| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 var __create = Object.create; 2 var __defProp = Object.defineProperty; 3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 4 var __getOwnPropNames = Object.getOwnPropertyNames; 5 var __getProtoOf = Object.getPrototypeOf; 6 var __hasOwnProp = Object.prototype.hasOwnProperty; 7 var __commonJS = (cb, mod) => function __require() { 8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 9 }; 10 var __copyProps = (to, from, except, desc) => { 11 if (from && typeof from === "object" || typeof from === "function") { 12 for (let key of __getOwnPropNames(from)) 13 if (!__hasOwnProp.call(to, key) && key !== except) 14 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 15 } 16 return to; 17 }; 18 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 19 // If the importer is in node compatibility mode or this is not an ESM 20 // file that has been converted to a CommonJS file using a Babel- 21 // compatible transform (i.e. "__esModule" has not been set), then set 22 // "default" to the CommonJS "module.exports" for node compatibility. 23 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 24 mod 25 )); 26 27 // package-external:@wordpress/core-data 28 var require_core_data = __commonJS({ 29 "package-external:@wordpress/core-data"(exports, module) { 30 module.exports = window.wp.coreData; 31 } 32 }); 33 34 // package-external:@wordpress/element 35 var require_element = __commonJS({ 36 "package-external:@wordpress/element"(exports, module) { 37 module.exports = window.wp.element; 38 } 39 }); 40 41 // package-external:@wordpress/i18n 42 var require_i18n = __commonJS({ 43 "package-external:@wordpress/i18n"(exports, module) { 44 module.exports = window.wp.i18n; 45 } 46 }); 47 48 // package-external:@wordpress/components 49 var require_components = __commonJS({ 50 "package-external:@wordpress/components"(exports, module) { 51 module.exports = window.wp.components; 52 } 53 }); 54 55 // vendor-external:react/jsx-runtime 56 var require_jsx_runtime = __commonJS({ 57 "vendor-external:react/jsx-runtime"(exports, module) { 58 module.exports = window.ReactJSXRuntime; 59 } 60 }); 61 62 // package-external:@wordpress/data 63 var require_data = __commonJS({ 64 "package-external:@wordpress/data"(exports, module) { 65 module.exports = window.wp.data; 66 } 67 }); 68 69 // package-external:@wordpress/preferences 70 var require_preferences = __commonJS({ 71 "package-external:@wordpress/preferences"(exports, module) { 72 module.exports = window.wp.preferences; 73 } 74 }); 75 76 // package-external:@wordpress/compose 77 var require_compose = __commonJS({ 78 "package-external:@wordpress/compose"(exports, module) { 79 module.exports = window.wp.compose; 80 } 81 }); 82 83 // package-external:@wordpress/primitives 84 var require_primitives = __commonJS({ 85 "package-external:@wordpress/primitives"(exports, module) { 86 module.exports = window.wp.primitives; 87 } 88 }); 89 90 // package-external:@wordpress/keycodes 91 var require_keycodes = __commonJS({ 92 "package-external:@wordpress/keycodes"(exports, module) { 93 module.exports = window.wp.keycodes; 94 } 95 }); 96 97 // package-external:@wordpress/private-apis 98 var require_private_apis = __commonJS({ 99 "package-external:@wordpress/private-apis"(exports, module) { 100 module.exports = window.wp.privateApis; 101 } 102 }); 103 104 // vendor-external:react 105 var require_react = __commonJS({ 106 "vendor-external:react"(exports, module) { 107 module.exports = window.React; 108 } 109 }); 110 111 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js 112 var require_use_sync_external_store_shim_development = __commonJS({ 113 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) { 114 "use strict"; 115 (function() { 116 function is(x2, y2) { 117 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 118 } 119 function useSyncExternalStore$2(subscribe2, getSnapshot) { 120 didWarnOld18Alpha || void 0 === React5.startTransition || (didWarnOld18Alpha = true, console.error( 121 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release." 122 )); 123 var value = getSnapshot(); 124 if (!didWarnUncachedGetSnapshot) { 125 var cachedValue = getSnapshot(); 126 objectIs(value, cachedValue) || (console.error( 127 "The result of getSnapshot should be cached to avoid an infinite loop" 128 ), didWarnUncachedGetSnapshot = true); 129 } 130 cachedValue = useState24({ 131 inst: { value, getSnapshot } 132 }); 133 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1]; 134 useLayoutEffect2( 135 function() { 136 inst.value = value; 137 inst.getSnapshot = getSnapshot; 138 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 139 }, 140 [subscribe2, value, getSnapshot] 141 ); 142 useEffect17( 143 function() { 144 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 145 return subscribe2(function() { 146 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 147 }); 148 }, 149 [subscribe2] 150 ); 151 useDebugValue(value); 152 return value; 153 } 154 function checkIfSnapshotChanged(inst) { 155 var latestGetSnapshot = inst.getSnapshot; 156 inst = inst.value; 157 try { 158 var nextValue = latestGetSnapshot(); 159 return !objectIs(inst, nextValue); 160 } catch (error) { 161 return true; 162 } 163 } 164 function useSyncExternalStore$1(subscribe2, getSnapshot) { 165 return getSnapshot(); 166 } 167 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 168 var React5 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState24 = React5.useState, useEffect17 = React5.useEffect, useLayoutEffect2 = React5.useLayoutEffect, useDebugValue = React5.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2; 169 exports.useSyncExternalStore = void 0 !== React5.useSyncExternalStore ? React5.useSyncExternalStore : shim; 170 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 171 })(); 172 } 173 }); 174 175 // node_modules/use-sync-external-store/shim/index.js 176 var require_shim = __commonJS({ 177 "node_modules/use-sync-external-store/shim/index.js"(exports, module) { 178 "use strict"; 179 if (false) { 180 module.exports = null; 181 } else { 182 module.exports = require_use_sync_external_store_shim_development(); 183 } 184 } 185 }); 186 187 // vendor-external:react-dom 188 var require_react_dom = __commonJS({ 189 "vendor-external:react-dom"(exports, module) { 190 module.exports = window.ReactDOM; 191 } 192 }); 193 194 // node_modules/remove-accents/index.js 195 var require_remove_accents = __commonJS({ 196 "node_modules/remove-accents/index.js"(exports, module) { 197 var characterMap = { 198 "\xC0": "A", 199 "\xC1": "A", 200 "\xC2": "A", 201 "\xC3": "A", 202 "\xC4": "A", 203 "\xC5": "A", 204 "\u1EA4": "A", 205 "\u1EAE": "A", 206 "\u1EB2": "A", 207 "\u1EB4": "A", 208 "\u1EB6": "A", 209 "\xC6": "AE", 210 "\u1EA6": "A", 211 "\u1EB0": "A", 212 "\u0202": "A", 213 "\u1EA2": "A", 214 "\u1EA0": "A", 215 "\u1EA8": "A", 216 "\u1EAA": "A", 217 "\u1EAC": "A", 218 "\xC7": "C", 219 "\u1E08": "C", 220 "\xC8": "E", 221 "\xC9": "E", 222 "\xCA": "E", 223 "\xCB": "E", 224 "\u1EBE": "E", 225 "\u1E16": "E", 226 "\u1EC0": "E", 227 "\u1E14": "E", 228 "\u1E1C": "E", 229 "\u0206": "E", 230 "\u1EBA": "E", 231 "\u1EBC": "E", 232 "\u1EB8": "E", 233 "\u1EC2": "E", 234 "\u1EC4": "E", 235 "\u1EC6": "E", 236 "\xCC": "I", 237 "\xCD": "I", 238 "\xCE": "I", 239 "\xCF": "I", 240 "\u1E2E": "I", 241 "\u020A": "I", 242 "\u1EC8": "I", 243 "\u1ECA": "I", 244 "\xD0": "D", 245 "\xD1": "N", 246 "\xD2": "O", 247 "\xD3": "O", 248 "\xD4": "O", 249 "\xD5": "O", 250 "\xD6": "O", 251 "\xD8": "O", 252 "\u1ED0": "O", 253 "\u1E4C": "O", 254 "\u1E52": "O", 255 "\u020E": "O", 256 "\u1ECE": "O", 257 "\u1ECC": "O", 258 "\u1ED4": "O", 259 "\u1ED6": "O", 260 "\u1ED8": "O", 261 "\u1EDC": "O", 262 "\u1EDE": "O", 263 "\u1EE0": "O", 264 "\u1EDA": "O", 265 "\u1EE2": "O", 266 "\xD9": "U", 267 "\xDA": "U", 268 "\xDB": "U", 269 "\xDC": "U", 270 "\u1EE6": "U", 271 "\u1EE4": "U", 272 "\u1EEC": "U", 273 "\u1EEE": "U", 274 "\u1EF0": "U", 275 "\xDD": "Y", 276 "\xE0": "a", 277 "\xE1": "a", 278 "\xE2": "a", 279 "\xE3": "a", 280 "\xE4": "a", 281 "\xE5": "a", 282 "\u1EA5": "a", 283 "\u1EAF": "a", 284 "\u1EB3": "a", 285 "\u1EB5": "a", 286 "\u1EB7": "a", 287 "\xE6": "ae", 288 "\u1EA7": "a", 289 "\u1EB1": "a", 290 "\u0203": "a", 291 "\u1EA3": "a", 292 "\u1EA1": "a", 293 "\u1EA9": "a", 294 "\u1EAB": "a", 295 "\u1EAD": "a", 296 "\xE7": "c", 297 "\u1E09": "c", 298 "\xE8": "e", 299 "\xE9": "e", 300 "\xEA": "e", 301 "\xEB": "e", 302 "\u1EBF": "e", 303 "\u1E17": "e", 304 "\u1EC1": "e", 305 "\u1E15": "e", 306 "\u1E1D": "e", 307 "\u0207": "e", 308 "\u1EBB": "e", 309 "\u1EBD": "e", 310 "\u1EB9": "e", 311 "\u1EC3": "e", 312 "\u1EC5": "e", 313 "\u1EC7": "e", 314 "\xEC": "i", 315 "\xED": "i", 316 "\xEE": "i", 317 "\xEF": "i", 318 "\u1E2F": "i", 319 "\u020B": "i", 320 "\u1EC9": "i", 321 "\u1ECB": "i", 322 "\xF0": "d", 323 "\xF1": "n", 324 "\xF2": "o", 325 "\xF3": "o", 326 "\xF4": "o", 327 "\xF5": "o", 328 "\xF6": "o", 329 "\xF8": "o", 330 "\u1ED1": "o", 331 "\u1E4D": "o", 332 "\u1E53": "o", 333 "\u020F": "o", 334 "\u1ECF": "o", 335 "\u1ECD": "o", 336 "\u1ED5": "o", 337 "\u1ED7": "o", 338 "\u1ED9": "o", 339 "\u1EDD": "o", 340 "\u1EDF": "o", 341 "\u1EE1": "o", 342 "\u1EDB": "o", 343 "\u1EE3": "o", 344 "\xF9": "u", 345 "\xFA": "u", 346 "\xFB": "u", 347 "\xFC": "u", 348 "\u1EE7": "u", 349 "\u1EE5": "u", 350 "\u1EED": "u", 351 "\u1EEF": "u", 352 "\u1EF1": "u", 353 "\xFD": "y", 354 "\xFF": "y", 355 "\u0100": "A", 356 "\u0101": "a", 357 "\u0102": "A", 358 "\u0103": "a", 359 "\u0104": "A", 360 "\u0105": "a", 361 "\u0106": "C", 362 "\u0107": "c", 363 "\u0108": "C", 364 "\u0109": "c", 365 "\u010A": "C", 366 "\u010B": "c", 367 "\u010C": "C", 368 "\u010D": "c", 369 "C\u0306": "C", 370 "c\u0306": "c", 371 "\u010E": "D", 372 "\u010F": "d", 373 "\u0110": "D", 374 "\u0111": "d", 375 "\u0112": "E", 376 "\u0113": "e", 377 "\u0114": "E", 378 "\u0115": "e", 379 "\u0116": "E", 380 "\u0117": "e", 381 "\u0118": "E", 382 "\u0119": "e", 383 "\u011A": "E", 384 "\u011B": "e", 385 "\u011C": "G", 386 "\u01F4": "G", 387 "\u011D": "g", 388 "\u01F5": "g", 389 "\u011E": "G", 390 "\u011F": "g", 391 "\u0120": "G", 392 "\u0121": "g", 393 "\u0122": "G", 394 "\u0123": "g", 395 "\u0124": "H", 396 "\u0125": "h", 397 "\u0126": "H", 398 "\u0127": "h", 399 "\u1E2A": "H", 400 "\u1E2B": "h", 401 "\u0128": "I", 402 "\u0129": "i", 403 "\u012A": "I", 404 "\u012B": "i", 405 "\u012C": "I", 406 "\u012D": "i", 407 "\u012E": "I", 408 "\u012F": "i", 409 "\u0130": "I", 410 "\u0131": "i", 411 "\u0132": "IJ", 412 "\u0133": "ij", 413 "\u0134": "J", 414 "\u0135": "j", 415 "\u0136": "K", 416 "\u0137": "k", 417 "\u1E30": "K", 418 "\u1E31": "k", 419 "K\u0306": "K", 420 "k\u0306": "k", 421 "\u0139": "L", 422 "\u013A": "l", 423 "\u013B": "L", 424 "\u013C": "l", 425 "\u013D": "L", 426 "\u013E": "l", 427 "\u013F": "L", 428 "\u0140": "l", 429 "\u0141": "l", 430 "\u0142": "l", 431 "\u1E3E": "M", 432 "\u1E3F": "m", 433 "M\u0306": "M", 434 "m\u0306": "m", 435 "\u0143": "N", 436 "\u0144": "n", 437 "\u0145": "N", 438 "\u0146": "n", 439 "\u0147": "N", 440 "\u0148": "n", 441 "\u0149": "n", 442 "N\u0306": "N", 443 "n\u0306": "n", 444 "\u014C": "O", 445 "\u014D": "o", 446 "\u014E": "O", 447 "\u014F": "o", 448 "\u0150": "O", 449 "\u0151": "o", 450 "\u0152": "OE", 451 "\u0153": "oe", 452 "P\u0306": "P", 453 "p\u0306": "p", 454 "\u0154": "R", 455 "\u0155": "r", 456 "\u0156": "R", 457 "\u0157": "r", 458 "\u0158": "R", 459 "\u0159": "r", 460 "R\u0306": "R", 461 "r\u0306": "r", 462 "\u0212": "R", 463 "\u0213": "r", 464 "\u015A": "S", 465 "\u015B": "s", 466 "\u015C": "S", 467 "\u015D": "s", 468 "\u015E": "S", 469 "\u0218": "S", 470 "\u0219": "s", 471 "\u015F": "s", 472 "\u0160": "S", 473 "\u0161": "s", 474 "\u0162": "T", 475 "\u0163": "t", 476 "\u021B": "t", 477 "\u021A": "T", 478 "\u0164": "T", 479 "\u0165": "t", 480 "\u0166": "T", 481 "\u0167": "t", 482 "T\u0306": "T", 483 "t\u0306": "t", 484 "\u0168": "U", 485 "\u0169": "u", 486 "\u016A": "U", 487 "\u016B": "u", 488 "\u016C": "U", 489 "\u016D": "u", 490 "\u016E": "U", 491 "\u016F": "u", 492 "\u0170": "U", 493 "\u0171": "u", 494 "\u0172": "U", 495 "\u0173": "u", 496 "\u0216": "U", 497 "\u0217": "u", 498 "V\u0306": "V", 499 "v\u0306": "v", 500 "\u0174": "W", 501 "\u0175": "w", 502 "\u1E82": "W", 503 "\u1E83": "w", 504 "X\u0306": "X", 505 "x\u0306": "x", 506 "\u0176": "Y", 507 "\u0177": "y", 508 "\u0178": "Y", 509 "Y\u0306": "Y", 510 "y\u0306": "y", 511 "\u0179": "Z", 512 "\u017A": "z", 513 "\u017B": "Z", 514 "\u017C": "z", 515 "\u017D": "Z", 516 "\u017E": "z", 517 "\u017F": "s", 518 "\u0192": "f", 519 "\u01A0": "O", 520 "\u01A1": "o", 521 "\u01AF": "U", 522 "\u01B0": "u", 523 "\u01CD": "A", 524 "\u01CE": "a", 525 "\u01CF": "I", 526 "\u01D0": "i", 527 "\u01D1": "O", 528 "\u01D2": "o", 529 "\u01D3": "U", 530 "\u01D4": "u", 531 "\u01D5": "U", 532 "\u01D6": "u", 533 "\u01D7": "U", 534 "\u01D8": "u", 535 "\u01D9": "U", 536 "\u01DA": "u", 537 "\u01DB": "U", 538 "\u01DC": "u", 539 "\u1EE8": "U", 540 "\u1EE9": "u", 541 "\u1E78": "U", 542 "\u1E79": "u", 543 "\u01FA": "A", 544 "\u01FB": "a", 545 "\u01FC": "AE", 546 "\u01FD": "ae", 547 "\u01FE": "O", 548 "\u01FF": "o", 549 "\xDE": "TH", 550 "\xFE": "th", 551 "\u1E54": "P", 552 "\u1E55": "p", 553 "\u1E64": "S", 554 "\u1E65": "s", 555 "X\u0301": "X", 556 "x\u0301": "x", 557 "\u0403": "\u0413", 558 "\u0453": "\u0433", 559 "\u040C": "\u041A", 560 "\u045C": "\u043A", 561 "A\u030B": "A", 562 "a\u030B": "a", 563 "E\u030B": "E", 564 "e\u030B": "e", 565 "I\u030B": "I", 566 "i\u030B": "i", 567 "\u01F8": "N", 568 "\u01F9": "n", 569 "\u1ED2": "O", 570 "\u1ED3": "o", 571 "\u1E50": "O", 572 "\u1E51": "o", 573 "\u1EEA": "U", 574 "\u1EEB": "u", 575 "\u1E80": "W", 576 "\u1E81": "w", 577 "\u1EF2": "Y", 578 "\u1EF3": "y", 579 "\u0200": "A", 580 "\u0201": "a", 581 "\u0204": "E", 582 "\u0205": "e", 583 "\u0208": "I", 584 "\u0209": "i", 585 "\u020C": "O", 586 "\u020D": "o", 587 "\u0210": "R", 588 "\u0211": "r", 589 "\u0214": "U", 590 "\u0215": "u", 591 "B\u030C": "B", 592 "b\u030C": "b", 593 "\u010C\u0323": "C", 594 "\u010D\u0323": "c", 595 "\xCA\u030C": "E", 596 "\xEA\u030C": "e", 597 "F\u030C": "F", 598 "f\u030C": "f", 599 "\u01E6": "G", 600 "\u01E7": "g", 601 "\u021E": "H", 602 "\u021F": "h", 603 "J\u030C": "J", 604 "\u01F0": "j", 605 "\u01E8": "K", 606 "\u01E9": "k", 607 "M\u030C": "M", 608 "m\u030C": "m", 609 "P\u030C": "P", 610 "p\u030C": "p", 611 "Q\u030C": "Q", 612 "q\u030C": "q", 613 "\u0158\u0329": "R", 614 "\u0159\u0329": "r", 615 "\u1E66": "S", 616 "\u1E67": "s", 617 "V\u030C": "V", 618 "v\u030C": "v", 619 "W\u030C": "W", 620 "w\u030C": "w", 621 "X\u030C": "X", 622 "x\u030C": "x", 623 "Y\u030C": "Y", 624 "y\u030C": "y", 625 "A\u0327": "A", 626 "a\u0327": "a", 627 "B\u0327": "B", 628 "b\u0327": "b", 629 "\u1E10": "D", 630 "\u1E11": "d", 631 "\u0228": "E", 632 "\u0229": "e", 633 "\u0190\u0327": "E", 634 "\u025B\u0327": "e", 635 "\u1E28": "H", 636 "\u1E29": "h", 637 "I\u0327": "I", 638 "i\u0327": "i", 639 "\u0197\u0327": "I", 640 "\u0268\u0327": "i", 641 "M\u0327": "M", 642 "m\u0327": "m", 643 "O\u0327": "O", 644 "o\u0327": "o", 645 "Q\u0327": "Q", 646 "q\u0327": "q", 647 "U\u0327": "U", 648 "u\u0327": "u", 649 "X\u0327": "X", 650 "x\u0327": "x", 651 "Z\u0327": "Z", 652 "z\u0327": "z", 653 "\u0439": "\u0438", 654 "\u0419": "\u0418", 655 "\u0451": "\u0435", 656 "\u0401": "\u0415" 657 }; 658 var chars = Object.keys(characterMap).join("|"); 659 var allAccents = new RegExp(chars, "g"); 660 var firstAccent = new RegExp(chars, ""); 661 function matcher(match2) { 662 return characterMap[match2]; 663 } 664 var removeAccents2 = function(string) { 665 return string.replace(allAccents, matcher); 666 }; 667 var hasAccents = function(string) { 668 return !!string.match(firstAccent); 669 }; 670 module.exports = removeAccents2; 671 module.exports.has = hasAccents; 672 module.exports.remove = removeAccents2; 673 } 674 }); 675 676 // node_modules/fast-deep-equal/es6/index.js 677 var require_es6 = __commonJS({ 678 "node_modules/fast-deep-equal/es6/index.js"(exports, module) { 679 "use strict"; 680 module.exports = function equal(a2, b2) { 681 if (a2 === b2) return true; 682 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") { 683 if (a2.constructor !== b2.constructor) return false; 684 var length, i2, keys; 685 if (Array.isArray(a2)) { 686 length = a2.length; 687 if (length != b2.length) return false; 688 for (i2 = length; i2-- !== 0; ) 689 if (!equal(a2[i2], b2[i2])) return false; 690 return true; 691 } 692 if (a2 instanceof Map && b2 instanceof Map) { 693 if (a2.size !== b2.size) return false; 694 for (i2 of a2.entries()) 695 if (!b2.has(i2[0])) return false; 696 for (i2 of a2.entries()) 697 if (!equal(i2[1], b2.get(i2[0]))) return false; 698 return true; 699 } 700 if (a2 instanceof Set && b2 instanceof Set) { 701 if (a2.size !== b2.size) return false; 702 for (i2 of a2.entries()) 703 if (!b2.has(i2[0])) return false; 704 return true; 705 } 706 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) { 707 length = a2.length; 708 if (length != b2.length) return false; 709 for (i2 = length; i2-- !== 0; ) 710 if (a2[i2] !== b2[i2]) return false; 711 return true; 712 } 713 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags; 714 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf(); 715 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString(); 716 keys = Object.keys(a2); 717 length = keys.length; 718 if (length !== Object.keys(b2).length) return false; 719 for (i2 = length; i2-- !== 0; ) 720 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false; 721 for (i2 = length; i2-- !== 0; ) { 722 var key = keys[i2]; 723 if (!equal(a2[key], b2[key])) return false; 724 } 725 return true; 726 } 727 return a2 !== a2 && b2 !== b2; 728 }; 729 } 730 }); 731 732 // package-external:@wordpress/warning 733 var require_warning = __commonJS({ 734 "package-external:@wordpress/warning"(exports, module) { 735 module.exports = window.wp.warning; 736 } 737 }); 738 739 // package-external:@wordpress/date 740 var require_date = __commonJS({ 741 "package-external:@wordpress/date"(exports, module) { 742 module.exports = window.wp.date; 743 } 744 }); 745 746 // package-external:@wordpress/editor 747 var require_editor = __commonJS({ 748 "package-external:@wordpress/editor"(exports, module) { 749 module.exports = window.wp.editor; 750 } 751 }); 752 753 // package-external:@wordpress/notices 754 var require_notices = __commonJS({ 755 "package-external:@wordpress/notices"(exports, module) { 756 module.exports = window.wp.notices; 757 } 758 }); 759 760 // routes/navigation-list/stage.tsx 761 var import_core_data2 = __toESM(require_core_data()); 762 var import_element55 = __toESM(require_element()); 763 import { useNavigate as useNavigate3, useSearch } from "@wordpress/route"; 764 765 // node_modules/clsx/dist/clsx.mjs 766 function r(e2) { 767 var t2, f2, n2 = ""; 768 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2; 769 else if ("object" == typeof e2) if (Array.isArray(e2)) { 770 var o2 = e2.length; 771 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2); 772 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2); 773 return n2; 774 } 775 function clsx() { 776 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2); 777 return n2; 778 } 779 var clsx_default = clsx; 780 781 // packages/admin-ui/build-module/navigable-region/index.js 782 var import_element = __toESM(require_element()); 783 var import_jsx_runtime = __toESM(require_jsx_runtime()); 784 var NavigableRegion = (0, import_element.forwardRef)( 785 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => { 786 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( 787 Tag, 788 { 789 ref, 790 className: clsx_default("admin-ui-navigable-region", className), 791 "aria-label": ariaLabel, 792 role: "region", 793 tabIndex: "-1", 794 ...props, 795 children 796 } 797 ); 798 } 799 ); 800 NavigableRegion.displayName = "NavigableRegion"; 801 var navigable_region_default = NavigableRegion; 802 803 // packages/admin-ui/build-module/page/header.js 804 var import_components2 = __toESM(require_components()); 805 806 // packages/admin-ui/build-module/page/sidebar-toggle-slot.js 807 var import_components = __toESM(require_components()); 808 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle"); 809 810 // packages/admin-ui/build-module/page/header.js 811 var import_jsx_runtime2 = __toESM(require_jsx_runtime()); 812 function Header({ 813 breadcrumbs, 814 badges, 815 title, 816 subTitle, 817 actions, 818 showSidebarToggle = true 819 }) { 820 return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_components2.__experimentalVStack, { className: "admin-ui-page__header", as: "header", children: [ 821 /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_components2.__experimentalHStack, { justify: "space-between", spacing: 2, children: [ 822 /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_components2.__experimentalHStack, { spacing: 2, justify: "left", children: [ 823 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( 824 SidebarToggleSlot, 825 { 826 bubblesVirtually: true, 827 className: "admin-ui-page__sidebar-toggle-slot" 828 } 829 ), 830 title && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_components2.__experimentalHeading, { as: "h2", level: 3, weight: 500, truncate: true, children: title }), 831 breadcrumbs, 832 badges 833 ] }), 834 /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( 835 import_components2.__experimentalHStack, 836 { 837 style: { width: "auto", flexShrink: 0 }, 838 spacing: 2, 839 className: "admin-ui-page__header-actions", 840 children: actions 841 } 842 ) 843 ] }), 844 subTitle && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "admin-ui-page__header-subtitle", children: subTitle }) 845 ] }); 846 } 847 848 // packages/admin-ui/build-module/page/index.js 849 var import_jsx_runtime3 = __toESM(require_jsx_runtime()); 850 function Page({ 851 breadcrumbs, 852 badges, 853 title, 854 subTitle, 855 children, 856 className, 857 actions, 858 hasPadding = false, 859 showSidebarToggle = true 860 }) { 861 const classes = clsx_default("admin-ui-page", className); 862 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(navigable_region_default, { className: classes, ariaLabel: title, children: [ 863 (title || breadcrumbs || badges) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)( 864 Header, 865 { 866 breadcrumbs, 867 badges, 868 title, 869 subTitle, 870 actions, 871 showSidebarToggle 872 } 873 ), 874 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "admin-ui-page__content has-padding", children }) : children 875 ] }); 876 } 877 Page.SidebarToggleFill = SidebarToggleFill; 878 var page_default = Page; 879 880 // routes/navigation-list/stage.tsx 881 var import_i18n44 = __toESM(require_i18n()); 882 883 // node_modules/dequal/dist/index.mjs 884 var has = Object.prototype.hasOwnProperty; 885 function find(iter, tar, key) { 886 for (key of iter.keys()) { 887 if (dequal(key, tar)) return key; 888 } 889 } 890 function dequal(foo, bar) { 891 var ctor, len, tmp; 892 if (foo === bar) return true; 893 if (foo && bar && (ctor = foo.constructor) === bar.constructor) { 894 if (ctor === Date) return foo.getTime() === bar.getTime(); 895 if (ctor === RegExp) return foo.toString() === bar.toString(); 896 if (ctor === Array) { 897 if ((len = foo.length) === bar.length) { 898 while (len-- && dequal(foo[len], bar[len])) ; 899 } 900 return len === -1; 901 } 902 if (ctor === Set) { 903 if (foo.size !== bar.size) { 904 return false; 905 } 906 for (len of foo) { 907 tmp = len; 908 if (tmp && typeof tmp === "object") { 909 tmp = find(bar, tmp); 910 if (!tmp) return false; 911 } 912 if (!bar.has(tmp)) return false; 913 } 914 return true; 915 } 916 if (ctor === Map) { 917 if (foo.size !== bar.size) { 918 return false; 919 } 920 for (len of foo) { 921 tmp = len[0]; 922 if (tmp && typeof tmp === "object") { 923 tmp = find(bar, tmp); 924 if (!tmp) return false; 925 } 926 if (!dequal(len[1], bar.get(tmp))) { 927 return false; 928 } 929 } 930 return true; 931 } 932 if (ctor === ArrayBuffer) { 933 foo = new Uint8Array(foo); 934 bar = new Uint8Array(bar); 935 } else if (ctor === DataView) { 936 if ((len = foo.byteLength) === bar.byteLength) { 937 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ; 938 } 939 return len === -1; 940 } 941 if (ArrayBuffer.isView(foo)) { 942 if ((len = foo.byteLength) === bar.byteLength) { 943 while (len-- && foo[len] === bar[len]) ; 944 } 945 return len === -1; 946 } 947 if (!ctor || typeof foo === "object") { 948 len = 0; 949 for (ctor in foo) { 950 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false; 951 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false; 952 } 953 return Object.keys(bar).length === len; 954 } 955 } 956 return foo !== foo && bar !== bar; 957 } 958 959 // packages/views/build-module/preference-keys.js 960 function generatePreferenceKey(kind, name, slug) { 961 return `dataviews-$kind}-$name}-$slug}`; 962 } 963 964 // packages/views/build-module/use-view.js 965 var import_element2 = __toESM(require_element()); 966 var import_data = __toESM(require_data()); 967 var import_preferences = __toESM(require_preferences()); 968 function omit(obj, keys) { 969 const result = { ...obj }; 970 for (const key of keys) { 971 delete result[key]; 972 } 973 return result; 974 } 975 function useView(config) { 976 const { kind, name, slug, defaultView, queryParams, onChangeQueryParams } = config; 977 const preferenceKey = generatePreferenceKey(kind, name, slug); 978 const persistedView = (0, import_data.useSelect)( 979 (select2) => { 980 return select2(import_preferences.store).get( 981 "core/views", 982 preferenceKey 983 ); 984 }, 985 [preferenceKey] 986 ); 987 const { set } = (0, import_data.useDispatch)(import_preferences.store); 988 const baseView = persistedView ?? defaultView; 989 const page = Number(queryParams?.page ?? baseView.page ?? 1); 990 const search = queryParams?.search ?? baseView.search ?? ""; 991 const view = (0, import_element2.useMemo)(() => { 992 return { 993 ...baseView, 994 page, 995 search 996 }; 997 }, [baseView, page, search]); 998 const isModified = !!persistedView; 999 const updateView = (0, import_element2.useCallback)( 1000 (newView) => { 1001 const urlParams = { 1002 page: newView?.page, 1003 search: newView?.search 1004 }; 1005 const preferenceView = omit(newView, ["page", "search"]); 1006 if (onChangeQueryParams && !dequal(urlParams, { page, search })) { 1007 onChangeQueryParams(urlParams); 1008 } 1009 if (!dequal(baseView, preferenceView)) { 1010 if (dequal(preferenceView, defaultView)) { 1011 set("core/views", preferenceKey, void 0); 1012 } else { 1013 set("core/views", preferenceKey, preferenceView); 1014 } 1015 } 1016 }, 1017 [ 1018 onChangeQueryParams, 1019 page, 1020 search, 1021 baseView, 1022 defaultView, 1023 set, 1024 preferenceKey 1025 ] 1026 ); 1027 const resetToDefault = (0, import_element2.useCallback)(() => { 1028 set("core/views", preferenceKey, void 0); 1029 }, [preferenceKey, set]); 1030 return { 1031 view, 1032 isModified, 1033 updateView, 1034 resetToDefault 1035 }; 1036 } 1037 1038 // packages/views/build-module/load-view.js 1039 var import_data2 = __toESM(require_data()); 1040 var import_preferences2 = __toESM(require_preferences()); 1041 1042 // packages/dataviews/build-module/components/dataviews/index.js 1043 var import_components51 = __toESM(require_components()); 1044 var import_element53 = __toESM(require_element()); 1045 var import_compose11 = __toESM(require_compose()); 1046 1047 // packages/dataviews/build-module/components/dataviews-context/index.js 1048 var import_element3 = __toESM(require_element()); 1049 1050 // packages/dataviews/build-module/constants.js 1051 var import_i18n = __toESM(require_i18n()); 1052 1053 // packages/icons/build-module/library/arrow-down.js 1054 var import_primitives = __toESM(require_primitives()); 1055 var import_jsx_runtime4 = __toESM(require_jsx_runtime()); 1056 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) }); 1057 1058 // packages/icons/build-module/library/arrow-left.js 1059 var import_primitives2 = __toESM(require_primitives()); 1060 var import_jsx_runtime5 = __toESM(require_jsx_runtime()); 1061 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) }); 1062 1063 // packages/icons/build-module/library/arrow-right.js 1064 var import_primitives3 = __toESM(require_primitives()); 1065 var import_jsx_runtime6 = __toESM(require_jsx_runtime()); 1066 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) }); 1067 1068 // packages/icons/build-module/library/arrow-up.js 1069 var import_primitives4 = __toESM(require_primitives()); 1070 var import_jsx_runtime7 = __toESM(require_jsx_runtime()); 1071 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) }); 1072 1073 // packages/icons/build-module/library/block-table.js 1074 var import_primitives5 = __toESM(require_primitives()); 1075 var import_jsx_runtime8 = __toESM(require_jsx_runtime()); 1076 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives5.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives5.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) }); 1077 1078 // packages/icons/build-module/library/category.js 1079 var import_primitives6 = __toESM(require_primitives()); 1080 var import_jsx_runtime9 = __toESM(require_jsx_runtime()); 1081 var category_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives6.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( 1082 import_primitives6.Path, 1083 { 1084 d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z", 1085 fillRule: "evenodd", 1086 clipRule: "evenodd" 1087 } 1088 ) }); 1089 1090 // packages/icons/build-module/library/check.js 1091 var import_primitives7 = __toESM(require_primitives()); 1092 var import_jsx_runtime10 = __toESM(require_jsx_runtime()); 1093 var check_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives7.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) }); 1094 1095 // packages/icons/build-module/library/close-small.js 1096 var import_primitives8 = __toESM(require_primitives()); 1097 var import_jsx_runtime11 = __toESM(require_jsx_runtime()); 1098 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives8.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) }); 1099 1100 // packages/icons/build-module/library/cog.js 1101 var import_primitives9 = __toESM(require_primitives()); 1102 var import_jsx_runtime12 = __toESM(require_jsx_runtime()); 1103 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 1104 import_primitives9.Path, 1105 { 1106 fillRule: "evenodd", 1107 d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z", 1108 clipRule: "evenodd" 1109 } 1110 ) }); 1111 1112 // packages/icons/build-module/library/envelope.js 1113 var import_primitives10 = __toESM(require_primitives()); 1114 var import_jsx_runtime13 = __toESM(require_jsx_runtime()); 1115 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)( 1116 import_primitives10.Path, 1117 { 1118 fillRule: "evenodd", 1119 clipRule: "evenodd", 1120 d: "M3 7c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm2-.5h14c.3 0 .5.2.5.5v1L12 13.5 4.5 7.9V7c0-.3.2-.5.5-.5Zm-.5 3.3V17c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V9.8L12 15.4 4.5 9.8Z" 1121 } 1122 ) }); 1123 1124 // packages/icons/build-module/library/error.js 1125 var import_primitives11 = __toESM(require_primitives()); 1126 var import_jsx_runtime14 = __toESM(require_jsx_runtime()); 1127 var error_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives11.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( 1128 import_primitives11.Path, 1129 { 1130 fillRule: "evenodd", 1131 clipRule: "evenodd", 1132 d: "M12.218 5.377a.25.25 0 0 0-.436 0l-7.29 12.96a.25.25 0 0 0 .218.373h14.58a.25.25 0 0 0 .218-.372l-7.29-12.96Zm-1.743-.735c.669-1.19 2.381-1.19 3.05 0l7.29 12.96a1.75 1.75 0 0 1-1.525 2.608H4.71a1.75 1.75 0 0 1-1.525-2.608l7.29-12.96ZM12.75 17.46h-1.5v-1.5h1.5v1.5Zm-1.5-3h1.5v-5h-1.5v5Z" 1133 } 1134 ) }); 1135 1136 // packages/icons/build-module/library/format-list-bullets-rtl.js 1137 var import_primitives12 = __toESM(require_primitives()); 1138 var import_jsx_runtime15 = __toESM(require_jsx_runtime()); 1139 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives12.Path, { d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" }) }); 1140 1141 // packages/icons/build-module/library/format-list-bullets.js 1142 var import_primitives13 = __toESM(require_primitives()); 1143 var import_jsx_runtime16 = __toESM(require_jsx_runtime()); 1144 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives13.Path, { d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) }); 1145 1146 // packages/icons/build-module/library/funnel.js 1147 var import_primitives14 = __toESM(require_primitives()); 1148 var import_jsx_runtime17 = __toESM(require_jsx_runtime()); 1149 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives14.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives14.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) }); 1150 1151 // packages/icons/build-module/library/link.js 1152 var import_primitives15 = __toESM(require_primitives()); 1153 var import_jsx_runtime18 = __toESM(require_jsx_runtime()); 1154 var link_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives15.Path, { d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" }) }); 1155 1156 // packages/icons/build-module/library/mobile.js 1157 var import_primitives16 = __toESM(require_primitives()); 1158 var import_jsx_runtime19 = __toESM(require_jsx_runtime()); 1159 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives16.Path, { d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z" }) }); 1160 1161 // packages/icons/build-module/library/more-vertical.js 1162 var import_primitives17 = __toESM(require_primitives()); 1163 var import_jsx_runtime20 = __toESM(require_jsx_runtime()); 1164 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives17.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) }); 1165 1166 // packages/icons/build-module/library/next.js 1167 var import_primitives18 = __toESM(require_primitives()); 1168 var import_jsx_runtime21 = __toESM(require_jsx_runtime()); 1169 var next_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives18.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) }); 1170 1171 // packages/icons/build-module/library/pencil.js 1172 var import_primitives19 = __toESM(require_primitives()); 1173 var import_jsx_runtime22 = __toESM(require_jsx_runtime()); 1174 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives19.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) }); 1175 1176 // packages/icons/build-module/library/previous.js 1177 var import_primitives20 = __toESM(require_primitives()); 1178 var import_jsx_runtime23 = __toESM(require_jsx_runtime()); 1179 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives20.Path, { d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" }) }); 1180 1181 // packages/icons/build-module/library/scheduled.js 1182 var import_primitives21 = __toESM(require_primitives()); 1183 var import_jsx_runtime24 = __toESM(require_jsx_runtime()); 1184 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( 1185 import_primitives21.Path, 1186 { 1187 fillRule: "evenodd", 1188 clipRule: "evenodd", 1189 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z" 1190 } 1191 ) }); 1192 1193 // packages/icons/build-module/library/search.js 1194 var import_primitives22 = __toESM(require_primitives()); 1195 var import_jsx_runtime25 = __toESM(require_jsx_runtime()); 1196 var search_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives22.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" }) }); 1197 1198 // packages/icons/build-module/library/seen.js 1199 var import_primitives23 = __toESM(require_primitives()); 1200 var import_jsx_runtime26 = __toESM(require_jsx_runtime()); 1201 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives23.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives23.Path, { d: "M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z" }) }); 1202 1203 // packages/icons/build-module/library/unseen.js 1204 var import_primitives24 = __toESM(require_primitives()); 1205 var import_jsx_runtime27 = __toESM(require_jsx_runtime()); 1206 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives24.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives24.Path, { d: "M20.7 12.7s0-.1-.1-.2c0-.2-.2-.4-.4-.6-.3-.5-.9-1.2-1.6-1.8-.7-.6-1.5-1.3-2.6-1.8l-.6 1.4c.9.4 1.6 1 2.1 1.5.6.6 1.1 1.2 1.4 1.6.1.2.3.4.3.5v.1l.7-.3.7-.3Zm-5.2-9.3-1.8 4c-.5-.1-1.1-.2-1.7-.2-3 0-5.2 1.4-6.6 2.7-.7.7-1.2 1.3-1.6 1.8-.2.3-.3.5-.4.6 0 0 0 .1-.1.2s0 0 .7.3l.7.3V13c0-.1.2-.3.3-.5.3-.4.7-1 1.4-1.6 1.2-1.2 3-2.3 5.5-2.3H13v.3c-.4 0-.8-.1-1.1-.1-1.9 0-3.5 1.6-3.5 3.5s.6 2.3 1.6 2.9l-2 4.4.9.4 7.6-16.2-.9-.4Zm-3 12.6c1.7-.2 3-1.7 3-3.5s-.2-1.4-.6-1.9L12.4 16Z" }) }); 1207 1208 // packages/dataviews/build-module/constants.js 1209 var OPERATOR_IS_ANY = "isAny"; 1210 var OPERATOR_IS_NONE = "isNone"; 1211 var OPERATOR_IS_ALL = "isAll"; 1212 var OPERATOR_IS_NOT_ALL = "isNotAll"; 1213 var OPERATOR_BETWEEN = "between"; 1214 var OPERATOR_IN_THE_PAST = "inThePast"; 1215 var OPERATOR_OVER = "over"; 1216 var OPERATOR_IS = "is"; 1217 var OPERATOR_IS_NOT = "isNot"; 1218 var OPERATOR_LESS_THAN = "lessThan"; 1219 var OPERATOR_GREATER_THAN = "greaterThan"; 1220 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual"; 1221 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual"; 1222 var OPERATOR_BEFORE = "before"; 1223 var OPERATOR_AFTER = "after"; 1224 var OPERATOR_BEFORE_INC = "beforeInc"; 1225 var OPERATOR_AFTER_INC = "afterInc"; 1226 var OPERATOR_CONTAINS = "contains"; 1227 var OPERATOR_NOT_CONTAINS = "notContains"; 1228 var OPERATOR_STARTS_WITH = "startsWith"; 1229 var OPERATOR_ON = "on"; 1230 var OPERATOR_NOT_ON = "notOn"; 1231 var SORTING_DIRECTIONS = ["asc", "desc"]; 1232 var sortArrows = { asc: "\u2191", desc: "\u2193" }; 1233 var sortValues = { asc: "ascending", desc: "descending" }; 1234 var sortLabels = { 1235 asc: (0, import_i18n.__)("Sort ascending"), 1236 desc: (0, import_i18n.__)("Sort descending") 1237 }; 1238 var sortIcons = { 1239 asc: arrow_up_default, 1240 desc: arrow_down_default 1241 }; 1242 var LAYOUT_TABLE = "table"; 1243 var LAYOUT_GRID = "grid"; 1244 var LAYOUT_LIST = "list"; 1245 var LAYOUT_ACTIVITY = "activity"; 1246 var LAYOUT_PICKER_GRID = "pickerGrid"; 1247 var LAYOUT_PICKER_TABLE = "pickerTable"; 1248 1249 // packages/dataviews/build-module/components/dataviews-context/index.js 1250 var DataViewsContext = (0, import_element3.createContext)({ 1251 view: { type: LAYOUT_TABLE }, 1252 onChangeView: () => { 1253 }, 1254 fields: [], 1255 data: [], 1256 paginationInfo: { 1257 totalItems: 0, 1258 totalPages: 0 1259 }, 1260 selection: [], 1261 onChangeSelection: () => { 1262 }, 1263 setOpenedFilter: () => { 1264 }, 1265 openedFilter: null, 1266 getItemId: (item) => item.id, 1267 isItemClickable: () => true, 1268 renderItemLink: void 0, 1269 containerWidth: 0, 1270 containerRef: (0, import_element3.createRef)(), 1271 resizeObserverRef: () => { 1272 }, 1273 defaultLayouts: { list: {}, grid: {}, table: {} }, 1274 filters: [], 1275 isShowingFilter: false, 1276 setIsShowingFilter: () => { 1277 }, 1278 hasInfiniteScrollHandler: false, 1279 config: { 1280 perPageSizes: [] 1281 } 1282 }); 1283 DataViewsContext.displayName = "DataViewsContext"; 1284 var dataviews_context_default = DataViewsContext; 1285 1286 // packages/dataviews/build-module/dataviews-layouts/index.js 1287 var import_i18n20 = __toESM(require_i18n()); 1288 1289 // packages/dataviews/build-module/dataviews-layouts/table/index.js 1290 var import_i18n8 = __toESM(require_i18n()); 1291 var import_components9 = __toESM(require_components()); 1292 var import_element10 = __toESM(require_element()); 1293 var import_keycodes = __toESM(require_keycodes()); 1294 1295 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.js 1296 var import_components3 = __toESM(require_components()); 1297 var import_i18n2 = __toESM(require_i18n()); 1298 var import_jsx_runtime28 = __toESM(require_jsx_runtime()); 1299 function DataViewsSelectionCheckbox({ 1300 selection, 1301 onChangeSelection, 1302 item, 1303 getItemId: getItemId2, 1304 titleField, 1305 disabled, 1306 ...extraProps 1307 }) { 1308 const id = getItemId2(item); 1309 const checked = !disabled && selection.includes(id); 1310 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)"); 1311 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 1312 import_components3.CheckboxControl, 1313 { 1314 className: "dataviews-selection-checkbox", 1315 "aria-label": selectionLabel, 1316 "aria-disabled": disabled, 1317 checked, 1318 onChange: () => { 1319 if (disabled) { 1320 return; 1321 } 1322 onChangeSelection( 1323 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 1324 ); 1325 }, 1326 ...extraProps 1327 } 1328 ); 1329 } 1330 1331 // packages/dataviews/build-module/components/dataviews-item-actions/index.js 1332 var import_components4 = __toESM(require_components()); 1333 var import_i18n3 = __toESM(require_i18n()); 1334 var import_element4 = __toESM(require_element()); 1335 var import_data3 = __toESM(require_data()); 1336 var import_compose = __toESM(require_compose()); 1337 1338 // packages/dataviews/build-module/lock-unlock.js 1339 var import_private_apis = __toESM(require_private_apis()); 1340 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 1341 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 1342 "@wordpress/dataviews" 1343 ); 1344 1345 // packages/dataviews/build-module/components/dataviews-item-actions/index.js 1346 var import_jsx_runtime29 = __toESM(require_jsx_runtime()); 1347 var { Menu, kebabCase } = unlock(import_components4.privateApis); 1348 function ButtonTrigger({ 1349 action, 1350 onClick, 1351 items, 1352 variant 1353 }) { 1354 const label = typeof action.label === "string" ? action.label : action.label(items); 1355 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1356 import_components4.Button, 1357 { 1358 disabled: !!action.disabled, 1359 accessibleWhenDisabled: true, 1360 size: "compact", 1361 variant, 1362 onClick, 1363 children: label 1364 } 1365 ); 1366 } 1367 function MenuItemTrigger({ 1368 action, 1369 onClick, 1370 items 1371 }) { 1372 const label = typeof action.label === "string" ? action.label : action.label(items); 1373 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Menu.ItemLabel, { children: label }) }); 1374 } 1375 function ActionModal({ 1376 action, 1377 items, 1378 closeModal 1379 }) { 1380 const label = typeof action.label === "string" ? action.label : action.label(items); 1381 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader; 1382 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1383 import_components4.Modal, 1384 { 1385 title: modalHeader || label, 1386 __experimentalHideHeader: !!action.hideModalHeader, 1387 onRequestClose: closeModal, 1388 focusOnMount: action.modalFocusOnMount ?? true, 1389 size: action.modalSize || "medium", 1390 overlayClassName: `dataviews-action-modal dataviews-action-modal__$kebabCase( 1391 action.id 1392 )}`, 1393 children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(action.RenderModal, { items, closeModal }) 1394 } 1395 ); 1396 } 1397 function ActionsMenuGroup({ 1398 actions, 1399 item, 1400 registry, 1401 setActiveModalAction 1402 }) { 1403 const { primaryActions, regularActions } = (0, import_element4.useMemo)(() => { 1404 return actions.reduce( 1405 (acc, action) => { 1406 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action); 1407 return acc; 1408 }, 1409 { 1410 primaryActions: [], 1411 regularActions: [] 1412 } 1413 ); 1414 }, [actions]); 1415 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1416 MenuItemTrigger, 1417 { 1418 action, 1419 onClick: () => { 1420 if ("RenderModal" in action) { 1421 setActiveModalAction(action); 1422 return; 1423 } 1424 action.callback([item], { registry }); 1425 }, 1426 items: [item] 1427 }, 1428 action.id 1429 )); 1430 return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Menu.Group, { children: [ 1431 renderActionGroup(primaryActions), 1432 primaryActions.length > 0 && regularActions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Menu.Separator, {}), 1433 renderActionGroup(regularActions) 1434 ] }); 1435 } 1436 function ItemActions({ 1437 item, 1438 actions, 1439 isCompact 1440 }) { 1441 const registry = (0, import_data3.useRegistry)(); 1442 const { primaryActions, eligibleActions } = (0, import_element4.useMemo)(() => { 1443 const _eligibleActions = actions.filter( 1444 (action) => !action.isEligible || action.isEligible(item) 1445 ); 1446 const _primaryActions = _eligibleActions.filter( 1447 (action) => action.isPrimary 1448 ); 1449 return { 1450 primaryActions: _primaryActions, 1451 eligibleActions: _eligibleActions 1452 }; 1453 }, [actions, item]); 1454 if (isCompact) { 1455 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1456 CompactItemActions, 1457 { 1458 item, 1459 actions: eligibleActions, 1460 isSmall: true, 1461 registry 1462 } 1463 ); 1464 } 1465 return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)( 1466 import_components4.__experimentalHStack, 1467 { 1468 spacing: 0, 1469 justify: "flex-end", 1470 className: "dataviews-item-actions", 1471 style: { 1472 flexShrink: 0, 1473 width: "auto" 1474 }, 1475 children: [ 1476 /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1477 PrimaryActions, 1478 { 1479 item, 1480 actions: primaryActions, 1481 registry 1482 } 1483 ), 1484 primaryActions.length < eligibleActions.length && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1485 CompactItemActions, 1486 { 1487 item, 1488 actions: eligibleActions, 1489 registry 1490 } 1491 ) 1492 ] 1493 } 1494 ); 1495 } 1496 function CompactItemActions({ 1497 item, 1498 actions, 1499 isSmall, 1500 registry 1501 }) { 1502 const [activeModalAction, setActiveModalAction] = (0, import_element4.useState)( 1503 null 1504 ); 1505 return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [ 1506 /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Menu, { placement: "bottom-end", children: [ 1507 /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1508 Menu.TriggerButton, 1509 { 1510 render: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1511 import_components4.Button, 1512 { 1513 size: isSmall ? "small" : "compact", 1514 icon: more_vertical_default, 1515 label: (0, import_i18n3.__)("Actions"), 1516 accessibleWhenDisabled: true, 1517 disabled: !actions.length, 1518 className: "dataviews-all-actions-button" 1519 } 1520 ) 1521 } 1522 ), 1523 /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1524 ActionsMenuGroup, 1525 { 1526 actions, 1527 item, 1528 registry, 1529 setActiveModalAction 1530 } 1531 ) }) 1532 ] }), 1533 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1534 ActionModal, 1535 { 1536 action: activeModalAction, 1537 items: [item], 1538 closeModal: () => setActiveModalAction(null) 1539 } 1540 ) 1541 ] }); 1542 } 1543 function PrimaryActions({ 1544 item, 1545 actions, 1546 registry, 1547 buttonVariant 1548 }) { 1549 const [activeModalAction, setActiveModalAction] = (0, import_element4.useState)(null); 1550 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<"); 1551 if (isMobileViewport) { 1552 return null; 1553 } 1554 if (!Array.isArray(actions) || actions.length === 0) { 1555 return null; 1556 } 1557 return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [ 1558 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1559 ButtonTrigger, 1560 { 1561 action, 1562 onClick: () => { 1563 if ("RenderModal" in action) { 1564 setActiveModalAction(action); 1565 return; 1566 } 1567 action.callback([item], { registry }); 1568 }, 1569 items: [item], 1570 variant: buttonVariant 1571 }, 1572 action.id 1573 )), 1574 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1575 ActionModal, 1576 { 1577 action: activeModalAction, 1578 items: [item], 1579 closeModal: () => setActiveModalAction(null) 1580 } 1581 ) 1582 ] }); 1583 } 1584 1585 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.js 1586 var import_components5 = __toESM(require_components()); 1587 var import_i18n4 = __toESM(require_i18n()); 1588 var import_element5 = __toESM(require_element()); 1589 var import_data4 = __toESM(require_data()); 1590 var import_compose2 = __toESM(require_compose()); 1591 var import_jsx_runtime30 = __toESM(require_jsx_runtime()); 1592 function ActionWithModal({ 1593 action, 1594 items, 1595 ActionTriggerComponent 1596 }) { 1597 const [isModalOpen, setIsModalOpen] = (0, import_element5.useState)(false); 1598 const actionTriggerProps = { 1599 action, 1600 onClick: () => { 1601 setIsModalOpen(true); 1602 }, 1603 items 1604 }; 1605 return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [ 1606 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ActionTriggerComponent, { ...actionTriggerProps }), 1607 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1608 ActionModal, 1609 { 1610 action, 1611 items, 1612 closeModal: () => setIsModalOpen(false) 1613 } 1614 ) 1615 ] }); 1616 } 1617 function useHasAPossibleBulkAction(actions, item) { 1618 return (0, import_element5.useMemo)(() => { 1619 return actions.some((action) => { 1620 return action.supportsBulk && (!action.isEligible || action.isEligible(item)); 1621 }); 1622 }, [actions, item]); 1623 } 1624 function useSomeItemHasAPossibleBulkAction(actions, data) { 1625 return (0, import_element5.useMemo)(() => { 1626 return data.some((item) => { 1627 return actions.some((action) => { 1628 return action.supportsBulk && (!action.isEligible || action.isEligible(item)); 1629 }); 1630 }); 1631 }, [actions, data]); 1632 } 1633 function BulkSelectionCheckbox({ 1634 selection, 1635 onChangeSelection, 1636 data, 1637 actions, 1638 getItemId: getItemId2 1639 }) { 1640 const selectableItems = (0, import_element5.useMemo)(() => { 1641 return data.filter((item) => { 1642 return actions.some( 1643 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item)) 1644 ); 1645 }); 1646 }, [data, actions]); 1647 const selectedItems = data.filter( 1648 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item) 1649 ); 1650 const areAllSelected = selectedItems.length === selectableItems.length; 1651 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1652 import_components5.CheckboxControl, 1653 { 1654 className: "dataviews-view-table-selection-checkbox", 1655 checked: areAllSelected, 1656 indeterminate: !areAllSelected && !!selectedItems.length, 1657 onChange: () => { 1658 if (areAllSelected) { 1659 onChangeSelection([]); 1660 } else { 1661 onChangeSelection( 1662 selectableItems.map((item) => getItemId2(item)) 1663 ); 1664 } 1665 }, 1666 "aria-label": areAllSelected ? (0, import_i18n4.__)("Deselect all") : (0, import_i18n4.__)("Select all") 1667 } 1668 ); 1669 } 1670 function ActionTrigger({ 1671 action, 1672 onClick, 1673 isBusy, 1674 items 1675 }) { 1676 const label = typeof action.label === "string" ? action.label : action.label(items); 1677 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<"); 1678 if (isMobile) { 1679 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1680 import_components5.Button, 1681 { 1682 disabled: isBusy, 1683 accessibleWhenDisabled: true, 1684 label, 1685 icon: action.icon, 1686 size: "compact", 1687 onClick, 1688 isBusy 1689 } 1690 ); 1691 } 1692 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1693 import_components5.Button, 1694 { 1695 disabled: isBusy, 1696 accessibleWhenDisabled: true, 1697 size: "compact", 1698 onClick, 1699 isBusy, 1700 children: label 1701 } 1702 ); 1703 } 1704 var EMPTY_ARRAY = []; 1705 function ActionButton({ 1706 action, 1707 selectedItems, 1708 actionInProgress, 1709 setActionInProgress 1710 }) { 1711 const registry = (0, import_data4.useRegistry)(); 1712 const selectedEligibleItems = (0, import_element5.useMemo)(() => { 1713 return selectedItems.filter((item) => { 1714 return !action.isEligible || action.isEligible(item); 1715 }); 1716 }, [action, selectedItems]); 1717 if ("RenderModal" in action) { 1718 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1719 ActionWithModal, 1720 { 1721 action, 1722 items: selectedEligibleItems, 1723 ActionTriggerComponent: ActionTrigger 1724 }, 1725 action.id 1726 ); 1727 } 1728 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1729 ActionTrigger, 1730 { 1731 action, 1732 onClick: async () => { 1733 setActionInProgress(action.id); 1734 await action.callback(selectedItems, { 1735 registry 1736 }); 1737 setActionInProgress(null); 1738 }, 1739 items: selectedEligibleItems, 1740 isBusy: actionInProgress === action.id 1741 }, 1742 action.id 1743 ); 1744 } 1745 function renderFooterContent(data, actions, getItemId2, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection) { 1746 const message2 = selectedItems.length > 0 ? (0, import_i18n4.sprintf)( 1747 /* translators: %d: number of items. */ 1748 (0, import_i18n4._n)( 1749 "%d Item selected", 1750 "%d Items selected", 1751 selectedItems.length 1752 ), 1753 selectedItems.length 1754 ) : (0, import_i18n4.sprintf)( 1755 /* translators: %d: number of items. */ 1756 (0, import_i18n4._n)("%d Item", "%d Items", data.length), 1757 data.length 1758 ); 1759 return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)( 1760 import_components5.__experimentalHStack, 1761 { 1762 expanded: false, 1763 className: "dataviews-bulk-actions-footer__container", 1764 spacing: 3, 1765 children: [ 1766 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1767 BulkSelectionCheckbox, 1768 { 1769 selection, 1770 onChangeSelection, 1771 data, 1772 actions, 1773 getItemId: getItemId2 1774 } 1775 ), 1776 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }), 1777 /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)( 1778 import_components5.__experimentalHStack, 1779 { 1780 className: "dataviews-bulk-actions-footer__action-buttons", 1781 expanded: false, 1782 spacing: 1, 1783 children: [ 1784 actionsToShow.map((action) => { 1785 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1786 ActionButton, 1787 { 1788 action, 1789 selectedItems, 1790 actionInProgress, 1791 setActionInProgress 1792 }, 1793 action.id 1794 ); 1795 }), 1796 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1797 import_components5.Button, 1798 { 1799 icon: close_small_default, 1800 showTooltip: true, 1801 tooltipPosition: "top", 1802 size: "compact", 1803 label: (0, import_i18n4.__)("Cancel"), 1804 disabled: !!actionInProgress, 1805 accessibleWhenDisabled: false, 1806 onClick: () => { 1807 onChangeSelection(EMPTY_ARRAY); 1808 } 1809 } 1810 ) 1811 ] 1812 } 1813 ) 1814 ] 1815 } 1816 ); 1817 } 1818 function FooterContent({ 1819 selection, 1820 actions, 1821 onChangeSelection, 1822 data, 1823 getItemId: getItemId2 1824 }) { 1825 const [actionInProgress, setActionInProgress] = (0, import_element5.useState)( 1826 null 1827 ); 1828 const footerContentRef = (0, import_element5.useRef)(null); 1829 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<"); 1830 const bulkActions = (0, import_element5.useMemo)( 1831 () => actions.filter((action) => action.supportsBulk), 1832 [actions] 1833 ); 1834 const selectableItems = (0, import_element5.useMemo)(() => { 1835 return data.filter((item) => { 1836 return bulkActions.some( 1837 (action) => !action.isEligible || action.isEligible(item) 1838 ); 1839 }); 1840 }, [data, bulkActions]); 1841 const selectedItems = (0, import_element5.useMemo)(() => { 1842 return data.filter( 1843 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item) 1844 ); 1845 }, [selection, data, getItemId2, selectableItems]); 1846 const actionsToShow = (0, import_element5.useMemo)( 1847 () => actions.filter((action) => { 1848 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some( 1849 (item) => !action.isEligible || action.isEligible(item) 1850 ); 1851 }), 1852 [actions, selectedItems, isMobile] 1853 ); 1854 if (!actionInProgress) { 1855 if (footerContentRef.current) { 1856 footerContentRef.current = null; 1857 } 1858 return renderFooterContent( 1859 data, 1860 actions, 1861 getItemId2, 1862 selection, 1863 actionsToShow, 1864 selectedItems, 1865 actionInProgress, 1866 setActionInProgress, 1867 onChangeSelection 1868 ); 1869 } else if (!footerContentRef.current) { 1870 footerContentRef.current = renderFooterContent( 1871 data, 1872 actions, 1873 getItemId2, 1874 selection, 1875 actionsToShow, 1876 selectedItems, 1877 actionInProgress, 1878 setActionInProgress, 1879 onChangeSelection 1880 ); 1881 } 1882 return footerContentRef.current; 1883 } 1884 function BulkActionsFooter() { 1885 const { 1886 data, 1887 selection, 1888 actions = EMPTY_ARRAY, 1889 onChangeSelection, 1890 getItemId: getItemId2 1891 } = (0, import_element5.useContext)(dataviews_context_default); 1892 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1893 FooterContent, 1894 { 1895 selection, 1896 onChangeSelection, 1897 data, 1898 actions, 1899 getItemId: getItemId2 1900 } 1901 ); 1902 } 1903 1904 // packages/dataviews/build-module/dataviews-layouts/table/column-header-menu.js 1905 var import_i18n5 = __toESM(require_i18n()); 1906 var import_components6 = __toESM(require_components()); 1907 var import_element6 = __toESM(require_element()); 1908 1909 // packages/dataviews/build-module/utils/get-hideable-fields.js 1910 function getHideableFields(view, fields) { 1911 const togglableFields = [ 1912 view?.titleField, 1913 view?.mediaField, 1914 view?.descriptionField 1915 ].filter(Boolean); 1916 return fields.filter( 1917 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false 1918 ); 1919 } 1920 1921 // packages/dataviews/build-module/dataviews-layouts/table/column-header-menu.js 1922 var import_jsx_runtime31 = __toESM(require_jsx_runtime()); 1923 var { Menu: Menu2 } = unlock(import_components6.privateApis); 1924 function WithMenuSeparators({ children }) { 1925 return import_element6.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_element6.Fragment, { children: [ 1926 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.Separator, {}), 1927 child 1928 ] }, i2)); 1929 } 1930 var _HeaderMenu = (0, import_element6.forwardRef)(function HeaderMenu({ 1931 fieldId, 1932 view, 1933 fields, 1934 onChangeView, 1935 onHide, 1936 setOpenedFilter, 1937 canMove = true, 1938 canInsertLeft = true, 1939 canInsertRight = true 1940 }, ref) { 1941 const visibleFieldIds = view.fields ?? []; 1942 const index = visibleFieldIds?.indexOf(fieldId); 1943 const isSorted = view.sort?.field === fieldId; 1944 let isHidable = false; 1945 let isSortable = false; 1946 let canAddFilter = false; 1947 let operators = []; 1948 const field = fields.find((f2) => f2.id === fieldId); 1949 const { setIsShowingFilter } = (0, import_element6.useContext)(dataviews_context_default); 1950 if (!field) { 1951 return null; 1952 } 1953 isHidable = field.enableHiding !== false; 1954 isSortable = field.enableSorting !== false; 1955 const header = field.header; 1956 operators = !!field.filterBy && field.filterBy?.operators || []; 1957 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary; 1958 if (!isSortable && !canMove && !isHidable && !canAddFilter) { 1959 return header; 1960 } 1961 const hiddenFields = getHideableFields(view, fields).filter( 1962 (f2) => !visibleFieldIds.includes(f2.id) 1963 ); 1964 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length; 1965 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Menu2, { children: [ 1966 /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)( 1967 Menu2.TriggerButton, 1968 { 1969 render: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 1970 import_components6.Button, 1971 { 1972 size: "compact", 1973 className: "dataviews-view-table-header-button", 1974 ref, 1975 variant: "tertiary" 1976 } 1977 ), 1978 children: [ 1979 header, 1980 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] }) 1981 ] 1982 } 1983 ), 1984 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(WithMenuSeparators, { children: [ 1985 isSortable && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map( 1986 (direction) => { 1987 const isChecked = view.sort && isSorted && view.sort.direction === direction; 1988 const value = `$fieldId}-$direction}`; 1989 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 1990 Menu2.RadioItem, 1991 { 1992 name: "view-table-sorting", 1993 value, 1994 checked: isChecked, 1995 onChange: () => { 1996 onChangeView({ 1997 ...view, 1998 sort: { 1999 field: fieldId, 2000 direction 2001 }, 2002 showLevels: false 2003 }); 2004 }, 2005 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] }) 2006 }, 2007 value 2008 ); 2009 } 2010 ) }), 2011 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 2012 Menu2.Item, 2013 { 2014 prefix: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components6.Icon, { icon: funnel_default }), 2015 onClick: () => { 2016 setOpenedFilter(fieldId); 2017 setIsShowingFilter(true); 2018 onChangeView({ 2019 ...view, 2020 page: 1, 2021 filters: [ 2022 ...view.filters || [], 2023 { 2024 field: fieldId, 2025 value: void 0, 2026 operator: operators[0] 2027 } 2028 ] 2029 }); 2030 }, 2031 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Add filter") }) 2032 } 2033 ) }), 2034 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Menu2.Group, { children: [ 2035 canMove && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 2036 Menu2.Item, 2037 { 2038 prefix: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components6.Icon, { icon: arrow_left_default }), 2039 disabled: index < 1, 2040 onClick: () => { 2041 onChangeView({ 2042 ...view, 2043 fields: [ 2044 ...visibleFieldIds.slice( 2045 0, 2046 index - 1 2047 ) ?? [], 2048 fieldId, 2049 visibleFieldIds[index - 1], 2050 ...visibleFieldIds.slice( 2051 index + 1 2052 ) 2053 ] 2054 }); 2055 }, 2056 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Move left") }) 2057 } 2058 ), 2059 canMove && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 2060 Menu2.Item, 2061 { 2062 prefix: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components6.Icon, { icon: arrow_right_default }), 2063 disabled: index >= visibleFieldIds.length - 1, 2064 onClick: () => { 2065 onChangeView({ 2066 ...view, 2067 fields: [ 2068 ...visibleFieldIds.slice( 2069 0, 2070 index 2071 ) ?? [], 2072 visibleFieldIds[index + 1], 2073 fieldId, 2074 ...visibleFieldIds.slice( 2075 index + 2 2076 ) 2077 ] 2078 }); 2079 }, 2080 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Move right") }) 2081 } 2082 ), 2083 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Menu2, { children: [ 2084 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Insert left") }) }), 2085 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 2086 Menu2.Item, 2087 { 2088 onClick: () => { 2089 onChangeView({ 2090 ...view, 2091 fields: [ 2092 ...visibleFieldIds.slice( 2093 0, 2094 index 2095 ), 2096 hiddenField.id, 2097 ...visibleFieldIds.slice( 2098 index 2099 ) 2100 ] 2101 }); 2102 }, 2103 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 2104 }, 2105 hiddenField.id 2106 )) }) 2107 ] }), 2108 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Menu2, { children: [ 2109 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Insert right") }) }), 2110 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 2111 Menu2.Item, 2112 { 2113 onClick: () => { 2114 onChangeView({ 2115 ...view, 2116 fields: [ 2117 ...visibleFieldIds.slice( 2118 0, 2119 index + 1 2120 ), 2121 hiddenField.id, 2122 ...visibleFieldIds.slice( 2123 index + 1 2124 ) 2125 ] 2126 }); 2127 }, 2128 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 2129 }, 2130 hiddenField.id 2131 )) }) 2132 ] }), 2133 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 2134 Menu2.Item, 2135 { 2136 prefix: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components6.Icon, { icon: unseen_default }), 2137 onClick: () => { 2138 onHide(field); 2139 onChangeView({ 2140 ...view, 2141 fields: visibleFieldIds.filter( 2142 (id) => id !== fieldId 2143 ) 2144 }); 2145 }, 2146 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Hide column") }) 2147 } 2148 ) 2149 ] }) 2150 ] }) }) 2151 ] }); 2152 }); 2153 var ColumnHeaderMenu = _HeaderMenu; 2154 var column_header_menu_default = ColumnHeaderMenu; 2155 2156 // packages/dataviews/build-module/dataviews-layouts/table/column-primary.js 2157 var import_components7 = __toESM(require_components()); 2158 2159 // packages/dataviews/build-module/dataviews-layouts/utils/item-click-wrapper.js 2160 var import_element7 = __toESM(require_element()); 2161 var import_jsx_runtime32 = __toESM(require_jsx_runtime()); 2162 function getClickableItemProps({ 2163 item, 2164 isItemClickable, 2165 onClickItem, 2166 className 2167 }) { 2168 if (!isItemClickable(item) || !onClickItem) { 2169 return { className }; 2170 } 2171 return { 2172 className: className ? `$className} $className}--clickable` : void 0, 2173 role: "button", 2174 tabIndex: 0, 2175 onClick: (event) => { 2176 event.stopPropagation(); 2177 onClickItem(item); 2178 }, 2179 onKeyDown: (event) => { 2180 if (event.key === "Enter" || event.key === "" || event.key === " ") { 2181 event.stopPropagation(); 2182 onClickItem(item); 2183 } 2184 } 2185 }; 2186 } 2187 function ItemClickWrapper({ 2188 item, 2189 isItemClickable, 2190 onClickItem, 2191 renderItemLink, 2192 className, 2193 children, 2194 ...extraProps 2195 }) { 2196 if (!isItemClickable(item)) { 2197 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className, ...extraProps, children }); 2198 } 2199 if (renderItemLink) { 2200 const renderedElement = renderItemLink({ 2201 item, 2202 className: `$className} $className}--clickable`, 2203 ...extraProps, 2204 children 2205 }); 2206 return (0, import_element7.cloneElement)(renderedElement, { 2207 onClick: (event) => { 2208 event.stopPropagation(); 2209 if (renderedElement.props.onClick) { 2210 renderedElement.props.onClick(event); 2211 } 2212 }, 2213 onKeyDown: (event) => { 2214 if (event.key === "Enter" || event.key === "" || event.key === " ") { 2215 event.stopPropagation(); 2216 if (renderedElement.props.onKeyDown) { 2217 renderedElement.props.onKeyDown(event); 2218 } 2219 } 2220 } 2221 }); 2222 } 2223 const clickProps = getClickableItemProps({ 2224 item, 2225 isItemClickable, 2226 onClickItem, 2227 className 2228 }); 2229 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { ...clickProps, ...extraProps, children }); 2230 } 2231 2232 // packages/dataviews/build-module/dataviews-layouts/table/column-primary.js 2233 var import_jsx_runtime33 = __toESM(require_jsx_runtime()); 2234 function ColumnPrimary({ 2235 item, 2236 level, 2237 titleField, 2238 mediaField, 2239 descriptionField, 2240 onClickItem, 2241 renderItemLink, 2242 isItemClickable 2243 }) { 2244 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_components7.__experimentalHStack, { spacing: 3, alignment: "flex-start", justify: "flex-start", children: [ 2245 mediaField && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)( 2246 ItemClickWrapper, 2247 { 2248 item, 2249 isItemClickable, 2250 onClickItem, 2251 renderItemLink, 2252 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media", 2253 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0, 2254 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)( 2255 mediaField.render, 2256 { 2257 item, 2258 field: mediaField, 2259 config: { sizes: "32px" } 2260 } 2261 ) 2262 } 2263 ), 2264 /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)( 2265 import_components7.__experimentalVStack, 2266 { 2267 spacing: 0, 2268 alignment: "flex-start", 2269 className: "dataviews-view-table__primary-column-content", 2270 children: [ 2271 titleField && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)( 2272 ItemClickWrapper, 2273 { 2274 item, 2275 isItemClickable, 2276 onClickItem, 2277 renderItemLink, 2278 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field", 2279 children: [ 2280 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("span", { className: "dataviews-view-table__level", children: [ 2281 "\u2014".repeat(level), 2282 "\xA0" 2283 ] }), 2284 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(titleField.render, { item, field: titleField }) 2285 ] 2286 } 2287 ), 2288 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)( 2289 descriptionField.render, 2290 { 2291 item, 2292 field: descriptionField 2293 } 2294 ) 2295 ] 2296 } 2297 ) 2298 ] }); 2299 } 2300 var column_primary_default = ColumnPrimary; 2301 2302 // packages/dataviews/build-module/dataviews-layouts/table/use-is-horizontal-scroll-end.js 2303 var import_compose3 = __toESM(require_compose()); 2304 var import_element8 = __toESM(require_element()); 2305 var import_i18n6 = __toESM(require_i18n()); 2306 var isScrolledToEnd = (element) => { 2307 if ((0, import_i18n6.isRTL)()) { 2308 const scrollLeft = Math.abs(element.scrollLeft); 2309 return scrollLeft <= 1; 2310 } 2311 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1; 2312 }; 2313 function useIsHorizontalScrollEnd({ 2314 scrollContainerRef, 2315 enabled = false 2316 }) { 2317 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element8.useState)(false); 2318 const handleIsHorizontalScrollEnd = (0, import_compose3.useDebounce)( 2319 (0, import_element8.useCallback)(() => { 2320 const scrollContainer = scrollContainerRef.current; 2321 if (scrollContainer) { 2322 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer)); 2323 } 2324 }, [scrollContainerRef, setIsHorizontalScrollEnd]), 2325 200 2326 ); 2327 (0, import_element8.useEffect)(() => { 2328 if (typeof window === "undefined" || !enabled || !scrollContainerRef.current) { 2329 return () => { 2330 }; 2331 } 2332 handleIsHorizontalScrollEnd(); 2333 scrollContainerRef.current.addEventListener( 2334 "scroll", 2335 handleIsHorizontalScrollEnd 2336 ); 2337 window.addEventListener("resize", handleIsHorizontalScrollEnd); 2338 return () => { 2339 scrollContainerRef.current?.removeEventListener( 2340 "scroll", 2341 handleIsHorizontalScrollEnd 2342 ); 2343 window.removeEventListener("resize", handleIsHorizontalScrollEnd); 2344 }; 2345 }, [scrollContainerRef, enabled]); 2346 return isHorizontalScrollEnd; 2347 } 2348 2349 // packages/dataviews/build-module/dataviews-layouts/utils/get-data-by-group.js 2350 function getDataByGroup(data, groupByField) { 2351 return data.reduce((groups, item) => { 2352 const groupName = groupByField.getValue({ item }); 2353 if (!groups.has(groupName)) { 2354 groups.set(groupName, []); 2355 } 2356 groups.get(groupName)?.push(item); 2357 return groups; 2358 }, /* @__PURE__ */ new Map()); 2359 } 2360 2361 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.js 2362 var import_components8 = __toESM(require_components()); 2363 var import_i18n7 = __toESM(require_i18n()); 2364 var import_element9 = __toESM(require_element()); 2365 var import_jsx_runtime34 = __toESM(require_jsx_runtime()); 2366 function FieldItem({ 2367 field, 2368 isVisible: isVisible2, 2369 onToggleVisibility 2370 }) { 2371 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components8.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_components8.__experimentalHStack, { expanded: true, justify: "flex-start", alignment: "center", children: [ 2372 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components8.Icon, { icon: check_default }) }), 2373 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "dataviews-view-config__label", children: field.label }) 2374 ] }) }); 2375 } 2376 function isDefined(item) { 2377 return !!item; 2378 } 2379 function PropertiesSection({ 2380 showLabel = true 2381 }) { 2382 const { view, fields, onChangeView } = (0, import_element9.useContext)(dataviews_context_default); 2383 const regularFields = getHideableFields(view, fields); 2384 if (!regularFields?.length) { 2385 return null; 2386 } 2387 const titleField = fields.find((f2) => f2.id === view.titleField); 2388 const previewField = fields.find((f2) => f2.id === view.mediaField); 2389 const descriptionField = fields.find( 2390 (f2) => f2.id === view.descriptionField 2391 ); 2392 const lockedFields = [ 2393 { 2394 field: titleField, 2395 isVisibleFlag: "showTitle" 2396 }, 2397 { 2398 field: previewField, 2399 isVisibleFlag: "showMedia" 2400 }, 2401 { 2402 field: descriptionField, 2403 isVisibleFlag: "showDescription" 2404 } 2405 ].filter(({ field }) => isDefined(field)); 2406 const visibleFieldIds = view.fields ?? []; 2407 const visibleRegularFieldsCount = regularFields.filter( 2408 (f2) => visibleFieldIds.includes(f2.id) 2409 ).length; 2410 let visibleLockedFields = lockedFields.filter( 2411 ({ field, isVisibleFlag }) => ( 2412 // @ts-expect-error 2413 isDefined(field) && (view[isVisibleFlag] ?? true) 2414 ) 2415 ); 2416 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount; 2417 if (totalVisibleFields === 1) { 2418 if (visibleLockedFields.length === 1) { 2419 visibleLockedFields = visibleLockedFields.map((locked) => ({ 2420 ...locked, 2421 field: { ...locked.field, enableHiding: false } 2422 })); 2423 } 2424 } 2425 const hiddenLockedFields = lockedFields.filter( 2426 ({ field, isVisibleFlag }) => ( 2427 // @ts-expect-error 2428 isDefined(field) && !(view[isVisibleFlag] ?? true) 2429 ) 2430 ); 2431 return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_components8.__experimentalVStack, { className: "dataviews-field-control", spacing: 0, children: [ 2432 showLabel && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components8.BaseControl.VisualLabel, { children: (0, import_i18n7.__)("Properties") }), 2433 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components8.__experimentalVStack, { className: "dataviews-view-config__properties", spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_components8.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [ 2434 visibleLockedFields.map(({ field, isVisibleFlag }) => { 2435 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)( 2436 FieldItem, 2437 { 2438 field, 2439 isVisible: true, 2440 onToggleVisibility: () => { 2441 onChangeView({ 2442 ...view, 2443 [isVisibleFlag]: false 2444 }); 2445 } 2446 }, 2447 field.id 2448 ); 2449 }), 2450 hiddenLockedFields.map(({ field, isVisibleFlag }) => { 2451 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)( 2452 FieldItem, 2453 { 2454 field, 2455 isVisible: false, 2456 onToggleVisibility: () => { 2457 onChangeView({ 2458 ...view, 2459 [isVisibleFlag]: true 2460 }); 2461 } 2462 }, 2463 field.id 2464 ); 2465 }), 2466 regularFields.map((field) => { 2467 const isVisible2 = visibleFieldIds.includes(field.id); 2468 const isLastVisible = totalVisibleFields === 1 && isVisible2; 2469 const fieldToRender = isLastVisible ? { ...field, enableHiding: false } : field; 2470 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)( 2471 FieldItem, 2472 { 2473 field: fieldToRender, 2474 isVisible: isVisible2, 2475 onToggleVisibility: () => { 2476 onChangeView({ 2477 ...view, 2478 fields: isVisible2 ? visibleFieldIds.filter( 2479 (fieldId) => fieldId !== field.id 2480 ) : [...visibleFieldIds, field.id] 2481 }); 2482 } 2483 }, 2484 field.id 2485 ); 2486 }) 2487 ] }) }) 2488 ] }); 2489 } 2490 2491 // packages/dataviews/build-module/dataviews-layouts/table/index.js 2492 var import_jsx_runtime35 = __toESM(require_jsx_runtime()); 2493 function TableColumnField({ 2494 item, 2495 fields, 2496 column, 2497 align 2498 }) { 2499 const field = fields.find((f2) => f2.id === column); 2500 if (!field) { 2501 return null; 2502 } 2503 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 2504 "dataviews-view-table__cell-align-end": align === "end", 2505 "dataviews-view-table__cell-align-center": align === "center" 2506 }); 2507 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(field.render, { item, field }) }); 2508 } 2509 function TableRow({ 2510 hasBulkActions, 2511 item, 2512 level, 2513 actions, 2514 fields, 2515 id, 2516 view, 2517 titleField, 2518 mediaField, 2519 descriptionField, 2520 selection, 2521 getItemId: getItemId2, 2522 isItemClickable, 2523 onClickItem, 2524 renderItemLink, 2525 onChangeSelection, 2526 isActionsColumnSticky, 2527 posinset 2528 }) { 2529 const { paginationInfo } = (0, import_element10.useContext)(dataviews_context_default); 2530 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item); 2531 const isSelected2 = hasPossibleBulkAction && selection.includes(id); 2532 const { 2533 showTitle = true, 2534 showMedia = true, 2535 showDescription = true, 2536 infiniteScrollEnabled 2537 } = view; 2538 const isTouchDeviceRef = (0, import_element10.useRef)(false); 2539 const columns = view.fields ?? []; 2540 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription; 2541 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)( 2542 "tr", 2543 { 2544 className: clsx_default("dataviews-view-table__row", { 2545 "is-selected": hasPossibleBulkAction && isSelected2, 2546 "has-bulk-actions": hasPossibleBulkAction 2547 }), 2548 onTouchStart: () => { 2549 isTouchDeviceRef.current = true; 2550 }, 2551 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 2552 "aria-posinset": posinset, 2553 role: infiniteScrollEnabled ? "article" : void 0, 2554 onMouseDown: (event) => { 2555 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey; 2556 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) { 2557 event?.preventDefault(); 2558 } 2559 }, 2560 onClick: (event) => { 2561 if (!hasPossibleBulkAction) { 2562 return; 2563 } 2564 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey; 2565 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") { 2566 onChangeSelection( 2567 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 2568 ); 2569 } 2570 }, 2571 children: [ 2572 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2573 DataViewsSelectionCheckbox, 2574 { 2575 item, 2576 selection, 2577 onChangeSelection, 2578 getItemId: getItemId2, 2579 titleField, 2580 disabled: !hasPossibleBulkAction 2581 } 2582 ) }) }), 2583 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2584 column_primary_default, 2585 { 2586 item, 2587 level, 2588 titleField: showTitle ? titleField : void 0, 2589 mediaField: showMedia ? mediaField : void 0, 2590 descriptionField: showDescription ? descriptionField : void 0, 2591 isItemClickable, 2592 onClickItem, 2593 renderItemLink 2594 } 2595 ) }), 2596 columns.map((column) => { 2597 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 2598 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2599 "td", 2600 { 2601 style: { 2602 width, 2603 maxWidth, 2604 minWidth 2605 }, 2606 children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2607 TableColumnField, 2608 { 2609 fields, 2610 item, 2611 column, 2612 align 2613 } 2614 ) 2615 }, 2616 column 2617 ); 2618 }), 2619 !!actions?.length && // Disable reason: we are not making the element interactive, 2620 // but preventing any click events from bubbling up to the 2621 // table row. This allows us to add a click handler to the row 2622 // itself (to toggle row selection) without erroneously 2623 // intercepting click events from ItemActions. 2624 /* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */ 2625 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2626 "td", 2627 { 2628 className: clsx_default("dataviews-view-table__actions-column", { 2629 "dataviews-view-table__actions-column--sticky": true, 2630 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky 2631 }), 2632 onClick: (e2) => e2.stopPropagation(), 2633 children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ItemActions, { item, actions }) 2634 } 2635 ) 2636 ] 2637 } 2638 ); 2639 } 2640 function ViewTable({ 2641 actions, 2642 data, 2643 fields, 2644 getItemId: getItemId2, 2645 getItemLevel, 2646 isLoading = false, 2647 onChangeView, 2648 onChangeSelection, 2649 selection, 2650 setOpenedFilter, 2651 onClickItem, 2652 isItemClickable, 2653 renderItemLink, 2654 view, 2655 className, 2656 empty 2657 }) { 2658 const { containerRef } = (0, import_element10.useContext)(dataviews_context_default); 2659 const headerMenuRefs = (0, import_element10.useRef)(/* @__PURE__ */ new Map()); 2660 const headerMenuToFocusRef = (0, import_element10.useRef)(); 2661 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element10.useState)(); 2662 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 2663 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element10.useState)(null); 2664 (0, import_element10.useEffect)(() => { 2665 if (headerMenuToFocusRef.current) { 2666 headerMenuToFocusRef.current.focus(); 2667 headerMenuToFocusRef.current = void 0; 2668 } 2669 }); 2670 const tableNoticeId = (0, import_element10.useId)(); 2671 const isHorizontalScrollEnd = useIsHorizontalScrollEnd({ 2672 scrollContainerRef: containerRef, 2673 enabled: !!actions?.length 2674 }); 2675 if (nextHeaderMenuToFocus) { 2676 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 2677 setNextHeaderMenuToFocus(void 0); 2678 return; 2679 } 2680 const onHide = (field) => { 2681 const hidden = headerMenuRefs.current.get(field.id); 2682 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 2683 setNextHeaderMenuToFocus(fallback?.node); 2684 }; 2685 const handleHeaderContextMenu = (event) => { 2686 event.preventDefault(); 2687 event.stopPropagation(); 2688 const virtualAnchor = { 2689 getBoundingClientRect: () => ({ 2690 x: event.clientX, 2691 y: event.clientY, 2692 top: event.clientY, 2693 left: event.clientX, 2694 right: event.clientX, 2695 bottom: event.clientY, 2696 width: 0, 2697 height: 0, 2698 toJSON: () => ({}) 2699 }) 2700 }; 2701 window.requestAnimationFrame(() => { 2702 setContextMenuAnchor(virtualAnchor); 2703 }); 2704 }; 2705 const hasData = !!data?.length; 2706 const titleField = fields.find((field) => field.id === view.titleField); 2707 const mediaField = fields.find((field) => field.id === view.mediaField); 2708 const descriptionField = fields.find( 2709 (field) => field.id === view.descriptionField 2710 ); 2711 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 2712 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 2713 const { showTitle = true, showMedia = true, showDescription = true } = view; 2714 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription; 2715 const columns = view.fields ?? []; 2716 const headerMenuRef = (column, index) => (node) => { 2717 if (node) { 2718 headerMenuRefs.current.set(column, { 2719 node, 2720 fallback: columns[index > 0 ? index - 1 : 1] 2721 }); 2722 } else { 2723 headerMenuRefs.current.delete(column); 2724 } 2725 }; 2726 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 2727 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [ 2728 /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)( 2729 "table", 2730 { 2731 className: clsx_default("dataviews-view-table", className, { 2732 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 2733 view.layout.density 2734 ), 2735 "has-bulk-actions": hasBulkActions 2736 }), 2737 "aria-busy": isLoading, 2738 "aria-describedby": tableNoticeId, 2739 role: isInfiniteScroll ? "feed" : void 0, 2740 children: [ 2741 /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("colgroup", { children: [ 2742 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("col", { className: "dataviews-view-table__col-checkbox" }), 2743 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("col", { className: "dataviews-view-table__col-first-data" }), 2744 columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2745 "col", 2746 { 2747 className: clsx_default( 2748 `dataviews-view-table__col-$column}`, 2749 { 2750 "dataviews-view-table__col-first-data": !hasPrimaryColumn && index === 0 2751 } 2752 ) 2753 }, 2754 `col-$column}` 2755 )), 2756 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("col", { className: "dataviews-view-table__col-actions" }) 2757 ] }), 2758 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2759 import_components9.Popover, 2760 { 2761 anchor: contextMenuAnchor, 2762 onClose: () => setContextMenuAnchor(null), 2763 placement: "bottom-start", 2764 children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PropertiesSection, { showLabel: false }) 2765 } 2766 ), 2767 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("thead", { onContextMenu: handleHeaderContextMenu, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("tr", { className: "dataviews-view-table__row", children: [ 2768 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2769 "th", 2770 { 2771 className: "dataviews-view-table__checkbox-column", 2772 scope: "col", 2773 onContextMenu: handleHeaderContextMenu, 2774 children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2775 BulkSelectionCheckbox, 2776 { 2777 selection, 2778 onChangeSelection, 2779 data, 2780 actions, 2781 getItemId: getItemId2 2782 } 2783 ) 2784 } 2785 ), 2786 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2787 column_header_menu_default, 2788 { 2789 ref: headerMenuRef( 2790 titleField.id, 2791 0 2792 ), 2793 fieldId: titleField.id, 2794 view, 2795 fields, 2796 onChangeView, 2797 onHide, 2798 setOpenedFilter, 2799 canMove: false, 2800 canInsertLeft: false, 2801 canInsertRight: view.layout?.enableMoving ?? true 2802 } 2803 ) }), 2804 columns.map((column, index) => { 2805 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 2806 const canInsertOrMove = view.layout?.enableMoving ?? true; 2807 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2808 "th", 2809 { 2810 style: { 2811 width, 2812 maxWidth, 2813 minWidth, 2814 textAlign: align 2815 }, 2816 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 2817 scope: "col", 2818 children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2819 column_header_menu_default, 2820 { 2821 ref: headerMenuRef(column, index), 2822 fieldId: column, 2823 view, 2824 fields, 2825 onChangeView, 2826 onHide, 2827 setOpenedFilter, 2828 canMove: canInsertOrMove, 2829 canInsertLeft: canInsertOrMove, 2830 canInsertRight: canInsertOrMove 2831 } 2832 ) 2833 }, 2834 column 2835 ); 2836 }), 2837 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2838 "th", 2839 { 2840 className: clsx_default( 2841 "dataviews-view-table__actions-column", 2842 { 2843 "dataviews-view-table__actions-column--sticky": true, 2844 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd 2845 } 2846 ), 2847 children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n8.__)("Actions") }) 2848 } 2849 ) 2850 ] }) }), 2851 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 2852 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("tbody", { children: [ 2853 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2854 "td", 2855 { 2856 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0), 2857 className: "dataviews-view-table__group-header-cell", 2858 children: (0, import_i18n8.sprintf)( 2859 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 2860 (0, import_i18n8.__)("%1$s: %2$s"), 2861 groupField.label, 2862 groupName 2863 ) 2864 } 2865 ) }), 2866 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2867 TableRow, 2868 { 2869 item, 2870 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0, 2871 hasBulkActions, 2872 actions, 2873 fields, 2874 id: getItemId2(item) || index.toString(), 2875 view, 2876 titleField, 2877 mediaField, 2878 descriptionField, 2879 selection, 2880 getItemId: getItemId2, 2881 onChangeSelection, 2882 onClickItem, 2883 renderItemLink, 2884 isItemClickable, 2885 isActionsColumnSticky: !isHorizontalScrollEnd 2886 }, 2887 getItemId2(item) 2888 )) 2889 ] }, `group-$groupName}`) 2890 ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2891 TableRow, 2892 { 2893 item, 2894 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0, 2895 hasBulkActions, 2896 actions, 2897 fields, 2898 id: getItemId2(item) || index.toString(), 2899 view, 2900 titleField, 2901 mediaField, 2902 descriptionField, 2903 selection, 2904 getItemId: getItemId2, 2905 onChangeSelection, 2906 onClickItem, 2907 renderItemLink, 2908 isItemClickable, 2909 isActionsColumnSticky: !isHorizontalScrollEnd, 2910 posinset: isInfiniteScroll ? index + 1 : void 0 2911 }, 2912 getItemId2(item) 2913 )) }) 2914 ] 2915 } 2916 ), 2917 /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)( 2918 "div", 2919 { 2920 className: clsx_default({ 2921 "dataviews-loading": isLoading, 2922 "dataviews-no-results": !hasData && !isLoading 2923 }), 2924 id: tableNoticeId, 2925 children: [ 2926 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_components9.Spinner, {}) }) : empty), 2927 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_components9.Spinner, {}) }) 2928 ] 2929 } 2930 ) 2931 ] }); 2932 } 2933 var table_default = ViewTable; 2934 2935 // packages/dataviews/build-module/dataviews-layouts/grid/index.js 2936 var import_components12 = __toESM(require_components()); 2937 var import_i18n11 = __toESM(require_i18n()); 2938 2939 // packages/dataviews/build-module/dataviews-layouts/grid/composite-grid.js 2940 var import_components11 = __toESM(require_components()); 2941 var import_i18n10 = __toESM(require_i18n()); 2942 var import_compose4 = __toESM(require_compose()); 2943 var import_keycodes2 = __toESM(require_keycodes()); 2944 var import_element12 = __toESM(require_element()); 2945 2946 // packages/dataviews/build-module/dataviews-layouts/grid/preview-size-picker.js 2947 var import_components10 = __toESM(require_components()); 2948 var import_i18n9 = __toESM(require_i18n()); 2949 var import_element11 = __toESM(require_element()); 2950 var import_jsx_runtime36 = __toESM(require_jsx_runtime()); 2951 var imageSizes = [ 2952 { 2953 value: 120, 2954 breakpoint: 1 2955 }, 2956 { 2957 value: 170, 2958 breakpoint: 1 2959 }, 2960 { 2961 value: 230, 2962 breakpoint: 1 2963 }, 2964 { 2965 value: 290, 2966 breakpoint: 1112 2967 // at minimum image width, 4 images display at this container size 2968 }, 2969 { 2970 value: 350, 2971 breakpoint: 1636 2972 // at minimum image width, 6 images display at this container size 2973 }, 2974 { 2975 value: 430, 2976 breakpoint: 588 2977 // at minimum image width, 2 images display at this container size 2978 } 2979 ]; 2980 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value; 2981 function useGridColumns() { 2982 const context = (0, import_element11.useContext)(dataviews_context_default); 2983 const view = context.view; 2984 return (0, import_element11.useMemo)(() => { 2985 const containerWidth = context.containerWidth; 2986 const gap = 32; 2987 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE; 2988 const columns = Math.floor( 2989 (containerWidth + gap) / (previewSize + gap) 2990 ); 2991 return Math.max(1, columns); 2992 }, [context.containerWidth, view.layout?.previewSize]); 2993 } 2994 2995 // packages/dataviews/build-module/dataviews-layouts/grid/composite-grid.js 2996 var import_jsx_runtime37 = __toESM(require_jsx_runtime()); 2997 var { Badge } = unlock(import_components11.privateApis); 2998 function chunk(array, size) { 2999 const chunks = []; 3000 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) { 3001 chunks.push(array.slice(i2, i2 + size)); 3002 } 3003 return chunks; 3004 } 3005 var GridItem = (0, import_element12.forwardRef)(function GridItem2({ 3006 view, 3007 selection, 3008 onChangeSelection, 3009 onClickItem, 3010 isItemClickable, 3011 renderItemLink, 3012 getItemId: getItemId2, 3013 item, 3014 actions, 3015 mediaField, 3016 titleField, 3017 descriptionField, 3018 regularFields, 3019 badgeFields, 3020 hasBulkActions, 3021 config, 3022 ...props 3023 }, ref) { 3024 const { showTitle = true, showMedia = true, showDescription = true } = view; 3025 const hasBulkAction = useHasAPossibleBulkAction(actions, item); 3026 const id = getItemId2(item); 3027 const instanceId = (0, import_compose4.useInstanceId)(GridItem2); 3028 const isSelected2 = selection.includes(id); 3029 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3030 mediaField.render, 3031 { 3032 item, 3033 field: mediaField, 3034 config 3035 } 3036 ) : null; 3037 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(titleField.render, { item, field: titleField }) : null; 3038 const shouldRenderMedia = showMedia && renderedMediaField; 3039 let mediaA11yProps; 3040 let titleA11yProps; 3041 if (isItemClickable(item) && onClickItem) { 3042 if (renderedTitleField) { 3043 mediaA11yProps = { 3044 "aria-labelledby": `dataviews-view-grid__title-field-$instanceId}` 3045 }; 3046 titleA11yProps = { 3047 id: `dataviews-view-grid__title-field-$instanceId}` 3048 }; 3049 } else { 3050 mediaA11yProps = { 3051 "aria-label": (0, import_i18n10.__)("Navigate to item") 3052 }; 3053 } 3054 } 3055 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)( 3056 import_components11.__experimentalVStack, 3057 { 3058 ...props, 3059 ref, 3060 spacing: 0, 3061 className: clsx_default( 3062 props.className, 3063 "dataviews-view-grid__row__gridcell", 3064 "dataviews-view-grid__card", 3065 { 3066 "is-selected": hasBulkAction && isSelected2 3067 } 3068 ), 3069 onClickCapture: (event) => { 3070 props.onClickCapture?.(event); 3071 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) { 3072 event.stopPropagation(); 3073 event.preventDefault(); 3074 if (!hasBulkAction) { 3075 return; 3076 } 3077 onChangeSelection( 3078 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 3079 ); 3080 } 3081 }, 3082 children: [ 3083 shouldRenderMedia && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3084 ItemClickWrapper, 3085 { 3086 item, 3087 isItemClickable, 3088 onClickItem, 3089 renderItemLink, 3090 className: "dataviews-view-grid__media", 3091 ...mediaA11yProps, 3092 children: renderedMediaField 3093 } 3094 ), 3095 hasBulkActions && shouldRenderMedia && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3096 DataViewsSelectionCheckbox, 3097 { 3098 item, 3099 selection, 3100 onChangeSelection, 3101 getItemId: getItemId2, 3102 titleField, 3103 disabled: !hasBulkAction 3104 } 3105 ), 3106 !showTitle && shouldRenderMedia && !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ItemActions, { item, actions, isCompact: true }) }), 3107 showTitle && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)( 3108 import_components11.__experimentalHStack, 3109 { 3110 justify: "space-between", 3111 className: "dataviews-view-grid__title-actions", 3112 children: [ 3113 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3114 ItemClickWrapper, 3115 { 3116 item, 3117 isItemClickable, 3118 onClickItem, 3119 renderItemLink, 3120 className: "dataviews-view-grid__title-field dataviews-title-field", 3121 ...titleA11yProps, 3122 children: renderedTitleField 3123 } 3124 ), 3125 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3126 ItemActions, 3127 { 3128 item, 3129 actions, 3130 isCompact: true 3131 } 3132 ) 3133 ] 3134 } 3135 ), 3136 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_components11.__experimentalVStack, { spacing: 1, children: [ 3137 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3138 descriptionField.render, 3139 { 3140 item, 3141 field: descriptionField 3142 } 3143 ), 3144 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3145 import_components11.__experimentalHStack, 3146 { 3147 className: "dataviews-view-grid__badge-fields", 3148 spacing: 2, 3149 wrap: true, 3150 alignment: "top", 3151 justify: "flex-start", 3152 children: badgeFields.map((field) => { 3153 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3154 Badge, 3155 { 3156 className: "dataviews-view-grid__field-value", 3157 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3158 field.render, 3159 { 3160 item, 3161 field 3162 } 3163 ) 3164 }, 3165 field.id 3166 ); 3167 }) 3168 } 3169 ), 3170 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3171 import_components11.__experimentalVStack, 3172 { 3173 className: "dataviews-view-grid__fields", 3174 spacing: 1, 3175 children: regularFields.map((field) => { 3176 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3177 import_components11.Flex, 3178 { 3179 className: "dataviews-view-grid__field", 3180 gap: 1, 3181 justify: "flex-start", 3182 expanded: true, 3183 style: { height: "auto" }, 3184 direction: "row", 3185 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [ 3186 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components11.Tooltip, { text: field.label, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components11.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) }), 3187 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3188 import_components11.FlexItem, 3189 { 3190 className: "dataviews-view-grid__field-value", 3191 style: { maxHeight: "none" }, 3192 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3193 field.render, 3194 { 3195 item, 3196 field 3197 } 3198 ) 3199 } 3200 ) 3201 ] }) 3202 }, 3203 field.id 3204 ); 3205 }) 3206 } 3207 ) 3208 ] }) 3209 ] 3210 } 3211 ); 3212 }); 3213 function CompositeGrid({ 3214 data, 3215 isInfiniteScroll, 3216 className, 3217 isLoading, 3218 view, 3219 fields, 3220 selection, 3221 onChangeSelection, 3222 onClickItem, 3223 isItemClickable, 3224 renderItemLink, 3225 getItemId: getItemId2, 3226 actions 3227 }) { 3228 const { paginationInfo, resizeObserverRef } = (0, import_element12.useContext)(dataviews_context_default); 3229 const gridColumns = useGridColumns(); 3230 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 3231 const titleField = fields.find( 3232 (field) => field.id === view?.titleField 3233 ); 3234 const mediaField = fields.find( 3235 (field) => field.id === view?.mediaField 3236 ); 3237 const descriptionField = fields.find( 3238 (field) => field.id === view?.descriptionField 3239 ); 3240 const otherFields = view.fields ?? []; 3241 const { regularFields, badgeFields } = otherFields.reduce( 3242 (accumulator, fieldId) => { 3243 const field = fields.find((f2) => f2.id === fieldId); 3244 if (!field) { 3245 return accumulator; 3246 } 3247 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 3248 accumulator[key].push(field); 3249 return accumulator; 3250 }, 3251 { regularFields: [], badgeFields: [] } 3252 ); 3253 const size = "900px"; 3254 const totalRows = Math.ceil(data.length / gridColumns); 3255 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3256 import_components11.Composite, 3257 { 3258 role: isInfiniteScroll ? "feed" : "grid", 3259 className: clsx_default("dataviews-view-grid", className), 3260 focusWrap: true, 3261 "aria-busy": isLoading, 3262 "aria-rowcount": isInfiniteScroll ? void 0 : totalRows, 3263 ref: resizeObserverRef, 3264 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3265 import_components11.Composite.Row, 3266 { 3267 render: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3268 "div", 3269 { 3270 role: "row", 3271 "aria-rowindex": i2 + 1, 3272 "aria-label": (0, import_i18n10.sprintf)( 3273 /* translators: %d: The row number in the grid */ 3274 (0, import_i18n10.__)("Row %d"), 3275 i2 + 1 3276 ), 3277 className: "dataviews-view-grid__row", 3278 style: { 3279 gridTemplateColumns: `repeat( $gridColumns}, minmax(0, 1fr) )` 3280 } 3281 } 3282 ), 3283 children: row.map((item, indexInRow) => { 3284 const index = i2 * gridColumns + indexInRow; 3285 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3286 import_components11.Composite.Item, 3287 { 3288 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)( 3289 GridItem, 3290 { 3291 ...props, 3292 role: isInfiniteScroll ? "article" : "gridcell", 3293 "aria-setsize": isInfiniteScroll ? paginationInfo.totalItems : void 0, 3294 "aria-posinset": isInfiniteScroll ? index + 1 : void 0, 3295 view, 3296 selection, 3297 onChangeSelection, 3298 onClickItem, 3299 isItemClickable, 3300 renderItemLink, 3301 getItemId: getItemId2, 3302 item, 3303 actions, 3304 mediaField, 3305 titleField, 3306 descriptionField, 3307 regularFields, 3308 badgeFields, 3309 hasBulkActions, 3310 config: { 3311 sizes: size 3312 } 3313 } 3314 ) 3315 }, 3316 getItemId2(item) 3317 ); 3318 }) 3319 }, 3320 i2 3321 )) 3322 } 3323 ); 3324 } 3325 3326 // packages/dataviews/build-module/dataviews-layouts/grid/index.js 3327 var import_jsx_runtime38 = __toESM(require_jsx_runtime()); 3328 function ViewGrid({ 3329 actions, 3330 data, 3331 fields, 3332 getItemId: getItemId2, 3333 isLoading, 3334 onChangeSelection, 3335 onClickItem, 3336 isItemClickable, 3337 renderItemLink, 3338 selection, 3339 view, 3340 className, 3341 empty 3342 }) { 3343 const hasData = !!data?.length; 3344 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 3345 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 3346 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 3347 const gridProps = { 3348 className, 3349 isLoading, 3350 view, 3351 fields, 3352 selection, 3353 onChangeSelection, 3354 onClickItem, 3355 isItemClickable, 3356 renderItemLink, 3357 getItemId: getItemId2, 3358 actions 3359 }; 3360 return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { 3361 // Render multiple groups. 3362 children: [ 3363 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_components12.__experimentalVStack, { spacing: 4, children: Array.from(dataByGroup.entries()).map( 3364 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_components12.__experimentalVStack, { spacing: 2, children: [ 3365 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h3", { className: "dataviews-view-grid__group-header", children: (0, import_i18n11.sprintf)( 3366 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 3367 (0, import_i18n11.__)("%1$s: %2$s"), 3368 groupField.label, 3369 groupName 3370 ) }), 3371 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3372 CompositeGrid, 3373 { 3374 ...gridProps, 3375 data: groupItems, 3376 isInfiniteScroll: false 3377 } 3378 ) 3379 ] }, groupName) 3380 ) }), 3381 // Render a single grid with all data. 3382 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3383 CompositeGrid, 3384 { 3385 ...gridProps, 3386 data, 3387 isInfiniteScroll: !!isInfiniteScroll 3388 } 3389 ), 3390 // Render empty state. 3391 !hasData && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3392 "div", 3393 { 3394 className: clsx_default({ 3395 "dataviews-loading": isLoading, 3396 "dataviews-no-results": !isLoading 3397 }), 3398 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_components12.Spinner, {}) }) : empty 3399 } 3400 ), 3401 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_components12.Spinner, {}) }) 3402 ] 3403 }); 3404 } 3405 var grid_default = ViewGrid; 3406 3407 // packages/dataviews/build-module/dataviews-layouts/list/index.js 3408 var import_compose5 = __toESM(require_compose()); 3409 var import_components13 = __toESM(require_components()); 3410 var import_element13 = __toESM(require_element()); 3411 var import_i18n12 = __toESM(require_i18n()); 3412 var import_data5 = __toESM(require_data()); 3413 var import_jsx_runtime39 = __toESM(require_jsx_runtime()); 3414 var { Menu: Menu3 } = unlock(import_components13.privateApis); 3415 function generateItemWrapperCompositeId(idPrefix) { 3416 return `$idPrefix}-item-wrapper`; 3417 } 3418 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) { 3419 return `$idPrefix}-primary-action-$primaryActionId}`; 3420 } 3421 function generateDropdownTriggerCompositeId(idPrefix) { 3422 return `$idPrefix}-dropdown`; 3423 } 3424 function PrimaryActionGridCell({ 3425 idPrefix, 3426 primaryAction, 3427 item 3428 }) { 3429 const registry = (0, import_data5.useRegistry)(); 3430 const [isModalOpen, setIsModalOpen] = (0, import_element13.useState)(false); 3431 const compositeItemId = generatePrimaryActionCompositeId( 3432 idPrefix, 3433 primaryAction.id 3434 ); 3435 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]); 3436 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3437 import_components13.Composite.Item, 3438 { 3439 id: compositeItemId, 3440 render: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3441 import_components13.Button, 3442 { 3443 disabled: !!primaryAction.disabled, 3444 accessibleWhenDisabled: true, 3445 text: label, 3446 size: "small", 3447 onClick: () => setIsModalOpen(true) 3448 } 3449 ), 3450 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3451 ActionModal, 3452 { 3453 action: primaryAction, 3454 items: [item], 3455 closeModal: () => setIsModalOpen(false) 3456 } 3457 ) 3458 } 3459 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3460 import_components13.Composite.Item, 3461 { 3462 id: compositeItemId, 3463 render: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3464 import_components13.Button, 3465 { 3466 disabled: !!primaryAction.disabled, 3467 accessibleWhenDisabled: true, 3468 size: "small", 3469 onClick: () => { 3470 primaryAction.callback([item], { registry }); 3471 }, 3472 children: label 3473 } 3474 ) 3475 } 3476 ) }, primaryAction.id); 3477 } 3478 function ListItem({ 3479 view, 3480 actions, 3481 idPrefix, 3482 isSelected: isSelected2, 3483 item, 3484 titleField, 3485 mediaField, 3486 descriptionField, 3487 onSelect, 3488 otherFields, 3489 onDropdownTriggerKeyDown, 3490 posinset 3491 }) { 3492 const { 3493 showTitle = true, 3494 showMedia = true, 3495 showDescription = true, 3496 infiniteScrollEnabled 3497 } = view; 3498 const itemRef = (0, import_element13.useRef)(null); 3499 const labelId = `$idPrefix}-label`; 3500 const descriptionId = `$idPrefix}-description`; 3501 const registry = (0, import_data5.useRegistry)(); 3502 const [isHovered, setIsHovered] = (0, import_element13.useState)(false); 3503 const [activeModalAction, setActiveModalAction] = (0, import_element13.useState)( 3504 null 3505 ); 3506 const handleHover = ({ type }) => { 3507 const isHover = type === "mouseenter"; 3508 setIsHovered(isHover); 3509 }; 3510 const { paginationInfo } = (0, import_element13.useContext)(dataviews_context_default); 3511 (0, import_element13.useEffect)(() => { 3512 if (isSelected2) { 3513 itemRef.current?.scrollIntoView({ 3514 behavior: "auto", 3515 block: "nearest", 3516 inline: "nearest" 3517 }); 3518 } 3519 }, [isSelected2]); 3520 const { primaryAction, eligibleActions } = (0, import_element13.useMemo)(() => { 3521 const _eligibleActions = actions.filter( 3522 (action) => !action.isEligible || action.isEligible(item) 3523 ); 3524 const _primaryActions = _eligibleActions.filter( 3525 (action) => action.isPrimary 3526 ); 3527 return { 3528 primaryAction: _primaryActions[0], 3529 eligibleActions: _eligibleActions 3530 }; 3531 }, [actions, item]); 3532 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1; 3533 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3534 mediaField.render, 3535 { 3536 item, 3537 field: mediaField, 3538 config: { sizes: "52px" } 3539 } 3540 ) }) : null; 3541 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(titleField.render, { item, field: titleField }) : null; 3542 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_components13.__experimentalHStack, { spacing: 3, className: "dataviews-view-list__item-actions", children: [ 3543 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3544 PrimaryActionGridCell, 3545 { 3546 idPrefix, 3547 primaryAction, 3548 item 3549 } 3550 ), 3551 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { role: "gridcell", children: [ 3552 /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Menu3, { placement: "bottom-end", children: [ 3553 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3554 Menu3.TriggerButton, 3555 { 3556 render: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3557 import_components13.Composite.Item, 3558 { 3559 id: generateDropdownTriggerCompositeId( 3560 idPrefix 3561 ), 3562 render: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3563 import_components13.Button, 3564 { 3565 size: "small", 3566 icon: more_vertical_default, 3567 label: (0, import_i18n12.__)("Actions"), 3568 accessibleWhenDisabled: true, 3569 disabled: !actions.length, 3570 onKeyDown: onDropdownTriggerKeyDown 3571 } 3572 ) 3573 } 3574 ) 3575 } 3576 ), 3577 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3578 ActionsMenuGroup, 3579 { 3580 actions: eligibleActions, 3581 item, 3582 registry, 3583 setActiveModalAction 3584 } 3585 ) }) 3586 ] }), 3587 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3588 ActionModal, 3589 { 3590 action: activeModalAction, 3591 items: [item], 3592 closeModal: () => setActiveModalAction(null) 3593 } 3594 ) 3595 ] }) 3596 ] }); 3597 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3598 import_components13.Composite.Row, 3599 { 3600 ref: itemRef, 3601 render: ( 3602 /* aria-posinset breaks Composite.Row if passed to it directly. */ 3603 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3604 "div", 3605 { 3606 "aria-posinset": posinset, 3607 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0 3608 } 3609 ) 3610 ), 3611 role: infiniteScrollEnabled ? "article" : "row", 3612 className: clsx_default({ 3613 "is-selected": isSelected2, 3614 "is-hovered": isHovered 3615 }), 3616 onMouseEnter: handleHover, 3617 onMouseLeave: handleHover, 3618 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_components13.__experimentalHStack, { className: "dataviews-view-list__item-wrapper", spacing: 0, children: [ 3619 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3620 import_components13.Composite.Item, 3621 { 3622 id: generateItemWrapperCompositeId(idPrefix), 3623 "aria-pressed": isSelected2, 3624 "aria-labelledby": labelId, 3625 "aria-describedby": descriptionId, 3626 className: "dataviews-view-list__item", 3627 onClick: () => onSelect(item) 3628 } 3629 ) }), 3630 /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_components13.__experimentalHStack, { spacing: 3, justify: "start", alignment: "flex-start", children: [ 3631 renderedMediaField, 3632 /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)( 3633 import_components13.__experimentalVStack, 3634 { 3635 spacing: 1, 3636 className: "dataviews-view-list__field-wrapper", 3637 children: [ 3638 /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_components13.__experimentalHStack, { spacing: 0, children: [ 3639 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3640 "div", 3641 { 3642 className: "dataviews-title-field", 3643 id: labelId, 3644 children: renderedTitleField 3645 } 3646 ), 3647 usedActions 3648 ] }), 3649 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3650 descriptionField.render, 3651 { 3652 item, 3653 field: descriptionField 3654 } 3655 ) }), 3656 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3657 "div", 3658 { 3659 className: "dataviews-view-list__fields", 3660 id: descriptionId, 3661 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)( 3662 "div", 3663 { 3664 className: "dataviews-view-list__field", 3665 children: [ 3666 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3667 import_components13.VisuallyHidden, 3668 { 3669 as: "span", 3670 className: "dataviews-view-list__field-label", 3671 children: field.label 3672 } 3673 ), 3674 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3675 field.render, 3676 { 3677 item, 3678 field 3679 } 3680 ) }) 3681 ] 3682 }, 3683 field.id 3684 )) 3685 } 3686 ) 3687 ] 3688 } 3689 ) 3690 ] }) 3691 ] }) 3692 } 3693 ); 3694 } 3695 function isDefined2(item) { 3696 return !!item; 3697 } 3698 function ViewList(props) { 3699 const { 3700 actions, 3701 data, 3702 fields, 3703 getItemId: getItemId2, 3704 isLoading, 3705 onChangeSelection, 3706 selection, 3707 view, 3708 className, 3709 empty 3710 } = props; 3711 const baseId = (0, import_compose5.useInstanceId)(ViewList, "view-list"); 3712 const selectedItem = data?.findLast( 3713 (item) => selection.includes(getItemId2(item)) 3714 ); 3715 const titleField = fields.find((field) => field.id === view.titleField); 3716 const mediaField = fields.find((field) => field.id === view.mediaField); 3717 const descriptionField = fields.find( 3718 (field) => field.id === view.descriptionField 3719 ); 3720 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2); 3721 const onSelect = (item) => onChangeSelection([getItemId2(item)]); 3722 const generateCompositeItemIdPrefix = (0, import_element13.useCallback)( 3723 (item) => `$baseId}-$getItemId2(item)}`, 3724 [baseId, getItemId2] 3725 ); 3726 const isActiveCompositeItem = (0, import_element13.useCallback)( 3727 (item, idToCheck) => { 3728 return idToCheck.startsWith( 3729 generateCompositeItemIdPrefix(item) 3730 ); 3731 }, 3732 [generateCompositeItemIdPrefix] 3733 ); 3734 const [activeCompositeId, setActiveCompositeId] = (0, import_element13.useState)(void 0); 3735 (0, import_element13.useEffect)(() => { 3736 if (selectedItem) { 3737 setActiveCompositeId( 3738 generateItemWrapperCompositeId( 3739 generateCompositeItemIdPrefix(selectedItem) 3740 ) 3741 ); 3742 } 3743 }, [selectedItem, generateCompositeItemIdPrefix]); 3744 const activeItemIndex = data.findIndex( 3745 (item) => isActiveCompositeItem(item, activeCompositeId ?? "") 3746 ); 3747 const previousActiveItemIndex = (0, import_compose5.usePrevious)(activeItemIndex); 3748 const isActiveIdInList = activeItemIndex !== -1; 3749 const selectCompositeItem = (0, import_element13.useCallback)( 3750 (targetIndex, generateCompositeId) => { 3751 const clampedIndex = Math.min( 3752 data.length - 1, 3753 Math.max(0, targetIndex) 3754 ); 3755 if (!data[clampedIndex]) { 3756 return; 3757 } 3758 const itemIdPrefix = generateCompositeItemIdPrefix( 3759 data[clampedIndex] 3760 ); 3761 const targetCompositeItemId = generateCompositeId(itemIdPrefix); 3762 setActiveCompositeId(targetCompositeItemId); 3763 document.getElementById(targetCompositeItemId)?.focus(); 3764 }, 3765 [data, generateCompositeItemIdPrefix] 3766 ); 3767 (0, import_element13.useEffect)(() => { 3768 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1; 3769 if (!isActiveIdInList && wasActiveIdInList) { 3770 selectCompositeItem( 3771 previousActiveItemIndex, 3772 generateItemWrapperCompositeId 3773 ); 3774 } 3775 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]); 3776 const onDropdownTriggerKeyDown = (0, import_element13.useCallback)( 3777 (event) => { 3778 if (event.key === "ArrowDown") { 3779 event.preventDefault(); 3780 selectCompositeItem( 3781 activeItemIndex + 1, 3782 generateDropdownTriggerCompositeId 3783 ); 3784 } 3785 if (event.key === "ArrowUp") { 3786 event.preventDefault(); 3787 selectCompositeItem( 3788 activeItemIndex - 1, 3789 generateDropdownTriggerCompositeId 3790 ); 3791 } 3792 }, 3793 [selectCompositeItem, activeItemIndex] 3794 ); 3795 const hasData = data?.length; 3796 if (!hasData) { 3797 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3798 "div", 3799 { 3800 className: clsx_default({ 3801 "dataviews-loading": isLoading, 3802 "dataviews-no-results": !hasData && !isLoading 3803 }), 3804 children: !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components13.Spinner, {}) }) : empty) 3805 } 3806 ); 3807 } 3808 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null; 3809 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 3810 if (hasData && groupField && dataByGroup) { 3811 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3812 import_components13.Composite, 3813 { 3814 id: `$baseId}`, 3815 render: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", {}), 3816 className: "dataviews-view-list__group", 3817 role: "grid", 3818 activeId: activeCompositeId, 3819 setActiveId: setActiveCompositeId, 3820 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3821 import_components13.__experimentalVStack, 3822 { 3823 spacing: 4, 3824 className: clsx_default("dataviews-view-list", className), 3825 children: Array.from(dataByGroup.entries()).map( 3826 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_components13.__experimentalVStack, { spacing: 2, children: [ 3827 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h3", { className: "dataviews-view-list__group-header", children: (0, import_i18n12.sprintf)( 3828 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 3829 (0, import_i18n12.__)("%1$s: %2$s"), 3830 groupField.label, 3831 groupName 3832 ) }), 3833 groupItems.map((item) => { 3834 const id = generateCompositeItemIdPrefix(item); 3835 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3836 ListItem, 3837 { 3838 view, 3839 idPrefix: id, 3840 actions, 3841 item, 3842 isSelected: item === selectedItem, 3843 onSelect, 3844 mediaField, 3845 titleField, 3846 descriptionField, 3847 otherFields, 3848 onDropdownTriggerKeyDown 3849 }, 3850 id 3851 ); 3852 }) 3853 ] }, groupName) 3854 ) 3855 } 3856 ) 3857 } 3858 ); 3859 } 3860 return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [ 3861 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3862 import_components13.Composite, 3863 { 3864 id: baseId, 3865 render: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", {}), 3866 className: clsx_default("dataviews-view-list", className), 3867 role: view.infiniteScrollEnabled ? "feed" : "grid", 3868 activeId: activeCompositeId, 3869 setActiveId: setActiveCompositeId, 3870 children: data.map((item, index) => { 3871 const id = generateCompositeItemIdPrefix(item); 3872 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3873 ListItem, 3874 { 3875 view, 3876 idPrefix: id, 3877 actions, 3878 item, 3879 isSelected: item === selectedItem, 3880 onSelect, 3881 mediaField, 3882 titleField, 3883 descriptionField, 3884 otherFields, 3885 onDropdownTriggerKeyDown, 3886 posinset: view.infiniteScrollEnabled ? index + 1 : void 0 3887 }, 3888 id 3889 ); 3890 }) 3891 } 3892 ), 3893 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components13.Spinner, {}) }) 3894 ] }); 3895 } 3896 3897 // packages/dataviews/build-module/dataviews-layouts/activity/index.js 3898 var import_components16 = __toESM(require_components()); 3899 3900 // packages/dataviews/build-module/dataviews-layouts/activity/activity-group.js 3901 var import_components14 = __toESM(require_components()); 3902 var import_i18n13 = __toESM(require_i18n()); 3903 var import_element14 = __toESM(require_element()); 3904 var import_jsx_runtime40 = __toESM(require_jsx_runtime()); 3905 function ActivityGroup({ 3906 groupName, 3907 groupData, 3908 groupField, 3909 children 3910 }) { 3911 const groupHeader = (0, import_element14.createInterpolateElement)( 3912 // translators: %s: The label of the field e.g. "Status". 3913 (0, import_i18n13.sprintf)((0, import_i18n13.__)("%s: <groupName />"), groupField.label).trim(), 3914 { 3915 groupName: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3916 groupField.render, 3917 { 3918 item: groupData[0], 3919 field: groupField 3920 } 3921 ) 3922 } 3923 ); 3924 return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)( 3925 import_components14.__experimentalVStack, 3926 { 3927 spacing: 0, 3928 className: "dataviews-view-activity__group", 3929 children: [ 3930 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }), 3931 children 3932 ] 3933 }, 3934 groupName 3935 ); 3936 } 3937 3938 // packages/dataviews/build-module/dataviews-layouts/activity/activity-item.js 3939 var import_components15 = __toESM(require_components()); 3940 var import_element15 = __toESM(require_element()); 3941 var import_data6 = __toESM(require_data()); 3942 var import_jsx_runtime41 = __toESM(require_jsx_runtime()); 3943 function ActivityItem(props) { 3944 const { 3945 view, 3946 actions, 3947 item, 3948 titleField, 3949 mediaField, 3950 descriptionField, 3951 otherFields, 3952 posinset, 3953 onClickItem, 3954 renderItemLink, 3955 isItemClickable 3956 } = props; 3957 const { 3958 showTitle = true, 3959 showMedia = true, 3960 showDescription = true, 3961 infiniteScrollEnabled 3962 } = view; 3963 const itemRef = (0, import_element15.useRef)(null); 3964 const registry = (0, import_data6.useRegistry)(); 3965 const { paginationInfo } = (0, import_element15.useContext)(dataviews_context_default); 3966 const { primaryActions, eligibleActions } = (0, import_element15.useMemo)(() => { 3967 const _eligibleActions = actions.filter( 3968 (action) => !action.isEligible || action.isEligible(item) 3969 ); 3970 const _primaryActions = _eligibleActions.filter( 3971 (action) => action.isPrimary 3972 ); 3973 return { 3974 primaryActions: _primaryActions, 3975 eligibleActions: _eligibleActions 3976 }; 3977 }, [actions, item]); 3978 const density = view.layout?.density ?? "balanced"; 3979 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 3980 mediaField.render, 3981 { 3982 item, 3983 field: mediaField, 3984 config: { 3985 sizes: density === "comfortable" ? "32px" : "24px" 3986 } 3987 } 3988 ) : null; 3989 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 3990 "span", 3991 { 3992 className: "dataviews-view-activity__item-bullet", 3993 "aria-hidden": "true" 3994 } 3995 ) }); 3996 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(titleField.render, { item, field: titleField }) : null; 3997 const verticalSpacing = (0, import_element15.useMemo)(() => { 3998 switch (density) { 3999 case "comfortable": 4000 return "3"; 4001 default: 4002 return "2"; 4003 } 4004 }, [density]); 4005 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 4006 "div", 4007 { 4008 ref: itemRef, 4009 role: infiniteScrollEnabled ? "article" : void 0, 4010 "aria-posinset": posinset, 4011 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 4012 className: clsx_default( 4013 "dataviews-view-activity__item", 4014 density === "compact" && "is-compact", 4015 density === "balanced" && "is-balanced", 4016 density === "comfortable" && "is-comfortable" 4017 ), 4018 children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_components15.__experimentalHStack, { spacing: 4, justify: "start", alignment: "flex-start", children: [ 4019 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 4020 import_components15.__experimentalVStack, 4021 { 4022 spacing: 1, 4023 alignment: "center", 4024 className: "dataviews-view-activity__item-type", 4025 children: renderedMediaField 4026 } 4027 ), 4028 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)( 4029 import_components15.__experimentalVStack, 4030 { 4031 spacing: verticalSpacing, 4032 alignment: "flex-start", 4033 className: "dataviews-view-activity__item-content", 4034 children: [ 4035 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 4036 ItemClickWrapper, 4037 { 4038 item, 4039 isItemClickable, 4040 onClickItem, 4041 renderItemLink, 4042 className: "dataviews-view-activity__item-title", 4043 children: renderedTitleField 4044 } 4045 ), 4046 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 4047 descriptionField.render, 4048 { 4049 item, 4050 field: descriptionField 4051 } 4052 ) }), 4053 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)( 4054 "div", 4055 { 4056 className: "dataviews-view-activity__item-field", 4057 children: [ 4058 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 4059 import_components15.VisuallyHidden, 4060 { 4061 as: "span", 4062 className: "dataviews-view-activity__item-field-label", 4063 children: field.label 4064 } 4065 ), 4066 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 4067 field.render, 4068 { 4069 item, 4070 field 4071 } 4072 ) }) 4073 ] 4074 }, 4075 field.id 4076 )) }), 4077 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 4078 PrimaryActions, 4079 { 4080 item, 4081 actions: primaryActions, 4082 registry, 4083 buttonVariant: "secondary" 4084 } 4085 ) 4086 ] 4087 } 4088 ), 4089 primaryActions.length < eligibleActions.length && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 4090 ItemActions, 4091 { 4092 item, 4093 actions: eligibleActions, 4094 isCompact: true 4095 } 4096 ) }) 4097 ] }) 4098 } 4099 ); 4100 } 4101 var activity_item_default = ActivityItem; 4102 4103 // packages/dataviews/build-module/dataviews-layouts/activity/activity-items.js 4104 var import_react = __toESM(require_react()); 4105 function isDefined3(item) { 4106 return !!item; 4107 } 4108 function ActivityItems(props) { 4109 const { data, fields, getItemId: getItemId2, view } = props; 4110 const titleField = fields.find((field) => field.id === view.titleField); 4111 const mediaField = fields.find((field) => field.id === view.mediaField); 4112 const descriptionField = fields.find( 4113 (field) => field.id === view.descriptionField 4114 ); 4115 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3); 4116 return data.map((item, index) => { 4117 return /* @__PURE__ */ (0, import_react.createElement)( 4118 activity_item_default, 4119 { 4120 ...props, 4121 key: getItemId2(item), 4122 item, 4123 mediaField, 4124 titleField, 4125 descriptionField, 4126 otherFields, 4127 posinset: view.infiniteScrollEnabled ? index + 1 : void 0 4128 } 4129 ); 4130 }); 4131 } 4132 4133 // packages/dataviews/build-module/dataviews-layouts/activity/index.js 4134 var import_jsx_runtime42 = __toESM(require_jsx_runtime()); 4135 function ViewActivity(props) { 4136 const { empty, data, fields, isLoading, view, className } = props; 4137 const hasData = data?.length; 4138 if (!hasData) { 4139 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 4140 "div", 4141 { 4142 className: clsx_default({ 4143 "dataviews-loading": isLoading, 4144 "dataviews-no-results": !hasData && !isLoading 4145 }), 4146 children: !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components16.Spinner, {}) }) : empty) 4147 } 4148 ); 4149 } 4150 const wrapperClassName = clsx_default("dataviews-view-activity", className); 4151 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null; 4152 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 4153 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : []; 4154 if (hasData && groupField && dataByGroup) { 4155 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components16.__experimentalVStack, { spacing: 2, className: wrapperClassName, children: groupedEntries.map( 4156 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 4157 ActivityGroup, 4158 { 4159 groupName, 4160 groupData, 4161 groupField, 4162 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 4163 ActivityItems, 4164 { 4165 ...props, 4166 data: groupData 4167 } 4168 ) 4169 }, 4170 groupName 4171 ) 4172 ) }); 4173 } 4174 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [ 4175 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 4176 "div", 4177 { 4178 className: wrapperClassName, 4179 role: view.infiniteScrollEnabled ? "feed" : void 0, 4180 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ActivityItems, { ...props }) 4181 } 4182 ), 4183 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components16.Spinner, {}) }) 4184 ] }); 4185 } 4186 4187 // packages/dataviews/build-module/dataviews-layouts/picker-grid/index.js 4188 var import_components19 = __toESM(require_components()); 4189 var import_i18n16 = __toESM(require_i18n()); 4190 var import_compose6 = __toESM(require_compose()); 4191 var import_element19 = __toESM(require_element()); 4192 4193 // packages/dataviews/build-module/components/dataviews-picker/footer.js 4194 var import_components18 = __toESM(require_components()); 4195 var import_data7 = __toESM(require_data()); 4196 var import_element17 = __toESM(require_element()); 4197 var import_i18n15 = __toESM(require_i18n()); 4198 4199 // packages/dataviews/build-module/components/dataviews-pagination/index.js 4200 var import_components17 = __toESM(require_components()); 4201 var import_element16 = __toESM(require_element()); 4202 var import_i18n14 = __toESM(require_i18n()); 4203 var import_jsx_runtime43 = __toESM(require_jsx_runtime()); 4204 function DataViewsPagination() { 4205 const { 4206 view, 4207 onChangeView, 4208 paginationInfo: { totalItems = 0, totalPages } 4209 } = (0, import_element16.useContext)(dataviews_context_default); 4210 if (!totalItems || !totalPages || view.infiniteScrollEnabled) { 4211 return null; 4212 } 4213 const currentPage = view.page ?? 1; 4214 const pageSelectOptions = Array.from(Array(totalPages)).map( 4215 (_, i2) => { 4216 const page = i2 + 1; 4217 return { 4218 value: page.toString(), 4219 label: page.toString(), 4220 "aria-label": currentPage === page ? (0, import_i18n14.sprintf)( 4221 // translators: 1: current page number. 2: total number of pages. 4222 (0, import_i18n14.__)("Page %1$d of %2$d"), 4223 currentPage, 4224 totalPages 4225 ) : page.toString() 4226 }; 4227 } 4228 ); 4229 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)( 4230 import_components17.__experimentalHStack, 4231 { 4232 expanded: false, 4233 className: "dataviews-pagination", 4234 justify: "end", 4235 spacing: 6, 4236 children: [ 4237 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 4238 import_components17.__experimentalHStack, 4239 { 4240 justify: "flex-start", 4241 expanded: false, 4242 spacing: 1, 4243 className: "dataviews-pagination__page-select", 4244 children: (0, import_element16.createInterpolateElement)( 4245 (0, import_i18n14.sprintf)( 4246 // translators: 1: Current page number, 2: Total number of pages. 4247 (0, import_i18n14._x)( 4248 "<div>Page</div>%1$s<div>of %2$d</div>", 4249 "paging" 4250 ), 4251 "<CurrentPage />", 4252 totalPages 4253 ), 4254 { 4255 div: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { "aria-hidden": true }), 4256 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 4257 import_components17.SelectControl, 4258 { 4259 "aria-label": (0, import_i18n14.__)("Current page"), 4260 value: currentPage.toString(), 4261 options: pageSelectOptions, 4262 onChange: (newValue) => { 4263 onChangeView({ 4264 ...view, 4265 page: +newValue 4266 }); 4267 }, 4268 size: "small", 4269 variant: "minimal" 4270 } 4271 ) 4272 } 4273 ) 4274 } 4275 ), 4276 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_components17.__experimentalHStack, { expanded: false, spacing: 1, children: [ 4277 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 4278 import_components17.Button, 4279 { 4280 onClick: () => onChangeView({ 4281 ...view, 4282 page: currentPage - 1 4283 }), 4284 disabled: currentPage === 1, 4285 accessibleWhenDisabled: true, 4286 label: (0, import_i18n14.__)("Previous page"), 4287 icon: (0, import_i18n14.isRTL)() ? next_default : previous_default, 4288 showTooltip: true, 4289 size: "compact", 4290 tooltipPosition: "top" 4291 } 4292 ), 4293 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 4294 import_components17.Button, 4295 { 4296 onClick: () => onChangeView({ ...view, page: currentPage + 1 }), 4297 disabled: currentPage >= totalPages, 4298 accessibleWhenDisabled: true, 4299 label: (0, import_i18n14.__)("Next page"), 4300 icon: (0, import_i18n14.isRTL)() ? previous_default : next_default, 4301 showTooltip: true, 4302 size: "compact", 4303 tooltipPosition: "top" 4304 } 4305 ) 4306 ] }) 4307 ] 4308 } 4309 ); 4310 } 4311 var dataviews_pagination_default = (0, import_element16.memo)(DataViewsPagination); 4312 4313 // packages/dataviews/build-module/components/dataviews-picker/footer.js 4314 var import_jsx_runtime44 = __toESM(require_jsx_runtime()); 4315 function useIsMultiselectPicker(actions) { 4316 return (0, import_element17.useMemo)(() => { 4317 return actions?.every((action) => action.supportsBulk); 4318 }, [actions]); 4319 } 4320 4321 // packages/dataviews/build-module/dataviews-layouts/utils/grid-items.js 4322 var import_element18 = __toESM(require_element()); 4323 var import_jsx_runtime45 = __toESM(require_jsx_runtime()); 4324 var GridItems = (0, import_element18.forwardRef)(({ className, previewSize, ...props }, ref) => { 4325 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 4326 "div", 4327 { 4328 ref, 4329 className: clsx_default("dataviews-view-grid-items", className), 4330 style: { 4331 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax($previewSize}px, 1fr))` 4332 }, 4333 ...props 4334 } 4335 ); 4336 }); 4337 4338 // packages/dataviews/build-module/dataviews-layouts/picker-grid/index.js 4339 var import_jsx_runtime46 = __toESM(require_jsx_runtime()); 4340 var { Badge: Badge2 } = unlock(import_components19.privateApis); 4341 function GridItem3({ 4342 view, 4343 multiselect, 4344 selection, 4345 onChangeSelection, 4346 getItemId: getItemId2, 4347 item, 4348 mediaField, 4349 titleField, 4350 descriptionField, 4351 regularFields, 4352 badgeFields, 4353 config, 4354 posinset, 4355 setsize 4356 }) { 4357 const { showTitle = true, showMedia = true, showDescription = true } = view; 4358 const id = getItemId2(item); 4359 const isSelected2 = selection.includes(id); 4360 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4361 mediaField.render, 4362 { 4363 item, 4364 field: mediaField, 4365 config 4366 } 4367 ) : null; 4368 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(titleField.render, { item, field: titleField }) : null; 4369 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)( 4370 import_components19.Composite.Item, 4371 { 4372 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n16.__)("(no title)") : void 0, 4373 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components19.__experimentalVStack, { spacing: 0, children, ...props }), 4374 role: "option", 4375 "aria-posinset": posinset, 4376 "aria-setsize": setsize, 4377 className: clsx_default("dataviews-view-picker-grid__card", { 4378 "is-selected": isSelected2 4379 }), 4380 "aria-selected": isSelected2, 4381 onClick: () => { 4382 if (isSelected2) { 4383 onChangeSelection( 4384 selection.filter((itemId) => id !== itemId) 4385 ); 4386 } else { 4387 const newSelection = multiselect ? [...selection, id] : [id]; 4388 onChangeSelection(newSelection); 4389 } 4390 }, 4391 children: [ 4392 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }), 4393 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4394 DataViewsSelectionCheckbox, 4395 { 4396 item, 4397 selection, 4398 onChangeSelection, 4399 getItemId: getItemId2, 4400 titleField, 4401 disabled: false, 4402 "aria-hidden": true, 4403 tabIndex: -1 4404 } 4405 ), 4406 showTitle && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4407 import_components19.__experimentalHStack, 4408 { 4409 justify: "space-between", 4410 className: "dataviews-view-picker-grid__title-actions", 4411 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField }) 4412 } 4413 ), 4414 /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_components19.__experimentalVStack, { spacing: 1, children: [ 4415 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4416 descriptionField.render, 4417 { 4418 item, 4419 field: descriptionField 4420 } 4421 ), 4422 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4423 import_components19.__experimentalHStack, 4424 { 4425 className: "dataviews-view-picker-grid__badge-fields", 4426 spacing: 2, 4427 wrap: true, 4428 alignment: "top", 4429 justify: "flex-start", 4430 children: badgeFields.map((field) => { 4431 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4432 Badge2, 4433 { 4434 className: "dataviews-view-picker-grid__field-value", 4435 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4436 field.render, 4437 { 4438 item, 4439 field 4440 } 4441 ) 4442 }, 4443 field.id 4444 ); 4445 }) 4446 } 4447 ), 4448 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4449 import_components19.__experimentalVStack, 4450 { 4451 className: "dataviews-view-picker-grid__fields", 4452 spacing: 1, 4453 children: regularFields.map((field) => { 4454 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4455 import_components19.Flex, 4456 { 4457 className: "dataviews-view-picker-grid__field", 4458 gap: 1, 4459 justify: "flex-start", 4460 expanded: true, 4461 style: { height: "auto" }, 4462 direction: "row", 4463 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [ 4464 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components19.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }), 4465 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4466 import_components19.FlexItem, 4467 { 4468 className: "dataviews-view-picker-grid__field-value", 4469 style: { maxHeight: "none" }, 4470 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4471 field.render, 4472 { 4473 item, 4474 field 4475 } 4476 ) 4477 } 4478 ) 4479 ] }) 4480 }, 4481 field.id 4482 ); 4483 }) 4484 } 4485 ) 4486 ] }) 4487 ] 4488 }, 4489 id 4490 ); 4491 } 4492 function GridGroup({ 4493 groupName, 4494 groupField, 4495 children 4496 }) { 4497 const headerId = (0, import_compose6.useInstanceId)( 4498 GridGroup, 4499 "dataviews-view-picker-grid-group__header" 4500 ); 4501 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)( 4502 import_components19.__experimentalVStack, 4503 { 4504 spacing: 2, 4505 role: "group", 4506 "aria-labelledby": headerId, 4507 children: [ 4508 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4509 "h3", 4510 { 4511 className: "dataviews-view-picker-grid-group__header", 4512 id: headerId, 4513 children: (0, import_i18n16.sprintf)( 4514 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 4515 (0, import_i18n16.__)("%1$s: %2$s"), 4516 groupField.label, 4517 groupName 4518 ) 4519 } 4520 ), 4521 children 4522 ] 4523 }, 4524 groupName 4525 ); 4526 } 4527 function ViewPickerGrid({ 4528 actions, 4529 data, 4530 fields, 4531 getItemId: getItemId2, 4532 isLoading, 4533 onChangeSelection, 4534 selection, 4535 view, 4536 className, 4537 empty 4538 }) { 4539 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element19.useContext)(dataviews_context_default); 4540 const titleField = fields.find( 4541 (field) => field.id === view?.titleField 4542 ); 4543 const mediaField = fields.find( 4544 (field) => field.id === view?.mediaField 4545 ); 4546 const descriptionField = fields.find( 4547 (field) => field.id === view?.descriptionField 4548 ); 4549 const otherFields = view.fields ?? []; 4550 const { regularFields, badgeFields } = otherFields.reduce( 4551 (accumulator, fieldId) => { 4552 const field = fields.find((f2) => f2.id === fieldId); 4553 if (!field) { 4554 return accumulator; 4555 } 4556 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 4557 accumulator[key].push(field); 4558 return accumulator; 4559 }, 4560 { regularFields: [], badgeFields: [] } 4561 ); 4562 const hasData = !!data?.length; 4563 const usedPreviewSize = view.layout?.previewSize; 4564 const isMultiselect = useIsMultiselectPicker(actions); 4565 const size = "900px"; 4566 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 4567 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 4568 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 4569 const currentPage = view?.page ?? 1; 4570 const perPage = view?.perPage ?? 0; 4571 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0; 4572 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { 4573 // Render multiple groups. 4574 children: [ 4575 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4576 import_components19.Composite, 4577 { 4578 virtualFocus: true, 4579 orientation: "horizontal", 4580 role: "listbox", 4581 "aria-multiselectable": isMultiselect, 4582 className: clsx_default( 4583 "dataviews-view-picker-grid", 4584 className 4585 ), 4586 "aria-label": itemListLabel, 4587 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4588 import_components19.__experimentalVStack, 4589 { 4590 spacing: 4, 4591 children, 4592 ...props 4593 } 4594 ), 4595 children: Array.from(dataByGroup.entries()).map( 4596 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4597 GridGroup, 4598 { 4599 groupName, 4600 groupField, 4601 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4602 GridItems, 4603 { 4604 previewSize: usedPreviewSize, 4605 style: { 4606 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax($usedPreviewSize}px, 1fr))` 4607 }, 4608 "aria-busy": isLoading, 4609 ref: resizeObserverRef, 4610 children: groupItems.map((item) => { 4611 const posInSet = (currentPage - 1) * perPage + data.indexOf(item) + 1; 4612 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4613 GridItem3, 4614 { 4615 view, 4616 multiselect: isMultiselect, 4617 selection, 4618 onChangeSelection, 4619 getItemId: getItemId2, 4620 item, 4621 mediaField, 4622 titleField, 4623 descriptionField, 4624 regularFields, 4625 badgeFields, 4626 config: { 4627 sizes: size 4628 }, 4629 posinset: posInSet, 4630 setsize: setSize 4631 }, 4632 getItemId2(item) 4633 ); 4634 }) 4635 } 4636 ) 4637 }, 4638 groupName 4639 ) 4640 ) 4641 } 4642 ), 4643 // Render a single grid with all data. 4644 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4645 import_components19.Composite, 4646 { 4647 render: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4648 GridItems, 4649 { 4650 className: clsx_default( 4651 "dataviews-view-picker-grid", 4652 className 4653 ), 4654 previewSize: usedPreviewSize, 4655 "aria-busy": isLoading, 4656 ref: resizeObserverRef 4657 } 4658 ), 4659 virtualFocus: true, 4660 orientation: "horizontal", 4661 role: "listbox", 4662 "aria-multiselectable": isMultiselect, 4663 "aria-label": itemListLabel, 4664 children: data.map((item, index) => { 4665 let posinset = isInfiniteScroll ? index + 1 : void 0; 4666 if (!isInfiniteScroll) { 4667 posinset = (currentPage - 1) * perPage + index + 1; 4668 } 4669 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4670 GridItem3, 4671 { 4672 view, 4673 multiselect: isMultiselect, 4674 selection, 4675 onChangeSelection, 4676 getItemId: getItemId2, 4677 item, 4678 mediaField, 4679 titleField, 4680 descriptionField, 4681 regularFields, 4682 badgeFields, 4683 config: { 4684 sizes: size 4685 }, 4686 posinset, 4687 setsize: setSize 4688 }, 4689 getItemId2(item) 4690 ); 4691 }) 4692 } 4693 ), 4694 // Render empty state. 4695 !hasData && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4696 "div", 4697 { 4698 className: clsx_default({ 4699 "dataviews-loading": isLoading, 4700 "dataviews-no-results": !isLoading 4701 }), 4702 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components19.Spinner, {}) }) : empty 4703 } 4704 ), 4705 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components19.Spinner, {}) }) 4706 ] 4707 }); 4708 } 4709 var picker_grid_default = ViewPickerGrid; 4710 4711 // packages/dataviews/build-module/dataviews-layouts/picker-table/index.js 4712 var import_i18n17 = __toESM(require_i18n()); 4713 var import_components20 = __toESM(require_components()); 4714 var import_element20 = __toESM(require_element()); 4715 var import_jsx_runtime47 = __toESM(require_jsx_runtime()); 4716 function TableColumnField2({ 4717 item, 4718 fields, 4719 column, 4720 align 4721 }) { 4722 const field = fields.find((f2) => f2.id === column); 4723 if (!field) { 4724 return null; 4725 } 4726 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 4727 "dataviews-view-table__cell-align-end": align === "end", 4728 "dataviews-view-table__cell-align-center": align === "center" 4729 }); 4730 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(field.render, { item, field }) }); 4731 } 4732 function TableRow2({ 4733 item, 4734 fields, 4735 id, 4736 view, 4737 titleField, 4738 mediaField, 4739 descriptionField, 4740 selection, 4741 getItemId: getItemId2, 4742 onChangeSelection, 4743 multiselect, 4744 posinset 4745 }) { 4746 const { paginationInfo } = (0, import_element20.useContext)(dataviews_context_default); 4747 const isSelected2 = selection.includes(id); 4748 const [isHovered, setIsHovered] = (0, import_element20.useState)(false); 4749 const { 4750 showTitle = true, 4751 showMedia = true, 4752 showDescription = true, 4753 infiniteScrollEnabled 4754 } = view; 4755 const handleMouseEnter = () => { 4756 setIsHovered(true); 4757 }; 4758 const handleMouseLeave = () => { 4759 setIsHovered(false); 4760 }; 4761 const columns = view.fields ?? []; 4762 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription; 4763 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)( 4764 import_components20.Composite.Item, 4765 { 4766 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4767 "tr", 4768 { 4769 className: clsx_default("dataviews-view-table__row", { 4770 "is-selected": isSelected2, 4771 "is-hovered": isHovered 4772 }), 4773 onMouseEnter: handleMouseEnter, 4774 onMouseLeave: handleMouseLeave, 4775 children, 4776 ...props 4777 } 4778 ), 4779 "aria-selected": isSelected2, 4780 "aria-setsize": paginationInfo.totalItems || void 0, 4781 "aria-posinset": posinset, 4782 role: infiniteScrollEnabled ? "article" : "option", 4783 onClick: () => { 4784 if (isSelected2) { 4785 onChangeSelection( 4786 selection.filter((itemId) => id !== itemId) 4787 ); 4788 } else { 4789 const newSelection = multiselect ? [...selection, id] : [id]; 4790 onChangeSelection(newSelection); 4791 } 4792 }, 4793 children: [ 4794 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4795 "td", 4796 { 4797 className: "dataviews-view-table__checkbox-column", 4798 role: "presentation", 4799 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4800 DataViewsSelectionCheckbox, 4801 { 4802 item, 4803 selection, 4804 onChangeSelection, 4805 getItemId: getItemId2, 4806 titleField, 4807 disabled: false, 4808 "aria-hidden": true, 4809 tabIndex: -1 4810 } 4811 ) }) 4812 } 4813 ), 4814 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("td", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4815 column_primary_default, 4816 { 4817 item, 4818 titleField: showTitle ? titleField : void 0, 4819 mediaField: showMedia ? mediaField : void 0, 4820 descriptionField: showDescription ? descriptionField : void 0, 4821 isItemClickable: () => false 4822 } 4823 ) }), 4824 columns.map((column) => { 4825 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 4826 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4827 "td", 4828 { 4829 style: { 4830 width, 4831 maxWidth, 4832 minWidth 4833 }, 4834 role: "presentation", 4835 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4836 TableColumnField2, 4837 { 4838 fields, 4839 item, 4840 column, 4841 align 4842 } 4843 ) 4844 }, 4845 column 4846 ); 4847 }) 4848 ] 4849 }, 4850 id 4851 ); 4852 } 4853 function ViewPickerTable({ 4854 actions, 4855 data, 4856 fields, 4857 getItemId: getItemId2, 4858 isLoading = false, 4859 onChangeView, 4860 onChangeSelection, 4861 selection, 4862 setOpenedFilter, 4863 view, 4864 className, 4865 empty 4866 }) { 4867 const headerMenuRefs = (0, import_element20.useRef)(/* @__PURE__ */ new Map()); 4868 const headerMenuToFocusRef = (0, import_element20.useRef)(); 4869 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element20.useState)(); 4870 const isMultiselect = useIsMultiselectPicker(actions) ?? false; 4871 (0, import_element20.useEffect)(() => { 4872 if (headerMenuToFocusRef.current) { 4873 headerMenuToFocusRef.current.focus(); 4874 headerMenuToFocusRef.current = void 0; 4875 } 4876 }); 4877 const tableNoticeId = (0, import_element20.useId)(); 4878 if (nextHeaderMenuToFocus) { 4879 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 4880 setNextHeaderMenuToFocus(void 0); 4881 return; 4882 } 4883 const onHide = (field) => { 4884 const hidden = headerMenuRefs.current.get(field.id); 4885 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 4886 setNextHeaderMenuToFocus(fallback?.node); 4887 }; 4888 const hasData = !!data?.length; 4889 const titleField = fields.find((field) => field.id === view.titleField); 4890 const mediaField = fields.find((field) => field.id === view.mediaField); 4891 const descriptionField = fields.find( 4892 (field) => field.id === view.descriptionField 4893 ); 4894 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 4895 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 4896 const { showTitle = true, showMedia = true, showDescription = true } = view; 4897 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription; 4898 const columns = view.fields ?? []; 4899 const headerMenuRef = (column, index) => (node) => { 4900 if (node) { 4901 headerMenuRefs.current.set(column, { 4902 node, 4903 fallback: columns[index > 0 ? index - 1 : 1] 4904 }); 4905 } else { 4906 headerMenuRefs.current.delete(column); 4907 } 4908 }; 4909 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 4910 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [ 4911 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)( 4912 "table", 4913 { 4914 className: clsx_default( 4915 "dataviews-view-table", 4916 "dataviews-view-picker-table", 4917 className, 4918 { 4919 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 4920 view.layout.density 4921 ) 4922 } 4923 ), 4924 "aria-busy": isLoading, 4925 "aria-describedby": tableNoticeId, 4926 role: isInfiniteScroll ? "feed" : "listbox", 4927 children: [ 4928 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)( 4929 "tr", 4930 { 4931 className: "dataviews-view-table__row", 4932 role: "presentation", 4933 children: [ 4934 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4935 BulkSelectionCheckbox, 4936 { 4937 selection, 4938 onChangeSelection, 4939 data, 4940 actions, 4941 getItemId: getItemId2 4942 } 4943 ) }), 4944 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4945 column_header_menu_default, 4946 { 4947 ref: headerMenuRef( 4948 titleField.id, 4949 0 4950 ), 4951 fieldId: titleField.id, 4952 view, 4953 fields, 4954 onChangeView, 4955 onHide, 4956 setOpenedFilter, 4957 canMove: false 4958 } 4959 ) }), 4960 columns.map((column, index) => { 4961 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 4962 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4963 "th", 4964 { 4965 style: { 4966 width, 4967 maxWidth, 4968 minWidth, 4969 textAlign: align 4970 }, 4971 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 4972 scope: "col", 4973 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4974 column_header_menu_default, 4975 { 4976 ref: headerMenuRef(column, index), 4977 fieldId: column, 4978 view, 4979 fields, 4980 onChangeView, 4981 onHide, 4982 setOpenedFilter, 4983 canMove: view.layout?.enableMoving ?? true 4984 } 4985 ) 4986 }, 4987 column 4988 ); 4989 }) 4990 ] 4991 } 4992 ) }), 4993 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 4994 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)( 4995 import_components20.Composite, 4996 { 4997 virtualFocus: true, 4998 orientation: "vertical", 4999 render: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tbody", { role: "group" }), 5000 children: [ 5001 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 5002 "tr", 5003 { 5004 className: "dataviews-view-table__group-header-row", 5005 role: "presentation", 5006 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 5007 "td", 5008 { 5009 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1, 5010 className: "dataviews-view-table__group-header-cell", 5011 role: "presentation", 5012 children: (0, import_i18n17.sprintf)( 5013 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 5014 (0, import_i18n17.__)("%1$s: %2$s"), 5015 groupField.label, 5016 groupName 5017 ) 5018 } 5019 ) 5020 } 5021 ), 5022 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 5023 TableRow2, 5024 { 5025 item, 5026 fields, 5027 id: getItemId2(item) || index.toString(), 5028 view, 5029 titleField, 5030 mediaField, 5031 descriptionField, 5032 selection, 5033 getItemId: getItemId2, 5034 onChangeSelection, 5035 multiselect: isMultiselect 5036 }, 5037 getItemId2(item) 5038 )) 5039 ] 5040 }, 5041 `group-$groupName}` 5042 ) 5043 ) : /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 5044 import_components20.Composite, 5045 { 5046 render: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tbody", { role: "presentation" }), 5047 virtualFocus: true, 5048 orientation: "vertical", 5049 children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 5050 TableRow2, 5051 { 5052 item, 5053 fields, 5054 id: getItemId2(item) || index.toString(), 5055 view, 5056 titleField, 5057 mediaField, 5058 descriptionField, 5059 selection, 5060 getItemId: getItemId2, 5061 onChangeSelection, 5062 multiselect: isMultiselect, 5063 posinset: index + 1 5064 }, 5065 getItemId2(item) 5066 )) 5067 } 5068 ) 5069 ] 5070 } 5071 ), 5072 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)( 5073 "div", 5074 { 5075 className: clsx_default({ 5076 "dataviews-loading": isLoading, 5077 "dataviews-no-results": !hasData && !isLoading 5078 }), 5079 id: tableNoticeId, 5080 children: [ 5081 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components20.Spinner, {}) }) : empty), 5082 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components20.Spinner, {}) }) 5083 ] 5084 } 5085 ) 5086 ] }); 5087 } 5088 var picker_table_default = ViewPickerTable; 5089 5090 // packages/dataviews/build-module/dataviews-layouts/utils/preview-size-picker.js 5091 var import_components21 = __toESM(require_components()); 5092 var import_i18n18 = __toESM(require_i18n()); 5093 var import_element21 = __toESM(require_element()); 5094 var import_jsx_runtime48 = __toESM(require_jsx_runtime()); 5095 var imageSizes2 = [ 5096 { 5097 value: 120, 5098 breakpoint: 1 5099 }, 5100 { 5101 value: 170, 5102 breakpoint: 1 5103 }, 5104 { 5105 value: 230, 5106 breakpoint: 1 5107 }, 5108 { 5109 value: 290, 5110 breakpoint: 1112 5111 // at minimum image width, 4 images display at this container size 5112 }, 5113 { 5114 value: 350, 5115 breakpoint: 1636 5116 // at minimum image width, 6 images display at this container size 5117 }, 5118 { 5119 value: 430, 5120 breakpoint: 588 5121 // at minimum image width, 2 images display at this container size 5122 } 5123 ]; 5124 function PreviewSizePicker() { 5125 const context = (0, import_element21.useContext)(dataviews_context_default); 5126 const view = context.view; 5127 const breakValues = imageSizes2.filter((size) => { 5128 return context.containerWidth >= size.breakpoint; 5129 }); 5130 const layoutPreviewSize = view.layout?.previewSize ?? 230; 5131 const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0; 5132 const marks = breakValues.map((size, index) => { 5133 return { 5134 value: index 5135 }; 5136 }); 5137 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 5138 import_components21.RangeControl, 5139 { 5140 __next40pxDefaultSize: true, 5141 showTooltip: false, 5142 label: (0, import_i18n18.__)("Preview size"), 5143 value: previewSizeToUse, 5144 min: 0, 5145 max: breakValues.length - 1, 5146 withInputField: false, 5147 onChange: (value = 0) => { 5148 context.onChangeView({ 5149 ...view, 5150 layout: { 5151 ...view.layout, 5152 previewSize: breakValues[value].value 5153 } 5154 }); 5155 }, 5156 step: 1, 5157 marks 5158 } 5159 ); 5160 } 5161 5162 // packages/dataviews/build-module/dataviews-layouts/table/density-picker.js 5163 var import_components22 = __toESM(require_components()); 5164 var import_i18n19 = __toESM(require_i18n()); 5165 var import_element22 = __toESM(require_element()); 5166 var import_jsx_runtime49 = __toESM(require_jsx_runtime()); 5167 function DensityPicker() { 5168 const context = (0, import_element22.useContext)(dataviews_context_default); 5169 const view = context.view; 5170 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)( 5171 import_components22.__experimentalToggleGroupControl, 5172 { 5173 size: "__unstable-large", 5174 label: (0, import_i18n19.__)("Density"), 5175 value: view.layout?.density || "balanced", 5176 onChange: (value) => { 5177 context.onChangeView({ 5178 ...view, 5179 layout: { 5180 ...view.layout, 5181 density: value 5182 } 5183 }); 5184 }, 5185 isBlock: true, 5186 children: [ 5187 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 5188 import_components22.__experimentalToggleGroupControlOption, 5189 { 5190 value: "comfortable", 5191 label: (0, import_i18n19._x)( 5192 "Comfortable", 5193 "Density option for DataView layout" 5194 ) 5195 }, 5196 "comfortable" 5197 ), 5198 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 5199 import_components22.__experimentalToggleGroupControlOption, 5200 { 5201 value: "balanced", 5202 label: (0, import_i18n19._x)("Balanced", "Density option for DataView layout") 5203 }, 5204 "balanced" 5205 ), 5206 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 5207 import_components22.__experimentalToggleGroupControlOption, 5208 { 5209 value: "compact", 5210 label: (0, import_i18n19._x)("Compact", "Density option for DataView layout") 5211 }, 5212 "compact" 5213 ) 5214 ] 5215 } 5216 ); 5217 } 5218 5219 // packages/dataviews/build-module/dataviews-layouts/index.js 5220 var VIEW_LAYOUTS = [ 5221 { 5222 type: LAYOUT_TABLE, 5223 label: (0, import_i18n20.__)("Table"), 5224 component: table_default, 5225 icon: block_table_default, 5226 viewConfigOptions: DensityPicker 5227 }, 5228 { 5229 type: LAYOUT_GRID, 5230 label: (0, import_i18n20.__)("Grid"), 5231 component: grid_default, 5232 icon: category_default, 5233 viewConfigOptions: PreviewSizePicker 5234 }, 5235 { 5236 type: LAYOUT_LIST, 5237 label: (0, import_i18n20.__)("List"), 5238 component: ViewList, 5239 icon: (0, import_i18n20.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default 5240 }, 5241 { 5242 type: LAYOUT_ACTIVITY, 5243 label: (0, import_i18n20.__)("Activity"), 5244 component: ViewActivity, 5245 icon: scheduled_default, 5246 viewConfigOptions: DensityPicker 5247 }, 5248 { 5249 type: LAYOUT_PICKER_GRID, 5250 label: (0, import_i18n20.__)("Grid"), 5251 component: picker_grid_default, 5252 icon: category_default, 5253 viewConfigOptions: PreviewSizePicker, 5254 isPicker: true 5255 }, 5256 { 5257 type: LAYOUT_PICKER_TABLE, 5258 label: (0, import_i18n20.__)("Table"), 5259 component: picker_table_default, 5260 icon: block_table_default, 5261 viewConfigOptions: DensityPicker, 5262 isPicker: true 5263 } 5264 ]; 5265 5266 // packages/dataviews/build-module/components/dataviews-filters/filters.js 5267 var import_element30 = __toESM(require_element()); 5268 var import_components28 = __toESM(require_components()); 5269 5270 // packages/dataviews/build-module/components/dataviews-filters/filter.js 5271 var import_components25 = __toESM(require_components()); 5272 var import_i18n23 = __toESM(require_i18n()); 5273 var import_element27 = __toESM(require_element()); 5274 5275 // node_modules/@ariakit/react-core/esm/__chunks/3YLGPPWQ.js 5276 var __defProp2 = Object.defineProperty; 5277 var __defProps = Object.defineProperties; 5278 var __getOwnPropDescs = Object.getOwnPropertyDescriptors; 5279 var __getOwnPropSymbols = Object.getOwnPropertySymbols; 5280 var __hasOwnProp2 = Object.prototype.hasOwnProperty; 5281 var __propIsEnum = Object.prototype.propertyIsEnumerable; 5282 var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 5283 var __spreadValues = (a2, b2) => { 5284 for (var prop in b2 || (b2 = {})) 5285 if (__hasOwnProp2.call(b2, prop)) 5286 __defNormalProp(a2, prop, b2[prop]); 5287 if (__getOwnPropSymbols) 5288 for (var prop of __getOwnPropSymbols(b2)) { 5289 if (__propIsEnum.call(b2, prop)) 5290 __defNormalProp(a2, prop, b2[prop]); 5291 } 5292 return a2; 5293 }; 5294 var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2)); 5295 var __objRest = (source, exclude) => { 5296 var target = {}; 5297 for (var prop in source) 5298 if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0) 5299 target[prop] = source[prop]; 5300 if (source != null && __getOwnPropSymbols) 5301 for (var prop of __getOwnPropSymbols(source)) { 5302 if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) 5303 target[prop] = source[prop]; 5304 } 5305 return target; 5306 }; 5307 5308 // node_modules/@ariakit/core/esm/__chunks/3YLGPPWQ.js 5309 var __defProp3 = Object.defineProperty; 5310 var __defProps2 = Object.defineProperties; 5311 var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors; 5312 var __getOwnPropSymbols2 = Object.getOwnPropertySymbols; 5313 var __hasOwnProp3 = Object.prototype.hasOwnProperty; 5314 var __propIsEnum2 = Object.prototype.propertyIsEnumerable; 5315 var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 5316 var __spreadValues2 = (a2, b2) => { 5317 for (var prop in b2 || (b2 = {})) 5318 if (__hasOwnProp3.call(b2, prop)) 5319 __defNormalProp2(a2, prop, b2[prop]); 5320 if (__getOwnPropSymbols2) 5321 for (var prop of __getOwnPropSymbols2(b2)) { 5322 if (__propIsEnum2.call(b2, prop)) 5323 __defNormalProp2(a2, prop, b2[prop]); 5324 } 5325 return a2; 5326 }; 5327 var __spreadProps2 = (a2, b2) => __defProps2(a2, __getOwnPropDescs2(b2)); 5328 var __objRest2 = (source, exclude) => { 5329 var target = {}; 5330 for (var prop in source) 5331 if (__hasOwnProp3.call(source, prop) && exclude.indexOf(prop) < 0) 5332 target[prop] = source[prop]; 5333 if (source != null && __getOwnPropSymbols2) 5334 for (var prop of __getOwnPropSymbols2(source)) { 5335 if (exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop)) 5336 target[prop] = source[prop]; 5337 } 5338 return target; 5339 }; 5340 5341 // node_modules/@ariakit/core/esm/__chunks/PBFD2E7P.js 5342 function noop(..._) { 5343 } 5344 function applyState(argument, currentValue) { 5345 if (isUpdater(argument)) { 5346 const value = isLazyValue(currentValue) ? currentValue() : currentValue; 5347 return argument(value); 5348 } 5349 return argument; 5350 } 5351 function isUpdater(argument) { 5352 return typeof argument === "function"; 5353 } 5354 function isLazyValue(value) { 5355 return typeof value === "function"; 5356 } 5357 function hasOwnProperty(object, prop) { 5358 if (typeof Object.hasOwn === "function") { 5359 return Object.hasOwn(object, prop); 5360 } 5361 return Object.prototype.hasOwnProperty.call(object, prop); 5362 } 5363 function chain(...fns) { 5364 return (...args) => { 5365 for (const fn of fns) { 5366 if (typeof fn === "function") { 5367 fn(...args); 5368 } 5369 } 5370 }; 5371 } 5372 function normalizeString(str) { 5373 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); 5374 } 5375 function omit2(object, keys) { 5376 const result = __spreadValues2({}, object); 5377 for (const key of keys) { 5378 if (hasOwnProperty(result, key)) { 5379 delete result[key]; 5380 } 5381 } 5382 return result; 5383 } 5384 function pick(object, paths) { 5385 const result = {}; 5386 for (const key of paths) { 5387 if (hasOwnProperty(object, key)) { 5388 result[key] = object[key]; 5389 } 5390 } 5391 return result; 5392 } 5393 function identity(value) { 5394 return value; 5395 } 5396 function invariant(condition, message2) { 5397 if (condition) return; 5398 if (typeof message2 !== "string") throw new Error("Invariant failed"); 5399 throw new Error(message2); 5400 } 5401 function getKeys(obj) { 5402 return Object.keys(obj); 5403 } 5404 function isFalsyBooleanCallback(booleanOrCallback, ...args) { 5405 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback; 5406 if (result == null) return false; 5407 return !result; 5408 } 5409 function disabledFromProps(props) { 5410 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true"; 5411 } 5412 function removeUndefinedValues(obj) { 5413 const result = {}; 5414 for (const key in obj) { 5415 if (obj[key] !== void 0) { 5416 result[key] = obj[key]; 5417 } 5418 } 5419 return result; 5420 } 5421 function defaultValue(...values) { 5422 for (const value of values) { 5423 if (value !== void 0) return value; 5424 } 5425 return void 0; 5426 } 5427 5428 // node_modules/@ariakit/react-core/esm/__chunks/SK3NAZA3.js 5429 var import_react2 = __toESM(require_react(), 1); 5430 function setRef(ref, value) { 5431 if (typeof ref === "function") { 5432 ref(value); 5433 } else if (ref) { 5434 ref.current = value; 5435 } 5436 } 5437 function isValidElementWithRef(element) { 5438 if (!element) return false; 5439 if (!(0, import_react2.isValidElement)(element)) return false; 5440 if ("ref" in element.props) return true; 5441 if ("ref" in element) return true; 5442 return false; 5443 } 5444 function getRefProperty(element) { 5445 if (!isValidElementWithRef(element)) return null; 5446 const props = __spreadValues({}, element.props); 5447 return props.ref || element.ref; 5448 } 5449 function mergeProps(base, overrides) { 5450 const props = __spreadValues({}, base); 5451 for (const key in overrides) { 5452 if (!hasOwnProperty(overrides, key)) continue; 5453 if (key === "className") { 5454 const prop = "className"; 5455 props[prop] = base[prop] ? `$base[prop]} $overrides[prop]}` : overrides[prop]; 5456 continue; 5457 } 5458 if (key === "style") { 5459 const prop = "style"; 5460 props[prop] = base[prop] ? __spreadValues(__spreadValues({}, base[prop]), overrides[prop]) : overrides[prop]; 5461 continue; 5462 } 5463 const overrideValue = overrides[key]; 5464 if (typeof overrideValue === "function" && key.startsWith("on")) { 5465 const baseValue = base[key]; 5466 if (typeof baseValue === "function") { 5467 props[key] = (...args) => { 5468 overrideValue(...args); 5469 baseValue(...args); 5470 }; 5471 continue; 5472 } 5473 } 5474 props[key] = overrideValue; 5475 } 5476 return props; 5477 } 5478 5479 // node_modules/@ariakit/core/esm/__chunks/DTR5TSDJ.js 5480 var canUseDOM = checkIsBrowser(); 5481 function checkIsBrowser() { 5482 var _a; 5483 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement); 5484 } 5485 function getDocument(node) { 5486 if (!node) return document; 5487 if ("self" in node) return node.document; 5488 return node.ownerDocument || document; 5489 } 5490 function getActiveElement(node, activeDescendant = false) { 5491 const { activeElement } = getDocument(node); 5492 if (!(activeElement == null ? void 0 : activeElement.nodeName)) { 5493 return null; 5494 } 5495 if (isFrame(activeElement) && activeElement.contentDocument) { 5496 return getActiveElement( 5497 activeElement.contentDocument.body, 5498 activeDescendant 5499 ); 5500 } 5501 if (activeDescendant) { 5502 const id = activeElement.getAttribute("aria-activedescendant"); 5503 if (id) { 5504 const element = getDocument(activeElement).getElementById(id); 5505 if (element) { 5506 return element; 5507 } 5508 } 5509 } 5510 return activeElement; 5511 } 5512 function contains(parent, child) { 5513 return parent === child || parent.contains(child); 5514 } 5515 function isFrame(element) { 5516 return element.tagName === "IFRAME"; 5517 } 5518 function isButton(element) { 5519 const tagName = element.tagName.toLowerCase(); 5520 if (tagName === "button") return true; 5521 if (tagName === "input" && element.type) { 5522 return buttonInputTypes.indexOf(element.type) !== -1; 5523 } 5524 return false; 5525 } 5526 var buttonInputTypes = [ 5527 "button", 5528 "color", 5529 "file", 5530 "image", 5531 "reset", 5532 "submit" 5533 ]; 5534 function isVisible(element) { 5535 if (typeof element.checkVisibility === "function") { 5536 return element.checkVisibility(); 5537 } 5538 const htmlElement = element; 5539 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0; 5540 } 5541 function isTextField(element) { 5542 try { 5543 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null; 5544 const isTextArea = element.tagName === "TEXTAREA"; 5545 return isTextInput || isTextArea || false; 5546 } catch (error) { 5547 return false; 5548 } 5549 } 5550 function isTextbox(element) { 5551 return element.isContentEditable || isTextField(element); 5552 } 5553 function getTextboxValue(element) { 5554 if (isTextField(element)) { 5555 return element.value; 5556 } 5557 if (element.isContentEditable) { 5558 const range = getDocument(element).createRange(); 5559 range.selectNodeContents(element); 5560 return range.toString(); 5561 } 5562 return ""; 5563 } 5564 function getTextboxSelection(element) { 5565 let start = 0; 5566 let end = 0; 5567 if (isTextField(element)) { 5568 start = element.selectionStart || 0; 5569 end = element.selectionEnd || 0; 5570 } else if (element.isContentEditable) { 5571 const selection = getDocument(element).getSelection(); 5572 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) { 5573 const range = selection.getRangeAt(0); 5574 const nextRange = range.cloneRange(); 5575 nextRange.selectNodeContents(element); 5576 nextRange.setEnd(range.startContainer, range.startOffset); 5577 start = nextRange.toString().length; 5578 nextRange.setEnd(range.endContainer, range.endOffset); 5579 end = nextRange.toString().length; 5580 } 5581 } 5582 return { start, end }; 5583 } 5584 function getPopupRole(element, fallback) { 5585 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"]; 5586 const role = element == null ? void 0 : element.getAttribute("role"); 5587 if (role && allowedPopupRoles.indexOf(role) !== -1) { 5588 return role; 5589 } 5590 return fallback; 5591 } 5592 function getScrollingElement(element) { 5593 if (!element) return null; 5594 const isScrollableOverflow = (overflow) => { 5595 if (overflow === "auto") return true; 5596 if (overflow === "scroll") return true; 5597 return false; 5598 }; 5599 if (element.clientHeight && element.scrollHeight > element.clientHeight) { 5600 const { overflowY } = getComputedStyle(element); 5601 if (isScrollableOverflow(overflowY)) return element; 5602 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) { 5603 const { overflowX } = getComputedStyle(element); 5604 if (isScrollableOverflow(overflowX)) return element; 5605 } 5606 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body; 5607 } 5608 function setSelectionRange(element, ...args) { 5609 if (/text|search|password|tel|url/i.test(element.type)) { 5610 element.setSelectionRange(...args); 5611 } 5612 } 5613 function sortBasedOnDOMPosition(items, getElement) { 5614 const pairs = items.map((item, index) => [index, item]); 5615 let isOrderDifferent = false; 5616 pairs.sort(([indexA, a2], [indexB, b2]) => { 5617 const elementA = getElement(a2); 5618 const elementB = getElement(b2); 5619 if (elementA === elementB) return 0; 5620 if (!elementA || !elementB) return 0; 5621 if (isElementPreceding(elementA, elementB)) { 5622 if (indexA > indexB) { 5623 isOrderDifferent = true; 5624 } 5625 return -1; 5626 } 5627 if (indexA < indexB) { 5628 isOrderDifferent = true; 5629 } 5630 return 1; 5631 }); 5632 if (isOrderDifferent) { 5633 return pairs.map(([_, item]) => item); 5634 } 5635 return items; 5636 } 5637 function isElementPreceding(a2, b2) { 5638 return Boolean( 5639 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING 5640 ); 5641 } 5642 5643 // node_modules/@ariakit/core/esm/__chunks/QAGXQEUG.js 5644 function isTouchDevice() { 5645 return canUseDOM && !!navigator.maxTouchPoints; 5646 } 5647 function isApple() { 5648 if (!canUseDOM) return false; 5649 return /mac|iphone|ipad|ipod/i.test(navigator.platform); 5650 } 5651 function isSafari() { 5652 return canUseDOM && isApple() && /apple/i.test(navigator.vendor); 5653 } 5654 function isFirefox() { 5655 return canUseDOM && /firefox\//i.test(navigator.userAgent); 5656 } 5657 5658 // node_modules/@ariakit/core/esm/utils/events.js 5659 function isPortalEvent(event) { 5660 return Boolean( 5661 event.currentTarget && !contains(event.currentTarget, event.target) 5662 ); 5663 } 5664 function isSelfTarget(event) { 5665 return event.target === event.currentTarget; 5666 } 5667 function isOpeningInNewTab(event) { 5668 const element = event.currentTarget; 5669 if (!element) return false; 5670 const isAppleDevice = isApple(); 5671 if (isAppleDevice && !event.metaKey) return false; 5672 if (!isAppleDevice && !event.ctrlKey) return false; 5673 const tagName = element.tagName.toLowerCase(); 5674 if (tagName === "a") return true; 5675 if (tagName === "button" && element.type === "submit") return true; 5676 if (tagName === "input" && element.type === "submit") return true; 5677 return false; 5678 } 5679 function isDownloading(event) { 5680 const element = event.currentTarget; 5681 if (!element) return false; 5682 const tagName = element.tagName.toLowerCase(); 5683 if (!event.altKey) return false; 5684 if (tagName === "a") return true; 5685 if (tagName === "button" && element.type === "submit") return true; 5686 if (tagName === "input" && element.type === "submit") return true; 5687 return false; 5688 } 5689 function fireBlurEvent(element, eventInit) { 5690 const event = new FocusEvent("blur", eventInit); 5691 const defaultAllowed = element.dispatchEvent(event); 5692 const bubbleInit = __spreadProps2(__spreadValues2({}, eventInit), { bubbles: true }); 5693 element.dispatchEvent(new FocusEvent("focusout", bubbleInit)); 5694 return defaultAllowed; 5695 } 5696 function fireKeyboardEvent(element, type, eventInit) { 5697 const event = new KeyboardEvent(type, eventInit); 5698 return element.dispatchEvent(event); 5699 } 5700 function fireClickEvent(element, eventInit) { 5701 const event = new MouseEvent("click", eventInit); 5702 return element.dispatchEvent(event); 5703 } 5704 function isFocusEventOutside(event, container) { 5705 const containerElement = container || event.currentTarget; 5706 const relatedTarget = event.relatedTarget; 5707 return !relatedTarget || !contains(containerElement, relatedTarget); 5708 } 5709 function queueBeforeEvent(element, type, callback, timeout) { 5710 const createTimer = (callback2) => { 5711 if (timeout) { 5712 const timerId2 = setTimeout(callback2, timeout); 5713 return () => clearTimeout(timerId2); 5714 } 5715 const timerId = requestAnimationFrame(callback2); 5716 return () => cancelAnimationFrame(timerId); 5717 }; 5718 const cancelTimer = createTimer(() => { 5719 element.removeEventListener(type, callSync, true); 5720 callback(); 5721 }); 5722 const callSync = () => { 5723 cancelTimer(); 5724 callback(); 5725 }; 5726 element.addEventListener(type, callSync, { once: true, capture: true }); 5727 return cancelTimer; 5728 } 5729 function addGlobalEventListener(type, listener, options, scope = window) { 5730 const children = []; 5731 try { 5732 scope.document.addEventListener(type, listener, options); 5733 for (const frame of Array.from(scope.frames)) { 5734 children.push(addGlobalEventListener(type, listener, options, frame)); 5735 } 5736 } catch (e2) { 5737 } 5738 const removeEventListener = () => { 5739 try { 5740 scope.document.removeEventListener(type, listener, options); 5741 } catch (e2) { 5742 } 5743 for (const remove of children) { 5744 remove(); 5745 } 5746 }; 5747 return removeEventListener; 5748 } 5749 5750 // node_modules/@ariakit/react-core/esm/__chunks/ABQUS43J.js 5751 var import_react3 = __toESM(require_react(), 1); 5752 var React2 = __toESM(require_react(), 1); 5753 var _React = __spreadValues({}, React2); 5754 var useReactId = _React.useId; 5755 var useReactDeferredValue = _React.useDeferredValue; 5756 var useReactInsertionEffect = _React.useInsertionEffect; 5757 var useSafeLayoutEffect = canUseDOM ? import_react3.useLayoutEffect : import_react3.useEffect; 5758 function useInitialValue(value) { 5759 const [initialValue] = (0, import_react3.useState)(value); 5760 return initialValue; 5761 } 5762 function useLiveRef(value) { 5763 const ref = (0, import_react3.useRef)(value); 5764 useSafeLayoutEffect(() => { 5765 ref.current = value; 5766 }); 5767 return ref; 5768 } 5769 function useEvent(callback) { 5770 const ref = (0, import_react3.useRef)(() => { 5771 throw new Error("Cannot call an event handler while rendering."); 5772 }); 5773 if (useReactInsertionEffect) { 5774 useReactInsertionEffect(() => { 5775 ref.current = callback; 5776 }); 5777 } else { 5778 ref.current = callback; 5779 } 5780 return (0, import_react3.useCallback)((...args) => { 5781 var _a; 5782 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args); 5783 }, []); 5784 } 5785 function useTransactionState(callback) { 5786 const [state, setState] = (0, import_react3.useState)(null); 5787 useSafeLayoutEffect(() => { 5788 if (state == null) return; 5789 if (!callback) return; 5790 let prevState = null; 5791 callback((prev) => { 5792 prevState = prev; 5793 return state; 5794 }); 5795 return () => { 5796 callback(prevState); 5797 }; 5798 }, [state, callback]); 5799 return [state, setState]; 5800 } 5801 function useMergeRefs(...refs) { 5802 return (0, import_react3.useMemo)(() => { 5803 if (!refs.some(Boolean)) return; 5804 return (value) => { 5805 for (const ref of refs) { 5806 setRef(ref, value); 5807 } 5808 }; 5809 }, refs); 5810 } 5811 function useId3(defaultId) { 5812 if (useReactId) { 5813 const reactId = useReactId(); 5814 if (defaultId) return defaultId; 5815 return reactId; 5816 } 5817 const [id, setId] = (0, import_react3.useState)(defaultId); 5818 useSafeLayoutEffect(() => { 5819 if (defaultId || id) return; 5820 const random = Math.random().toString(36).slice(2, 8); 5821 setId(`id-$random}`); 5822 }, [defaultId, id]); 5823 return defaultId || id; 5824 } 5825 function useTagName(refOrElement, type) { 5826 const stringOrUndefined = (type2) => { 5827 if (typeof type2 !== "string") return; 5828 return type2; 5829 }; 5830 const [tagName, setTagName] = (0, import_react3.useState)(() => stringOrUndefined(type)); 5831 useSafeLayoutEffect(() => { 5832 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 5833 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type)); 5834 }, [refOrElement, type]); 5835 return tagName; 5836 } 5837 function useAttribute(refOrElement, attributeName, defaultValue2) { 5838 const initialValue = useInitialValue(defaultValue2); 5839 const [attribute, setAttribute] = (0, import_react3.useState)(initialValue); 5840 (0, import_react3.useEffect)(() => { 5841 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 5842 if (!element) return; 5843 const callback = () => { 5844 const value = element.getAttribute(attributeName); 5845 setAttribute(value == null ? initialValue : value); 5846 }; 5847 const observer = new MutationObserver(callback); 5848 observer.observe(element, { attributeFilter: [attributeName] }); 5849 callback(); 5850 return () => observer.disconnect(); 5851 }, [refOrElement, attributeName, initialValue]); 5852 return attribute; 5853 } 5854 function useUpdateEffect(effect, deps) { 5855 const mounted = (0, import_react3.useRef)(false); 5856 (0, import_react3.useEffect)(() => { 5857 if (mounted.current) { 5858 return effect(); 5859 } 5860 mounted.current = true; 5861 }, deps); 5862 (0, import_react3.useEffect)( 5863 () => () => { 5864 mounted.current = false; 5865 }, 5866 [] 5867 ); 5868 } 5869 function useUpdateLayoutEffect(effect, deps) { 5870 const mounted = (0, import_react3.useRef)(false); 5871 useSafeLayoutEffect(() => { 5872 if (mounted.current) { 5873 return effect(); 5874 } 5875 mounted.current = true; 5876 }, deps); 5877 useSafeLayoutEffect( 5878 () => () => { 5879 mounted.current = false; 5880 }, 5881 [] 5882 ); 5883 } 5884 function useForceUpdate() { 5885 return (0, import_react3.useReducer)(() => [], []); 5886 } 5887 function useBooleanEvent(booleanOrCallback) { 5888 return useEvent( 5889 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback 5890 ); 5891 } 5892 function useWrapElement(props, callback, deps = []) { 5893 const wrapElement = (0, import_react3.useCallback)( 5894 (element) => { 5895 if (props.wrapElement) { 5896 element = props.wrapElement(element); 5897 } 5898 return callback(element); 5899 }, 5900 [...deps, props.wrapElement] 5901 ); 5902 return __spreadProps(__spreadValues({}, props), { wrapElement }); 5903 } 5904 function useMetadataProps(props, key, value) { 5905 const parent = props.onLoadedMetadataCapture; 5906 const onLoadedMetadataCapture = (0, import_react3.useMemo)(() => { 5907 return Object.assign(() => { 5908 }, __spreadProps(__spreadValues({}, parent), { [key]: value })); 5909 }, [parent, key, value]); 5910 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }]; 5911 } 5912 function useIsMouseMoving() { 5913 (0, import_react3.useEffect)(() => { 5914 addGlobalEventListener("mousemove", setMouseMoving, true); 5915 addGlobalEventListener("mousedown", resetMouseMoving, true); 5916 addGlobalEventListener("mouseup", resetMouseMoving, true); 5917 addGlobalEventListener("keydown", resetMouseMoving, true); 5918 addGlobalEventListener("scroll", resetMouseMoving, true); 5919 }, []); 5920 const isMouseMoving = useEvent(() => mouseMoving); 5921 return isMouseMoving; 5922 } 5923 var mouseMoving = false; 5924 var previousScreenX = 0; 5925 var previousScreenY = 0; 5926 function hasMouseMovement(event) { 5927 const movementX = event.movementX || event.screenX - previousScreenX; 5928 const movementY = event.movementY || event.screenY - previousScreenY; 5929 previousScreenX = event.screenX; 5930 previousScreenY = event.screenY; 5931 return movementX || movementY || false; 5932 } 5933 function setMouseMoving(event) { 5934 if (!hasMouseMovement(event)) return; 5935 mouseMoving = true; 5936 } 5937 function resetMouseMoving() { 5938 mouseMoving = false; 5939 } 5940 5941 // node_modules/@ariakit/react-core/esm/__chunks/LMDWO4NN.js 5942 var React3 = __toESM(require_react(), 1); 5943 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1); 5944 function forwardRef22(render4) { 5945 const Role = React3.forwardRef((props, ref) => render4(__spreadProps(__spreadValues({}, props), { ref }))); 5946 Role.displayName = render4.displayName || render4.name; 5947 return Role; 5948 } 5949 function memo22(Component, propsAreEqual) { 5950 return React3.memo(Component, propsAreEqual); 5951 } 5952 function createElement2(Type, props) { 5953 const _a = props, { wrapElement, render: render4 } = _a, rest = __objRest(_a, ["wrapElement", "render"]); 5954 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4)); 5955 let element; 5956 if (React3.isValidElement(render4)) { 5957 const renderProps = __spreadProps(__spreadValues({}, render4.props), { ref: mergedRef }); 5958 element = React3.cloneElement(render4, mergeProps(rest, renderProps)); 5959 } else if (render4) { 5960 element = render4(rest); 5961 } else { 5962 element = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Type, __spreadValues({}, rest)); 5963 } 5964 if (wrapElement) { 5965 return wrapElement(element); 5966 } 5967 return element; 5968 } 5969 function createHook(useProps) { 5970 const useRole = (props = {}) => { 5971 return useProps(props); 5972 }; 5973 useRole.displayName = useProps.name; 5974 return useRole; 5975 } 5976 function createStoreContext(providers = [], scopedProviders = []) { 5977 const context = React3.createContext(void 0); 5978 const scopedContext = React3.createContext(void 0); 5979 const useContext28 = () => React3.useContext(context); 5980 const useScopedContext = (onlyScoped = false) => { 5981 const scoped = React3.useContext(scopedContext); 5982 const store = useContext28(); 5983 if (onlyScoped) return scoped; 5984 return scoped || store; 5985 }; 5986 const useProviderContext = () => { 5987 const scoped = React3.useContext(scopedContext); 5988 const store = useContext28(); 5989 if (scoped && scoped === store) return; 5990 return store; 5991 }; 5992 const ContextProvider = (props) => { 5993 return providers.reduceRight( 5994 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Provider, __spreadProps(__spreadValues({}, props), { children })), 5995 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(context.Provider, __spreadValues({}, props)) 5996 ); 5997 }; 5998 const ScopedContextProvider = (props) => { 5999 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ContextProvider, __spreadProps(__spreadValues({}, props), { children: scopedProviders.reduceRight( 6000 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Provider, __spreadProps(__spreadValues({}, props), { children })), 6001 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(scopedContext.Provider, __spreadValues({}, props)) 6002 ) })); 6003 }; 6004 return { 6005 context, 6006 scopedContext, 6007 useContext: useContext28, 6008 useScopedContext, 6009 useProviderContext, 6010 ContextProvider, 6011 ScopedContextProvider 6012 }; 6013 } 6014 6015 // node_modules/@ariakit/react-core/esm/__chunks/VDHZ5F7K.js 6016 var ctx = createStoreContext(); 6017 var useCollectionContext = ctx.useContext; 6018 var useCollectionScopedContext = ctx.useScopedContext; 6019 var useCollectionProviderContext = ctx.useProviderContext; 6020 var CollectionContextProvider = ctx.ContextProvider; 6021 var CollectionScopedContextProvider = ctx.ScopedContextProvider; 6022 6023 // node_modules/@ariakit/react-core/esm/__chunks/P7GR5CS5.js 6024 var import_react4 = __toESM(require_react(), 1); 6025 var ctx2 = createStoreContext( 6026 [CollectionContextProvider], 6027 [CollectionScopedContextProvider] 6028 ); 6029 var useCompositeContext = ctx2.useContext; 6030 var useCompositeScopedContext = ctx2.useScopedContext; 6031 var useCompositeProviderContext = ctx2.useProviderContext; 6032 var CompositeContextProvider = ctx2.ContextProvider; 6033 var CompositeScopedContextProvider = ctx2.ScopedContextProvider; 6034 var CompositeItemContext = (0, import_react4.createContext)( 6035 void 0 6036 ); 6037 var CompositeRowContext = (0, import_react4.createContext)( 6038 void 0 6039 ); 6040 6041 // node_modules/@ariakit/react-core/esm/__chunks/3XAVFTCA.js 6042 var import_react5 = __toESM(require_react(), 1); 6043 var TagValueContext = (0, import_react5.createContext)(null); 6044 var TagRemoveIdContext = (0, import_react5.createContext)( 6045 null 6046 ); 6047 var ctx3 = createStoreContext( 6048 [CompositeContextProvider], 6049 [CompositeScopedContextProvider] 6050 ); 6051 var useTagContext = ctx3.useContext; 6052 var useTagScopedContext = ctx3.useScopedContext; 6053 var useTagProviderContext = ctx3.useProviderContext; 6054 var TagContextProvider = ctx3.ContextProvider; 6055 var TagScopedContextProvider = ctx3.ScopedContextProvider; 6056 6057 // node_modules/@ariakit/core/esm/__chunks/BCALMBPZ.js 6058 function getInternal(store, key) { 6059 const internals = store.__unstableInternals; 6060 invariant(internals, "Invalid store"); 6061 return internals[key]; 6062 } 6063 function createStore(initialState, ...stores) { 6064 let state = initialState; 6065 let prevStateBatch = state; 6066 let lastUpdate = Symbol(); 6067 let destroy = noop; 6068 const instances = /* @__PURE__ */ new Set(); 6069 const updatedKeys = /* @__PURE__ */ new Set(); 6070 const setups = /* @__PURE__ */ new Set(); 6071 const listeners = /* @__PURE__ */ new Set(); 6072 const batchListeners = /* @__PURE__ */ new Set(); 6073 const disposables = /* @__PURE__ */ new WeakMap(); 6074 const listenerKeys = /* @__PURE__ */ new WeakMap(); 6075 const storeSetup = (callback) => { 6076 setups.add(callback); 6077 return () => setups.delete(callback); 6078 }; 6079 const storeInit = () => { 6080 const initialized = instances.size; 6081 const instance = Symbol(); 6082 instances.add(instance); 6083 const maybeDestroy = () => { 6084 instances.delete(instance); 6085 if (instances.size) return; 6086 destroy(); 6087 }; 6088 if (initialized) return maybeDestroy; 6089 const desyncs = getKeys(state).map( 6090 (key) => chain( 6091 ...stores.map((store) => { 6092 var _a; 6093 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store); 6094 if (!storeState) return; 6095 if (!hasOwnProperty(storeState, key)) return; 6096 return sync(store, [key], (state2) => { 6097 setState( 6098 key, 6099 state2[key], 6100 // @ts-expect-error - Not public API. This is just to prevent 6101 // infinite loops. 6102 true 6103 ); 6104 }); 6105 }) 6106 ) 6107 ); 6108 const teardowns = []; 6109 for (const setup2 of setups) { 6110 teardowns.push(setup2()); 6111 } 6112 const cleanups = stores.map(init); 6113 destroy = chain(...desyncs, ...teardowns, ...cleanups); 6114 return maybeDestroy; 6115 }; 6116 const sub = (keys, listener, set = listeners) => { 6117 set.add(listener); 6118 listenerKeys.set(listener, keys); 6119 return () => { 6120 var _a; 6121 (_a = disposables.get(listener)) == null ? void 0 : _a(); 6122 disposables.delete(listener); 6123 listenerKeys.delete(listener); 6124 set.delete(listener); 6125 }; 6126 }; 6127 const storeSubscribe = (keys, listener) => sub(keys, listener); 6128 const storeSync = (keys, listener) => { 6129 disposables.set(listener, listener(state, state)); 6130 return sub(keys, listener); 6131 }; 6132 const storeBatch = (keys, listener) => { 6133 disposables.set(listener, listener(state, prevStateBatch)); 6134 return sub(keys, listener, batchListeners); 6135 }; 6136 const storePick = (keys) => createStore(pick(state, keys), finalStore); 6137 const storeOmit = (keys) => createStore(omit2(state, keys), finalStore); 6138 const getState = () => state; 6139 const setState = (key, value, fromStores = false) => { 6140 var _a; 6141 if (!hasOwnProperty(state, key)) return; 6142 const nextValue = applyState(value, state[key]); 6143 if (nextValue === state[key]) return; 6144 if (!fromStores) { 6145 for (const store of stores) { 6146 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue); 6147 } 6148 } 6149 const prevState = state; 6150 state = __spreadProps2(__spreadValues2({}, state), { [key]: nextValue }); 6151 const thisUpdate = Symbol(); 6152 lastUpdate = thisUpdate; 6153 updatedKeys.add(key); 6154 const run = (listener, prev, uKeys) => { 6155 var _a2; 6156 const keys = listenerKeys.get(listener); 6157 const updated = (k) => uKeys ? uKeys.has(k) : k === key; 6158 if (!keys || keys.some(updated)) { 6159 (_a2 = disposables.get(listener)) == null ? void 0 : _a2(); 6160 disposables.set(listener, listener(state, prev)); 6161 } 6162 }; 6163 for (const listener of listeners) { 6164 run(listener, prevState); 6165 } 6166 queueMicrotask(() => { 6167 if (lastUpdate !== thisUpdate) return; 6168 const snapshot = state; 6169 for (const listener of batchListeners) { 6170 run(listener, prevStateBatch, updatedKeys); 6171 } 6172 prevStateBatch = snapshot; 6173 updatedKeys.clear(); 6174 }); 6175 }; 6176 const finalStore = { 6177 getState, 6178 setState, 6179 __unstableInternals: { 6180 setup: storeSetup, 6181 init: storeInit, 6182 subscribe: storeSubscribe, 6183 sync: storeSync, 6184 batch: storeBatch, 6185 pick: storePick, 6186 omit: storeOmit 6187 } 6188 }; 6189 return finalStore; 6190 } 6191 function setup(store, ...args) { 6192 if (!store) return; 6193 return getInternal(store, "setup")(...args); 6194 } 6195 function init(store, ...args) { 6196 if (!store) return; 6197 return getInternal(store, "init")(...args); 6198 } 6199 function subscribe(store, ...args) { 6200 if (!store) return; 6201 return getInternal(store, "subscribe")(...args); 6202 } 6203 function sync(store, ...args) { 6204 if (!store) return; 6205 return getInternal(store, "sync")(...args); 6206 } 6207 function batch(store, ...args) { 6208 if (!store) return; 6209 return getInternal(store, "batch")(...args); 6210 } 6211 function omit22(store, ...args) { 6212 if (!store) return; 6213 return getInternal(store, "omit")(...args); 6214 } 6215 function pick2(store, ...args) { 6216 if (!store) return; 6217 return getInternal(store, "pick")(...args); 6218 } 6219 function mergeStore(...stores) { 6220 const initialState = stores.reduce((state, store2) => { 6221 var _a; 6222 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2); 6223 if (!nextState) return state; 6224 return Object.assign(state, nextState); 6225 }, {}); 6226 const store = createStore(initialState, ...stores); 6227 return Object.assign({}, ...stores, store); 6228 } 6229 function throwOnConflictingProps(props, store) { 6230 if (false) return; 6231 if (!store) return; 6232 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => { 6233 var _a; 6234 const stateKey = key.replace("default", ""); 6235 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}$stateKey.slice(1)}`; 6236 }); 6237 if (!defaultKeys.length) return; 6238 const storeState = store.getState(); 6239 const conflictingProps = defaultKeys.filter( 6240 (key) => hasOwnProperty(storeState, key) 6241 ); 6242 if (!conflictingProps.length) return; 6243 throw new Error( 6244 `Passing a store prop in conjunction with a default state is not supported. 6245 6246 const store = useSelectStore(); 6247 <SelectProvider store={store} defaultValue="Apple" /> 6248 ^ ^ 6249 6250 Instead, pass the default state to the topmost store: 6251 6252 const store = useSelectStore({ defaultValue: "Apple" }); 6253 <SelectProvider store={store} /> 6254 6255 See https://github.com/ariakit/ariakit/pull/2745 for more details. 6256 6257 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit 6258 ` 6259 ); 6260 } 6261 6262 // node_modules/@ariakit/react-core/esm/__chunks/YV4JVR4I.js 6263 var React4 = __toESM(require_react(), 1); 6264 var import_shim = __toESM(require_shim(), 1); 6265 var { useSyncExternalStore } = import_shim.default; 6266 var noopSubscribe = () => () => { 6267 }; 6268 function useStoreState(store, keyOrSelector = identity) { 6269 const storeSubscribe = React4.useCallback( 6270 (callback) => { 6271 if (!store) return noopSubscribe(); 6272 return subscribe(store, null, callback); 6273 }, 6274 [store] 6275 ); 6276 const getSnapshot = () => { 6277 const key = typeof keyOrSelector === "string" ? keyOrSelector : null; 6278 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null; 6279 const state = store == null ? void 0 : store.getState(); 6280 if (selector2) return selector2(state); 6281 if (!state) return; 6282 if (!key) return; 6283 if (!hasOwnProperty(state, key)) return; 6284 return state[key]; 6285 }; 6286 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot); 6287 } 6288 function useStoreStateObject(store, object) { 6289 const objRef = React4.useRef( 6290 {} 6291 ); 6292 const storeSubscribe = React4.useCallback( 6293 (callback) => { 6294 if (!store) return noopSubscribe(); 6295 return subscribe(store, null, callback); 6296 }, 6297 [store] 6298 ); 6299 const getSnapshot = () => { 6300 const state = store == null ? void 0 : store.getState(); 6301 let updated = false; 6302 const obj = objRef.current; 6303 for (const prop in object) { 6304 const keyOrSelector = object[prop]; 6305 if (typeof keyOrSelector === "function") { 6306 const value = keyOrSelector(state); 6307 if (value !== obj[prop]) { 6308 obj[prop] = value; 6309 updated = true; 6310 } 6311 } 6312 if (typeof keyOrSelector === "string") { 6313 if (!state) continue; 6314 if (!hasOwnProperty(state, keyOrSelector)) continue; 6315 const value = state[keyOrSelector]; 6316 if (value !== obj[prop]) { 6317 obj[prop] = value; 6318 updated = true; 6319 } 6320 } 6321 } 6322 if (updated) { 6323 objRef.current = __spreadValues({}, obj); 6324 } 6325 return objRef.current; 6326 }; 6327 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot); 6328 } 6329 function useStoreProps(store, props, key, setKey) { 6330 const value = hasOwnProperty(props, key) ? props[key] : void 0; 6331 const setValue = setKey ? props[setKey] : void 0; 6332 const propsRef = useLiveRef({ value, setValue }); 6333 useSafeLayoutEffect(() => { 6334 return sync(store, [key], (state, prev) => { 6335 const { value: value2, setValue: setValue2 } = propsRef.current; 6336 if (!setValue2) return; 6337 if (state[key] === prev[key]) return; 6338 if (state[key] === value2) return; 6339 setValue2(state[key]); 6340 }); 6341 }, [store, key]); 6342 useSafeLayoutEffect(() => { 6343 if (value === void 0) return; 6344 store.setState(key, value); 6345 return batch(store, [key], () => { 6346 if (value === void 0) return; 6347 store.setState(key, value); 6348 }); 6349 }); 6350 } 6351 function useStore(createStore2, props) { 6352 const [store, setStore] = React4.useState(() => createStore2(props)); 6353 useSafeLayoutEffect(() => init(store), [store]); 6354 const useState24 = React4.useCallback( 6355 (keyOrSelector) => useStoreState(store, keyOrSelector), 6356 [store] 6357 ); 6358 const memoizedStore = React4.useMemo( 6359 () => __spreadProps(__spreadValues({}, store), { useState: useState24 }), 6360 [store, useState24] 6361 ); 6362 const updateStore = useEvent(() => { 6363 setStore((store2) => createStore2(__spreadValues(__spreadValues({}, props), store2.getState()))); 6364 }); 6365 return [memoizedStore, updateStore]; 6366 } 6367 6368 // node_modules/@ariakit/core/esm/__chunks/CYQWQL4J.js 6369 function getCommonParent(items) { 6370 var _a; 6371 const firstItem = items.find((item) => !!item.element); 6372 const lastItem = [...items].reverse().find((item) => !!item.element); 6373 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement; 6374 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) { 6375 const parent = parentElement; 6376 if (lastItem && parent.contains(lastItem.element)) { 6377 return parentElement; 6378 } 6379 parentElement = parentElement.parentElement; 6380 } 6381 return getDocument(parentElement).body; 6382 } 6383 function getPrivateStore(store) { 6384 return store == null ? void 0 : store.__unstablePrivateStore; 6385 } 6386 function createCollectionStore(props = {}) { 6387 var _a; 6388 throwOnConflictingProps(props, props.store); 6389 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 6390 const items = defaultValue( 6391 props.items, 6392 syncState == null ? void 0 : syncState.items, 6393 props.defaultItems, 6394 [] 6395 ); 6396 const itemsMap = new Map(items.map((item) => [item.id, item])); 6397 const initialState = { 6398 items, 6399 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, []) 6400 }; 6401 const syncPrivateStore = getPrivateStore(props.store); 6402 const privateStore = createStore( 6403 { items, renderedItems: initialState.renderedItems }, 6404 syncPrivateStore 6405 ); 6406 const collection = createStore(initialState, props.store); 6407 const sortItems = (renderedItems) => { 6408 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element); 6409 privateStore.setState("renderedItems", sortedItems); 6410 collection.setState("renderedItems", sortedItems); 6411 }; 6412 setup(collection, () => init(privateStore)); 6413 setup(privateStore, () => { 6414 return batch(privateStore, ["items"], (state) => { 6415 collection.setState("items", state.items); 6416 }); 6417 }); 6418 setup(privateStore, () => { 6419 return batch(privateStore, ["renderedItems"], (state) => { 6420 let firstRun = true; 6421 let raf = requestAnimationFrame(() => { 6422 const { renderedItems } = collection.getState(); 6423 if (state.renderedItems === renderedItems) return; 6424 sortItems(state.renderedItems); 6425 }); 6426 if (typeof IntersectionObserver !== "function") { 6427 return () => cancelAnimationFrame(raf); 6428 } 6429 const ioCallback = () => { 6430 if (firstRun) { 6431 firstRun = false; 6432 return; 6433 } 6434 cancelAnimationFrame(raf); 6435 raf = requestAnimationFrame(() => sortItems(state.renderedItems)); 6436 }; 6437 const root = getCommonParent(state.renderedItems); 6438 const observer = new IntersectionObserver(ioCallback, { root }); 6439 for (const item of state.renderedItems) { 6440 if (!item.element) continue; 6441 observer.observe(item.element); 6442 } 6443 return () => { 6444 cancelAnimationFrame(raf); 6445 observer.disconnect(); 6446 }; 6447 }); 6448 }); 6449 const mergeItem = (item, setItems, canDeleteFromMap = false) => { 6450 let prevItem; 6451 setItems((items2) => { 6452 const index = items2.findIndex(({ id }) => id === item.id); 6453 const nextItems = items2.slice(); 6454 if (index !== -1) { 6455 prevItem = items2[index]; 6456 const nextItem = __spreadValues2(__spreadValues2({}, prevItem), item); 6457 nextItems[index] = nextItem; 6458 itemsMap.set(item.id, nextItem); 6459 } else { 6460 nextItems.push(item); 6461 itemsMap.set(item.id, item); 6462 } 6463 return nextItems; 6464 }); 6465 const unmergeItem = () => { 6466 setItems((items2) => { 6467 if (!prevItem) { 6468 if (canDeleteFromMap) { 6469 itemsMap.delete(item.id); 6470 } 6471 return items2.filter(({ id }) => id !== item.id); 6472 } 6473 const index = items2.findIndex(({ id }) => id === item.id); 6474 if (index === -1) return items2; 6475 const nextItems = items2.slice(); 6476 nextItems[index] = prevItem; 6477 itemsMap.set(item.id, prevItem); 6478 return nextItems; 6479 }); 6480 }; 6481 return unmergeItem; 6482 }; 6483 const registerItem = (item) => mergeItem( 6484 item, 6485 (getItems) => privateStore.setState("items", getItems), 6486 true 6487 ); 6488 return __spreadProps2(__spreadValues2({}, collection), { 6489 registerItem, 6490 renderItem: (item) => chain( 6491 registerItem(item), 6492 mergeItem( 6493 item, 6494 (getItems) => privateStore.setState("renderedItems", getItems) 6495 ) 6496 ), 6497 item: (id) => { 6498 if (!id) return null; 6499 let item = itemsMap.get(id); 6500 if (!item) { 6501 const { items: items2 } = privateStore.getState(); 6502 item = items2.find((item2) => item2.id === id); 6503 if (item) { 6504 itemsMap.set(id, item); 6505 } 6506 } 6507 return item || null; 6508 }, 6509 // @ts-expect-error Internal 6510 __unstablePrivateStore: privateStore 6511 }); 6512 } 6513 6514 // node_modules/@ariakit/react-core/esm/__chunks/C3IKGW5T.js 6515 function useCollectionStoreProps(store, update, props) { 6516 useUpdateEffect(update, [props.store]); 6517 useStoreProps(store, props, "items", "setItems"); 6518 return store; 6519 } 6520 6521 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js 6522 function toArray(arg) { 6523 if (Array.isArray(arg)) { 6524 return arg; 6525 } 6526 return typeof arg !== "undefined" ? [arg] : []; 6527 } 6528 function flatten2DArray(array) { 6529 const flattened = []; 6530 for (const row of array) { 6531 flattened.push(...row); 6532 } 6533 return flattened; 6534 } 6535 function reverseArray(array) { 6536 return array.slice().reverse(); 6537 } 6538 6539 // node_modules/@ariakit/core/esm/__chunks/AJZ4BYF3.js 6540 var NULL_ITEM = { id: null }; 6541 function findFirstEnabledItem(items, excludeId) { 6542 return items.find((item) => { 6543 if (excludeId) { 6544 return !item.disabled && item.id !== excludeId; 6545 } 6546 return !item.disabled; 6547 }); 6548 } 6549 function getEnabledItems(items, excludeId) { 6550 return items.filter((item) => { 6551 if (excludeId) { 6552 return !item.disabled && item.id !== excludeId; 6553 } 6554 return !item.disabled; 6555 }); 6556 } 6557 function getItemsInRow(items, rowId) { 6558 return items.filter((item) => item.rowId === rowId); 6559 } 6560 function flipItems(items, activeId, shouldInsertNullItem = false) { 6561 const index = items.findIndex((item) => item.id === activeId); 6562 return [ 6563 ...items.slice(index + 1), 6564 ...shouldInsertNullItem ? [NULL_ITEM] : [], 6565 ...items.slice(0, index) 6566 ]; 6567 } 6568 function groupItemsByRows(items) { 6569 const rows = []; 6570 for (const item of items) { 6571 const row = rows.find((currentRow) => { 6572 var _a; 6573 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 6574 }); 6575 if (row) { 6576 row.push(item); 6577 } else { 6578 rows.push([item]); 6579 } 6580 } 6581 return rows; 6582 } 6583 function getMaxRowLength(array) { 6584 let maxLength = 0; 6585 for (const { length } of array) { 6586 if (length > maxLength) { 6587 maxLength = length; 6588 } 6589 } 6590 return maxLength; 6591 } 6592 function createEmptyItem(rowId) { 6593 return { 6594 id: "__EMPTY_ITEM__", 6595 disabled: true, 6596 rowId 6597 }; 6598 } 6599 function normalizeRows(rows, activeId, focusShift) { 6600 const maxLength = getMaxRowLength(rows); 6601 for (const row of rows) { 6602 for (let i2 = 0; i2 < maxLength; i2 += 1) { 6603 const item = row[i2]; 6604 if (!item || focusShift && item.disabled) { 6605 const isFirst = i2 === 0; 6606 const previousItem = isFirst && focusShift ? findFirstEnabledItem(row) : row[i2 - 1]; 6607 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId); 6608 } 6609 } 6610 } 6611 return rows; 6612 } 6613 function verticalizeItems(items) { 6614 const rows = groupItemsByRows(items); 6615 const maxLength = getMaxRowLength(rows); 6616 const verticalized = []; 6617 for (let i2 = 0; i2 < maxLength; i2 += 1) { 6618 for (const row of rows) { 6619 const item = row[i2]; 6620 if (item) { 6621 verticalized.push(__spreadProps2(__spreadValues2({}, item), { 6622 // If there's no rowId, it means that it's not a grid composite, but 6623 // a single row instead. So, instead of verticalizing it, that is, 6624 // assigning a different rowId based on the column index, we keep it 6625 // undefined so they will be part of the same row. This is useful 6626 // when using up/down on one-dimensional composites. 6627 rowId: item.rowId ? `$i2}` : void 0 6628 })); 6629 } 6630 } 6631 } 6632 return verticalized; 6633 } 6634 function createCompositeStore(props = {}) { 6635 var _a; 6636 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 6637 const collection = createCollectionStore(props); 6638 const activeId = defaultValue( 6639 props.activeId, 6640 syncState == null ? void 0 : syncState.activeId, 6641 props.defaultActiveId 6642 ); 6643 const initialState = __spreadProps2(__spreadValues2({}, collection.getState()), { 6644 id: defaultValue( 6645 props.id, 6646 syncState == null ? void 0 : syncState.id, 6647 `id-$Math.random().toString(36).slice(2, 8)}` 6648 ), 6649 activeId, 6650 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null), 6651 includesBaseElement: defaultValue( 6652 props.includesBaseElement, 6653 syncState == null ? void 0 : syncState.includesBaseElement, 6654 activeId === null 6655 ), 6656 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0), 6657 orientation: defaultValue( 6658 props.orientation, 6659 syncState == null ? void 0 : syncState.orientation, 6660 "both" 6661 ), 6662 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false), 6663 virtualFocus: defaultValue( 6664 props.virtualFocus, 6665 syncState == null ? void 0 : syncState.virtualFocus, 6666 false 6667 ), 6668 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false), 6669 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false), 6670 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false) 6671 }); 6672 const composite = createStore(initialState, collection, props.store); 6673 setup( 6674 composite, 6675 () => sync(composite, ["renderedItems", "activeId"], (state) => { 6676 composite.setState("activeId", (activeId2) => { 6677 var _a2; 6678 if (activeId2 !== void 0) return activeId2; 6679 return (_a2 = findFirstEnabledItem(state.renderedItems)) == null ? void 0 : _a2.id; 6680 }); 6681 }) 6682 ); 6683 const getNextId = (direction = "next", options = {}) => { 6684 var _a2, _b; 6685 const defaultState = composite.getState(); 6686 const { 6687 skip = 0, 6688 activeId: activeId2 = defaultState.activeId, 6689 focusShift = defaultState.focusShift, 6690 focusLoop = defaultState.focusLoop, 6691 focusWrap = defaultState.focusWrap, 6692 includesBaseElement = defaultState.includesBaseElement, 6693 renderedItems = defaultState.renderedItems, 6694 rtl = defaultState.rtl 6695 } = options; 6696 const isVerticalDirection = direction === "up" || direction === "down"; 6697 const isNextDirection = direction === "next" || direction === "down"; 6698 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection; 6699 const canShift = focusShift && !skip; 6700 let items = !isVerticalDirection ? renderedItems : flatten2DArray( 6701 normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift) 6702 ); 6703 items = canReverse ? reverseArray(items) : items; 6704 items = isVerticalDirection ? verticalizeItems(items) : items; 6705 if (activeId2 == null) { 6706 return (_a2 = findFirstEnabledItem(items)) == null ? void 0 : _a2.id; 6707 } 6708 const activeItem = items.find((item) => item.id === activeId2); 6709 if (!activeItem) { 6710 return (_b = findFirstEnabledItem(items)) == null ? void 0 : _b.id; 6711 } 6712 const isGrid2 = items.some((item) => item.rowId); 6713 const activeIndex = items.indexOf(activeItem); 6714 const nextItems = items.slice(activeIndex + 1); 6715 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId); 6716 if (skip) { 6717 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2); 6718 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one. 6719 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1]; 6720 return nextItem2 == null ? void 0 : nextItem2.id; 6721 } 6722 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"); 6723 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical"); 6724 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false; 6725 if (canLoop) { 6726 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId); 6727 const sortedItems = flipItems(loopItems, activeId2, hasNullItem); 6728 const nextItem2 = findFirstEnabledItem(sortedItems, activeId2); 6729 return nextItem2 == null ? void 0 : nextItem2.id; 6730 } 6731 if (canWrap) { 6732 const nextItem2 = findFirstEnabledItem( 6733 // We can use nextItems, which contains all the next items, including 6734 // items from other rows, to wrap between rows. However, if there is a 6735 // null item (the composite container), we'll only use the next items in 6736 // the row. So moving next from the last item will focus on the 6737 // composite container. On grid composites, horizontal navigation never 6738 // focuses on the composite container, only vertical. 6739 hasNullItem ? nextItemsInRow : nextItems, 6740 activeId2 6741 ); 6742 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id; 6743 return nextId; 6744 } 6745 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2); 6746 if (!nextItem && hasNullItem) { 6747 return null; 6748 } 6749 return nextItem == null ? void 0 : nextItem.id; 6750 }; 6751 return __spreadProps2(__spreadValues2(__spreadValues2({}, collection), composite), { 6752 setBaseElement: (element) => composite.setState("baseElement", element), 6753 setActiveId: (id) => composite.setState("activeId", id), 6754 move: (id) => { 6755 if (id === void 0) return; 6756 composite.setState("activeId", id); 6757 composite.setState("moves", (moves) => moves + 1); 6758 }, 6759 first: () => { 6760 var _a2; 6761 return (_a2 = findFirstEnabledItem(composite.getState().renderedItems)) == null ? void 0 : _a2.id; 6762 }, 6763 last: () => { 6764 var _a2; 6765 return (_a2 = findFirstEnabledItem(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id; 6766 }, 6767 next: (options) => { 6768 if (options !== void 0 && typeof options === "number") { 6769 options = { skip: options }; 6770 } 6771 return getNextId("next", options); 6772 }, 6773 previous: (options) => { 6774 if (options !== void 0 && typeof options === "number") { 6775 options = { skip: options }; 6776 } 6777 return getNextId("previous", options); 6778 }, 6779 down: (options) => { 6780 if (options !== void 0 && typeof options === "number") { 6781 options = { skip: options }; 6782 } 6783 return getNextId("down", options); 6784 }, 6785 up: (options) => { 6786 if (options !== void 0 && typeof options === "number") { 6787 options = { skip: options }; 6788 } 6789 return getNextId("up", options); 6790 } 6791 }); 6792 } 6793 6794 // node_modules/@ariakit/react-core/esm/__chunks/4CMBR7SL.js 6795 function useCompositeStoreOptions(props) { 6796 const id = useId3(props.id); 6797 return __spreadValues({ id }, props); 6798 } 6799 function useCompositeStoreProps(store, update, props) { 6800 store = useCollectionStoreProps(store, update, props); 6801 useStoreProps(store, props, "activeId", "setActiveId"); 6802 useStoreProps(store, props, "includesBaseElement"); 6803 useStoreProps(store, props, "virtualFocus"); 6804 useStoreProps(store, props, "orientation"); 6805 useStoreProps(store, props, "rtl"); 6806 useStoreProps(store, props, "focusLoop"); 6807 useStoreProps(store, props, "focusWrap"); 6808 useStoreProps(store, props, "focusShift"); 6809 return store; 6810 } 6811 6812 // node_modules/@ariakit/core/esm/__chunks/RCQ5P4YE.js 6813 function createDisclosureStore(props = {}) { 6814 const store = mergeStore( 6815 props.store, 6816 omit22(props.disclosure, ["contentElement", "disclosureElement"]) 6817 ); 6818 throwOnConflictingProps(props, store); 6819 const syncState = store == null ? void 0 : store.getState(); 6820 const open = defaultValue( 6821 props.open, 6822 syncState == null ? void 0 : syncState.open, 6823 props.defaultOpen, 6824 false 6825 ); 6826 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false); 6827 const initialState = { 6828 open, 6829 animated, 6830 animating: !!animated && open, 6831 mounted: open, 6832 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null), 6833 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null) 6834 }; 6835 const disclosure = createStore(initialState, store); 6836 setup( 6837 disclosure, 6838 () => sync(disclosure, ["animated", "animating"], (state) => { 6839 if (state.animated) return; 6840 disclosure.setState("animating", false); 6841 }) 6842 ); 6843 setup( 6844 disclosure, 6845 () => subscribe(disclosure, ["open"], () => { 6846 if (!disclosure.getState().animated) return; 6847 disclosure.setState("animating", true); 6848 }) 6849 ); 6850 setup( 6851 disclosure, 6852 () => sync(disclosure, ["open", "animating"], (state) => { 6853 disclosure.setState("mounted", state.open || state.animating); 6854 }) 6855 ); 6856 return __spreadProps2(__spreadValues2({}, disclosure), { 6857 disclosure: props.disclosure, 6858 setOpen: (value) => disclosure.setState("open", value), 6859 show: () => disclosure.setState("open", true), 6860 hide: () => disclosure.setState("open", false), 6861 toggle: () => disclosure.setState("open", (open2) => !open2), 6862 stopAnimation: () => disclosure.setState("animating", false), 6863 setContentElement: (value) => disclosure.setState("contentElement", value), 6864 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value) 6865 }); 6866 } 6867 6868 // node_modules/@ariakit/react-core/esm/__chunks/WYCIER3C.js 6869 function useDisclosureStoreProps(store, update, props) { 6870 useUpdateEffect(update, [props.store, props.disclosure]); 6871 useStoreProps(store, props, "open", "setOpen"); 6872 useStoreProps(store, props, "mounted", "setMounted"); 6873 useStoreProps(store, props, "animated"); 6874 return Object.assign(store, { disclosure: props.disclosure }); 6875 } 6876 6877 // node_modules/@ariakit/core/esm/__chunks/FZZ2AVHF.js 6878 function createDialogStore(props = {}) { 6879 return createDisclosureStore(props); 6880 } 6881 6882 // node_modules/@ariakit/react-core/esm/__chunks/BM6PGYQY.js 6883 function useDialogStoreProps(store, update, props) { 6884 return useDisclosureStoreProps(store, update, props); 6885 } 6886 6887 // node_modules/@ariakit/core/esm/__chunks/ME2CUF3F.js 6888 function createPopoverStore(_a = {}) { 6889 var _b = _a, { 6890 popover: otherPopover 6891 } = _b, props = __objRest2(_b, [ 6892 "popover" 6893 ]); 6894 const store = mergeStore( 6895 props.store, 6896 omit22(otherPopover, [ 6897 "arrowElement", 6898 "anchorElement", 6899 "contentElement", 6900 "popoverElement", 6901 "disclosureElement" 6902 ]) 6903 ); 6904 throwOnConflictingProps(props, store); 6905 const syncState = store == null ? void 0 : store.getState(); 6906 const dialog = createDialogStore(__spreadProps2(__spreadValues2({}, props), { store })); 6907 const placement = defaultValue( 6908 props.placement, 6909 syncState == null ? void 0 : syncState.placement, 6910 "bottom" 6911 ); 6912 const initialState = __spreadProps2(__spreadValues2({}, dialog.getState()), { 6913 placement, 6914 currentPlacement: placement, 6915 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null), 6916 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null), 6917 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null), 6918 rendered: Symbol("rendered") 6919 }); 6920 const popover = createStore(initialState, dialog, store); 6921 return __spreadProps2(__spreadValues2(__spreadValues2({}, dialog), popover), { 6922 setAnchorElement: (element) => popover.setState("anchorElement", element), 6923 setPopoverElement: (element) => popover.setState("popoverElement", element), 6924 setArrowElement: (element) => popover.setState("arrowElement", element), 6925 render: () => popover.setState("rendered", Symbol("rendered")) 6926 }); 6927 } 6928 6929 // node_modules/@ariakit/react-core/esm/__chunks/O2PQ2652.js 6930 function usePopoverStoreProps(store, update, props) { 6931 useUpdateEffect(update, [props.popover]); 6932 useStoreProps(store, props, "placement"); 6933 return useDialogStoreProps(store, update, props); 6934 } 6935 6936 // node_modules/@ariakit/core/esm/combobox/combobox-store.js 6937 var isTouchSafari = isSafari() && isTouchDevice(); 6938 function createComboboxStore(_a = {}) { 6939 var _b = _a, { 6940 tag 6941 } = _b, props = __objRest2(_b, [ 6942 "tag" 6943 ]); 6944 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"])); 6945 throwOnConflictingProps(props, store); 6946 const tagState = tag == null ? void 0 : tag.getState(); 6947 const syncState = store == null ? void 0 : store.getState(); 6948 const activeId = defaultValue( 6949 props.activeId, 6950 syncState == null ? void 0 : syncState.activeId, 6951 props.defaultActiveId, 6952 null 6953 ); 6954 const composite = createCompositeStore(__spreadProps2(__spreadValues2({}, props), { 6955 activeId, 6956 includesBaseElement: defaultValue( 6957 props.includesBaseElement, 6958 syncState == null ? void 0 : syncState.includesBaseElement, 6959 true 6960 ), 6961 orientation: defaultValue( 6962 props.orientation, 6963 syncState == null ? void 0 : syncState.orientation, 6964 "vertical" 6965 ), 6966 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true), 6967 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true), 6968 virtualFocus: defaultValue( 6969 props.virtualFocus, 6970 syncState == null ? void 0 : syncState.virtualFocus, 6971 true 6972 ) 6973 })); 6974 const popover = createPopoverStore(__spreadProps2(__spreadValues2({}, props), { 6975 placement: defaultValue( 6976 props.placement, 6977 syncState == null ? void 0 : syncState.placement, 6978 "bottom-start" 6979 ) 6980 })); 6981 const value = defaultValue( 6982 props.value, 6983 syncState == null ? void 0 : syncState.value, 6984 props.defaultValue, 6985 "" 6986 ); 6987 const selectedValue = defaultValue( 6988 props.selectedValue, 6989 syncState == null ? void 0 : syncState.selectedValue, 6990 tagState == null ? void 0 : tagState.values, 6991 props.defaultSelectedValue, 6992 "" 6993 ); 6994 const multiSelectable = Array.isArray(selectedValue); 6995 const initialState = __spreadProps2(__spreadValues2(__spreadValues2({}, composite.getState()), popover.getState()), { 6996 value, 6997 selectedValue, 6998 resetValueOnSelect: defaultValue( 6999 props.resetValueOnSelect, 7000 syncState == null ? void 0 : syncState.resetValueOnSelect, 7001 multiSelectable 7002 ), 7003 resetValueOnHide: defaultValue( 7004 props.resetValueOnHide, 7005 syncState == null ? void 0 : syncState.resetValueOnHide, 7006 multiSelectable && !tag 7007 ), 7008 activeValue: syncState == null ? void 0 : syncState.activeValue 7009 }); 7010 const combobox = createStore(initialState, composite, popover, store); 7011 if (isTouchSafari) { 7012 setup( 7013 combobox, 7014 () => sync(combobox, ["virtualFocus"], () => { 7015 combobox.setState("virtualFocus", false); 7016 }) 7017 ); 7018 } 7019 setup(combobox, () => { 7020 if (!tag) return; 7021 return chain( 7022 sync(combobox, ["selectedValue"], (state) => { 7023 if (!Array.isArray(state.selectedValue)) return; 7024 tag.setValues(state.selectedValue); 7025 }), 7026 sync(tag, ["values"], (state) => { 7027 combobox.setState("selectedValue", state.values); 7028 }) 7029 ); 7030 }); 7031 setup( 7032 combobox, 7033 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => { 7034 if (!state.resetValueOnHide) return; 7035 if (state.mounted) return; 7036 combobox.setState("value", value); 7037 }) 7038 ); 7039 setup( 7040 combobox, 7041 () => sync(combobox, ["open"], (state) => { 7042 if (state.open) return; 7043 combobox.setState("activeId", activeId); 7044 combobox.setState("moves", 0); 7045 }) 7046 ); 7047 setup( 7048 combobox, 7049 () => sync(combobox, ["moves", "activeId"], (state, prevState) => { 7050 if (state.moves === prevState.moves) { 7051 combobox.setState("activeValue", void 0); 7052 } 7053 }) 7054 ); 7055 setup( 7056 combobox, 7057 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => { 7058 if (state.moves === prev.moves) return; 7059 const { activeId: activeId2 } = combobox.getState(); 7060 const activeItem = composite.item(activeId2); 7061 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value); 7062 }) 7063 ); 7064 return __spreadProps2(__spreadValues2(__spreadValues2(__spreadValues2({}, popover), composite), combobox), { 7065 tag, 7066 setValue: (value2) => combobox.setState("value", value2), 7067 resetValue: () => combobox.setState("value", initialState.value), 7068 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2) 7069 }); 7070 } 7071 7072 // node_modules/@ariakit/react-core/esm/__chunks/FEOFMWBY.js 7073 function useComboboxStoreOptions(props) { 7074 const tag = useTagContext(); 7075 props = __spreadProps(__spreadValues({}, props), { 7076 tag: props.tag !== void 0 ? props.tag : tag 7077 }); 7078 return useCompositeStoreOptions(props); 7079 } 7080 function useComboboxStoreProps(store, update, props) { 7081 useUpdateEffect(update, [props.tag]); 7082 useStoreProps(store, props, "value", "setValue"); 7083 useStoreProps(store, props, "selectedValue", "setSelectedValue"); 7084 useStoreProps(store, props, "resetValueOnHide"); 7085 useStoreProps(store, props, "resetValueOnSelect"); 7086 return Object.assign( 7087 useCompositeStoreProps( 7088 usePopoverStoreProps(store, update, props), 7089 update, 7090 props 7091 ), 7092 { tag: props.tag } 7093 ); 7094 } 7095 function useComboboxStore(props = {}) { 7096 props = useComboboxStoreOptions(props); 7097 const [store, update] = useStore(createComboboxStore, props); 7098 return useComboboxStoreProps(store, update, props); 7099 } 7100 7101 // node_modules/@ariakit/react-core/esm/__chunks/S6EF7IVO.js 7102 var ctx4 = createStoreContext(); 7103 var useDisclosureContext = ctx4.useContext; 7104 var useDisclosureScopedContext = ctx4.useScopedContext; 7105 var useDisclosureProviderContext = ctx4.useProviderContext; 7106 var DisclosureContextProvider = ctx4.ContextProvider; 7107 var DisclosureScopedContextProvider = ctx4.ScopedContextProvider; 7108 7109 // node_modules/@ariakit/react-core/esm/__chunks/RS7LB2H4.js 7110 var import_react6 = __toESM(require_react(), 1); 7111 var ctx5 = createStoreContext( 7112 [DisclosureContextProvider], 7113 [DisclosureScopedContextProvider] 7114 ); 7115 var useDialogContext = ctx5.useContext; 7116 var useDialogScopedContext = ctx5.useScopedContext; 7117 var useDialogProviderContext = ctx5.useProviderContext; 7118 var DialogContextProvider = ctx5.ContextProvider; 7119 var DialogScopedContextProvider = ctx5.ScopedContextProvider; 7120 var DialogHeadingContext = (0, import_react6.createContext)(void 0); 7121 var DialogDescriptionContext = (0, import_react6.createContext)(void 0); 7122 7123 // node_modules/@ariakit/react-core/esm/__chunks/MTZPJQMC.js 7124 var ctx6 = createStoreContext( 7125 [DialogContextProvider], 7126 [DialogScopedContextProvider] 7127 ); 7128 var usePopoverContext = ctx6.useContext; 7129 var usePopoverScopedContext = ctx6.useScopedContext; 7130 var usePopoverProviderContext = ctx6.useProviderContext; 7131 var PopoverContextProvider = ctx6.ContextProvider; 7132 var PopoverScopedContextProvider = ctx6.ScopedContextProvider; 7133 7134 // node_modules/@ariakit/react-core/esm/__chunks/VEVQD5MH.js 7135 var import_react7 = __toESM(require_react(), 1); 7136 var ComboboxListRoleContext = (0, import_react7.createContext)( 7137 void 0 7138 ); 7139 var ctx7 = createStoreContext( 7140 [PopoverContextProvider, CompositeContextProvider], 7141 [PopoverScopedContextProvider, CompositeScopedContextProvider] 7142 ); 7143 var useComboboxContext = ctx7.useContext; 7144 var useComboboxScopedContext = ctx7.useScopedContext; 7145 var useComboboxProviderContext = ctx7.useProviderContext; 7146 var ComboboxContextProvider = ctx7.ContextProvider; 7147 var ComboboxScopedContextProvider = ctx7.ScopedContextProvider; 7148 var ComboboxItemValueContext = (0, import_react7.createContext)( 7149 void 0 7150 ); 7151 var ComboboxItemCheckedContext = (0, import_react7.createContext)(false); 7152 7153 // node_modules/@ariakit/react-core/esm/__chunks/OMU7RWRV.js 7154 var TagName = "div"; 7155 var usePopoverAnchor = createHook( 7156 function usePopoverAnchor2(_a) { 7157 var _b = _a, { store } = _b, props = __objRest(_b, ["store"]); 7158 const context = usePopoverProviderContext(); 7159 store = store || context; 7160 props = __spreadProps(__spreadValues({}, props), { 7161 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref) 7162 }); 7163 return props; 7164 } 7165 ); 7166 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) { 7167 const htmlProps = usePopoverAnchor(props); 7168 return createElement2(TagName, htmlProps); 7169 }); 7170 7171 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js 7172 function findFirstEnabledItem2(items, excludeId) { 7173 return items.find((item) => { 7174 if (excludeId) { 7175 return !item.disabled && item.id !== excludeId; 7176 } 7177 return !item.disabled; 7178 }); 7179 } 7180 function getEnabledItem(store, id) { 7181 if (!id) return null; 7182 return store.item(id) || null; 7183 } 7184 function groupItemsByRows2(items) { 7185 const rows = []; 7186 for (const item of items) { 7187 const row = rows.find((currentRow) => { 7188 var _a; 7189 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 7190 }); 7191 if (row) { 7192 row.push(item); 7193 } else { 7194 rows.push([item]); 7195 } 7196 } 7197 return rows; 7198 } 7199 function selectTextField(element, collapseToEnd = false) { 7200 if (isTextField(element)) { 7201 element.setSelectionRange( 7202 collapseToEnd ? element.value.length : 0, 7203 element.value.length 7204 ); 7205 } else if (element.isContentEditable) { 7206 const selection = getDocument(element).getSelection(); 7207 selection == null ? void 0 : selection.selectAllChildren(element); 7208 if (collapseToEnd) { 7209 selection == null ? void 0 : selection.collapseToEnd(); 7210 } 7211 } 7212 } 7213 var FOCUS_SILENTLY = Symbol("FOCUS_SILENTLY"); 7214 function focusSilently(element) { 7215 element[FOCUS_SILENTLY] = true; 7216 element.focus({ preventScroll: true }); 7217 } 7218 function silentlyFocused(element) { 7219 const isSilentlyFocused = element[FOCUS_SILENTLY]; 7220 delete element[FOCUS_SILENTLY]; 7221 return isSilentlyFocused; 7222 } 7223 function isItem(store, element, exclude) { 7224 if (!element) return false; 7225 if (element === exclude) return false; 7226 const item = store.item(element.id); 7227 if (!item) return false; 7228 if (exclude && item.element === exclude) return false; 7229 return true; 7230 } 7231 7232 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js 7233 var import_react8 = __toESM(require_react(), 1); 7234 var FocusableContext = (0, import_react8.createContext)(true); 7235 7236 // node_modules/@ariakit/core/esm/utils/focus.js 7237 var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])"; 7238 function isFocusable(element) { 7239 if (!element.matches(selector)) return false; 7240 if (!isVisible(element)) return false; 7241 if (element.closest("[inert]")) return false; 7242 return true; 7243 } 7244 function getClosestFocusable(element) { 7245 while (element && !isFocusable(element)) { 7246 element = element.closest(selector); 7247 } 7248 return element || null; 7249 } 7250 function hasFocus(element) { 7251 const activeElement = getActiveElement(element); 7252 if (!activeElement) return false; 7253 if (activeElement === element) return true; 7254 const activeDescendant = activeElement.getAttribute("aria-activedescendant"); 7255 if (!activeDescendant) return false; 7256 return activeDescendant === element.id; 7257 } 7258 function hasFocusWithin(element) { 7259 const activeElement = getActiveElement(element); 7260 if (!activeElement) return false; 7261 if (contains(element, activeElement)) return true; 7262 const activeDescendant = activeElement.getAttribute("aria-activedescendant"); 7263 if (!activeDescendant) return false; 7264 if (!("id" in element)) return false; 7265 if (activeDescendant === element.id) return true; 7266 return !!element.querySelector(`#$CSS.escape(activeDescendant)}`); 7267 } 7268 function focusIfNeeded(element) { 7269 if (!hasFocusWithin(element) && isFocusable(element)) { 7270 element.focus(); 7271 } 7272 } 7273 function focusIntoView(element, options) { 7274 if (!("scrollIntoView" in element)) { 7275 element.focus(); 7276 } else { 7277 element.focus({ preventScroll: true }); 7278 element.scrollIntoView(__spreadValues2({ block: "nearest", inline: "nearest" }, options)); 7279 } 7280 } 7281 7282 // node_modules/@ariakit/react-core/esm/__chunks/LVA2YJMS.js 7283 var import_react9 = __toESM(require_react(), 1); 7284 var TagName2 = "div"; 7285 var isSafariBrowser = isSafari(); 7286 var alwaysFocusVisibleInputTypes = [ 7287 "text", 7288 "search", 7289 "url", 7290 "tel", 7291 "email", 7292 "password", 7293 "number", 7294 "date", 7295 "month", 7296 "week", 7297 "time", 7298 "datetime", 7299 "datetime-local" 7300 ]; 7301 var safariFocusAncestorSymbol = Symbol("safariFocusAncestor"); 7302 function markSafariFocusAncestor(element, value) { 7303 if (!element) return; 7304 element[safariFocusAncestorSymbol] = value; 7305 } 7306 function isAlwaysFocusVisible(element) { 7307 const { tagName, readOnly, type } = element; 7308 if (tagName === "TEXTAREA" && !readOnly) return true; 7309 if (tagName === "SELECT" && !readOnly) return true; 7310 if (tagName === "INPUT" && !readOnly) { 7311 return alwaysFocusVisibleInputTypes.includes(type); 7312 } 7313 if (element.isContentEditable) return true; 7314 const role = element.getAttribute("role"); 7315 if (role === "combobox" && element.dataset.name) { 7316 return true; 7317 } 7318 return false; 7319 } 7320 function getLabels(element) { 7321 if ("labels" in element) { 7322 return element.labels; 7323 } 7324 return null; 7325 } 7326 function isNativeCheckboxOrRadio(element) { 7327 const tagName = element.tagName.toLowerCase(); 7328 if (tagName === "input" && element.type) { 7329 return element.type === "radio" || element.type === "checkbox"; 7330 } 7331 return false; 7332 } 7333 function isNativeTabbable(tagName) { 7334 if (!tagName) return true; 7335 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a"; 7336 } 7337 function supportsDisabledAttribute(tagName) { 7338 if (!tagName) return true; 7339 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea"; 7340 } 7341 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) { 7342 if (!focusable) { 7343 return tabIndexProp; 7344 } 7345 if (trulyDisabled) { 7346 if (nativeTabbable && !supportsDisabled) { 7347 return -1; 7348 } 7349 return; 7350 } 7351 if (nativeTabbable) { 7352 return tabIndexProp; 7353 } 7354 return tabIndexProp || 0; 7355 } 7356 function useDisableEvent(onEvent, disabled) { 7357 return useEvent((event) => { 7358 onEvent == null ? void 0 : onEvent(event); 7359 if (event.defaultPrevented) return; 7360 if (disabled) { 7361 event.stopPropagation(); 7362 event.preventDefault(); 7363 } 7364 }); 7365 } 7366 var isKeyboardModality = true; 7367 function onGlobalMouseDown(event) { 7368 const target = event.target; 7369 if (target && "hasAttribute" in target) { 7370 if (!target.hasAttribute("data-focus-visible")) { 7371 isKeyboardModality = false; 7372 } 7373 } 7374 } 7375 function onGlobalKeyDown(event) { 7376 if (event.metaKey) return; 7377 if (event.ctrlKey) return; 7378 if (event.altKey) return; 7379 isKeyboardModality = true; 7380 } 7381 var useFocusable = createHook( 7382 function useFocusable2(_a) { 7383 var _b = _a, { 7384 focusable = true, 7385 accessibleWhenDisabled, 7386 autoFocus, 7387 onFocusVisible 7388 } = _b, props = __objRest(_b, [ 7389 "focusable", 7390 "accessibleWhenDisabled", 7391 "autoFocus", 7392 "onFocusVisible" 7393 ]); 7394 const ref = (0, import_react9.useRef)(null); 7395 (0, import_react9.useEffect)(() => { 7396 if (!focusable) return; 7397 addGlobalEventListener("mousedown", onGlobalMouseDown, true); 7398 addGlobalEventListener("keydown", onGlobalKeyDown, true); 7399 }, [focusable]); 7400 if (isSafariBrowser) { 7401 (0, import_react9.useEffect)(() => { 7402 if (!focusable) return; 7403 const element = ref.current; 7404 if (!element) return; 7405 if (!isNativeCheckboxOrRadio(element)) return; 7406 const labels = getLabels(element); 7407 if (!labels) return; 7408 const onMouseUp = () => queueMicrotask(() => element.focus()); 7409 for (const label of labels) { 7410 label.addEventListener("mouseup", onMouseUp); 7411 } 7412 return () => { 7413 for (const label of labels) { 7414 label.removeEventListener("mouseup", onMouseUp); 7415 } 7416 }; 7417 }, [focusable]); 7418 } 7419 const disabled = focusable && disabledFromProps(props); 7420 const trulyDisabled = !!disabled && !accessibleWhenDisabled; 7421 const [focusVisible, setFocusVisible] = (0, import_react9.useState)(false); 7422 (0, import_react9.useEffect)(() => { 7423 if (!focusable) return; 7424 if (trulyDisabled && focusVisible) { 7425 setFocusVisible(false); 7426 } 7427 }, [focusable, trulyDisabled, focusVisible]); 7428 (0, import_react9.useEffect)(() => { 7429 if (!focusable) return; 7430 if (!focusVisible) return; 7431 const element = ref.current; 7432 if (!element) return; 7433 if (typeof IntersectionObserver === "undefined") return; 7434 const observer = new IntersectionObserver(() => { 7435 if (!isFocusable(element)) { 7436 setFocusVisible(false); 7437 } 7438 }); 7439 observer.observe(element); 7440 return () => observer.disconnect(); 7441 }, [focusable, focusVisible]); 7442 const onKeyPressCapture = useDisableEvent( 7443 props.onKeyPressCapture, 7444 disabled 7445 ); 7446 const onMouseDownCapture = useDisableEvent( 7447 props.onMouseDownCapture, 7448 disabled 7449 ); 7450 const onClickCapture = useDisableEvent(props.onClickCapture, disabled); 7451 const onMouseDownProp = props.onMouseDown; 7452 const onMouseDown = useEvent((event) => { 7453 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 7454 if (event.defaultPrevented) return; 7455 if (!focusable) return; 7456 const element = event.currentTarget; 7457 if (!isSafariBrowser) return; 7458 if (isPortalEvent(event)) return; 7459 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return; 7460 let receivedFocus = false; 7461 const onFocus = () => { 7462 receivedFocus = true; 7463 }; 7464 const options = { capture: true, once: true }; 7465 element.addEventListener("focusin", onFocus, options); 7466 const focusableContainer = getClosestFocusable(element.parentElement); 7467 markSafariFocusAncestor(focusableContainer, true); 7468 queueBeforeEvent(element, "mouseup", () => { 7469 element.removeEventListener("focusin", onFocus, true); 7470 markSafariFocusAncestor(focusableContainer, false); 7471 if (receivedFocus) return; 7472 focusIfNeeded(element); 7473 }); 7474 }); 7475 const handleFocusVisible = (event, currentTarget) => { 7476 if (currentTarget) { 7477 event.currentTarget = currentTarget; 7478 } 7479 if (!focusable) return; 7480 const element = event.currentTarget; 7481 if (!element) return; 7482 if (!hasFocus(element)) return; 7483 onFocusVisible == null ? void 0 : onFocusVisible(event); 7484 if (event.defaultPrevented) return; 7485 element.dataset.focusVisible = "true"; 7486 setFocusVisible(true); 7487 }; 7488 const onKeyDownCaptureProp = props.onKeyDownCapture; 7489 const onKeyDownCapture = useEvent((event) => { 7490 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event); 7491 if (event.defaultPrevented) return; 7492 if (!focusable) return; 7493 if (focusVisible) return; 7494 if (event.metaKey) return; 7495 if (event.altKey) return; 7496 if (event.ctrlKey) return; 7497 if (!isSelfTarget(event)) return; 7498 const element = event.currentTarget; 7499 const applyFocusVisible = () => handleFocusVisible(event, element); 7500 queueBeforeEvent(element, "focusout", applyFocusVisible); 7501 }); 7502 const onFocusCaptureProp = props.onFocusCapture; 7503 const onFocusCapture = useEvent((event) => { 7504 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 7505 if (event.defaultPrevented) return; 7506 if (!focusable) return; 7507 if (!isSelfTarget(event)) { 7508 setFocusVisible(false); 7509 return; 7510 } 7511 const element = event.currentTarget; 7512 const applyFocusVisible = () => handleFocusVisible(event, element); 7513 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) { 7514 queueBeforeEvent(event.target, "focusout", applyFocusVisible); 7515 } else { 7516 setFocusVisible(false); 7517 } 7518 }); 7519 const onBlurProp = props.onBlur; 7520 const onBlur = useEvent((event) => { 7521 onBlurProp == null ? void 0 : onBlurProp(event); 7522 if (!focusable) return; 7523 if (!isFocusEventOutside(event)) return; 7524 setFocusVisible(false); 7525 }); 7526 const autoFocusOnShow = (0, import_react9.useContext)(FocusableContext); 7527 const autoFocusRef = useEvent((element) => { 7528 if (!focusable) return; 7529 if (!autoFocus) return; 7530 if (!element) return; 7531 if (!autoFocusOnShow) return; 7532 queueMicrotask(() => { 7533 if (hasFocus(element)) return; 7534 if (!isFocusable(element)) return; 7535 element.focus(); 7536 }); 7537 }); 7538 const tagName = useTagName(ref); 7539 const nativeTabbable = focusable && isNativeTabbable(tagName); 7540 const supportsDisabled = focusable && supportsDisabledAttribute(tagName); 7541 const styleProp = props.style; 7542 const style = (0, import_react9.useMemo)(() => { 7543 if (trulyDisabled) { 7544 return __spreadValues({ pointerEvents: "none" }, styleProp); 7545 } 7546 return styleProp; 7547 }, [trulyDisabled, styleProp]); 7548 props = __spreadProps(__spreadValues({ 7549 "data-focus-visible": focusable && focusVisible || void 0, 7550 "data-autofocus": autoFocus || void 0, 7551 "aria-disabled": disabled || void 0 7552 }, props), { 7553 ref: useMergeRefs(ref, autoFocusRef, props.ref), 7554 style, 7555 tabIndex: getTabIndex( 7556 focusable, 7557 trulyDisabled, 7558 nativeTabbable, 7559 supportsDisabled, 7560 props.tabIndex 7561 ), 7562 disabled: supportsDisabled && trulyDisabled ? true : void 0, 7563 // TODO: Test Focusable contentEditable. 7564 contentEditable: disabled ? void 0 : props.contentEditable, 7565 onKeyPressCapture, 7566 onClickCapture, 7567 onMouseDownCapture, 7568 onMouseDown, 7569 onKeyDownCapture, 7570 onFocusCapture, 7571 onBlur 7572 }); 7573 return removeUndefinedValues(props); 7574 } 7575 ); 7576 var Focusable = forwardRef22(function Focusable2(props) { 7577 const htmlProps = useFocusable(props); 7578 return createElement2(TagName2, htmlProps); 7579 }); 7580 7581 // node_modules/@ariakit/react-core/esm/__chunks/ITI7HKP4.js 7582 var import_react10 = __toESM(require_react(), 1); 7583 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1); 7584 var TagName3 = "div"; 7585 function isGrid(items) { 7586 return items.some((item) => !!item.rowId); 7587 } 7588 function isPrintableKey(event) { 7589 const target = event.target; 7590 if (target && !isTextField(target)) return false; 7591 return event.key.length === 1 && !event.ctrlKey && !event.metaKey; 7592 } 7593 function isModifierKey(event) { 7594 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta"; 7595 } 7596 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) { 7597 return useEvent((event) => { 7598 var _a; 7599 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event); 7600 if (event.defaultPrevented) return; 7601 if (event.isPropagationStopped()) return; 7602 if (!isSelfTarget(event)) return; 7603 if (isModifierKey(event)) return; 7604 if (isPrintableKey(event)) return; 7605 const state = store.getState(); 7606 const activeElement = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element; 7607 if (!activeElement) return; 7608 const _b = event, { view } = _b, eventInit = __objRest(_b, ["view"]); 7609 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current; 7610 if (activeElement !== previousElement) { 7611 activeElement.focus(); 7612 } 7613 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) { 7614 event.preventDefault(); 7615 } 7616 if (event.currentTarget.contains(activeElement)) { 7617 event.stopPropagation(); 7618 } 7619 }); 7620 } 7621 function findFirstEnabledItemInTheLastRow(items) { 7622 return findFirstEnabledItem2( 7623 flatten2DArray(reverseArray(groupItemsByRows2(items))) 7624 ); 7625 } 7626 function useScheduleFocus(store) { 7627 const [scheduled, setScheduled] = (0, import_react10.useState)(false); 7628 const schedule = (0, import_react10.useCallback)(() => setScheduled(true), []); 7629 const activeItem = store.useState( 7630 (state) => getEnabledItem(store, state.activeId) 7631 ); 7632 (0, import_react10.useEffect)(() => { 7633 const activeElement = activeItem == null ? void 0 : activeItem.element; 7634 if (!scheduled) return; 7635 if (!activeElement) return; 7636 setScheduled(false); 7637 activeElement.focus({ preventScroll: true }); 7638 }, [activeItem, scheduled]); 7639 return schedule; 7640 } 7641 var useComposite = createHook( 7642 function useComposite2(_a) { 7643 var _b = _a, { 7644 store, 7645 composite = true, 7646 focusOnMove = composite, 7647 moveOnKeyPress = true 7648 } = _b, props = __objRest(_b, [ 7649 "store", 7650 "composite", 7651 "focusOnMove", 7652 "moveOnKeyPress" 7653 ]); 7654 const context = useCompositeProviderContext(); 7655 store = store || context; 7656 invariant( 7657 store, 7658 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component." 7659 ); 7660 const ref = (0, import_react10.useRef)(null); 7661 const previousElementRef = (0, import_react10.useRef)(null); 7662 const scheduleFocus = useScheduleFocus(store); 7663 const moves = store.useState("moves"); 7664 const [, setBaseElement] = useTransactionState( 7665 composite ? store.setBaseElement : null 7666 ); 7667 (0, import_react10.useEffect)(() => { 7668 var _a2; 7669 if (!store) return; 7670 if (!moves) return; 7671 if (!composite) return; 7672 if (!focusOnMove) return; 7673 const { activeId: activeId2 } = store.getState(); 7674 const itemElement = (_a2 = getEnabledItem(store, activeId2)) == null ? void 0 : _a2.element; 7675 if (!itemElement) return; 7676 focusIntoView(itemElement); 7677 }, [store, moves, composite, focusOnMove]); 7678 useSafeLayoutEffect(() => { 7679 if (!store) return; 7680 if (!moves) return; 7681 if (!composite) return; 7682 const { baseElement, activeId: activeId2 } = store.getState(); 7683 const isSelfAcive = activeId2 === null; 7684 if (!isSelfAcive) return; 7685 if (!baseElement) return; 7686 const previousElement = previousElementRef.current; 7687 previousElementRef.current = null; 7688 if (previousElement) { 7689 fireBlurEvent(previousElement, { relatedTarget: baseElement }); 7690 } 7691 if (!hasFocus(baseElement)) { 7692 baseElement.focus(); 7693 } 7694 }, [store, moves, composite]); 7695 const activeId = store.useState("activeId"); 7696 const virtualFocus = store.useState("virtualFocus"); 7697 useSafeLayoutEffect(() => { 7698 var _a2; 7699 if (!store) return; 7700 if (!composite) return; 7701 if (!virtualFocus) return; 7702 const previousElement = previousElementRef.current; 7703 previousElementRef.current = null; 7704 if (!previousElement) return; 7705 const activeElement = (_a2 = getEnabledItem(store, activeId)) == null ? void 0 : _a2.element; 7706 const relatedTarget = activeElement || getActiveElement(previousElement); 7707 if (relatedTarget === previousElement) return; 7708 fireBlurEvent(previousElement, { relatedTarget }); 7709 }, [store, activeId, virtualFocus, composite]); 7710 const onKeyDownCapture = useKeyboardEventProxy( 7711 store, 7712 props.onKeyDownCapture, 7713 previousElementRef 7714 ); 7715 const onKeyUpCapture = useKeyboardEventProxy( 7716 store, 7717 props.onKeyUpCapture, 7718 previousElementRef 7719 ); 7720 const onFocusCaptureProp = props.onFocusCapture; 7721 const onFocusCapture = useEvent((event) => { 7722 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 7723 if (event.defaultPrevented) return; 7724 if (!store) return; 7725 const { virtualFocus: virtualFocus2 } = store.getState(); 7726 if (!virtualFocus2) return; 7727 const previousActiveElement = event.relatedTarget; 7728 const isSilentlyFocused = silentlyFocused(event.currentTarget); 7729 if (isSelfTarget(event) && isSilentlyFocused) { 7730 event.stopPropagation(); 7731 previousElementRef.current = previousActiveElement; 7732 } 7733 }); 7734 const onFocusProp = props.onFocus; 7735 const onFocus = useEvent((event) => { 7736 onFocusProp == null ? void 0 : onFocusProp(event); 7737 if (event.defaultPrevented) return; 7738 if (!composite) return; 7739 if (!store) return; 7740 const { relatedTarget } = event; 7741 const { virtualFocus: virtualFocus2 } = store.getState(); 7742 if (virtualFocus2) { 7743 if (isSelfTarget(event) && !isItem(store, relatedTarget)) { 7744 queueMicrotask(scheduleFocus); 7745 } 7746 } else if (isSelfTarget(event)) { 7747 store.setActiveId(null); 7748 } 7749 }); 7750 const onBlurCaptureProp = props.onBlurCapture; 7751 const onBlurCapture = useEvent((event) => { 7752 var _a2; 7753 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 7754 if (event.defaultPrevented) return; 7755 if (!store) return; 7756 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState(); 7757 if (!virtualFocus2) return; 7758 const activeElement = (_a2 = getEnabledItem(store, activeId2)) == null ? void 0 : _a2.element; 7759 const nextActiveElement = event.relatedTarget; 7760 const nextActiveElementIsItem = isItem(store, nextActiveElement); 7761 const previousElement = previousElementRef.current; 7762 previousElementRef.current = null; 7763 if (isSelfTarget(event) && nextActiveElementIsItem) { 7764 if (nextActiveElement === activeElement) { 7765 if (previousElement && previousElement !== nextActiveElement) { 7766 fireBlurEvent(previousElement, event); 7767 } 7768 } else if (activeElement) { 7769 fireBlurEvent(activeElement, event); 7770 } else if (previousElement) { 7771 fireBlurEvent(previousElement, event); 7772 } 7773 event.stopPropagation(); 7774 } else { 7775 const targetIsItem = isItem(store, event.target); 7776 if (!targetIsItem && activeElement) { 7777 fireBlurEvent(activeElement, event); 7778 } 7779 } 7780 }); 7781 const onKeyDownProp = props.onKeyDown; 7782 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 7783 const onKeyDown = useEvent((event) => { 7784 var _a2; 7785 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 7786 if (event.defaultPrevented) return; 7787 if (!store) return; 7788 if (!isSelfTarget(event)) return; 7789 const { orientation, renderedItems, activeId: activeId2 } = store.getState(); 7790 const activeItem = getEnabledItem(store, activeId2); 7791 if ((_a2 = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a2.isConnected) return; 7792 const isVertical = orientation !== "horizontal"; 7793 const isHorizontal = orientation !== "vertical"; 7794 const grid = isGrid(renderedItems); 7795 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End"; 7796 if (isHorizontalKey && isTextField(event.currentTarget)) return; 7797 const up = () => { 7798 if (grid) { 7799 const item = findFirstEnabledItemInTheLastRow(renderedItems); 7800 return item == null ? void 0 : item.id; 7801 } 7802 return store == null ? void 0 : store.last(); 7803 }; 7804 const keyMap = { 7805 ArrowUp: (grid || isVertical) && up, 7806 ArrowRight: (grid || isHorizontal) && store.first, 7807 ArrowDown: (grid || isVertical) && store.first, 7808 ArrowLeft: (grid || isHorizontal) && store.last, 7809 Home: store.first, 7810 End: store.last, 7811 PageUp: store.first, 7812 PageDown: store.last 7813 }; 7814 const action = keyMap[event.key]; 7815 if (action) { 7816 const id = action(); 7817 if (id !== void 0) { 7818 if (!moveOnKeyPressProp(event)) return; 7819 event.preventDefault(); 7820 store.move(id); 7821 } 7822 } 7823 }); 7824 props = useWrapElement( 7825 props, 7826 (element) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(CompositeContextProvider, { value: store, children: element }), 7827 [store] 7828 ); 7829 const activeDescendant = store.useState((state) => { 7830 var _a2; 7831 if (!store) return; 7832 if (!composite) return; 7833 if (!state.virtualFocus) return; 7834 return (_a2 = getEnabledItem(store, state.activeId)) == null ? void 0 : _a2.id; 7835 }); 7836 props = __spreadProps(__spreadValues({ 7837 "aria-activedescendant": activeDescendant 7838 }, props), { 7839 ref: useMergeRefs(ref, setBaseElement, props.ref), 7840 onKeyDownCapture, 7841 onKeyUpCapture, 7842 onFocusCapture, 7843 onFocus, 7844 onBlurCapture, 7845 onKeyDown 7846 }); 7847 const focusable = store.useState( 7848 (state) => composite && (state.virtualFocus || state.activeId === null) 7849 ); 7850 props = useFocusable(__spreadValues({ focusable }, props)); 7851 return props; 7852 } 7853 ); 7854 var Composite5 = forwardRef22(function Composite22(props) { 7855 const htmlProps = useComposite(props); 7856 return createElement2(TagName3, htmlProps); 7857 }); 7858 7859 // node_modules/@ariakit/react-core/esm/combobox/combobox.js 7860 var import_react11 = __toESM(require_react(), 1); 7861 var TagName4 = "input"; 7862 function isFirstItemAutoSelected(items, activeValue, autoSelect) { 7863 if (!autoSelect) return false; 7864 const firstItem = items.find((item) => !item.disabled && item.value); 7865 return (firstItem == null ? void 0 : firstItem.value) === activeValue; 7866 } 7867 function hasCompletionString(value, activeValue) { 7868 if (!activeValue) return false; 7869 if (value == null) return false; 7870 value = normalizeString(value); 7871 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0; 7872 } 7873 function isInputEvent(event) { 7874 return event.type === "input"; 7875 } 7876 function isAriaAutoCompleteValue(value) { 7877 return value === "inline" || value === "list" || value === "both" || value === "none"; 7878 } 7879 function getDefaultAutoSelectId(items) { 7880 const item = items.find((item2) => { 7881 var _a; 7882 if (item2.disabled) return false; 7883 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab"; 7884 }); 7885 return item == null ? void 0 : item.id; 7886 } 7887 var useCombobox = createHook( 7888 function useCombobox2(_a) { 7889 var _b = _a, { 7890 store, 7891 focusable = true, 7892 autoSelect: autoSelectProp = false, 7893 getAutoSelectId, 7894 setValueOnChange, 7895 showMinLength = 0, 7896 showOnChange, 7897 showOnMouseDown, 7898 showOnClick = showOnMouseDown, 7899 showOnKeyDown, 7900 showOnKeyPress = showOnKeyDown, 7901 blurActiveItemOnClick, 7902 setValueOnClick = true, 7903 moveOnKeyPress = true, 7904 autoComplete = "list" 7905 } = _b, props = __objRest(_b, [ 7906 "store", 7907 "focusable", 7908 "autoSelect", 7909 "getAutoSelectId", 7910 "setValueOnChange", 7911 "showMinLength", 7912 "showOnChange", 7913 "showOnMouseDown", 7914 "showOnClick", 7915 "showOnKeyDown", 7916 "showOnKeyPress", 7917 "blurActiveItemOnClick", 7918 "setValueOnClick", 7919 "moveOnKeyPress", 7920 "autoComplete" 7921 ]); 7922 const context = useComboboxProviderContext(); 7923 store = store || context; 7924 invariant( 7925 store, 7926 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component." 7927 ); 7928 const ref = (0, import_react11.useRef)(null); 7929 const [valueUpdated, forceValueUpdate] = useForceUpdate(); 7930 const canAutoSelectRef = (0, import_react11.useRef)(false); 7931 const composingRef = (0, import_react11.useRef)(false); 7932 const autoSelect = store.useState( 7933 (state) => state.virtualFocus && autoSelectProp 7934 ); 7935 const inline = autoComplete === "inline" || autoComplete === "both"; 7936 const [canInline, setCanInline] = (0, import_react11.useState)(inline); 7937 useUpdateLayoutEffect(() => { 7938 if (!inline) return; 7939 setCanInline(true); 7940 }, [inline]); 7941 const storeValue = store.useState("value"); 7942 const prevSelectedValueRef = (0, import_react11.useRef)(); 7943 (0, import_react11.useEffect)(() => { 7944 return sync(store, ["selectedValue", "activeId"], (_, prev) => { 7945 prevSelectedValueRef.current = prev.selectedValue; 7946 }); 7947 }, []); 7948 const inlineActiveValue = store.useState((state) => { 7949 var _a2; 7950 if (!inline) return; 7951 if (!canInline) return; 7952 if (state.activeValue && Array.isArray(state.selectedValue)) { 7953 if (state.selectedValue.includes(state.activeValue)) return; 7954 if ((_a2 = prevSelectedValueRef.current) == null ? void 0 : _a2.includes(state.activeValue)) return; 7955 } 7956 return state.activeValue; 7957 }); 7958 const items = store.useState("renderedItems"); 7959 const open = store.useState("open"); 7960 const contentElement = store.useState("contentElement"); 7961 const value = (0, import_react11.useMemo)(() => { 7962 if (!inline) return storeValue; 7963 if (!canInline) return storeValue; 7964 const firstItemAutoSelected = isFirstItemAutoSelected( 7965 items, 7966 inlineActiveValue, 7967 autoSelect 7968 ); 7969 if (firstItemAutoSelected) { 7970 if (hasCompletionString(storeValue, inlineActiveValue)) { 7971 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || ""; 7972 return storeValue + slice; 7973 } 7974 return storeValue; 7975 } 7976 return inlineActiveValue || storeValue; 7977 }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]); 7978 (0, import_react11.useEffect)(() => { 7979 const element = ref.current; 7980 if (!element) return; 7981 const onCompositeItemMove = () => setCanInline(true); 7982 element.addEventListener("combobox-item-move", onCompositeItemMove); 7983 return () => { 7984 element.removeEventListener("combobox-item-move", onCompositeItemMove); 7985 }; 7986 }, []); 7987 (0, import_react11.useEffect)(() => { 7988 if (!inline) return; 7989 if (!canInline) return; 7990 if (!inlineActiveValue) return; 7991 const firstItemAutoSelected = isFirstItemAutoSelected( 7992 items, 7993 inlineActiveValue, 7994 autoSelect 7995 ); 7996 if (!firstItemAutoSelected) return; 7997 if (!hasCompletionString(storeValue, inlineActiveValue)) return; 7998 let cleanup = noop; 7999 queueMicrotask(() => { 8000 const element = ref.current; 8001 if (!element) return; 8002 const { start: prevStart, end: prevEnd } = getTextboxSelection(element); 8003 const nextStart = storeValue.length; 8004 const nextEnd = inlineActiveValue.length; 8005 setSelectionRange(element, nextStart, nextEnd); 8006 cleanup = () => { 8007 if (!hasFocus(element)) return; 8008 const { start, end } = getTextboxSelection(element); 8009 if (start !== nextStart) return; 8010 if (end !== nextEnd) return; 8011 setSelectionRange(element, prevStart, prevEnd); 8012 }; 8013 }); 8014 return () => cleanup(); 8015 }, [ 8016 valueUpdated, 8017 inline, 8018 canInline, 8019 inlineActiveValue, 8020 items, 8021 autoSelect, 8022 storeValue 8023 ]); 8024 const scrollingElementRef = (0, import_react11.useRef)(null); 8025 const getAutoSelectIdProp = useEvent(getAutoSelectId); 8026 const autoSelectIdRef = (0, import_react11.useRef)(null); 8027 (0, import_react11.useEffect)(() => { 8028 if (!open) return; 8029 if (!contentElement) return; 8030 const scrollingElement = getScrollingElement(contentElement); 8031 if (!scrollingElement) return; 8032 scrollingElementRef.current = scrollingElement; 8033 const onUserScroll = () => { 8034 canAutoSelectRef.current = false; 8035 }; 8036 const onScroll = () => { 8037 if (!store) return; 8038 if (!canAutoSelectRef.current) return; 8039 const { activeId } = store.getState(); 8040 if (activeId === null) return; 8041 if (activeId === autoSelectIdRef.current) return; 8042 canAutoSelectRef.current = false; 8043 }; 8044 const options = { passive: true, capture: true }; 8045 scrollingElement.addEventListener("wheel", onUserScroll, options); 8046 scrollingElement.addEventListener("touchmove", onUserScroll, options); 8047 scrollingElement.addEventListener("scroll", onScroll, options); 8048 return () => { 8049 scrollingElement.removeEventListener("wheel", onUserScroll, true); 8050 scrollingElement.removeEventListener("touchmove", onUserScroll, true); 8051 scrollingElement.removeEventListener("scroll", onScroll, true); 8052 }; 8053 }, [open, contentElement, store]); 8054 useSafeLayoutEffect(() => { 8055 if (!storeValue) return; 8056 if (composingRef.current) return; 8057 canAutoSelectRef.current = true; 8058 }, [storeValue]); 8059 useSafeLayoutEffect(() => { 8060 if (autoSelect !== "always" && open) return; 8061 canAutoSelectRef.current = open; 8062 }, [autoSelect, open]); 8063 const resetValueOnSelect = store.useState("resetValueOnSelect"); 8064 useUpdateEffect(() => { 8065 var _a2, _b2; 8066 const canAutoSelect = canAutoSelectRef.current; 8067 if (!store) return; 8068 if (!open) return; 8069 if (!canAutoSelect && !resetValueOnSelect) return; 8070 const { baseElement, contentElement: contentElement2, activeId } = store.getState(); 8071 if (baseElement && !hasFocus(baseElement)) return; 8072 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) { 8073 const observer = new MutationObserver(forceValueUpdate); 8074 observer.observe(contentElement2, { attributeFilter: ["data-placing"] }); 8075 return () => observer.disconnect(); 8076 } 8077 if (autoSelect && canAutoSelect) { 8078 const userAutoSelectId = getAutoSelectIdProp(items); 8079 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a2 = getDefaultAutoSelectId(items)) != null ? _a2 : store.first(); 8080 autoSelectIdRef.current = autoSelectId; 8081 store.move(autoSelectId != null ? autoSelectId : null); 8082 } else { 8083 const element = (_b2 = store.item(activeId || store.first())) == null ? void 0 : _b2.element; 8084 if (element && "scrollIntoView" in element) { 8085 element.scrollIntoView({ block: "nearest", inline: "nearest" }); 8086 } 8087 } 8088 return; 8089 }, [ 8090 store, 8091 open, 8092 valueUpdated, 8093 storeValue, 8094 autoSelect, 8095 resetValueOnSelect, 8096 getAutoSelectIdProp, 8097 items 8098 ]); 8099 (0, import_react11.useEffect)(() => { 8100 if (!inline) return; 8101 const combobox = ref.current; 8102 if (!combobox) return; 8103 const elements = [combobox, contentElement].filter( 8104 (value2) => !!value2 8105 ); 8106 const onBlur2 = (event) => { 8107 if (elements.every((el) => isFocusEventOutside(event, el))) { 8108 store == null ? void 0 : store.setValue(value); 8109 } 8110 }; 8111 for (const element of elements) { 8112 element.addEventListener("focusout", onBlur2); 8113 } 8114 return () => { 8115 for (const element of elements) { 8116 element.removeEventListener("focusout", onBlur2); 8117 } 8118 }; 8119 }, [inline, contentElement, store, value]); 8120 const canShow = (event) => { 8121 const currentTarget = event.currentTarget; 8122 return currentTarget.value.length >= showMinLength; 8123 }; 8124 const onChangeProp = props.onChange; 8125 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow); 8126 const setValueOnChangeProp = useBooleanEvent( 8127 // If the combobox is combined with tags, the value will be set by the tag 8128 // input component. 8129 setValueOnChange != null ? setValueOnChange : !store.tag 8130 ); 8131 const onChange = useEvent((event) => { 8132 onChangeProp == null ? void 0 : onChangeProp(event); 8133 if (event.defaultPrevented) return; 8134 if (!store) return; 8135 const currentTarget = event.currentTarget; 8136 const { value: value2, selectionStart, selectionEnd } = currentTarget; 8137 const nativeEvent = event.nativeEvent; 8138 canAutoSelectRef.current = true; 8139 if (isInputEvent(nativeEvent)) { 8140 if (nativeEvent.isComposing) { 8141 canAutoSelectRef.current = false; 8142 composingRef.current = true; 8143 } 8144 if (inline) { 8145 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText"; 8146 const caretAtEnd = selectionStart === value2.length; 8147 setCanInline(textInserted && caretAtEnd); 8148 } 8149 } 8150 if (setValueOnChangeProp(event)) { 8151 const isSameValue = value2 === store.getState().value; 8152 store.setValue(value2); 8153 queueMicrotask(() => { 8154 setSelectionRange(currentTarget, selectionStart, selectionEnd); 8155 }); 8156 if (inline && autoSelect && isSameValue) { 8157 forceValueUpdate(); 8158 } 8159 } 8160 if (showOnChangeProp(event)) { 8161 store.show(); 8162 } 8163 if (!autoSelect || !canAutoSelectRef.current) { 8164 store.setActiveId(null); 8165 } 8166 }); 8167 const onCompositionEndProp = props.onCompositionEnd; 8168 const onCompositionEnd = useEvent((event) => { 8169 canAutoSelectRef.current = true; 8170 composingRef.current = false; 8171 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event); 8172 if (event.defaultPrevented) return; 8173 if (!autoSelect) return; 8174 forceValueUpdate(); 8175 }); 8176 const onMouseDownProp = props.onMouseDown; 8177 const blurActiveItemOnClickProp = useBooleanEvent( 8178 blurActiveItemOnClick != null ? blurActiveItemOnClick : () => !!(store == null ? void 0 : store.getState().includesBaseElement) 8179 ); 8180 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 8181 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow); 8182 const onMouseDown = useEvent((event) => { 8183 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 8184 if (event.defaultPrevented) return; 8185 if (event.button) return; 8186 if (event.ctrlKey) return; 8187 if (!store) return; 8188 if (blurActiveItemOnClickProp(event)) { 8189 store.setActiveId(null); 8190 } 8191 if (setValueOnClickProp(event)) { 8192 store.setValue(value); 8193 } 8194 if (showOnClickProp(event)) { 8195 queueBeforeEvent(event.currentTarget, "mouseup", store.show); 8196 } 8197 }); 8198 const onKeyDownProp = props.onKeyDown; 8199 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow); 8200 const onKeyDown = useEvent((event) => { 8201 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 8202 if (!event.repeat) { 8203 canAutoSelectRef.current = false; 8204 } 8205 if (event.defaultPrevented) return; 8206 if (event.ctrlKey) return; 8207 if (event.altKey) return; 8208 if (event.shiftKey) return; 8209 if (event.metaKey) return; 8210 if (!store) return; 8211 const { open: open2 } = store.getState(); 8212 if (open2) return; 8213 if (event.key === "ArrowUp" || event.key === "ArrowDown") { 8214 if (showOnKeyPressProp(event)) { 8215 event.preventDefault(); 8216 store.show(); 8217 } 8218 } 8219 }); 8220 const onBlurProp = props.onBlur; 8221 const onBlur = useEvent((event) => { 8222 canAutoSelectRef.current = false; 8223 onBlurProp == null ? void 0 : onBlurProp(event); 8224 if (event.defaultPrevented) return; 8225 }); 8226 const id = useId3(props.id); 8227 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0; 8228 const isActiveItem = store.useState((state) => state.activeId === null); 8229 props = __spreadProps(__spreadValues({ 8230 id, 8231 role: "combobox", 8232 "aria-autocomplete": ariaAutoComplete, 8233 "aria-haspopup": getPopupRole(contentElement, "listbox"), 8234 "aria-expanded": open, 8235 "aria-controls": contentElement == null ? void 0 : contentElement.id, 8236 "data-active-item": isActiveItem || void 0, 8237 value 8238 }, props), { 8239 ref: useMergeRefs(ref, props.ref), 8240 onChange, 8241 onCompositionEnd, 8242 onMouseDown, 8243 onKeyDown, 8244 onBlur 8245 }); 8246 props = useComposite(__spreadProps(__spreadValues({ 8247 store, 8248 focusable 8249 }, props), { 8250 // Enable inline autocomplete when the user moves from the combobox input 8251 // to an item. 8252 moveOnKeyPress: (event) => { 8253 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false; 8254 if (inline) setCanInline(true); 8255 return true; 8256 } 8257 })); 8258 props = usePopoverAnchor(__spreadValues({ store }, props)); 8259 return __spreadValues({ autoComplete: "off" }, props); 8260 } 8261 ); 8262 var Combobox = forwardRef22(function Combobox2(props) { 8263 const htmlProps = useCombobox(props); 8264 return createElement2(TagName4, htmlProps); 8265 }); 8266 8267 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js 8268 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1); 8269 function ComboboxProvider(props = {}) { 8270 const store = useComboboxStore(props); 8271 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ComboboxContextProvider, { value: store, children: props.children }); 8272 } 8273 8274 // node_modules/@ariakit/react-core/esm/__chunks/KUU7WJ55.js 8275 var import_react12 = __toESM(require_react(), 1); 8276 var TagName5 = "button"; 8277 function isNativeClick(event) { 8278 if (!event.isTrusted) return false; 8279 const element = event.currentTarget; 8280 if (event.key === "Enter") { 8281 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A"; 8282 } 8283 if (event.key === " ") { 8284 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT"; 8285 } 8286 return false; 8287 } 8288 var symbol = Symbol("command"); 8289 var useCommand = createHook( 8290 function useCommand2(_a) { 8291 var _b = _a, { clickOnEnter = true, clickOnSpace = true } = _b, props = __objRest(_b, ["clickOnEnter", "clickOnSpace"]); 8292 const ref = (0, import_react12.useRef)(null); 8293 const [isNativeButton, setIsNativeButton] = (0, import_react12.useState)(false); 8294 (0, import_react12.useEffect)(() => { 8295 if (!ref.current) return; 8296 setIsNativeButton(isButton(ref.current)); 8297 }, []); 8298 const [active, setActive] = (0, import_react12.useState)(false); 8299 const activeRef = (0, import_react12.useRef)(false); 8300 const disabled = disabledFromProps(props); 8301 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true); 8302 const onKeyDownProp = props.onKeyDown; 8303 const onKeyDown = useEvent((event) => { 8304 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 8305 const element = event.currentTarget; 8306 if (event.defaultPrevented) return; 8307 if (isDuplicate) return; 8308 if (disabled) return; 8309 if (!isSelfTarget(event)) return; 8310 if (isTextField(element)) return; 8311 if (element.isContentEditable) return; 8312 const isEnter = clickOnEnter && event.key === "Enter"; 8313 const isSpace = clickOnSpace && event.key === " "; 8314 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter; 8315 const shouldPreventSpace = event.key === " " && !clickOnSpace; 8316 if (shouldPreventEnter || shouldPreventSpace) { 8317 event.preventDefault(); 8318 return; 8319 } 8320 if (isEnter || isSpace) { 8321 const nativeClick = isNativeClick(event); 8322 if (isEnter) { 8323 if (!nativeClick) { 8324 event.preventDefault(); 8325 const _a2 = event, { view } = _a2, eventInit = __objRest(_a2, ["view"]); 8326 const click = () => fireClickEvent(element, eventInit); 8327 if (isFirefox()) { 8328 queueBeforeEvent(element, "keyup", click); 8329 } else { 8330 queueMicrotask(click); 8331 } 8332 } 8333 } else if (isSpace) { 8334 activeRef.current = true; 8335 if (!nativeClick) { 8336 event.preventDefault(); 8337 setActive(true); 8338 } 8339 } 8340 } 8341 }); 8342 const onKeyUpProp = props.onKeyUp; 8343 const onKeyUp = useEvent((event) => { 8344 onKeyUpProp == null ? void 0 : onKeyUpProp(event); 8345 if (event.defaultPrevented) return; 8346 if (isDuplicate) return; 8347 if (disabled) return; 8348 if (event.metaKey) return; 8349 const isSpace = clickOnSpace && event.key === " "; 8350 if (activeRef.current && isSpace) { 8351 activeRef.current = false; 8352 if (!isNativeClick(event)) { 8353 event.preventDefault(); 8354 setActive(false); 8355 const element = event.currentTarget; 8356 const _a2 = event, { view } = _a2, eventInit = __objRest(_a2, ["view"]); 8357 queueMicrotask(() => fireClickEvent(element, eventInit)); 8358 } 8359 } 8360 }); 8361 props = __spreadProps(__spreadValues(__spreadValues({ 8362 "data-active": active || void 0, 8363 type: isNativeButton ? "button" : void 0 8364 }, metadataProps), props), { 8365 ref: useMergeRefs(ref, props.ref), 8366 onKeyDown, 8367 onKeyUp 8368 }); 8369 props = useFocusable(props); 8370 return props; 8371 } 8372 ); 8373 var Command = forwardRef22(function Command2(props) { 8374 const htmlProps = useCommand(props); 8375 return createElement2(TagName5, htmlProps); 8376 }); 8377 8378 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js 8379 var import_react13 = __toESM(require_react(), 1); 8380 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1); 8381 var TagName6 = "span"; 8382 function normalizeValue(value) { 8383 return normalizeString(value).toLowerCase(); 8384 } 8385 function getOffsets(string, values) { 8386 const offsets = []; 8387 for (const value of values) { 8388 let pos = 0; 8389 const length = value.length; 8390 while (string.indexOf(value, pos) !== -1) { 8391 const index = string.indexOf(value, pos); 8392 if (index !== -1) { 8393 offsets.push([index, length]); 8394 } 8395 pos = index + 1; 8396 } 8397 } 8398 return offsets; 8399 } 8400 function filterOverlappingOffsets(offsets) { 8401 return offsets.filter(([offset, length], i2, arr) => { 8402 return !arr.some( 8403 ([o2, l2], j2) => j2 !== i2 && o2 <= offset && o2 + l2 >= offset + length 8404 ); 8405 }); 8406 } 8407 function sortOffsets(offsets) { 8408 return offsets.sort(([a2], [b2]) => a2 - b2); 8409 } 8410 function splitValue(itemValue, userValue) { 8411 if (!itemValue) return itemValue; 8412 if (!userValue) return itemValue; 8413 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue); 8414 const parts = []; 8415 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 8416 "span", 8417 { 8418 "data-autocomplete-value": autocomplete ? "" : void 0, 8419 "data-user-value": autocomplete ? void 0 : "", 8420 children: value 8421 }, 8422 parts.length 8423 ); 8424 const offsets = sortOffsets( 8425 filterOverlappingOffsets( 8426 // Convert userValues into a set to avoid duplicates 8427 getOffsets(normalizeValue(itemValue), new Set(userValues)) 8428 ) 8429 ); 8430 if (!offsets.length) { 8431 parts.push(span(itemValue, true)); 8432 return parts; 8433 } 8434 const [firstOffset] = offsets[0]; 8435 const values = [ 8436 itemValue.slice(0, firstOffset), 8437 ...offsets.flatMap(([offset, length], i2) => { 8438 var _a; 8439 const value = itemValue.slice(offset, offset + length); 8440 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0]; 8441 const nextValue = itemValue.slice(offset + length, nextOffset); 8442 return [value, nextValue]; 8443 }) 8444 ]; 8445 values.forEach((value, i2) => { 8446 if (!value) return; 8447 parts.push(span(value, i2 % 2 === 0)); 8448 }); 8449 return parts; 8450 } 8451 var useComboboxItemValue = createHook(function useComboboxItemValue2(_a) { 8452 var _b = _a, { store, value, userValue } = _b, props = __objRest(_b, ["store", "value", "userValue"]); 8453 const context = useComboboxScopedContext(); 8454 store = store || context; 8455 const itemContext = (0, import_react13.useContext)(ComboboxItemValueContext); 8456 const itemValue = value != null ? value : itemContext; 8457 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value); 8458 const children = (0, import_react13.useMemo)(() => { 8459 if (!itemValue) return; 8460 if (!inputValue) return itemValue; 8461 return splitValue(itemValue, inputValue); 8462 }, [itemValue, inputValue]); 8463 props = __spreadValues({ 8464 children 8465 }, props); 8466 return removeUndefinedValues(props); 8467 }); 8468 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) { 8469 const htmlProps = useComboboxItemValue(props); 8470 return createElement2(TagName6, htmlProps); 8471 }); 8472 8473 // node_modules/@ariakit/react-core/esm/__chunks/UQQRIHDV.js 8474 var import_react14 = __toESM(require_react(), 1); 8475 var TagName7 = "div"; 8476 function getMouseDestination(event) { 8477 const relatedTarget = event.relatedTarget; 8478 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) { 8479 return relatedTarget; 8480 } 8481 return null; 8482 } 8483 function hoveringInside(event) { 8484 const nextElement = getMouseDestination(event); 8485 if (!nextElement) return false; 8486 return contains(event.currentTarget, nextElement); 8487 } 8488 var symbol2 = Symbol("composite-hover"); 8489 function movingToAnotherItem(event) { 8490 let dest = getMouseDestination(event); 8491 if (!dest) return false; 8492 do { 8493 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true; 8494 dest = dest.parentElement; 8495 } while (dest); 8496 return false; 8497 } 8498 var useCompositeHover = createHook( 8499 function useCompositeHover2(_a) { 8500 var _b = _a, { 8501 store, 8502 focusOnHover = true, 8503 blurOnHoverEnd = !!focusOnHover 8504 } = _b, props = __objRest(_b, [ 8505 "store", 8506 "focusOnHover", 8507 "blurOnHoverEnd" 8508 ]); 8509 const context = useCompositeContext(); 8510 store = store || context; 8511 invariant( 8512 store, 8513 "CompositeHover must be wrapped in a Composite component." 8514 ); 8515 const isMouseMoving = useIsMouseMoving(); 8516 const onMouseMoveProp = props.onMouseMove; 8517 const focusOnHoverProp = useBooleanEvent(focusOnHover); 8518 const onMouseMove = useEvent((event) => { 8519 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event); 8520 if (event.defaultPrevented) return; 8521 if (!isMouseMoving()) return; 8522 if (!focusOnHoverProp(event)) return; 8523 if (!hasFocusWithin(event.currentTarget)) { 8524 const baseElement = store == null ? void 0 : store.getState().baseElement; 8525 if (baseElement && !hasFocus(baseElement)) { 8526 baseElement.focus(); 8527 } 8528 } 8529 store == null ? void 0 : store.setActiveId(event.currentTarget.id); 8530 }); 8531 const onMouseLeaveProp = props.onMouseLeave; 8532 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd); 8533 const onMouseLeave = useEvent((event) => { 8534 var _a2; 8535 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event); 8536 if (event.defaultPrevented) return; 8537 if (!isMouseMoving()) return; 8538 if (hoveringInside(event)) return; 8539 if (movingToAnotherItem(event)) return; 8540 if (!focusOnHoverProp(event)) return; 8541 if (!blurOnHoverEndProp(event)) return; 8542 store == null ? void 0 : store.setActiveId(null); 8543 (_a2 = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a2.focus(); 8544 }); 8545 const ref = (0, import_react14.useCallback)((element) => { 8546 if (!element) return; 8547 element[symbol2] = true; 8548 }, []); 8549 props = __spreadProps(__spreadValues({}, props), { 8550 ref: useMergeRefs(ref, props.ref), 8551 onMouseMove, 8552 onMouseLeave 8553 }); 8554 return removeUndefinedValues(props); 8555 } 8556 ); 8557 var CompositeHover = memo22( 8558 forwardRef22(function CompositeHover2(props) { 8559 const htmlProps = useCompositeHover(props); 8560 return createElement2(TagName7, htmlProps); 8561 }) 8562 ); 8563 8564 // node_modules/@ariakit/react-core/esm/__chunks/RZ4GPYOB.js 8565 var import_react15 = __toESM(require_react(), 1); 8566 var TagName8 = "div"; 8567 var useCollectionItem = createHook( 8568 function useCollectionItem2(_a) { 8569 var _b = _a, { 8570 store, 8571 shouldRegisterItem = true, 8572 getItem = identity, 8573 element 8574 } = _b, props = __objRest(_b, [ 8575 "store", 8576 "shouldRegisterItem", 8577 "getItem", 8578 // @ts-expect-error This prop may come from a collection renderer. 8579 "element" 8580 ]); 8581 const context = useCollectionContext(); 8582 store = store || context; 8583 const id = useId3(props.id); 8584 const ref = (0, import_react15.useRef)(element); 8585 (0, import_react15.useEffect)(() => { 8586 const element2 = ref.current; 8587 if (!id) return; 8588 if (!element2) return; 8589 if (!shouldRegisterItem) return; 8590 const item = getItem({ id, element: element2 }); 8591 return store == null ? void 0 : store.renderItem(item); 8592 }, [id, shouldRegisterItem, getItem, store]); 8593 props = __spreadProps(__spreadValues({}, props), { 8594 ref: useMergeRefs(ref, props.ref) 8595 }); 8596 return removeUndefinedValues(props); 8597 } 8598 ); 8599 var CollectionItem = forwardRef22(function CollectionItem2(props) { 8600 const htmlProps = useCollectionItem(props); 8601 return createElement2(TagName8, htmlProps); 8602 }); 8603 8604 // node_modules/@ariakit/react-core/esm/__chunks/P2CTZE2T.js 8605 var import_react16 = __toESM(require_react(), 1); 8606 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1); 8607 var TagName9 = "button"; 8608 function isEditableElement(element) { 8609 if (isTextbox(element)) return true; 8610 return element.tagName === "INPUT" && !isButton(element); 8611 } 8612 function getNextPageOffset(scrollingElement, pageUp = false) { 8613 const height = scrollingElement.clientHeight; 8614 const { top } = scrollingElement.getBoundingClientRect(); 8615 const pageSize = Math.max(height * 0.875, height - 40) * 1.5; 8616 const pageOffset = pageUp ? height - pageSize + top : pageSize + top; 8617 if (scrollingElement.tagName === "HTML") { 8618 return pageOffset + scrollingElement.scrollTop; 8619 } 8620 return pageOffset; 8621 } 8622 function getItemOffset(itemElement, pageUp = false) { 8623 const { top } = itemElement.getBoundingClientRect(); 8624 if (pageUp) { 8625 return top + itemElement.clientHeight; 8626 } 8627 return top; 8628 } 8629 function findNextPageItemId(element, store, next, pageUp = false) { 8630 var _a; 8631 if (!store) return; 8632 if (!next) return; 8633 const { renderedItems } = store.getState(); 8634 const scrollingElement = getScrollingElement(element); 8635 if (!scrollingElement) return; 8636 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp); 8637 let id; 8638 let prevDifference; 8639 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) { 8640 const previousId = id; 8641 id = next(i2); 8642 if (!id) break; 8643 if (id === previousId) continue; 8644 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element; 8645 if (!itemElement) continue; 8646 const itemOffset = getItemOffset(itemElement, pageUp); 8647 const difference = itemOffset - nextPageOffset; 8648 const absDifference = Math.abs(difference); 8649 if (pageUp && difference <= 0 || !pageUp && difference >= 0) { 8650 if (prevDifference !== void 0 && prevDifference < absDifference) { 8651 id = previousId; 8652 } 8653 break; 8654 } 8655 prevDifference = absDifference; 8656 } 8657 return id; 8658 } 8659 function targetIsAnotherItem(event, store) { 8660 if (isSelfTarget(event)) return false; 8661 return isItem(store, event.target); 8662 } 8663 var useCompositeItem = createHook( 8664 function useCompositeItem2(_a) { 8665 var _b = _a, { 8666 store, 8667 rowId: rowIdProp, 8668 preventScrollOnKeyDown = false, 8669 moveOnKeyPress = true, 8670 tabbable = false, 8671 getItem: getItemProp, 8672 "aria-setsize": ariaSetSizeProp, 8673 "aria-posinset": ariaPosInSetProp 8674 } = _b, props = __objRest(_b, [ 8675 "store", 8676 "rowId", 8677 "preventScrollOnKeyDown", 8678 "moveOnKeyPress", 8679 "tabbable", 8680 "getItem", 8681 "aria-setsize", 8682 "aria-posinset" 8683 ]); 8684 const context = useCompositeContext(); 8685 store = store || context; 8686 const id = useId3(props.id); 8687 const ref = (0, import_react16.useRef)(null); 8688 const row = (0, import_react16.useContext)(CompositeRowContext); 8689 const disabled = disabledFromProps(props); 8690 const trulyDisabled = disabled && !props.accessibleWhenDisabled; 8691 const { 8692 rowId, 8693 baseElement, 8694 isActiveItem, 8695 ariaSetSize, 8696 ariaPosInSet, 8697 isTabbable 8698 } = useStoreStateObject(store, { 8699 rowId(state) { 8700 if (rowIdProp) return rowIdProp; 8701 if (!state) return; 8702 if (!(row == null ? void 0 : row.baseElement)) return; 8703 if (row.baseElement !== state.baseElement) return; 8704 return row.id; 8705 }, 8706 baseElement(state) { 8707 return (state == null ? void 0 : state.baseElement) || void 0; 8708 }, 8709 isActiveItem(state) { 8710 return !!state && state.activeId === id; 8711 }, 8712 ariaSetSize(state) { 8713 if (ariaSetSizeProp != null) return ariaSetSizeProp; 8714 if (!state) return; 8715 if (!(row == null ? void 0 : row.ariaSetSize)) return; 8716 if (row.baseElement !== state.baseElement) return; 8717 return row.ariaSetSize; 8718 }, 8719 ariaPosInSet(state) { 8720 if (ariaPosInSetProp != null) return ariaPosInSetProp; 8721 if (!state) return; 8722 if (!(row == null ? void 0 : row.ariaPosInSet)) return; 8723 if (row.baseElement !== state.baseElement) return; 8724 const itemsInRow = state.renderedItems.filter( 8725 (item) => item.rowId === rowId 8726 ); 8727 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id); 8728 }, 8729 isTabbable(state) { 8730 if (!(state == null ? void 0 : state.renderedItems.length)) return true; 8731 if (state.virtualFocus) return false; 8732 if (tabbable) return true; 8733 if (state.activeId === null) return false; 8734 const item = store == null ? void 0 : store.item(state.activeId); 8735 if (item == null ? void 0 : item.disabled) return true; 8736 if (!(item == null ? void 0 : item.element)) return true; 8737 return state.activeId === id; 8738 } 8739 }); 8740 const getItem = (0, import_react16.useCallback)( 8741 (item) => { 8742 var _a2; 8743 const nextItem = __spreadProps(__spreadValues({}, item), { 8744 id: id || item.id, 8745 rowId, 8746 disabled: !!trulyDisabled, 8747 children: (_a2 = item.element) == null ? void 0 : _a2.textContent 8748 }); 8749 if (getItemProp) { 8750 return getItemProp(nextItem); 8751 } 8752 return nextItem; 8753 }, 8754 [id, rowId, trulyDisabled, getItemProp] 8755 ); 8756 const onFocusProp = props.onFocus; 8757 const hasFocusedComposite = (0, import_react16.useRef)(false); 8758 const onFocus = useEvent((event) => { 8759 onFocusProp == null ? void 0 : onFocusProp(event); 8760 if (event.defaultPrevented) return; 8761 if (isPortalEvent(event)) return; 8762 if (!id) return; 8763 if (!store) return; 8764 if (targetIsAnotherItem(event, store)) return; 8765 const { virtualFocus, baseElement: baseElement2 } = store.getState(); 8766 store.setActiveId(id); 8767 if (isTextbox(event.currentTarget)) { 8768 selectTextField(event.currentTarget); 8769 } 8770 if (!virtualFocus) return; 8771 if (!isSelfTarget(event)) return; 8772 if (isEditableElement(event.currentTarget)) return; 8773 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return; 8774 if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) { 8775 event.currentTarget.scrollIntoView({ 8776 block: "nearest", 8777 inline: "nearest" 8778 }); 8779 } 8780 hasFocusedComposite.current = true; 8781 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget); 8782 if (fromComposite) { 8783 focusSilently(baseElement2); 8784 } else { 8785 baseElement2.focus(); 8786 } 8787 }); 8788 const onBlurCaptureProp = props.onBlurCapture; 8789 const onBlurCapture = useEvent((event) => { 8790 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 8791 if (event.defaultPrevented) return; 8792 const state = store == null ? void 0 : store.getState(); 8793 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) { 8794 hasFocusedComposite.current = false; 8795 event.preventDefault(); 8796 event.stopPropagation(); 8797 } 8798 }); 8799 const onKeyDownProp = props.onKeyDown; 8800 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown); 8801 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 8802 const onKeyDown = useEvent((event) => { 8803 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 8804 if (event.defaultPrevented) return; 8805 if (!isSelfTarget(event)) return; 8806 if (!store) return; 8807 const { currentTarget } = event; 8808 const state = store.getState(); 8809 const item = store.item(id); 8810 const isGrid2 = !!(item == null ? void 0 : item.rowId); 8811 const isVertical = state.orientation !== "horizontal"; 8812 const isHorizontal = state.orientation !== "vertical"; 8813 const canHomeEnd = () => { 8814 if (isGrid2) return true; 8815 if (isHorizontal) return true; 8816 if (!state.baseElement) return true; 8817 if (!isTextField(state.baseElement)) return true; 8818 return false; 8819 }; 8820 const keyMap = { 8821 ArrowUp: (isGrid2 || isVertical) && store.up, 8822 ArrowRight: (isGrid2 || isHorizontal) && store.next, 8823 ArrowDown: (isGrid2 || isVertical) && store.down, 8824 ArrowLeft: (isGrid2 || isHorizontal) && store.previous, 8825 Home: () => { 8826 if (!canHomeEnd()) return; 8827 if (!isGrid2 || event.ctrlKey) { 8828 return store == null ? void 0 : store.first(); 8829 } 8830 return store == null ? void 0 : store.previous(-1); 8831 }, 8832 End: () => { 8833 if (!canHomeEnd()) return; 8834 if (!isGrid2 || event.ctrlKey) { 8835 return store == null ? void 0 : store.last(); 8836 } 8837 return store == null ? void 0 : store.next(-1); 8838 }, 8839 PageUp: () => { 8840 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true); 8841 }, 8842 PageDown: () => { 8843 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down); 8844 } 8845 }; 8846 const action = keyMap[event.key]; 8847 if (action) { 8848 if (isTextbox(currentTarget)) { 8849 const selection = getTextboxSelection(currentTarget); 8850 const isLeft = isHorizontal && event.key === "ArrowLeft"; 8851 const isRight = isHorizontal && event.key === "ArrowRight"; 8852 const isUp = isVertical && event.key === "ArrowUp"; 8853 const isDown = isVertical && event.key === "ArrowDown"; 8854 if (isRight || isDown) { 8855 const { length: valueLength } = getTextboxValue(currentTarget); 8856 if (selection.end !== valueLength) return; 8857 } else if ((isLeft || isUp) && selection.start !== 0) return; 8858 } 8859 const nextId = action(); 8860 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) { 8861 if (!moveOnKeyPressProp(event)) return; 8862 event.preventDefault(); 8863 store.move(nextId); 8864 } 8865 } 8866 }); 8867 const providerValue = (0, import_react16.useMemo)( 8868 () => ({ id, baseElement }), 8869 [id, baseElement] 8870 ); 8871 props = useWrapElement( 8872 props, 8873 (element) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }), 8874 [providerValue] 8875 ); 8876 props = __spreadProps(__spreadValues({ 8877 id, 8878 "data-active-item": isActiveItem || void 0 8879 }, props), { 8880 ref: useMergeRefs(ref, props.ref), 8881 tabIndex: isTabbable ? props.tabIndex : -1, 8882 onFocus, 8883 onBlurCapture, 8884 onKeyDown 8885 }); 8886 props = useCommand(props); 8887 props = useCollectionItem(__spreadProps(__spreadValues({ 8888 store 8889 }, props), { 8890 getItem, 8891 shouldRegisterItem: id ? props.shouldRegisterItem : false 8892 })); 8893 return removeUndefinedValues(__spreadProps(__spreadValues({}, props), { 8894 "aria-setsize": ariaSetSize, 8895 "aria-posinset": ariaPosInSet 8896 })); 8897 } 8898 ); 8899 var CompositeItem = memo22( 8900 forwardRef22(function CompositeItem2(props) { 8901 const htmlProps = useCompositeItem(props); 8902 return createElement2(TagName9, htmlProps); 8903 }) 8904 ); 8905 8906 // node_modules/@ariakit/react-core/esm/__chunks/ZTDSJLD6.js 8907 var import_react17 = __toESM(require_react(), 1); 8908 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1); 8909 var TagName10 = "div"; 8910 function isSelected(storeValue, itemValue) { 8911 if (itemValue == null) return; 8912 if (storeValue == null) return false; 8913 if (Array.isArray(storeValue)) { 8914 return storeValue.includes(itemValue); 8915 } 8916 return storeValue === itemValue; 8917 } 8918 function getItemRole(popupRole) { 8919 var _a; 8920 const itemRoleByPopupRole = { 8921 menu: "menuitem", 8922 listbox: "option", 8923 tree: "treeitem" 8924 }; 8925 const key = popupRole; 8926 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option"; 8927 } 8928 var useComboboxItem = createHook( 8929 function useComboboxItem2(_a) { 8930 var _b = _a, { 8931 store, 8932 value, 8933 hideOnClick, 8934 setValueOnClick, 8935 selectValueOnClick = true, 8936 resetValueOnSelect, 8937 focusOnHover = false, 8938 moveOnKeyPress = true, 8939 getItem: getItemProp 8940 } = _b, props = __objRest(_b, [ 8941 "store", 8942 "value", 8943 "hideOnClick", 8944 "setValueOnClick", 8945 "selectValueOnClick", 8946 "resetValueOnSelect", 8947 "focusOnHover", 8948 "moveOnKeyPress", 8949 "getItem" 8950 ]); 8951 var _a2; 8952 const context = useComboboxScopedContext(); 8953 store = store || context; 8954 invariant( 8955 store, 8956 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component." 8957 ); 8958 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, { 8959 resetValueOnSelectState: "resetValueOnSelect", 8960 multiSelectable(state) { 8961 return Array.isArray(state.selectedValue); 8962 }, 8963 selected(state) { 8964 return isSelected(state.selectedValue, value); 8965 } 8966 }); 8967 const getItem = (0, import_react17.useCallback)( 8968 (item) => { 8969 const nextItem = __spreadProps(__spreadValues({}, item), { value }); 8970 if (getItemProp) { 8971 return getItemProp(nextItem); 8972 } 8973 return nextItem; 8974 }, 8975 [value, getItemProp] 8976 ); 8977 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable; 8978 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable; 8979 const onClickProp = props.onClick; 8980 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 8981 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick); 8982 const resetValueOnSelectProp = useBooleanEvent( 8983 (_a2 = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a2 : multiSelectable 8984 ); 8985 const hideOnClickProp = useBooleanEvent(hideOnClick); 8986 const onClick = useEvent((event) => { 8987 onClickProp == null ? void 0 : onClickProp(event); 8988 if (event.defaultPrevented) return; 8989 if (isDownloading(event)) return; 8990 if (isOpeningInNewTab(event)) return; 8991 if (value != null) { 8992 if (selectValueOnClickProp(event)) { 8993 if (resetValueOnSelectProp(event)) { 8994 store == null ? void 0 : store.resetValue(); 8995 } 8996 store == null ? void 0 : store.setSelectedValue((prevValue) => { 8997 if (!Array.isArray(prevValue)) return value; 8998 if (prevValue.includes(value)) { 8999 return prevValue.filter((v2) => v2 !== value); 9000 } 9001 return [...prevValue, value]; 9002 }); 9003 } 9004 if (setValueOnClickProp(event)) { 9005 store == null ? void 0 : store.setValue(value); 9006 } 9007 } 9008 if (hideOnClickProp(event)) { 9009 store == null ? void 0 : store.hide(); 9010 } 9011 }); 9012 const onKeyDownProp = props.onKeyDown; 9013 const onKeyDown = useEvent((event) => { 9014 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 9015 if (event.defaultPrevented) return; 9016 const baseElement = store == null ? void 0 : store.getState().baseElement; 9017 if (!baseElement) return; 9018 if (hasFocus(baseElement)) return; 9019 const printable = event.key.length === 1; 9020 if (printable || event.key === "Backspace" || event.key === "Delete") { 9021 queueMicrotask(() => baseElement.focus()); 9022 if (isTextField(baseElement)) { 9023 store == null ? void 0 : store.setValue(baseElement.value); 9024 } 9025 } 9026 }); 9027 if (multiSelectable && selected != null) { 9028 props = __spreadValues({ 9029 "aria-selected": selected 9030 }, props); 9031 } 9032 props = useWrapElement( 9033 props, 9034 (element) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }), 9035 [value, selected] 9036 ); 9037 const popupRole = (0, import_react17.useContext)(ComboboxListRoleContext); 9038 props = __spreadProps(__spreadValues({ 9039 role: getItemRole(popupRole), 9040 children: value 9041 }, props), { 9042 onClick, 9043 onKeyDown 9044 }); 9045 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 9046 props = useCompositeItem(__spreadProps(__spreadValues({ 9047 store 9048 }, props), { 9049 getItem, 9050 // Dispatch a custom event on the combobox input when moving to an item 9051 // with the keyboard so the Combobox component can enable inline 9052 // autocompletion. 9053 moveOnKeyPress: (event) => { 9054 if (!moveOnKeyPressProp(event)) return false; 9055 const moveEvent = new Event("combobox-item-move"); 9056 const baseElement = store == null ? void 0 : store.getState().baseElement; 9057 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent); 9058 return true; 9059 } 9060 })); 9061 props = useCompositeHover(__spreadValues({ store, focusOnHover }, props)); 9062 return props; 9063 } 9064 ); 9065 var ComboboxItem = memo22( 9066 forwardRef22(function ComboboxItem2(props) { 9067 const htmlProps = useComboboxItem(props); 9068 return createElement2(TagName10, htmlProps); 9069 }) 9070 ); 9071 9072 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js 9073 var TagName11 = "label"; 9074 var useComboboxLabel = createHook( 9075 function useComboboxLabel2(_a) { 9076 var _b = _a, { store } = _b, props = __objRest(_b, ["store"]); 9077 const context = useComboboxProviderContext(); 9078 store = store || context; 9079 invariant( 9080 store, 9081 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component." 9082 ); 9083 const comboboxId = store.useState((state) => { 9084 var _a2; 9085 return (_a2 = state.baseElement) == null ? void 0 : _a2.id; 9086 }); 9087 props = __spreadValues({ 9088 htmlFor: comboboxId 9089 }, props); 9090 return removeUndefinedValues(props); 9091 } 9092 ); 9093 var ComboboxLabel = memo22( 9094 forwardRef22(function ComboboxLabel2(props) { 9095 const htmlProps = useComboboxLabel(props); 9096 return createElement2(TagName11, htmlProps); 9097 }) 9098 ); 9099 9100 // node_modules/@ariakit/react-core/esm/__chunks/VGCJ63VH.js 9101 var import_react18 = __toESM(require_react(), 1); 9102 var import_react_dom = __toESM(require_react_dom(), 1); 9103 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1); 9104 var TagName12 = "div"; 9105 function afterTimeout(timeoutMs, cb) { 9106 const timeoutId = setTimeout(cb, timeoutMs); 9107 return () => clearTimeout(timeoutId); 9108 } 9109 function afterPaint2(cb) { 9110 let raf = requestAnimationFrame(() => { 9111 raf = requestAnimationFrame(cb); 9112 }); 9113 return () => cancelAnimationFrame(raf); 9114 } 9115 function parseCSSTime(...times) { 9116 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => { 9117 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3; 9118 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier; 9119 if (currentTime > longestTime) return currentTime; 9120 return longestTime; 9121 }, 0); 9122 } 9123 function isHidden(mounted, hidden, alwaysVisible) { 9124 return !alwaysVisible && hidden !== false && (!mounted || !!hidden); 9125 } 9126 var useDisclosureContent = createHook(function useDisclosureContent2(_a) { 9127 var _b = _a, { store, alwaysVisible } = _b, props = __objRest(_b, ["store", "alwaysVisible"]); 9128 const context = useDisclosureProviderContext(); 9129 store = store || context; 9130 invariant( 9131 store, 9132 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component." 9133 ); 9134 const ref = (0, import_react18.useRef)(null); 9135 const id = useId3(props.id); 9136 const [transition, setTransition] = (0, import_react18.useState)(null); 9137 const open = store.useState("open"); 9138 const mounted = store.useState("mounted"); 9139 const animated = store.useState("animated"); 9140 const contentElement = store.useState("contentElement"); 9141 const otherElement = useStoreState(store.disclosure, "contentElement"); 9142 useSafeLayoutEffect(() => { 9143 if (!ref.current) return; 9144 store == null ? void 0 : store.setContentElement(ref.current); 9145 }, [store]); 9146 useSafeLayoutEffect(() => { 9147 let previousAnimated; 9148 store == null ? void 0 : store.setState("animated", (animated2) => { 9149 previousAnimated = animated2; 9150 return true; 9151 }); 9152 return () => { 9153 if (previousAnimated === void 0) return; 9154 store == null ? void 0 : store.setState("animated", previousAnimated); 9155 }; 9156 }, [store]); 9157 useSafeLayoutEffect(() => { 9158 if (!animated) return; 9159 if (!(contentElement == null ? void 0 : contentElement.isConnected)) { 9160 setTransition(null); 9161 return; 9162 } 9163 return afterPaint2(() => { 9164 setTransition(open ? "enter" : mounted ? "leave" : null); 9165 }); 9166 }, [animated, contentElement, open, mounted]); 9167 useSafeLayoutEffect(() => { 9168 if (!store) return; 9169 if (!animated) return; 9170 if (!transition) return; 9171 if (!contentElement) return; 9172 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false); 9173 const stopAnimationSync = () => (0, import_react_dom.flushSync)(stopAnimation); 9174 if (transition === "leave" && open) return; 9175 if (transition === "enter" && !open) return; 9176 if (typeof animated === "number") { 9177 const timeout2 = animated; 9178 return afterTimeout(timeout2, stopAnimationSync); 9179 } 9180 const { 9181 transitionDuration, 9182 animationDuration, 9183 transitionDelay, 9184 animationDelay 9185 } = getComputedStyle(contentElement); 9186 const { 9187 transitionDuration: transitionDuration2 = "0", 9188 animationDuration: animationDuration2 = "0", 9189 transitionDelay: transitionDelay2 = "0", 9190 animationDelay: animationDelay2 = "0" 9191 } = otherElement ? getComputedStyle(otherElement) : {}; 9192 const delay = parseCSSTime( 9193 transitionDelay, 9194 animationDelay, 9195 transitionDelay2, 9196 animationDelay2 9197 ); 9198 const duration = parseCSSTime( 9199 transitionDuration, 9200 animationDuration, 9201 transitionDuration2, 9202 animationDuration2 9203 ); 9204 const timeout = delay + duration; 9205 if (!timeout) { 9206 if (transition === "enter") { 9207 store.setState("animated", false); 9208 } 9209 stopAnimation(); 9210 return; 9211 } 9212 const frameRate = 1e3 / 60; 9213 const maxTimeout = Math.max(timeout - frameRate, 0); 9214 return afterTimeout(maxTimeout, stopAnimationSync); 9215 }, [store, animated, contentElement, otherElement, open, transition]); 9216 props = useWrapElement( 9217 props, 9218 (element) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(DialogScopedContextProvider, { value: store, children: element }), 9219 [store] 9220 ); 9221 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 9222 const styleProp = props.style; 9223 const style = (0, import_react18.useMemo)(() => { 9224 if (hidden) { 9225 return __spreadProps(__spreadValues({}, styleProp), { display: "none" }); 9226 } 9227 return styleProp; 9228 }, [hidden, styleProp]); 9229 props = __spreadProps(__spreadValues({ 9230 id, 9231 "data-open": open || void 0, 9232 "data-enter": transition === "enter" || void 0, 9233 "data-leave": transition === "leave" || void 0, 9234 hidden 9235 }, props), { 9236 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref), 9237 style 9238 }); 9239 return removeUndefinedValues(props); 9240 }); 9241 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) { 9242 const htmlProps = useDisclosureContent(props); 9243 return createElement2(TagName12, htmlProps); 9244 }); 9245 var DisclosureContent = forwardRef22(function DisclosureContent2(_a) { 9246 var _b = _a, { 9247 unmountOnHide 9248 } = _b, props = __objRest(_b, [ 9249 "unmountOnHide" 9250 ]); 9251 const context = useDisclosureProviderContext(); 9252 const store = props.store || context; 9253 const mounted = useStoreState( 9254 store, 9255 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted) 9256 ); 9257 if (mounted === false) return null; 9258 return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(DisclosureContentImpl, __spreadValues({}, props)); 9259 }); 9260 9261 // node_modules/@ariakit/react-core/esm/__chunks/HUWAI7RB.js 9262 var import_react19 = __toESM(require_react(), 1); 9263 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1); 9264 var TagName13 = "div"; 9265 var useComboboxList = createHook( 9266 function useComboboxList2(_a) { 9267 var _b = _a, { store, alwaysVisible } = _b, props = __objRest(_b, ["store", "alwaysVisible"]); 9268 const scopedContext = useComboboxScopedContext(true); 9269 const context = useComboboxContext(); 9270 store = store || context; 9271 const scopedContextSameStore = !!store && store === scopedContext; 9272 invariant( 9273 store, 9274 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component." 9275 ); 9276 const ref = (0, import_react19.useRef)(null); 9277 const id = useId3(props.id); 9278 const mounted = store.useState("mounted"); 9279 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 9280 const style = hidden ? __spreadProps(__spreadValues({}, props.style), { display: "none" }) : props.style; 9281 const multiSelectable = store.useState( 9282 (state) => Array.isArray(state.selectedValue) 9283 ); 9284 const role = useAttribute(ref, "role", props.role); 9285 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid"; 9286 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0; 9287 const [hasListboxInside, setHasListboxInside] = (0, import_react19.useState)(false); 9288 const contentElement = store.useState("contentElement"); 9289 useSafeLayoutEffect(() => { 9290 if (!mounted) return; 9291 const element = ref.current; 9292 if (!element) return; 9293 if (contentElement !== element) return; 9294 const callback = () => { 9295 setHasListboxInside(!!element.querySelector("[role='listbox']")); 9296 }; 9297 const observer = new MutationObserver(callback); 9298 observer.observe(element, { 9299 subtree: true, 9300 childList: true, 9301 attributeFilter: ["role"] 9302 }); 9303 callback(); 9304 return () => observer.disconnect(); 9305 }, [mounted, contentElement]); 9306 if (!hasListboxInside) { 9307 props = __spreadValues({ 9308 role: "listbox", 9309 "aria-multiselectable": ariaMultiSelectable 9310 }, props); 9311 } 9312 props = useWrapElement( 9313 props, 9314 (element) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }), 9315 [store, role] 9316 ); 9317 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null; 9318 props = __spreadProps(__spreadValues({ 9319 id, 9320 hidden 9321 }, props), { 9322 ref: useMergeRefs(setContentElement, ref, props.ref), 9323 style 9324 }); 9325 return removeUndefinedValues(props); 9326 } 9327 ); 9328 var ComboboxList = forwardRef22(function ComboboxList2(props) { 9329 const htmlProps = useComboboxList(props); 9330 return createElement2(TagName13, htmlProps); 9331 }); 9332 9333 // packages/dataviews/build-module/components/dataviews-filters/search-widget.js 9334 var import_remove_accents = __toESM(require_remove_accents()); 9335 var import_compose7 = __toESM(require_compose()); 9336 var import_i18n21 = __toESM(require_i18n()); 9337 var import_element24 = __toESM(require_element()); 9338 var import_components23 = __toESM(require_components()); 9339 9340 // packages/dataviews/build-module/components/dataviews-filters/utils.js 9341 var EMPTY_ARRAY2 = []; 9342 var getCurrentValue = (filterDefinition, currentFilter) => { 9343 if (filterDefinition.singleSelection) { 9344 return currentFilter?.value; 9345 } 9346 if (Array.isArray(currentFilter?.value)) { 9347 return currentFilter.value; 9348 } 9349 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) { 9350 return [currentFilter.value]; 9351 } 9352 return EMPTY_ARRAY2; 9353 }; 9354 9355 // packages/dataviews/build-module/hooks/use-elements.js 9356 var import_element23 = __toESM(require_element()); 9357 var EMPTY_ARRAY3 = []; 9358 function useElements({ 9359 elements, 9360 getElements 9361 }) { 9362 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY3; 9363 const [records, setRecords] = (0, import_element23.useState)(staticElements); 9364 const [isLoading, setIsLoading] = (0, import_element23.useState)(false); 9365 (0, import_element23.useEffect)(() => { 9366 if (!getElements) { 9367 setRecords(staticElements); 9368 return; 9369 } 9370 let cancelled = false; 9371 setIsLoading(true); 9372 getElements().then((fetchedElements) => { 9373 if (!cancelled) { 9374 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements; 9375 setRecords(dynamicElements); 9376 } 9377 }).catch(() => { 9378 if (!cancelled) { 9379 setRecords(staticElements); 9380 } 9381 }).finally(() => { 9382 if (!cancelled) { 9383 setIsLoading(false); 9384 } 9385 }); 9386 return () => { 9387 cancelled = true; 9388 }; 9389 }, [getElements, staticElements]); 9390 return { 9391 elements: records, 9392 isLoading 9393 }; 9394 } 9395 9396 // packages/dataviews/build-module/components/dataviews-filters/search-widget.js 9397 var import_jsx_runtime58 = __toESM(require_jsx_runtime()); 9398 function normalizeSearchInput(input = "") { 9399 return (0, import_remove_accents.default)(input.trim().toLowerCase()); 9400 } 9401 var getNewValue = (filterDefinition, currentFilter, value) => { 9402 if (filterDefinition.singleSelection) { 9403 return value; 9404 } 9405 if (Array.isArray(currentFilter?.value)) { 9406 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value]; 9407 } 9408 return [value]; 9409 }; 9410 function generateFilterElementCompositeItemId(prefix, filterElementValue) { 9411 return `$prefix}-$filterElementValue}`; 9412 } 9413 var MultiSelectionOption = ({ selected }) => { 9414 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 9415 "span", 9416 { 9417 className: clsx_default( 9418 "dataviews-filters__search-widget-listitem-multi-selection", 9419 { "is-selected": selected } 9420 ), 9421 children: selected && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components23.Icon, { icon: check_default }) 9422 } 9423 ); 9424 }; 9425 var SingleSelectionOption = ({ selected }) => { 9426 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 9427 "span", 9428 { 9429 className: clsx_default( 9430 "dataviews-filters__search-widget-listitem-single-selection", 9431 { "is-selected": selected } 9432 ) 9433 } 9434 ); 9435 }; 9436 function ListBox({ view, filter, onChangeView }) { 9437 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box"); 9438 const [activeCompositeId, setActiveCompositeId] = (0, import_element24.useState)( 9439 // When there are one or less operators, the first item is set as active 9440 // (by setting the initial `activeId` to `undefined`). 9441 // With 2 or more operators, the focus is moved on the operators control 9442 // (by setting the initial `activeId` to `null`), meaning that there won't 9443 // be an active item initially. Focus is then managed via the 9444 // `onFocusVisible` callback. 9445 filter.operators?.length === 1 ? void 0 : null 9446 ); 9447 const currentFilter = view.filters?.find( 9448 (f2) => f2.field === filter.field 9449 ); 9450 const currentValue = getCurrentValue(filter, currentFilter); 9451 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 9452 import_components23.Composite, 9453 { 9454 virtualFocus: true, 9455 focusLoop: true, 9456 activeId: activeCompositeId, 9457 setActiveId: setActiveCompositeId, 9458 role: "listbox", 9459 className: "dataviews-filters__search-widget-listbox", 9460 "aria-label": (0, import_i18n21.sprintf)( 9461 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */ 9462 (0, import_i18n21.__)("List of: %1$s"), 9463 filter.name 9464 ), 9465 onFocusVisible: () => { 9466 if (!activeCompositeId && filter.elements.length) { 9467 setActiveCompositeId( 9468 generateFilterElementCompositeItemId( 9469 baseId, 9470 filter.elements[0].value 9471 ) 9472 ); 9473 } 9474 }, 9475 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components23.Composite.Typeahead, {}), 9476 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)( 9477 import_components23.Composite.Hover, 9478 { 9479 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 9480 import_components23.Composite.Item, 9481 { 9482 id: generateFilterElementCompositeItemId( 9483 baseId, 9484 element.value 9485 ), 9486 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 9487 "div", 9488 { 9489 "aria-label": element.label, 9490 role: "option", 9491 className: "dataviews-filters__search-widget-listitem" 9492 } 9493 ), 9494 onClick: () => { 9495 const newFilters = currentFilter ? [ 9496 ...(view.filters ?? []).map( 9497 (_filter) => { 9498 if (_filter.field === filter.field) { 9499 return { 9500 ..._filter, 9501 operator: currentFilter.operator || filter.operators[0], 9502 value: getNewValue( 9503 filter, 9504 currentFilter, 9505 element.value 9506 ) 9507 }; 9508 } 9509 return _filter; 9510 } 9511 ) 9512 ] : [ 9513 ...view.filters ?? [], 9514 { 9515 field: filter.field, 9516 operator: filter.operators[0], 9517 value: getNewValue( 9518 filter, 9519 currentFilter, 9520 element.value 9521 ) 9522 } 9523 ]; 9524 onChangeView({ 9525 ...view, 9526 page: 1, 9527 filters: newFilters 9528 }); 9529 } 9530 } 9531 ), 9532 children: [ 9533 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 9534 SingleSelectionOption, 9535 { 9536 selected: currentValue === element.value 9537 } 9538 ), 9539 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 9540 MultiSelectionOption, 9541 { 9542 selected: currentValue.includes(element.value) 9543 } 9544 ), 9545 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { children: element.label }) 9546 ] 9547 }, 9548 element.value 9549 )) 9550 } 9551 ); 9552 } 9553 function ComboboxList22({ view, filter, onChangeView }) { 9554 const [searchValue, setSearchValue] = (0, import_element24.useState)(""); 9555 const deferredSearchValue = (0, import_element24.useDeferredValue)(searchValue); 9556 const currentFilter = view.filters?.find( 9557 (_filter) => _filter.field === filter.field 9558 ); 9559 const currentValue = getCurrentValue(filter, currentFilter); 9560 const matches = (0, import_element24.useMemo)(() => { 9561 const normalizedSearch = normalizeSearchInput(deferredSearchValue); 9562 return filter.elements.filter( 9563 (item) => normalizeSearchInput(item.label).includes(normalizedSearch) 9564 ); 9565 }, [filter.elements, deferredSearchValue]); 9566 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)( 9567 ComboboxProvider, 9568 { 9569 selectedValue: currentValue, 9570 setSelectedValue: (value) => { 9571 const newFilters = currentFilter ? [ 9572 ...(view.filters ?? []).map((_filter) => { 9573 if (_filter.field === filter.field) { 9574 return { 9575 ..._filter, 9576 operator: currentFilter.operator || filter.operators[0], 9577 value 9578 }; 9579 } 9580 return _filter; 9581 }) 9582 ] : [ 9583 ...view.filters ?? [], 9584 { 9585 field: filter.field, 9586 operator: filter.operators[0], 9587 value 9588 } 9589 ]; 9590 onChangeView({ 9591 ...view, 9592 page: 1, 9593 filters: newFilters 9594 }); 9595 }, 9596 setValue: setSearchValue, 9597 children: [ 9598 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [ 9599 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 9600 ComboboxLabel, 9601 { 9602 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components23.VisuallyHidden, { children: (0, import_i18n21.__)("Search items") }), 9603 children: (0, import_i18n21.__)("Search items") 9604 } 9605 ), 9606 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 9607 Combobox, 9608 { 9609 autoSelect: "always", 9610 placeholder: (0, import_i18n21.__)("Search"), 9611 className: "dataviews-filters__search-widget-filter-combobox__input" 9612 } 9613 ), 9614 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components23.Icon, { icon: search_default }) }) 9615 ] }), 9616 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)( 9617 ComboboxList, 9618 { 9619 className: "dataviews-filters__search-widget-filter-combobox-list", 9620 alwaysVisible: true, 9621 children: [ 9622 matches.map((element) => { 9623 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)( 9624 ComboboxItem, 9625 { 9626 resetValueOnSelect: false, 9627 value: element.value, 9628 className: "dataviews-filters__search-widget-listitem", 9629 hideOnClick: false, 9630 setValueOnClick: false, 9631 focusOnHover: true, 9632 children: [ 9633 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 9634 SingleSelectionOption, 9635 { 9636 selected: currentValue === element.value 9637 } 9638 ), 9639 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 9640 MultiSelectionOption, 9641 { 9642 selected: currentValue.includes( 9643 element.value 9644 ) 9645 } 9646 ), 9647 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("span", { children: [ 9648 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 9649 ComboboxItemValue, 9650 { 9651 className: "dataviews-filters__search-widget-filter-combobox-item-value", 9652 value: element.label 9653 } 9654 ), 9655 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description }) 9656 ] }) 9657 ] 9658 }, 9659 element.value 9660 ); 9661 }), 9662 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { children: (0, import_i18n21.__)("No results found") }) 9663 ] 9664 } 9665 ) 9666 ] 9667 } 9668 ); 9669 } 9670 function SearchWidget(props) { 9671 const { elements, isLoading } = useElements({ 9672 elements: props.filter.elements, 9673 getElements: props.filter.getElements 9674 }); 9675 if (isLoading) { 9676 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components23.Spinner, {}) }); 9677 } 9678 if (elements.length === 0) { 9679 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n21.__)("No elements found") }); 9680 } 9681 const Widget = elements.length > 10 ? ComboboxList22 : ListBox; 9682 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Widget, { ...props, filter: { ...props.filter, elements } }); 9683 } 9684 9685 // packages/dataviews/build-module/components/dataviews-filters/input-widget.js 9686 var import_es6 = __toESM(require_es6()); 9687 var import_compose8 = __toESM(require_compose()); 9688 var import_element25 = __toESM(require_element()); 9689 var import_components24 = __toESM(require_components()); 9690 var import_jsx_runtime59 = __toESM(require_jsx_runtime()); 9691 function InputWidget({ 9692 filter, 9693 view, 9694 onChangeView, 9695 fields 9696 }) { 9697 const currentFilter = view.filters?.find( 9698 (f2) => f2.field === filter.field 9699 ); 9700 const currentValue = getCurrentValue(filter, currentFilter); 9701 const field = (0, import_element25.useMemo)(() => { 9702 const currentField = fields.find((f2) => f2.id === filter.field); 9703 if (currentField) { 9704 return { 9705 ...currentField, 9706 // Deactivate validation for filters. 9707 isValid: {}, 9708 // Configure getValue/setValue as if Item was a plain object. 9709 getValue: ({ item }) => item[currentField.id], 9710 setValue: ({ value }) => ({ 9711 [currentField.id]: value 9712 }) 9713 }; 9714 } 9715 return currentField; 9716 }, [fields, filter.field]); 9717 const data = (0, import_element25.useMemo)(() => { 9718 return (view.filters ?? []).reduce( 9719 (acc, activeFilter) => { 9720 acc[activeFilter.field] = activeFilter.value; 9721 return acc; 9722 }, 9723 {} 9724 ); 9725 }, [view.filters]); 9726 const handleChange = (0, import_compose8.useEvent)((updatedData) => { 9727 if (!field || !currentFilter) { 9728 return; 9729 } 9730 const nextValue = field.getValue({ item: updatedData }); 9731 if ((0, import_es6.default)(nextValue, currentValue)) { 9732 return; 9733 } 9734 onChangeView({ 9735 ...view, 9736 filters: (view.filters ?? []).map( 9737 (_filter) => _filter.field === filter.field ? { 9738 ..._filter, 9739 operator: currentFilter.operator || filter.operators[0], 9740 // Consider empty strings as undefined: 9741 // 9742 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records 9743 // - empty string as value means "search empty string": returns only the records that have an empty string as value 9744 // 9745 // In practice, this means the filter will not be able to find an empty string as the value. 9746 value: nextValue === "" ? void 0 : nextValue 9747 } : _filter 9748 ) 9749 }); 9750 }); 9751 if (!field || !field.Edit || !currentFilter) { 9752 return null; 9753 } 9754 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9755 import_components24.Flex, 9756 { 9757 className: "dataviews-filters__user-input-widget", 9758 gap: 2.5, 9759 direction: "column", 9760 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9761 field.Edit, 9762 { 9763 hideLabelFromVision: true, 9764 data, 9765 field, 9766 operator: currentFilter.operator, 9767 onChange: handleChange 9768 } 9769 ) 9770 } 9771 ); 9772 } 9773 9774 // packages/dataviews/build-module/utils/operators.js 9775 var import_i18n22 = __toESM(require_i18n()); 9776 var import_element26 = __toESM(require_element()); 9777 var import_jsx_runtime60 = __toESM(require_jsx_runtime()); 9778 var filterTextWrappers = { 9779 Name: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }), 9780 Value: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" }) 9781 }; 9782 var OPERATORS = [ 9783 { 9784 name: OPERATOR_IS_ANY, 9785 /* translators: DataViews operator name */ 9786 label: (0, import_i18n22.__)("Includes"), 9787 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9788 (0, import_i18n22.sprintf)( 9789 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */ 9790 (0, import_i18n22.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"), 9791 filter.name, 9792 activeElements.map((element) => element.label).join(", ") 9793 ), 9794 filterTextWrappers 9795 ), 9796 selection: "multi" 9797 }, 9798 { 9799 name: OPERATOR_IS_NONE, 9800 /* translators: DataViews operator name */ 9801 label: (0, import_i18n22.__)("Is none of"), 9802 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9803 (0, import_i18n22.sprintf)( 9804 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 9805 (0, import_i18n22.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 9806 filter.name, 9807 activeElements.map((element) => element.label).join(", ") 9808 ), 9809 filterTextWrappers 9810 ), 9811 selection: "multi" 9812 }, 9813 { 9814 name: OPERATOR_IS_ALL, 9815 /* translators: DataViews operator name */ 9816 label: (0, import_i18n22.__)("Includes all"), 9817 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9818 (0, import_i18n22.sprintf)( 9819 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */ 9820 (0, import_i18n22.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"), 9821 filter.name, 9822 activeElements.map((element) => element.label).join(", ") 9823 ), 9824 filterTextWrappers 9825 ), 9826 selection: "multi" 9827 }, 9828 { 9829 name: OPERATOR_IS_NOT_ALL, 9830 /* translators: DataViews operator name */ 9831 label: (0, import_i18n22.__)("Is none of"), 9832 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9833 (0, import_i18n22.sprintf)( 9834 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 9835 (0, import_i18n22.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 9836 filter.name, 9837 activeElements.map((element) => element.label).join(", ") 9838 ), 9839 filterTextWrappers 9840 ), 9841 selection: "multi" 9842 }, 9843 { 9844 name: OPERATOR_BETWEEN, 9845 /* translators: DataViews operator name */ 9846 label: (0, import_i18n22.__)("Between (inc)"), 9847 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9848 (0, import_i18n22.sprintf)( 9849 /* translators: 1: Filter name (e.g. "Item count"). 2: Filter value min. 3: Filter value max. e.g.: "Item count between (inc): 10 and 180". */ 9850 (0, import_i18n22.__)( 9851 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>" 9852 ), 9853 filter.name, 9854 activeElements[0].label[0], 9855 activeElements[0].label[1] 9856 ), 9857 filterTextWrappers 9858 ), 9859 selection: "custom" 9860 }, 9861 { 9862 name: OPERATOR_IN_THE_PAST, 9863 /* translators: DataViews operator name */ 9864 label: (0, import_i18n22.__)("In the past"), 9865 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9866 (0, import_i18n22.sprintf)( 9867 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */ 9868 (0, import_i18n22.__)( 9869 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>" 9870 ), 9871 filter.name, 9872 `$activeElements[0].value.value} $activeElements[0].value.unit}` 9873 ), 9874 filterTextWrappers 9875 ), 9876 selection: "custom" 9877 }, 9878 { 9879 name: OPERATOR_OVER, 9880 /* translators: DataViews operator name */ 9881 label: (0, import_i18n22.__)("Over"), 9882 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9883 (0, import_i18n22.sprintf)( 9884 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */ 9885 (0, import_i18n22.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"), 9886 filter.name, 9887 `$activeElements[0].value.value} $activeElements[0].value.unit}` 9888 ), 9889 filterTextWrappers 9890 ), 9891 selection: "custom" 9892 }, 9893 { 9894 name: OPERATOR_IS, 9895 /* translators: DataViews operator name */ 9896 label: (0, import_i18n22.__)("Is"), 9897 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9898 (0, import_i18n22.sprintf)( 9899 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */ 9900 (0, import_i18n22.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 9901 filter.name, 9902 activeElements[0].label 9903 ), 9904 filterTextWrappers 9905 ), 9906 selection: "single" 9907 }, 9908 { 9909 name: OPERATOR_IS_NOT, 9910 /* translators: DataViews operator name */ 9911 label: (0, import_i18n22.__)("Is not"), 9912 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9913 (0, import_i18n22.sprintf)( 9914 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */ 9915 (0, import_i18n22.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 9916 filter.name, 9917 activeElements[0].label 9918 ), 9919 filterTextWrappers 9920 ), 9921 selection: "single" 9922 }, 9923 { 9924 name: OPERATOR_LESS_THAN, 9925 /* translators: DataViews operator name */ 9926 label: (0, import_i18n22.__)("Less than"), 9927 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9928 (0, import_i18n22.sprintf)( 9929 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */ 9930 (0, import_i18n22.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"), 9931 filter.name, 9932 activeElements[0].label 9933 ), 9934 filterTextWrappers 9935 ), 9936 selection: "single" 9937 }, 9938 { 9939 name: OPERATOR_GREATER_THAN, 9940 /* translators: DataViews operator name */ 9941 label: (0, import_i18n22.__)("Greater than"), 9942 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9943 (0, import_i18n22.sprintf)( 9944 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */ 9945 (0, import_i18n22.__)( 9946 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>" 9947 ), 9948 filter.name, 9949 activeElements[0].label 9950 ), 9951 filterTextWrappers 9952 ), 9953 selection: "single" 9954 }, 9955 { 9956 name: OPERATOR_LESS_THAN_OR_EQUAL, 9957 /* translators: DataViews operator name */ 9958 label: (0, import_i18n22.__)("Less than or equal"), 9959 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9960 (0, import_i18n22.sprintf)( 9961 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */ 9962 (0, import_i18n22.__)( 9963 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>" 9964 ), 9965 filter.name, 9966 activeElements[0].label 9967 ), 9968 filterTextWrappers 9969 ), 9970 selection: "single" 9971 }, 9972 { 9973 name: OPERATOR_GREATER_THAN_OR_EQUAL, 9974 /* translators: DataViews operator name */ 9975 label: (0, import_i18n22.__)("Greater than or equal"), 9976 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9977 (0, import_i18n22.sprintf)( 9978 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */ 9979 (0, import_i18n22.__)( 9980 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>" 9981 ), 9982 filter.name, 9983 activeElements[0].label 9984 ), 9985 filterTextWrappers 9986 ), 9987 selection: "single" 9988 }, 9989 { 9990 name: OPERATOR_BEFORE, 9991 /* translators: DataViews operator name */ 9992 label: (0, import_i18n22.__)("Before"), 9993 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 9994 (0, import_i18n22.sprintf)( 9995 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */ 9996 (0, import_i18n22.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"), 9997 filter.name, 9998 activeElements[0].label 9999 ), 10000 filterTextWrappers 10001 ), 10002 selection: "single" 10003 }, 10004 { 10005 name: OPERATOR_AFTER, 10006 /* translators: DataViews operator name */ 10007 label: (0, import_i18n22.__)("After"), 10008 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 10009 (0, import_i18n22.sprintf)( 10010 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */ 10011 (0, import_i18n22.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"), 10012 filter.name, 10013 activeElements[0].label 10014 ), 10015 filterTextWrappers 10016 ), 10017 selection: "single" 10018 }, 10019 { 10020 name: OPERATOR_BEFORE_INC, 10021 /* translators: DataViews operator name */ 10022 label: (0, import_i18n22.__)("Before (inc)"), 10023 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 10024 (0, import_i18n22.sprintf)( 10025 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */ 10026 (0, import_i18n22.__)( 10027 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>" 10028 ), 10029 filter.name, 10030 activeElements[0].label 10031 ), 10032 filterTextWrappers 10033 ), 10034 selection: "single" 10035 }, 10036 { 10037 name: OPERATOR_AFTER_INC, 10038 /* translators: DataViews operator name */ 10039 label: (0, import_i18n22.__)("After (inc)"), 10040 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 10041 (0, import_i18n22.sprintf)( 10042 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */ 10043 (0, import_i18n22.__)( 10044 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>" 10045 ), 10046 filter.name, 10047 activeElements[0].label 10048 ), 10049 filterTextWrappers 10050 ), 10051 selection: "single" 10052 }, 10053 { 10054 name: OPERATOR_CONTAINS, 10055 /* translators: DataViews operator name */ 10056 label: (0, import_i18n22.__)("Contains"), 10057 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 10058 (0, import_i18n22.sprintf)( 10059 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */ 10060 (0, import_i18n22.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"), 10061 filter.name, 10062 activeElements[0].label 10063 ), 10064 filterTextWrappers 10065 ), 10066 selection: "single" 10067 }, 10068 { 10069 name: OPERATOR_NOT_CONTAINS, 10070 /* translators: DataViews operator name */ 10071 label: (0, import_i18n22.__)("Doesn't contain"), 10072 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 10073 (0, import_i18n22.sprintf)( 10074 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */ 10075 (0, import_i18n22.__)( 10076 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>" 10077 ), 10078 filter.name, 10079 activeElements[0].label 10080 ), 10081 filterTextWrappers 10082 ), 10083 selection: "single" 10084 }, 10085 { 10086 name: OPERATOR_STARTS_WITH, 10087 /* translators: DataViews operator name */ 10088 label: (0, import_i18n22.__)("Starts with"), 10089 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 10090 (0, import_i18n22.sprintf)( 10091 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */ 10092 (0, import_i18n22.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"), 10093 filter.name, 10094 activeElements[0].label 10095 ), 10096 filterTextWrappers 10097 ), 10098 selection: "single" 10099 }, 10100 { 10101 name: OPERATOR_ON, 10102 /* translators: DataViews operator name */ 10103 label: (0, import_i18n22.__)("On"), 10104 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 10105 (0, import_i18n22.sprintf)( 10106 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */ 10107 (0, import_i18n22.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 10108 filter.name, 10109 activeElements[0].label 10110 ), 10111 filterTextWrappers 10112 ), 10113 selection: "single" 10114 }, 10115 { 10116 name: OPERATOR_NOT_ON, 10117 /* translators: DataViews operator name */ 10118 label: (0, import_i18n22.__)("Not on"), 10119 filterText: (filter, activeElements) => (0, import_element26.createInterpolateElement)( 10120 (0, import_i18n22.sprintf)( 10121 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */ 10122 (0, import_i18n22.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 10123 filter.name, 10124 activeElements[0].label 10125 ), 10126 filterTextWrappers 10127 ), 10128 selection: "single" 10129 } 10130 ]; 10131 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name); 10132 var getAllOperatorNames = () => OPERATORS.map((op) => op.name); 10133 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some( 10134 (op) => op.name === name 10135 ); 10136 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name); 10137 10138 // packages/dataviews/build-module/components/dataviews-filters/filter.js 10139 var import_jsx_runtime61 = __toESM(require_jsx_runtime()); 10140 var ENTER = "Enter"; 10141 var SPACE = " "; 10142 var FilterText = ({ 10143 activeElements, 10144 filterInView, 10145 filter 10146 }) => { 10147 if (activeElements === void 0 || activeElements.length === 0) { 10148 return filter.name; 10149 } 10150 const operator = getOperatorByName(filterInView?.operator); 10151 if (operator !== void 0) { 10152 return operator.filterText(filter, activeElements); 10153 } 10154 return (0, import_i18n23.sprintf)( 10155 /* translators: 1: Filter name e.g.: "Unknown status for Author". */ 10156 (0, import_i18n23.__)("Unknown status for %1$s"), 10157 filter.name 10158 ); 10159 }; 10160 function OperatorSelector({ 10161 filter, 10162 view, 10163 onChangeView 10164 }) { 10165 const operatorOptions = filter.operators?.map((operator) => ({ 10166 value: operator, 10167 label: getOperatorByName(operator)?.label || operator 10168 })); 10169 const currentFilter = view.filters?.find( 10170 (_filter) => _filter.field === filter.field 10171 ); 10172 const value = currentFilter?.operator || filter.operators[0]; 10173 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)( 10174 import_components25.__experimentalHStack, 10175 { 10176 spacing: 2, 10177 justify: "flex-start", 10178 className: "dataviews-filters__summary-operators-container", 10179 children: [ 10180 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_components25.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }), 10181 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 10182 import_components25.SelectControl, 10183 { 10184 className: "dataviews-filters__summary-operators-filter-select", 10185 label: (0, import_i18n23.__)("Conditions"), 10186 value, 10187 options: operatorOptions, 10188 onChange: (newValue) => { 10189 const newOperator = newValue; 10190 const currentOperator = currentFilter?.operator; 10191 const newFilters = currentFilter ? [ 10192 ...(view.filters ?? []).map( 10193 (_filter) => { 10194 if (_filter.field === filter.field) { 10195 const currentOpSelectionModel = getOperatorByName( 10196 currentOperator 10197 )?.selection; 10198 const newOpSelectionModel = getOperatorByName( 10199 newOperator 10200 )?.selection; 10201 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [ 10202 currentOpSelectionModel, 10203 newOpSelectionModel 10204 ].includes("custom"); 10205 return { 10206 ..._filter, 10207 value: shouldResetValue ? void 0 : _filter.value, 10208 operator: newOperator 10209 }; 10210 } 10211 return _filter; 10212 } 10213 ) 10214 ] : [ 10215 ...view.filters ?? [], 10216 { 10217 field: filter.field, 10218 operator: newOperator, 10219 value: void 0 10220 } 10221 ]; 10222 onChangeView({ 10223 ...view, 10224 page: 1, 10225 filters: newFilters 10226 }); 10227 }, 10228 size: "small", 10229 variant: "minimal", 10230 hideLabelFromVision: true 10231 } 10232 ) 10233 ] 10234 } 10235 ); 10236 } 10237 function Filter({ 10238 addFilterRef, 10239 openedFilter, 10240 fields, 10241 ...commonProps 10242 }) { 10243 const toggleRef = (0, import_element27.useRef)(null); 10244 const { filter, view, onChangeView } = commonProps; 10245 const filterInView = view.filters?.find( 10246 (f2) => f2.field === filter.field 10247 ); 10248 let activeElements = []; 10249 const field = (0, import_element27.useMemo)(() => { 10250 const currentField = fields.find((f2) => f2.id === filter.field); 10251 if (currentField) { 10252 return { 10253 ...currentField, 10254 // Configure getValue as if Item was a plain object. 10255 // See related input-widget.tsx 10256 getValue: ({ item }) => item[currentField.id] 10257 }; 10258 } 10259 return currentField; 10260 }, [fields, filter.field]); 10261 const { elements } = useElements({ 10262 elements: filter.elements, 10263 getElements: filter.getElements 10264 }); 10265 if (elements.length > 0) { 10266 activeElements = elements.filter((element) => { 10267 if (filter.singleSelection) { 10268 return element.value === filterInView?.value; 10269 } 10270 return filterInView?.value?.includes(element.value); 10271 }); 10272 } else if (Array.isArray(filterInView?.value)) { 10273 const label = filterInView.value.map((v2) => { 10274 const formattedValue = field?.getValueFormatted({ 10275 item: { [field.id]: v2 }, 10276 field 10277 }); 10278 return formattedValue || String(v2); 10279 }); 10280 activeElements = [ 10281 { 10282 value: filterInView.value, 10283 // @ts-ignore 10284 label 10285 } 10286 ]; 10287 } else if (typeof filterInView?.value === "object") { 10288 activeElements = [ 10289 { value: filterInView.value, label: filterInView.value } 10290 ]; 10291 } else if (filterInView?.value !== void 0) { 10292 const label = field !== void 0 ? field.getValueFormatted({ 10293 item: { [field.id]: filterInView.value }, 10294 field 10295 }) : String(filterInView.value); 10296 activeElements = [ 10297 { 10298 value: filterInView.value, 10299 label 10300 } 10301 ]; 10302 } 10303 const isPrimary = filter.isPrimary; 10304 const isLocked = filterInView?.isLocked; 10305 const hasValues = !isLocked && filterInView?.value !== void 0; 10306 const canResetOrRemove = !isLocked && (!isPrimary || hasValues); 10307 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 10308 import_components25.Dropdown, 10309 { 10310 defaultOpen: openedFilter === filter.field, 10311 contentClassName: "dataviews-filters__summary-popover", 10312 popoverProps: { placement: "bottom-start", role: "dialog" }, 10313 onClose: () => { 10314 toggleRef.current?.focus(); 10315 }, 10316 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [ 10317 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 10318 import_components25.Tooltip, 10319 { 10320 text: (0, import_i18n23.sprintf)( 10321 /* translators: 1: Filter name. */ 10322 (0, import_i18n23.__)("Filter by: %1$s"), 10323 filter.name.toLowerCase() 10324 ), 10325 placement: "top", 10326 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 10327 "div", 10328 { 10329 className: clsx_default( 10330 "dataviews-filters__summary-chip", 10331 { 10332 "has-reset": canResetOrRemove, 10333 "has-values": hasValues, 10334 "is-not-clickable": isLocked 10335 } 10336 ), 10337 role: "button", 10338 tabIndex: isLocked ? -1 : 0, 10339 onClick: () => { 10340 if (!isLocked) { 10341 onToggle(); 10342 } 10343 }, 10344 onKeyDown: (event) => { 10345 if (!isLocked && [ENTER, SPACE].includes(event.key)) { 10346 onToggle(); 10347 event.preventDefault(); 10348 } 10349 }, 10350 "aria-disabled": isLocked, 10351 "aria-pressed": isOpen, 10352 "aria-expanded": isOpen, 10353 ref: toggleRef, 10354 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 10355 FilterText, 10356 { 10357 activeElements, 10358 filterInView, 10359 filter 10360 } 10361 ) 10362 } 10363 ) 10364 } 10365 ), 10366 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 10367 import_components25.Tooltip, 10368 { 10369 text: isPrimary ? (0, import_i18n23.__)("Reset") : (0, import_i18n23.__)("Remove"), 10370 placement: "top", 10371 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 10372 "button", 10373 { 10374 className: clsx_default( 10375 "dataviews-filters__summary-chip-remove", 10376 { "has-values": hasValues } 10377 ), 10378 onClick: () => { 10379 onChangeView({ 10380 ...view, 10381 page: 1, 10382 filters: view.filters?.filter( 10383 (_filter) => _filter.field !== filter.field 10384 ) 10385 }); 10386 if (!isPrimary) { 10387 addFilterRef.current?.focus(); 10388 } else { 10389 toggleRef.current?.focus(); 10390 } 10391 }, 10392 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_components25.Icon, { icon: close_small_default }) 10393 } 10394 ) 10395 } 10396 ) 10397 ] }), 10398 renderContent: () => { 10399 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_components25.__experimentalVStack, { spacing: 0, justify: "flex-start", children: [ 10400 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(OperatorSelector, { ...commonProps }), 10401 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 10402 SearchWidget, 10403 { 10404 ...commonProps, 10405 filter: { 10406 ...commonProps.filter, 10407 elements 10408 } 10409 } 10410 ) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(InputWidget, { ...commonProps, fields }) 10411 ] }); 10412 } 10413 } 10414 ); 10415 } 10416 10417 // packages/dataviews/build-module/components/dataviews-filters/add-filter.js 10418 var import_components26 = __toESM(require_components()); 10419 var import_i18n24 = __toESM(require_i18n()); 10420 var import_element28 = __toESM(require_element()); 10421 var import_jsx_runtime62 = __toESM(require_jsx_runtime()); 10422 var { Menu: Menu4 } = unlock(import_components26.privateApis); 10423 function AddFilterMenu({ 10424 filters, 10425 view, 10426 onChangeView, 10427 setOpenedFilter, 10428 triggerProps 10429 }) { 10430 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 10431 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Menu4, { children: [ 10432 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu4.TriggerButton, { ...triggerProps }), 10433 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => { 10434 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 10435 Menu4.Item, 10436 { 10437 onClick: () => { 10438 setOpenedFilter(filter.field); 10439 onChangeView({ 10440 ...view, 10441 page: 1, 10442 filters: [ 10443 ...view.filters || [], 10444 { 10445 field: filter.field, 10446 value: void 0, 10447 operator: filter.operators[0] 10448 } 10449 ] 10450 }); 10451 }, 10452 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Menu4.ItemLabel, { children: filter.name }) 10453 }, 10454 filter.field 10455 ); 10456 }) }) 10457 ] }); 10458 } 10459 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) { 10460 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) { 10461 return null; 10462 } 10463 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 10464 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 10465 AddFilterMenu, 10466 { 10467 triggerProps: { 10468 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 10469 import_components26.Button, 10470 { 10471 accessibleWhenDisabled: true, 10472 size: "compact", 10473 className: "dataviews-filters-button", 10474 variant: "tertiary", 10475 disabled: !inactiveFilters.length, 10476 ref 10477 } 10478 ), 10479 children: (0, import_i18n24.__)("Add filter") 10480 }, 10481 ...{ filters, view, onChangeView, setOpenedFilter } 10482 } 10483 ); 10484 } 10485 var add_filter_default = (0, import_element28.forwardRef)(AddFilter); 10486 10487 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.js 10488 var import_components27 = __toESM(require_components()); 10489 var import_i18n25 = __toESM(require_i18n()); 10490 var import_jsx_runtime63 = __toESM(require_jsx_runtime()); 10491 function ResetFilter({ 10492 filters, 10493 view, 10494 onChangeView 10495 }) { 10496 const isPrimary = (field) => filters.some( 10497 (_filter) => _filter.field === field && _filter.isPrimary 10498 ); 10499 const isDisabled = !view.search && !view.filters?.some( 10500 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field)) 10501 ); 10502 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)( 10503 import_components27.Button, 10504 { 10505 disabled: isDisabled, 10506 accessibleWhenDisabled: true, 10507 size: "compact", 10508 variant: "tertiary", 10509 className: "dataviews-filters__reset-button", 10510 onClick: () => { 10511 onChangeView({ 10512 ...view, 10513 page: 1, 10514 search: "", 10515 filters: view.filters?.filter((f2) => !!f2.isLocked) || [] 10516 }); 10517 }, 10518 children: (0, import_i18n25.__)("Reset") 10519 } 10520 ); 10521 } 10522 10523 // packages/dataviews/build-module/components/dataviews-filters/use-filters.js 10524 var import_element29 = __toESM(require_element()); 10525 function useFilters(fields, view) { 10526 return (0, import_element29.useMemo)(() => { 10527 const filters = []; 10528 fields.forEach((field) => { 10529 if (field.filterBy === false || !field.hasElements && !field.Edit) { 10530 return; 10531 } 10532 const operators = field.filterBy.operators; 10533 const isPrimary = !!field.filterBy?.isPrimary; 10534 const isLocked = view.filters?.some( 10535 (f2) => f2.field === field.id && !!f2.isLocked 10536 ) ?? false; 10537 filters.push({ 10538 field: field.id, 10539 name: field.label, 10540 elements: field.elements, 10541 getElements: field.getElements, 10542 hasElements: field.hasElements, 10543 singleSelection: operators.some( 10544 (op) => isSingleSelectionOperator(op) 10545 ), 10546 operators, 10547 isVisible: isLocked || isPrimary || !!view.filters?.some( 10548 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator) 10549 ), 10550 isPrimary, 10551 isLocked 10552 }); 10553 }); 10554 filters.sort((a2, b2) => { 10555 if (a2.isLocked && !b2.isLocked) { 10556 return -1; 10557 } 10558 if (!a2.isLocked && b2.isLocked) { 10559 return 1; 10560 } 10561 if (a2.isPrimary && !b2.isPrimary) { 10562 return -1; 10563 } 10564 if (!a2.isPrimary && b2.isPrimary) { 10565 return 1; 10566 } 10567 return a2.name.localeCompare(b2.name); 10568 }); 10569 return filters; 10570 }, [fields, view]); 10571 } 10572 var use_filters_default = useFilters; 10573 10574 // packages/dataviews/build-module/components/dataviews-filters/filters.js 10575 var import_jsx_runtime64 = __toESM(require_jsx_runtime()); 10576 function Filters({ className }) { 10577 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element30.useContext)(dataviews_context_default); 10578 const addFilterRef = (0, import_element30.useRef)(null); 10579 const filters = use_filters_default(fields, view); 10580 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 10581 add_filter_default, 10582 { 10583 filters, 10584 view, 10585 onChangeView, 10586 ref: addFilterRef, 10587 setOpenedFilter 10588 }, 10589 "add-filter" 10590 ); 10591 const visibleFilters = filters.filter((filter) => filter.isVisible); 10592 if (visibleFilters.length === 0) { 10593 return null; 10594 } 10595 const filterComponents = [ 10596 ...visibleFilters.map((filter) => { 10597 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 10598 Filter, 10599 { 10600 filter, 10601 view, 10602 fields, 10603 onChangeView, 10604 addFilterRef, 10605 openedFilter 10606 }, 10607 filter.field 10608 ); 10609 }), 10610 addFilter 10611 ]; 10612 filterComponents.push( 10613 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 10614 ResetFilter, 10615 { 10616 filters, 10617 view, 10618 onChangeView 10619 }, 10620 "reset-filters" 10621 ) 10622 ); 10623 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 10624 import_components28.__experimentalHStack, 10625 { 10626 justify: "flex-start", 10627 style: { width: "fit-content" }, 10628 wrap: true, 10629 className, 10630 children: filterComponents 10631 } 10632 ); 10633 } 10634 var filters_default = (0, import_element30.memo)(Filters); 10635 10636 // packages/dataviews/build-module/components/dataviews-filters/toggle.js 10637 var import_element31 = __toESM(require_element()); 10638 var import_components29 = __toESM(require_components()); 10639 var import_i18n26 = __toESM(require_i18n()); 10640 var import_jsx_runtime65 = __toESM(require_jsx_runtime()); 10641 function FiltersToggle() { 10642 const { 10643 filters, 10644 view, 10645 onChangeView, 10646 setOpenedFilter, 10647 isShowingFilter, 10648 setIsShowingFilter 10649 } = (0, import_element31.useContext)(dataviews_context_default); 10650 const buttonRef = (0, import_element31.useRef)(null); 10651 const onChangeViewWithFilterVisibility = (0, import_element31.useCallback)( 10652 (_view) => { 10653 onChangeView(_view); 10654 setIsShowingFilter(true); 10655 }, 10656 [onChangeView, setIsShowingFilter] 10657 ); 10658 const visibleFilters = filters.filter((filter) => filter.isVisible); 10659 const hasVisibleFilters = !!visibleFilters.length; 10660 if (filters.length === 0) { 10661 return null; 10662 } 10663 const addFilterButtonProps = { 10664 label: (0, import_i18n26.__)("Add filter"), 10665 "aria-expanded": false, 10666 isPressed: false 10667 }; 10668 const toggleFiltersButtonProps = { 10669 label: (0, import_i18n26._x)("Filter", "verb"), 10670 "aria-expanded": isShowingFilter, 10671 isPressed: isShowingFilter, 10672 onClick: () => { 10673 if (!isShowingFilter) { 10674 setOpenedFilter(null); 10675 } 10676 setIsShowingFilter(!isShowingFilter); 10677 } 10678 }; 10679 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 10680 import_components29.Button, 10681 { 10682 ref: buttonRef, 10683 className: "dataviews-filters__visibility-toggle", 10684 size: "compact", 10685 icon: funnel_default, 10686 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps 10687 } 10688 ); 10689 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 10690 AddFilterMenu, 10691 { 10692 filters, 10693 view, 10694 onChangeView: onChangeViewWithFilterVisibility, 10695 setOpenedFilter, 10696 triggerProps: { render: buttonComponent } 10697 } 10698 ) : /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 10699 FilterVisibilityToggle, 10700 { 10701 buttonRef, 10702 filtersCount: view.filters?.length, 10703 children: buttonComponent 10704 } 10705 ) }); 10706 } 10707 function FilterVisibilityToggle({ 10708 buttonRef, 10709 filtersCount, 10710 children 10711 }) { 10712 (0, import_element31.useEffect)( 10713 () => () => { 10714 buttonRef.current?.focus(); 10715 }, 10716 [buttonRef] 10717 ); 10718 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [ 10719 children, 10720 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount }) 10721 ] }); 10722 } 10723 var toggle_default = FiltersToggle; 10724 10725 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.js 10726 var import_element32 = __toESM(require_element()); 10727 var import_jsx_runtime66 = __toESM(require_jsx_runtime()); 10728 function FiltersToggled(props) { 10729 const { isShowingFilter } = (0, import_element32.useContext)(dataviews_context_default); 10730 if (!isShowingFilter) { 10731 return null; 10732 } 10733 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(filters_default, { ...props }); 10734 } 10735 var filters_toggled_default = FiltersToggled; 10736 10737 // packages/dataviews/build-module/components/dataviews-layout/index.js 10738 var import_element33 = __toESM(require_element()); 10739 var import_i18n27 = __toESM(require_i18n()); 10740 var import_jsx_runtime67 = __toESM(require_jsx_runtime()); 10741 function DataViewsLayout({ className }) { 10742 const { 10743 actions = [], 10744 data, 10745 fields, 10746 getItemId: getItemId2, 10747 getItemLevel, 10748 isLoading, 10749 view, 10750 onChangeView, 10751 selection, 10752 onChangeSelection, 10753 setOpenedFilter, 10754 onClickItem, 10755 isItemClickable, 10756 renderItemLink, 10757 defaultLayouts, 10758 empty = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { children: (0, import_i18n27.__)("No results") }) 10759 } = (0, import_element33.useContext)(dataviews_context_default); 10760 const ViewComponent = VIEW_LAYOUTS.find( 10761 (v2) => v2.type === view.type && defaultLayouts[v2.type] 10762 )?.component; 10763 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)( 10764 ViewComponent, 10765 { 10766 className, 10767 actions, 10768 data, 10769 fields, 10770 getItemId: getItemId2, 10771 getItemLevel, 10772 isLoading, 10773 onChangeView, 10774 onChangeSelection, 10775 selection, 10776 setOpenedFilter, 10777 onClickItem, 10778 renderItemLink, 10779 isItemClickable, 10780 view, 10781 empty 10782 } 10783 ); 10784 } 10785 10786 // packages/dataviews/build-module/components/dataviews-footer/index.js 10787 var import_components30 = __toESM(require_components()); 10788 var import_element34 = __toESM(require_element()); 10789 var import_jsx_runtime68 = __toESM(require_jsx_runtime()); 10790 var EMPTY_ARRAY4 = []; 10791 function DataViewsFooter() { 10792 const { 10793 view, 10794 paginationInfo: { totalItems = 0, totalPages }, 10795 data, 10796 actions = EMPTY_ARRAY4 10797 } = (0, import_element34.useContext)(dataviews_context_default); 10798 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type); 10799 if (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions) { 10800 return null; 10801 } 10802 return !!totalItems && /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)( 10803 import_components30.__experimentalHStack, 10804 { 10805 expanded: false, 10806 justify: "end", 10807 className: "dataviews-footer", 10808 children: [ 10809 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(BulkActionsFooter, {}), 10810 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(dataviews_pagination_default, {}) 10811 ] 10812 } 10813 ); 10814 } 10815 10816 // packages/dataviews/build-module/components/dataviews-search/index.js 10817 var import_i18n28 = __toESM(require_i18n()); 10818 var import_element35 = __toESM(require_element()); 10819 var import_components31 = __toESM(require_components()); 10820 var import_compose9 = __toESM(require_compose()); 10821 var import_jsx_runtime69 = __toESM(require_jsx_runtime()); 10822 var DataViewsSearch = (0, import_element35.memo)(function Search({ label }) { 10823 const { view, onChangeView } = (0, import_element35.useContext)(dataviews_context_default); 10824 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)( 10825 view.search 10826 ); 10827 (0, import_element35.useEffect)(() => { 10828 setSearch(view.search ?? ""); 10829 }, [view.search, setSearch]); 10830 const onChangeViewRef = (0, import_element35.useRef)(onChangeView); 10831 const viewRef = (0, import_element35.useRef)(view); 10832 (0, import_element35.useEffect)(() => { 10833 onChangeViewRef.current = onChangeView; 10834 viewRef.current = view; 10835 }, [onChangeView, view]); 10836 (0, import_element35.useEffect)(() => { 10837 if (debouncedSearch !== viewRef.current?.search) { 10838 onChangeViewRef.current({ 10839 ...viewRef.current, 10840 page: 1, 10841 search: debouncedSearch 10842 }); 10843 } 10844 }, [debouncedSearch]); 10845 const searchLabel = label || (0, import_i18n28.__)("Search"); 10846 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)( 10847 import_components31.SearchControl, 10848 { 10849 className: "dataviews-search", 10850 onChange: setSearch, 10851 value: search, 10852 label: searchLabel, 10853 placeholder: searchLabel, 10854 size: "compact" 10855 } 10856 ); 10857 }); 10858 var dataviews_search_default = DataViewsSearch; 10859 10860 // packages/dataviews/build-module/components/dataviews-view-config/index.js 10861 var import_components33 = __toESM(require_components()); 10862 var import_i18n30 = __toESM(require_i18n()); 10863 var import_element37 = __toESM(require_element()); 10864 var import_warning = __toESM(require_warning()); 10865 var import_compose10 = __toESM(require_compose()); 10866 10867 // packages/dataviews/build-module/components/dataviews-view-config/infinite-scroll-toggle.js 10868 var import_components32 = __toESM(require_components()); 10869 var import_i18n29 = __toESM(require_i18n()); 10870 var import_element36 = __toESM(require_element()); 10871 var import_jsx_runtime70 = __toESM(require_jsx_runtime()); 10872 function InfiniteScrollToggle() { 10873 const context = (0, import_element36.useContext)(dataviews_context_default); 10874 const { view, onChangeView } = context; 10875 const infiniteScrollEnabled = view.infiniteScrollEnabled ?? false; 10876 if (!context.hasInfiniteScrollHandler) { 10877 return null; 10878 } 10879 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 10880 import_components32.ToggleControl, 10881 { 10882 label: (0, import_i18n29.__)("Enable infinite scroll"), 10883 help: (0, import_i18n29.__)( 10884 "Automatically load more content as you scroll, instead of showing pagination links." 10885 ), 10886 checked: infiniteScrollEnabled, 10887 onChange: (newValue) => { 10888 onChangeView({ 10889 ...view, 10890 infiniteScrollEnabled: newValue 10891 }); 10892 } 10893 } 10894 ); 10895 } 10896 10897 // packages/dataviews/build-module/components/dataviews-view-config/index.js 10898 var import_jsx_runtime71 = __toESM(require_jsx_runtime()); 10899 var { Menu: Menu5 } = unlock(import_components33.privateApis); 10900 var DATAVIEWS_CONFIG_POPOVER_PROPS = { 10901 className: "dataviews-config__popover", 10902 placement: "bottom-end", 10903 offset: 9 10904 }; 10905 function ViewTypeMenu() { 10906 const { view, onChangeView, defaultLayouts } = (0, import_element37.useContext)(dataviews_context_default); 10907 const availableLayouts = Object.keys(defaultLayouts); 10908 if (availableLayouts.length <= 1) { 10909 return null; 10910 } 10911 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type); 10912 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Menu5, { children: [ 10913 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 10914 Menu5.TriggerButton, 10915 { 10916 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 10917 import_components33.Button, 10918 { 10919 size: "compact", 10920 icon: activeView?.icon, 10921 label: (0, import_i18n30.__)("Layout") 10922 } 10923 ) 10924 } 10925 ), 10926 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => { 10927 const config = VIEW_LAYOUTS.find( 10928 (v2) => v2.type === layout 10929 ); 10930 if (!config) { 10931 return null; 10932 } 10933 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 10934 Menu5.RadioItem, 10935 { 10936 value: layout, 10937 name: "view-actions-available-view", 10938 checked: layout === view.type, 10939 hideOnClick: true, 10940 onChange: (e2) => { 10941 switch (e2.target.value) { 10942 case "list": 10943 case "grid": 10944 case "table": 10945 case "pickerGrid": 10946 case "pickerTable": 10947 case "activity": 10948 const viewWithoutLayout = { ...view }; 10949 if ("layout" in viewWithoutLayout) { 10950 delete viewWithoutLayout.layout; 10951 } 10952 return onChangeView({ 10953 ...viewWithoutLayout, 10954 type: e2.target.value, 10955 ...defaultLayouts[e2.target.value] 10956 }); 10957 } 10958 (0, import_warning.default)("Invalid dataview"); 10959 }, 10960 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Menu5.ItemLabel, { children: config.label }) 10961 }, 10962 layout 10963 ); 10964 }) }) 10965 ] }); 10966 } 10967 function SortFieldControl() { 10968 const { view, fields, onChangeView } = (0, import_element37.useContext)(dataviews_context_default); 10969 const orderOptions = (0, import_element37.useMemo)(() => { 10970 const sortableFields = fields.filter( 10971 (field) => field.enableSorting !== false 10972 ); 10973 return sortableFields.map((field) => { 10974 return { 10975 label: field.label, 10976 value: field.id 10977 }; 10978 }); 10979 }, [fields]); 10980 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 10981 import_components33.SelectControl, 10982 { 10983 __next40pxDefaultSize: true, 10984 label: (0, import_i18n30.__)("Sort by"), 10985 value: view.sort?.field, 10986 options: orderOptions, 10987 onChange: (value) => { 10988 onChangeView({ 10989 ...view, 10990 sort: { 10991 direction: view?.sort?.direction || "desc", 10992 field: value 10993 }, 10994 showLevels: false 10995 }); 10996 } 10997 } 10998 ); 10999 } 11000 function SortDirectionControl() { 11001 const { view, fields, onChangeView } = (0, import_element37.useContext)(dataviews_context_default); 11002 const sortableFields = fields.filter( 11003 (field) => field.enableSorting !== false 11004 ); 11005 if (sortableFields.length === 0) { 11006 return null; 11007 } 11008 let value = view.sort?.direction; 11009 if (!value && view.sort?.field) { 11010 value = "desc"; 11011 } 11012 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 11013 import_components33.__experimentalToggleGroupControl, 11014 { 11015 className: "dataviews-view-config__sort-direction", 11016 __next40pxDefaultSize: true, 11017 isBlock: true, 11018 label: (0, import_i18n30.__)("Order"), 11019 value, 11020 onChange: (newDirection) => { 11021 if (newDirection === "asc" || newDirection === "desc") { 11022 onChangeView({ 11023 ...view, 11024 sort: { 11025 direction: newDirection, 11026 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field. 11027 fields.find( 11028 (field) => field.enableSorting !== false 11029 )?.id || "" 11030 }, 11031 showLevels: false 11032 }); 11033 return; 11034 } 11035 (0, import_warning.default)("Invalid direction"); 11036 }, 11037 children: SORTING_DIRECTIONS.map((direction) => { 11038 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 11039 import_components33.__experimentalToggleGroupControlOptionIcon, 11040 { 11041 value: direction, 11042 icon: sortIcons[direction], 11043 label: sortLabels[direction] 11044 }, 11045 direction 11046 ); 11047 }) 11048 } 11049 ); 11050 } 11051 function ItemsPerPageControl() { 11052 const { view, config, onChangeView } = (0, import_element37.useContext)(dataviews_context_default); 11053 const { infiniteScrollEnabled } = view; 11054 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) { 11055 return null; 11056 } 11057 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 11058 import_components33.__experimentalToggleGroupControl, 11059 { 11060 __next40pxDefaultSize: true, 11061 isBlock: true, 11062 label: (0, import_i18n30.__)("Items per page"), 11063 value: view.perPage || 10, 11064 disabled: !view?.sort?.field, 11065 onChange: (newItemsPerPage) => { 11066 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10); 11067 onChangeView({ 11068 ...view, 11069 perPage: newItemsPerPageNumber, 11070 page: 1 11071 }); 11072 }, 11073 children: config.perPageSizes.map((value) => { 11074 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 11075 import_components33.__experimentalToggleGroupControlOption, 11076 { 11077 value, 11078 label: value.toString() 11079 }, 11080 value 11081 ); 11082 }) 11083 } 11084 ); 11085 } 11086 function SettingsSection({ 11087 title, 11088 description, 11089 children 11090 }) { 11091 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_components33.__experimentalGrid, { columns: 12, className: "dataviews-settings-section", gap: 4, children: [ 11092 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "dataviews-settings-section__sidebar", children: [ 11093 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 11094 import_components33.__experimentalHeading, 11095 { 11096 level: 2, 11097 className: "dataviews-settings-section__title", 11098 children: title 11099 } 11100 ), 11101 description && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 11102 import_components33.__experimentalText, 11103 { 11104 variant: "muted", 11105 className: "dataviews-settings-section__description", 11106 children: description 11107 } 11108 ) 11109 ] }), 11110 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 11111 import_components33.__experimentalGrid, 11112 { 11113 columns: 8, 11114 gap: 4, 11115 className: "dataviews-settings-section__content", 11116 children 11117 } 11118 ) 11119 ] }); 11120 } 11121 function DataviewsViewConfigDropdown() { 11122 const { view } = (0, import_element37.useContext)(dataviews_context_default); 11123 const popoverId = (0, import_compose10.useInstanceId)( 11124 _DataViewsViewConfig, 11125 "dataviews-view-config-dropdown" 11126 ); 11127 const activeLayout = VIEW_LAYOUTS.find( 11128 (layout) => layout.type === view.type 11129 ); 11130 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 11131 import_components33.Dropdown, 11132 { 11133 expandOnMobile: true, 11134 popoverProps: { 11135 ...DATAVIEWS_CONFIG_POPOVER_PROPS, 11136 id: popoverId 11137 }, 11138 renderToggle: ({ onToggle, isOpen }) => { 11139 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 11140 import_components33.Button, 11141 { 11142 size: "compact", 11143 icon: cog_default, 11144 label: (0, import_i18n30._x)("View options", "View is used as a noun"), 11145 onClick: onToggle, 11146 "aria-expanded": isOpen ? "true" : "false", 11147 "aria-controls": popoverId 11148 } 11149 ); 11150 }, 11151 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 11152 import_components33.__experimentalDropdownContentWrapper, 11153 { 11154 paddingSize: "medium", 11155 className: "dataviews-config__popover-content-wrapper", 11156 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components33.__experimentalVStack, { className: "dataviews-view-config", spacing: 6, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(SettingsSection, { title: (0, import_i18n30.__)("Appearance"), children: [ 11157 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_components33.__experimentalHStack, { expanded: true, className: "is-divided-in-two", children: [ 11158 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(SortFieldControl, {}), 11159 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(SortDirectionControl, {}) 11160 ] }), 11161 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(activeLayout.viewConfigOptions, {}), 11162 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(InfiniteScrollToggle, {}), 11163 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ItemsPerPageControl, {}), 11164 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(PropertiesSection, {}) 11165 ] }) }) 11166 } 11167 ) 11168 } 11169 ); 11170 } 11171 function _DataViewsViewConfig() { 11172 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [ 11173 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ViewTypeMenu, {}), 11174 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DataviewsViewConfigDropdown, {}) 11175 ] }); 11176 } 11177 var DataViewsViewConfig = (0, import_element37.memo)(_DataViewsViewConfig); 11178 var dataviews_view_config_default = DataViewsViewConfig; 11179 11180 // packages/dataviews/build-module/dataform-controls/checkbox.js 11181 var import_components34 = __toESM(require_components()); 11182 var import_element38 = __toESM(require_element()); 11183 11184 // packages/dataviews/build-module/dataform-controls/utils/get-custom-validity.js 11185 function getCustomValidity(isValid2, validity) { 11186 let customValidity; 11187 if (isValid2?.required && validity?.required) { 11188 customValidity = validity?.required?.message ? validity.required : void 0; 11189 } else if (isValid2?.pattern && validity?.pattern) { 11190 customValidity = validity.pattern; 11191 } else if (isValid2?.min && validity?.min) { 11192 customValidity = validity.min; 11193 } else if (isValid2?.max && validity?.max) { 11194 customValidity = validity.max; 11195 } else if (isValid2?.minLength && validity?.minLength) { 11196 customValidity = validity.minLength; 11197 } else if (isValid2?.maxLength && validity?.maxLength) { 11198 customValidity = validity.maxLength; 11199 } else if (isValid2?.elements && validity?.elements) { 11200 customValidity = validity.elements; 11201 } else if (validity?.custom) { 11202 customValidity = validity.custom; 11203 } 11204 return customValidity; 11205 } 11206 11207 // packages/dataviews/build-module/dataform-controls/checkbox.js 11208 var import_jsx_runtime72 = __toESM(require_jsx_runtime()); 11209 var { ValidatedCheckboxControl } = unlock(import_components34.privateApis); 11210 function Checkbox({ 11211 field, 11212 onChange, 11213 data, 11214 hideLabelFromVision, 11215 validity 11216 }) { 11217 const { getValue, setValue, label, description, isValid: isValid2 } = field; 11218 const onChangeControl = (0, import_element38.useCallback)(() => { 11219 onChange( 11220 setValue({ item: data, value: !getValue({ item: data }) }) 11221 ); 11222 }, [data, getValue, onChange, setValue]); 11223 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 11224 ValidatedCheckboxControl, 11225 { 11226 required: !!field.isValid?.required, 11227 customValidity: getCustomValidity(isValid2, validity), 11228 hidden: hideLabelFromVision, 11229 label, 11230 help: description, 11231 checked: getValue({ item: data }), 11232 onChange: onChangeControl 11233 } 11234 ); 11235 } 11236 11237 // packages/dataviews/node_modules/date-fns/constants.js 11238 var daysInYear = 365.2425; 11239 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3; 11240 var minTime = -maxTime; 11241 var millisecondsInWeek = 6048e5; 11242 var millisecondsInDay = 864e5; 11243 var secondsInHour = 3600; 11244 var secondsInDay = secondsInHour * 24; 11245 var secondsInWeek = secondsInDay * 7; 11246 var secondsInYear = secondsInDay * daysInYear; 11247 var secondsInMonth = secondsInYear / 12; 11248 var secondsInQuarter = secondsInMonth * 3; 11249 var constructFromSymbol = Symbol.for("constructDateFrom"); 11250 11251 // packages/dataviews/node_modules/date-fns/constructFrom.js 11252 function constructFrom(date, value) { 11253 if (typeof date === "function") return date(value); 11254 if (date && typeof date === "object" && constructFromSymbol in date) 11255 return date[constructFromSymbol](value); 11256 if (date instanceof Date) return new date.constructor(value); 11257 return new Date(value); 11258 } 11259 11260 // packages/dataviews/node_modules/date-fns/toDate.js 11261 function toDate(argument, context) { 11262 return constructFrom(context || argument, argument); 11263 } 11264 11265 // packages/dataviews/node_modules/date-fns/addDays.js 11266 function addDays(date, amount, options) { 11267 const _date = toDate(date, options?.in); 11268 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 11269 if (!amount) return _date; 11270 _date.setDate(_date.getDate() + amount); 11271 return _date; 11272 } 11273 11274 // packages/dataviews/node_modules/date-fns/addMonths.js 11275 function addMonths(date, amount, options) { 11276 const _date = toDate(date, options?.in); 11277 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 11278 if (!amount) { 11279 return _date; 11280 } 11281 const dayOfMonth = _date.getDate(); 11282 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime()); 11283 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0); 11284 const daysInMonth = endOfDesiredMonth.getDate(); 11285 if (dayOfMonth >= daysInMonth) { 11286 return endOfDesiredMonth; 11287 } else { 11288 _date.setFullYear( 11289 endOfDesiredMonth.getFullYear(), 11290 endOfDesiredMonth.getMonth(), 11291 dayOfMonth 11292 ); 11293 return _date; 11294 } 11295 } 11296 11297 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js 11298 var defaultOptions = {}; 11299 function getDefaultOptions() { 11300 return defaultOptions; 11301 } 11302 11303 // packages/dataviews/node_modules/date-fns/startOfWeek.js 11304 function startOfWeek(date, options) { 11305 const defaultOptions2 = getDefaultOptions(); 11306 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 11307 const _date = toDate(date, options?.in); 11308 const day = _date.getDay(); 11309 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; 11310 _date.setDate(_date.getDate() - diff); 11311 _date.setHours(0, 0, 0, 0); 11312 return _date; 11313 } 11314 11315 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js 11316 function startOfISOWeek(date, options) { 11317 return startOfWeek(date, { ...options, weekStartsOn: 1 }); 11318 } 11319 11320 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js 11321 function getISOWeekYear(date, options) { 11322 const _date = toDate(date, options?.in); 11323 const year = _date.getFullYear(); 11324 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0); 11325 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); 11326 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); 11327 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); 11328 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0); 11329 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); 11330 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); 11331 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); 11332 if (_date.getTime() >= startOfNextYear.getTime()) { 11333 return year + 1; 11334 } else if (_date.getTime() >= startOfThisYear.getTime()) { 11335 return year; 11336 } else { 11337 return year - 1; 11338 } 11339 } 11340 11341 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js 11342 function getTimezoneOffsetInMilliseconds(date) { 11343 const _date = toDate(date); 11344 const utcDate = new Date( 11345 Date.UTC( 11346 _date.getFullYear(), 11347 _date.getMonth(), 11348 _date.getDate(), 11349 _date.getHours(), 11350 _date.getMinutes(), 11351 _date.getSeconds(), 11352 _date.getMilliseconds() 11353 ) 11354 ); 11355 utcDate.setUTCFullYear(_date.getFullYear()); 11356 return +date - +utcDate; 11357 } 11358 11359 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js 11360 function normalizeDates(context, ...dates) { 11361 const normalize = constructFrom.bind( 11362 null, 11363 context || dates.find((date) => typeof date === "object") 11364 ); 11365 return dates.map(normalize); 11366 } 11367 11368 // packages/dataviews/node_modules/date-fns/startOfDay.js 11369 function startOfDay(date, options) { 11370 const _date = toDate(date, options?.in); 11371 _date.setHours(0, 0, 0, 0); 11372 return _date; 11373 } 11374 11375 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js 11376 function differenceInCalendarDays(laterDate, earlierDate, options) { 11377 const [laterDate_, earlierDate_] = normalizeDates( 11378 options?.in, 11379 laterDate, 11380 earlierDate 11381 ); 11382 const laterStartOfDay = startOfDay(laterDate_); 11383 const earlierStartOfDay = startOfDay(earlierDate_); 11384 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay); 11385 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay); 11386 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay); 11387 } 11388 11389 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js 11390 function startOfISOWeekYear(date, options) { 11391 const year = getISOWeekYear(date, options); 11392 const fourthOfJanuary = constructFrom(options?.in || date, 0); 11393 fourthOfJanuary.setFullYear(year, 0, 4); 11394 fourthOfJanuary.setHours(0, 0, 0, 0); 11395 return startOfISOWeek(fourthOfJanuary); 11396 } 11397 11398 // packages/dataviews/node_modules/date-fns/addYears.js 11399 function addYears(date, amount, options) { 11400 return addMonths(date, amount * 12, options); 11401 } 11402 11403 // packages/dataviews/node_modules/date-fns/isDate.js 11404 function isDate(value) { 11405 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"; 11406 } 11407 11408 // packages/dataviews/node_modules/date-fns/isValid.js 11409 function isValid(date) { 11410 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date))); 11411 } 11412 11413 // packages/dataviews/node_modules/date-fns/startOfMonth.js 11414 function startOfMonth(date, options) { 11415 const _date = toDate(date, options?.in); 11416 _date.setDate(1); 11417 _date.setHours(0, 0, 0, 0); 11418 return _date; 11419 } 11420 11421 // packages/dataviews/node_modules/date-fns/startOfYear.js 11422 function startOfYear(date, options) { 11423 const date_ = toDate(date, options?.in); 11424 date_.setFullYear(date_.getFullYear(), 0, 1); 11425 date_.setHours(0, 0, 0, 0); 11426 return date_; 11427 } 11428 11429 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js 11430 var formatDistanceLocale = { 11431 lessThanXSeconds: { 11432 one: "less than a second", 11433 other: "less than {{count}} seconds" 11434 }, 11435 xSeconds: { 11436 one: "1 second", 11437 other: "{{count}} seconds" 11438 }, 11439 halfAMinute: "half a minute", 11440 lessThanXMinutes: { 11441 one: "less than a minute", 11442 other: "less than {{count}} minutes" 11443 }, 11444 xMinutes: { 11445 one: "1 minute", 11446 other: "{{count}} minutes" 11447 }, 11448 aboutXHours: { 11449 one: "about 1 hour", 11450 other: "about {{count}} hours" 11451 }, 11452 xHours: { 11453 one: "1 hour", 11454 other: "{{count}} hours" 11455 }, 11456 xDays: { 11457 one: "1 day", 11458 other: "{{count}} days" 11459 }, 11460 aboutXWeeks: { 11461 one: "about 1 week", 11462 other: "about {{count}} weeks" 11463 }, 11464 xWeeks: { 11465 one: "1 week", 11466 other: "{{count}} weeks" 11467 }, 11468 aboutXMonths: { 11469 one: "about 1 month", 11470 other: "about {{count}} months" 11471 }, 11472 xMonths: { 11473 one: "1 month", 11474 other: "{{count}} months" 11475 }, 11476 aboutXYears: { 11477 one: "about 1 year", 11478 other: "about {{count}} years" 11479 }, 11480 xYears: { 11481 one: "1 year", 11482 other: "{{count}} years" 11483 }, 11484 overXYears: { 11485 one: "over 1 year", 11486 other: "over {{count}} years" 11487 }, 11488 almostXYears: { 11489 one: "almost 1 year", 11490 other: "almost {{count}} years" 11491 } 11492 }; 11493 var formatDistance = (token, count, options) => { 11494 let result; 11495 const tokenValue = formatDistanceLocale[token]; 11496 if (typeof tokenValue === "string") { 11497 result = tokenValue; 11498 } else if (count === 1) { 11499 result = tokenValue.one; 11500 } else { 11501 result = tokenValue.other.replace("{{count}}", count.toString()); 11502 } 11503 if (options?.addSuffix) { 11504 if (options.comparison && options.comparison > 0) { 11505 return "in " + result; 11506 } else { 11507 return result + " ago"; 11508 } 11509 } 11510 return result; 11511 }; 11512 11513 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js 11514 function buildFormatLongFn(args) { 11515 return (options = {}) => { 11516 const width = options.width ? String(options.width) : args.defaultWidth; 11517 const format6 = args.formats[width] || args.formats[args.defaultWidth]; 11518 return format6; 11519 }; 11520 } 11521 11522 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js 11523 var dateFormats = { 11524 full: "EEEE, MMMM do, y", 11525 long: "MMMM do, y", 11526 medium: "MMM d, y", 11527 short: "MM/dd/yyyy" 11528 }; 11529 var timeFormats = { 11530 full: "h:mm:ss a zzzz", 11531 long: "h:mm:ss a z", 11532 medium: "h:mm:ss a", 11533 short: "h:mm a" 11534 }; 11535 var dateTimeFormats = { 11536 full: "{{date}} 'at' {{time}}", 11537 long: "{{date}} 'at' {{time}}", 11538 medium: "{{date}}, {{time}}", 11539 short: "{{date}}, {{time}}" 11540 }; 11541 var formatLong = { 11542 date: buildFormatLongFn({ 11543 formats: dateFormats, 11544 defaultWidth: "full" 11545 }), 11546 time: buildFormatLongFn({ 11547 formats: timeFormats, 11548 defaultWidth: "full" 11549 }), 11550 dateTime: buildFormatLongFn({ 11551 formats: dateTimeFormats, 11552 defaultWidth: "full" 11553 }) 11554 }; 11555 11556 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js 11557 var formatRelativeLocale = { 11558 lastWeek: "'last' eeee 'at' p", 11559 yesterday: "'yesterday at' p", 11560 today: "'today at' p", 11561 tomorrow: "'tomorrow at' p", 11562 nextWeek: "eeee 'at' p", 11563 other: "P" 11564 }; 11565 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token]; 11566 11567 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js 11568 function buildLocalizeFn(args) { 11569 return (value, options) => { 11570 const context = options?.context ? String(options.context) : "standalone"; 11571 let valuesArray; 11572 if (context === "formatting" && args.formattingValues) { 11573 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth; 11574 const width = options?.width ? String(options.width) : defaultWidth; 11575 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; 11576 } else { 11577 const defaultWidth = args.defaultWidth; 11578 const width = options?.width ? String(options.width) : args.defaultWidth; 11579 valuesArray = args.values[width] || args.values[defaultWidth]; 11580 } 11581 const index = args.argumentCallback ? args.argumentCallback(value) : value; 11582 return valuesArray[index]; 11583 }; 11584 } 11585 11586 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js 11587 var eraValues = { 11588 narrow: ["B", "A"], 11589 abbreviated: ["BC", "AD"], 11590 wide: ["Before Christ", "Anno Domini"] 11591 }; 11592 var quarterValues = { 11593 narrow: ["1", "2", "3", "4"], 11594 abbreviated: ["Q1", "Q2", "Q3", "Q4"], 11595 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] 11596 }; 11597 var monthValues = { 11598 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], 11599 abbreviated: [ 11600 "Jan", 11601 "Feb", 11602 "Mar", 11603 "Apr", 11604 "May", 11605 "Jun", 11606 "Jul", 11607 "Aug", 11608 "Sep", 11609 "Oct", 11610 "Nov", 11611 "Dec" 11612 ], 11613 wide: [ 11614 "January", 11615 "February", 11616 "March", 11617 "April", 11618 "May", 11619 "June", 11620 "July", 11621 "August", 11622 "September", 11623 "October", 11624 "November", 11625 "December" 11626 ] 11627 }; 11628 var dayValues = { 11629 narrow: ["S", "M", "T", "W", "T", "F", "S"], 11630 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 11631 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 11632 wide: [ 11633 "Sunday", 11634 "Monday", 11635 "Tuesday", 11636 "Wednesday", 11637 "Thursday", 11638 "Friday", 11639 "Saturday" 11640 ] 11641 }; 11642 var dayPeriodValues = { 11643 narrow: { 11644 am: "a", 11645 pm: "p", 11646 midnight: "mi", 11647 noon: "n", 11648 morning: "morning", 11649 afternoon: "afternoon", 11650 evening: "evening", 11651 night: "night" 11652 }, 11653 abbreviated: { 11654 am: "AM", 11655 pm: "PM", 11656 midnight: "midnight", 11657 noon: "noon", 11658 morning: "morning", 11659 afternoon: "afternoon", 11660 evening: "evening", 11661 night: "night" 11662 }, 11663 wide: { 11664 am: "a.m.", 11665 pm: "p.m.", 11666 midnight: "midnight", 11667 noon: "noon", 11668 morning: "morning", 11669 afternoon: "afternoon", 11670 evening: "evening", 11671 night: "night" 11672 } 11673 }; 11674 var formattingDayPeriodValues = { 11675 narrow: { 11676 am: "a", 11677 pm: "p", 11678 midnight: "mi", 11679 noon: "n", 11680 morning: "in the morning", 11681 afternoon: "in the afternoon", 11682 evening: "in the evening", 11683 night: "at night" 11684 }, 11685 abbreviated: { 11686 am: "AM", 11687 pm: "PM", 11688 midnight: "midnight", 11689 noon: "noon", 11690 morning: "in the morning", 11691 afternoon: "in the afternoon", 11692 evening: "in the evening", 11693 night: "at night" 11694 }, 11695 wide: { 11696 am: "a.m.", 11697 pm: "p.m.", 11698 midnight: "midnight", 11699 noon: "noon", 11700 morning: "in the morning", 11701 afternoon: "in the afternoon", 11702 evening: "in the evening", 11703 night: "at night" 11704 } 11705 }; 11706 var ordinalNumber = (dirtyNumber, _options) => { 11707 const number = Number(dirtyNumber); 11708 const rem100 = number % 100; 11709 if (rem100 > 20 || rem100 < 10) { 11710 switch (rem100 % 10) { 11711 case 1: 11712 return number + "st"; 11713 case 2: 11714 return number + "nd"; 11715 case 3: 11716 return number + "rd"; 11717 } 11718 } 11719 return number + "th"; 11720 }; 11721 var localize = { 11722 ordinalNumber, 11723 era: buildLocalizeFn({ 11724 values: eraValues, 11725 defaultWidth: "wide" 11726 }), 11727 quarter: buildLocalizeFn({ 11728 values: quarterValues, 11729 defaultWidth: "wide", 11730 argumentCallback: (quarter) => quarter - 1 11731 }), 11732 month: buildLocalizeFn({ 11733 values: monthValues, 11734 defaultWidth: "wide" 11735 }), 11736 day: buildLocalizeFn({ 11737 values: dayValues, 11738 defaultWidth: "wide" 11739 }), 11740 dayPeriod: buildLocalizeFn({ 11741 values: dayPeriodValues, 11742 defaultWidth: "wide", 11743 formattingValues: formattingDayPeriodValues, 11744 defaultFormattingWidth: "wide" 11745 }) 11746 }; 11747 11748 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js 11749 function buildMatchFn(args) { 11750 return (string, options = {}) => { 11751 const width = options.width; 11752 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; 11753 const matchResult = string.match(matchPattern); 11754 if (!matchResult) { 11755 return null; 11756 } 11757 const matchedString = matchResult[0]; 11758 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; 11759 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : ( 11760 // [TODO] -- I challenge you to fix the type 11761 findKey(parsePatterns, (pattern) => pattern.test(matchedString)) 11762 ); 11763 let value; 11764 value = args.valueCallback ? args.valueCallback(key) : key; 11765 value = options.valueCallback ? ( 11766 // [TODO] -- I challenge you to fix the type 11767 options.valueCallback(value) 11768 ) : value; 11769 const rest = string.slice(matchedString.length); 11770 return { value, rest }; 11771 }; 11772 } 11773 function findKey(object, predicate) { 11774 for (const key in object) { 11775 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) { 11776 return key; 11777 } 11778 } 11779 return void 0; 11780 } 11781 function findIndex(array, predicate) { 11782 for (let key = 0; key < array.length; key++) { 11783 if (predicate(array[key])) { 11784 return key; 11785 } 11786 } 11787 return void 0; 11788 } 11789 11790 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js 11791 function buildMatchPatternFn(args) { 11792 return (string, options = {}) => { 11793 const matchResult = string.match(args.matchPattern); 11794 if (!matchResult) return null; 11795 const matchedString = matchResult[0]; 11796 const parseResult = string.match(args.parsePattern); 11797 if (!parseResult) return null; 11798 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; 11799 value = options.valueCallback ? options.valueCallback(value) : value; 11800 const rest = string.slice(matchedString.length); 11801 return { value, rest }; 11802 }; 11803 } 11804 11805 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js 11806 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; 11807 var parseOrdinalNumberPattern = /\d+/i; 11808 var matchEraPatterns = { 11809 narrow: /^(b|a)/i, 11810 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, 11811 wide: /^(before christ|before common era|anno domini|common era)/i 11812 }; 11813 var parseEraPatterns = { 11814 any: [/^b/i, /^(a|c)/i] 11815 }; 11816 var matchQuarterPatterns = { 11817 narrow: /^[1234]/i, 11818 abbreviated: /^q[1234]/i, 11819 wide: /^[1234](th|st|nd|rd)? quarter/i 11820 }; 11821 var parseQuarterPatterns = { 11822 any: [/1/i, /2/i, /3/i, /4/i] 11823 }; 11824 var matchMonthPatterns = { 11825 narrow: /^[jfmasond]/i, 11826 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, 11827 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i 11828 }; 11829 var parseMonthPatterns = { 11830 narrow: [ 11831 /^j/i, 11832 /^f/i, 11833 /^m/i, 11834 /^a/i, 11835 /^m/i, 11836 /^j/i, 11837 /^j/i, 11838 /^a/i, 11839 /^s/i, 11840 /^o/i, 11841 /^n/i, 11842 /^d/i 11843 ], 11844 any: [ 11845 /^ja/i, 11846 /^f/i, 11847 /^mar/i, 11848 /^ap/i, 11849 /^may/i, 11850 /^jun/i, 11851 /^jul/i, 11852 /^au/i, 11853 /^s/i, 11854 /^o/i, 11855 /^n/i, 11856 /^d/i 11857 ] 11858 }; 11859 var matchDayPatterns = { 11860 narrow: /^[smtwf]/i, 11861 short: /^(su|mo|tu|we|th|fr|sa)/i, 11862 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, 11863 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i 11864 }; 11865 var parseDayPatterns = { 11866 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], 11867 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] 11868 }; 11869 var matchDayPeriodPatterns = { 11870 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, 11871 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i 11872 }; 11873 var parseDayPeriodPatterns = { 11874 any: { 11875 am: /^a/i, 11876 pm: /^p/i, 11877 midnight: /^mi/i, 11878 noon: /^no/i, 11879 morning: /morning/i, 11880 afternoon: /afternoon/i, 11881 evening: /evening/i, 11882 night: /night/i 11883 } 11884 }; 11885 var match = { 11886 ordinalNumber: buildMatchPatternFn({ 11887 matchPattern: matchOrdinalNumberPattern, 11888 parsePattern: parseOrdinalNumberPattern, 11889 valueCallback: (value) => parseInt(value, 10) 11890 }), 11891 era: buildMatchFn({ 11892 matchPatterns: matchEraPatterns, 11893 defaultMatchWidth: "wide", 11894 parsePatterns: parseEraPatterns, 11895 defaultParseWidth: "any" 11896 }), 11897 quarter: buildMatchFn({ 11898 matchPatterns: matchQuarterPatterns, 11899 defaultMatchWidth: "wide", 11900 parsePatterns: parseQuarterPatterns, 11901 defaultParseWidth: "any", 11902 valueCallback: (index) => index + 1 11903 }), 11904 month: buildMatchFn({ 11905 matchPatterns: matchMonthPatterns, 11906 defaultMatchWidth: "wide", 11907 parsePatterns: parseMonthPatterns, 11908 defaultParseWidth: "any" 11909 }), 11910 day: buildMatchFn({ 11911 matchPatterns: matchDayPatterns, 11912 defaultMatchWidth: "wide", 11913 parsePatterns: parseDayPatterns, 11914 defaultParseWidth: "any" 11915 }), 11916 dayPeriod: buildMatchFn({ 11917 matchPatterns: matchDayPeriodPatterns, 11918 defaultMatchWidth: "any", 11919 parsePatterns: parseDayPeriodPatterns, 11920 defaultParseWidth: "any" 11921 }) 11922 }; 11923 11924 // packages/dataviews/node_modules/date-fns/locale/en-US.js 11925 var enUS = { 11926 code: "en-US", 11927 formatDistance, 11928 formatLong, 11929 formatRelative, 11930 localize, 11931 match, 11932 options: { 11933 weekStartsOn: 0, 11934 firstWeekContainsDate: 1 11935 } 11936 }; 11937 11938 // packages/dataviews/node_modules/date-fns/getDayOfYear.js 11939 function getDayOfYear(date, options) { 11940 const _date = toDate(date, options?.in); 11941 const diff = differenceInCalendarDays(_date, startOfYear(_date)); 11942 const dayOfYear = diff + 1; 11943 return dayOfYear; 11944 } 11945 11946 // packages/dataviews/node_modules/date-fns/getISOWeek.js 11947 function getISOWeek(date, options) { 11948 const _date = toDate(date, options?.in); 11949 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date); 11950 return Math.round(diff / millisecondsInWeek) + 1; 11951 } 11952 11953 // packages/dataviews/node_modules/date-fns/getWeekYear.js 11954 function getWeekYear(date, options) { 11955 const _date = toDate(date, options?.in); 11956 const year = _date.getFullYear(); 11957 const defaultOptions2 = getDefaultOptions(); 11958 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 11959 const firstWeekOfNextYear = constructFrom(options?.in || date, 0); 11960 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); 11961 firstWeekOfNextYear.setHours(0, 0, 0, 0); 11962 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options); 11963 const firstWeekOfThisYear = constructFrom(options?.in || date, 0); 11964 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); 11965 firstWeekOfThisYear.setHours(0, 0, 0, 0); 11966 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options); 11967 if (+_date >= +startOfNextYear) { 11968 return year + 1; 11969 } else if (+_date >= +startOfThisYear) { 11970 return year; 11971 } else { 11972 return year - 1; 11973 } 11974 } 11975 11976 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js 11977 function startOfWeekYear(date, options) { 11978 const defaultOptions2 = getDefaultOptions(); 11979 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 11980 const year = getWeekYear(date, options); 11981 const firstWeek = constructFrom(options?.in || date, 0); 11982 firstWeek.setFullYear(year, 0, firstWeekContainsDate); 11983 firstWeek.setHours(0, 0, 0, 0); 11984 const _date = startOfWeek(firstWeek, options); 11985 return _date; 11986 } 11987 11988 // packages/dataviews/node_modules/date-fns/getWeek.js 11989 function getWeek(date, options) { 11990 const _date = toDate(date, options?.in); 11991 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options); 11992 return Math.round(diff / millisecondsInWeek) + 1; 11993 } 11994 11995 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js 11996 function addLeadingZeros(number, targetLength) { 11997 const sign = number < 0 ? "-" : ""; 11998 const output = Math.abs(number).toString().padStart(targetLength, "0"); 11999 return sign + output; 12000 } 12001 12002 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js 12003 var lightFormatters = { 12004 // Year 12005 y(date, token) { 12006 const signedYear = date.getFullYear(); 12007 const year = signedYear > 0 ? signedYear : 1 - signedYear; 12008 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length); 12009 }, 12010 // Month 12011 M(date, token) { 12012 const month = date.getMonth(); 12013 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2); 12014 }, 12015 // Day of the month 12016 d(date, token) { 12017 return addLeadingZeros(date.getDate(), token.length); 12018 }, 12019 // AM or PM 12020 a(date, token) { 12021 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am"; 12022 switch (token) { 12023 case "a": 12024 case "aa": 12025 return dayPeriodEnumValue.toUpperCase(); 12026 case "aaa": 12027 return dayPeriodEnumValue; 12028 case "aaaaa": 12029 return dayPeriodEnumValue[0]; 12030 case "aaaa": 12031 default: 12032 return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; 12033 } 12034 }, 12035 // Hour [1-12] 12036 h(date, token) { 12037 return addLeadingZeros(date.getHours() % 12 || 12, token.length); 12038 }, 12039 // Hour [0-23] 12040 H(date, token) { 12041 return addLeadingZeros(date.getHours(), token.length); 12042 }, 12043 // Minute 12044 m(date, token) { 12045 return addLeadingZeros(date.getMinutes(), token.length); 12046 }, 12047 // Second 12048 s(date, token) { 12049 return addLeadingZeros(date.getSeconds(), token.length); 12050 }, 12051 // Fraction of second 12052 S(date, token) { 12053 const numberOfDigits = token.length; 12054 const milliseconds = date.getMilliseconds(); 12055 const fractionalSeconds = Math.trunc( 12056 milliseconds * Math.pow(10, numberOfDigits - 3) 12057 ); 12058 return addLeadingZeros(fractionalSeconds, token.length); 12059 } 12060 }; 12061 12062 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js 12063 var dayPeriodEnum = { 12064 am: "am", 12065 pm: "pm", 12066 midnight: "midnight", 12067 noon: "noon", 12068 morning: "morning", 12069 afternoon: "afternoon", 12070 evening: "evening", 12071 night: "night" 12072 }; 12073 var formatters = { 12074 // Era 12075 G: function(date, token, localize2) { 12076 const era = date.getFullYear() > 0 ? 1 : 0; 12077 switch (token) { 12078 // AD, BC 12079 case "G": 12080 case "GG": 12081 case "GGG": 12082 return localize2.era(era, { width: "abbreviated" }); 12083 // A, B 12084 case "GGGGG": 12085 return localize2.era(era, { width: "narrow" }); 12086 // Anno Domini, Before Christ 12087 case "GGGG": 12088 default: 12089 return localize2.era(era, { width: "wide" }); 12090 } 12091 }, 12092 // Year 12093 y: function(date, token, localize2) { 12094 if (token === "yo") { 12095 const signedYear = date.getFullYear(); 12096 const year = signedYear > 0 ? signedYear : 1 - signedYear; 12097 return localize2.ordinalNumber(year, { unit: "year" }); 12098 } 12099 return lightFormatters.y(date, token); 12100 }, 12101 // Local week-numbering year 12102 Y: function(date, token, localize2, options) { 12103 const signedWeekYear = getWeekYear(date, options); 12104 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; 12105 if (token === "YY") { 12106 const twoDigitYear = weekYear % 100; 12107 return addLeadingZeros(twoDigitYear, 2); 12108 } 12109 if (token === "Yo") { 12110 return localize2.ordinalNumber(weekYear, { unit: "year" }); 12111 } 12112 return addLeadingZeros(weekYear, token.length); 12113 }, 12114 // ISO week-numbering year 12115 R: function(date, token) { 12116 const isoWeekYear = getISOWeekYear(date); 12117 return addLeadingZeros(isoWeekYear, token.length); 12118 }, 12119 // Extended year. This is a single number designating the year of this calendar system. 12120 // The main difference between `y` and `u` localizers are B.C. years: 12121 // | Year | `y` | `u` | 12122 // |------|-----|-----| 12123 // | AC 1 | 1 | 1 | 12124 // | BC 1 | 1 | 0 | 12125 // | BC 2 | 2 | -1 | 12126 // Also `yy` always returns the last two digits of a year, 12127 // while `uu` pads single digit years to 2 characters and returns other years unchanged. 12128 u: function(date, token) { 12129 const year = date.getFullYear(); 12130 return addLeadingZeros(year, token.length); 12131 }, 12132 // Quarter 12133 Q: function(date, token, localize2) { 12134 const quarter = Math.ceil((date.getMonth() + 1) / 3); 12135 switch (token) { 12136 // 1, 2, 3, 4 12137 case "Q": 12138 return String(quarter); 12139 // 01, 02, 03, 04 12140 case "QQ": 12141 return addLeadingZeros(quarter, 2); 12142 // 1st, 2nd, 3rd, 4th 12143 case "Qo": 12144 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 12145 // Q1, Q2, Q3, Q4 12146 case "QQQ": 12147 return localize2.quarter(quarter, { 12148 width: "abbreviated", 12149 context: "formatting" 12150 }); 12151 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 12152 case "QQQQQ": 12153 return localize2.quarter(quarter, { 12154 width: "narrow", 12155 context: "formatting" 12156 }); 12157 // 1st quarter, 2nd quarter, ... 12158 case "QQQQ": 12159 default: 12160 return localize2.quarter(quarter, { 12161 width: "wide", 12162 context: "formatting" 12163 }); 12164 } 12165 }, 12166 // Stand-alone quarter 12167 q: function(date, token, localize2) { 12168 const quarter = Math.ceil((date.getMonth() + 1) / 3); 12169 switch (token) { 12170 // 1, 2, 3, 4 12171 case "q": 12172 return String(quarter); 12173 // 01, 02, 03, 04 12174 case "qq": 12175 return addLeadingZeros(quarter, 2); 12176 // 1st, 2nd, 3rd, 4th 12177 case "qo": 12178 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 12179 // Q1, Q2, Q3, Q4 12180 case "qqq": 12181 return localize2.quarter(quarter, { 12182 width: "abbreviated", 12183 context: "standalone" 12184 }); 12185 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 12186 case "qqqqq": 12187 return localize2.quarter(quarter, { 12188 width: "narrow", 12189 context: "standalone" 12190 }); 12191 // 1st quarter, 2nd quarter, ... 12192 case "qqqq": 12193 default: 12194 return localize2.quarter(quarter, { 12195 width: "wide", 12196 context: "standalone" 12197 }); 12198 } 12199 }, 12200 // Month 12201 M: function(date, token, localize2) { 12202 const month = date.getMonth(); 12203 switch (token) { 12204 case "M": 12205 case "MM": 12206 return lightFormatters.M(date, token); 12207 // 1st, 2nd, ..., 12th 12208 case "Mo": 12209 return localize2.ordinalNumber(month + 1, { unit: "month" }); 12210 // Jan, Feb, ..., Dec 12211 case "MMM": 12212 return localize2.month(month, { 12213 width: "abbreviated", 12214 context: "formatting" 12215 }); 12216 // J, F, ..., D 12217 case "MMMMM": 12218 return localize2.month(month, { 12219 width: "narrow", 12220 context: "formatting" 12221 }); 12222 // January, February, ..., December 12223 case "MMMM": 12224 default: 12225 return localize2.month(month, { width: "wide", context: "formatting" }); 12226 } 12227 }, 12228 // Stand-alone month 12229 L: function(date, token, localize2) { 12230 const month = date.getMonth(); 12231 switch (token) { 12232 // 1, 2, ..., 12 12233 case "L": 12234 return String(month + 1); 12235 // 01, 02, ..., 12 12236 case "LL": 12237 return addLeadingZeros(month + 1, 2); 12238 // 1st, 2nd, ..., 12th 12239 case "Lo": 12240 return localize2.ordinalNumber(month + 1, { unit: "month" }); 12241 // Jan, Feb, ..., Dec 12242 case "LLL": 12243 return localize2.month(month, { 12244 width: "abbreviated", 12245 context: "standalone" 12246 }); 12247 // J, F, ..., D 12248 case "LLLLL": 12249 return localize2.month(month, { 12250 width: "narrow", 12251 context: "standalone" 12252 }); 12253 // January, February, ..., December 12254 case "LLLL": 12255 default: 12256 return localize2.month(month, { width: "wide", context: "standalone" }); 12257 } 12258 }, 12259 // Local week of year 12260 w: function(date, token, localize2, options) { 12261 const week = getWeek(date, options); 12262 if (token === "wo") { 12263 return localize2.ordinalNumber(week, { unit: "week" }); 12264 } 12265 return addLeadingZeros(week, token.length); 12266 }, 12267 // ISO week of year 12268 I: function(date, token, localize2) { 12269 const isoWeek = getISOWeek(date); 12270 if (token === "Io") { 12271 return localize2.ordinalNumber(isoWeek, { unit: "week" }); 12272 } 12273 return addLeadingZeros(isoWeek, token.length); 12274 }, 12275 // Day of the month 12276 d: function(date, token, localize2) { 12277 if (token === "do") { 12278 return localize2.ordinalNumber(date.getDate(), { unit: "date" }); 12279 } 12280 return lightFormatters.d(date, token); 12281 }, 12282 // Day of year 12283 D: function(date, token, localize2) { 12284 const dayOfYear = getDayOfYear(date); 12285 if (token === "Do") { 12286 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" }); 12287 } 12288 return addLeadingZeros(dayOfYear, token.length); 12289 }, 12290 // Day of week 12291 E: function(date, token, localize2) { 12292 const dayOfWeek = date.getDay(); 12293 switch (token) { 12294 // Tue 12295 case "E": 12296 case "EE": 12297 case "EEE": 12298 return localize2.day(dayOfWeek, { 12299 width: "abbreviated", 12300 context: "formatting" 12301 }); 12302 // T 12303 case "EEEEE": 12304 return localize2.day(dayOfWeek, { 12305 width: "narrow", 12306 context: "formatting" 12307 }); 12308 // Tu 12309 case "EEEEEE": 12310 return localize2.day(dayOfWeek, { 12311 width: "short", 12312 context: "formatting" 12313 }); 12314 // Tuesday 12315 case "EEEE": 12316 default: 12317 return localize2.day(dayOfWeek, { 12318 width: "wide", 12319 context: "formatting" 12320 }); 12321 } 12322 }, 12323 // Local day of week 12324 e: function(date, token, localize2, options) { 12325 const dayOfWeek = date.getDay(); 12326 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 12327 switch (token) { 12328 // Numerical value (Nth day of week with current locale or weekStartsOn) 12329 case "e": 12330 return String(localDayOfWeek); 12331 // Padded numerical value 12332 case "ee": 12333 return addLeadingZeros(localDayOfWeek, 2); 12334 // 1st, 2nd, ..., 7th 12335 case "eo": 12336 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 12337 case "eee": 12338 return localize2.day(dayOfWeek, { 12339 width: "abbreviated", 12340 context: "formatting" 12341 }); 12342 // T 12343 case "eeeee": 12344 return localize2.day(dayOfWeek, { 12345 width: "narrow", 12346 context: "formatting" 12347 }); 12348 // Tu 12349 case "eeeeee": 12350 return localize2.day(dayOfWeek, { 12351 width: "short", 12352 context: "formatting" 12353 }); 12354 // Tuesday 12355 case "eeee": 12356 default: 12357 return localize2.day(dayOfWeek, { 12358 width: "wide", 12359 context: "formatting" 12360 }); 12361 } 12362 }, 12363 // Stand-alone local day of week 12364 c: function(date, token, localize2, options) { 12365 const dayOfWeek = date.getDay(); 12366 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 12367 switch (token) { 12368 // Numerical value (same as in `e`) 12369 case "c": 12370 return String(localDayOfWeek); 12371 // Padded numerical value 12372 case "cc": 12373 return addLeadingZeros(localDayOfWeek, token.length); 12374 // 1st, 2nd, ..., 7th 12375 case "co": 12376 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 12377 case "ccc": 12378 return localize2.day(dayOfWeek, { 12379 width: "abbreviated", 12380 context: "standalone" 12381 }); 12382 // T 12383 case "ccccc": 12384 return localize2.day(dayOfWeek, { 12385 width: "narrow", 12386 context: "standalone" 12387 }); 12388 // Tu 12389 case "cccccc": 12390 return localize2.day(dayOfWeek, { 12391 width: "short", 12392 context: "standalone" 12393 }); 12394 // Tuesday 12395 case "cccc": 12396 default: 12397 return localize2.day(dayOfWeek, { 12398 width: "wide", 12399 context: "standalone" 12400 }); 12401 } 12402 }, 12403 // ISO day of week 12404 i: function(date, token, localize2) { 12405 const dayOfWeek = date.getDay(); 12406 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; 12407 switch (token) { 12408 // 2 12409 case "i": 12410 return String(isoDayOfWeek); 12411 // 02 12412 case "ii": 12413 return addLeadingZeros(isoDayOfWeek, token.length); 12414 // 2nd 12415 case "io": 12416 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" }); 12417 // Tue 12418 case "iii": 12419 return localize2.day(dayOfWeek, { 12420 width: "abbreviated", 12421 context: "formatting" 12422 }); 12423 // T 12424 case "iiiii": 12425 return localize2.day(dayOfWeek, { 12426 width: "narrow", 12427 context: "formatting" 12428 }); 12429 // Tu 12430 case "iiiiii": 12431 return localize2.day(dayOfWeek, { 12432 width: "short", 12433 context: "formatting" 12434 }); 12435 // Tuesday 12436 case "iiii": 12437 default: 12438 return localize2.day(dayOfWeek, { 12439 width: "wide", 12440 context: "formatting" 12441 }); 12442 } 12443 }, 12444 // AM or PM 12445 a: function(date, token, localize2) { 12446 const hours = date.getHours(); 12447 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 12448 switch (token) { 12449 case "a": 12450 case "aa": 12451 return localize2.dayPeriod(dayPeriodEnumValue, { 12452 width: "abbreviated", 12453 context: "formatting" 12454 }); 12455 case "aaa": 12456 return localize2.dayPeriod(dayPeriodEnumValue, { 12457 width: "abbreviated", 12458 context: "formatting" 12459 }).toLowerCase(); 12460 case "aaaaa": 12461 return localize2.dayPeriod(dayPeriodEnumValue, { 12462 width: "narrow", 12463 context: "formatting" 12464 }); 12465 case "aaaa": 12466 default: 12467 return localize2.dayPeriod(dayPeriodEnumValue, { 12468 width: "wide", 12469 context: "formatting" 12470 }); 12471 } 12472 }, 12473 // AM, PM, midnight, noon 12474 b: function(date, token, localize2) { 12475 const hours = date.getHours(); 12476 let dayPeriodEnumValue; 12477 if (hours === 12) { 12478 dayPeriodEnumValue = dayPeriodEnum.noon; 12479 } else if (hours === 0) { 12480 dayPeriodEnumValue = dayPeriodEnum.midnight; 12481 } else { 12482 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 12483 } 12484 switch (token) { 12485 case "b": 12486 case "bb": 12487 return localize2.dayPeriod(dayPeriodEnumValue, { 12488 width: "abbreviated", 12489 context: "formatting" 12490 }); 12491 case "bbb": 12492 return localize2.dayPeriod(dayPeriodEnumValue, { 12493 width: "abbreviated", 12494 context: "formatting" 12495 }).toLowerCase(); 12496 case "bbbbb": 12497 return localize2.dayPeriod(dayPeriodEnumValue, { 12498 width: "narrow", 12499 context: "formatting" 12500 }); 12501 case "bbbb": 12502 default: 12503 return localize2.dayPeriod(dayPeriodEnumValue, { 12504 width: "wide", 12505 context: "formatting" 12506 }); 12507 } 12508 }, 12509 // in the morning, in the afternoon, in the evening, at night 12510 B: function(date, token, localize2) { 12511 const hours = date.getHours(); 12512 let dayPeriodEnumValue; 12513 if (hours >= 17) { 12514 dayPeriodEnumValue = dayPeriodEnum.evening; 12515 } else if (hours >= 12) { 12516 dayPeriodEnumValue = dayPeriodEnum.afternoon; 12517 } else if (hours >= 4) { 12518 dayPeriodEnumValue = dayPeriodEnum.morning; 12519 } else { 12520 dayPeriodEnumValue = dayPeriodEnum.night; 12521 } 12522 switch (token) { 12523 case "B": 12524 case "BB": 12525 case "BBB": 12526 return localize2.dayPeriod(dayPeriodEnumValue, { 12527 width: "abbreviated", 12528 context: "formatting" 12529 }); 12530 case "BBBBB": 12531 return localize2.dayPeriod(dayPeriodEnumValue, { 12532 width: "narrow", 12533 context: "formatting" 12534 }); 12535 case "BBBB": 12536 default: 12537 return localize2.dayPeriod(dayPeriodEnumValue, { 12538 width: "wide", 12539 context: "formatting" 12540 }); 12541 } 12542 }, 12543 // Hour [1-12] 12544 h: function(date, token, localize2) { 12545 if (token === "ho") { 12546 let hours = date.getHours() % 12; 12547 if (hours === 0) hours = 12; 12548 return localize2.ordinalNumber(hours, { unit: "hour" }); 12549 } 12550 return lightFormatters.h(date, token); 12551 }, 12552 // Hour [0-23] 12553 H: function(date, token, localize2) { 12554 if (token === "Ho") { 12555 return localize2.ordinalNumber(date.getHours(), { unit: "hour" }); 12556 } 12557 return lightFormatters.H(date, token); 12558 }, 12559 // Hour [0-11] 12560 K: function(date, token, localize2) { 12561 const hours = date.getHours() % 12; 12562 if (token === "Ko") { 12563 return localize2.ordinalNumber(hours, { unit: "hour" }); 12564 } 12565 return addLeadingZeros(hours, token.length); 12566 }, 12567 // Hour [1-24] 12568 k: function(date, token, localize2) { 12569 let hours = date.getHours(); 12570 if (hours === 0) hours = 24; 12571 if (token === "ko") { 12572 return localize2.ordinalNumber(hours, { unit: "hour" }); 12573 } 12574 return addLeadingZeros(hours, token.length); 12575 }, 12576 // Minute 12577 m: function(date, token, localize2) { 12578 if (token === "mo") { 12579 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" }); 12580 } 12581 return lightFormatters.m(date, token); 12582 }, 12583 // Second 12584 s: function(date, token, localize2) { 12585 if (token === "so") { 12586 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" }); 12587 } 12588 return lightFormatters.s(date, token); 12589 }, 12590 // Fraction of second 12591 S: function(date, token) { 12592 return lightFormatters.S(date, token); 12593 }, 12594 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) 12595 X: function(date, token, _localize) { 12596 const timezoneOffset = date.getTimezoneOffset(); 12597 if (timezoneOffset === 0) { 12598 return "Z"; 12599 } 12600 switch (token) { 12601 // Hours and optional minutes 12602 case "X": 12603 return formatTimezoneWithOptionalMinutes(timezoneOffset); 12604 // Hours, minutes and optional seconds without `:` delimiter 12605 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 12606 // so this token always has the same output as `XX` 12607 case "XXXX": 12608 case "XX": 12609 return formatTimezone(timezoneOffset); 12610 // Hours, minutes and optional seconds with `:` delimiter 12611 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 12612 // so this token always has the same output as `XXX` 12613 case "XXXXX": 12614 case "XXX": 12615 // Hours and minutes with `:` delimiter 12616 default: 12617 return formatTimezone(timezoneOffset, ":"); 12618 } 12619 }, 12620 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) 12621 x: function(date, token, _localize) { 12622 const timezoneOffset = date.getTimezoneOffset(); 12623 switch (token) { 12624 // Hours and optional minutes 12625 case "x": 12626 return formatTimezoneWithOptionalMinutes(timezoneOffset); 12627 // Hours, minutes and optional seconds without `:` delimiter 12628 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 12629 // so this token always has the same output as `xx` 12630 case "xxxx": 12631 case "xx": 12632 return formatTimezone(timezoneOffset); 12633 // Hours, minutes and optional seconds with `:` delimiter 12634 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 12635 // so this token always has the same output as `xxx` 12636 case "xxxxx": 12637 case "xxx": 12638 // Hours and minutes with `:` delimiter 12639 default: 12640 return formatTimezone(timezoneOffset, ":"); 12641 } 12642 }, 12643 // Timezone (GMT) 12644 O: function(date, token, _localize) { 12645 const timezoneOffset = date.getTimezoneOffset(); 12646 switch (token) { 12647 // Short 12648 case "O": 12649 case "OO": 12650 case "OOO": 12651 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 12652 // Long 12653 case "OOOO": 12654 default: 12655 return "GMT" + formatTimezone(timezoneOffset, ":"); 12656 } 12657 }, 12658 // Timezone (specific non-location) 12659 z: function(date, token, _localize) { 12660 const timezoneOffset = date.getTimezoneOffset(); 12661 switch (token) { 12662 // Short 12663 case "z": 12664 case "zz": 12665 case "zzz": 12666 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 12667 // Long 12668 case "zzzz": 12669 default: 12670 return "GMT" + formatTimezone(timezoneOffset, ":"); 12671 } 12672 }, 12673 // Seconds timestamp 12674 t: function(date, token, _localize) { 12675 const timestamp = Math.trunc(+date / 1e3); 12676 return addLeadingZeros(timestamp, token.length); 12677 }, 12678 // Milliseconds timestamp 12679 T: function(date, token, _localize) { 12680 return addLeadingZeros(+date, token.length); 12681 } 12682 }; 12683 function formatTimezoneShort(offset, delimiter = "") { 12684 const sign = offset > 0 ? "-" : "+"; 12685 const absOffset = Math.abs(offset); 12686 const hours = Math.trunc(absOffset / 60); 12687 const minutes = absOffset % 60; 12688 if (minutes === 0) { 12689 return sign + String(hours); 12690 } 12691 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2); 12692 } 12693 function formatTimezoneWithOptionalMinutes(offset, delimiter) { 12694 if (offset % 60 === 0) { 12695 const sign = offset > 0 ? "-" : "+"; 12696 return sign + addLeadingZeros(Math.abs(offset) / 60, 2); 12697 } 12698 return formatTimezone(offset, delimiter); 12699 } 12700 function formatTimezone(offset, delimiter = "") { 12701 const sign = offset > 0 ? "-" : "+"; 12702 const absOffset = Math.abs(offset); 12703 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2); 12704 const minutes = addLeadingZeros(absOffset % 60, 2); 12705 return sign + hours + delimiter + minutes; 12706 } 12707 12708 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js 12709 var dateLongFormatter = (pattern, formatLong2) => { 12710 switch (pattern) { 12711 case "P": 12712 return formatLong2.date({ width: "short" }); 12713 case "PP": 12714 return formatLong2.date({ width: "medium" }); 12715 case "PPP": 12716 return formatLong2.date({ width: "long" }); 12717 case "PPPP": 12718 default: 12719 return formatLong2.date({ width: "full" }); 12720 } 12721 }; 12722 var timeLongFormatter = (pattern, formatLong2) => { 12723 switch (pattern) { 12724 case "p": 12725 return formatLong2.time({ width: "short" }); 12726 case "pp": 12727 return formatLong2.time({ width: "medium" }); 12728 case "ppp": 12729 return formatLong2.time({ width: "long" }); 12730 case "pppp": 12731 default: 12732 return formatLong2.time({ width: "full" }); 12733 } 12734 }; 12735 var dateTimeLongFormatter = (pattern, formatLong2) => { 12736 const matchResult = pattern.match(/(P+)(p+)?/) || []; 12737 const datePattern = matchResult[1]; 12738 const timePattern = matchResult[2]; 12739 if (!timePattern) { 12740 return dateLongFormatter(pattern, formatLong2); 12741 } 12742 let dateTimeFormat; 12743 switch (datePattern) { 12744 case "P": 12745 dateTimeFormat = formatLong2.dateTime({ width: "short" }); 12746 break; 12747 case "PP": 12748 dateTimeFormat = formatLong2.dateTime({ width: "medium" }); 12749 break; 12750 case "PPP": 12751 dateTimeFormat = formatLong2.dateTime({ width: "long" }); 12752 break; 12753 case "PPPP": 12754 default: 12755 dateTimeFormat = formatLong2.dateTime({ width: "full" }); 12756 break; 12757 } 12758 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); 12759 }; 12760 var longFormatters = { 12761 p: timeLongFormatter, 12762 P: dateTimeLongFormatter 12763 }; 12764 12765 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js 12766 var dayOfYearTokenRE = /^D+$/; 12767 var weekYearTokenRE = /^Y+$/; 12768 var throwTokens = ["D", "DD", "YY", "YYYY"]; 12769 function isProtectedDayOfYearToken(token) { 12770 return dayOfYearTokenRE.test(token); 12771 } 12772 function isProtectedWeekYearToken(token) { 12773 return weekYearTokenRE.test(token); 12774 } 12775 function warnOrThrowProtectedError(token, format6, input) { 12776 const _message = message(token, format6, input); 12777 console.warn(_message); 12778 if (throwTokens.includes(token)) throw new RangeError(_message); 12779 } 12780 function message(token, format6, input) { 12781 const subject = token[0] === "Y" ? "years" : "days of the month"; 12782 return `Use \`$token.toLowerCase()}\` instead of \`$token}\` (in \`$format6}\`) for formatting $subject} to the input \`$input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`; 12783 } 12784 12785 // packages/dataviews/node_modules/date-fns/format.js 12786 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; 12787 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; 12788 var escapedStringRegExp = /^'([^]*?)'?$/; 12789 var doubleQuoteRegExp = /''/g; 12790 var unescapedLatinCharacterRegExp = /[a-zA-Z]/; 12791 function format(date, formatStr, options) { 12792 const defaultOptions2 = getDefaultOptions(); 12793 const locale = options?.locale ?? defaultOptions2.locale ?? enUS; 12794 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 12795 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 12796 const originalDate = toDate(date, options?.in); 12797 if (!isValid(originalDate)) { 12798 throw new RangeError("Invalid time value"); 12799 } 12800 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => { 12801 const firstCharacter = substring[0]; 12802 if (firstCharacter === "p" || firstCharacter === "P") { 12803 const longFormatter = longFormatters[firstCharacter]; 12804 return longFormatter(substring, locale.formatLong); 12805 } 12806 return substring; 12807 }).join("").match(formattingTokensRegExp).map((substring) => { 12808 if (substring === "''") { 12809 return { isToken: false, value: "'" }; 12810 } 12811 const firstCharacter = substring[0]; 12812 if (firstCharacter === "'") { 12813 return { isToken: false, value: cleanEscapedString(substring) }; 12814 } 12815 if (formatters[firstCharacter]) { 12816 return { isToken: true, value: substring }; 12817 } 12818 if (firstCharacter.match(unescapedLatinCharacterRegExp)) { 12819 throw new RangeError( 12820 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`" 12821 ); 12822 } 12823 return { isToken: false, value: substring }; 12824 }); 12825 if (locale.localize.preprocessor) { 12826 parts = locale.localize.preprocessor(originalDate, parts); 12827 } 12828 const formatterOptions = { 12829 firstWeekContainsDate, 12830 weekStartsOn, 12831 locale 12832 }; 12833 return parts.map((part) => { 12834 if (!part.isToken) return part.value; 12835 const token = part.value; 12836 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) { 12837 warnOrThrowProtectedError(token, formatStr, String(date)); 12838 } 12839 const formatter = formatters[token[0]]; 12840 return formatter(originalDate, token, locale.localize, formatterOptions); 12841 }).join(""); 12842 } 12843 function cleanEscapedString(input) { 12844 const matched = input.match(escapedStringRegExp); 12845 if (!matched) { 12846 return input; 12847 } 12848 return matched[1].replace(doubleQuoteRegExp, "'"); 12849 } 12850 12851 // packages/dataviews/node_modules/date-fns/subDays.js 12852 function subDays(date, amount, options) { 12853 return addDays(date, -amount, options); 12854 } 12855 12856 // packages/dataviews/node_modules/date-fns/subMonths.js 12857 function subMonths(date, amount, options) { 12858 return addMonths(date, -amount, options); 12859 } 12860 12861 // packages/dataviews/node_modules/date-fns/subYears.js 12862 function subYears(date, amount, options) { 12863 return addYears(date, -amount, options); 12864 } 12865 12866 // packages/dataviews/build-module/dataform-controls/datetime.js 12867 var import_components36 = __toESM(require_components()); 12868 var import_element40 = __toESM(require_element()); 12869 var import_i18n32 = __toESM(require_i18n()); 12870 var import_date2 = __toESM(require_date()); 12871 12872 // packages/dataviews/build-module/dataform-controls/utils/relative-date-control.js 12873 var import_components35 = __toESM(require_components()); 12874 var import_element39 = __toESM(require_element()); 12875 var import_i18n31 = __toESM(require_i18n()); 12876 var import_jsx_runtime73 = __toESM(require_jsx_runtime()); 12877 var TIME_UNITS_OPTIONS = { 12878 [OPERATOR_IN_THE_PAST]: [ 12879 { value: "days", label: (0, import_i18n31.__)("Days") }, 12880 { value: "weeks", label: (0, import_i18n31.__)("Weeks") }, 12881 { value: "months", label: (0, import_i18n31.__)("Months") }, 12882 { value: "years", label: (0, import_i18n31.__)("Years") } 12883 ], 12884 [OPERATOR_OVER]: [ 12885 { value: "days", label: (0, import_i18n31.__)("Days ago") }, 12886 { value: "weeks", label: (0, import_i18n31.__)("Weeks ago") }, 12887 { value: "months", label: (0, import_i18n31.__)("Months ago") }, 12888 { value: "years", label: (0, import_i18n31.__)("Years ago") } 12889 ] 12890 }; 12891 function RelativeDateControl({ 12892 className, 12893 data, 12894 field, 12895 onChange, 12896 hideLabelFromVision, 12897 operator 12898 }) { 12899 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"]; 12900 const { id, label, getValue, setValue } = field; 12901 const fieldValue = getValue({ item: data }); 12902 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {}; 12903 const onChangeValue = (0, import_element39.useCallback)( 12904 (newValue) => onChange( 12905 setValue({ 12906 item: data, 12907 value: { value: Number(newValue), unit } 12908 }) 12909 ), 12910 [onChange, setValue, data, unit] 12911 ); 12912 const onChangeUnit = (0, import_element39.useCallback)( 12913 (newUnit) => onChange( 12914 setValue({ 12915 item: data, 12916 value: { value: relValue, unit: newUnit } 12917 }) 12918 ), 12919 [onChange, setValue, data, relValue] 12920 ); 12921 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 12922 import_components35.BaseControl, 12923 { 12924 id, 12925 className: clsx_default(className, "dataviews-controls__relative-date"), 12926 label, 12927 hideLabelFromVision, 12928 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_components35.__experimentalHStack, { spacing: 2.5, children: [ 12929 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 12930 import_components35.__experimentalNumberControl, 12931 { 12932 __next40pxDefaultSize: true, 12933 className: "dataviews-controls__relative-date-number", 12934 spinControls: "none", 12935 min: 1, 12936 step: 1, 12937 value: relValue, 12938 onChange: onChangeValue 12939 } 12940 ), 12941 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 12942 import_components35.SelectControl, 12943 { 12944 className: "dataviews-controls__relative-date-unit", 12945 __next40pxDefaultSize: true, 12946 label: (0, import_i18n31.__)("Unit"), 12947 value: unit, 12948 options, 12949 onChange: onChangeUnit, 12950 hideLabelFromVision: true 12951 } 12952 ) 12953 ] }) 12954 } 12955 ); 12956 } 12957 12958 // packages/dataviews/build-module/field-types/utils/parse-date-time.js 12959 var import_date = __toESM(require_date()); 12960 function parseDateTime(dateTimeString) { 12961 if (!dateTimeString) { 12962 return null; 12963 } 12964 const parsed = (0, import_date.getDate)(dateTimeString); 12965 return parsed && isValid(parsed) ? parsed : null; 12966 } 12967 12968 // packages/dataviews/build-module/dataform-controls/datetime.js 12969 var import_jsx_runtime74 = __toESM(require_jsx_runtime()); 12970 var { DateCalendar, ValidatedInputControl } = unlock(import_components36.privateApis); 12971 var formatDateTime = (date) => { 12972 if (!date) { 12973 return ""; 12974 } 12975 if (typeof date === "string") { 12976 return date; 12977 } 12978 return format(date, "yyyy-MM-dd'T'HH:mm"); 12979 }; 12980 function CalendarDateTimeControl({ 12981 data, 12982 field, 12983 onChange, 12984 hideLabelFromVision, 12985 validity 12986 }) { 12987 const { id, label, description, setValue, getValue, isValid: isValid2 } = field; 12988 const fieldValue = getValue({ item: data }); 12989 const value = typeof fieldValue === "string" ? fieldValue : void 0; 12990 const [calendarMonth, setCalendarMonth] = (0, import_element40.useState)(() => { 12991 const parsedDate = parseDateTime(value); 12992 return parsedDate || /* @__PURE__ */ new Date(); 12993 }); 12994 const inputControlRef = (0, import_element40.useRef)(null); 12995 const validationTimeoutRef = (0, import_element40.useRef)(); 12996 const previousFocusRef = (0, import_element40.useRef)(null); 12997 const onChangeCallback = (0, import_element40.useCallback)( 12998 (newValue) => onChange(setValue({ item: data, value: newValue })), 12999 [data, onChange, setValue] 13000 ); 13001 (0, import_element40.useEffect)(() => { 13002 return () => { 13003 if (validationTimeoutRef.current) { 13004 clearTimeout(validationTimeoutRef.current); 13005 } 13006 }; 13007 }, []); 13008 const onSelectDate = (0, import_element40.useCallback)( 13009 (newDate) => { 13010 let dateTimeValue; 13011 if (newDate) { 13012 let finalDateTime = newDate; 13013 if (value) { 13014 const currentDateTime = parseDateTime(value); 13015 if (currentDateTime) { 13016 finalDateTime = new Date(newDate); 13017 finalDateTime.setHours(currentDateTime.getHours()); 13018 finalDateTime.setMinutes( 13019 currentDateTime.getMinutes() 13020 ); 13021 } 13022 } 13023 dateTimeValue = finalDateTime.toISOString(); 13024 onChangeCallback(dateTimeValue); 13025 if (validationTimeoutRef.current) { 13026 clearTimeout(validationTimeoutRef.current); 13027 } 13028 } else { 13029 onChangeCallback(void 0); 13030 } 13031 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement; 13032 validationTimeoutRef.current = setTimeout(() => { 13033 if (inputControlRef.current) { 13034 inputControlRef.current.focus(); 13035 inputControlRef.current.blur(); 13036 onChangeCallback(dateTimeValue); 13037 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) { 13038 previousFocusRef.current.focus(); 13039 } 13040 } 13041 }, 0); 13042 }, 13043 [onChangeCallback, value] 13044 ); 13045 const handleManualDateTimeChange = (0, import_element40.useCallback)( 13046 (newValue) => { 13047 if (newValue) { 13048 const dateTime = new Date(newValue); 13049 onChangeCallback(dateTime.toISOString()); 13050 const parsedDate = parseDateTime(dateTime.toISOString()); 13051 if (parsedDate) { 13052 setCalendarMonth(parsedDate); 13053 } 13054 } else { 13055 onChangeCallback(void 0); 13056 } 13057 }, 13058 [onChangeCallback] 13059 ); 13060 const { format: fieldFormat } = field; 13061 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date2.getSettings)().l10n.startOfWeek; 13062 const { 13063 timezone: { string: timezoneString } 13064 } = (0, import_date2.getSettings)(); 13065 const displayLabel = isValid2?.required && !hideLabelFromVision ? `$label} (${(0, import_i18n32.__)("Required")})` : label; 13066 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 13067 import_components36.BaseControl, 13068 { 13069 id, 13070 label: displayLabel, 13071 help: description, 13072 hideLabelFromVision, 13073 children: /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_components36.__experimentalVStack, { spacing: 4, children: [ 13074 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 13075 DateCalendar, 13076 { 13077 style: { width: "100%" }, 13078 selected: value ? parseDateTime(value) || void 0 : void 0, 13079 onSelect: onSelectDate, 13080 month: calendarMonth, 13081 onMonthChange: setCalendarMonth, 13082 timeZone: timezoneString || void 0, 13083 weekStartsOn 13084 } 13085 ), 13086 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 13087 ValidatedInputControl, 13088 { 13089 ref: inputControlRef, 13090 __next40pxDefaultSize: true, 13091 required: !!isValid2?.required, 13092 customValidity: getCustomValidity(isValid2, validity), 13093 type: "datetime-local", 13094 label: (0, import_i18n32.__)("Date time"), 13095 hideLabelFromVision: true, 13096 value: value ? formatDateTime( 13097 parseDateTime(value) || void 0 13098 ) : "", 13099 onChange: handleManualDateTimeChange 13100 } 13101 ) 13102 ] }) 13103 } 13104 ); 13105 } 13106 function DateTime({ 13107 data, 13108 field, 13109 onChange, 13110 hideLabelFromVision, 13111 operator, 13112 validity 13113 }) { 13114 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 13115 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 13116 RelativeDateControl, 13117 { 13118 className: "dataviews-controls__datetime", 13119 data, 13120 field, 13121 onChange, 13122 hideLabelFromVision, 13123 operator 13124 } 13125 ); 13126 } 13127 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 13128 CalendarDateTimeControl, 13129 { 13130 data, 13131 field, 13132 onChange, 13133 hideLabelFromVision, 13134 validity 13135 } 13136 ); 13137 } 13138 13139 // packages/dataviews/build-module/dataform-controls/date.js 13140 var import_components37 = __toESM(require_components()); 13141 var import_element41 = __toESM(require_element()); 13142 var import_i18n33 = __toESM(require_i18n()); 13143 var import_date3 = __toESM(require_date()); 13144 var import_jsx_runtime75 = __toESM(require_jsx_runtime()); 13145 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock(import_components37.privateApis); 13146 var DATE_PRESETS = [ 13147 { 13148 id: "today", 13149 label: (0, import_i18n33.__)("Today"), 13150 getValue: () => (0, import_date3.getDate)(null) 13151 }, 13152 { 13153 id: "yesterday", 13154 label: (0, import_i18n33.__)("Yesterday"), 13155 getValue: () => { 13156 const today = (0, import_date3.getDate)(null); 13157 return subDays(today, 1); 13158 } 13159 }, 13160 { 13161 id: "past-week", 13162 label: (0, import_i18n33.__)("Past week"), 13163 getValue: () => { 13164 const today = (0, import_date3.getDate)(null); 13165 return subDays(today, 7); 13166 } 13167 }, 13168 { 13169 id: "past-month", 13170 label: (0, import_i18n33.__)("Past month"), 13171 getValue: () => { 13172 const today = (0, import_date3.getDate)(null); 13173 return subMonths(today, 1); 13174 } 13175 } 13176 ]; 13177 var DATE_RANGE_PRESETS = [ 13178 { 13179 id: "last-7-days", 13180 label: (0, import_i18n33.__)("Last 7 days"), 13181 getValue: () => { 13182 const today = (0, import_date3.getDate)(null); 13183 return [subDays(today, 7), today]; 13184 } 13185 }, 13186 { 13187 id: "last-30-days", 13188 label: (0, import_i18n33.__)("Last 30 days"), 13189 getValue: () => { 13190 const today = (0, import_date3.getDate)(null); 13191 return [subDays(today, 30), today]; 13192 } 13193 }, 13194 { 13195 id: "month-to-date", 13196 label: (0, import_i18n33.__)("Month to date"), 13197 getValue: () => { 13198 const today = (0, import_date3.getDate)(null); 13199 return [startOfMonth(today), today]; 13200 } 13201 }, 13202 { 13203 id: "last-year", 13204 label: (0, import_i18n33.__)("Last year"), 13205 getValue: () => { 13206 const today = (0, import_date3.getDate)(null); 13207 return [subYears(today, 1), today]; 13208 } 13209 }, 13210 { 13211 id: "year-to-date", 13212 label: (0, import_i18n33.__)("Year to date"), 13213 getValue: () => { 13214 const today = (0, import_date3.getDate)(null); 13215 return [startOfYear(today), today]; 13216 } 13217 } 13218 ]; 13219 var parseDate = (dateString) => { 13220 if (!dateString) { 13221 return null; 13222 } 13223 const parsed = (0, import_date3.getDate)(dateString); 13224 return parsed && isValid(parsed) ? parsed : null; 13225 }; 13226 var formatDate = (date) => { 13227 if (!date) { 13228 return ""; 13229 } 13230 return typeof date === "string" ? date : format(date, "yyyy-MM-dd"); 13231 }; 13232 function ValidatedDateControl({ 13233 field, 13234 validity, 13235 inputRefs, 13236 isTouched, 13237 setIsTouched, 13238 children 13239 }) { 13240 const { isValid: isValid2 } = field; 13241 const [customValidity, setCustomValidity] = (0, import_element41.useState)(void 0); 13242 const validateRefs = (0, import_element41.useCallback)(() => { 13243 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 13244 for (const ref of refs) { 13245 const input = ref.current; 13246 if (input && !input.validity.valid) { 13247 setCustomValidity({ 13248 type: "invalid", 13249 message: input.validationMessage 13250 }); 13251 return; 13252 } 13253 } 13254 setCustomValidity(void 0); 13255 }, [inputRefs]); 13256 (0, import_element41.useEffect)(() => { 13257 if (isTouched) { 13258 const timeoutId = setTimeout(() => { 13259 if (validity) { 13260 setCustomValidity(getCustomValidity(isValid2, validity)); 13261 } else { 13262 validateRefs(); 13263 } 13264 }, 0); 13265 return () => clearTimeout(timeoutId); 13266 } 13267 return void 0; 13268 }, [isTouched, isValid2, validity, validateRefs]); 13269 const onBlur = (event) => { 13270 if (isTouched) { 13271 return; 13272 } 13273 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) { 13274 setIsTouched(true); 13275 } 13276 }; 13277 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { onBlur, children: [ 13278 children, 13279 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)( 13280 "p", 13281 { 13282 className: clsx_default( 13283 "components-validated-control__indicator", 13284 customValidity.type === "invalid" ? "is-invalid" : void 0, 13285 customValidity.type === "valid" ? "is-valid" : void 0 13286 ), 13287 children: [ 13288 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13289 import_components37.Icon, 13290 { 13291 className: "components-validated-control__indicator-icon", 13292 icon: error_default, 13293 size: 16, 13294 fill: "currentColor" 13295 } 13296 ), 13297 customValidity.message 13298 ] 13299 } 13300 ) }) 13301 ] }); 13302 } 13303 function CalendarDateControl({ 13304 data, 13305 field, 13306 onChange, 13307 hideLabelFromVision, 13308 validity 13309 }) { 13310 const { 13311 id, 13312 label, 13313 setValue, 13314 getValue, 13315 isValid: isValid2, 13316 format: fieldFormat 13317 } = field; 13318 const [selectedPresetId, setSelectedPresetId] = (0, import_element41.useState)( 13319 null 13320 ); 13321 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 13322 const fieldValue = getValue({ item: data }); 13323 const value = typeof fieldValue === "string" ? fieldValue : void 0; 13324 const [calendarMonth, setCalendarMonth] = (0, import_element41.useState)(() => { 13325 const parsedDate = parseDate(value); 13326 return parsedDate || /* @__PURE__ */ new Date(); 13327 }); 13328 const [isTouched, setIsTouched] = (0, import_element41.useState)(false); 13329 const validityTargetRef = (0, import_element41.useRef)(null); 13330 const onChangeCallback = (0, import_element41.useCallback)( 13331 (newValue) => onChange(setValue({ item: data, value: newValue })), 13332 [data, onChange, setValue] 13333 ); 13334 const onSelectDate = (0, import_element41.useCallback)( 13335 (newDate) => { 13336 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0; 13337 onChangeCallback(dateValue); 13338 setSelectedPresetId(null); 13339 setIsTouched(true); 13340 }, 13341 [onChangeCallback] 13342 ); 13343 const handlePresetClick = (0, import_element41.useCallback)( 13344 (preset) => { 13345 const presetDate = preset.getValue(); 13346 const dateValue = formatDate(presetDate); 13347 setCalendarMonth(presetDate); 13348 onChangeCallback(dateValue); 13349 setSelectedPresetId(preset.id); 13350 setIsTouched(true); 13351 }, 13352 [onChangeCallback] 13353 ); 13354 const handleManualDateChange = (0, import_element41.useCallback)( 13355 (newValue) => { 13356 onChangeCallback(newValue); 13357 if (newValue) { 13358 const parsedDate = parseDate(newValue); 13359 if (parsedDate) { 13360 setCalendarMonth(parsedDate); 13361 } 13362 } 13363 setSelectedPresetId(null); 13364 setIsTouched(true); 13365 }, 13366 [onChangeCallback] 13367 ); 13368 const { 13369 timezone: { string: timezoneString } 13370 } = (0, import_date3.getSettings)(); 13371 const displayLabel = isValid2?.required ? `$label} (${(0, import_i18n33.__)("Required")})` : label; 13372 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13373 ValidatedDateControl, 13374 { 13375 field, 13376 validity, 13377 inputRefs: validityTargetRef, 13378 isTouched, 13379 setIsTouched, 13380 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13381 import_components37.BaseControl, 13382 { 13383 id, 13384 className: "dataviews-controls__date", 13385 label: displayLabel, 13386 hideLabelFromVision, 13387 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_components37.__experimentalVStack, { spacing: 4, children: [ 13388 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_components37.__experimentalHStack, { spacing: 2, wrap: true, justify: "flex-start", children: [ 13389 DATE_PRESETS.map((preset) => { 13390 const isSelected2 = selectedPresetId === preset.id; 13391 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13392 import_components37.Button, 13393 { 13394 className: "dataviews-controls__date-preset", 13395 variant: "tertiary", 13396 isPressed: isSelected2, 13397 size: "small", 13398 onClick: () => handlePresetClick(preset), 13399 children: preset.label 13400 }, 13401 preset.id 13402 ); 13403 }), 13404 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13405 import_components37.Button, 13406 { 13407 className: "dataviews-controls__date-preset", 13408 variant: "tertiary", 13409 isPressed: !selectedPresetId, 13410 size: "small", 13411 disabled: !!selectedPresetId, 13412 accessibleWhenDisabled: false, 13413 children: (0, import_i18n33.__)("Custom") 13414 } 13415 ) 13416 ] }), 13417 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13418 import_components37.__experimentalInputControl, 13419 { 13420 __next40pxDefaultSize: true, 13421 ref: validityTargetRef, 13422 type: "date", 13423 label: (0, import_i18n33.__)("Date"), 13424 hideLabelFromVision: true, 13425 value, 13426 onChange: handleManualDateChange, 13427 required: !!field.isValid?.required 13428 } 13429 ), 13430 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13431 DateCalendar2, 13432 { 13433 style: { width: "100%" }, 13434 selected: value ? parseDate(value) || void 0 : void 0, 13435 onSelect: onSelectDate, 13436 month: calendarMonth, 13437 onMonthChange: setCalendarMonth, 13438 timeZone: timezoneString || void 0, 13439 weekStartsOn 13440 } 13441 ) 13442 ] }) 13443 } 13444 ) 13445 } 13446 ); 13447 } 13448 function CalendarDateRangeControl({ 13449 data, 13450 field, 13451 onChange, 13452 hideLabelFromVision, 13453 validity 13454 }) { 13455 const { id, label, getValue, setValue, format: fieldFormat } = field; 13456 let value; 13457 const fieldValue = getValue({ item: data }); 13458 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) { 13459 value = fieldValue; 13460 } 13461 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 13462 const onChangeCallback = (0, import_element41.useCallback)( 13463 (newValue) => { 13464 onChange( 13465 setValue({ 13466 item: data, 13467 value: newValue 13468 }) 13469 ); 13470 }, 13471 [data, onChange, setValue] 13472 ); 13473 const [selectedPresetId, setSelectedPresetId] = (0, import_element41.useState)( 13474 null 13475 ); 13476 const selectedRange = (0, import_element41.useMemo)(() => { 13477 if (!value) { 13478 return { from: void 0, to: void 0 }; 13479 } 13480 const [from, to] = value; 13481 return { 13482 from: parseDate(from) || void 0, 13483 to: parseDate(to) || void 0 13484 }; 13485 }, [value]); 13486 const [calendarMonth, setCalendarMonth] = (0, import_element41.useState)(() => { 13487 return selectedRange.from || /* @__PURE__ */ new Date(); 13488 }); 13489 const [isTouched, setIsTouched] = (0, import_element41.useState)(false); 13490 const fromInputRef = (0, import_element41.useRef)(null); 13491 const toInputRef = (0, import_element41.useRef)(null); 13492 const updateDateRange = (0, import_element41.useCallback)( 13493 (fromDate, toDate2) => { 13494 if (fromDate && toDate2) { 13495 onChangeCallback([ 13496 formatDate(fromDate), 13497 formatDate(toDate2) 13498 ]); 13499 } else if (!fromDate && !toDate2) { 13500 onChangeCallback(void 0); 13501 } 13502 }, 13503 [onChangeCallback] 13504 ); 13505 const onSelectCalendarRange = (0, import_element41.useCallback)( 13506 (newRange) => { 13507 updateDateRange(newRange?.from, newRange?.to); 13508 setSelectedPresetId(null); 13509 setIsTouched(true); 13510 }, 13511 [updateDateRange] 13512 ); 13513 const handlePresetClick = (0, import_element41.useCallback)( 13514 (preset) => { 13515 const [startDate, endDate] = preset.getValue(); 13516 setCalendarMonth(startDate); 13517 updateDateRange(startDate, endDate); 13518 setSelectedPresetId(preset.id); 13519 setIsTouched(true); 13520 }, 13521 [updateDateRange] 13522 ); 13523 const handleManualDateChange = (0, import_element41.useCallback)( 13524 (fromOrTo, newValue) => { 13525 const [currentFrom, currentTo] = value || [ 13526 void 0, 13527 void 0 13528 ]; 13529 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom; 13530 const updatedTo = fromOrTo === "to" ? newValue : currentTo; 13531 updateDateRange(updatedFrom, updatedTo); 13532 if (newValue) { 13533 const parsedDate = parseDate(newValue); 13534 if (parsedDate) { 13535 setCalendarMonth(parsedDate); 13536 } 13537 } 13538 setSelectedPresetId(null); 13539 setIsTouched(true); 13540 }, 13541 [value, updateDateRange] 13542 ); 13543 const { timezone } = (0, import_date3.getSettings)(); 13544 const displayLabel = field.isValid?.required ? `$label} (${(0, import_i18n33.__)("Required")})` : label; 13545 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13546 ValidatedDateControl, 13547 { 13548 field, 13549 validity, 13550 inputRefs: [fromInputRef, toInputRef], 13551 isTouched, 13552 setIsTouched, 13553 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13554 import_components37.BaseControl, 13555 { 13556 id, 13557 className: "dataviews-controls__date", 13558 label: displayLabel, 13559 hideLabelFromVision, 13560 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_components37.__experimentalVStack, { spacing: 4, children: [ 13561 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_components37.__experimentalHStack, { spacing: 2, wrap: true, justify: "flex-start", children: [ 13562 DATE_RANGE_PRESETS.map((preset) => { 13563 const isSelected2 = selectedPresetId === preset.id; 13564 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13565 import_components37.Button, 13566 { 13567 className: "dataviews-controls__date-preset", 13568 variant: "tertiary", 13569 isPressed: isSelected2, 13570 size: "small", 13571 onClick: () => handlePresetClick(preset), 13572 children: preset.label 13573 }, 13574 preset.id 13575 ); 13576 }), 13577 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13578 import_components37.Button, 13579 { 13580 className: "dataviews-controls__date-preset", 13581 variant: "tertiary", 13582 isPressed: !selectedPresetId, 13583 size: "small", 13584 accessibleWhenDisabled: false, 13585 disabled: !!selectedPresetId, 13586 children: (0, import_i18n33.__)("Custom") 13587 } 13588 ) 13589 ] }), 13590 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_components37.__experimentalHStack, { spacing: 2, children: [ 13591 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13592 import_components37.__experimentalInputControl, 13593 { 13594 __next40pxDefaultSize: true, 13595 ref: fromInputRef, 13596 type: "date", 13597 label: (0, import_i18n33.__)("From"), 13598 hideLabelFromVision: true, 13599 value: value?.[0], 13600 onChange: (newValue) => handleManualDateChange("from", newValue), 13601 required: !!field.isValid?.required 13602 } 13603 ), 13604 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13605 import_components37.__experimentalInputControl, 13606 { 13607 __next40pxDefaultSize: true, 13608 ref: toInputRef, 13609 type: "date", 13610 label: (0, import_i18n33.__)("To"), 13611 hideLabelFromVision: true, 13612 value: value?.[1], 13613 onChange: (newValue) => handleManualDateChange("to", newValue), 13614 required: !!field.isValid?.required 13615 } 13616 ) 13617 ] }), 13618 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13619 DateRangeCalendar, 13620 { 13621 style: { width: "100%" }, 13622 selected: selectedRange, 13623 onSelect: onSelectCalendarRange, 13624 month: calendarMonth, 13625 onMonthChange: setCalendarMonth, 13626 timeZone: timezone.string || void 0, 13627 weekStartsOn 13628 } 13629 ) 13630 ] }) 13631 } 13632 ) 13633 } 13634 ); 13635 } 13636 function DateControl({ 13637 data, 13638 field, 13639 onChange, 13640 hideLabelFromVision, 13641 operator, 13642 validity 13643 }) { 13644 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 13645 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13646 RelativeDateControl, 13647 { 13648 className: "dataviews-controls__date", 13649 data, 13650 field, 13651 onChange, 13652 hideLabelFromVision, 13653 operator 13654 } 13655 ); 13656 } 13657 if (operator === OPERATOR_BETWEEN) { 13658 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13659 CalendarDateRangeControl, 13660 { 13661 data, 13662 field, 13663 onChange, 13664 hideLabelFromVision, 13665 validity 13666 } 13667 ); 13668 } 13669 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13670 CalendarDateControl, 13671 { 13672 data, 13673 field, 13674 onChange, 13675 hideLabelFromVision, 13676 validity 13677 } 13678 ); 13679 } 13680 13681 // packages/dataviews/build-module/dataform-controls/email.js 13682 var import_components39 = __toESM(require_components()); 13683 13684 // packages/dataviews/build-module/dataform-controls/utils/validated-input.js 13685 var import_components38 = __toESM(require_components()); 13686 var import_element42 = __toESM(require_element()); 13687 var import_jsx_runtime76 = __toESM(require_jsx_runtime()); 13688 var { ValidatedInputControl: ValidatedInputControl2 } = unlock(import_components38.privateApis); 13689 function ValidatedText({ 13690 data, 13691 field, 13692 onChange, 13693 hideLabelFromVision, 13694 type, 13695 prefix, 13696 suffix, 13697 validity 13698 }) { 13699 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 13700 const value = getValue({ item: data }); 13701 const onChangeControl = (0, import_element42.useCallback)( 13702 (newValue) => onChange( 13703 setValue({ 13704 item: data, 13705 value: newValue 13706 }) 13707 ), 13708 [data, setValue, onChange] 13709 ); 13710 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13711 ValidatedInputControl2, 13712 { 13713 required: !!isValid2.required, 13714 customValidity: getCustomValidity(isValid2, validity), 13715 label, 13716 placeholder, 13717 value: value ?? "", 13718 help: description, 13719 onChange: onChangeControl, 13720 hideLabelFromVision, 13721 type, 13722 prefix, 13723 suffix, 13724 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0, 13725 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 13726 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 13727 __next40pxDefaultSize: true 13728 } 13729 ); 13730 } 13731 13732 // packages/dataviews/build-module/dataform-controls/email.js 13733 var import_jsx_runtime77 = __toESM(require_jsx_runtime()); 13734 function Email({ 13735 data, 13736 field, 13737 onChange, 13738 hideLabelFromVision, 13739 validity 13740 }) { 13741 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 13742 ValidatedText, 13743 { 13744 ...{ 13745 data, 13746 field, 13747 onChange, 13748 hideLabelFromVision, 13749 validity, 13750 type: "email", 13751 prefix: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components39.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components39.Icon, { icon: envelope_default }) }) 13752 } 13753 } 13754 ); 13755 } 13756 13757 // packages/dataviews/build-module/dataform-controls/telephone.js 13758 var import_components40 = __toESM(require_components()); 13759 var import_jsx_runtime78 = __toESM(require_jsx_runtime()); 13760 function Telephone({ 13761 data, 13762 field, 13763 onChange, 13764 hideLabelFromVision, 13765 validity 13766 }) { 13767 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 13768 ValidatedText, 13769 { 13770 ...{ 13771 data, 13772 field, 13773 onChange, 13774 hideLabelFromVision, 13775 validity, 13776 type: "tel", 13777 prefix: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components40.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components40.Icon, { icon: mobile_default }) }) 13778 } 13779 } 13780 ); 13781 } 13782 13783 // packages/dataviews/build-module/dataform-controls/url.js 13784 var import_components41 = __toESM(require_components()); 13785 var import_jsx_runtime79 = __toESM(require_jsx_runtime()); 13786 function Url({ 13787 data, 13788 field, 13789 onChange, 13790 hideLabelFromVision, 13791 validity 13792 }) { 13793 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 13794 ValidatedText, 13795 { 13796 ...{ 13797 data, 13798 field, 13799 onChange, 13800 hideLabelFromVision, 13801 validity, 13802 type: "url", 13803 prefix: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components41.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components41.Icon, { icon: link_default }) }) 13804 } 13805 } 13806 ); 13807 } 13808 13809 // packages/dataviews/build-module/dataform-controls/utils/validated-number.js 13810 var import_components42 = __toESM(require_components()); 13811 var import_element43 = __toESM(require_element()); 13812 var import_i18n34 = __toESM(require_i18n()); 13813 var import_jsx_runtime80 = __toESM(require_jsx_runtime()); 13814 var { ValidatedNumberControl } = unlock(import_components42.privateApis); 13815 function toNumberOrEmpty(value) { 13816 if (value === "" || value === void 0) { 13817 return ""; 13818 } 13819 const number = Number(value); 13820 return Number.isFinite(number) ? number : ""; 13821 } 13822 function BetweenControls({ 13823 value, 13824 onChange, 13825 hideLabelFromVision, 13826 step 13827 }) { 13828 const [min = "", max = ""] = value; 13829 const onChangeMin = (0, import_element43.useCallback)( 13830 (newValue) => onChange([toNumberOrEmpty(newValue), max]), 13831 [onChange, max] 13832 ); 13833 const onChangeMax = (0, import_element43.useCallback)( 13834 (newValue) => onChange([min, toNumberOrEmpty(newValue)]), 13835 [onChange, min] 13836 ); 13837 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 13838 import_components42.BaseControl, 13839 { 13840 help: (0, import_i18n34.__)("The max. value must be greater than the min. value."), 13841 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(import_components42.Flex, { direction: "row", gap: 4, children: [ 13842 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 13843 import_components42.__experimentalNumberControl, 13844 { 13845 label: (0, import_i18n34.__)("Min."), 13846 value: min, 13847 max: max ? Number(max) - step : void 0, 13848 onChange: onChangeMin, 13849 __next40pxDefaultSize: true, 13850 hideLabelFromVision, 13851 step 13852 } 13853 ), 13854 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 13855 import_components42.__experimentalNumberControl, 13856 { 13857 label: (0, import_i18n34.__)("Max."), 13858 value: max, 13859 min: min ? Number(min) + step : void 0, 13860 onChange: onChangeMax, 13861 __next40pxDefaultSize: true, 13862 hideLabelFromVision, 13863 step 13864 } 13865 ) 13866 ] }) 13867 } 13868 ); 13869 } 13870 function ValidatedNumber({ 13871 data, 13872 field, 13873 onChange, 13874 hideLabelFromVision, 13875 operator, 13876 validity 13877 }) { 13878 const decimals = field.format?.decimals ?? 0; 13879 const step = Math.pow(10, Math.abs(decimals) * -1); 13880 const { label, description, getValue, setValue, isValid: isValid2 } = field; 13881 const value = getValue({ item: data }) ?? ""; 13882 const onChangeControl = (0, import_element43.useCallback)( 13883 (newValue) => { 13884 onChange( 13885 setValue({ 13886 item: data, 13887 // Do not convert an empty string or undefined to a number, 13888 // otherwise there's a mismatch between the UI control (empty) 13889 // and the data relied by onChange (0). 13890 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue) 13891 }) 13892 ); 13893 }, 13894 [data, onChange, setValue] 13895 ); 13896 const onChangeBetweenControls = (0, import_element43.useCallback)( 13897 (newValue) => { 13898 onChange( 13899 setValue({ 13900 item: data, 13901 value: newValue 13902 }) 13903 ); 13904 }, 13905 [data, onChange, setValue] 13906 ); 13907 if (operator === OPERATOR_BETWEEN) { 13908 let valueBetween = ["", ""]; 13909 if (Array.isArray(value) && value.length === 2 && value.every( 13910 (element) => typeof element === "number" || element === "" 13911 )) { 13912 valueBetween = value; 13913 } 13914 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 13915 BetweenControls, 13916 { 13917 value: valueBetween, 13918 onChange: onChangeBetweenControls, 13919 hideLabelFromVision, 13920 step 13921 } 13922 ); 13923 } 13924 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 13925 ValidatedNumberControl, 13926 { 13927 required: !!isValid2.required, 13928 customValidity: getCustomValidity(isValid2, validity), 13929 label, 13930 help: description, 13931 value, 13932 onChange: onChangeControl, 13933 __next40pxDefaultSize: true, 13934 hideLabelFromVision, 13935 step, 13936 min: isValid2.min ? isValid2.min.constraint : void 0, 13937 max: isValid2.max ? isValid2.max.constraint : void 0 13938 } 13939 ); 13940 } 13941 13942 // packages/dataviews/build-module/dataform-controls/integer.js 13943 var import_jsx_runtime81 = __toESM(require_jsx_runtime()); 13944 function Integer(props) { 13945 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ValidatedNumber, { ...props }); 13946 } 13947 13948 // packages/dataviews/build-module/dataform-controls/number.js 13949 var import_jsx_runtime82 = __toESM(require_jsx_runtime()); 13950 function Number2(props) { 13951 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ValidatedNumber, { ...props }); 13952 } 13953 13954 // packages/dataviews/build-module/dataform-controls/radio.js 13955 var import_components43 = __toESM(require_components()); 13956 var import_element44 = __toESM(require_element()); 13957 var import_jsx_runtime83 = __toESM(require_jsx_runtime()); 13958 var { ValidatedRadioControl } = unlock(import_components43.privateApis); 13959 function Radio({ 13960 data, 13961 field, 13962 onChange, 13963 hideLabelFromVision, 13964 validity 13965 }) { 13966 const { label, description, getValue, setValue, isValid: isValid2 } = field; 13967 const { elements, isLoading } = useElements({ 13968 elements: field.elements, 13969 getElements: field.getElements 13970 }); 13971 const value = getValue({ item: data }); 13972 const onChangeControl = (0, import_element44.useCallback)( 13973 (newValue) => onChange(setValue({ item: data, value: newValue })), 13974 [data, onChange, setValue] 13975 ); 13976 if (isLoading) { 13977 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components43.Spinner, {}); 13978 } 13979 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 13980 ValidatedRadioControl, 13981 { 13982 required: !!field.isValid?.required, 13983 customValidity: getCustomValidity(isValid2, validity), 13984 label, 13985 help: description, 13986 onChange: onChangeControl, 13987 options: elements, 13988 selected: value, 13989 hideLabelFromVision 13990 } 13991 ); 13992 } 13993 13994 // packages/dataviews/build-module/dataform-controls/select.js 13995 var import_components44 = __toESM(require_components()); 13996 var import_element45 = __toESM(require_element()); 13997 var import_jsx_runtime84 = __toESM(require_jsx_runtime()); 13998 var { ValidatedSelectControl } = unlock(import_components44.privateApis); 13999 function Select({ 14000 data, 14001 field, 14002 onChange, 14003 hideLabelFromVision, 14004 validity 14005 }) { 14006 const { type, label, description, getValue, setValue, isValid: isValid2 } = field; 14007 const isMultiple = type === "array"; 14008 const value = getValue({ item: data }) ?? (isMultiple ? [] : ""); 14009 const onChangeControl = (0, import_element45.useCallback)( 14010 (newValue) => onChange(setValue({ item: data, value: newValue })), 14011 [data, onChange, setValue] 14012 ); 14013 const { elements, isLoading } = useElements({ 14014 elements: field.elements, 14015 getElements: field.getElements 14016 }); 14017 if (isLoading) { 14018 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_components44.Spinner, {}); 14019 } 14020 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)( 14021 ValidatedSelectControl, 14022 { 14023 required: !!field.isValid?.required, 14024 customValidity: getCustomValidity(isValid2, validity), 14025 label, 14026 value, 14027 help: description, 14028 options: elements, 14029 onChange: onChangeControl, 14030 __next40pxDefaultSize: true, 14031 hideLabelFromVision, 14032 multiple: isMultiple 14033 } 14034 ); 14035 } 14036 14037 // packages/dataviews/build-module/dataform-controls/text.js 14038 var import_element46 = __toESM(require_element()); 14039 var import_jsx_runtime85 = __toESM(require_jsx_runtime()); 14040 function Text2({ 14041 data, 14042 field, 14043 onChange, 14044 hideLabelFromVision, 14045 config, 14046 validity 14047 }) { 14048 const { prefix, suffix } = config || {}; 14049 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 14050 ValidatedText, 14051 { 14052 ...{ 14053 data, 14054 field, 14055 onChange, 14056 hideLabelFromVision, 14057 validity, 14058 prefix: prefix ? (0, import_element46.createElement)(prefix) : void 0, 14059 suffix: suffix ? (0, import_element46.createElement)(suffix) : void 0 14060 } 14061 } 14062 ); 14063 } 14064 14065 // packages/dataviews/build-module/dataform-controls/toggle.js 14066 var import_components45 = __toESM(require_components()); 14067 var import_element47 = __toESM(require_element()); 14068 var import_jsx_runtime86 = __toESM(require_jsx_runtime()); 14069 var { ValidatedToggleControl } = unlock(import_components45.privateApis); 14070 function Toggle({ 14071 field, 14072 onChange, 14073 data, 14074 hideLabelFromVision, 14075 validity 14076 }) { 14077 const { label, description, getValue, setValue, isValid: isValid2 } = field; 14078 const onChangeControl = (0, import_element47.useCallback)(() => { 14079 onChange( 14080 setValue({ item: data, value: !getValue({ item: data }) }) 14081 ); 14082 }, [onChange, setValue, data, getValue]); 14083 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 14084 ValidatedToggleControl, 14085 { 14086 required: !!isValid2.required, 14087 customValidity: getCustomValidity(isValid2, validity), 14088 hidden: hideLabelFromVision, 14089 label, 14090 help: description, 14091 checked: getValue({ item: data }), 14092 onChange: onChangeControl 14093 } 14094 ); 14095 } 14096 14097 // packages/dataviews/build-module/dataform-controls/textarea.js 14098 var import_components46 = __toESM(require_components()); 14099 var import_element48 = __toESM(require_element()); 14100 var import_jsx_runtime87 = __toESM(require_jsx_runtime()); 14101 var { ValidatedTextareaControl } = unlock(import_components46.privateApis); 14102 function Textarea({ 14103 data, 14104 field, 14105 onChange, 14106 hideLabelFromVision, 14107 config, 14108 validity 14109 }) { 14110 const { rows = 4 } = config || {}; 14111 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 14112 const value = field.getValue({ item: data }); 14113 const onChangeControl = (0, import_element48.useCallback)( 14114 (newValue) => onChange(setValue({ item: data, value: newValue })), 14115 [data, onChange, setValue] 14116 ); 14117 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 14118 ValidatedTextareaControl, 14119 { 14120 required: !!isValid2.required, 14121 customValidity: getCustomValidity(isValid2, validity), 14122 label, 14123 placeholder, 14124 value: value ?? "", 14125 help: description, 14126 onChange: onChangeControl, 14127 rows, 14128 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 14129 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 14130 __next40pxDefaultSize: true, 14131 hideLabelFromVision 14132 } 14133 ); 14134 } 14135 14136 // packages/dataviews/build-module/dataform-controls/toggle-group.js 14137 var import_components47 = __toESM(require_components()); 14138 var import_element49 = __toESM(require_element()); 14139 var import_jsx_runtime88 = __toESM(require_jsx_runtime()); 14140 var { ValidatedToggleGroupControl } = unlock(import_components47.privateApis); 14141 function ToggleGroup({ 14142 data, 14143 field, 14144 onChange, 14145 hideLabelFromVision, 14146 validity 14147 }) { 14148 const { getValue, setValue, isValid: isValid2 } = field; 14149 const value = getValue({ item: data }); 14150 const onChangeControl = (0, import_element49.useCallback)( 14151 (newValue) => onChange(setValue({ item: data, value: newValue })), 14152 [data, onChange, setValue] 14153 ); 14154 const { elements, isLoading } = useElements({ 14155 elements: field.elements, 14156 getElements: field.getElements 14157 }); 14158 if (isLoading) { 14159 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components47.Spinner, {}); 14160 } 14161 if (elements.length === 0) { 14162 return null; 14163 } 14164 const selectedOption = elements.find((el) => el.value === value); 14165 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 14166 ValidatedToggleGroupControl, 14167 { 14168 required: !!field.isValid?.required, 14169 customValidity: getCustomValidity(isValid2, validity), 14170 __next40pxDefaultSize: true, 14171 isBlock: true, 14172 label: field.label, 14173 help: selectedOption?.description || field.description, 14174 onChange: onChangeControl, 14175 value, 14176 hideLabelFromVision, 14177 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 14178 import_components47.__experimentalToggleGroupControlOption, 14179 { 14180 label: el.label, 14181 value: el.value 14182 }, 14183 el.value 14184 )) 14185 } 14186 ); 14187 } 14188 14189 // packages/dataviews/build-module/dataform-controls/array.js 14190 var import_components48 = __toESM(require_components()); 14191 var import_element50 = __toESM(require_element()); 14192 var import_jsx_runtime89 = __toESM(require_jsx_runtime()); 14193 var { ValidatedFormTokenField } = unlock(import_components48.privateApis); 14194 function ArrayControl({ 14195 data, 14196 field, 14197 onChange, 14198 hideLabelFromVision, 14199 validity 14200 }) { 14201 const { label, placeholder, getValue, setValue, isValid: isValid2 } = field; 14202 const value = getValue({ item: data }); 14203 const { elements, isLoading } = useElements({ 14204 elements: field.elements, 14205 getElements: field.getElements 14206 }); 14207 const arrayValueAsElements = (0, import_element50.useMemo)( 14208 () => Array.isArray(value) ? value.map((token) => { 14209 const element = elements?.find( 14210 (suggestion) => suggestion.value === token 14211 ); 14212 return element || { value: token, label: token }; 14213 }) : [], 14214 [value, elements] 14215 ); 14216 const onChangeControl = (0, import_element50.useCallback)( 14217 (tokens) => { 14218 const valueTokens = tokens.map((token) => { 14219 if (typeof token === "object" && "value" in token) { 14220 return token.value; 14221 } 14222 return token; 14223 }); 14224 onChange(setValue({ item: data, value: valueTokens })); 14225 }, 14226 [onChange, setValue, data] 14227 ); 14228 if (isLoading) { 14229 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components48.Spinner, {}); 14230 } 14231 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 14232 ValidatedFormTokenField, 14233 { 14234 required: !!isValid2?.required, 14235 customValidity: getCustomValidity(isValid2, validity), 14236 label: hideLabelFromVision ? void 0 : label, 14237 value: arrayValueAsElements, 14238 onChange: onChangeControl, 14239 placeholder, 14240 suggestions: elements?.map((element) => element.value), 14241 __experimentalValidateInput: (token) => { 14242 if (field.isValid?.elements && elements) { 14243 return elements.some( 14244 (element) => element.value === token || element.label === token 14245 ); 14246 } 14247 return true; 14248 }, 14249 __experimentalExpandOnFocus: elements && elements.length > 0, 14250 __experimentalShowHowTo: !field.isValid?.elements, 14251 displayTransform: (token) => { 14252 if (typeof token === "object" && "label" in token) { 14253 return token.label; 14254 } 14255 if (typeof token === "string" && elements) { 14256 const element = elements.find( 14257 (el) => el.value === token 14258 ); 14259 return element?.label || token; 14260 } 14261 return token; 14262 }, 14263 __experimentalRenderItem: ({ item }) => { 14264 if (typeof item === "string" && elements) { 14265 const element = elements.find( 14266 (el) => el.value === item 14267 ); 14268 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("span", { children: element?.label || item }); 14269 } 14270 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("span", { children: item }); 14271 } 14272 } 14273 ); 14274 } 14275 14276 // node_modules/colord/index.mjs 14277 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; 14278 var t = function(r3) { 14279 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3; 14280 }; 14281 var n = function(r3, t2, n2) { 14282 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0; 14283 }; 14284 var e = function(r3, t2, n2) { 14285 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2; 14286 }; 14287 var u = function(r3) { 14288 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360; 14289 }; 14290 var a = function(r3) { 14291 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) }; 14292 }; 14293 var o = function(r3) { 14294 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) }; 14295 }; 14296 var i = /^#([0-9a-f]{3,8})$/i; 14297 var s = function(r3) { 14298 var t2 = r3.toString(16); 14299 return t2.length < 2 ? "0" + t2 : t2; 14300 }; 14301 var h = function(r3) { 14302 var t2 = r3.r, n2 = r3.g, e2 = r3.b, u2 = r3.a, a2 = Math.max(t2, n2, e2), o2 = a2 - Math.min(t2, n2, e2), i2 = o2 ? a2 === t2 ? (n2 - e2) / o2 : a2 === n2 ? 2 + (e2 - t2) / o2 : 4 + (t2 - n2) / o2 : 0; 14303 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 }; 14304 }; 14305 var b = function(r3) { 14306 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a; 14307 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100; 14308 var a2 = Math.floor(t2), o2 = e2 * (1 - n2), i2 = e2 * (1 - (t2 - a2) * n2), s2 = e2 * (1 - (1 - t2 + a2) * n2), h2 = a2 % 6; 14309 return { r: 255 * [e2, i2, o2, o2, s2, e2][h2], g: 255 * [s2, e2, e2, i2, o2, o2][h2], b: 255 * [o2, o2, s2, e2, e2, i2][h2], a: u2 }; 14310 }; 14311 var g = function(r3) { 14312 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) }; 14313 }; 14314 var d = function(r3) { 14315 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) }; 14316 }; 14317 var f = function(r3) { 14318 return b((n2 = (t2 = r3).s, { h: t2.h, s: (n2 *= ((e2 = t2.l) < 50 ? e2 : 100 - e2) / 100) > 0 ? 2 * n2 / (e2 + n2) * 100 : 0, v: e2 + n2, a: t2.a })); 14319 var t2, n2, e2; 14320 }; 14321 var c = function(r3) { 14322 return { h: (t2 = h(r3)).h, s: (u2 = (200 - (n2 = t2.s)) * (e2 = t2.v) / 100) > 0 && u2 < 200 ? n2 * e2 / 100 / (u2 <= 100 ? u2 : 200 - u2) * 100 : 0, l: u2 / 2, a: t2.a }; 14323 var t2, n2, e2, u2; 14324 }; 14325 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 14326 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 14327 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 14328 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 14329 var y = { string: [[function(r3) { 14330 var t2 = i.exec(r3); 14331 return t2 ? (r3 = t2[1]).length <= 4 ? { r: parseInt(r3[0] + r3[0], 16), g: parseInt(r3[1] + r3[1], 16), b: parseInt(r3[2] + r3[2], 16), a: 4 === r3.length ? n(parseInt(r3[3] + r3[3], 16) / 255, 2) : 1 } : 6 === r3.length || 8 === r3.length ? { r: parseInt(r3.substr(0, 2), 16), g: parseInt(r3.substr(2, 2), 16), b: parseInt(r3.substr(4, 2), 16), a: 8 === r3.length ? n(parseInt(r3.substr(6, 2), 16) / 255, 2) : 1 } : null : null; 14332 }, "hex"], [function(r3) { 14333 var t2 = v.exec(r3) || m.exec(r3); 14334 return t2 ? t2[2] !== t2[4] || t2[4] !== t2[6] ? null : a({ r: Number(t2[1]) / (t2[2] ? 100 / 255 : 1), g: Number(t2[3]) / (t2[4] ? 100 / 255 : 1), b: Number(t2[5]) / (t2[6] ? 100 / 255 : 1), a: void 0 === t2[7] ? 1 : Number(t2[7]) / (t2[8] ? 100 : 1) }) : null; 14335 }, "rgb"], [function(t2) { 14336 var n2 = l.exec(t2) || p.exec(t2); 14337 if (!n2) return null; 14338 var e2, u2, a2 = g({ h: (e2 = n2[1], u2 = n2[2], void 0 === u2 && (u2 = "deg"), Number(e2) * (r2[u2] || 1)), s: Number(n2[3]), l: Number(n2[4]), a: void 0 === n2[5] ? 1 : Number(n2[5]) / (n2[6] ? 100 : 1) }); 14339 return f(a2); 14340 }, "hsl"]], object: [[function(r3) { 14341 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2; 14342 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null; 14343 }, "rgb"], [function(r3) { 14344 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2; 14345 if (!t(n2) || !t(e2) || !t(u2)) return null; 14346 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) }); 14347 return f(i2); 14348 }, "hsl"], [function(r3) { 14349 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2; 14350 if (!t(n2) || !t(a2) || !t(o2)) return null; 14351 var h2 = (function(r4) { 14352 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) }; 14353 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) }); 14354 return b(h2); 14355 }, "hsv"]] }; 14356 var N = function(r3, t2) { 14357 for (var n2 = 0; n2 < t2.length; n2++) { 14358 var e2 = t2[n2][0](r3); 14359 if (e2) return [e2, t2[n2][1]]; 14360 } 14361 return [null, void 0]; 14362 }; 14363 var x = function(r3) { 14364 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0]; 14365 }; 14366 var M = function(r3, t2) { 14367 var n2 = c(r3); 14368 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a }; 14369 }; 14370 var H = function(r3) { 14371 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255; 14372 }; 14373 var $ = function(r3, t2) { 14374 var n2 = c(r3); 14375 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a }; 14376 }; 14377 var j = (function() { 14378 function r3(r4) { 14379 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 14380 } 14381 return r3.prototype.isValid = function() { 14382 return null !== this.parsed; 14383 }, r3.prototype.brightness = function() { 14384 return n(H(this.rgba), 2); 14385 }, r3.prototype.isDark = function() { 14386 return H(this.rgba) < 0.5; 14387 }, r3.prototype.isLight = function() { 14388 return H(this.rgba) >= 0.5; 14389 }, r3.prototype.toHex = function() { 14390 return r4 = o(this.rgba), t2 = r4.r, e2 = r4.g, u2 = r4.b, i2 = (a2 = r4.a) < 1 ? s(n(255 * a2)) : "", "#" + s(t2) + s(e2) + s(u2) + i2; 14391 var r4, t2, e2, u2, a2, i2; 14392 }, r3.prototype.toRgb = function() { 14393 return o(this.rgba); 14394 }, r3.prototype.toRgbString = function() { 14395 return r4 = o(this.rgba), t2 = r4.r, n2 = r4.g, e2 = r4.b, (u2 = r4.a) < 1 ? "rgba(" + t2 + ", " + n2 + ", " + e2 + ", " + u2 + ")" : "rgb(" + t2 + ", " + n2 + ", " + e2 + ")"; 14396 var r4, t2, n2, e2, u2; 14397 }, r3.prototype.toHsl = function() { 14398 return d(c(this.rgba)); 14399 }, r3.prototype.toHslString = function() { 14400 return r4 = d(c(this.rgba)), t2 = r4.h, n2 = r4.s, e2 = r4.l, (u2 = r4.a) < 1 ? "hsla(" + t2 + ", " + n2 + "%, " + e2 + "%, " + u2 + ")" : "hsl(" + t2 + ", " + n2 + "%, " + e2 + "%)"; 14401 var r4, t2, n2, e2, u2; 14402 }, r3.prototype.toHsv = function() { 14403 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) }; 14404 var r4; 14405 }, r3.prototype.invert = function() { 14406 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a }); 14407 var r4; 14408 }, r3.prototype.saturate = function(r4) { 14409 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4)); 14410 }, r3.prototype.desaturate = function(r4) { 14411 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4)); 14412 }, r3.prototype.grayscale = function() { 14413 return w(M(this.rgba, -1)); 14414 }, r3.prototype.lighten = function(r4) { 14415 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4)); 14416 }, r3.prototype.darken = function(r4) { 14417 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4)); 14418 }, r3.prototype.rotate = function(r4) { 14419 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4); 14420 }, r3.prototype.alpha = function(r4) { 14421 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3); 14422 var t2; 14423 }, r3.prototype.hue = function(r4) { 14424 var t2 = c(this.rgba); 14425 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h); 14426 }, r3.prototype.isEqual = function(r4) { 14427 return this.toHex() === w(r4).toHex(); 14428 }, r3; 14429 })(); 14430 var w = function(r3) { 14431 return r3 instanceof j ? r3 : new j(r3); 14432 }; 14433 14434 // packages/dataviews/build-module/dataform-controls/color.js 14435 var import_components49 = __toESM(require_components()); 14436 var import_element51 = __toESM(require_element()); 14437 var import_jsx_runtime90 = __toESM(require_jsx_runtime()); 14438 var { ValidatedInputControl: ValidatedInputControl3, Picker } = unlock(import_components49.privateApis); 14439 var ColorPicker = ({ 14440 color, 14441 onColorChange 14442 }) => { 14443 const validColor = color && w(color).isValid() ? color : "#ffffff"; 14444 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 14445 import_components49.Dropdown, 14446 { 14447 renderToggle: ({ onToggle, isOpen }) => /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components49.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 14448 "button", 14449 { 14450 type: "button", 14451 onClick: onToggle, 14452 style: { 14453 width: "24px", 14454 height: "24px", 14455 borderRadius: "50%", 14456 backgroundColor: validColor, 14457 border: "1px solid #ddd", 14458 cursor: "pointer", 14459 outline: isOpen ? "2px solid #007cba" : "none", 14460 outlineOffset: "2px", 14461 display: "flex", 14462 alignItems: "center", 14463 justifyContent: "center", 14464 padding: 0, 14465 margin: 0 14466 }, 14467 "aria-label": "Open color picker" 14468 } 14469 ) }), 14470 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { style: { padding: "16px" }, children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 14471 Picker, 14472 { 14473 color: w(validColor), 14474 onChange: onColorChange, 14475 enableAlpha: true 14476 } 14477 ) }) 14478 } 14479 ); 14480 }; 14481 function Color({ 14482 data, 14483 field, 14484 onChange, 14485 hideLabelFromVision, 14486 validity 14487 }) { 14488 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 14489 const value = field.getValue({ item: data }) || ""; 14490 const handleColorChange = (0, import_element51.useCallback)( 14491 (colorObject) => { 14492 onChange(setValue({ item: data, value: colorObject.toHex() })); 14493 }, 14494 [data, onChange, setValue] 14495 ); 14496 const handleInputChange = (0, import_element51.useCallback)( 14497 (newValue) => { 14498 onChange(setValue({ item: data, value: newValue || "" })); 14499 }, 14500 [data, onChange, setValue] 14501 ); 14502 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 14503 ValidatedInputControl3, 14504 { 14505 required: !!field.isValid?.required, 14506 customValidity: getCustomValidity(isValid2, validity), 14507 label, 14508 placeholder, 14509 value, 14510 help: description, 14511 onChange: handleInputChange, 14512 hideLabelFromVision, 14513 type: "text", 14514 prefix: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 14515 ColorPicker, 14516 { 14517 color: value, 14518 onColorChange: handleColorChange 14519 } 14520 ) 14521 } 14522 ); 14523 } 14524 14525 // packages/dataviews/build-module/dataform-controls/password.js 14526 var import_components50 = __toESM(require_components()); 14527 var import_element52 = __toESM(require_element()); 14528 var import_i18n35 = __toESM(require_i18n()); 14529 var import_jsx_runtime91 = __toESM(require_jsx_runtime()); 14530 function Password({ 14531 data, 14532 field, 14533 onChange, 14534 hideLabelFromVision, 14535 validity 14536 }) { 14537 const [isVisible2, setIsVisible] = (0, import_element52.useState)(false); 14538 const toggleVisibility = (0, import_element52.useCallback)(() => { 14539 setIsVisible((prev) => !prev); 14540 }, []); 14541 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 14542 ValidatedText, 14543 { 14544 ...{ 14545 data, 14546 field, 14547 onChange, 14548 hideLabelFromVision, 14549 validity, 14550 type: isVisible2 ? "text" : "password", 14551 suffix: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_components50.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 14552 import_components50.Button, 14553 { 14554 icon: isVisible2 ? unseen_default : seen_default, 14555 onClick: toggleVisibility, 14556 size: "small", 14557 label: isVisible2 ? (0, import_i18n35.__)("Hide password") : (0, import_i18n35.__)("Show password") 14558 } 14559 ) }) 14560 } 14561 } 14562 ); 14563 } 14564 14565 // packages/dataviews/build-module/field-types/utils/has-elements.js 14566 function hasElements(field) { 14567 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function"; 14568 } 14569 14570 // packages/dataviews/build-module/dataform-controls/index.js 14571 var import_jsx_runtime92 = __toESM(require_jsx_runtime()); 14572 var FORM_CONTROLS = { 14573 array: ArrayControl, 14574 checkbox: Checkbox, 14575 color: Color, 14576 datetime: DateTime, 14577 date: DateControl, 14578 email: Email, 14579 telephone: Telephone, 14580 url: Url, 14581 integer: Integer, 14582 number: Number2, 14583 password: Password, 14584 radio: Radio, 14585 select: Select, 14586 text: Text2, 14587 toggle: Toggle, 14588 textarea: Textarea, 14589 toggleGroup: ToggleGroup 14590 }; 14591 function isEditConfig(value) { 14592 return value && typeof value === "object" && typeof value.control === "string"; 14593 } 14594 function createConfiguredControl(config) { 14595 const { control, ...controlConfig } = config; 14596 const BaseControlType = getControlByType(control); 14597 if (BaseControlType === null) { 14598 return null; 14599 } 14600 return function ConfiguredControl(props) { 14601 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(BaseControlType, { ...props, config: controlConfig }); 14602 }; 14603 } 14604 function getControl(field, fallback) { 14605 if (typeof field.Edit === "function") { 14606 return field.Edit; 14607 } 14608 if (typeof field.Edit === "string") { 14609 return getControlByType(field.Edit); 14610 } 14611 if (isEditConfig(field.Edit)) { 14612 return createConfiguredControl(field.Edit); 14613 } 14614 if (hasElements(field) && field.type !== "array") { 14615 return getControlByType("select"); 14616 } 14617 if (fallback === null) { 14618 return null; 14619 } 14620 return getControlByType(fallback); 14621 } 14622 function getControlByType(type) { 14623 if (Object.keys(FORM_CONTROLS).includes(type)) { 14624 return FORM_CONTROLS[type]; 14625 } 14626 return null; 14627 } 14628 14629 // packages/dataviews/build-module/field-types/utils/get-filter-by.js 14630 function getFilterBy(field, defaultOperators, validOperators) { 14631 if (field.filterBy === false) { 14632 return false; 14633 } 14634 const operators = field.filterBy?.operators?.filter( 14635 (op) => validOperators.includes(op) 14636 ) ?? defaultOperators; 14637 if (operators.length === 0) { 14638 return false; 14639 } 14640 return { 14641 isPrimary: !!field.filterBy?.isPrimary, 14642 operators 14643 }; 14644 } 14645 var get_filter_by_default = getFilterBy; 14646 14647 // packages/dataviews/build-module/field-types/utils/get-value-from-id.js 14648 var getValueFromId = (id) => ({ item }) => { 14649 const path = id.split("."); 14650 let value = item; 14651 for (const segment of path) { 14652 if (value.hasOwnProperty(segment)) { 14653 value = value[segment]; 14654 } else { 14655 value = void 0; 14656 } 14657 } 14658 return value; 14659 }; 14660 var get_value_from_id_default = getValueFromId; 14661 14662 // packages/dataviews/build-module/field-types/utils/set-value-from-id.js 14663 var setValueFromId = (id) => ({ value }) => { 14664 const path = id.split("."); 14665 const result = {}; 14666 let current = result; 14667 for (const segment of path.slice(0, -1)) { 14668 current[segment] = {}; 14669 current = current[segment]; 14670 } 14671 current[path.at(-1)] = value; 14672 return result; 14673 }; 14674 var set_value_from_id_default = setValueFromId; 14675 14676 // packages/dataviews/build-module/field-types/email.js 14677 var import_i18n36 = __toESM(require_i18n()); 14678 14679 // packages/dataviews/build-module/field-types/utils/render-from-elements.js 14680 function RenderFromElements({ 14681 item, 14682 field 14683 }) { 14684 const { elements, isLoading } = useElements({ 14685 elements: field.elements, 14686 getElements: field.getElements 14687 }); 14688 const value = field.getValue({ item }); 14689 if (isLoading) { 14690 return value; 14691 } 14692 if (elements.length === 0) { 14693 return value; 14694 } 14695 return elements?.find((element) => element.value === value)?.label || field.getValue({ item }); 14696 } 14697 14698 // packages/dataviews/build-module/field-types/utils/render-default.js 14699 var import_jsx_runtime93 = __toESM(require_jsx_runtime()); 14700 function render({ 14701 item, 14702 field 14703 }) { 14704 if (field.hasElements) { 14705 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(RenderFromElements, { item, field }); 14706 } 14707 return field.getValueFormatted({ item, field }); 14708 } 14709 14710 // packages/dataviews/build-module/field-types/utils/sort-text.js 14711 var sort_text_default = (a2, b2, direction) => { 14712 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2); 14713 }; 14714 14715 // packages/dataviews/build-module/field-types/utils/is-valid-required.js 14716 function isValidRequired(item, field) { 14717 const value = field.getValue({ item }); 14718 return ![void 0, "", null].includes(value); 14719 } 14720 14721 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.js 14722 function isValidMinLength(item, field) { 14723 if (typeof field.isValid.minLength?.constraint !== "number") { 14724 return false; 14725 } 14726 const value = field.getValue({ item }); 14727 if ([void 0, "", null].includes(value)) { 14728 return true; 14729 } 14730 return String(value).length >= field.isValid.minLength.constraint; 14731 } 14732 14733 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.js 14734 function isValidMaxLength(item, field) { 14735 if (typeof field.isValid.maxLength?.constraint !== "number") { 14736 return false; 14737 } 14738 const value = field.getValue({ item }); 14739 if ([void 0, "", null].includes(value)) { 14740 return true; 14741 } 14742 return String(value).length <= field.isValid.maxLength.constraint; 14743 } 14744 14745 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.js 14746 function isValidPattern(item, field) { 14747 if (field.isValid.pattern?.constraint === void 0) { 14748 return true; 14749 } 14750 try { 14751 const regexp = new RegExp(field.isValid.pattern.constraint); 14752 const value = field.getValue({ item }); 14753 if ([void 0, "", null].includes(value)) { 14754 return true; 14755 } 14756 return regexp.test(String(value)); 14757 } catch { 14758 return false; 14759 } 14760 } 14761 14762 // packages/dataviews/build-module/field-types/utils/is-valid-elements.js 14763 function isValidElements(item, field) { 14764 const elements = field.elements ?? []; 14765 const validValues = elements.map((el) => el.value); 14766 if (validValues.length === 0) { 14767 return true; 14768 } 14769 const value = field.getValue({ item }); 14770 return [].concat(value).every((v2) => validValues.includes(v2)); 14771 } 14772 14773 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.js 14774 function getValueFormatted({ 14775 item, 14776 field 14777 }) { 14778 return field.getValue({ item }); 14779 } 14780 var get_value_formatted_default_default = getValueFormatted; 14781 14782 // packages/dataviews/build-module/field-types/email.js 14783 var emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; 14784 function isValidCustom(item, field) { 14785 const value = field.getValue({ item }); 14786 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) { 14787 return (0, import_i18n36.__)("Value must be a valid email address."); 14788 } 14789 return null; 14790 } 14791 var email_default = { 14792 type: "email", 14793 render, 14794 Edit: "email", 14795 sort: sort_text_default, 14796 enableSorting: true, 14797 enableGlobalSearch: false, 14798 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 14799 validOperators: [ 14800 OPERATOR_IS, 14801 OPERATOR_IS_NOT, 14802 OPERATOR_CONTAINS, 14803 OPERATOR_NOT_CONTAINS, 14804 OPERATOR_STARTS_WITH, 14805 // Multiple selection 14806 OPERATOR_IS_ANY, 14807 OPERATOR_IS_NONE, 14808 OPERATOR_IS_ALL, 14809 OPERATOR_IS_NOT_ALL 14810 ], 14811 format: {}, 14812 getValueFormatted: get_value_formatted_default_default, 14813 validate: { 14814 required: isValidRequired, 14815 pattern: isValidPattern, 14816 minLength: isValidMinLength, 14817 maxLength: isValidMaxLength, 14818 elements: isValidElements, 14819 custom: isValidCustom 14820 } 14821 }; 14822 14823 // packages/dataviews/build-module/field-types/integer.js 14824 var import_i18n37 = __toESM(require_i18n()); 14825 14826 // packages/dataviews/build-module/field-types/utils/sort-number.js 14827 var sort_number_default = (a2, b2, direction) => { 14828 return direction === "asc" ? a2 - b2 : b2 - a2; 14829 }; 14830 14831 // packages/dataviews/build-module/field-types/utils/is-valid-min.js 14832 function isValidMin(item, field) { 14833 if (typeof field.isValid.min?.constraint !== "number") { 14834 return false; 14835 } 14836 const value = field.getValue({ item }); 14837 if ([void 0, "", null].includes(value)) { 14838 return true; 14839 } 14840 return Number(value) >= field.isValid.min.constraint; 14841 } 14842 14843 // packages/dataviews/build-module/field-types/utils/is-valid-max.js 14844 function isValidMax(item, field) { 14845 if (typeof field.isValid.max?.constraint !== "number") { 14846 return false; 14847 } 14848 const value = field.getValue({ item }); 14849 if ([void 0, "", null].includes(value)) { 14850 return true; 14851 } 14852 return Number(value) <= field.isValid.max.constraint; 14853 } 14854 14855 // packages/dataviews/build-module/field-types/integer.js 14856 var format2 = { 14857 separatorThousand: "," 14858 }; 14859 function getValueFormatted2({ 14860 item, 14861 field 14862 }) { 14863 let value = field.getValue({ item }); 14864 if (value === null || value === void 0) { 14865 return ""; 14866 } 14867 value = Number(value); 14868 if (!Number.isFinite(value)) { 14869 return String(value); 14870 } 14871 let formatInteger; 14872 if (field.type !== "integer") { 14873 formatInteger = format2; 14874 } else { 14875 formatInteger = field.format; 14876 } 14877 const { separatorThousand } = formatInteger; 14878 const integerValue = Math.trunc(value); 14879 if (!separatorThousand) { 14880 return String(integerValue); 14881 } 14882 return String(integerValue).replace( 14883 /\B(?=(\d{3})+(?!\d))/g, 14884 separatorThousand 14885 ); 14886 } 14887 function isValidCustom2(item, field) { 14888 const value = field.getValue({ item }); 14889 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) { 14890 return (0, import_i18n37.__)("Value must be an integer."); 14891 } 14892 return null; 14893 } 14894 var integer_default = { 14895 type: "integer", 14896 render, 14897 Edit: "integer", 14898 sort: sort_number_default, 14899 enableSorting: true, 14900 enableGlobalSearch: false, 14901 defaultOperators: [ 14902 OPERATOR_IS, 14903 OPERATOR_IS_NOT, 14904 OPERATOR_LESS_THAN, 14905 OPERATOR_GREATER_THAN, 14906 OPERATOR_LESS_THAN_OR_EQUAL, 14907 OPERATOR_GREATER_THAN_OR_EQUAL, 14908 OPERATOR_BETWEEN 14909 ], 14910 validOperators: [ 14911 // Single-selection 14912 OPERATOR_IS, 14913 OPERATOR_IS_NOT, 14914 OPERATOR_LESS_THAN, 14915 OPERATOR_GREATER_THAN, 14916 OPERATOR_LESS_THAN_OR_EQUAL, 14917 OPERATOR_GREATER_THAN_OR_EQUAL, 14918 OPERATOR_BETWEEN, 14919 // Multiple-selection 14920 OPERATOR_IS_ANY, 14921 OPERATOR_IS_NONE, 14922 OPERATOR_IS_ALL, 14923 OPERATOR_IS_NOT_ALL 14924 ], 14925 format: format2, 14926 getValueFormatted: getValueFormatted2, 14927 validate: { 14928 required: isValidRequired, 14929 min: isValidMin, 14930 max: isValidMax, 14931 elements: isValidElements, 14932 custom: isValidCustom2 14933 } 14934 }; 14935 14936 // packages/dataviews/build-module/field-types/number.js 14937 var import_i18n38 = __toESM(require_i18n()); 14938 var format3 = { 14939 separatorThousand: ",", 14940 separatorDecimal: ".", 14941 decimals: 2 14942 }; 14943 function getValueFormatted3({ 14944 item, 14945 field 14946 }) { 14947 let value = field.getValue({ item }); 14948 if (value === null || value === void 0) { 14949 return ""; 14950 } 14951 value = Number(value); 14952 if (!Number.isFinite(value)) { 14953 return String(value); 14954 } 14955 let formatNumber; 14956 if (field.type !== "number") { 14957 formatNumber = format3; 14958 } else { 14959 formatNumber = field.format; 14960 } 14961 const { separatorThousand, separatorDecimal, decimals } = formatNumber; 14962 const fixedValue = value.toFixed(decimals); 14963 const [integerPart, decimalPart] = fixedValue.split("."); 14964 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart; 14965 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart; 14966 } 14967 function isEmpty2(value) { 14968 return value === "" || value === void 0 || value === null; 14969 } 14970 function isValidCustom3(item, field) { 14971 const value = field.getValue({ item }); 14972 if (!isEmpty2(value) && !Number.isFinite(value)) { 14973 return (0, import_i18n38.__)("Value must be a number."); 14974 } 14975 return null; 14976 } 14977 var number_default = { 14978 type: "number", 14979 render, 14980 Edit: "number", 14981 sort: sort_number_default, 14982 enableSorting: true, 14983 enableGlobalSearch: false, 14984 defaultOperators: [ 14985 OPERATOR_IS, 14986 OPERATOR_IS_NOT, 14987 OPERATOR_LESS_THAN, 14988 OPERATOR_GREATER_THAN, 14989 OPERATOR_LESS_THAN_OR_EQUAL, 14990 OPERATOR_GREATER_THAN_OR_EQUAL, 14991 OPERATOR_BETWEEN 14992 ], 14993 validOperators: [ 14994 // Single-selection 14995 OPERATOR_IS, 14996 OPERATOR_IS_NOT, 14997 OPERATOR_LESS_THAN, 14998 OPERATOR_GREATER_THAN, 14999 OPERATOR_LESS_THAN_OR_EQUAL, 15000 OPERATOR_GREATER_THAN_OR_EQUAL, 15001 OPERATOR_BETWEEN, 15002 // Multiple-selection 15003 OPERATOR_IS_ANY, 15004 OPERATOR_IS_NONE, 15005 OPERATOR_IS_ALL, 15006 OPERATOR_IS_NOT_ALL 15007 ], 15008 format: format3, 15009 getValueFormatted: getValueFormatted3, 15010 validate: { 15011 required: isValidRequired, 15012 min: isValidMin, 15013 max: isValidMax, 15014 elements: isValidElements, 15015 custom: isValidCustom3 15016 } 15017 }; 15018 15019 // packages/dataviews/build-module/field-types/text.js 15020 var text_default = { 15021 type: "text", 15022 render, 15023 Edit: "text", 15024 sort: sort_text_default, 15025 enableSorting: true, 15026 enableGlobalSearch: false, 15027 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15028 validOperators: [ 15029 // Single selection 15030 OPERATOR_IS, 15031 OPERATOR_IS_NOT, 15032 OPERATOR_CONTAINS, 15033 OPERATOR_NOT_CONTAINS, 15034 OPERATOR_STARTS_WITH, 15035 // Multiple selection 15036 OPERATOR_IS_ANY, 15037 OPERATOR_IS_NONE, 15038 OPERATOR_IS_ALL, 15039 OPERATOR_IS_NOT_ALL 15040 ], 15041 format: {}, 15042 getValueFormatted: get_value_formatted_default_default, 15043 validate: { 15044 required: isValidRequired, 15045 pattern: isValidPattern, 15046 minLength: isValidMinLength, 15047 maxLength: isValidMaxLength, 15048 elements: isValidElements 15049 } 15050 }; 15051 15052 // packages/dataviews/build-module/field-types/datetime.js 15053 var import_date5 = __toESM(require_date()); 15054 var format4 = { 15055 datetime: (0, import_date5.getSettings)().formats.datetime, 15056 weekStartsOn: (0, import_date5.getSettings)().l10n.startOfWeek 15057 }; 15058 function getValueFormatted4({ 15059 item, 15060 field 15061 }) { 15062 const value = field.getValue({ item }); 15063 if (["", void 0, null].includes(value)) { 15064 return ""; 15065 } 15066 let formatDatetime; 15067 if (field.type !== "datetime") { 15068 formatDatetime = format4; 15069 } else { 15070 formatDatetime = field.format; 15071 } 15072 return (0, import_date5.dateI18n)(formatDatetime.datetime, (0, import_date5.getDate)(value)); 15073 } 15074 var sort = (a2, b2, direction) => { 15075 const timeA = new Date(a2).getTime(); 15076 const timeB = new Date(b2).getTime(); 15077 return direction === "asc" ? timeA - timeB : timeB - timeA; 15078 }; 15079 var datetime_default = { 15080 type: "datetime", 15081 render, 15082 Edit: "datetime", 15083 sort, 15084 enableSorting: true, 15085 enableGlobalSearch: false, 15086 defaultOperators: [ 15087 OPERATOR_ON, 15088 OPERATOR_NOT_ON, 15089 OPERATOR_BEFORE, 15090 OPERATOR_AFTER, 15091 OPERATOR_BEFORE_INC, 15092 OPERATOR_AFTER_INC, 15093 OPERATOR_IN_THE_PAST, 15094 OPERATOR_OVER 15095 ], 15096 validOperators: [ 15097 OPERATOR_ON, 15098 OPERATOR_NOT_ON, 15099 OPERATOR_BEFORE, 15100 OPERATOR_AFTER, 15101 OPERATOR_BEFORE_INC, 15102 OPERATOR_AFTER_INC, 15103 OPERATOR_IN_THE_PAST, 15104 OPERATOR_OVER 15105 ], 15106 format: format4, 15107 getValueFormatted: getValueFormatted4, 15108 validate: { 15109 required: isValidRequired, 15110 elements: isValidElements 15111 } 15112 }; 15113 15114 // packages/dataviews/build-module/field-types/date.js 15115 var import_date6 = __toESM(require_date()); 15116 var format5 = { 15117 date: (0, import_date6.getSettings)().formats.date, 15118 weekStartsOn: (0, import_date6.getSettings)().l10n.startOfWeek 15119 }; 15120 function getValueFormatted5({ 15121 item, 15122 field 15123 }) { 15124 const value = field.getValue({ item }); 15125 if (["", void 0, null].includes(value)) { 15126 return ""; 15127 } 15128 let formatDate2; 15129 if (field.type !== "date") { 15130 formatDate2 = format5; 15131 } else { 15132 formatDate2 = field.format; 15133 } 15134 return (0, import_date6.dateI18n)(formatDate2.date, (0, import_date6.getDate)(value)); 15135 } 15136 var sort2 = (a2, b2, direction) => { 15137 const timeA = new Date(a2).getTime(); 15138 const timeB = new Date(b2).getTime(); 15139 return direction === "asc" ? timeA - timeB : timeB - timeA; 15140 }; 15141 var date_default = { 15142 type: "date", 15143 render, 15144 Edit: "date", 15145 sort: sort2, 15146 enableSorting: true, 15147 enableGlobalSearch: false, 15148 defaultOperators: [ 15149 OPERATOR_ON, 15150 OPERATOR_NOT_ON, 15151 OPERATOR_BEFORE, 15152 OPERATOR_AFTER, 15153 OPERATOR_BEFORE_INC, 15154 OPERATOR_AFTER_INC, 15155 OPERATOR_IN_THE_PAST, 15156 OPERATOR_OVER, 15157 OPERATOR_BETWEEN 15158 ], 15159 validOperators: [ 15160 OPERATOR_ON, 15161 OPERATOR_NOT_ON, 15162 OPERATOR_BEFORE, 15163 OPERATOR_AFTER, 15164 OPERATOR_BEFORE_INC, 15165 OPERATOR_AFTER_INC, 15166 OPERATOR_IN_THE_PAST, 15167 OPERATOR_OVER, 15168 OPERATOR_BETWEEN 15169 ], 15170 format: format5, 15171 getValueFormatted: getValueFormatted5, 15172 validate: { 15173 required: isValidRequired, 15174 elements: isValidElements 15175 } 15176 }; 15177 15178 // packages/dataviews/build-module/field-types/boolean.js 15179 var import_i18n39 = __toESM(require_i18n()); 15180 15181 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.js 15182 function isValidRequiredForBool(item, field) { 15183 const value = field.getValue({ item }); 15184 return value === true; 15185 } 15186 15187 // packages/dataviews/build-module/field-types/boolean.js 15188 function getValueFormatted6({ 15189 item, 15190 field 15191 }) { 15192 const value = field.getValue({ item }); 15193 if (value === true) { 15194 return (0, import_i18n39.__)("True"); 15195 } 15196 if (value === false) { 15197 return (0, import_i18n39.__)("False"); 15198 } 15199 return ""; 15200 } 15201 function isValidCustom4(item, field) { 15202 const value = field.getValue({ item }); 15203 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) { 15204 return (0, import_i18n39.__)("Value must be true, false, or undefined"); 15205 } 15206 return null; 15207 } 15208 var sort3 = (a2, b2, direction) => { 15209 const boolA = Boolean(a2); 15210 const boolB = Boolean(b2); 15211 if (boolA === boolB) { 15212 return 0; 15213 } 15214 if (direction === "asc") { 15215 return boolA ? 1 : -1; 15216 } 15217 return boolA ? -1 : 1; 15218 }; 15219 var boolean_default = { 15220 type: "boolean", 15221 render, 15222 Edit: "checkbox", 15223 sort: sort3, 15224 validate: { 15225 required: isValidRequiredForBool, 15226 elements: isValidElements, 15227 custom: isValidCustom4 15228 }, 15229 enableSorting: true, 15230 enableGlobalSearch: false, 15231 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 15232 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 15233 format: {}, 15234 getValueFormatted: getValueFormatted6 15235 }; 15236 15237 // packages/dataviews/build-module/field-types/media.js 15238 var media_default = { 15239 type: "media", 15240 render: () => null, 15241 Edit: null, 15242 sort: () => 0, 15243 enableSorting: false, 15244 enableGlobalSearch: false, 15245 defaultOperators: [], 15246 validOperators: [], 15247 format: {}, 15248 getValueFormatted: get_value_formatted_default_default, 15249 // cannot validate any constraint, so 15250 // the only available validation for the field author 15251 // would be providing a custom validator. 15252 validate: {} 15253 }; 15254 15255 // packages/dataviews/build-module/field-types/array.js 15256 var import_i18n40 = __toESM(require_i18n()); 15257 15258 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.js 15259 function isValidRequiredForArray(item, field) { 15260 const value = field.getValue({ item }); 15261 return Array.isArray(value) && value.length > 0 && value.every( 15262 (element) => ![void 0, "", null].includes(element) 15263 ); 15264 } 15265 15266 // packages/dataviews/build-module/field-types/array.js 15267 function getValueFormatted7({ 15268 item, 15269 field 15270 }) { 15271 const value = field.getValue({ item }); 15272 const arr = Array.isArray(value) ? value : []; 15273 return arr.join(", "); 15274 } 15275 function render2({ item, field }) { 15276 return getValueFormatted7({ item, field }); 15277 } 15278 function isValidCustom5(item, field) { 15279 const value = field.getValue({ item }); 15280 if (![void 0, "", null].includes(value) && !Array.isArray(value)) { 15281 return (0, import_i18n40.__)("Value must be an array."); 15282 } 15283 if (!value.every((v2) => typeof v2 === "string")) { 15284 return (0, import_i18n40.__)("Every value must be a string."); 15285 } 15286 return null; 15287 } 15288 var sort4 = (a2, b2, direction) => { 15289 const arrA = Array.isArray(a2) ? a2 : []; 15290 const arrB = Array.isArray(b2) ? b2 : []; 15291 if (arrA.length !== arrB.length) { 15292 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length; 15293 } 15294 const joinedA = arrA.join(","); 15295 const joinedB = arrB.join(","); 15296 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA); 15297 }; 15298 var array_default = { 15299 type: "array", 15300 render: render2, 15301 Edit: "array", 15302 sort: sort4, 15303 enableSorting: true, 15304 enableGlobalSearch: false, 15305 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15306 validOperators: [ 15307 OPERATOR_IS_ANY, 15308 OPERATOR_IS_NONE, 15309 OPERATOR_IS_ALL, 15310 OPERATOR_IS_NOT_ALL 15311 ], 15312 format: {}, 15313 getValueFormatted: getValueFormatted7, 15314 validate: { 15315 required: isValidRequiredForArray, 15316 elements: isValidElements, 15317 custom: isValidCustom5 15318 } 15319 }; 15320 15321 // packages/dataviews/build-module/field-types/password.js 15322 function getValueFormatted8({ 15323 item, 15324 field 15325 }) { 15326 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : ""; 15327 } 15328 var password_default = { 15329 type: "password", 15330 render, 15331 Edit: "password", 15332 sort: () => 0, 15333 // Passwords should not be sortable for security reasons 15334 enableSorting: false, 15335 enableGlobalSearch: false, 15336 defaultOperators: [], 15337 validOperators: [], 15338 format: {}, 15339 getValueFormatted: getValueFormatted8, 15340 validate: { 15341 required: isValidRequired, 15342 pattern: isValidPattern, 15343 minLength: isValidMinLength, 15344 maxLength: isValidMaxLength, 15345 elements: isValidElements 15346 } 15347 }; 15348 15349 // packages/dataviews/build-module/field-types/telephone.js 15350 var telephone_default = { 15351 type: "telephone", 15352 render, 15353 Edit: "telephone", 15354 sort: sort_text_default, 15355 enableSorting: true, 15356 enableGlobalSearch: false, 15357 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15358 validOperators: [ 15359 OPERATOR_IS, 15360 OPERATOR_IS_NOT, 15361 OPERATOR_CONTAINS, 15362 OPERATOR_NOT_CONTAINS, 15363 OPERATOR_STARTS_WITH, 15364 // Multiple selection 15365 OPERATOR_IS_ANY, 15366 OPERATOR_IS_NONE, 15367 OPERATOR_IS_ALL, 15368 OPERATOR_IS_NOT_ALL 15369 ], 15370 format: {}, 15371 getValueFormatted: get_value_formatted_default_default, 15372 validate: { 15373 required: isValidRequired, 15374 pattern: isValidPattern, 15375 minLength: isValidMinLength, 15376 maxLength: isValidMaxLength, 15377 elements: isValidElements 15378 } 15379 }; 15380 15381 // packages/dataviews/build-module/field-types/color.js 15382 var import_i18n41 = __toESM(require_i18n()); 15383 var import_jsx_runtime94 = __toESM(require_jsx_runtime()); 15384 function render3({ item, field }) { 15385 if (field.hasElements) { 15386 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(RenderFromElements, { item, field }); 15387 } 15388 const value = get_value_formatted_default_default({ item, field }); 15389 if (!value || !w(value).isValid()) { 15390 return value; 15391 } 15392 return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [ 15393 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)( 15394 "div", 15395 { 15396 style: { 15397 width: "16px", 15398 height: "16px", 15399 borderRadius: "50%", 15400 backgroundColor: value, 15401 border: "1px solid #ddd", 15402 flexShrink: 0 15403 } 15404 } 15405 ), 15406 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("span", { children: value }) 15407 ] }); 15408 } 15409 function isValidCustom6(item, field) { 15410 const value = field.getValue({ item }); 15411 if (![void 0, "", null].includes(value) && !w(value).isValid()) { 15412 return (0, import_i18n41.__)("Value must be a valid color."); 15413 } 15414 return null; 15415 } 15416 var sort5 = (a2, b2, direction) => { 15417 const colorA = w(a2); 15418 const colorB = w(b2); 15419 if (!colorA.isValid() && !colorB.isValid()) { 15420 return 0; 15421 } 15422 if (!colorA.isValid()) { 15423 return direction === "asc" ? 1 : -1; 15424 } 15425 if (!colorB.isValid()) { 15426 return direction === "asc" ? -1 : 1; 15427 } 15428 const hslA = colorA.toHsl(); 15429 const hslB = colorB.toHsl(); 15430 if (hslA.h !== hslB.h) { 15431 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h; 15432 } 15433 if (hslA.s !== hslB.s) { 15434 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s; 15435 } 15436 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l; 15437 }; 15438 var color_default = { 15439 type: "color", 15440 render: render3, 15441 Edit: "color", 15442 sort: sort5, 15443 enableSorting: true, 15444 enableGlobalSearch: false, 15445 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15446 validOperators: [ 15447 OPERATOR_IS, 15448 OPERATOR_IS_NOT, 15449 OPERATOR_IS_ANY, 15450 OPERATOR_IS_NONE 15451 ], 15452 format: {}, 15453 getValueFormatted: get_value_formatted_default_default, 15454 validate: { 15455 required: isValidRequired, 15456 elements: isValidElements, 15457 custom: isValidCustom6 15458 } 15459 }; 15460 15461 // packages/dataviews/build-module/field-types/url.js 15462 var url_default = { 15463 type: "url", 15464 render, 15465 Edit: "url", 15466 sort: sort_text_default, 15467 enableSorting: true, 15468 enableGlobalSearch: false, 15469 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15470 validOperators: [ 15471 OPERATOR_IS, 15472 OPERATOR_IS_NOT, 15473 OPERATOR_CONTAINS, 15474 OPERATOR_NOT_CONTAINS, 15475 OPERATOR_STARTS_WITH, 15476 // Multiple selection 15477 OPERATOR_IS_ANY, 15478 OPERATOR_IS_NONE, 15479 OPERATOR_IS_ALL, 15480 OPERATOR_IS_NOT_ALL 15481 ], 15482 format: {}, 15483 getValueFormatted: get_value_formatted_default_default, 15484 validate: { 15485 required: isValidRequired, 15486 pattern: isValidPattern, 15487 minLength: isValidMinLength, 15488 maxLength: isValidMaxLength, 15489 elements: isValidElements 15490 } 15491 }; 15492 15493 // packages/dataviews/build-module/field-types/no-type.js 15494 var sort6 = (a2, b2, direction) => { 15495 if (typeof a2 === "number" && typeof b2 === "number") { 15496 return sort_number_default(a2, b2, direction); 15497 } 15498 return sort_text_default(a2, b2, direction); 15499 }; 15500 var no_type_default = { 15501 // type: no type for this one 15502 render, 15503 Edit: null, 15504 sort: sort6, 15505 enableSorting: true, 15506 enableGlobalSearch: false, 15507 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 15508 validOperators: getAllOperatorNames(), 15509 format: {}, 15510 getValueFormatted: get_value_formatted_default_default, 15511 validate: { 15512 required: isValidRequired, 15513 elements: isValidElements 15514 } 15515 }; 15516 15517 // packages/dataviews/build-module/field-types/utils/get-is-valid.js 15518 function getIsValid(field, fieldType) { 15519 let required; 15520 if (field.isValid?.required === true && fieldType.validate.required !== void 0) { 15521 required = { 15522 constraint: true, 15523 validate: fieldType.validate.required 15524 }; 15525 } 15526 let elements; 15527 if ((field.isValid?.elements === true || // elements is enabled unless the field opts-out 15528 field.isValid?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) { 15529 elements = { 15530 constraint: true, 15531 validate: fieldType.validate.elements 15532 }; 15533 } 15534 let min; 15535 if (typeof field.isValid?.min === "number" && fieldType.validate.min !== void 0) { 15536 min = { 15537 constraint: field.isValid.min, 15538 validate: fieldType.validate.min 15539 }; 15540 } 15541 let max; 15542 if (typeof field.isValid?.max === "number" && fieldType.validate.max !== void 0) { 15543 max = { 15544 constraint: field.isValid.max, 15545 validate: fieldType.validate.max 15546 }; 15547 } 15548 let minLength; 15549 if (typeof field.isValid?.minLength === "number" && fieldType.validate.minLength !== void 0) { 15550 minLength = { 15551 constraint: field.isValid.minLength, 15552 validate: fieldType.validate.minLength 15553 }; 15554 } 15555 let maxLength; 15556 if (typeof field.isValid?.maxLength === "number" && fieldType.validate.maxLength !== void 0) { 15557 maxLength = { 15558 constraint: field.isValid.maxLength, 15559 validate: fieldType.validate.maxLength 15560 }; 15561 } 15562 let pattern; 15563 if (field.isValid?.pattern !== void 0 && fieldType.validate.pattern !== void 0) { 15564 pattern = { 15565 constraint: field.isValid?.pattern, 15566 validate: fieldType.validate.pattern 15567 }; 15568 } 15569 const custom = field.isValid?.custom ?? fieldType.validate.custom; 15570 return { 15571 required, 15572 elements, 15573 min, 15574 max, 15575 minLength, 15576 maxLength, 15577 pattern, 15578 custom 15579 }; 15580 } 15581 15582 // packages/dataviews/build-module/field-types/utils/get-format.js 15583 function getFormat(field, fieldType) { 15584 return { 15585 ...fieldType.format, 15586 ...field.format 15587 }; 15588 } 15589 var get_format_default = getFormat; 15590 15591 // packages/dataviews/build-module/field-types/index.js 15592 function getFieldTypeByName(type) { 15593 const found = [ 15594 email_default, 15595 integer_default, 15596 number_default, 15597 text_default, 15598 datetime_default, 15599 date_default, 15600 boolean_default, 15601 media_default, 15602 array_default, 15603 password_default, 15604 telephone_default, 15605 color_default, 15606 url_default 15607 ].find((fieldType) => fieldType?.type === type); 15608 if (!!found) { 15609 return found; 15610 } 15611 return no_type_default; 15612 } 15613 function normalizeFields(fields) { 15614 return fields.map((field) => { 15615 const fieldType = getFieldTypeByName(field.type); 15616 const getValue = field.getValue || get_value_from_id_default(field.id); 15617 const sort7 = function(a2, b2, direction) { 15618 const aValue = getValue({ item: a2 }); 15619 const bValue = getValue({ item: b2 }); 15620 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction); 15621 }; 15622 return { 15623 id: field.id, 15624 label: field.label || field.id, 15625 header: field.header || field.label || field.id, 15626 description: field.description, 15627 placeholder: field.placeholder, 15628 getValue, 15629 setValue: field.setValue || set_value_from_id_default(field.id), 15630 elements: field.elements, 15631 getElements: field.getElements, 15632 hasElements: hasElements(field), 15633 isVisible: field.isVisible, 15634 enableHiding: field.enableHiding ?? true, 15635 readOnly: field.readOnly ?? false, 15636 // The type provides defaults for the following props 15637 type: fieldType.type, 15638 render: field.render ?? fieldType.render, 15639 Edit: getControl(field, fieldType.Edit), 15640 sort: sort7, 15641 enableSorting: field.enableSorting ?? fieldType.enableSorting, 15642 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch, 15643 isValid: getIsValid(field, fieldType), 15644 filterBy: get_filter_by_default( 15645 field, 15646 fieldType.defaultOperators, 15647 fieldType.validOperators 15648 ), 15649 format: get_format_default(field, fieldType), 15650 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted 15651 }; 15652 }); 15653 } 15654 15655 // packages/dataviews/build-module/components/dataviews/index.js 15656 var import_jsx_runtime95 = __toESM(require_jsx_runtime()); 15657 var defaultGetItemId = (item) => item.id; 15658 var defaultIsItemClickable = () => true; 15659 var EMPTY_ARRAY5 = []; 15660 var dataViewsLayouts = VIEW_LAYOUTS.filter( 15661 (viewLayout) => !viewLayout.isPicker 15662 ); 15663 function DefaultUI({ 15664 header, 15665 search = true, 15666 searchLabel = void 0 15667 }) { 15668 return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_jsx_runtime95.Fragment, { children: [ 15669 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)( 15670 import_components51.__experimentalHStack, 15671 { 15672 alignment: "top", 15673 justify: "space-between", 15674 className: "dataviews__view-actions", 15675 spacing: 1, 15676 children: [ 15677 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)( 15678 import_components51.__experimentalHStack, 15679 { 15680 justify: "start", 15681 expanded: false, 15682 className: "dataviews__search", 15683 children: [ 15684 search && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(dataviews_search_default, { label: searchLabel }), 15685 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(toggle_default, {}) 15686 ] 15687 } 15688 ), 15689 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)( 15690 import_components51.__experimentalHStack, 15691 { 15692 spacing: 1, 15693 expanded: false, 15694 style: { flexShrink: 0 }, 15695 children: [ 15696 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(dataviews_view_config_default, {}), 15697 header 15698 ] 15699 } 15700 ) 15701 ] 15702 } 15703 ), 15704 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }), 15705 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(DataViewsLayout, {}), 15706 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(DataViewsFooter, {}) 15707 ] }); 15708 } 15709 function DataViews({ 15710 view, 15711 onChangeView, 15712 fields, 15713 search = true, 15714 searchLabel = void 0, 15715 actions = EMPTY_ARRAY5, 15716 data, 15717 getItemId: getItemId2 = defaultGetItemId, 15718 getItemLevel, 15719 isLoading = false, 15720 paginationInfo, 15721 defaultLayouts: defaultLayoutsProperty, 15722 selection: selectionProperty, 15723 onChangeSelection, 15724 onClickItem, 15725 renderItemLink, 15726 isItemClickable = defaultIsItemClickable, 15727 header, 15728 children, 15729 config = { perPageSizes: [10, 20, 50, 100] }, 15730 empty 15731 }) { 15732 const { infiniteScrollHandler } = paginationInfo; 15733 const containerRef = (0, import_element53.useRef)(null); 15734 const [containerWidth, setContainerWidth] = (0, import_element53.useState)(0); 15735 const resizeObserverRef = (0, import_compose11.useResizeObserver)( 15736 (resizeObserverEntries) => { 15737 setContainerWidth( 15738 resizeObserverEntries[0].borderBoxSize[0].inlineSize 15739 ); 15740 }, 15741 { box: "border-box" } 15742 ); 15743 const [selectionState, setSelectionState] = (0, import_element53.useState)([]); 15744 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0; 15745 const selection = isUncontrolled ? selectionState : selectionProperty; 15746 const [openedFilter, setOpenedFilter] = (0, import_element53.useState)(null); 15747 function setSelectionWithChange(value) { 15748 const newValue = typeof value === "function" ? value(selection) : value; 15749 if (isUncontrolled) { 15750 setSelectionState(newValue); 15751 } 15752 if (onChangeSelection) { 15753 onChangeSelection(newValue); 15754 } 15755 } 15756 const _fields = (0, import_element53.useMemo)(() => normalizeFields(fields), [fields]); 15757 const _selection = (0, import_element53.useMemo)(() => { 15758 return selection.filter( 15759 (id) => data.some((item) => getItemId2(item) === id) 15760 ); 15761 }, [selection, data, getItemId2]); 15762 const filters = use_filters_default(_fields, view); 15763 const hasPrimaryOrLockedFilters = (0, import_element53.useMemo)( 15764 () => (filters || []).some( 15765 (filter) => filter.isPrimary || filter.isLocked 15766 ), 15767 [filters] 15768 ); 15769 const [isShowingFilter, setIsShowingFilter] = (0, import_element53.useState)( 15770 hasPrimaryOrLockedFilters 15771 ); 15772 (0, import_element53.useEffect)(() => { 15773 if (hasPrimaryOrLockedFilters && !isShowingFilter) { 15774 setIsShowingFilter(true); 15775 } 15776 }, [hasPrimaryOrLockedFilters, isShowingFilter]); 15777 (0, import_element53.useEffect)(() => { 15778 if (!view.infiniteScrollEnabled || !containerRef.current) { 15779 return; 15780 } 15781 const handleScroll = (0, import_compose11.throttle)((event) => { 15782 const target = event.target; 15783 const scrollTop = target.scrollTop; 15784 const scrollHeight = target.scrollHeight; 15785 const clientHeight = target.clientHeight; 15786 if (scrollTop + clientHeight >= scrollHeight - 100) { 15787 infiniteScrollHandler?.(); 15788 } 15789 }, 100); 15790 const container = containerRef.current; 15791 container.addEventListener("scroll", handleScroll); 15792 return () => { 15793 container.removeEventListener("scroll", handleScroll); 15794 handleScroll.cancel(); 15795 }; 15796 }, [infiniteScrollHandler, view.infiniteScrollEnabled]); 15797 const defaultLayouts = (0, import_element53.useMemo)( 15798 () => Object.fromEntries( 15799 Object.entries(defaultLayoutsProperty).filter( 15800 ([layoutType]) => { 15801 return dataViewsLayouts.some( 15802 (viewLayout) => viewLayout.type === layoutType 15803 ); 15804 } 15805 ) 15806 ), 15807 [defaultLayoutsProperty] 15808 ); 15809 if (!defaultLayouts[view.type]) { 15810 return null; 15811 } 15812 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 15813 dataviews_context_default.Provider, 15814 { 15815 value: { 15816 view, 15817 onChangeView, 15818 fields: _fields, 15819 actions, 15820 data, 15821 isLoading, 15822 paginationInfo, 15823 selection: _selection, 15824 onChangeSelection: setSelectionWithChange, 15825 openedFilter, 15826 setOpenedFilter, 15827 getItemId: getItemId2, 15828 getItemLevel, 15829 isItemClickable, 15830 onClickItem, 15831 renderItemLink, 15832 containerWidth, 15833 containerRef, 15834 resizeObserverRef, 15835 defaultLayouts, 15836 filters, 15837 isShowingFilter, 15838 setIsShowingFilter, 15839 config, 15840 empty, 15841 hasInfiniteScrollHandler: !!infiniteScrollHandler 15842 }, 15843 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: "dataviews-wrapper", ref: containerRef, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 15844 DefaultUI, 15845 { 15846 header, 15847 search, 15848 searchLabel 15849 } 15850 ) }) 15851 } 15852 ); 15853 } 15854 var DataViewsSubComponents = DataViews; 15855 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter; 15856 DataViewsSubComponents.Filters = filters_default; 15857 DataViewsSubComponents.FiltersToggled = filters_toggled_default; 15858 DataViewsSubComponents.FiltersToggle = toggle_default; 15859 DataViewsSubComponents.Layout = DataViewsLayout; 15860 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu; 15861 DataViewsSubComponents.Pagination = DataViewsPagination; 15862 DataViewsSubComponents.Search = dataviews_search_default; 15863 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown; 15864 DataViewsSubComponents.Footer = DataViewsFooter; 15865 var dataviews_default = DataViewsSubComponents; 15866 15867 // routes/navigation-list/stage.tsx 15868 var import_components53 = __toESM(require_components()); 15869 var import_editor = __toESM(require_editor()); 15870 15871 // routes/lock-unlock.ts 15872 var import_private_apis2 = __toESM(require_private_apis()); 15873 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 15874 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 15875 "@wordpress/routes" 15876 ); 15877 15878 // routes/navigation-list/view-utils.ts 15879 var DEFAULT_VIEW = { 15880 type: "list", 15881 sort: { 15882 field: "date", 15883 direction: "desc" 15884 }, 15885 titleField: "title" 15886 }; 15887 function getDefaultView() { 15888 return DEFAULT_VIEW; 15889 } 15890 15891 // routes/navigation-list/actions/edit-navigation.tsx 15892 var import_i18n42 = __toESM(require_i18n()); 15893 import { useNavigate } from "@wordpress/route"; 15894 function useEditNavigationAction() { 15895 const navigate = useNavigate(); 15896 return { 15897 id: "edit", 15898 label: (0, import_i18n42.__)("Edit"), 15899 isPrimary: true, 15900 icon: pencil_default, 15901 callback: (items) => { 15902 const item = items[0]; 15903 navigate({ 15904 to: `/navigation/edit/$item.id}` 15905 }); 15906 }, 15907 isEligible(item) { 15908 return item.type === "wp_navigation" && String(item.status) !== "trash"; 15909 } 15910 }; 15911 } 15912 15913 // routes/navigation-list/add-navigation.tsx 15914 var import_element54 = __toESM(require_element()); 15915 var import_i18n43 = __toESM(require_i18n()); 15916 var import_core_data = __toESM(require_core_data()); 15917 var import_notices = __toESM(require_notices()); 15918 var import_data8 = __toESM(require_data()); 15919 var import_components52 = __toESM(require_components()); 15920 import { useNavigate as useNavigate2 } from "@wordpress/route"; 15921 var NAVIGATION_POST_TYPE = "wp_navigation"; 15922 var AddNavigationModal = ({ 15923 closeModal 15924 }) => { 15925 const [menuTitle, setMenuTitle] = (0, import_element54.useState)(""); 15926 const [isBusy, setIsBusy] = (0, import_element54.useState)(false); 15927 const navigate = useNavigate2(); 15928 const { saveEntityRecord } = (0, import_data8.useDispatch)(import_core_data.store); 15929 const { createSuccessNotice, createErrorNotice } = (0, import_data8.useDispatch)(import_notices.store); 15930 const handleConfirmAdd = async () => { 15931 if (!menuTitle || !menuTitle.trim()) { 15932 return; 15933 } 15934 const trimmedTitle = menuTitle.trim(); 15935 setIsBusy(true); 15936 try { 15937 const savedRecord = await saveEntityRecord( 15938 "postType", 15939 NAVIGATION_POST_TYPE, 15940 { 15941 title: trimmedTitle, 15942 status: "publish" 15943 }, 15944 { 15945 throwOnError: true 15946 } 15947 ); 15948 if (savedRecord) { 15949 createSuccessNotice( 15950 (0, import_i18n43.__)("Navigation menu created successfully."), 15951 { 15952 type: "snackbar" 15953 } 15954 ); 15955 navigate({ 15956 to: `/navigation/edit/$encodeURIComponent( 15957 savedRecord.id 15958 )}` 15959 }); 15960 } 15961 } catch (error) { 15962 const errorMessage = error instanceof Error ? error.message : "Unknown error"; 15963 createErrorNotice( 15964 (0, import_i18n43.sprintf)( 15965 /* translators: %s: error message describing why the navigation menu could not be created. */ 15966 (0, import_i18n43.__)("Unable to create navigation menu: %s"), 15967 errorMessage 15968 ), 15969 { 15970 type: "snackbar" 15971 } 15972 ); 15973 } 15974 setIsBusy(false); 15975 closeModal?.(); 15976 }; 15977 return /* @__PURE__ */ React.createElement( 15978 import_components52.Modal, 15979 { 15980 title: (0, import_i18n43.__)("Add New Navigation Menu"), 15981 onRequestClose: () => closeModal?.(), 15982 focusOnMount: "firstContentElement", 15983 size: "small" 15984 }, 15985 /* @__PURE__ */ React.createElement( 15986 "form", 15987 { 15988 onSubmit: (event) => { 15989 event.preventDefault(); 15990 handleConfirmAdd(); 15991 } 15992 }, 15993 /* @__PURE__ */ React.createElement(import_components52.__experimentalVStack, { spacing: 4 }, /* @__PURE__ */ React.createElement( 15994 import_components52.TextControl, 15995 { 15996 autoComplete: "off", 15997 value: menuTitle, 15998 onChange: setMenuTitle, 15999 label: (0, import_i18n43.__)("Name"), 16000 placeholder: (0, import_i18n43.__)("Enter menu name"), 16001 disabled: isBusy 16002 } 16003 ), /* @__PURE__ */ React.createElement(import_components52.__experimentalHStack, { justify: "right", spacing: 2 }, /* @__PURE__ */ React.createElement( 16004 import_components52.Button, 16005 { 16006 variant: "tertiary", 16007 onClick: closeModal, 16008 disabled: isBusy, 16009 accessibleWhenDisabled: true 16010 }, 16011 (0, import_i18n43.__)("Cancel") 16012 ), /* @__PURE__ */ React.createElement( 16013 import_components52.Button, 16014 { 16015 variant: "primary", 16016 type: "submit", 16017 "aria-busy": isBusy, 16018 disabled: isBusy || !menuTitle?.trim(), 16019 accessibleWhenDisabled: true 16020 }, 16021 (0, import_i18n43.__)("Create Menu") 16022 ))) 16023 ) 16024 ); 16025 }; 16026 16027 // routes/navigation-list/style.scss 16028 var css = `/** 16029 * SCSS Variables. 16030 * 16031 * Please use variables from this sheet to ensure consistency across the UI. 16032 * Don't add to this sheet unless you're pretty sure the value will be reused in many places. 16033 * For example, don't add rules to this sheet that affect block visuals. It's purely for UI. 16034 */ 16035 /** 16036 * Colors 16037 */ 16038 /** 16039 * Fonts & basic variables. 16040 */ 16041 /** 16042 * Typography 16043 */ 16044 /** 16045 * Grid System. 16046 * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/ 16047 */ 16048 /** 16049 * Radius scale. 16050 */ 16051 /** 16052 * Elevation scale. 16053 */ 16054 /** 16055 * Dimensions. 16056 */ 16057 /** 16058 * Mobile specific styles 16059 */ 16060 /** 16061 * Editor styles. 16062 */ 16063 /** 16064 * Block & Editor UI. 16065 */ 16066 /** 16067 * Block paddings. 16068 */ 16069 /** 16070 * React Native specific. 16071 * These variables do not appear to be used anywhere else. 16072 */`; 16073 document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css)); 16074 16075 // routes/navigation-list/stage.tsx 16076 var { useEntityRecordsWithPermissions } = unlock2(import_core_data2.privateApis); 16077 var { usePostActions, usePostFields } = unlock2(import_editor.privateApis); 16078 var NAVIGATION_POST_TYPE2 = "wp_navigation"; 16079 var PRELOADED_NAVIGATION_MENUS_QUERY = { 16080 per_page: 100, 16081 status: ["publish", "draft"], 16082 order: "desc", 16083 orderby: "date" 16084 }; 16085 function getItemId(item) { 16086 return item.id.toString(); 16087 } 16088 function NavigationList() { 16089 const navigate = useNavigate3(); 16090 const searchParams = useSearch({ from: "/navigation/list" }); 16091 const defaultView = (0, import_element55.useMemo)(() => { 16092 return getDefaultView(); 16093 }, []); 16094 const handleQueryParamsChange = (0, import_element55.useCallback)( 16095 (params) => { 16096 navigate({ 16097 search: { 16098 ...searchParams, 16099 ...params 16100 } 16101 }); 16102 }, 16103 [searchParams, navigate] 16104 ); 16105 const { view, updateView, isModified, resetToDefault } = useView({ 16106 kind: "postType", 16107 name: NAVIGATION_POST_TYPE2, 16108 slug: "all", 16109 defaultView, 16110 queryParams: searchParams, 16111 onChangeQueryParams: handleQueryParamsChange 16112 }); 16113 const { 16114 records: navigationMenus, 16115 totalItems, 16116 totalPages, 16117 isResolving 16118 } = useEntityRecordsWithPermissions( 16119 "postType", 16120 NAVIGATION_POST_TYPE2, 16121 PRELOADED_NAVIGATION_MENUS_QUERY 16122 ); 16123 const fields = usePostFields({ 16124 postType: NAVIGATION_POST_TYPE2 16125 }); 16126 const [showAddModal, setShowAddModal] = (0, import_element55.useState)(false); 16127 const editAction = useEditNavigationAction(); 16128 const postTypeActions = usePostActions({ 16129 postType: NAVIGATION_POST_TYPE2, 16130 context: "list" 16131 }); 16132 const actions = (0, import_element55.useMemo)(() => { 16133 return [ 16134 editAction, 16135 ...postTypeActions?.flatMap((action) => { 16136 switch (action.id) { 16137 // Skip revisions as Gutenberg does not support it in this context 16138 case "view-post-revisions": 16139 return []; 16140 } 16141 return [action]; 16142 }) ?? [] 16143 ]; 16144 }, [editAction, postTypeActions]); 16145 const selection = (searchParams.ids ?? []).map((id) => id.toString()) ?? []; 16146 const firstNavigationId = (0, import_element55.useMemo)(() => { 16147 if (navigationMenus && navigationMenus.length > 0) { 16148 return navigationMenus[0].id.toString(); 16149 } 16150 return null; 16151 }, [navigationMenus]); 16152 if (selection.length === 0 && firstNavigationId) { 16153 selection.push(firstNavigationId); 16154 } 16155 if (view.type === "list") { 16156 selection.splice(1); 16157 } 16158 return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement( 16159 page_default, 16160 { 16161 title: (0, import_i18n44.__)("Navigation"), 16162 className: "navigation-page", 16163 hasPadding: false, 16164 actions: /* @__PURE__ */ React.createElement(React.Fragment, null, isModified && /* @__PURE__ */ React.createElement( 16165 import_components53.Button, 16166 { 16167 variant: "tertiary", 16168 size: "compact", 16169 onClick: resetToDefault 16170 }, 16171 (0, import_i18n44.__)("Reset view") 16172 ), /* @__PURE__ */ React.createElement( 16173 import_components53.Button, 16174 { 16175 variant: "primary", 16176 size: "compact", 16177 onClick: () => setShowAddModal(true) 16178 }, 16179 (0, import_i18n44.__)("Add New") 16180 )) 16181 }, 16182 /* @__PURE__ */ React.createElement( 16183 dataviews_default, 16184 { 16185 data: navigationMenus, 16186 fields, 16187 view, 16188 onChangeView: updateView, 16189 isLoading: isResolving || !fields, 16190 actions, 16191 paginationInfo: { 16192 totalItems, 16193 totalPages 16194 }, 16195 defaultLayouts: { 16196 list: {} 16197 }, 16198 getItemId, 16199 selection, 16200 onChangeSelection: (items) => { 16201 navigate({ 16202 search: { 16203 ...searchParams, 16204 ids: items.length > 0 ? items.map((id) => Number(id)) : void 0 16205 } 16206 }); 16207 } 16208 } 16209 ) 16210 ), showAddModal && /* @__PURE__ */ React.createElement( 16211 AddNavigationModal, 16212 { 16213 closeModal: () => setShowAddModal(false) 16214 } 16215 )); 16216 } 16217 var stage = NavigationList; 16218 export { 16219 stage 16220 }; 16221 /*! Bundled license information: 16222 16223 use-sync-external-store/cjs/use-sync-external-store-shim.development.js: 16224 (** 16225 * @license React 16226 * use-sync-external-store-shim.development.js 16227 * 16228 * Copyright (c) Meta Platforms, Inc. and affiliates. 16229 * 16230 * This source code is licensed under the MIT license found in the 16231 * LICENSE file in the root directory of this source tree. 16232 *) 16233 */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Wed May 6 08:20:15 2026 | Cross-referenced by PHPXref |