| [ 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/element 28 var require_element = __commonJS({ 29 "package-external:@wordpress/element"(exports, module) { 30 module.exports = window.wp.element; 31 } 32 }); 33 34 // package-external:@wordpress/data 35 var require_data = __commonJS({ 36 "package-external:@wordpress/data"(exports, module) { 37 module.exports = window.wp.data; 38 } 39 }); 40 41 // package-external:@wordpress/preferences 42 var require_preferences = __commonJS({ 43 "package-external:@wordpress/preferences"(exports, module) { 44 module.exports = window.wp.preferences; 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 // package-external:@wordpress/compose 56 var require_compose = __commonJS({ 57 "package-external:@wordpress/compose"(exports, module) { 58 module.exports = window.wp.compose; 59 } 60 }); 61 62 // package-external:@wordpress/i18n 63 var require_i18n = __commonJS({ 64 "package-external:@wordpress/i18n"(exports, module) { 65 module.exports = window.wp.i18n; 66 } 67 }); 68 69 // package-external:@wordpress/primitives 70 var require_primitives = __commonJS({ 71 "package-external:@wordpress/primitives"(exports, module) { 72 module.exports = window.wp.primitives; 73 } 74 }); 75 76 // vendor-external:react/jsx-runtime 77 var require_jsx_runtime = __commonJS({ 78 "vendor-external:react/jsx-runtime"(exports, module) { 79 module.exports = window.ReactJSXRuntime; 80 } 81 }); 82 83 // package-external:@wordpress/keycodes 84 var require_keycodes = __commonJS({ 85 "package-external:@wordpress/keycodes"(exports, module) { 86 module.exports = window.wp.keycodes; 87 } 88 }); 89 90 // package-external:@wordpress/private-apis 91 var require_private_apis = __commonJS({ 92 "package-external:@wordpress/private-apis"(exports, module) { 93 module.exports = window.wp.privateApis; 94 } 95 }); 96 97 // vendor-external:react 98 var require_react = __commonJS({ 99 "vendor-external:react"(exports, module) { 100 module.exports = window.React; 101 } 102 }); 103 104 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js 105 var require_use_sync_external_store_shim_development = __commonJS({ 106 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) { 107 "use strict"; 108 (function() { 109 function is(x2, y2) { 110 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2; 111 } 112 function useSyncExternalStore$2(subscribe2, getSnapshot) { 113 didWarnOld18Alpha || void 0 === React5.startTransition || (didWarnOld18Alpha = true, console.error( 114 "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." 115 )); 116 var value = getSnapshot(); 117 if (!didWarnUncachedGetSnapshot) { 118 var cachedValue = getSnapshot(); 119 objectIs(value, cachedValue) || (console.error( 120 "The result of getSnapshot should be cached to avoid an infinite loop" 121 ), didWarnUncachedGetSnapshot = true); 122 } 123 cachedValue = useState24({ 124 inst: { value, getSnapshot } 125 }); 126 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1]; 127 useLayoutEffect2( 128 function() { 129 inst.value = value; 130 inst.getSnapshot = getSnapshot; 131 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 132 }, 133 [subscribe2, value, getSnapshot] 134 ); 135 useEffect17( 136 function() { 137 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 138 return subscribe2(function() { 139 checkIfSnapshotChanged(inst) && forceUpdate({ inst }); 140 }); 141 }, 142 [subscribe2] 143 ); 144 useDebugValue(value); 145 return value; 146 } 147 function checkIfSnapshotChanged(inst) { 148 var latestGetSnapshot = inst.getSnapshot; 149 inst = inst.value; 150 try { 151 var nextValue = latestGetSnapshot(); 152 return !objectIs(inst, nextValue); 153 } catch (error) { 154 return true; 155 } 156 } 157 function useSyncExternalStore$1(subscribe2, getSnapshot) { 158 return getSnapshot(); 159 } 160 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); 161 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; 162 exports.useSyncExternalStore = void 0 !== React5.useSyncExternalStore ? React5.useSyncExternalStore : shim; 163 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error()); 164 })(); 165 } 166 }); 167 168 // node_modules/use-sync-external-store/shim/index.js 169 var require_shim = __commonJS({ 170 "node_modules/use-sync-external-store/shim/index.js"(exports, module) { 171 "use strict"; 172 if (false) { 173 module.exports = null; 174 } else { 175 module.exports = require_use_sync_external_store_shim_development(); 176 } 177 } 178 }); 179 180 // vendor-external:react-dom 181 var require_react_dom = __commonJS({ 182 "vendor-external:react-dom"(exports, module) { 183 module.exports = window.ReactDOM; 184 } 185 }); 186 187 // node_modules/remove-accents/index.js 188 var require_remove_accents = __commonJS({ 189 "node_modules/remove-accents/index.js"(exports, module) { 190 var characterMap = { 191 "\xC0": "A", 192 "\xC1": "A", 193 "\xC2": "A", 194 "\xC3": "A", 195 "\xC4": "A", 196 "\xC5": "A", 197 "\u1EA4": "A", 198 "\u1EAE": "A", 199 "\u1EB2": "A", 200 "\u1EB4": "A", 201 "\u1EB6": "A", 202 "\xC6": "AE", 203 "\u1EA6": "A", 204 "\u1EB0": "A", 205 "\u0202": "A", 206 "\u1EA2": "A", 207 "\u1EA0": "A", 208 "\u1EA8": "A", 209 "\u1EAA": "A", 210 "\u1EAC": "A", 211 "\xC7": "C", 212 "\u1E08": "C", 213 "\xC8": "E", 214 "\xC9": "E", 215 "\xCA": "E", 216 "\xCB": "E", 217 "\u1EBE": "E", 218 "\u1E16": "E", 219 "\u1EC0": "E", 220 "\u1E14": "E", 221 "\u1E1C": "E", 222 "\u0206": "E", 223 "\u1EBA": "E", 224 "\u1EBC": "E", 225 "\u1EB8": "E", 226 "\u1EC2": "E", 227 "\u1EC4": "E", 228 "\u1EC6": "E", 229 "\xCC": "I", 230 "\xCD": "I", 231 "\xCE": "I", 232 "\xCF": "I", 233 "\u1E2E": "I", 234 "\u020A": "I", 235 "\u1EC8": "I", 236 "\u1ECA": "I", 237 "\xD0": "D", 238 "\xD1": "N", 239 "\xD2": "O", 240 "\xD3": "O", 241 "\xD4": "O", 242 "\xD5": "O", 243 "\xD6": "O", 244 "\xD8": "O", 245 "\u1ED0": "O", 246 "\u1E4C": "O", 247 "\u1E52": "O", 248 "\u020E": "O", 249 "\u1ECE": "O", 250 "\u1ECC": "O", 251 "\u1ED4": "O", 252 "\u1ED6": "O", 253 "\u1ED8": "O", 254 "\u1EDC": "O", 255 "\u1EDE": "O", 256 "\u1EE0": "O", 257 "\u1EDA": "O", 258 "\u1EE2": "O", 259 "\xD9": "U", 260 "\xDA": "U", 261 "\xDB": "U", 262 "\xDC": "U", 263 "\u1EE6": "U", 264 "\u1EE4": "U", 265 "\u1EEC": "U", 266 "\u1EEE": "U", 267 "\u1EF0": "U", 268 "\xDD": "Y", 269 "\xE0": "a", 270 "\xE1": "a", 271 "\xE2": "a", 272 "\xE3": "a", 273 "\xE4": "a", 274 "\xE5": "a", 275 "\u1EA5": "a", 276 "\u1EAF": "a", 277 "\u1EB3": "a", 278 "\u1EB5": "a", 279 "\u1EB7": "a", 280 "\xE6": "ae", 281 "\u1EA7": "a", 282 "\u1EB1": "a", 283 "\u0203": "a", 284 "\u1EA3": "a", 285 "\u1EA1": "a", 286 "\u1EA9": "a", 287 "\u1EAB": "a", 288 "\u1EAD": "a", 289 "\xE7": "c", 290 "\u1E09": "c", 291 "\xE8": "e", 292 "\xE9": "e", 293 "\xEA": "e", 294 "\xEB": "e", 295 "\u1EBF": "e", 296 "\u1E17": "e", 297 "\u1EC1": "e", 298 "\u1E15": "e", 299 "\u1E1D": "e", 300 "\u0207": "e", 301 "\u1EBB": "e", 302 "\u1EBD": "e", 303 "\u1EB9": "e", 304 "\u1EC3": "e", 305 "\u1EC5": "e", 306 "\u1EC7": "e", 307 "\xEC": "i", 308 "\xED": "i", 309 "\xEE": "i", 310 "\xEF": "i", 311 "\u1E2F": "i", 312 "\u020B": "i", 313 "\u1EC9": "i", 314 "\u1ECB": "i", 315 "\xF0": "d", 316 "\xF1": "n", 317 "\xF2": "o", 318 "\xF3": "o", 319 "\xF4": "o", 320 "\xF5": "o", 321 "\xF6": "o", 322 "\xF8": "o", 323 "\u1ED1": "o", 324 "\u1E4D": "o", 325 "\u1E53": "o", 326 "\u020F": "o", 327 "\u1ECF": "o", 328 "\u1ECD": "o", 329 "\u1ED5": "o", 330 "\u1ED7": "o", 331 "\u1ED9": "o", 332 "\u1EDD": "o", 333 "\u1EDF": "o", 334 "\u1EE1": "o", 335 "\u1EDB": "o", 336 "\u1EE3": "o", 337 "\xF9": "u", 338 "\xFA": "u", 339 "\xFB": "u", 340 "\xFC": "u", 341 "\u1EE7": "u", 342 "\u1EE5": "u", 343 "\u1EED": "u", 344 "\u1EEF": "u", 345 "\u1EF1": "u", 346 "\xFD": "y", 347 "\xFF": "y", 348 "\u0100": "A", 349 "\u0101": "a", 350 "\u0102": "A", 351 "\u0103": "a", 352 "\u0104": "A", 353 "\u0105": "a", 354 "\u0106": "C", 355 "\u0107": "c", 356 "\u0108": "C", 357 "\u0109": "c", 358 "\u010A": "C", 359 "\u010B": "c", 360 "\u010C": "C", 361 "\u010D": "c", 362 "C\u0306": "C", 363 "c\u0306": "c", 364 "\u010E": "D", 365 "\u010F": "d", 366 "\u0110": "D", 367 "\u0111": "d", 368 "\u0112": "E", 369 "\u0113": "e", 370 "\u0114": "E", 371 "\u0115": "e", 372 "\u0116": "E", 373 "\u0117": "e", 374 "\u0118": "E", 375 "\u0119": "e", 376 "\u011A": "E", 377 "\u011B": "e", 378 "\u011C": "G", 379 "\u01F4": "G", 380 "\u011D": "g", 381 "\u01F5": "g", 382 "\u011E": "G", 383 "\u011F": "g", 384 "\u0120": "G", 385 "\u0121": "g", 386 "\u0122": "G", 387 "\u0123": "g", 388 "\u0124": "H", 389 "\u0125": "h", 390 "\u0126": "H", 391 "\u0127": "h", 392 "\u1E2A": "H", 393 "\u1E2B": "h", 394 "\u0128": "I", 395 "\u0129": "i", 396 "\u012A": "I", 397 "\u012B": "i", 398 "\u012C": "I", 399 "\u012D": "i", 400 "\u012E": "I", 401 "\u012F": "i", 402 "\u0130": "I", 403 "\u0131": "i", 404 "\u0132": "IJ", 405 "\u0133": "ij", 406 "\u0134": "J", 407 "\u0135": "j", 408 "\u0136": "K", 409 "\u0137": "k", 410 "\u1E30": "K", 411 "\u1E31": "k", 412 "K\u0306": "K", 413 "k\u0306": "k", 414 "\u0139": "L", 415 "\u013A": "l", 416 "\u013B": "L", 417 "\u013C": "l", 418 "\u013D": "L", 419 "\u013E": "l", 420 "\u013F": "L", 421 "\u0140": "l", 422 "\u0141": "l", 423 "\u0142": "l", 424 "\u1E3E": "M", 425 "\u1E3F": "m", 426 "M\u0306": "M", 427 "m\u0306": "m", 428 "\u0143": "N", 429 "\u0144": "n", 430 "\u0145": "N", 431 "\u0146": "n", 432 "\u0147": "N", 433 "\u0148": "n", 434 "\u0149": "n", 435 "N\u0306": "N", 436 "n\u0306": "n", 437 "\u014C": "O", 438 "\u014D": "o", 439 "\u014E": "O", 440 "\u014F": "o", 441 "\u0150": "O", 442 "\u0151": "o", 443 "\u0152": "OE", 444 "\u0153": "oe", 445 "P\u0306": "P", 446 "p\u0306": "p", 447 "\u0154": "R", 448 "\u0155": "r", 449 "\u0156": "R", 450 "\u0157": "r", 451 "\u0158": "R", 452 "\u0159": "r", 453 "R\u0306": "R", 454 "r\u0306": "r", 455 "\u0212": "R", 456 "\u0213": "r", 457 "\u015A": "S", 458 "\u015B": "s", 459 "\u015C": "S", 460 "\u015D": "s", 461 "\u015E": "S", 462 "\u0218": "S", 463 "\u0219": "s", 464 "\u015F": "s", 465 "\u0160": "S", 466 "\u0161": "s", 467 "\u0162": "T", 468 "\u0163": "t", 469 "\u021B": "t", 470 "\u021A": "T", 471 "\u0164": "T", 472 "\u0165": "t", 473 "\u0166": "T", 474 "\u0167": "t", 475 "T\u0306": "T", 476 "t\u0306": "t", 477 "\u0168": "U", 478 "\u0169": "u", 479 "\u016A": "U", 480 "\u016B": "u", 481 "\u016C": "U", 482 "\u016D": "u", 483 "\u016E": "U", 484 "\u016F": "u", 485 "\u0170": "U", 486 "\u0171": "u", 487 "\u0172": "U", 488 "\u0173": "u", 489 "\u0216": "U", 490 "\u0217": "u", 491 "V\u0306": "V", 492 "v\u0306": "v", 493 "\u0174": "W", 494 "\u0175": "w", 495 "\u1E82": "W", 496 "\u1E83": "w", 497 "X\u0306": "X", 498 "x\u0306": "x", 499 "\u0176": "Y", 500 "\u0177": "y", 501 "\u0178": "Y", 502 "Y\u0306": "Y", 503 "y\u0306": "y", 504 "\u0179": "Z", 505 "\u017A": "z", 506 "\u017B": "Z", 507 "\u017C": "z", 508 "\u017D": "Z", 509 "\u017E": "z", 510 "\u017F": "s", 511 "\u0192": "f", 512 "\u01A0": "O", 513 "\u01A1": "o", 514 "\u01AF": "U", 515 "\u01B0": "u", 516 "\u01CD": "A", 517 "\u01CE": "a", 518 "\u01CF": "I", 519 "\u01D0": "i", 520 "\u01D1": "O", 521 "\u01D2": "o", 522 "\u01D3": "U", 523 "\u01D4": "u", 524 "\u01D5": "U", 525 "\u01D6": "u", 526 "\u01D7": "U", 527 "\u01D8": "u", 528 "\u01D9": "U", 529 "\u01DA": "u", 530 "\u01DB": "U", 531 "\u01DC": "u", 532 "\u1EE8": "U", 533 "\u1EE9": "u", 534 "\u1E78": "U", 535 "\u1E79": "u", 536 "\u01FA": "A", 537 "\u01FB": "a", 538 "\u01FC": "AE", 539 "\u01FD": "ae", 540 "\u01FE": "O", 541 "\u01FF": "o", 542 "\xDE": "TH", 543 "\xFE": "th", 544 "\u1E54": "P", 545 "\u1E55": "p", 546 "\u1E64": "S", 547 "\u1E65": "s", 548 "X\u0301": "X", 549 "x\u0301": "x", 550 "\u0403": "\u0413", 551 "\u0453": "\u0433", 552 "\u040C": "\u041A", 553 "\u045C": "\u043A", 554 "A\u030B": "A", 555 "a\u030B": "a", 556 "E\u030B": "E", 557 "e\u030B": "e", 558 "I\u030B": "I", 559 "i\u030B": "i", 560 "\u01F8": "N", 561 "\u01F9": "n", 562 "\u1ED2": "O", 563 "\u1ED3": "o", 564 "\u1E50": "O", 565 "\u1E51": "o", 566 "\u1EEA": "U", 567 "\u1EEB": "u", 568 "\u1E80": "W", 569 "\u1E81": "w", 570 "\u1EF2": "Y", 571 "\u1EF3": "y", 572 "\u0200": "A", 573 "\u0201": "a", 574 "\u0204": "E", 575 "\u0205": "e", 576 "\u0208": "I", 577 "\u0209": "i", 578 "\u020C": "O", 579 "\u020D": "o", 580 "\u0210": "R", 581 "\u0211": "r", 582 "\u0214": "U", 583 "\u0215": "u", 584 "B\u030C": "B", 585 "b\u030C": "b", 586 "\u010C\u0323": "C", 587 "\u010D\u0323": "c", 588 "\xCA\u030C": "E", 589 "\xEA\u030C": "e", 590 "F\u030C": "F", 591 "f\u030C": "f", 592 "\u01E6": "G", 593 "\u01E7": "g", 594 "\u021E": "H", 595 "\u021F": "h", 596 "J\u030C": "J", 597 "\u01F0": "j", 598 "\u01E8": "K", 599 "\u01E9": "k", 600 "M\u030C": "M", 601 "m\u030C": "m", 602 "P\u030C": "P", 603 "p\u030C": "p", 604 "Q\u030C": "Q", 605 "q\u030C": "q", 606 "\u0158\u0329": "R", 607 "\u0159\u0329": "r", 608 "\u1E66": "S", 609 "\u1E67": "s", 610 "V\u030C": "V", 611 "v\u030C": "v", 612 "W\u030C": "W", 613 "w\u030C": "w", 614 "X\u030C": "X", 615 "x\u030C": "x", 616 "Y\u030C": "Y", 617 "y\u030C": "y", 618 "A\u0327": "A", 619 "a\u0327": "a", 620 "B\u0327": "B", 621 "b\u0327": "b", 622 "\u1E10": "D", 623 "\u1E11": "d", 624 "\u0228": "E", 625 "\u0229": "e", 626 "\u0190\u0327": "E", 627 "\u025B\u0327": "e", 628 "\u1E28": "H", 629 "\u1E29": "h", 630 "I\u0327": "I", 631 "i\u0327": "i", 632 "\u0197\u0327": "I", 633 "\u0268\u0327": "i", 634 "M\u0327": "M", 635 "m\u0327": "m", 636 "O\u0327": "O", 637 "o\u0327": "o", 638 "Q\u0327": "Q", 639 "q\u0327": "q", 640 "U\u0327": "U", 641 "u\u0327": "u", 642 "X\u0327": "X", 643 "x\u0327": "x", 644 "Z\u0327": "Z", 645 "z\u0327": "z", 646 "\u0439": "\u0438", 647 "\u0419": "\u0418", 648 "\u0451": "\u0435", 649 "\u0401": "\u0415" 650 }; 651 var chars = Object.keys(characterMap).join("|"); 652 var allAccents = new RegExp(chars, "g"); 653 var firstAccent = new RegExp(chars, ""); 654 function matcher(match2) { 655 return characterMap[match2]; 656 } 657 var removeAccents2 = function(string) { 658 return string.replace(allAccents, matcher); 659 }; 660 var hasAccents = function(string) { 661 return !!string.match(firstAccent); 662 }; 663 module.exports = removeAccents2; 664 module.exports.has = hasAccents; 665 module.exports.remove = removeAccents2; 666 } 667 }); 668 669 // node_modules/fast-deep-equal/es6/index.js 670 var require_es6 = __commonJS({ 671 "node_modules/fast-deep-equal/es6/index.js"(exports, module) { 672 "use strict"; 673 module.exports = function equal(a2, b2) { 674 if (a2 === b2) return true; 675 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") { 676 if (a2.constructor !== b2.constructor) return false; 677 var length, i2, keys; 678 if (Array.isArray(a2)) { 679 length = a2.length; 680 if (length != b2.length) return false; 681 for (i2 = length; i2-- !== 0; ) 682 if (!equal(a2[i2], b2[i2])) return false; 683 return true; 684 } 685 if (a2 instanceof Map && b2 instanceof Map) { 686 if (a2.size !== b2.size) return false; 687 for (i2 of a2.entries()) 688 if (!b2.has(i2[0])) return false; 689 for (i2 of a2.entries()) 690 if (!equal(i2[1], b2.get(i2[0]))) return false; 691 return true; 692 } 693 if (a2 instanceof Set && b2 instanceof Set) { 694 if (a2.size !== b2.size) return false; 695 for (i2 of a2.entries()) 696 if (!b2.has(i2[0])) return false; 697 return true; 698 } 699 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) { 700 length = a2.length; 701 if (length != b2.length) return false; 702 for (i2 = length; i2-- !== 0; ) 703 if (a2[i2] !== b2[i2]) return false; 704 return true; 705 } 706 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags; 707 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf(); 708 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString(); 709 keys = Object.keys(a2); 710 length = keys.length; 711 if (length !== Object.keys(b2).length) return false; 712 for (i2 = length; i2-- !== 0; ) 713 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false; 714 for (i2 = length; i2-- !== 0; ) { 715 var key = keys[i2]; 716 if (!equal(a2[key], b2[key])) return false; 717 } 718 return true; 719 } 720 return a2 !== a2 && b2 !== b2; 721 }; 722 } 723 }); 724 725 // package-external:@wordpress/warning 726 var require_warning = __commonJS({ 727 "package-external:@wordpress/warning"(exports, module) { 728 module.exports = window.wp.warning; 729 } 730 }); 731 732 // package-external:@wordpress/date 733 var require_date = __commonJS({ 734 "package-external:@wordpress/date"(exports, module) { 735 module.exports = window.wp.date; 736 } 737 }); 738 739 // package-external:@wordpress/core-data 740 var require_core_data = __commonJS({ 741 "package-external:@wordpress/core-data"(exports, module) { 742 module.exports = window.wp.coreData; 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 // package-external:@wordpress/blocks 761 var require_blocks = __commonJS({ 762 "package-external:@wordpress/blocks"(exports, module) { 763 module.exports = window.wp.blocks; 764 } 765 }); 766 767 // routes/template-part-list/stage.tsx 768 import { 769 useParams, 770 useNavigate, 771 useSearch, 772 Link, 773 useInvalidate 774 } from "@wordpress/route"; 775 776 // node_modules/dequal/dist/index.mjs 777 var has = Object.prototype.hasOwnProperty; 778 function find(iter, tar, key) { 779 for (key of iter.keys()) { 780 if (dequal(key, tar)) return key; 781 } 782 } 783 function dequal(foo, bar) { 784 var ctor, len, tmp; 785 if (foo === bar) return true; 786 if (foo && bar && (ctor = foo.constructor) === bar.constructor) { 787 if (ctor === Date) return foo.getTime() === bar.getTime(); 788 if (ctor === RegExp) return foo.toString() === bar.toString(); 789 if (ctor === Array) { 790 if ((len = foo.length) === bar.length) { 791 while (len-- && dequal(foo[len], bar[len])) ; 792 } 793 return len === -1; 794 } 795 if (ctor === Set) { 796 if (foo.size !== bar.size) { 797 return false; 798 } 799 for (len of foo) { 800 tmp = len; 801 if (tmp && typeof tmp === "object") { 802 tmp = find(bar, tmp); 803 if (!tmp) return false; 804 } 805 if (!bar.has(tmp)) return false; 806 } 807 return true; 808 } 809 if (ctor === Map) { 810 if (foo.size !== bar.size) { 811 return false; 812 } 813 for (len of foo) { 814 tmp = len[0]; 815 if (tmp && typeof tmp === "object") { 816 tmp = find(bar, tmp); 817 if (!tmp) return false; 818 } 819 if (!dequal(len[1], bar.get(tmp))) { 820 return false; 821 } 822 } 823 return true; 824 } 825 if (ctor === ArrayBuffer) { 826 foo = new Uint8Array(foo); 827 bar = new Uint8Array(bar); 828 } else if (ctor === DataView) { 829 if ((len = foo.byteLength) === bar.byteLength) { 830 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ; 831 } 832 return len === -1; 833 } 834 if (ArrayBuffer.isView(foo)) { 835 if ((len = foo.byteLength) === bar.byteLength) { 836 while (len-- && foo[len] === bar[len]) ; 837 } 838 return len === -1; 839 } 840 if (!ctor || typeof foo === "object") { 841 len = 0; 842 for (ctor in foo) { 843 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false; 844 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false; 845 } 846 return Object.keys(bar).length === len; 847 } 848 } 849 return foo !== foo && bar !== bar; 850 } 851 852 // packages/views/build-module/preference-keys.js 853 function generatePreferenceKey(kind, name, slug) { 854 return `dataviews-$kind}-$name}-$slug}`; 855 } 856 857 // packages/views/build-module/use-view.js 858 var import_element = __toESM(require_element()); 859 var import_data = __toESM(require_data()); 860 var import_preferences = __toESM(require_preferences()); 861 function omit(obj, keys) { 862 const result = { ...obj }; 863 for (const key of keys) { 864 delete result[key]; 865 } 866 return result; 867 } 868 function useView(config) { 869 const { kind, name, slug, defaultView, queryParams, onChangeQueryParams } = config; 870 const preferenceKey = generatePreferenceKey(kind, name, slug); 871 const persistedView = (0, import_data.useSelect)( 872 (select2) => { 873 return select2(import_preferences.store).get( 874 "core/views", 875 preferenceKey 876 ); 877 }, 878 [preferenceKey] 879 ); 880 const { set } = (0, import_data.useDispatch)(import_preferences.store); 881 const baseView = persistedView ?? defaultView; 882 const page = Number(queryParams?.page ?? baseView.page ?? 1); 883 const search = queryParams?.search ?? baseView.search ?? ""; 884 const view = (0, import_element.useMemo)(() => { 885 return { 886 ...baseView, 887 page, 888 search 889 }; 890 }, [baseView, page, search]); 891 const isModified = !!persistedView; 892 const updateView = (0, import_element.useCallback)( 893 (newView) => { 894 const urlParams = { 895 page: newView?.page, 896 search: newView?.search 897 }; 898 const preferenceView = omit(newView, ["page", "search"]); 899 if (onChangeQueryParams && !dequal(urlParams, { page, search })) { 900 onChangeQueryParams(urlParams); 901 } 902 if (!dequal(baseView, preferenceView)) { 903 if (dequal(preferenceView, defaultView)) { 904 set("core/views", preferenceKey, void 0); 905 } else { 906 set("core/views", preferenceKey, preferenceView); 907 } 908 } 909 }, 910 [ 911 onChangeQueryParams, 912 page, 913 search, 914 baseView, 915 defaultView, 916 set, 917 preferenceKey 918 ] 919 ); 920 const resetToDefault = (0, import_element.useCallback)(() => { 921 set("core/views", preferenceKey, void 0); 922 }, [preferenceKey, set]); 923 return { 924 view, 925 isModified, 926 updateView, 927 resetToDefault 928 }; 929 } 930 931 // packages/views/build-module/load-view.js 932 var import_data2 = __toESM(require_data()); 933 var import_preferences2 = __toESM(require_preferences()); 934 935 // packages/dataviews/build-module/components/dataviews/index.js 936 var import_components49 = __toESM(require_components()); 937 var import_element52 = __toESM(require_element()); 938 var import_compose11 = __toESM(require_compose()); 939 940 // packages/dataviews/build-module/components/dataviews-context/index.js 941 var import_element2 = __toESM(require_element()); 942 943 // packages/dataviews/build-module/constants.js 944 var import_i18n = __toESM(require_i18n()); 945 946 // packages/icons/build-module/library/arrow-down.js 947 var import_primitives = __toESM(require_primitives()); 948 var import_jsx_runtime = __toESM(require_jsx_runtime()); 949 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.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" }) }); 950 951 // packages/icons/build-module/library/arrow-left.js 952 var import_primitives2 = __toESM(require_primitives()); 953 var import_jsx_runtime2 = __toESM(require_jsx_runtime()); 954 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.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" }) }); 955 956 // packages/icons/build-module/library/arrow-right.js 957 var import_primitives3 = __toESM(require_primitives()); 958 var import_jsx_runtime3 = __toESM(require_jsx_runtime()); 959 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.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" }) }); 960 961 // packages/icons/build-module/library/arrow-up.js 962 var import_primitives4 = __toESM(require_primitives()); 963 var import_jsx_runtime4 = __toESM(require_jsx_runtime()); 964 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) }); 965 966 // packages/icons/build-module/library/block-table.js 967 var import_primitives5 = __toESM(require_primitives()); 968 var import_jsx_runtime5 = __toESM(require_jsx_runtime()); 969 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime5.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" }) }); 970 971 // packages/icons/build-module/library/category.js 972 var import_primitives6 = __toESM(require_primitives()); 973 var import_jsx_runtime6 = __toESM(require_jsx_runtime()); 974 var category_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)( 975 import_primitives6.Path, 976 { 977 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", 978 fillRule: "evenodd", 979 clipRule: "evenodd" 980 } 981 ) }); 982 983 // packages/icons/build-module/library/check.js 984 var import_primitives7 = __toESM(require_primitives()); 985 var import_jsx_runtime7 = __toESM(require_jsx_runtime()); 986 var check_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.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" }) }); 987 988 // packages/icons/build-module/library/close-small.js 989 var import_primitives8 = __toESM(require_primitives()); 990 var import_jsx_runtime8 = __toESM(require_jsx_runtime()); 991 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.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" }) }); 992 993 // packages/icons/build-module/library/cog.js 994 var import_primitives9 = __toESM(require_primitives()); 995 var import_jsx_runtime9 = __toESM(require_jsx_runtime()); 996 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( 997 import_primitives9.Path, 998 { 999 fillRule: "evenodd", 1000 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", 1001 clipRule: "evenodd" 1002 } 1003 ) }); 1004 1005 // packages/icons/build-module/library/envelope.js 1006 var import_primitives10 = __toESM(require_primitives()); 1007 var import_jsx_runtime10 = __toESM(require_jsx_runtime()); 1008 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( 1009 import_primitives10.Path, 1010 { 1011 fillRule: "evenodd", 1012 clipRule: "evenodd", 1013 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" 1014 } 1015 ) }); 1016 1017 // packages/icons/build-module/library/error.js 1018 var import_primitives11 = __toESM(require_primitives()); 1019 var import_jsx_runtime11 = __toESM(require_jsx_runtime()); 1020 var error_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)( 1021 import_primitives11.Path, 1022 { 1023 fillRule: "evenodd", 1024 clipRule: "evenodd", 1025 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" 1026 } 1027 ) }); 1028 1029 // packages/icons/build-module/library/footer.js 1030 var import_primitives12 = __toESM(require_primitives()); 1031 var import_jsx_runtime12 = __toESM(require_jsx_runtime()); 1032 var footer_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 1033 import_primitives12.Path, 1034 { 1035 fillRule: "evenodd", 1036 d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" 1037 } 1038 ) }); 1039 1040 // packages/icons/build-module/library/format-list-bullets-rtl.js 1041 var import_primitives13 = __toESM(require_primitives()); 1042 var import_jsx_runtime13 = __toESM(require_jsx_runtime()); 1043 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.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" }) }); 1044 1045 // packages/icons/build-module/library/format-list-bullets.js 1046 var import_primitives14 = __toESM(require_primitives()); 1047 var import_jsx_runtime14 = __toESM(require_jsx_runtime()); 1048 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.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" }) }); 1049 1050 // packages/icons/build-module/library/funnel.js 1051 var import_primitives15 = __toESM(require_primitives()); 1052 var import_jsx_runtime15 = __toESM(require_jsx_runtime()); 1053 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) }); 1054 1055 // packages/icons/build-module/library/header.js 1056 var import_primitives16 = __toESM(require_primitives()); 1057 var import_jsx_runtime16 = __toESM(require_jsx_runtime()); 1058 var header_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.Path, { d: "M18.5 10.5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) }); 1059 1060 // packages/icons/build-module/library/link.js 1061 var import_primitives17 = __toESM(require_primitives()); 1062 var import_jsx_runtime17 = __toESM(require_jsx_runtime()); 1063 var link_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.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" }) }); 1064 1065 // packages/icons/build-module/library/mobile.js 1066 var import_primitives18 = __toESM(require_primitives()); 1067 var import_jsx_runtime18 = __toESM(require_jsx_runtime()); 1068 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.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" }) }); 1069 1070 // packages/icons/build-module/library/more-vertical.js 1071 var import_primitives19 = __toESM(require_primitives()); 1072 var import_jsx_runtime19 = __toESM(require_jsx_runtime()); 1073 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) }); 1074 1075 // packages/icons/build-module/library/next.js 1076 var import_primitives20 = __toESM(require_primitives()); 1077 var import_jsx_runtime20 = __toESM(require_jsx_runtime()); 1078 var next_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.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" }) }); 1079 1080 // packages/icons/build-module/library/previous.js 1081 var import_primitives21 = __toESM(require_primitives()); 1082 var import_jsx_runtime21 = __toESM(require_jsx_runtime()); 1083 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.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" }) }); 1084 1085 // packages/icons/build-module/library/scheduled.js 1086 var import_primitives22 = __toESM(require_primitives()); 1087 var import_jsx_runtime22 = __toESM(require_jsx_runtime()); 1088 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)( 1089 import_primitives22.Path, 1090 { 1091 fillRule: "evenodd", 1092 clipRule: "evenodd", 1093 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" 1094 } 1095 ) }); 1096 1097 // packages/icons/build-module/library/search.js 1098 var import_primitives23 = __toESM(require_primitives()); 1099 var import_jsx_runtime23 = __toESM(require_jsx_runtime()); 1100 var search_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.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" }) }); 1101 1102 // packages/icons/build-module/library/seen.js 1103 var import_primitives24 = __toESM(require_primitives()); 1104 var import_jsx_runtime24 = __toESM(require_jsx_runtime()); 1105 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.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" }) }); 1106 1107 // packages/icons/build-module/library/sidebar.js 1108 var import_primitives25 = __toESM(require_primitives()); 1109 var import_jsx_runtime25 = __toESM(require_jsx_runtime()); 1110 var sidebar_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.Path, { d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) }); 1111 1112 // packages/icons/build-module/library/symbol-filled.js 1113 var import_primitives26 = __toESM(require_primitives()); 1114 var import_jsx_runtime26 = __toESM(require_jsx_runtime()); 1115 var symbol_filled_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" }) }); 1116 1117 // packages/icons/build-module/library/table-column-after.js 1118 var import_primitives27 = __toESM(require_primitives()); 1119 var import_jsx_runtime27 = __toESM(require_jsx_runtime()); 1120 var table_column_after_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14.2c.1.9.9 1.7 1.8 1.8H19.2c1-.1 1.8-1 1.8-2V5c0-1.1-.9-2-2-2ZM8.5 19.5H5c-.3 0-.5-.2-.5-.5v-3.5h4v4Zm0-5.5h-4v-4h4v4Zm0-5.5h-4V5c0-.3.2-.5.5-.5h3.5v4Zm11 10.5c0 .3-.2.5-.5.5h-9v-15h9c.3 0 .5.2.5.5v14Zm-4-10.8H14v3h-3v1.5h3v3h1.5v-3h3v-1.5h-3v-3Z" }) }); 1121 1122 // packages/icons/build-module/library/unseen.js 1123 var import_primitives28 = __toESM(require_primitives()); 1124 var import_jsx_runtime28 = __toESM(require_jsx_runtime()); 1125 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.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" }) }); 1126 1127 // packages/dataviews/build-module/constants.js 1128 var OPERATOR_IS_ANY = "isAny"; 1129 var OPERATOR_IS_NONE = "isNone"; 1130 var OPERATOR_IS_ALL = "isAll"; 1131 var OPERATOR_IS_NOT_ALL = "isNotAll"; 1132 var OPERATOR_BETWEEN = "between"; 1133 var OPERATOR_IN_THE_PAST = "inThePast"; 1134 var OPERATOR_OVER = "over"; 1135 var OPERATOR_IS = "is"; 1136 var OPERATOR_IS_NOT = "isNot"; 1137 var OPERATOR_LESS_THAN = "lessThan"; 1138 var OPERATOR_GREATER_THAN = "greaterThan"; 1139 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual"; 1140 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual"; 1141 var OPERATOR_BEFORE = "before"; 1142 var OPERATOR_AFTER = "after"; 1143 var OPERATOR_BEFORE_INC = "beforeInc"; 1144 var OPERATOR_AFTER_INC = "afterInc"; 1145 var OPERATOR_CONTAINS = "contains"; 1146 var OPERATOR_NOT_CONTAINS = "notContains"; 1147 var OPERATOR_STARTS_WITH = "startsWith"; 1148 var OPERATOR_ON = "on"; 1149 var OPERATOR_NOT_ON = "notOn"; 1150 var SORTING_DIRECTIONS = ["asc", "desc"]; 1151 var sortArrows = { asc: "\u2191", desc: "\u2193" }; 1152 var sortValues = { asc: "ascending", desc: "descending" }; 1153 var sortLabels = { 1154 asc: (0, import_i18n.__)("Sort ascending"), 1155 desc: (0, import_i18n.__)("Sort descending") 1156 }; 1157 var sortIcons = { 1158 asc: arrow_up_default, 1159 desc: arrow_down_default 1160 }; 1161 var LAYOUT_TABLE = "table"; 1162 var LAYOUT_GRID = "grid"; 1163 var LAYOUT_LIST = "list"; 1164 var LAYOUT_ACTIVITY = "activity"; 1165 var LAYOUT_PICKER_GRID = "pickerGrid"; 1166 var LAYOUT_PICKER_TABLE = "pickerTable"; 1167 1168 // packages/dataviews/build-module/components/dataviews-context/index.js 1169 var DataViewsContext = (0, import_element2.createContext)({ 1170 view: { type: LAYOUT_TABLE }, 1171 onChangeView: () => { 1172 }, 1173 fields: [], 1174 data: [], 1175 paginationInfo: { 1176 totalItems: 0, 1177 totalPages: 0 1178 }, 1179 selection: [], 1180 onChangeSelection: () => { 1181 }, 1182 setOpenedFilter: () => { 1183 }, 1184 openedFilter: null, 1185 getItemId: (item) => item.id, 1186 isItemClickable: () => true, 1187 renderItemLink: void 0, 1188 containerWidth: 0, 1189 containerRef: (0, import_element2.createRef)(), 1190 resizeObserverRef: () => { 1191 }, 1192 defaultLayouts: { list: {}, grid: {}, table: {} }, 1193 filters: [], 1194 isShowingFilter: false, 1195 setIsShowingFilter: () => { 1196 }, 1197 hasInfiniteScrollHandler: false, 1198 config: { 1199 perPageSizes: [] 1200 } 1201 }); 1202 DataViewsContext.displayName = "DataViewsContext"; 1203 var dataviews_context_default = DataViewsContext; 1204 1205 // packages/dataviews/build-module/dataviews-layouts/index.js 1206 var import_i18n20 = __toESM(require_i18n()); 1207 1208 // node_modules/clsx/dist/clsx.mjs 1209 function r(e2) { 1210 var t2, f2, n2 = ""; 1211 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2; 1212 else if ("object" == typeof e2) if (Array.isArray(e2)) { 1213 var o2 = e2.length; 1214 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2); 1215 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2); 1216 return n2; 1217 } 1218 function clsx() { 1219 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2); 1220 return n2; 1221 } 1222 var clsx_default = clsx; 1223 1224 // packages/dataviews/build-module/dataviews-layouts/table/index.js 1225 var import_i18n8 = __toESM(require_i18n()); 1226 var import_components7 = __toESM(require_components()); 1227 var import_element9 = __toESM(require_element()); 1228 var import_keycodes = __toESM(require_keycodes()); 1229 1230 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.js 1231 var import_components = __toESM(require_components()); 1232 var import_i18n2 = __toESM(require_i18n()); 1233 var import_jsx_runtime29 = __toESM(require_jsx_runtime()); 1234 function DataViewsSelectionCheckbox({ 1235 selection, 1236 onChangeSelection, 1237 item, 1238 getItemId: getItemId2, 1239 titleField, 1240 disabled, 1241 ...extraProps 1242 }) { 1243 const id = getItemId2(item); 1244 const checked = !disabled && selection.includes(id); 1245 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)"); 1246 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 1247 import_components.CheckboxControl, 1248 { 1249 className: "dataviews-selection-checkbox", 1250 "aria-label": selectionLabel, 1251 "aria-disabled": disabled, 1252 checked, 1253 onChange: () => { 1254 if (disabled) { 1255 return; 1256 } 1257 onChangeSelection( 1258 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 1259 ); 1260 }, 1261 ...extraProps 1262 } 1263 ); 1264 } 1265 1266 // packages/dataviews/build-module/components/dataviews-item-actions/index.js 1267 var import_components2 = __toESM(require_components()); 1268 var import_i18n3 = __toESM(require_i18n()); 1269 var import_element3 = __toESM(require_element()); 1270 var import_data3 = __toESM(require_data()); 1271 var import_compose = __toESM(require_compose()); 1272 1273 // packages/dataviews/build-module/lock-unlock.js 1274 var import_private_apis = __toESM(require_private_apis()); 1275 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 1276 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 1277 "@wordpress/dataviews" 1278 ); 1279 1280 // packages/dataviews/build-module/components/dataviews-item-actions/index.js 1281 var import_jsx_runtime30 = __toESM(require_jsx_runtime()); 1282 var { Menu, kebabCase } = unlock(import_components2.privateApis); 1283 function ButtonTrigger({ 1284 action, 1285 onClick, 1286 items, 1287 variant 1288 }) { 1289 const label = typeof action.label === "string" ? action.label : action.label(items); 1290 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1291 import_components2.Button, 1292 { 1293 disabled: !!action.disabled, 1294 accessibleWhenDisabled: true, 1295 size: "compact", 1296 variant, 1297 onClick, 1298 children: label 1299 } 1300 ); 1301 } 1302 function MenuItemTrigger({ 1303 action, 1304 onClick, 1305 items 1306 }) { 1307 const label = typeof action.label === "string" ? action.label : action.label(items); 1308 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Menu.ItemLabel, { children: label }) }); 1309 } 1310 function ActionModal({ 1311 action, 1312 items, 1313 closeModal 1314 }) { 1315 const label = typeof action.label === "string" ? action.label : action.label(items); 1316 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader; 1317 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1318 import_components2.Modal, 1319 { 1320 title: modalHeader || label, 1321 __experimentalHideHeader: !!action.hideModalHeader, 1322 onRequestClose: closeModal, 1323 focusOnMount: action.modalFocusOnMount ?? true, 1324 size: action.modalSize || "medium", 1325 overlayClassName: `dataviews-action-modal dataviews-action-modal__$kebabCase( 1326 action.id 1327 )}`, 1328 children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(action.RenderModal, { items, closeModal }) 1329 } 1330 ); 1331 } 1332 function ActionsMenuGroup({ 1333 actions, 1334 item, 1335 registry, 1336 setActiveModalAction 1337 }) { 1338 const { primaryActions, regularActions } = (0, import_element3.useMemo)(() => { 1339 return actions.reduce( 1340 (acc, action) => { 1341 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action); 1342 return acc; 1343 }, 1344 { 1345 primaryActions: [], 1346 regularActions: [] 1347 } 1348 ); 1349 }, [actions]); 1350 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1351 MenuItemTrigger, 1352 { 1353 action, 1354 onClick: () => { 1355 if ("RenderModal" in action) { 1356 setActiveModalAction(action); 1357 return; 1358 } 1359 action.callback([item], { registry }); 1360 }, 1361 items: [item] 1362 }, 1363 action.id 1364 )); 1365 return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Menu.Group, { children: [ 1366 renderActionGroup(primaryActions), 1367 primaryActions.length > 0 && regularActions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Menu.Separator, {}), 1368 renderActionGroup(regularActions) 1369 ] }); 1370 } 1371 function ItemActions({ 1372 item, 1373 actions, 1374 isCompact 1375 }) { 1376 const registry = (0, import_data3.useRegistry)(); 1377 const { primaryActions, eligibleActions } = (0, import_element3.useMemo)(() => { 1378 const _eligibleActions = actions.filter( 1379 (action) => !action.isEligible || action.isEligible(item) 1380 ); 1381 const _primaryActions = _eligibleActions.filter( 1382 (action) => action.isPrimary 1383 ); 1384 return { 1385 primaryActions: _primaryActions, 1386 eligibleActions: _eligibleActions 1387 }; 1388 }, [actions, item]); 1389 if (isCompact) { 1390 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1391 CompactItemActions, 1392 { 1393 item, 1394 actions: eligibleActions, 1395 isSmall: true, 1396 registry 1397 } 1398 ); 1399 } 1400 return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)( 1401 import_components2.__experimentalHStack, 1402 { 1403 spacing: 0, 1404 justify: "flex-end", 1405 className: "dataviews-item-actions", 1406 style: { 1407 flexShrink: 0, 1408 width: "auto" 1409 }, 1410 children: [ 1411 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1412 PrimaryActions, 1413 { 1414 item, 1415 actions: primaryActions, 1416 registry 1417 } 1418 ), 1419 primaryActions.length < eligibleActions.length && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1420 CompactItemActions, 1421 { 1422 item, 1423 actions: eligibleActions, 1424 registry 1425 } 1426 ) 1427 ] 1428 } 1429 ); 1430 } 1431 function CompactItemActions({ 1432 item, 1433 actions, 1434 isSmall, 1435 registry 1436 }) { 1437 const [activeModalAction, setActiveModalAction] = (0, import_element3.useState)( 1438 null 1439 ); 1440 return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [ 1441 /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Menu, { placement: "bottom-end", children: [ 1442 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1443 Menu.TriggerButton, 1444 { 1445 render: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1446 import_components2.Button, 1447 { 1448 size: isSmall ? "small" : "compact", 1449 icon: more_vertical_default, 1450 label: (0, import_i18n3.__)("Actions"), 1451 accessibleWhenDisabled: true, 1452 disabled: !actions.length, 1453 className: "dataviews-all-actions-button" 1454 } 1455 ) 1456 } 1457 ), 1458 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1459 ActionsMenuGroup, 1460 { 1461 actions, 1462 item, 1463 registry, 1464 setActiveModalAction 1465 } 1466 ) }) 1467 ] }), 1468 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1469 ActionModal, 1470 { 1471 action: activeModalAction, 1472 items: [item], 1473 closeModal: () => setActiveModalAction(null) 1474 } 1475 ) 1476 ] }); 1477 } 1478 function PrimaryActions({ 1479 item, 1480 actions, 1481 registry, 1482 buttonVariant 1483 }) { 1484 const [activeModalAction, setActiveModalAction] = (0, import_element3.useState)(null); 1485 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<"); 1486 if (isMobileViewport) { 1487 return null; 1488 } 1489 if (!Array.isArray(actions) || actions.length === 0) { 1490 return null; 1491 } 1492 return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [ 1493 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1494 ButtonTrigger, 1495 { 1496 action, 1497 onClick: () => { 1498 if ("RenderModal" in action) { 1499 setActiveModalAction(action); 1500 return; 1501 } 1502 action.callback([item], { registry }); 1503 }, 1504 items: [item], 1505 variant: buttonVariant 1506 }, 1507 action.id 1508 )), 1509 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 1510 ActionModal, 1511 { 1512 action: activeModalAction, 1513 items: [item], 1514 closeModal: () => setActiveModalAction(null) 1515 } 1516 ) 1517 ] }); 1518 } 1519 1520 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.js 1521 var import_components3 = __toESM(require_components()); 1522 var import_i18n4 = __toESM(require_i18n()); 1523 var import_element4 = __toESM(require_element()); 1524 var import_data4 = __toESM(require_data()); 1525 var import_compose2 = __toESM(require_compose()); 1526 var import_jsx_runtime31 = __toESM(require_jsx_runtime()); 1527 function ActionWithModal({ 1528 action, 1529 items, 1530 ActionTriggerComponent 1531 }) { 1532 const [isModalOpen, setIsModalOpen] = (0, import_element4.useState)(false); 1533 const actionTriggerProps = { 1534 action, 1535 onClick: () => { 1536 setIsModalOpen(true); 1537 }, 1538 items 1539 }; 1540 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [ 1541 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ActionTriggerComponent, { ...actionTriggerProps }), 1542 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 1543 ActionModal, 1544 { 1545 action, 1546 items, 1547 closeModal: () => setIsModalOpen(false) 1548 } 1549 ) 1550 ] }); 1551 } 1552 function useHasAPossibleBulkAction(actions, item) { 1553 return (0, import_element4.useMemo)(() => { 1554 return actions.some((action) => { 1555 return action.supportsBulk && (!action.isEligible || action.isEligible(item)); 1556 }); 1557 }, [actions, item]); 1558 } 1559 function useSomeItemHasAPossibleBulkAction(actions, data) { 1560 return (0, import_element4.useMemo)(() => { 1561 return data.some((item) => { 1562 return actions.some((action) => { 1563 return action.supportsBulk && (!action.isEligible || action.isEligible(item)); 1564 }); 1565 }); 1566 }, [actions, data]); 1567 } 1568 function BulkSelectionCheckbox({ 1569 selection, 1570 onChangeSelection, 1571 data, 1572 actions, 1573 getItemId: getItemId2 1574 }) { 1575 const selectableItems = (0, import_element4.useMemo)(() => { 1576 return data.filter((item) => { 1577 return actions.some( 1578 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item)) 1579 ); 1580 }); 1581 }, [data, actions]); 1582 const selectedItems = data.filter( 1583 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item) 1584 ); 1585 const areAllSelected = selectedItems.length === selectableItems.length; 1586 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 1587 import_components3.CheckboxControl, 1588 { 1589 className: "dataviews-view-table-selection-checkbox", 1590 checked: areAllSelected, 1591 indeterminate: !areAllSelected && !!selectedItems.length, 1592 onChange: () => { 1593 if (areAllSelected) { 1594 onChangeSelection([]); 1595 } else { 1596 onChangeSelection( 1597 selectableItems.map((item) => getItemId2(item)) 1598 ); 1599 } 1600 }, 1601 "aria-label": areAllSelected ? (0, import_i18n4.__)("Deselect all") : (0, import_i18n4.__)("Select all") 1602 } 1603 ); 1604 } 1605 function ActionTrigger({ 1606 action, 1607 onClick, 1608 isBusy, 1609 items 1610 }) { 1611 const label = typeof action.label === "string" ? action.label : action.label(items); 1612 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<"); 1613 if (isMobile) { 1614 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 1615 import_components3.Button, 1616 { 1617 disabled: isBusy, 1618 accessibleWhenDisabled: true, 1619 label, 1620 icon: action.icon, 1621 size: "compact", 1622 onClick, 1623 isBusy 1624 } 1625 ); 1626 } 1627 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 1628 import_components3.Button, 1629 { 1630 disabled: isBusy, 1631 accessibleWhenDisabled: true, 1632 size: "compact", 1633 onClick, 1634 isBusy, 1635 children: label 1636 } 1637 ); 1638 } 1639 var EMPTY_ARRAY = []; 1640 function ActionButton({ 1641 action, 1642 selectedItems, 1643 actionInProgress, 1644 setActionInProgress 1645 }) { 1646 const registry = (0, import_data4.useRegistry)(); 1647 const selectedEligibleItems = (0, import_element4.useMemo)(() => { 1648 return selectedItems.filter((item) => { 1649 return !action.isEligible || action.isEligible(item); 1650 }); 1651 }, [action, selectedItems]); 1652 if ("RenderModal" in action) { 1653 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 1654 ActionWithModal, 1655 { 1656 action, 1657 items: selectedEligibleItems, 1658 ActionTriggerComponent: ActionTrigger 1659 }, 1660 action.id 1661 ); 1662 } 1663 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 1664 ActionTrigger, 1665 { 1666 action, 1667 onClick: async () => { 1668 setActionInProgress(action.id); 1669 await action.callback(selectedItems, { 1670 registry 1671 }); 1672 setActionInProgress(null); 1673 }, 1674 items: selectedEligibleItems, 1675 isBusy: actionInProgress === action.id 1676 }, 1677 action.id 1678 ); 1679 } 1680 function renderFooterContent(data, actions, getItemId2, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection) { 1681 const message2 = selectedItems.length > 0 ? (0, import_i18n4.sprintf)( 1682 /* translators: %d: number of items. */ 1683 (0, import_i18n4._n)( 1684 "%d Item selected", 1685 "%d Items selected", 1686 selectedItems.length 1687 ), 1688 selectedItems.length 1689 ) : (0, import_i18n4.sprintf)( 1690 /* translators: %d: number of items. */ 1691 (0, import_i18n4._n)("%d Item", "%d Items", data.length), 1692 data.length 1693 ); 1694 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)( 1695 import_components3.__experimentalHStack, 1696 { 1697 expanded: false, 1698 className: "dataviews-bulk-actions-footer__container", 1699 spacing: 3, 1700 children: [ 1701 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 1702 BulkSelectionCheckbox, 1703 { 1704 selection, 1705 onChangeSelection, 1706 data, 1707 actions, 1708 getItemId: getItemId2 1709 } 1710 ), 1711 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }), 1712 /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)( 1713 import_components3.__experimentalHStack, 1714 { 1715 className: "dataviews-bulk-actions-footer__action-buttons", 1716 expanded: false, 1717 spacing: 1, 1718 children: [ 1719 actionsToShow.map((action) => { 1720 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 1721 ActionButton, 1722 { 1723 action, 1724 selectedItems, 1725 actionInProgress, 1726 setActionInProgress 1727 }, 1728 action.id 1729 ); 1730 }), 1731 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 1732 import_components3.Button, 1733 { 1734 icon: close_small_default, 1735 showTooltip: true, 1736 tooltipPosition: "top", 1737 size: "compact", 1738 label: (0, import_i18n4.__)("Cancel"), 1739 disabled: !!actionInProgress, 1740 accessibleWhenDisabled: false, 1741 onClick: () => { 1742 onChangeSelection(EMPTY_ARRAY); 1743 } 1744 } 1745 ) 1746 ] 1747 } 1748 ) 1749 ] 1750 } 1751 ); 1752 } 1753 function FooterContent({ 1754 selection, 1755 actions, 1756 onChangeSelection, 1757 data, 1758 getItemId: getItemId2 1759 }) { 1760 const [actionInProgress, setActionInProgress] = (0, import_element4.useState)( 1761 null 1762 ); 1763 const footerContentRef = (0, import_element4.useRef)(null); 1764 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<"); 1765 const bulkActions = (0, import_element4.useMemo)( 1766 () => actions.filter((action) => action.supportsBulk), 1767 [actions] 1768 ); 1769 const selectableItems = (0, import_element4.useMemo)(() => { 1770 return data.filter((item) => { 1771 return bulkActions.some( 1772 (action) => !action.isEligible || action.isEligible(item) 1773 ); 1774 }); 1775 }, [data, bulkActions]); 1776 const selectedItems = (0, import_element4.useMemo)(() => { 1777 return data.filter( 1778 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item) 1779 ); 1780 }, [selection, data, getItemId2, selectableItems]); 1781 const actionsToShow = (0, import_element4.useMemo)( 1782 () => actions.filter((action) => { 1783 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some( 1784 (item) => !action.isEligible || action.isEligible(item) 1785 ); 1786 }), 1787 [actions, selectedItems, isMobile] 1788 ); 1789 if (!actionInProgress) { 1790 if (footerContentRef.current) { 1791 footerContentRef.current = null; 1792 } 1793 return renderFooterContent( 1794 data, 1795 actions, 1796 getItemId2, 1797 selection, 1798 actionsToShow, 1799 selectedItems, 1800 actionInProgress, 1801 setActionInProgress, 1802 onChangeSelection 1803 ); 1804 } else if (!footerContentRef.current) { 1805 footerContentRef.current = renderFooterContent( 1806 data, 1807 actions, 1808 getItemId2, 1809 selection, 1810 actionsToShow, 1811 selectedItems, 1812 actionInProgress, 1813 setActionInProgress, 1814 onChangeSelection 1815 ); 1816 } 1817 return footerContentRef.current; 1818 } 1819 function BulkActionsFooter() { 1820 const { 1821 data, 1822 selection, 1823 actions = EMPTY_ARRAY, 1824 onChangeSelection, 1825 getItemId: getItemId2 1826 } = (0, import_element4.useContext)(dataviews_context_default); 1827 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)( 1828 FooterContent, 1829 { 1830 selection, 1831 onChangeSelection, 1832 data, 1833 actions, 1834 getItemId: getItemId2 1835 } 1836 ); 1837 } 1838 1839 // packages/dataviews/build-module/dataviews-layouts/table/column-header-menu.js 1840 var import_i18n5 = __toESM(require_i18n()); 1841 var import_components4 = __toESM(require_components()); 1842 var import_element5 = __toESM(require_element()); 1843 1844 // packages/dataviews/build-module/utils/get-hideable-fields.js 1845 function getHideableFields(view, fields) { 1846 const togglableFields = [ 1847 view?.titleField, 1848 view?.mediaField, 1849 view?.descriptionField 1850 ].filter(Boolean); 1851 return fields.filter( 1852 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false 1853 ); 1854 } 1855 1856 // packages/dataviews/build-module/dataviews-layouts/table/column-header-menu.js 1857 var import_jsx_runtime32 = __toESM(require_jsx_runtime()); 1858 var { Menu: Menu2 } = unlock(import_components4.privateApis); 1859 function WithMenuSeparators({ children }) { 1860 return import_element5.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_element5.Fragment, { children: [ 1861 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.Separator, {}), 1862 child 1863 ] }, i2)); 1864 } 1865 var _HeaderMenu = (0, import_element5.forwardRef)(function HeaderMenu({ 1866 fieldId, 1867 view, 1868 fields, 1869 onChangeView, 1870 onHide, 1871 setOpenedFilter, 1872 canMove = true, 1873 canInsertLeft = true, 1874 canInsertRight = true 1875 }, ref) { 1876 const visibleFieldIds = view.fields ?? []; 1877 const index = visibleFieldIds?.indexOf(fieldId); 1878 const isSorted = view.sort?.field === fieldId; 1879 let isHidable = false; 1880 let isSortable = false; 1881 let canAddFilter = false; 1882 let operators = []; 1883 const field = fields.find((f2) => f2.id === fieldId); 1884 const { setIsShowingFilter } = (0, import_element5.useContext)(dataviews_context_default); 1885 if (!field) { 1886 return null; 1887 } 1888 isHidable = field.enableHiding !== false; 1889 isSortable = field.enableSorting !== false; 1890 const header = field.header; 1891 operators = !!field.filterBy && field.filterBy?.operators || []; 1892 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary; 1893 if (!isSortable && !canMove && !isHidable && !canAddFilter) { 1894 return header; 1895 } 1896 const hiddenFields = getHideableFields(view, fields).filter( 1897 (f2) => !visibleFieldIds.includes(f2.id) 1898 ); 1899 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length; 1900 return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(Menu2, { children: [ 1901 /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)( 1902 Menu2.TriggerButton, 1903 { 1904 render: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( 1905 import_components4.Button, 1906 { 1907 size: "compact", 1908 className: "dataviews-view-table-header-button", 1909 ref, 1910 variant: "tertiary" 1911 } 1912 ), 1913 children: [ 1914 header, 1915 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] }) 1916 ] 1917 } 1918 ), 1919 /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(WithMenuSeparators, { children: [ 1920 isSortable && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map( 1921 (direction) => { 1922 const isChecked = view.sort && isSorted && view.sort.direction === direction; 1923 const value = `$fieldId}-$direction}`; 1924 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( 1925 Menu2.RadioItem, 1926 { 1927 name: "view-table-sorting", 1928 value, 1929 checked: isChecked, 1930 onChange: () => { 1931 onChangeView({ 1932 ...view, 1933 sort: { 1934 field: fieldId, 1935 direction 1936 }, 1937 showLevels: false 1938 }); 1939 }, 1940 children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] }) 1941 }, 1942 value 1943 ); 1944 } 1945 ) }), 1946 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( 1947 Menu2.Item, 1948 { 1949 prefix: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_components4.Icon, { icon: funnel_default }), 1950 onClick: () => { 1951 setOpenedFilter(fieldId); 1952 setIsShowingFilter(true); 1953 onChangeView({ 1954 ...view, 1955 page: 1, 1956 filters: [ 1957 ...view.filters || [], 1958 { 1959 field: fieldId, 1960 value: void 0, 1961 operator: operators[0] 1962 } 1963 ] 1964 }); 1965 }, 1966 children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Add filter") }) 1967 } 1968 ) }), 1969 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(Menu2.Group, { children: [ 1970 canMove && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( 1971 Menu2.Item, 1972 { 1973 prefix: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_components4.Icon, { icon: arrow_left_default }), 1974 disabled: index < 1, 1975 onClick: () => { 1976 onChangeView({ 1977 ...view, 1978 fields: [ 1979 ...visibleFieldIds.slice( 1980 0, 1981 index - 1 1982 ) ?? [], 1983 fieldId, 1984 visibleFieldIds[index - 1], 1985 ...visibleFieldIds.slice( 1986 index + 1 1987 ) 1988 ] 1989 }); 1990 }, 1991 children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Move left") }) 1992 } 1993 ), 1994 canMove && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( 1995 Menu2.Item, 1996 { 1997 prefix: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_components4.Icon, { icon: arrow_right_default }), 1998 disabled: index >= visibleFieldIds.length - 1, 1999 onClick: () => { 2000 onChangeView({ 2001 ...view, 2002 fields: [ 2003 ...visibleFieldIds.slice( 2004 0, 2005 index 2006 ) ?? [], 2007 visibleFieldIds[index + 1], 2008 fieldId, 2009 ...visibleFieldIds.slice( 2010 index + 2 2011 ) 2012 ] 2013 }); 2014 }, 2015 children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Move right") }) 2016 } 2017 ), 2018 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(Menu2, { children: [ 2019 /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Insert left") }) }), 2020 /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( 2021 Menu2.Item, 2022 { 2023 onClick: () => { 2024 onChangeView({ 2025 ...view, 2026 fields: [ 2027 ...visibleFieldIds.slice( 2028 0, 2029 index 2030 ), 2031 hiddenField.id, 2032 ...visibleFieldIds.slice( 2033 index 2034 ) 2035 ] 2036 }); 2037 }, 2038 children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 2039 }, 2040 hiddenField.id 2041 )) }) 2042 ] }), 2043 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(Menu2, { children: [ 2044 /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Insert right") }) }), 2045 /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( 2046 Menu2.Item, 2047 { 2048 onClick: () => { 2049 onChangeView({ 2050 ...view, 2051 fields: [ 2052 ...visibleFieldIds.slice( 2053 0, 2054 index + 1 2055 ), 2056 hiddenField.id, 2057 ...visibleFieldIds.slice( 2058 index + 1 2059 ) 2060 ] 2061 }); 2062 }, 2063 children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 2064 }, 2065 hiddenField.id 2066 )) }) 2067 ] }), 2068 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( 2069 Menu2.Item, 2070 { 2071 prefix: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_components4.Icon, { icon: unseen_default }), 2072 onClick: () => { 2073 onHide(field); 2074 onChangeView({ 2075 ...view, 2076 fields: visibleFieldIds.filter( 2077 (id) => id !== fieldId 2078 ) 2079 }); 2080 }, 2081 children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Hide column") }) 2082 } 2083 ) 2084 ] }) 2085 ] }) }) 2086 ] }); 2087 }); 2088 var ColumnHeaderMenu = _HeaderMenu; 2089 var column_header_menu_default = ColumnHeaderMenu; 2090 2091 // packages/dataviews/build-module/dataviews-layouts/table/column-primary.js 2092 var import_components5 = __toESM(require_components()); 2093 2094 // packages/dataviews/build-module/dataviews-layouts/utils/item-click-wrapper.js 2095 var import_element6 = __toESM(require_element()); 2096 var import_jsx_runtime33 = __toESM(require_jsx_runtime()); 2097 function getClickableItemProps({ 2098 item, 2099 isItemClickable, 2100 onClickItem, 2101 className 2102 }) { 2103 if (!isItemClickable(item) || !onClickItem) { 2104 return { className }; 2105 } 2106 return { 2107 className: className ? `$className} $className}--clickable` : void 0, 2108 role: "button", 2109 tabIndex: 0, 2110 onClick: (event) => { 2111 event.stopPropagation(); 2112 onClickItem(item); 2113 }, 2114 onKeyDown: (event) => { 2115 if (event.key === "Enter" || event.key === "" || event.key === " ") { 2116 event.stopPropagation(); 2117 onClickItem(item); 2118 } 2119 } 2120 }; 2121 } 2122 function ItemClickWrapper({ 2123 item, 2124 isItemClickable, 2125 onClickItem, 2126 renderItemLink, 2127 className, 2128 children, 2129 ...extraProps 2130 }) { 2131 if (!isItemClickable(item)) { 2132 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className, ...extraProps, children }); 2133 } 2134 if (renderItemLink) { 2135 const renderedElement = renderItemLink({ 2136 item, 2137 className: `$className} $className}--clickable`, 2138 ...extraProps, 2139 children 2140 }); 2141 return (0, import_element6.cloneElement)(renderedElement, { 2142 onClick: (event) => { 2143 event.stopPropagation(); 2144 if (renderedElement.props.onClick) { 2145 renderedElement.props.onClick(event); 2146 } 2147 }, 2148 onKeyDown: (event) => { 2149 if (event.key === "Enter" || event.key === "" || event.key === " ") { 2150 event.stopPropagation(); 2151 if (renderedElement.props.onKeyDown) { 2152 renderedElement.props.onKeyDown(event); 2153 } 2154 } 2155 } 2156 }); 2157 } 2158 const clickProps = getClickableItemProps({ 2159 item, 2160 isItemClickable, 2161 onClickItem, 2162 className 2163 }); 2164 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { ...clickProps, ...extraProps, children }); 2165 } 2166 2167 // packages/dataviews/build-module/dataviews-layouts/table/column-primary.js 2168 var import_jsx_runtime34 = __toESM(require_jsx_runtime()); 2169 function ColumnPrimary({ 2170 item, 2171 level, 2172 titleField, 2173 mediaField, 2174 descriptionField, 2175 onClickItem, 2176 renderItemLink, 2177 isItemClickable 2178 }) { 2179 return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_components5.__experimentalHStack, { spacing: 3, alignment: "flex-start", justify: "flex-start", children: [ 2180 mediaField && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)( 2181 ItemClickWrapper, 2182 { 2183 item, 2184 isItemClickable, 2185 onClickItem, 2186 renderItemLink, 2187 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media", 2188 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0, 2189 children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)( 2190 mediaField.render, 2191 { 2192 item, 2193 field: mediaField, 2194 config: { sizes: "32px" } 2195 } 2196 ) 2197 } 2198 ), 2199 /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)( 2200 import_components5.__experimentalVStack, 2201 { 2202 spacing: 0, 2203 alignment: "flex-start", 2204 className: "dataviews-view-table__primary-column-content", 2205 children: [ 2206 titleField && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)( 2207 ItemClickWrapper, 2208 { 2209 item, 2210 isItemClickable, 2211 onClickItem, 2212 renderItemLink, 2213 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field", 2214 children: [ 2215 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("span", { className: "dataviews-view-table__level", children: [ 2216 "\u2014".repeat(level), 2217 "\xA0" 2218 ] }), 2219 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(titleField.render, { item, field: titleField }) 2220 ] 2221 } 2222 ), 2223 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)( 2224 descriptionField.render, 2225 { 2226 item, 2227 field: descriptionField 2228 } 2229 ) 2230 ] 2231 } 2232 ) 2233 ] }); 2234 } 2235 var column_primary_default = ColumnPrimary; 2236 2237 // packages/dataviews/build-module/dataviews-layouts/table/use-is-horizontal-scroll-end.js 2238 var import_compose3 = __toESM(require_compose()); 2239 var import_element7 = __toESM(require_element()); 2240 var import_i18n6 = __toESM(require_i18n()); 2241 var isScrolledToEnd = (element) => { 2242 if ((0, import_i18n6.isRTL)()) { 2243 const scrollLeft = Math.abs(element.scrollLeft); 2244 return scrollLeft <= 1; 2245 } 2246 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1; 2247 }; 2248 function useIsHorizontalScrollEnd({ 2249 scrollContainerRef, 2250 enabled = false 2251 }) { 2252 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element7.useState)(false); 2253 const handleIsHorizontalScrollEnd = (0, import_compose3.useDebounce)( 2254 (0, import_element7.useCallback)(() => { 2255 const scrollContainer = scrollContainerRef.current; 2256 if (scrollContainer) { 2257 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer)); 2258 } 2259 }, [scrollContainerRef, setIsHorizontalScrollEnd]), 2260 200 2261 ); 2262 (0, import_element7.useEffect)(() => { 2263 if (typeof window === "undefined" || !enabled || !scrollContainerRef.current) { 2264 return () => { 2265 }; 2266 } 2267 handleIsHorizontalScrollEnd(); 2268 scrollContainerRef.current.addEventListener( 2269 "scroll", 2270 handleIsHorizontalScrollEnd 2271 ); 2272 window.addEventListener("resize", handleIsHorizontalScrollEnd); 2273 return () => { 2274 scrollContainerRef.current?.removeEventListener( 2275 "scroll", 2276 handleIsHorizontalScrollEnd 2277 ); 2278 window.removeEventListener("resize", handleIsHorizontalScrollEnd); 2279 }; 2280 }, [scrollContainerRef, enabled]); 2281 return isHorizontalScrollEnd; 2282 } 2283 2284 // packages/dataviews/build-module/dataviews-layouts/utils/get-data-by-group.js 2285 function getDataByGroup(data, groupByField) { 2286 return data.reduce((groups, item) => { 2287 const groupName = groupByField.getValue({ item }); 2288 if (!groups.has(groupName)) { 2289 groups.set(groupName, []); 2290 } 2291 groups.get(groupName)?.push(item); 2292 return groups; 2293 }, /* @__PURE__ */ new Map()); 2294 } 2295 2296 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.js 2297 var import_components6 = __toESM(require_components()); 2298 var import_i18n7 = __toESM(require_i18n()); 2299 var import_element8 = __toESM(require_element()); 2300 var import_jsx_runtime35 = __toESM(require_jsx_runtime()); 2301 function FieldItem({ 2302 field, 2303 isVisible: isVisible2, 2304 onToggleVisibility 2305 }) { 2306 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_components6.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_components6.__experimentalHStack, { expanded: true, justify: "flex-start", alignment: "center", children: [ 2307 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_components6.Icon, { icon: check_default }) }), 2308 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "dataviews-view-config__label", children: field.label }) 2309 ] }) }); 2310 } 2311 function isDefined(item) { 2312 return !!item; 2313 } 2314 function PropertiesSection({ 2315 showLabel = true 2316 }) { 2317 const { view, fields, onChangeView } = (0, import_element8.useContext)(dataviews_context_default); 2318 const regularFields = getHideableFields(view, fields); 2319 if (!regularFields?.length) { 2320 return null; 2321 } 2322 const titleField = fields.find((f2) => f2.id === view.titleField); 2323 const previewField2 = fields.find((f2) => f2.id === view.mediaField); 2324 const descriptionField = fields.find( 2325 (f2) => f2.id === view.descriptionField 2326 ); 2327 const lockedFields = [ 2328 { 2329 field: titleField, 2330 isVisibleFlag: "showTitle" 2331 }, 2332 { 2333 field: previewField2, 2334 isVisibleFlag: "showMedia" 2335 }, 2336 { 2337 field: descriptionField, 2338 isVisibleFlag: "showDescription" 2339 } 2340 ].filter(({ field }) => isDefined(field)); 2341 const visibleFieldIds = view.fields ?? []; 2342 const visibleRegularFieldsCount = regularFields.filter( 2343 (f2) => visibleFieldIds.includes(f2.id) 2344 ).length; 2345 let visibleLockedFields = lockedFields.filter( 2346 ({ field, isVisibleFlag }) => ( 2347 // @ts-expect-error 2348 isDefined(field) && (view[isVisibleFlag] ?? true) 2349 ) 2350 ); 2351 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount; 2352 if (totalVisibleFields === 1) { 2353 if (visibleLockedFields.length === 1) { 2354 visibleLockedFields = visibleLockedFields.map((locked) => ({ 2355 ...locked, 2356 field: { ...locked.field, enableHiding: false } 2357 })); 2358 } 2359 } 2360 const hiddenLockedFields = lockedFields.filter( 2361 ({ field, isVisibleFlag }) => ( 2362 // @ts-expect-error 2363 isDefined(field) && !(view[isVisibleFlag] ?? true) 2364 ) 2365 ); 2366 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_components6.__experimentalVStack, { className: "dataviews-field-control", spacing: 0, children: [ 2367 showLabel && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_components6.BaseControl.VisualLabel, { children: (0, import_i18n7.__)("Properties") }), 2368 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_components6.__experimentalVStack, { className: "dataviews-view-config__properties", spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_components6.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [ 2369 visibleLockedFields.map(({ field, isVisibleFlag }) => { 2370 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2371 FieldItem, 2372 { 2373 field, 2374 isVisible: true, 2375 onToggleVisibility: () => { 2376 onChangeView({ 2377 ...view, 2378 [isVisibleFlag]: false 2379 }); 2380 } 2381 }, 2382 field.id 2383 ); 2384 }), 2385 hiddenLockedFields.map(({ field, isVisibleFlag }) => { 2386 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2387 FieldItem, 2388 { 2389 field, 2390 isVisible: false, 2391 onToggleVisibility: () => { 2392 onChangeView({ 2393 ...view, 2394 [isVisibleFlag]: true 2395 }); 2396 } 2397 }, 2398 field.id 2399 ); 2400 }), 2401 regularFields.map((field) => { 2402 const isVisible2 = visibleFieldIds.includes(field.id); 2403 const isLastVisible = totalVisibleFields === 1 && isVisible2; 2404 const fieldToRender = isLastVisible ? { ...field, enableHiding: false } : field; 2405 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 2406 FieldItem, 2407 { 2408 field: fieldToRender, 2409 isVisible: isVisible2, 2410 onToggleVisibility: () => { 2411 onChangeView({ 2412 ...view, 2413 fields: isVisible2 ? visibleFieldIds.filter( 2414 (fieldId) => fieldId !== field.id 2415 ) : [...visibleFieldIds, field.id] 2416 }); 2417 } 2418 }, 2419 field.id 2420 ); 2421 }) 2422 ] }) }) 2423 ] }); 2424 } 2425 2426 // packages/dataviews/build-module/dataviews-layouts/table/index.js 2427 var import_jsx_runtime36 = __toESM(require_jsx_runtime()); 2428 function TableColumnField({ 2429 item, 2430 fields, 2431 column, 2432 align 2433 }) { 2434 const field = fields.find((f2) => f2.id === column); 2435 if (!field) { 2436 return null; 2437 } 2438 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 2439 "dataviews-view-table__cell-align-end": align === "end", 2440 "dataviews-view-table__cell-align-center": align === "center" 2441 }); 2442 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(field.render, { item, field }) }); 2443 } 2444 function TableRow({ 2445 hasBulkActions, 2446 item, 2447 level, 2448 actions, 2449 fields, 2450 id, 2451 view, 2452 titleField, 2453 mediaField, 2454 descriptionField, 2455 selection, 2456 getItemId: getItemId2, 2457 isItemClickable, 2458 onClickItem, 2459 renderItemLink, 2460 onChangeSelection, 2461 isActionsColumnSticky, 2462 posinset 2463 }) { 2464 const { paginationInfo } = (0, import_element9.useContext)(dataviews_context_default); 2465 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item); 2466 const isSelected2 = hasPossibleBulkAction && selection.includes(id); 2467 const { 2468 showTitle = true, 2469 showMedia = true, 2470 showDescription = true, 2471 infiniteScrollEnabled 2472 } = view; 2473 const isTouchDeviceRef = (0, import_element9.useRef)(false); 2474 const columns = view.fields ?? []; 2475 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription; 2476 return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)( 2477 "tr", 2478 { 2479 className: clsx_default("dataviews-view-table__row", { 2480 "is-selected": hasPossibleBulkAction && isSelected2, 2481 "has-bulk-actions": hasPossibleBulkAction 2482 }), 2483 onTouchStart: () => { 2484 isTouchDeviceRef.current = true; 2485 }, 2486 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 2487 "aria-posinset": posinset, 2488 role: infiniteScrollEnabled ? "article" : void 0, 2489 onMouseDown: (event) => { 2490 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey; 2491 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) { 2492 event?.preventDefault(); 2493 } 2494 }, 2495 onClick: (event) => { 2496 if (!hasPossibleBulkAction) { 2497 return; 2498 } 2499 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey; 2500 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") { 2501 onChangeSelection( 2502 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 2503 ); 2504 } 2505 }, 2506 children: [ 2507 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2508 DataViewsSelectionCheckbox, 2509 { 2510 item, 2511 selection, 2512 onChangeSelection, 2513 getItemId: getItemId2, 2514 titleField, 2515 disabled: !hasPossibleBulkAction 2516 } 2517 ) }) }), 2518 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2519 column_primary_default, 2520 { 2521 item, 2522 level, 2523 titleField: showTitle ? titleField : void 0, 2524 mediaField: showMedia ? mediaField : void 0, 2525 descriptionField: showDescription ? descriptionField : void 0, 2526 isItemClickable, 2527 onClickItem, 2528 renderItemLink 2529 } 2530 ) }), 2531 columns.map((column) => { 2532 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 2533 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2534 "td", 2535 { 2536 style: { 2537 width, 2538 maxWidth, 2539 minWidth 2540 }, 2541 children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2542 TableColumnField, 2543 { 2544 fields, 2545 item, 2546 column, 2547 align 2548 } 2549 ) 2550 }, 2551 column 2552 ); 2553 }), 2554 !!actions?.length && // Disable reason: we are not making the element interactive, 2555 // but preventing any click events from bubbling up to the 2556 // table row. This allows us to add a click handler to the row 2557 // itself (to toggle row selection) without erroneously 2558 // intercepting click events from ItemActions. 2559 /* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */ 2560 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2561 "td", 2562 { 2563 className: clsx_default("dataviews-view-table__actions-column", { 2564 "dataviews-view-table__actions-column--sticky": true, 2565 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky 2566 }), 2567 onClick: (e2) => e2.stopPropagation(), 2568 children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ItemActions, { item, actions }) 2569 } 2570 ) 2571 ] 2572 } 2573 ); 2574 } 2575 function ViewTable({ 2576 actions, 2577 data, 2578 fields, 2579 getItemId: getItemId2, 2580 getItemLevel, 2581 isLoading = false, 2582 onChangeView, 2583 onChangeSelection, 2584 selection, 2585 setOpenedFilter, 2586 onClickItem, 2587 isItemClickable, 2588 renderItemLink, 2589 view, 2590 className, 2591 empty 2592 }) { 2593 const { containerRef } = (0, import_element9.useContext)(dataviews_context_default); 2594 const headerMenuRefs = (0, import_element9.useRef)(/* @__PURE__ */ new Map()); 2595 const headerMenuToFocusRef = (0, import_element9.useRef)(); 2596 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element9.useState)(); 2597 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 2598 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element9.useState)(null); 2599 (0, import_element9.useEffect)(() => { 2600 if (headerMenuToFocusRef.current) { 2601 headerMenuToFocusRef.current.focus(); 2602 headerMenuToFocusRef.current = void 0; 2603 } 2604 }); 2605 const tableNoticeId = (0, import_element9.useId)(); 2606 const isHorizontalScrollEnd = useIsHorizontalScrollEnd({ 2607 scrollContainerRef: containerRef, 2608 enabled: !!actions?.length 2609 }); 2610 if (nextHeaderMenuToFocus) { 2611 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 2612 setNextHeaderMenuToFocus(void 0); 2613 return; 2614 } 2615 const onHide = (field) => { 2616 const hidden = headerMenuRefs.current.get(field.id); 2617 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 2618 setNextHeaderMenuToFocus(fallback?.node); 2619 }; 2620 const handleHeaderContextMenu = (event) => { 2621 event.preventDefault(); 2622 event.stopPropagation(); 2623 const virtualAnchor = { 2624 getBoundingClientRect: () => ({ 2625 x: event.clientX, 2626 y: event.clientY, 2627 top: event.clientY, 2628 left: event.clientX, 2629 right: event.clientX, 2630 bottom: event.clientY, 2631 width: 0, 2632 height: 0, 2633 toJSON: () => ({}) 2634 }) 2635 }; 2636 window.requestAnimationFrame(() => { 2637 setContextMenuAnchor(virtualAnchor); 2638 }); 2639 }; 2640 const hasData = !!data?.length; 2641 const titleField = fields.find((field) => field.id === view.titleField); 2642 const mediaField = fields.find((field) => field.id === view.mediaField); 2643 const descriptionField = fields.find( 2644 (field) => field.id === view.descriptionField 2645 ); 2646 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 2647 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 2648 const { showTitle = true, showMedia = true, showDescription = true } = view; 2649 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription; 2650 const columns = view.fields ?? []; 2651 const headerMenuRef = (column, index) => (node) => { 2652 if (node) { 2653 headerMenuRefs.current.set(column, { 2654 node, 2655 fallback: columns[index > 0 ? index - 1 : 1] 2656 }); 2657 } else { 2658 headerMenuRefs.current.delete(column); 2659 } 2660 }; 2661 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 2662 return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [ 2663 /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)( 2664 "table", 2665 { 2666 className: clsx_default("dataviews-view-table", className, { 2667 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 2668 view.layout.density 2669 ), 2670 "has-bulk-actions": hasBulkActions 2671 }), 2672 "aria-busy": isLoading, 2673 "aria-describedby": tableNoticeId, 2674 role: isInfiniteScroll ? "feed" : void 0, 2675 children: [ 2676 /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("colgroup", { children: [ 2677 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("col", { className: "dataviews-view-table__col-checkbox" }), 2678 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("col", { className: "dataviews-view-table__col-first-data" }), 2679 columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2680 "col", 2681 { 2682 className: clsx_default( 2683 `dataviews-view-table__col-$column}`, 2684 { 2685 "dataviews-view-table__col-first-data": !hasPrimaryColumn && index === 0 2686 } 2687 ) 2688 }, 2689 `col-$column}` 2690 )), 2691 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("col", { className: "dataviews-view-table__col-actions" }) 2692 ] }), 2693 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2694 import_components7.Popover, 2695 { 2696 anchor: contextMenuAnchor, 2697 onClose: () => setContextMenuAnchor(null), 2698 placement: "bottom-start", 2699 children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(PropertiesSection, { showLabel: false }) 2700 } 2701 ), 2702 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("thead", { onContextMenu: handleHeaderContextMenu, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("tr", { className: "dataviews-view-table__row", children: [ 2703 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2704 "th", 2705 { 2706 className: "dataviews-view-table__checkbox-column", 2707 scope: "col", 2708 onContextMenu: handleHeaderContextMenu, 2709 children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2710 BulkSelectionCheckbox, 2711 { 2712 selection, 2713 onChangeSelection, 2714 data, 2715 actions, 2716 getItemId: getItemId2 2717 } 2718 ) 2719 } 2720 ), 2721 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2722 column_header_menu_default, 2723 { 2724 ref: headerMenuRef( 2725 titleField.id, 2726 0 2727 ), 2728 fieldId: titleField.id, 2729 view, 2730 fields, 2731 onChangeView, 2732 onHide, 2733 setOpenedFilter, 2734 canMove: false, 2735 canInsertLeft: false, 2736 canInsertRight: view.layout?.enableMoving ?? true 2737 } 2738 ) }), 2739 columns.map((column, index) => { 2740 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 2741 const canInsertOrMove = view.layout?.enableMoving ?? true; 2742 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2743 "th", 2744 { 2745 style: { 2746 width, 2747 maxWidth, 2748 minWidth, 2749 textAlign: align 2750 }, 2751 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 2752 scope: "col", 2753 children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2754 column_header_menu_default, 2755 { 2756 ref: headerMenuRef(column, index), 2757 fieldId: column, 2758 view, 2759 fields, 2760 onChangeView, 2761 onHide, 2762 setOpenedFilter, 2763 canMove: canInsertOrMove, 2764 canInsertLeft: canInsertOrMove, 2765 canInsertRight: canInsertOrMove 2766 } 2767 ) 2768 }, 2769 column 2770 ); 2771 }), 2772 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2773 "th", 2774 { 2775 className: clsx_default( 2776 "dataviews-view-table__actions-column", 2777 { 2778 "dataviews-view-table__actions-column--sticky": true, 2779 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd 2780 } 2781 ), 2782 children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n8.__)("Actions") }) 2783 } 2784 ) 2785 ] }) }), 2786 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 2787 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("tbody", { children: [ 2788 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2789 "td", 2790 { 2791 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0), 2792 className: "dataviews-view-table__group-header-cell", 2793 children: (0, import_i18n8.sprintf)( 2794 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 2795 (0, import_i18n8.__)("%1$s: %2$s"), 2796 groupField.label, 2797 groupName 2798 ) 2799 } 2800 ) }), 2801 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2802 TableRow, 2803 { 2804 item, 2805 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0, 2806 hasBulkActions, 2807 actions, 2808 fields, 2809 id: getItemId2(item) || index.toString(), 2810 view, 2811 titleField, 2812 mediaField, 2813 descriptionField, 2814 selection, 2815 getItemId: getItemId2, 2816 onChangeSelection, 2817 onClickItem, 2818 renderItemLink, 2819 isItemClickable, 2820 isActionsColumnSticky: !isHorizontalScrollEnd 2821 }, 2822 getItemId2(item) 2823 )) 2824 ] }, `group-$groupName}`) 2825 ) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)( 2826 TableRow, 2827 { 2828 item, 2829 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0, 2830 hasBulkActions, 2831 actions, 2832 fields, 2833 id: getItemId2(item) || index.toString(), 2834 view, 2835 titleField, 2836 mediaField, 2837 descriptionField, 2838 selection, 2839 getItemId: getItemId2, 2840 onChangeSelection, 2841 onClickItem, 2842 renderItemLink, 2843 isItemClickable, 2844 isActionsColumnSticky: !isHorizontalScrollEnd, 2845 posinset: isInfiniteScroll ? index + 1 : void 0 2846 }, 2847 getItemId2(item) 2848 )) }) 2849 ] 2850 } 2851 ), 2852 /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)( 2853 "div", 2854 { 2855 className: clsx_default({ 2856 "dataviews-loading": isLoading, 2857 "dataviews-no-results": !hasData && !isLoading 2858 }), 2859 id: tableNoticeId, 2860 children: [ 2861 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components7.Spinner, {}) }) : empty), 2862 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components7.Spinner, {}) }) 2863 ] 2864 } 2865 ) 2866 ] }); 2867 } 2868 var table_default = ViewTable; 2869 2870 // packages/dataviews/build-module/dataviews-layouts/grid/index.js 2871 var import_components10 = __toESM(require_components()); 2872 var import_i18n11 = __toESM(require_i18n()); 2873 2874 // packages/dataviews/build-module/dataviews-layouts/grid/composite-grid.js 2875 var import_components9 = __toESM(require_components()); 2876 var import_i18n10 = __toESM(require_i18n()); 2877 var import_compose4 = __toESM(require_compose()); 2878 var import_keycodes2 = __toESM(require_keycodes()); 2879 var import_element11 = __toESM(require_element()); 2880 2881 // packages/dataviews/build-module/dataviews-layouts/grid/preview-size-picker.js 2882 var import_components8 = __toESM(require_components()); 2883 var import_i18n9 = __toESM(require_i18n()); 2884 var import_element10 = __toESM(require_element()); 2885 var import_jsx_runtime37 = __toESM(require_jsx_runtime()); 2886 var imageSizes = [ 2887 { 2888 value: 120, 2889 breakpoint: 1 2890 }, 2891 { 2892 value: 170, 2893 breakpoint: 1 2894 }, 2895 { 2896 value: 230, 2897 breakpoint: 1 2898 }, 2899 { 2900 value: 290, 2901 breakpoint: 1112 2902 // at minimum image width, 4 images display at this container size 2903 }, 2904 { 2905 value: 350, 2906 breakpoint: 1636 2907 // at minimum image width, 6 images display at this container size 2908 }, 2909 { 2910 value: 430, 2911 breakpoint: 588 2912 // at minimum image width, 2 images display at this container size 2913 } 2914 ]; 2915 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value; 2916 function useGridColumns() { 2917 const context = (0, import_element10.useContext)(dataviews_context_default); 2918 const view = context.view; 2919 return (0, import_element10.useMemo)(() => { 2920 const containerWidth = context.containerWidth; 2921 const gap = 32; 2922 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE; 2923 const columns = Math.floor( 2924 (containerWidth + gap) / (previewSize + gap) 2925 ); 2926 return Math.max(1, columns); 2927 }, [context.containerWidth, view.layout?.previewSize]); 2928 } 2929 2930 // packages/dataviews/build-module/dataviews-layouts/grid/composite-grid.js 2931 var import_jsx_runtime38 = __toESM(require_jsx_runtime()); 2932 var { Badge } = unlock(import_components9.privateApis); 2933 function chunk(array, size) { 2934 const chunks = []; 2935 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) { 2936 chunks.push(array.slice(i2, i2 + size)); 2937 } 2938 return chunks; 2939 } 2940 var GridItem = (0, import_element11.forwardRef)(function GridItem2({ 2941 view, 2942 selection, 2943 onChangeSelection, 2944 onClickItem, 2945 isItemClickable, 2946 renderItemLink, 2947 getItemId: getItemId2, 2948 item, 2949 actions, 2950 mediaField, 2951 titleField, 2952 descriptionField, 2953 regularFields, 2954 badgeFields, 2955 hasBulkActions, 2956 config, 2957 ...props 2958 }, ref) { 2959 const { showTitle = true, showMedia = true, showDescription = true } = view; 2960 const hasBulkAction = useHasAPossibleBulkAction(actions, item); 2961 const id = getItemId2(item); 2962 const instanceId = (0, import_compose4.useInstanceId)(GridItem2); 2963 const isSelected2 = selection.includes(id); 2964 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 2965 mediaField.render, 2966 { 2967 item, 2968 field: mediaField, 2969 config 2970 } 2971 ) : null; 2972 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(titleField.render, { item, field: titleField }) : null; 2973 const shouldRenderMedia = showMedia && renderedMediaField; 2974 let mediaA11yProps; 2975 let titleA11yProps; 2976 if (isItemClickable(item) && onClickItem) { 2977 if (renderedTitleField) { 2978 mediaA11yProps = { 2979 "aria-labelledby": `dataviews-view-grid__title-field-$instanceId}` 2980 }; 2981 titleA11yProps = { 2982 id: `dataviews-view-grid__title-field-$instanceId}` 2983 }; 2984 } else { 2985 mediaA11yProps = { 2986 "aria-label": (0, import_i18n10.__)("Navigate to item") 2987 }; 2988 } 2989 } 2990 return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)( 2991 import_components9.__experimentalVStack, 2992 { 2993 ...props, 2994 ref, 2995 spacing: 0, 2996 className: clsx_default( 2997 props.className, 2998 "dataviews-view-grid__row__gridcell", 2999 "dataviews-view-grid__card", 3000 { 3001 "is-selected": hasBulkAction && isSelected2 3002 } 3003 ), 3004 onClickCapture: (event) => { 3005 props.onClickCapture?.(event); 3006 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) { 3007 event.stopPropagation(); 3008 event.preventDefault(); 3009 if (!hasBulkAction) { 3010 return; 3011 } 3012 onChangeSelection( 3013 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 3014 ); 3015 } 3016 }, 3017 children: [ 3018 shouldRenderMedia && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3019 ItemClickWrapper, 3020 { 3021 item, 3022 isItemClickable, 3023 onClickItem, 3024 renderItemLink, 3025 className: "dataviews-view-grid__media", 3026 ...mediaA11yProps, 3027 children: renderedMediaField 3028 } 3029 ), 3030 hasBulkActions && shouldRenderMedia && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3031 DataViewsSelectionCheckbox, 3032 { 3033 item, 3034 selection, 3035 onChangeSelection, 3036 getItemId: getItemId2, 3037 titleField, 3038 disabled: !hasBulkAction 3039 } 3040 ), 3041 !showTitle && shouldRenderMedia && !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ItemActions, { item, actions, isCompact: true }) }), 3042 showTitle && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)( 3043 import_components9.__experimentalHStack, 3044 { 3045 justify: "space-between", 3046 className: "dataviews-view-grid__title-actions", 3047 children: [ 3048 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3049 ItemClickWrapper, 3050 { 3051 item, 3052 isItemClickable, 3053 onClickItem, 3054 renderItemLink, 3055 className: "dataviews-view-grid__title-field dataviews-title-field", 3056 ...titleA11yProps, 3057 children: renderedTitleField 3058 } 3059 ), 3060 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3061 ItemActions, 3062 { 3063 item, 3064 actions, 3065 isCompact: true 3066 } 3067 ) 3068 ] 3069 } 3070 ), 3071 /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_components9.__experimentalVStack, { spacing: 1, children: [ 3072 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3073 descriptionField.render, 3074 { 3075 item, 3076 field: descriptionField 3077 } 3078 ), 3079 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3080 import_components9.__experimentalHStack, 3081 { 3082 className: "dataviews-view-grid__badge-fields", 3083 spacing: 2, 3084 wrap: true, 3085 alignment: "top", 3086 justify: "flex-start", 3087 children: badgeFields.map((field) => { 3088 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3089 Badge, 3090 { 3091 className: "dataviews-view-grid__field-value", 3092 children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3093 field.render, 3094 { 3095 item, 3096 field 3097 } 3098 ) 3099 }, 3100 field.id 3101 ); 3102 }) 3103 } 3104 ), 3105 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3106 import_components9.__experimentalVStack, 3107 { 3108 className: "dataviews-view-grid__fields", 3109 spacing: 1, 3110 children: regularFields.map((field) => { 3111 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3112 import_components9.Flex, 3113 { 3114 className: "dataviews-view-grid__field", 3115 gap: 1, 3116 justify: "flex-start", 3117 expanded: true, 3118 style: { height: "auto" }, 3119 direction: "row", 3120 children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [ 3121 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_components9.Tooltip, { text: field.label, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_components9.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) }), 3122 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3123 import_components9.FlexItem, 3124 { 3125 className: "dataviews-view-grid__field-value", 3126 style: { maxHeight: "none" }, 3127 children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3128 field.render, 3129 { 3130 item, 3131 field 3132 } 3133 ) 3134 } 3135 ) 3136 ] }) 3137 }, 3138 field.id 3139 ); 3140 }) 3141 } 3142 ) 3143 ] }) 3144 ] 3145 } 3146 ); 3147 }); 3148 function CompositeGrid({ 3149 data, 3150 isInfiniteScroll, 3151 className, 3152 isLoading, 3153 view, 3154 fields, 3155 selection, 3156 onChangeSelection, 3157 onClickItem, 3158 isItemClickable, 3159 renderItemLink, 3160 getItemId: getItemId2, 3161 actions 3162 }) { 3163 const { paginationInfo, resizeObserverRef } = (0, import_element11.useContext)(dataviews_context_default); 3164 const gridColumns = useGridColumns(); 3165 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 3166 const titleField = fields.find( 3167 (field) => field.id === view?.titleField 3168 ); 3169 const mediaField = fields.find( 3170 (field) => field.id === view?.mediaField 3171 ); 3172 const descriptionField = fields.find( 3173 (field) => field.id === view?.descriptionField 3174 ); 3175 const otherFields = view.fields ?? []; 3176 const { regularFields, badgeFields } = otherFields.reduce( 3177 (accumulator, fieldId) => { 3178 const field = fields.find((f2) => f2.id === fieldId); 3179 if (!field) { 3180 return accumulator; 3181 } 3182 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 3183 accumulator[key].push(field); 3184 return accumulator; 3185 }, 3186 { regularFields: [], badgeFields: [] } 3187 ); 3188 const size = "900px"; 3189 const totalRows = Math.ceil(data.length / gridColumns); 3190 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3191 import_components9.Composite, 3192 { 3193 role: isInfiniteScroll ? "feed" : "grid", 3194 className: clsx_default("dataviews-view-grid", className), 3195 focusWrap: true, 3196 "aria-busy": isLoading, 3197 "aria-rowcount": isInfiniteScroll ? void 0 : totalRows, 3198 ref: resizeObserverRef, 3199 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3200 import_components9.Composite.Row, 3201 { 3202 render: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3203 "div", 3204 { 3205 role: "row", 3206 "aria-rowindex": i2 + 1, 3207 "aria-label": (0, import_i18n10.sprintf)( 3208 /* translators: %d: The row number in the grid */ 3209 (0, import_i18n10.__)("Row %d"), 3210 i2 + 1 3211 ), 3212 className: "dataviews-view-grid__row", 3213 style: { 3214 gridTemplateColumns: `repeat( $gridColumns}, minmax(0, 1fr) )` 3215 } 3216 } 3217 ), 3218 children: row.map((item, indexInRow) => { 3219 const index = i2 * gridColumns + indexInRow; 3220 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3221 import_components9.Composite.Item, 3222 { 3223 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)( 3224 GridItem, 3225 { 3226 ...props, 3227 role: isInfiniteScroll ? "article" : "gridcell", 3228 "aria-setsize": isInfiniteScroll ? paginationInfo.totalItems : void 0, 3229 "aria-posinset": isInfiniteScroll ? index + 1 : void 0, 3230 view, 3231 selection, 3232 onChangeSelection, 3233 onClickItem, 3234 isItemClickable, 3235 renderItemLink, 3236 getItemId: getItemId2, 3237 item, 3238 actions, 3239 mediaField, 3240 titleField, 3241 descriptionField, 3242 regularFields, 3243 badgeFields, 3244 hasBulkActions, 3245 config: { 3246 sizes: size 3247 } 3248 } 3249 ) 3250 }, 3251 getItemId2(item) 3252 ); 3253 }) 3254 }, 3255 i2 3256 )) 3257 } 3258 ); 3259 } 3260 3261 // packages/dataviews/build-module/dataviews-layouts/grid/index.js 3262 var import_jsx_runtime39 = __toESM(require_jsx_runtime()); 3263 function ViewGrid({ 3264 actions, 3265 data, 3266 fields, 3267 getItemId: getItemId2, 3268 isLoading, 3269 onChangeSelection, 3270 onClickItem, 3271 isItemClickable, 3272 renderItemLink, 3273 selection, 3274 view, 3275 className, 3276 empty 3277 }) { 3278 const hasData = !!data?.length; 3279 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 3280 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 3281 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 3282 const gridProps = { 3283 className, 3284 isLoading, 3285 view, 3286 fields, 3287 selection, 3288 onChangeSelection, 3289 onClickItem, 3290 isItemClickable, 3291 renderItemLink, 3292 getItemId: getItemId2, 3293 actions 3294 }; 3295 return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { 3296 // Render multiple groups. 3297 children: [ 3298 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components10.__experimentalVStack, { spacing: 4, children: Array.from(dataByGroup.entries()).map( 3299 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_components10.__experimentalVStack, { spacing: 2, children: [ 3300 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h3", { className: "dataviews-view-grid__group-header", children: (0, import_i18n11.sprintf)( 3301 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 3302 (0, import_i18n11.__)("%1$s: %2$s"), 3303 groupField.label, 3304 groupName 3305 ) }), 3306 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3307 CompositeGrid, 3308 { 3309 ...gridProps, 3310 data: groupItems, 3311 isInfiniteScroll: false 3312 } 3313 ) 3314 ] }, groupName) 3315 ) }), 3316 // Render a single grid with all data. 3317 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3318 CompositeGrid, 3319 { 3320 ...gridProps, 3321 data, 3322 isInfiniteScroll: !!isInfiniteScroll 3323 } 3324 ), 3325 // Render empty state. 3326 !hasData && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)( 3327 "div", 3328 { 3329 className: clsx_default({ 3330 "dataviews-loading": isLoading, 3331 "dataviews-no-results": !isLoading 3332 }), 3333 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components10.Spinner, {}) }) : empty 3334 } 3335 ), 3336 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components10.Spinner, {}) }) 3337 ] 3338 }); 3339 } 3340 var grid_default = ViewGrid; 3341 3342 // packages/dataviews/build-module/dataviews-layouts/list/index.js 3343 var import_compose5 = __toESM(require_compose()); 3344 var import_components11 = __toESM(require_components()); 3345 var import_element12 = __toESM(require_element()); 3346 var import_i18n12 = __toESM(require_i18n()); 3347 var import_data5 = __toESM(require_data()); 3348 var import_jsx_runtime40 = __toESM(require_jsx_runtime()); 3349 var { Menu: Menu3 } = unlock(import_components11.privateApis); 3350 function generateItemWrapperCompositeId(idPrefix) { 3351 return `$idPrefix}-item-wrapper`; 3352 } 3353 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) { 3354 return `$idPrefix}-primary-action-$primaryActionId}`; 3355 } 3356 function generateDropdownTriggerCompositeId(idPrefix) { 3357 return `$idPrefix}-dropdown`; 3358 } 3359 function PrimaryActionGridCell({ 3360 idPrefix, 3361 primaryAction, 3362 item 3363 }) { 3364 const registry = (0, import_data5.useRegistry)(); 3365 const [isModalOpen, setIsModalOpen] = (0, import_element12.useState)(false); 3366 const compositeItemId = generatePrimaryActionCompositeId( 3367 idPrefix, 3368 primaryAction.id 3369 ); 3370 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]); 3371 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3372 import_components11.Composite.Item, 3373 { 3374 id: compositeItemId, 3375 render: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3376 import_components11.Button, 3377 { 3378 disabled: !!primaryAction.disabled, 3379 accessibleWhenDisabled: true, 3380 text: label, 3381 size: "small", 3382 onClick: () => setIsModalOpen(true) 3383 } 3384 ), 3385 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3386 ActionModal, 3387 { 3388 action: primaryAction, 3389 items: [item], 3390 closeModal: () => setIsModalOpen(false) 3391 } 3392 ) 3393 } 3394 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3395 import_components11.Composite.Item, 3396 { 3397 id: compositeItemId, 3398 render: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3399 import_components11.Button, 3400 { 3401 disabled: !!primaryAction.disabled, 3402 accessibleWhenDisabled: true, 3403 size: "small", 3404 onClick: () => { 3405 primaryAction.callback([item], { registry }); 3406 }, 3407 children: label 3408 } 3409 ) 3410 } 3411 ) }, primaryAction.id); 3412 } 3413 function ListItem({ 3414 view, 3415 actions, 3416 idPrefix, 3417 isSelected: isSelected2, 3418 item, 3419 titleField, 3420 mediaField, 3421 descriptionField, 3422 onSelect, 3423 otherFields, 3424 onDropdownTriggerKeyDown, 3425 posinset 3426 }) { 3427 const { 3428 showTitle = true, 3429 showMedia = true, 3430 showDescription = true, 3431 infiniteScrollEnabled 3432 } = view; 3433 const itemRef = (0, import_element12.useRef)(null); 3434 const labelId = `$idPrefix}-label`; 3435 const descriptionId = `$idPrefix}-description`; 3436 const registry = (0, import_data5.useRegistry)(); 3437 const [isHovered, setIsHovered] = (0, import_element12.useState)(false); 3438 const [activeModalAction, setActiveModalAction] = (0, import_element12.useState)( 3439 null 3440 ); 3441 const handleHover = ({ type }) => { 3442 const isHover = type === "mouseenter"; 3443 setIsHovered(isHover); 3444 }; 3445 const { paginationInfo } = (0, import_element12.useContext)(dataviews_context_default); 3446 (0, import_element12.useEffect)(() => { 3447 if (isSelected2) { 3448 itemRef.current?.scrollIntoView({ 3449 behavior: "auto", 3450 block: "nearest", 3451 inline: "nearest" 3452 }); 3453 } 3454 }, [isSelected2]); 3455 const { primaryAction, eligibleActions } = (0, import_element12.useMemo)(() => { 3456 const _eligibleActions = actions.filter( 3457 (action) => !action.isEligible || action.isEligible(item) 3458 ); 3459 const _primaryActions = _eligibleActions.filter( 3460 (action) => action.isPrimary 3461 ); 3462 return { 3463 primaryAction: _primaryActions[0], 3464 eligibleActions: _eligibleActions 3465 }; 3466 }, [actions, item]); 3467 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1; 3468 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3469 mediaField.render, 3470 { 3471 item, 3472 field: mediaField, 3473 config: { sizes: "52px" } 3474 } 3475 ) }) : null; 3476 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(titleField.render, { item, field: titleField }) : null; 3477 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_components11.__experimentalHStack, { spacing: 3, className: "dataviews-view-list__item-actions", children: [ 3478 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3479 PrimaryActionGridCell, 3480 { 3481 idPrefix, 3482 primaryAction, 3483 item 3484 } 3485 ), 3486 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { role: "gridcell", children: [ 3487 /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(Menu3, { placement: "bottom-end", children: [ 3488 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3489 Menu3.TriggerButton, 3490 { 3491 render: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3492 import_components11.Composite.Item, 3493 { 3494 id: generateDropdownTriggerCompositeId( 3495 idPrefix 3496 ), 3497 render: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3498 import_components11.Button, 3499 { 3500 size: "small", 3501 icon: more_vertical_default, 3502 label: (0, import_i18n12.__)("Actions"), 3503 accessibleWhenDisabled: true, 3504 disabled: !actions.length, 3505 onKeyDown: onDropdownTriggerKeyDown 3506 } 3507 ) 3508 } 3509 ) 3510 } 3511 ), 3512 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3513 ActionsMenuGroup, 3514 { 3515 actions: eligibleActions, 3516 item, 3517 registry, 3518 setActiveModalAction 3519 } 3520 ) }) 3521 ] }), 3522 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3523 ActionModal, 3524 { 3525 action: activeModalAction, 3526 items: [item], 3527 closeModal: () => setActiveModalAction(null) 3528 } 3529 ) 3530 ] }) 3531 ] }); 3532 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3533 import_components11.Composite.Row, 3534 { 3535 ref: itemRef, 3536 render: ( 3537 /* aria-posinset breaks Composite.Row if passed to it directly. */ 3538 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3539 "div", 3540 { 3541 "aria-posinset": posinset, 3542 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0 3543 } 3544 ) 3545 ), 3546 role: infiniteScrollEnabled ? "article" : "row", 3547 className: clsx_default({ 3548 "is-selected": isSelected2, 3549 "is-hovered": isHovered 3550 }), 3551 onMouseEnter: handleHover, 3552 onMouseLeave: handleHover, 3553 children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_components11.__experimentalHStack, { className: "dataviews-view-list__item-wrapper", spacing: 0, children: [ 3554 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3555 import_components11.Composite.Item, 3556 { 3557 id: generateItemWrapperCompositeId(idPrefix), 3558 "aria-pressed": isSelected2, 3559 "aria-labelledby": labelId, 3560 "aria-describedby": descriptionId, 3561 className: "dataviews-view-list__item", 3562 onClick: () => onSelect(item) 3563 } 3564 ) }), 3565 /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_components11.__experimentalHStack, { spacing: 3, justify: "start", alignment: "flex-start", children: [ 3566 renderedMediaField, 3567 /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)( 3568 import_components11.__experimentalVStack, 3569 { 3570 spacing: 1, 3571 className: "dataviews-view-list__field-wrapper", 3572 children: [ 3573 /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_components11.__experimentalHStack, { spacing: 0, children: [ 3574 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3575 "div", 3576 { 3577 className: "dataviews-title-field", 3578 id: labelId, 3579 children: renderedTitleField 3580 } 3581 ), 3582 usedActions 3583 ] }), 3584 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3585 descriptionField.render, 3586 { 3587 item, 3588 field: descriptionField 3589 } 3590 ) }), 3591 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3592 "div", 3593 { 3594 className: "dataviews-view-list__fields", 3595 id: descriptionId, 3596 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)( 3597 "div", 3598 { 3599 className: "dataviews-view-list__field", 3600 children: [ 3601 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3602 import_components11.VisuallyHidden, 3603 { 3604 as: "span", 3605 className: "dataviews-view-list__field-label", 3606 children: field.label 3607 } 3608 ), 3609 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3610 field.render, 3611 { 3612 item, 3613 field 3614 } 3615 ) }) 3616 ] 3617 }, 3618 field.id 3619 )) 3620 } 3621 ) 3622 ] 3623 } 3624 ) 3625 ] }) 3626 ] }) 3627 } 3628 ); 3629 } 3630 function isDefined2(item) { 3631 return !!item; 3632 } 3633 function ViewList(props) { 3634 const { 3635 actions, 3636 data, 3637 fields, 3638 getItemId: getItemId2, 3639 isLoading, 3640 onChangeSelection, 3641 selection, 3642 view, 3643 className, 3644 empty 3645 } = props; 3646 const baseId = (0, import_compose5.useInstanceId)(ViewList, "view-list"); 3647 const selectedItem = data?.findLast( 3648 (item) => selection.includes(getItemId2(item)) 3649 ); 3650 const titleField = fields.find((field) => field.id === view.titleField); 3651 const mediaField = fields.find((field) => field.id === view.mediaField); 3652 const descriptionField = fields.find( 3653 (field) => field.id === view.descriptionField 3654 ); 3655 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2); 3656 const onSelect = (item) => onChangeSelection([getItemId2(item)]); 3657 const generateCompositeItemIdPrefix = (0, import_element12.useCallback)( 3658 (item) => `$baseId}-$getItemId2(item)}`, 3659 [baseId, getItemId2] 3660 ); 3661 const isActiveCompositeItem = (0, import_element12.useCallback)( 3662 (item, idToCheck) => { 3663 return idToCheck.startsWith( 3664 generateCompositeItemIdPrefix(item) 3665 ); 3666 }, 3667 [generateCompositeItemIdPrefix] 3668 ); 3669 const [activeCompositeId, setActiveCompositeId] = (0, import_element12.useState)(void 0); 3670 (0, import_element12.useEffect)(() => { 3671 if (selectedItem) { 3672 setActiveCompositeId( 3673 generateItemWrapperCompositeId( 3674 generateCompositeItemIdPrefix(selectedItem) 3675 ) 3676 ); 3677 } 3678 }, [selectedItem, generateCompositeItemIdPrefix]); 3679 const activeItemIndex = data.findIndex( 3680 (item) => isActiveCompositeItem(item, activeCompositeId ?? "") 3681 ); 3682 const previousActiveItemIndex = (0, import_compose5.usePrevious)(activeItemIndex); 3683 const isActiveIdInList = activeItemIndex !== -1; 3684 const selectCompositeItem = (0, import_element12.useCallback)( 3685 (targetIndex, generateCompositeId) => { 3686 const clampedIndex = Math.min( 3687 data.length - 1, 3688 Math.max(0, targetIndex) 3689 ); 3690 if (!data[clampedIndex]) { 3691 return; 3692 } 3693 const itemIdPrefix = generateCompositeItemIdPrefix( 3694 data[clampedIndex] 3695 ); 3696 const targetCompositeItemId = generateCompositeId(itemIdPrefix); 3697 setActiveCompositeId(targetCompositeItemId); 3698 document.getElementById(targetCompositeItemId)?.focus(); 3699 }, 3700 [data, generateCompositeItemIdPrefix] 3701 ); 3702 (0, import_element12.useEffect)(() => { 3703 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1; 3704 if (!isActiveIdInList && wasActiveIdInList) { 3705 selectCompositeItem( 3706 previousActiveItemIndex, 3707 generateItemWrapperCompositeId 3708 ); 3709 } 3710 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]); 3711 const onDropdownTriggerKeyDown = (0, import_element12.useCallback)( 3712 (event) => { 3713 if (event.key === "ArrowDown") { 3714 event.preventDefault(); 3715 selectCompositeItem( 3716 activeItemIndex + 1, 3717 generateDropdownTriggerCompositeId 3718 ); 3719 } 3720 if (event.key === "ArrowUp") { 3721 event.preventDefault(); 3722 selectCompositeItem( 3723 activeItemIndex - 1, 3724 generateDropdownTriggerCompositeId 3725 ); 3726 } 3727 }, 3728 [selectCompositeItem, activeItemIndex] 3729 ); 3730 const hasData = data?.length; 3731 if (!hasData) { 3732 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3733 "div", 3734 { 3735 className: clsx_default({ 3736 "dataviews-loading": isLoading, 3737 "dataviews-no-results": !hasData && !isLoading 3738 }), 3739 children: !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_components11.Spinner, {}) }) : empty) 3740 } 3741 ); 3742 } 3743 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null; 3744 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 3745 if (hasData && groupField && dataByGroup) { 3746 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3747 import_components11.Composite, 3748 { 3749 id: `$baseId}`, 3750 render: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", {}), 3751 className: "dataviews-view-list__group", 3752 role: "grid", 3753 activeId: activeCompositeId, 3754 setActiveId: setActiveCompositeId, 3755 children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3756 import_components11.__experimentalVStack, 3757 { 3758 spacing: 4, 3759 className: clsx_default("dataviews-view-list", className), 3760 children: Array.from(dataByGroup.entries()).map( 3761 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_components11.__experimentalVStack, { spacing: 2, children: [ 3762 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h3", { className: "dataviews-view-list__group-header", children: (0, import_i18n12.sprintf)( 3763 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 3764 (0, import_i18n12.__)("%1$s: %2$s"), 3765 groupField.label, 3766 groupName 3767 ) }), 3768 groupItems.map((item) => { 3769 const id = generateCompositeItemIdPrefix(item); 3770 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3771 ListItem, 3772 { 3773 view, 3774 idPrefix: id, 3775 actions, 3776 item, 3777 isSelected: item === selectedItem, 3778 onSelect, 3779 mediaField, 3780 titleField, 3781 descriptionField, 3782 otherFields, 3783 onDropdownTriggerKeyDown 3784 }, 3785 id 3786 ); 3787 }) 3788 ] }, groupName) 3789 ) 3790 } 3791 ) 3792 } 3793 ); 3794 } 3795 return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [ 3796 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3797 import_components11.Composite, 3798 { 3799 id: baseId, 3800 render: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", {}), 3801 className: clsx_default("dataviews-view-list", className), 3802 role: view.infiniteScrollEnabled ? "feed" : "grid", 3803 activeId: activeCompositeId, 3804 setActiveId: setActiveCompositeId, 3805 children: data.map((item, index) => { 3806 const id = generateCompositeItemIdPrefix(item); 3807 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 3808 ListItem, 3809 { 3810 view, 3811 idPrefix: id, 3812 actions, 3813 item, 3814 isSelected: item === selectedItem, 3815 onSelect, 3816 mediaField, 3817 titleField, 3818 descriptionField, 3819 otherFields, 3820 onDropdownTriggerKeyDown, 3821 posinset: view.infiniteScrollEnabled ? index + 1 : void 0 3822 }, 3823 id 3824 ); 3825 }) 3826 } 3827 ), 3828 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_components11.Spinner, {}) }) 3829 ] }); 3830 } 3831 3832 // packages/dataviews/build-module/dataviews-layouts/activity/index.js 3833 var import_components14 = __toESM(require_components()); 3834 3835 // packages/dataviews/build-module/dataviews-layouts/activity/activity-group.js 3836 var import_components12 = __toESM(require_components()); 3837 var import_i18n13 = __toESM(require_i18n()); 3838 var import_element13 = __toESM(require_element()); 3839 var import_jsx_runtime41 = __toESM(require_jsx_runtime()); 3840 function ActivityGroup({ 3841 groupName, 3842 groupData, 3843 groupField, 3844 children 3845 }) { 3846 const groupHeader = (0, import_element13.createInterpolateElement)( 3847 // translators: %s: The label of the field e.g. "Status". 3848 (0, import_i18n13.sprintf)((0, import_i18n13.__)("%s: <groupName />"), groupField.label).trim(), 3849 { 3850 groupName: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 3851 groupField.render, 3852 { 3853 item: groupData[0], 3854 field: groupField 3855 } 3856 ) 3857 } 3858 ); 3859 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)( 3860 import_components12.__experimentalVStack, 3861 { 3862 spacing: 0, 3863 className: "dataviews-view-activity__group", 3864 children: [ 3865 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }), 3866 children 3867 ] 3868 }, 3869 groupName 3870 ); 3871 } 3872 3873 // packages/dataviews/build-module/dataviews-layouts/activity/activity-item.js 3874 var import_components13 = __toESM(require_components()); 3875 var import_element14 = __toESM(require_element()); 3876 var import_data6 = __toESM(require_data()); 3877 var import_jsx_runtime42 = __toESM(require_jsx_runtime()); 3878 function ActivityItem(props) { 3879 const { 3880 view, 3881 actions, 3882 item, 3883 titleField, 3884 mediaField, 3885 descriptionField, 3886 otherFields, 3887 posinset, 3888 onClickItem, 3889 renderItemLink, 3890 isItemClickable 3891 } = props; 3892 const { 3893 showTitle = true, 3894 showMedia = true, 3895 showDescription = true, 3896 infiniteScrollEnabled 3897 } = view; 3898 const itemRef = (0, import_element14.useRef)(null); 3899 const registry = (0, import_data6.useRegistry)(); 3900 const { paginationInfo } = (0, import_element14.useContext)(dataviews_context_default); 3901 const { primaryActions, eligibleActions } = (0, import_element14.useMemo)(() => { 3902 const _eligibleActions = actions.filter( 3903 (action) => !action.isEligible || action.isEligible(item) 3904 ); 3905 const _primaryActions = _eligibleActions.filter( 3906 (action) => action.isPrimary 3907 ); 3908 return { 3909 primaryActions: _primaryActions, 3910 eligibleActions: _eligibleActions 3911 }; 3912 }, [actions, item]); 3913 const density = view.layout?.density ?? "balanced"; 3914 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 3915 mediaField.render, 3916 { 3917 item, 3918 field: mediaField, 3919 config: { 3920 sizes: density === "comfortable" ? "32px" : "24px" 3921 } 3922 } 3923 ) : null; 3924 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 3925 "span", 3926 { 3927 className: "dataviews-view-activity__item-bullet", 3928 "aria-hidden": "true" 3929 } 3930 ) }); 3931 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(titleField.render, { item, field: titleField }) : null; 3932 const verticalSpacing = (0, import_element14.useMemo)(() => { 3933 switch (density) { 3934 case "comfortable": 3935 return "3"; 3936 default: 3937 return "2"; 3938 } 3939 }, [density]); 3940 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 3941 "div", 3942 { 3943 ref: itemRef, 3944 role: infiniteScrollEnabled ? "article" : void 0, 3945 "aria-posinset": posinset, 3946 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 3947 className: clsx_default( 3948 "dataviews-view-activity__item", 3949 density === "compact" && "is-compact", 3950 density === "balanced" && "is-balanced", 3951 density === "comfortable" && "is-comfortable" 3952 ), 3953 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_components13.__experimentalHStack, { spacing: 4, justify: "start", alignment: "flex-start", children: [ 3954 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 3955 import_components13.__experimentalVStack, 3956 { 3957 spacing: 1, 3958 alignment: "center", 3959 className: "dataviews-view-activity__item-type", 3960 children: renderedMediaField 3961 } 3962 ), 3963 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)( 3964 import_components13.__experimentalVStack, 3965 { 3966 spacing: verticalSpacing, 3967 alignment: "flex-start", 3968 className: "dataviews-view-activity__item-content", 3969 children: [ 3970 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 3971 ItemClickWrapper, 3972 { 3973 item, 3974 isItemClickable, 3975 onClickItem, 3976 renderItemLink, 3977 className: "dataviews-view-activity__item-title", 3978 children: renderedTitleField 3979 } 3980 ), 3981 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 3982 descriptionField.render, 3983 { 3984 item, 3985 field: descriptionField 3986 } 3987 ) }), 3988 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)( 3989 "div", 3990 { 3991 className: "dataviews-view-activity__item-field", 3992 children: [ 3993 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 3994 import_components13.VisuallyHidden, 3995 { 3996 as: "span", 3997 className: "dataviews-view-activity__item-field-label", 3998 children: field.label 3999 } 4000 ), 4001 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 4002 field.render, 4003 { 4004 item, 4005 field 4006 } 4007 ) }) 4008 ] 4009 }, 4010 field.id 4011 )) }), 4012 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 4013 PrimaryActions, 4014 { 4015 item, 4016 actions: primaryActions, 4017 registry, 4018 buttonVariant: "secondary" 4019 } 4020 ) 4021 ] 4022 } 4023 ), 4024 primaryActions.length < eligibleActions.length && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 4025 ItemActions, 4026 { 4027 item, 4028 actions: eligibleActions, 4029 isCompact: true 4030 } 4031 ) }) 4032 ] }) 4033 } 4034 ); 4035 } 4036 var activity_item_default = ActivityItem; 4037 4038 // packages/dataviews/build-module/dataviews-layouts/activity/activity-items.js 4039 var import_react = __toESM(require_react()); 4040 function isDefined3(item) { 4041 return !!item; 4042 } 4043 function ActivityItems(props) { 4044 const { data, fields, getItemId: getItemId2, view } = props; 4045 const titleField = fields.find((field) => field.id === view.titleField); 4046 const mediaField = fields.find((field) => field.id === view.mediaField); 4047 const descriptionField = fields.find( 4048 (field) => field.id === view.descriptionField 4049 ); 4050 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3); 4051 return data.map((item, index) => { 4052 return /* @__PURE__ */ (0, import_react.createElement)( 4053 activity_item_default, 4054 { 4055 ...props, 4056 key: getItemId2(item), 4057 item, 4058 mediaField, 4059 titleField, 4060 descriptionField, 4061 otherFields, 4062 posinset: view.infiniteScrollEnabled ? index + 1 : void 0 4063 } 4064 ); 4065 }); 4066 } 4067 4068 // packages/dataviews/build-module/dataviews-layouts/activity/index.js 4069 var import_jsx_runtime43 = __toESM(require_jsx_runtime()); 4070 function ViewActivity(props) { 4071 const { empty, data, fields, isLoading, view, className } = props; 4072 const hasData = data?.length; 4073 if (!hasData) { 4074 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 4075 "div", 4076 { 4077 className: clsx_default({ 4078 "dataviews-loading": isLoading, 4079 "dataviews-no-results": !hasData && !isLoading 4080 }), 4081 children: !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components14.Spinner, {}) }) : empty) 4082 } 4083 ); 4084 } 4085 const wrapperClassName = clsx_default("dataviews-view-activity", className); 4086 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null; 4087 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 4088 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : []; 4089 if (hasData && groupField && dataByGroup) { 4090 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components14.__experimentalVStack, { spacing: 2, className: wrapperClassName, children: groupedEntries.map( 4091 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 4092 ActivityGroup, 4093 { 4094 groupName, 4095 groupData, 4096 groupField, 4097 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 4098 ActivityItems, 4099 { 4100 ...props, 4101 data: groupData 4102 } 4103 ) 4104 }, 4105 groupName 4106 ) 4107 ) }); 4108 } 4109 return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [ 4110 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 4111 "div", 4112 { 4113 className: wrapperClassName, 4114 role: view.infiniteScrollEnabled ? "feed" : void 0, 4115 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ActivityItems, { ...props }) 4116 } 4117 ), 4118 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components14.Spinner, {}) }) 4119 ] }); 4120 } 4121 4122 // packages/dataviews/build-module/dataviews-layouts/picker-grid/index.js 4123 var import_components17 = __toESM(require_components()); 4124 var import_i18n16 = __toESM(require_i18n()); 4125 var import_compose6 = __toESM(require_compose()); 4126 var import_element18 = __toESM(require_element()); 4127 4128 // packages/dataviews/build-module/components/dataviews-picker/footer.js 4129 var import_components16 = __toESM(require_components()); 4130 var import_data7 = __toESM(require_data()); 4131 var import_element16 = __toESM(require_element()); 4132 var import_i18n15 = __toESM(require_i18n()); 4133 4134 // packages/dataviews/build-module/components/dataviews-pagination/index.js 4135 var import_components15 = __toESM(require_components()); 4136 var import_element15 = __toESM(require_element()); 4137 var import_i18n14 = __toESM(require_i18n()); 4138 var import_jsx_runtime44 = __toESM(require_jsx_runtime()); 4139 function DataViewsPagination() { 4140 const { 4141 view, 4142 onChangeView, 4143 paginationInfo: { totalItems = 0, totalPages } 4144 } = (0, import_element15.useContext)(dataviews_context_default); 4145 if (!totalItems || !totalPages || view.infiniteScrollEnabled) { 4146 return null; 4147 } 4148 const currentPage = view.page ?? 1; 4149 const pageSelectOptions = Array.from(Array(totalPages)).map( 4150 (_, i2) => { 4151 const page = i2 + 1; 4152 return { 4153 value: page.toString(), 4154 label: page.toString(), 4155 "aria-label": currentPage === page ? (0, import_i18n14.sprintf)( 4156 // translators: 1: current page number. 2: total number of pages. 4157 (0, import_i18n14.__)("Page %1$d of %2$d"), 4158 currentPage, 4159 totalPages 4160 ) : page.toString() 4161 }; 4162 } 4163 ); 4164 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)( 4165 import_components15.__experimentalHStack, 4166 { 4167 expanded: false, 4168 className: "dataviews-pagination", 4169 justify: "end", 4170 spacing: 6, 4171 children: [ 4172 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)( 4173 import_components15.__experimentalHStack, 4174 { 4175 justify: "flex-start", 4176 expanded: false, 4177 spacing: 1, 4178 className: "dataviews-pagination__page-select", 4179 children: (0, import_element15.createInterpolateElement)( 4180 (0, import_i18n14.sprintf)( 4181 // translators: 1: Current page number, 2: Total number of pages. 4182 (0, import_i18n14._x)( 4183 "<div>Page</div>%1$s<div>of %2$d</div>", 4184 "paging" 4185 ), 4186 "<CurrentPage />", 4187 totalPages 4188 ), 4189 { 4190 div: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { "aria-hidden": true }), 4191 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)( 4192 import_components15.SelectControl, 4193 { 4194 "aria-label": (0, import_i18n14.__)("Current page"), 4195 value: currentPage.toString(), 4196 options: pageSelectOptions, 4197 onChange: (newValue) => { 4198 onChangeView({ 4199 ...view, 4200 page: +newValue 4201 }); 4202 }, 4203 size: "small", 4204 variant: "minimal" 4205 } 4206 ) 4207 } 4208 ) 4209 } 4210 ), 4211 /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_components15.__experimentalHStack, { expanded: false, spacing: 1, children: [ 4212 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)( 4213 import_components15.Button, 4214 { 4215 onClick: () => onChangeView({ 4216 ...view, 4217 page: currentPage - 1 4218 }), 4219 disabled: currentPage === 1, 4220 accessibleWhenDisabled: true, 4221 label: (0, import_i18n14.__)("Previous page"), 4222 icon: (0, import_i18n14.isRTL)() ? next_default : previous_default, 4223 showTooltip: true, 4224 size: "compact", 4225 tooltipPosition: "top" 4226 } 4227 ), 4228 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)( 4229 import_components15.Button, 4230 { 4231 onClick: () => onChangeView({ ...view, page: currentPage + 1 }), 4232 disabled: currentPage >= totalPages, 4233 accessibleWhenDisabled: true, 4234 label: (0, import_i18n14.__)("Next page"), 4235 icon: (0, import_i18n14.isRTL)() ? previous_default : next_default, 4236 showTooltip: true, 4237 size: "compact", 4238 tooltipPosition: "top" 4239 } 4240 ) 4241 ] }) 4242 ] 4243 } 4244 ); 4245 } 4246 var dataviews_pagination_default = (0, import_element15.memo)(DataViewsPagination); 4247 4248 // packages/dataviews/build-module/components/dataviews-picker/footer.js 4249 var import_jsx_runtime45 = __toESM(require_jsx_runtime()); 4250 function useIsMultiselectPicker(actions) { 4251 return (0, import_element16.useMemo)(() => { 4252 return actions?.every((action) => action.supportsBulk); 4253 }, [actions]); 4254 } 4255 4256 // packages/dataviews/build-module/dataviews-layouts/utils/grid-items.js 4257 var import_element17 = __toESM(require_element()); 4258 var import_jsx_runtime46 = __toESM(require_jsx_runtime()); 4259 var GridItems = (0, import_element17.forwardRef)(({ className, previewSize, ...props }, ref) => { 4260 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 4261 "div", 4262 { 4263 ref, 4264 className: clsx_default("dataviews-view-grid-items", className), 4265 style: { 4266 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax($previewSize}px, 1fr))` 4267 }, 4268 ...props 4269 } 4270 ); 4271 }); 4272 4273 // packages/dataviews/build-module/dataviews-layouts/picker-grid/index.js 4274 var import_jsx_runtime47 = __toESM(require_jsx_runtime()); 4275 var { Badge: Badge2 } = unlock(import_components17.privateApis); 4276 function GridItem3({ 4277 view, 4278 multiselect, 4279 selection, 4280 onChangeSelection, 4281 getItemId: getItemId2, 4282 item, 4283 mediaField, 4284 titleField, 4285 descriptionField, 4286 regularFields, 4287 badgeFields, 4288 config, 4289 posinset, 4290 setsize 4291 }) { 4292 const { showTitle = true, showMedia = true, showDescription = true } = view; 4293 const id = getItemId2(item); 4294 const isSelected2 = selection.includes(id); 4295 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4296 mediaField.render, 4297 { 4298 item, 4299 field: mediaField, 4300 config 4301 } 4302 ) : null; 4303 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(titleField.render, { item, field: titleField }) : null; 4304 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)( 4305 import_components17.Composite.Item, 4306 { 4307 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n16.__)("(no title)") : void 0, 4308 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components17.__experimentalVStack, { spacing: 0, children, ...props }), 4309 role: "option", 4310 "aria-posinset": posinset, 4311 "aria-setsize": setsize, 4312 className: clsx_default("dataviews-view-picker-grid__card", { 4313 "is-selected": isSelected2 4314 }), 4315 "aria-selected": isSelected2, 4316 onClick: () => { 4317 if (isSelected2) { 4318 onChangeSelection( 4319 selection.filter((itemId) => id !== itemId) 4320 ); 4321 } else { 4322 const newSelection = multiselect ? [...selection, id] : [id]; 4323 onChangeSelection(newSelection); 4324 } 4325 }, 4326 children: [ 4327 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }), 4328 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4329 DataViewsSelectionCheckbox, 4330 { 4331 item, 4332 selection, 4333 onChangeSelection, 4334 getItemId: getItemId2, 4335 titleField, 4336 disabled: false, 4337 "aria-hidden": true, 4338 tabIndex: -1 4339 } 4340 ), 4341 showTitle && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4342 import_components17.__experimentalHStack, 4343 { 4344 justify: "space-between", 4345 className: "dataviews-view-picker-grid__title-actions", 4346 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField }) 4347 } 4348 ), 4349 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_components17.__experimentalVStack, { spacing: 1, children: [ 4350 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4351 descriptionField.render, 4352 { 4353 item, 4354 field: descriptionField 4355 } 4356 ), 4357 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4358 import_components17.__experimentalHStack, 4359 { 4360 className: "dataviews-view-picker-grid__badge-fields", 4361 spacing: 2, 4362 wrap: true, 4363 alignment: "top", 4364 justify: "flex-start", 4365 children: badgeFields.map((field) => { 4366 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4367 Badge2, 4368 { 4369 className: "dataviews-view-picker-grid__field-value", 4370 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4371 field.render, 4372 { 4373 item, 4374 field 4375 } 4376 ) 4377 }, 4378 field.id 4379 ); 4380 }) 4381 } 4382 ), 4383 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4384 import_components17.__experimentalVStack, 4385 { 4386 className: "dataviews-view-picker-grid__fields", 4387 spacing: 1, 4388 children: regularFields.map((field) => { 4389 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4390 import_components17.Flex, 4391 { 4392 className: "dataviews-view-picker-grid__field", 4393 gap: 1, 4394 justify: "flex-start", 4395 expanded: true, 4396 style: { height: "auto" }, 4397 direction: "row", 4398 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [ 4399 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components17.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }), 4400 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4401 import_components17.FlexItem, 4402 { 4403 className: "dataviews-view-picker-grid__field-value", 4404 style: { maxHeight: "none" }, 4405 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4406 field.render, 4407 { 4408 item, 4409 field 4410 } 4411 ) 4412 } 4413 ) 4414 ] }) 4415 }, 4416 field.id 4417 ); 4418 }) 4419 } 4420 ) 4421 ] }) 4422 ] 4423 }, 4424 id 4425 ); 4426 } 4427 function GridGroup({ 4428 groupName, 4429 groupField, 4430 children 4431 }) { 4432 const headerId = (0, import_compose6.useInstanceId)( 4433 GridGroup, 4434 "dataviews-view-picker-grid-group__header" 4435 ); 4436 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)( 4437 import_components17.__experimentalVStack, 4438 { 4439 spacing: 2, 4440 role: "group", 4441 "aria-labelledby": headerId, 4442 children: [ 4443 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4444 "h3", 4445 { 4446 className: "dataviews-view-picker-grid-group__header", 4447 id: headerId, 4448 children: (0, import_i18n16.sprintf)( 4449 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 4450 (0, import_i18n16.__)("%1$s: %2$s"), 4451 groupField.label, 4452 groupName 4453 ) 4454 } 4455 ), 4456 children 4457 ] 4458 }, 4459 groupName 4460 ); 4461 } 4462 function ViewPickerGrid({ 4463 actions, 4464 data, 4465 fields, 4466 getItemId: getItemId2, 4467 isLoading, 4468 onChangeSelection, 4469 selection, 4470 view, 4471 className, 4472 empty 4473 }) { 4474 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element18.useContext)(dataviews_context_default); 4475 const titleField = fields.find( 4476 (field) => field.id === view?.titleField 4477 ); 4478 const mediaField = fields.find( 4479 (field) => field.id === view?.mediaField 4480 ); 4481 const descriptionField = fields.find( 4482 (field) => field.id === view?.descriptionField 4483 ); 4484 const otherFields = view.fields ?? []; 4485 const { regularFields, badgeFields } = otherFields.reduce( 4486 (accumulator, fieldId) => { 4487 const field = fields.find((f2) => f2.id === fieldId); 4488 if (!field) { 4489 return accumulator; 4490 } 4491 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 4492 accumulator[key].push(field); 4493 return accumulator; 4494 }, 4495 { regularFields: [], badgeFields: [] } 4496 ); 4497 const hasData = !!data?.length; 4498 const usedPreviewSize = view.layout?.previewSize; 4499 const isMultiselect = useIsMultiselectPicker(actions); 4500 const size = "900px"; 4501 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 4502 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 4503 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 4504 const currentPage = view?.page ?? 1; 4505 const perPage = view?.perPage ?? 0; 4506 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0; 4507 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { 4508 // Render multiple groups. 4509 children: [ 4510 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4511 import_components17.Composite, 4512 { 4513 virtualFocus: true, 4514 orientation: "horizontal", 4515 role: "listbox", 4516 "aria-multiselectable": isMultiselect, 4517 className: clsx_default( 4518 "dataviews-view-picker-grid", 4519 className 4520 ), 4521 "aria-label": itemListLabel, 4522 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4523 import_components17.__experimentalVStack, 4524 { 4525 spacing: 4, 4526 children, 4527 ...props 4528 } 4529 ), 4530 children: Array.from(dataByGroup.entries()).map( 4531 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4532 GridGroup, 4533 { 4534 groupName, 4535 groupField, 4536 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4537 GridItems, 4538 { 4539 previewSize: usedPreviewSize, 4540 style: { 4541 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax($usedPreviewSize}px, 1fr))` 4542 }, 4543 "aria-busy": isLoading, 4544 ref: resizeObserverRef, 4545 children: groupItems.map((item) => { 4546 const posInSet = (currentPage - 1) * perPage + data.indexOf(item) + 1; 4547 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4548 GridItem3, 4549 { 4550 view, 4551 multiselect: isMultiselect, 4552 selection, 4553 onChangeSelection, 4554 getItemId: getItemId2, 4555 item, 4556 mediaField, 4557 titleField, 4558 descriptionField, 4559 regularFields, 4560 badgeFields, 4561 config: { 4562 sizes: size 4563 }, 4564 posinset: posInSet, 4565 setsize: setSize 4566 }, 4567 getItemId2(item) 4568 ); 4569 }) 4570 } 4571 ) 4572 }, 4573 groupName 4574 ) 4575 ) 4576 } 4577 ), 4578 // Render a single grid with all data. 4579 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4580 import_components17.Composite, 4581 { 4582 render: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4583 GridItems, 4584 { 4585 className: clsx_default( 4586 "dataviews-view-picker-grid", 4587 className 4588 ), 4589 previewSize: usedPreviewSize, 4590 "aria-busy": isLoading, 4591 ref: resizeObserverRef 4592 } 4593 ), 4594 virtualFocus: true, 4595 orientation: "horizontal", 4596 role: "listbox", 4597 "aria-multiselectable": isMultiselect, 4598 "aria-label": itemListLabel, 4599 children: data.map((item, index) => { 4600 let posinset = isInfiniteScroll ? index + 1 : void 0; 4601 if (!isInfiniteScroll) { 4602 posinset = (currentPage - 1) * perPage + index + 1; 4603 } 4604 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4605 GridItem3, 4606 { 4607 view, 4608 multiselect: isMultiselect, 4609 selection, 4610 onChangeSelection, 4611 getItemId: getItemId2, 4612 item, 4613 mediaField, 4614 titleField, 4615 descriptionField, 4616 regularFields, 4617 badgeFields, 4618 config: { 4619 sizes: size 4620 }, 4621 posinset, 4622 setsize: setSize 4623 }, 4624 getItemId2(item) 4625 ); 4626 }) 4627 } 4628 ), 4629 // Render empty state. 4630 !hasData && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 4631 "div", 4632 { 4633 className: clsx_default({ 4634 "dataviews-loading": isLoading, 4635 "dataviews-no-results": !isLoading 4636 }), 4637 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components17.Spinner, {}) }) : empty 4638 } 4639 ), 4640 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components17.Spinner, {}) }) 4641 ] 4642 }); 4643 } 4644 var picker_grid_default = ViewPickerGrid; 4645 4646 // packages/dataviews/build-module/dataviews-layouts/picker-table/index.js 4647 var import_i18n17 = __toESM(require_i18n()); 4648 var import_components18 = __toESM(require_components()); 4649 var import_element19 = __toESM(require_element()); 4650 var import_jsx_runtime48 = __toESM(require_jsx_runtime()); 4651 function TableColumnField2({ 4652 item, 4653 fields, 4654 column, 4655 align 4656 }) { 4657 const field = fields.find((f2) => f2.id === column); 4658 if (!field) { 4659 return null; 4660 } 4661 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 4662 "dataviews-view-table__cell-align-end": align === "end", 4663 "dataviews-view-table__cell-align-center": align === "center" 4664 }); 4665 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(field.render, { item, field }) }); 4666 } 4667 function TableRow2({ 4668 item, 4669 fields, 4670 id, 4671 view, 4672 titleField, 4673 mediaField, 4674 descriptionField, 4675 selection, 4676 getItemId: getItemId2, 4677 onChangeSelection, 4678 multiselect, 4679 posinset 4680 }) { 4681 const { paginationInfo } = (0, import_element19.useContext)(dataviews_context_default); 4682 const isSelected2 = selection.includes(id); 4683 const [isHovered, setIsHovered] = (0, import_element19.useState)(false); 4684 const { 4685 showTitle = true, 4686 showMedia = true, 4687 showDescription = true, 4688 infiniteScrollEnabled 4689 } = view; 4690 const handleMouseEnter = () => { 4691 setIsHovered(true); 4692 }; 4693 const handleMouseLeave = () => { 4694 setIsHovered(false); 4695 }; 4696 const columns = view.fields ?? []; 4697 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription; 4698 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)( 4699 import_components18.Composite.Item, 4700 { 4701 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4702 "tr", 4703 { 4704 className: clsx_default("dataviews-view-table__row", { 4705 "is-selected": isSelected2, 4706 "is-hovered": isHovered 4707 }), 4708 onMouseEnter: handleMouseEnter, 4709 onMouseLeave: handleMouseLeave, 4710 children, 4711 ...props 4712 } 4713 ), 4714 "aria-selected": isSelected2, 4715 "aria-setsize": paginationInfo.totalItems || void 0, 4716 "aria-posinset": posinset, 4717 role: infiniteScrollEnabled ? "article" : "option", 4718 onClick: () => { 4719 if (isSelected2) { 4720 onChangeSelection( 4721 selection.filter((itemId) => id !== itemId) 4722 ); 4723 } else { 4724 const newSelection = multiselect ? [...selection, id] : [id]; 4725 onChangeSelection(newSelection); 4726 } 4727 }, 4728 children: [ 4729 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4730 "td", 4731 { 4732 className: "dataviews-view-table__checkbox-column", 4733 role: "presentation", 4734 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4735 DataViewsSelectionCheckbox, 4736 { 4737 item, 4738 selection, 4739 onChangeSelection, 4740 getItemId: getItemId2, 4741 titleField, 4742 disabled: false, 4743 "aria-hidden": true, 4744 tabIndex: -1 4745 } 4746 ) }) 4747 } 4748 ), 4749 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("td", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4750 column_primary_default, 4751 { 4752 item, 4753 titleField: showTitle ? titleField : void 0, 4754 mediaField: showMedia ? mediaField : void 0, 4755 descriptionField: showDescription ? descriptionField : void 0, 4756 isItemClickable: () => false 4757 } 4758 ) }), 4759 columns.map((column) => { 4760 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 4761 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4762 "td", 4763 { 4764 style: { 4765 width, 4766 maxWidth, 4767 minWidth 4768 }, 4769 role: "presentation", 4770 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4771 TableColumnField2, 4772 { 4773 fields, 4774 item, 4775 column, 4776 align 4777 } 4778 ) 4779 }, 4780 column 4781 ); 4782 }) 4783 ] 4784 }, 4785 id 4786 ); 4787 } 4788 function ViewPickerTable({ 4789 actions, 4790 data, 4791 fields, 4792 getItemId: getItemId2, 4793 isLoading = false, 4794 onChangeView, 4795 onChangeSelection, 4796 selection, 4797 setOpenedFilter, 4798 view, 4799 className, 4800 empty 4801 }) { 4802 const headerMenuRefs = (0, import_element19.useRef)(/* @__PURE__ */ new Map()); 4803 const headerMenuToFocusRef = (0, import_element19.useRef)(); 4804 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element19.useState)(); 4805 const isMultiselect = useIsMultiselectPicker(actions) ?? false; 4806 (0, import_element19.useEffect)(() => { 4807 if (headerMenuToFocusRef.current) { 4808 headerMenuToFocusRef.current.focus(); 4809 headerMenuToFocusRef.current = void 0; 4810 } 4811 }); 4812 const tableNoticeId = (0, import_element19.useId)(); 4813 if (nextHeaderMenuToFocus) { 4814 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 4815 setNextHeaderMenuToFocus(void 0); 4816 return; 4817 } 4818 const onHide = (field) => { 4819 const hidden = headerMenuRefs.current.get(field.id); 4820 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 4821 setNextHeaderMenuToFocus(fallback?.node); 4822 }; 4823 const hasData = !!data?.length; 4824 const titleField = fields.find((field) => field.id === view.titleField); 4825 const mediaField = fields.find((field) => field.id === view.mediaField); 4826 const descriptionField = fields.find( 4827 (field) => field.id === view.descriptionField 4828 ); 4829 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 4830 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 4831 const { showTitle = true, showMedia = true, showDescription = true } = view; 4832 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription; 4833 const columns = view.fields ?? []; 4834 const headerMenuRef = (column, index) => (node) => { 4835 if (node) { 4836 headerMenuRefs.current.set(column, { 4837 node, 4838 fallback: columns[index > 0 ? index - 1 : 1] 4839 }); 4840 } else { 4841 headerMenuRefs.current.delete(column); 4842 } 4843 }; 4844 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 4845 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [ 4846 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)( 4847 "table", 4848 { 4849 className: clsx_default( 4850 "dataviews-view-table", 4851 "dataviews-view-picker-table", 4852 className, 4853 { 4854 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 4855 view.layout.density 4856 ) 4857 } 4858 ), 4859 "aria-busy": isLoading, 4860 "aria-describedby": tableNoticeId, 4861 role: isInfiniteScroll ? "feed" : "listbox", 4862 children: [ 4863 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)( 4864 "tr", 4865 { 4866 className: "dataviews-view-table__row", 4867 role: "presentation", 4868 children: [ 4869 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4870 BulkSelectionCheckbox, 4871 { 4872 selection, 4873 onChangeSelection, 4874 data, 4875 actions, 4876 getItemId: getItemId2 4877 } 4878 ) }), 4879 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4880 column_header_menu_default, 4881 { 4882 ref: headerMenuRef( 4883 titleField.id, 4884 0 4885 ), 4886 fieldId: titleField.id, 4887 view, 4888 fields, 4889 onChangeView, 4890 onHide, 4891 setOpenedFilter, 4892 canMove: false 4893 } 4894 ) }), 4895 columns.map((column, index) => { 4896 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 4897 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4898 "th", 4899 { 4900 style: { 4901 width, 4902 maxWidth, 4903 minWidth, 4904 textAlign: align 4905 }, 4906 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 4907 scope: "col", 4908 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4909 column_header_menu_default, 4910 { 4911 ref: headerMenuRef(column, index), 4912 fieldId: column, 4913 view, 4914 fields, 4915 onChangeView, 4916 onHide, 4917 setOpenedFilter, 4918 canMove: view.layout?.enableMoving ?? true 4919 } 4920 ) 4921 }, 4922 column 4923 ); 4924 }) 4925 ] 4926 } 4927 ) }), 4928 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 4929 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)( 4930 import_components18.Composite, 4931 { 4932 virtualFocus: true, 4933 orientation: "vertical", 4934 render: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("tbody", { role: "group" }), 4935 children: [ 4936 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4937 "tr", 4938 { 4939 className: "dataviews-view-table__group-header-row", 4940 role: "presentation", 4941 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4942 "td", 4943 { 4944 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1, 4945 className: "dataviews-view-table__group-header-cell", 4946 role: "presentation", 4947 children: (0, import_i18n17.sprintf)( 4948 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 4949 (0, import_i18n17.__)("%1$s: %2$s"), 4950 groupField.label, 4951 groupName 4952 ) 4953 } 4954 ) 4955 } 4956 ), 4957 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4958 TableRow2, 4959 { 4960 item, 4961 fields, 4962 id: getItemId2(item) || index.toString(), 4963 view, 4964 titleField, 4965 mediaField, 4966 descriptionField, 4967 selection, 4968 getItemId: getItemId2, 4969 onChangeSelection, 4970 multiselect: isMultiselect 4971 }, 4972 getItemId2(item) 4973 )) 4974 ] 4975 }, 4976 `group-$groupName}` 4977 ) 4978 ) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4979 import_components18.Composite, 4980 { 4981 render: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("tbody", { role: "presentation" }), 4982 virtualFocus: true, 4983 orientation: "vertical", 4984 children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)( 4985 TableRow2, 4986 { 4987 item, 4988 fields, 4989 id: getItemId2(item) || index.toString(), 4990 view, 4991 titleField, 4992 mediaField, 4993 descriptionField, 4994 selection, 4995 getItemId: getItemId2, 4996 onChangeSelection, 4997 multiselect: isMultiselect, 4998 posinset: index + 1 4999 }, 5000 getItemId2(item) 5001 )) 5002 } 5003 ) 5004 ] 5005 } 5006 ), 5007 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)( 5008 "div", 5009 { 5010 className: clsx_default({ 5011 "dataviews-loading": isLoading, 5012 "dataviews-no-results": !hasData && !isLoading 5013 }), 5014 id: tableNoticeId, 5015 children: [ 5016 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_components18.Spinner, {}) }) : empty), 5017 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_components18.Spinner, {}) }) 5018 ] 5019 } 5020 ) 5021 ] }); 5022 } 5023 var picker_table_default = ViewPickerTable; 5024 5025 // packages/dataviews/build-module/dataviews-layouts/utils/preview-size-picker.js 5026 var import_components19 = __toESM(require_components()); 5027 var import_i18n18 = __toESM(require_i18n()); 5028 var import_element20 = __toESM(require_element()); 5029 var import_jsx_runtime49 = __toESM(require_jsx_runtime()); 5030 var imageSizes2 = [ 5031 { 5032 value: 120, 5033 breakpoint: 1 5034 }, 5035 { 5036 value: 170, 5037 breakpoint: 1 5038 }, 5039 { 5040 value: 230, 5041 breakpoint: 1 5042 }, 5043 { 5044 value: 290, 5045 breakpoint: 1112 5046 // at minimum image width, 4 images display at this container size 5047 }, 5048 { 5049 value: 350, 5050 breakpoint: 1636 5051 // at minimum image width, 6 images display at this container size 5052 }, 5053 { 5054 value: 430, 5055 breakpoint: 588 5056 // at minimum image width, 2 images display at this container size 5057 } 5058 ]; 5059 function PreviewSizePicker() { 5060 const context = (0, import_element20.useContext)(dataviews_context_default); 5061 const view = context.view; 5062 const breakValues = imageSizes2.filter((size) => { 5063 return context.containerWidth >= size.breakpoint; 5064 }); 5065 const layoutPreviewSize = view.layout?.previewSize ?? 230; 5066 const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0; 5067 const marks = breakValues.map((size, index) => { 5068 return { 5069 value: index 5070 }; 5071 }); 5072 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 5073 import_components19.RangeControl, 5074 { 5075 __next40pxDefaultSize: true, 5076 showTooltip: false, 5077 label: (0, import_i18n18.__)("Preview size"), 5078 value: previewSizeToUse, 5079 min: 0, 5080 max: breakValues.length - 1, 5081 withInputField: false, 5082 onChange: (value = 0) => { 5083 context.onChangeView({ 5084 ...view, 5085 layout: { 5086 ...view.layout, 5087 previewSize: breakValues[value].value 5088 } 5089 }); 5090 }, 5091 step: 1, 5092 marks 5093 } 5094 ); 5095 } 5096 5097 // packages/dataviews/build-module/dataviews-layouts/table/density-picker.js 5098 var import_components20 = __toESM(require_components()); 5099 var import_i18n19 = __toESM(require_i18n()); 5100 var import_element21 = __toESM(require_element()); 5101 var import_jsx_runtime50 = __toESM(require_jsx_runtime()); 5102 function DensityPicker() { 5103 const context = (0, import_element21.useContext)(dataviews_context_default); 5104 const view = context.view; 5105 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)( 5106 import_components20.__experimentalToggleGroupControl, 5107 { 5108 size: "__unstable-large", 5109 label: (0, import_i18n19.__)("Density"), 5110 value: view.layout?.density || "balanced", 5111 onChange: (value) => { 5112 context.onChangeView({ 5113 ...view, 5114 layout: { 5115 ...view.layout, 5116 density: value 5117 } 5118 }); 5119 }, 5120 isBlock: true, 5121 children: [ 5122 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 5123 import_components20.__experimentalToggleGroupControlOption, 5124 { 5125 value: "comfortable", 5126 label: (0, import_i18n19._x)( 5127 "Comfortable", 5128 "Density option for DataView layout" 5129 ) 5130 }, 5131 "comfortable" 5132 ), 5133 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 5134 import_components20.__experimentalToggleGroupControlOption, 5135 { 5136 value: "balanced", 5137 label: (0, import_i18n19._x)("Balanced", "Density option for DataView layout") 5138 }, 5139 "balanced" 5140 ), 5141 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 5142 import_components20.__experimentalToggleGroupControlOption, 5143 { 5144 value: "compact", 5145 label: (0, import_i18n19._x)("Compact", "Density option for DataView layout") 5146 }, 5147 "compact" 5148 ) 5149 ] 5150 } 5151 ); 5152 } 5153 5154 // packages/dataviews/build-module/dataviews-layouts/index.js 5155 var VIEW_LAYOUTS = [ 5156 { 5157 type: LAYOUT_TABLE, 5158 label: (0, import_i18n20.__)("Table"), 5159 component: table_default, 5160 icon: block_table_default, 5161 viewConfigOptions: DensityPicker 5162 }, 5163 { 5164 type: LAYOUT_GRID, 5165 label: (0, import_i18n20.__)("Grid"), 5166 component: grid_default, 5167 icon: category_default, 5168 viewConfigOptions: PreviewSizePicker 5169 }, 5170 { 5171 type: LAYOUT_LIST, 5172 label: (0, import_i18n20.__)("List"), 5173 component: ViewList, 5174 icon: (0, import_i18n20.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default 5175 }, 5176 { 5177 type: LAYOUT_ACTIVITY, 5178 label: (0, import_i18n20.__)("Activity"), 5179 component: ViewActivity, 5180 icon: scheduled_default, 5181 viewConfigOptions: DensityPicker 5182 }, 5183 { 5184 type: LAYOUT_PICKER_GRID, 5185 label: (0, import_i18n20.__)("Grid"), 5186 component: picker_grid_default, 5187 icon: category_default, 5188 viewConfigOptions: PreviewSizePicker, 5189 isPicker: true 5190 }, 5191 { 5192 type: LAYOUT_PICKER_TABLE, 5193 label: (0, import_i18n20.__)("Table"), 5194 component: picker_table_default, 5195 icon: block_table_default, 5196 viewConfigOptions: DensityPicker, 5197 isPicker: true 5198 } 5199 ]; 5200 5201 // packages/dataviews/build-module/components/dataviews-filters/filters.js 5202 var import_element29 = __toESM(require_element()); 5203 var import_components26 = __toESM(require_components()); 5204 5205 // packages/dataviews/build-module/components/dataviews-filters/filter.js 5206 var import_components23 = __toESM(require_components()); 5207 var import_i18n23 = __toESM(require_i18n()); 5208 var import_element26 = __toESM(require_element()); 5209 5210 // node_modules/@ariakit/react-core/esm/__chunks/3YLGPPWQ.js 5211 var __defProp2 = Object.defineProperty; 5212 var __defProps = Object.defineProperties; 5213 var __getOwnPropDescs = Object.getOwnPropertyDescriptors; 5214 var __getOwnPropSymbols = Object.getOwnPropertySymbols; 5215 var __hasOwnProp2 = Object.prototype.hasOwnProperty; 5216 var __propIsEnum = Object.prototype.propertyIsEnumerable; 5217 var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 5218 var __spreadValues = (a2, b2) => { 5219 for (var prop in b2 || (b2 = {})) 5220 if (__hasOwnProp2.call(b2, prop)) 5221 __defNormalProp(a2, prop, b2[prop]); 5222 if (__getOwnPropSymbols) 5223 for (var prop of __getOwnPropSymbols(b2)) { 5224 if (__propIsEnum.call(b2, prop)) 5225 __defNormalProp(a2, prop, b2[prop]); 5226 } 5227 return a2; 5228 }; 5229 var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2)); 5230 var __objRest = (source, exclude) => { 5231 var target = {}; 5232 for (var prop in source) 5233 if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0) 5234 target[prop] = source[prop]; 5235 if (source != null && __getOwnPropSymbols) 5236 for (var prop of __getOwnPropSymbols(source)) { 5237 if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) 5238 target[prop] = source[prop]; 5239 } 5240 return target; 5241 }; 5242 5243 // node_modules/@ariakit/core/esm/__chunks/3YLGPPWQ.js 5244 var __defProp3 = Object.defineProperty; 5245 var __defProps2 = Object.defineProperties; 5246 var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors; 5247 var __getOwnPropSymbols2 = Object.getOwnPropertySymbols; 5248 var __hasOwnProp3 = Object.prototype.hasOwnProperty; 5249 var __propIsEnum2 = Object.prototype.propertyIsEnumerable; 5250 var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 5251 var __spreadValues2 = (a2, b2) => { 5252 for (var prop in b2 || (b2 = {})) 5253 if (__hasOwnProp3.call(b2, prop)) 5254 __defNormalProp2(a2, prop, b2[prop]); 5255 if (__getOwnPropSymbols2) 5256 for (var prop of __getOwnPropSymbols2(b2)) { 5257 if (__propIsEnum2.call(b2, prop)) 5258 __defNormalProp2(a2, prop, b2[prop]); 5259 } 5260 return a2; 5261 }; 5262 var __spreadProps2 = (a2, b2) => __defProps2(a2, __getOwnPropDescs2(b2)); 5263 var __objRest2 = (source, exclude) => { 5264 var target = {}; 5265 for (var prop in source) 5266 if (__hasOwnProp3.call(source, prop) && exclude.indexOf(prop) < 0) 5267 target[prop] = source[prop]; 5268 if (source != null && __getOwnPropSymbols2) 5269 for (var prop of __getOwnPropSymbols2(source)) { 5270 if (exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop)) 5271 target[prop] = source[prop]; 5272 } 5273 return target; 5274 }; 5275 5276 // node_modules/@ariakit/core/esm/__chunks/PBFD2E7P.js 5277 function noop(..._) { 5278 } 5279 function applyState(argument, currentValue) { 5280 if (isUpdater(argument)) { 5281 const value = isLazyValue(currentValue) ? currentValue() : currentValue; 5282 return argument(value); 5283 } 5284 return argument; 5285 } 5286 function isUpdater(argument) { 5287 return typeof argument === "function"; 5288 } 5289 function isLazyValue(value) { 5290 return typeof value === "function"; 5291 } 5292 function hasOwnProperty(object, prop) { 5293 if (typeof Object.hasOwn === "function") { 5294 return Object.hasOwn(object, prop); 5295 } 5296 return Object.prototype.hasOwnProperty.call(object, prop); 5297 } 5298 function chain(...fns) { 5299 return (...args) => { 5300 for (const fn of fns) { 5301 if (typeof fn === "function") { 5302 fn(...args); 5303 } 5304 } 5305 }; 5306 } 5307 function normalizeString(str) { 5308 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); 5309 } 5310 function omit2(object, keys) { 5311 const result = __spreadValues2({}, object); 5312 for (const key of keys) { 5313 if (hasOwnProperty(result, key)) { 5314 delete result[key]; 5315 } 5316 } 5317 return result; 5318 } 5319 function pick(object, paths) { 5320 const result = {}; 5321 for (const key of paths) { 5322 if (hasOwnProperty(object, key)) { 5323 result[key] = object[key]; 5324 } 5325 } 5326 return result; 5327 } 5328 function identity(value) { 5329 return value; 5330 } 5331 function invariant(condition, message2) { 5332 if (condition) return; 5333 if (typeof message2 !== "string") throw new Error("Invariant failed"); 5334 throw new Error(message2); 5335 } 5336 function getKeys(obj) { 5337 return Object.keys(obj); 5338 } 5339 function isFalsyBooleanCallback(booleanOrCallback, ...args) { 5340 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback; 5341 if (result == null) return false; 5342 return !result; 5343 } 5344 function disabledFromProps(props) { 5345 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true"; 5346 } 5347 function removeUndefinedValues(obj) { 5348 const result = {}; 5349 for (const key in obj) { 5350 if (obj[key] !== void 0) { 5351 result[key] = obj[key]; 5352 } 5353 } 5354 return result; 5355 } 5356 function defaultValue(...values) { 5357 for (const value of values) { 5358 if (value !== void 0) return value; 5359 } 5360 return void 0; 5361 } 5362 5363 // node_modules/@ariakit/react-core/esm/__chunks/SK3NAZA3.js 5364 var import_react2 = __toESM(require_react(), 1); 5365 function setRef(ref, value) { 5366 if (typeof ref === "function") { 5367 ref(value); 5368 } else if (ref) { 5369 ref.current = value; 5370 } 5371 } 5372 function isValidElementWithRef(element) { 5373 if (!element) return false; 5374 if (!(0, import_react2.isValidElement)(element)) return false; 5375 if ("ref" in element.props) return true; 5376 if ("ref" in element) return true; 5377 return false; 5378 } 5379 function getRefProperty(element) { 5380 if (!isValidElementWithRef(element)) return null; 5381 const props = __spreadValues({}, element.props); 5382 return props.ref || element.ref; 5383 } 5384 function mergeProps(base, overrides) { 5385 const props = __spreadValues({}, base); 5386 for (const key in overrides) { 5387 if (!hasOwnProperty(overrides, key)) continue; 5388 if (key === "className") { 5389 const prop = "className"; 5390 props[prop] = base[prop] ? `$base[prop]} $overrides[prop]}` : overrides[prop]; 5391 continue; 5392 } 5393 if (key === "style") { 5394 const prop = "style"; 5395 props[prop] = base[prop] ? __spreadValues(__spreadValues({}, base[prop]), overrides[prop]) : overrides[prop]; 5396 continue; 5397 } 5398 const overrideValue = overrides[key]; 5399 if (typeof overrideValue === "function" && key.startsWith("on")) { 5400 const baseValue = base[key]; 5401 if (typeof baseValue === "function") { 5402 props[key] = (...args) => { 5403 overrideValue(...args); 5404 baseValue(...args); 5405 }; 5406 continue; 5407 } 5408 } 5409 props[key] = overrideValue; 5410 } 5411 return props; 5412 } 5413 5414 // node_modules/@ariakit/core/esm/__chunks/DTR5TSDJ.js 5415 var canUseDOM = checkIsBrowser(); 5416 function checkIsBrowser() { 5417 var _a; 5418 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement); 5419 } 5420 function getDocument(node) { 5421 if (!node) return document; 5422 if ("self" in node) return node.document; 5423 return node.ownerDocument || document; 5424 } 5425 function getActiveElement(node, activeDescendant = false) { 5426 const { activeElement } = getDocument(node); 5427 if (!(activeElement == null ? void 0 : activeElement.nodeName)) { 5428 return null; 5429 } 5430 if (isFrame(activeElement) && activeElement.contentDocument) { 5431 return getActiveElement( 5432 activeElement.contentDocument.body, 5433 activeDescendant 5434 ); 5435 } 5436 if (activeDescendant) { 5437 const id = activeElement.getAttribute("aria-activedescendant"); 5438 if (id) { 5439 const element = getDocument(activeElement).getElementById(id); 5440 if (element) { 5441 return element; 5442 } 5443 } 5444 } 5445 return activeElement; 5446 } 5447 function contains(parent, child) { 5448 return parent === child || parent.contains(child); 5449 } 5450 function isFrame(element) { 5451 return element.tagName === "IFRAME"; 5452 } 5453 function isButton(element) { 5454 const tagName = element.tagName.toLowerCase(); 5455 if (tagName === "button") return true; 5456 if (tagName === "input" && element.type) { 5457 return buttonInputTypes.indexOf(element.type) !== -1; 5458 } 5459 return false; 5460 } 5461 var buttonInputTypes = [ 5462 "button", 5463 "color", 5464 "file", 5465 "image", 5466 "reset", 5467 "submit" 5468 ]; 5469 function isVisible(element) { 5470 if (typeof element.checkVisibility === "function") { 5471 return element.checkVisibility(); 5472 } 5473 const htmlElement = element; 5474 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0; 5475 } 5476 function isTextField(element) { 5477 try { 5478 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null; 5479 const isTextArea = element.tagName === "TEXTAREA"; 5480 return isTextInput || isTextArea || false; 5481 } catch (error) { 5482 return false; 5483 } 5484 } 5485 function isTextbox(element) { 5486 return element.isContentEditable || isTextField(element); 5487 } 5488 function getTextboxValue(element) { 5489 if (isTextField(element)) { 5490 return element.value; 5491 } 5492 if (element.isContentEditable) { 5493 const range = getDocument(element).createRange(); 5494 range.selectNodeContents(element); 5495 return range.toString(); 5496 } 5497 return ""; 5498 } 5499 function getTextboxSelection(element) { 5500 let start = 0; 5501 let end = 0; 5502 if (isTextField(element)) { 5503 start = element.selectionStart || 0; 5504 end = element.selectionEnd || 0; 5505 } else if (element.isContentEditable) { 5506 const selection = getDocument(element).getSelection(); 5507 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) { 5508 const range = selection.getRangeAt(0); 5509 const nextRange = range.cloneRange(); 5510 nextRange.selectNodeContents(element); 5511 nextRange.setEnd(range.startContainer, range.startOffset); 5512 start = nextRange.toString().length; 5513 nextRange.setEnd(range.endContainer, range.endOffset); 5514 end = nextRange.toString().length; 5515 } 5516 } 5517 return { start, end }; 5518 } 5519 function getPopupRole(element, fallback) { 5520 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"]; 5521 const role = element == null ? void 0 : element.getAttribute("role"); 5522 if (role && allowedPopupRoles.indexOf(role) !== -1) { 5523 return role; 5524 } 5525 return fallback; 5526 } 5527 function getScrollingElement(element) { 5528 if (!element) return null; 5529 const isScrollableOverflow = (overflow) => { 5530 if (overflow === "auto") return true; 5531 if (overflow === "scroll") return true; 5532 return false; 5533 }; 5534 if (element.clientHeight && element.scrollHeight > element.clientHeight) { 5535 const { overflowY } = getComputedStyle(element); 5536 if (isScrollableOverflow(overflowY)) return element; 5537 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) { 5538 const { overflowX } = getComputedStyle(element); 5539 if (isScrollableOverflow(overflowX)) return element; 5540 } 5541 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body; 5542 } 5543 function setSelectionRange(element, ...args) { 5544 if (/text|search|password|tel|url/i.test(element.type)) { 5545 element.setSelectionRange(...args); 5546 } 5547 } 5548 function sortBasedOnDOMPosition(items, getElement) { 5549 const pairs = items.map((item, index) => [index, item]); 5550 let isOrderDifferent = false; 5551 pairs.sort(([indexA, a2], [indexB, b2]) => { 5552 const elementA = getElement(a2); 5553 const elementB = getElement(b2); 5554 if (elementA === elementB) return 0; 5555 if (!elementA || !elementB) return 0; 5556 if (isElementPreceding(elementA, elementB)) { 5557 if (indexA > indexB) { 5558 isOrderDifferent = true; 5559 } 5560 return -1; 5561 } 5562 if (indexA < indexB) { 5563 isOrderDifferent = true; 5564 } 5565 return 1; 5566 }); 5567 if (isOrderDifferent) { 5568 return pairs.map(([_, item]) => item); 5569 } 5570 return items; 5571 } 5572 function isElementPreceding(a2, b2) { 5573 return Boolean( 5574 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING 5575 ); 5576 } 5577 5578 // node_modules/@ariakit/core/esm/__chunks/QAGXQEUG.js 5579 function isTouchDevice() { 5580 return canUseDOM && !!navigator.maxTouchPoints; 5581 } 5582 function isApple() { 5583 if (!canUseDOM) return false; 5584 return /mac|iphone|ipad|ipod/i.test(navigator.platform); 5585 } 5586 function isSafari() { 5587 return canUseDOM && isApple() && /apple/i.test(navigator.vendor); 5588 } 5589 function isFirefox() { 5590 return canUseDOM && /firefox\//i.test(navigator.userAgent); 5591 } 5592 5593 // node_modules/@ariakit/core/esm/utils/events.js 5594 function isPortalEvent(event) { 5595 return Boolean( 5596 event.currentTarget && !contains(event.currentTarget, event.target) 5597 ); 5598 } 5599 function isSelfTarget(event) { 5600 return event.target === event.currentTarget; 5601 } 5602 function isOpeningInNewTab(event) { 5603 const element = event.currentTarget; 5604 if (!element) return false; 5605 const isAppleDevice = isApple(); 5606 if (isAppleDevice && !event.metaKey) return false; 5607 if (!isAppleDevice && !event.ctrlKey) return false; 5608 const tagName = element.tagName.toLowerCase(); 5609 if (tagName === "a") return true; 5610 if (tagName === "button" && element.type === "submit") return true; 5611 if (tagName === "input" && element.type === "submit") return true; 5612 return false; 5613 } 5614 function isDownloading(event) { 5615 const element = event.currentTarget; 5616 if (!element) return false; 5617 const tagName = element.tagName.toLowerCase(); 5618 if (!event.altKey) return false; 5619 if (tagName === "a") return true; 5620 if (tagName === "button" && element.type === "submit") return true; 5621 if (tagName === "input" && element.type === "submit") return true; 5622 return false; 5623 } 5624 function fireBlurEvent(element, eventInit) { 5625 const event = new FocusEvent("blur", eventInit); 5626 const defaultAllowed = element.dispatchEvent(event); 5627 const bubbleInit = __spreadProps2(__spreadValues2({}, eventInit), { bubbles: true }); 5628 element.dispatchEvent(new FocusEvent("focusout", bubbleInit)); 5629 return defaultAllowed; 5630 } 5631 function fireKeyboardEvent(element, type, eventInit) { 5632 const event = new KeyboardEvent(type, eventInit); 5633 return element.dispatchEvent(event); 5634 } 5635 function fireClickEvent(element, eventInit) { 5636 const event = new MouseEvent("click", eventInit); 5637 return element.dispatchEvent(event); 5638 } 5639 function isFocusEventOutside(event, container) { 5640 const containerElement = container || event.currentTarget; 5641 const relatedTarget = event.relatedTarget; 5642 return !relatedTarget || !contains(containerElement, relatedTarget); 5643 } 5644 function queueBeforeEvent(element, type, callback, timeout) { 5645 const createTimer = (callback2) => { 5646 if (timeout) { 5647 const timerId2 = setTimeout(callback2, timeout); 5648 return () => clearTimeout(timerId2); 5649 } 5650 const timerId = requestAnimationFrame(callback2); 5651 return () => cancelAnimationFrame(timerId); 5652 }; 5653 const cancelTimer = createTimer(() => { 5654 element.removeEventListener(type, callSync, true); 5655 callback(); 5656 }); 5657 const callSync = () => { 5658 cancelTimer(); 5659 callback(); 5660 }; 5661 element.addEventListener(type, callSync, { once: true, capture: true }); 5662 return cancelTimer; 5663 } 5664 function addGlobalEventListener(type, listener, options, scope = window) { 5665 const children = []; 5666 try { 5667 scope.document.addEventListener(type, listener, options); 5668 for (const frame of Array.from(scope.frames)) { 5669 children.push(addGlobalEventListener(type, listener, options, frame)); 5670 } 5671 } catch (e2) { 5672 } 5673 const removeEventListener = () => { 5674 try { 5675 scope.document.removeEventListener(type, listener, options); 5676 } catch (e2) { 5677 } 5678 for (const remove of children) { 5679 remove(); 5680 } 5681 }; 5682 return removeEventListener; 5683 } 5684 5685 // node_modules/@ariakit/react-core/esm/__chunks/ABQUS43J.js 5686 var import_react3 = __toESM(require_react(), 1); 5687 var React2 = __toESM(require_react(), 1); 5688 var _React = __spreadValues({}, React2); 5689 var useReactId = _React.useId; 5690 var useReactDeferredValue = _React.useDeferredValue; 5691 var useReactInsertionEffect = _React.useInsertionEffect; 5692 var useSafeLayoutEffect = canUseDOM ? import_react3.useLayoutEffect : import_react3.useEffect; 5693 function useInitialValue(value) { 5694 const [initialValue] = (0, import_react3.useState)(value); 5695 return initialValue; 5696 } 5697 function useLiveRef(value) { 5698 const ref = (0, import_react3.useRef)(value); 5699 useSafeLayoutEffect(() => { 5700 ref.current = value; 5701 }); 5702 return ref; 5703 } 5704 function useEvent(callback) { 5705 const ref = (0, import_react3.useRef)(() => { 5706 throw new Error("Cannot call an event handler while rendering."); 5707 }); 5708 if (useReactInsertionEffect) { 5709 useReactInsertionEffect(() => { 5710 ref.current = callback; 5711 }); 5712 } else { 5713 ref.current = callback; 5714 } 5715 return (0, import_react3.useCallback)((...args) => { 5716 var _a; 5717 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args); 5718 }, []); 5719 } 5720 function useTransactionState(callback) { 5721 const [state, setState] = (0, import_react3.useState)(null); 5722 useSafeLayoutEffect(() => { 5723 if (state == null) return; 5724 if (!callback) return; 5725 let prevState = null; 5726 callback((prev) => { 5727 prevState = prev; 5728 return state; 5729 }); 5730 return () => { 5731 callback(prevState); 5732 }; 5733 }, [state, callback]); 5734 return [state, setState]; 5735 } 5736 function useMergeRefs(...refs) { 5737 return (0, import_react3.useMemo)(() => { 5738 if (!refs.some(Boolean)) return; 5739 return (value) => { 5740 for (const ref of refs) { 5741 setRef(ref, value); 5742 } 5743 }; 5744 }, refs); 5745 } 5746 function useId3(defaultId) { 5747 if (useReactId) { 5748 const reactId = useReactId(); 5749 if (defaultId) return defaultId; 5750 return reactId; 5751 } 5752 const [id, setId] = (0, import_react3.useState)(defaultId); 5753 useSafeLayoutEffect(() => { 5754 if (defaultId || id) return; 5755 const random = Math.random().toString(36).slice(2, 8); 5756 setId(`id-$random}`); 5757 }, [defaultId, id]); 5758 return defaultId || id; 5759 } 5760 function useTagName(refOrElement, type) { 5761 const stringOrUndefined = (type2) => { 5762 if (typeof type2 !== "string") return; 5763 return type2; 5764 }; 5765 const [tagName, setTagName] = (0, import_react3.useState)(() => stringOrUndefined(type)); 5766 useSafeLayoutEffect(() => { 5767 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 5768 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type)); 5769 }, [refOrElement, type]); 5770 return tagName; 5771 } 5772 function useAttribute(refOrElement, attributeName, defaultValue2) { 5773 const initialValue = useInitialValue(defaultValue2); 5774 const [attribute, setAttribute] = (0, import_react3.useState)(initialValue); 5775 (0, import_react3.useEffect)(() => { 5776 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 5777 if (!element) return; 5778 const callback = () => { 5779 const value = element.getAttribute(attributeName); 5780 setAttribute(value == null ? initialValue : value); 5781 }; 5782 const observer = new MutationObserver(callback); 5783 observer.observe(element, { attributeFilter: [attributeName] }); 5784 callback(); 5785 return () => observer.disconnect(); 5786 }, [refOrElement, attributeName, initialValue]); 5787 return attribute; 5788 } 5789 function useUpdateEffect(effect, deps) { 5790 const mounted = (0, import_react3.useRef)(false); 5791 (0, import_react3.useEffect)(() => { 5792 if (mounted.current) { 5793 return effect(); 5794 } 5795 mounted.current = true; 5796 }, deps); 5797 (0, import_react3.useEffect)( 5798 () => () => { 5799 mounted.current = false; 5800 }, 5801 [] 5802 ); 5803 } 5804 function useUpdateLayoutEffect(effect, deps) { 5805 const mounted = (0, import_react3.useRef)(false); 5806 useSafeLayoutEffect(() => { 5807 if (mounted.current) { 5808 return effect(); 5809 } 5810 mounted.current = true; 5811 }, deps); 5812 useSafeLayoutEffect( 5813 () => () => { 5814 mounted.current = false; 5815 }, 5816 [] 5817 ); 5818 } 5819 function useForceUpdate() { 5820 return (0, import_react3.useReducer)(() => [], []); 5821 } 5822 function useBooleanEvent(booleanOrCallback) { 5823 return useEvent( 5824 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback 5825 ); 5826 } 5827 function useWrapElement(props, callback, deps = []) { 5828 const wrapElement = (0, import_react3.useCallback)( 5829 (element) => { 5830 if (props.wrapElement) { 5831 element = props.wrapElement(element); 5832 } 5833 return callback(element); 5834 }, 5835 [...deps, props.wrapElement] 5836 ); 5837 return __spreadProps(__spreadValues({}, props), { wrapElement }); 5838 } 5839 function useMetadataProps(props, key, value) { 5840 const parent = props.onLoadedMetadataCapture; 5841 const onLoadedMetadataCapture = (0, import_react3.useMemo)(() => { 5842 return Object.assign(() => { 5843 }, __spreadProps(__spreadValues({}, parent), { [key]: value })); 5844 }, [parent, key, value]); 5845 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }]; 5846 } 5847 function useIsMouseMoving() { 5848 (0, import_react3.useEffect)(() => { 5849 addGlobalEventListener("mousemove", setMouseMoving, true); 5850 addGlobalEventListener("mousedown", resetMouseMoving, true); 5851 addGlobalEventListener("mouseup", resetMouseMoving, true); 5852 addGlobalEventListener("keydown", resetMouseMoving, true); 5853 addGlobalEventListener("scroll", resetMouseMoving, true); 5854 }, []); 5855 const isMouseMoving = useEvent(() => mouseMoving); 5856 return isMouseMoving; 5857 } 5858 var mouseMoving = false; 5859 var previousScreenX = 0; 5860 var previousScreenY = 0; 5861 function hasMouseMovement(event) { 5862 const movementX = event.movementX || event.screenX - previousScreenX; 5863 const movementY = event.movementY || event.screenY - previousScreenY; 5864 previousScreenX = event.screenX; 5865 previousScreenY = event.screenY; 5866 return movementX || movementY || false; 5867 } 5868 function setMouseMoving(event) { 5869 if (!hasMouseMovement(event)) return; 5870 mouseMoving = true; 5871 } 5872 function resetMouseMoving() { 5873 mouseMoving = false; 5874 } 5875 5876 // node_modules/@ariakit/react-core/esm/__chunks/LMDWO4NN.js 5877 var React3 = __toESM(require_react(), 1); 5878 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1); 5879 function forwardRef22(render4) { 5880 const Role = React3.forwardRef((props, ref) => render4(__spreadProps(__spreadValues({}, props), { ref }))); 5881 Role.displayName = render4.displayName || render4.name; 5882 return Role; 5883 } 5884 function memo22(Component, propsAreEqual) { 5885 return React3.memo(Component, propsAreEqual); 5886 } 5887 function createElement2(Type, props) { 5888 const _a = props, { wrapElement, render: render4 } = _a, rest = __objRest(_a, ["wrapElement", "render"]); 5889 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4)); 5890 let element; 5891 if (React3.isValidElement(render4)) { 5892 const renderProps = __spreadProps(__spreadValues({}, render4.props), { ref: mergedRef }); 5893 element = React3.cloneElement(render4, mergeProps(rest, renderProps)); 5894 } else if (render4) { 5895 element = render4(rest); 5896 } else { 5897 element = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Type, __spreadValues({}, rest)); 5898 } 5899 if (wrapElement) { 5900 return wrapElement(element); 5901 } 5902 return element; 5903 } 5904 function createHook(useProps) { 5905 const useRole = (props = {}) => { 5906 return useProps(props); 5907 }; 5908 useRole.displayName = useProps.name; 5909 return useRole; 5910 } 5911 function createStoreContext(providers = [], scopedProviders = []) { 5912 const context = React3.createContext(void 0); 5913 const scopedContext = React3.createContext(void 0); 5914 const useContext28 = () => React3.useContext(context); 5915 const useScopedContext = (onlyScoped = false) => { 5916 const scoped = React3.useContext(scopedContext); 5917 const store = useContext28(); 5918 if (onlyScoped) return scoped; 5919 return scoped || store; 5920 }; 5921 const useProviderContext = () => { 5922 const scoped = React3.useContext(scopedContext); 5923 const store = useContext28(); 5924 if (scoped && scoped === store) return; 5925 return store; 5926 }; 5927 const ContextProvider = (props) => { 5928 return providers.reduceRight( 5929 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Provider, __spreadProps(__spreadValues({}, props), { children })), 5930 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(context.Provider, __spreadValues({}, props)) 5931 ); 5932 }; 5933 const ScopedContextProvider = (props) => { 5934 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ContextProvider, __spreadProps(__spreadValues({}, props), { children: scopedProviders.reduceRight( 5935 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Provider, __spreadProps(__spreadValues({}, props), { children })), 5936 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(scopedContext.Provider, __spreadValues({}, props)) 5937 ) })); 5938 }; 5939 return { 5940 context, 5941 scopedContext, 5942 useContext: useContext28, 5943 useScopedContext, 5944 useProviderContext, 5945 ContextProvider, 5946 ScopedContextProvider 5947 }; 5948 } 5949 5950 // node_modules/@ariakit/react-core/esm/__chunks/VDHZ5F7K.js 5951 var ctx = createStoreContext(); 5952 var useCollectionContext = ctx.useContext; 5953 var useCollectionScopedContext = ctx.useScopedContext; 5954 var useCollectionProviderContext = ctx.useProviderContext; 5955 var CollectionContextProvider = ctx.ContextProvider; 5956 var CollectionScopedContextProvider = ctx.ScopedContextProvider; 5957 5958 // node_modules/@ariakit/react-core/esm/__chunks/P7GR5CS5.js 5959 var import_react4 = __toESM(require_react(), 1); 5960 var ctx2 = createStoreContext( 5961 [CollectionContextProvider], 5962 [CollectionScopedContextProvider] 5963 ); 5964 var useCompositeContext = ctx2.useContext; 5965 var useCompositeScopedContext = ctx2.useScopedContext; 5966 var useCompositeProviderContext = ctx2.useProviderContext; 5967 var CompositeContextProvider = ctx2.ContextProvider; 5968 var CompositeScopedContextProvider = ctx2.ScopedContextProvider; 5969 var CompositeItemContext = (0, import_react4.createContext)( 5970 void 0 5971 ); 5972 var CompositeRowContext = (0, import_react4.createContext)( 5973 void 0 5974 ); 5975 5976 // node_modules/@ariakit/react-core/esm/__chunks/3XAVFTCA.js 5977 var import_react5 = __toESM(require_react(), 1); 5978 var TagValueContext = (0, import_react5.createContext)(null); 5979 var TagRemoveIdContext = (0, import_react5.createContext)( 5980 null 5981 ); 5982 var ctx3 = createStoreContext( 5983 [CompositeContextProvider], 5984 [CompositeScopedContextProvider] 5985 ); 5986 var useTagContext = ctx3.useContext; 5987 var useTagScopedContext = ctx3.useScopedContext; 5988 var useTagProviderContext = ctx3.useProviderContext; 5989 var TagContextProvider = ctx3.ContextProvider; 5990 var TagScopedContextProvider = ctx3.ScopedContextProvider; 5991 5992 // node_modules/@ariakit/core/esm/__chunks/BCALMBPZ.js 5993 function getInternal(store, key) { 5994 const internals = store.__unstableInternals; 5995 invariant(internals, "Invalid store"); 5996 return internals[key]; 5997 } 5998 function createStore(initialState, ...stores) { 5999 let state = initialState; 6000 let prevStateBatch = state; 6001 let lastUpdate = Symbol(); 6002 let destroy = noop; 6003 const instances = /* @__PURE__ */ new Set(); 6004 const updatedKeys = /* @__PURE__ */ new Set(); 6005 const setups = /* @__PURE__ */ new Set(); 6006 const listeners = /* @__PURE__ */ new Set(); 6007 const batchListeners = /* @__PURE__ */ new Set(); 6008 const disposables = /* @__PURE__ */ new WeakMap(); 6009 const listenerKeys = /* @__PURE__ */ new WeakMap(); 6010 const storeSetup = (callback) => { 6011 setups.add(callback); 6012 return () => setups.delete(callback); 6013 }; 6014 const storeInit = () => { 6015 const initialized = instances.size; 6016 const instance = Symbol(); 6017 instances.add(instance); 6018 const maybeDestroy = () => { 6019 instances.delete(instance); 6020 if (instances.size) return; 6021 destroy(); 6022 }; 6023 if (initialized) return maybeDestroy; 6024 const desyncs = getKeys(state).map( 6025 (key) => chain( 6026 ...stores.map((store) => { 6027 var _a; 6028 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store); 6029 if (!storeState) return; 6030 if (!hasOwnProperty(storeState, key)) return; 6031 return sync(store, [key], (state2) => { 6032 setState( 6033 key, 6034 state2[key], 6035 // @ts-expect-error - Not public API. This is just to prevent 6036 // infinite loops. 6037 true 6038 ); 6039 }); 6040 }) 6041 ) 6042 ); 6043 const teardowns = []; 6044 for (const setup2 of setups) { 6045 teardowns.push(setup2()); 6046 } 6047 const cleanups = stores.map(init); 6048 destroy = chain(...desyncs, ...teardowns, ...cleanups); 6049 return maybeDestroy; 6050 }; 6051 const sub = (keys, listener, set = listeners) => { 6052 set.add(listener); 6053 listenerKeys.set(listener, keys); 6054 return () => { 6055 var _a; 6056 (_a = disposables.get(listener)) == null ? void 0 : _a(); 6057 disposables.delete(listener); 6058 listenerKeys.delete(listener); 6059 set.delete(listener); 6060 }; 6061 }; 6062 const storeSubscribe = (keys, listener) => sub(keys, listener); 6063 const storeSync = (keys, listener) => { 6064 disposables.set(listener, listener(state, state)); 6065 return sub(keys, listener); 6066 }; 6067 const storeBatch = (keys, listener) => { 6068 disposables.set(listener, listener(state, prevStateBatch)); 6069 return sub(keys, listener, batchListeners); 6070 }; 6071 const storePick = (keys) => createStore(pick(state, keys), finalStore); 6072 const storeOmit = (keys) => createStore(omit2(state, keys), finalStore); 6073 const getState = () => state; 6074 const setState = (key, value, fromStores = false) => { 6075 var _a; 6076 if (!hasOwnProperty(state, key)) return; 6077 const nextValue = applyState(value, state[key]); 6078 if (nextValue === state[key]) return; 6079 if (!fromStores) { 6080 for (const store of stores) { 6081 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue); 6082 } 6083 } 6084 const prevState = state; 6085 state = __spreadProps2(__spreadValues2({}, state), { [key]: nextValue }); 6086 const thisUpdate = Symbol(); 6087 lastUpdate = thisUpdate; 6088 updatedKeys.add(key); 6089 const run = (listener, prev, uKeys) => { 6090 var _a2; 6091 const keys = listenerKeys.get(listener); 6092 const updated = (k) => uKeys ? uKeys.has(k) : k === key; 6093 if (!keys || keys.some(updated)) { 6094 (_a2 = disposables.get(listener)) == null ? void 0 : _a2(); 6095 disposables.set(listener, listener(state, prev)); 6096 } 6097 }; 6098 for (const listener of listeners) { 6099 run(listener, prevState); 6100 } 6101 queueMicrotask(() => { 6102 if (lastUpdate !== thisUpdate) return; 6103 const snapshot = state; 6104 for (const listener of batchListeners) { 6105 run(listener, prevStateBatch, updatedKeys); 6106 } 6107 prevStateBatch = snapshot; 6108 updatedKeys.clear(); 6109 }); 6110 }; 6111 const finalStore = { 6112 getState, 6113 setState, 6114 __unstableInternals: { 6115 setup: storeSetup, 6116 init: storeInit, 6117 subscribe: storeSubscribe, 6118 sync: storeSync, 6119 batch: storeBatch, 6120 pick: storePick, 6121 omit: storeOmit 6122 } 6123 }; 6124 return finalStore; 6125 } 6126 function setup(store, ...args) { 6127 if (!store) return; 6128 return getInternal(store, "setup")(...args); 6129 } 6130 function init(store, ...args) { 6131 if (!store) return; 6132 return getInternal(store, "init")(...args); 6133 } 6134 function subscribe(store, ...args) { 6135 if (!store) return; 6136 return getInternal(store, "subscribe")(...args); 6137 } 6138 function sync(store, ...args) { 6139 if (!store) return; 6140 return getInternal(store, "sync")(...args); 6141 } 6142 function batch(store, ...args) { 6143 if (!store) return; 6144 return getInternal(store, "batch")(...args); 6145 } 6146 function omit22(store, ...args) { 6147 if (!store) return; 6148 return getInternal(store, "omit")(...args); 6149 } 6150 function pick2(store, ...args) { 6151 if (!store) return; 6152 return getInternal(store, "pick")(...args); 6153 } 6154 function mergeStore(...stores) { 6155 const initialState = stores.reduce((state, store2) => { 6156 var _a; 6157 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2); 6158 if (!nextState) return state; 6159 return Object.assign(state, nextState); 6160 }, {}); 6161 const store = createStore(initialState, ...stores); 6162 return Object.assign({}, ...stores, store); 6163 } 6164 function throwOnConflictingProps(props, store) { 6165 if (false) return; 6166 if (!store) return; 6167 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => { 6168 var _a; 6169 const stateKey = key.replace("default", ""); 6170 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}$stateKey.slice(1)}`; 6171 }); 6172 if (!defaultKeys.length) return; 6173 const storeState = store.getState(); 6174 const conflictingProps = defaultKeys.filter( 6175 (key) => hasOwnProperty(storeState, key) 6176 ); 6177 if (!conflictingProps.length) return; 6178 throw new Error( 6179 `Passing a store prop in conjunction with a default state is not supported. 6180 6181 const store = useSelectStore(); 6182 <SelectProvider store={store} defaultValue="Apple" /> 6183 ^ ^ 6184 6185 Instead, pass the default state to the topmost store: 6186 6187 const store = useSelectStore({ defaultValue: "Apple" }); 6188 <SelectProvider store={store} /> 6189 6190 See https://github.com/ariakit/ariakit/pull/2745 for more details. 6191 6192 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit 6193 ` 6194 ); 6195 } 6196 6197 // node_modules/@ariakit/react-core/esm/__chunks/YV4JVR4I.js 6198 var React4 = __toESM(require_react(), 1); 6199 var import_shim = __toESM(require_shim(), 1); 6200 var { useSyncExternalStore } = import_shim.default; 6201 var noopSubscribe = () => () => { 6202 }; 6203 function useStoreState(store, keyOrSelector = identity) { 6204 const storeSubscribe = React4.useCallback( 6205 (callback) => { 6206 if (!store) return noopSubscribe(); 6207 return subscribe(store, null, callback); 6208 }, 6209 [store] 6210 ); 6211 const getSnapshot = () => { 6212 const key = typeof keyOrSelector === "string" ? keyOrSelector : null; 6213 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null; 6214 const state = store == null ? void 0 : store.getState(); 6215 if (selector2) return selector2(state); 6216 if (!state) return; 6217 if (!key) return; 6218 if (!hasOwnProperty(state, key)) return; 6219 return state[key]; 6220 }; 6221 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot); 6222 } 6223 function useStoreStateObject(store, object) { 6224 const objRef = React4.useRef( 6225 {} 6226 ); 6227 const storeSubscribe = React4.useCallback( 6228 (callback) => { 6229 if (!store) return noopSubscribe(); 6230 return subscribe(store, null, callback); 6231 }, 6232 [store] 6233 ); 6234 const getSnapshot = () => { 6235 const state = store == null ? void 0 : store.getState(); 6236 let updated = false; 6237 const obj = objRef.current; 6238 for (const prop in object) { 6239 const keyOrSelector = object[prop]; 6240 if (typeof keyOrSelector === "function") { 6241 const value = keyOrSelector(state); 6242 if (value !== obj[prop]) { 6243 obj[prop] = value; 6244 updated = true; 6245 } 6246 } 6247 if (typeof keyOrSelector === "string") { 6248 if (!state) continue; 6249 if (!hasOwnProperty(state, keyOrSelector)) continue; 6250 const value = state[keyOrSelector]; 6251 if (value !== obj[prop]) { 6252 obj[prop] = value; 6253 updated = true; 6254 } 6255 } 6256 } 6257 if (updated) { 6258 objRef.current = __spreadValues({}, obj); 6259 } 6260 return objRef.current; 6261 }; 6262 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot); 6263 } 6264 function useStoreProps(store, props, key, setKey) { 6265 const value = hasOwnProperty(props, key) ? props[key] : void 0; 6266 const setValue = setKey ? props[setKey] : void 0; 6267 const propsRef = useLiveRef({ value, setValue }); 6268 useSafeLayoutEffect(() => { 6269 return sync(store, [key], (state, prev) => { 6270 const { value: value2, setValue: setValue2 } = propsRef.current; 6271 if (!setValue2) return; 6272 if (state[key] === prev[key]) return; 6273 if (state[key] === value2) return; 6274 setValue2(state[key]); 6275 }); 6276 }, [store, key]); 6277 useSafeLayoutEffect(() => { 6278 if (value === void 0) return; 6279 store.setState(key, value); 6280 return batch(store, [key], () => { 6281 if (value === void 0) return; 6282 store.setState(key, value); 6283 }); 6284 }); 6285 } 6286 function useStore(createStore2, props) { 6287 const [store, setStore] = React4.useState(() => createStore2(props)); 6288 useSafeLayoutEffect(() => init(store), [store]); 6289 const useState24 = React4.useCallback( 6290 (keyOrSelector) => useStoreState(store, keyOrSelector), 6291 [store] 6292 ); 6293 const memoizedStore = React4.useMemo( 6294 () => __spreadProps(__spreadValues({}, store), { useState: useState24 }), 6295 [store, useState24] 6296 ); 6297 const updateStore = useEvent(() => { 6298 setStore((store2) => createStore2(__spreadValues(__spreadValues({}, props), store2.getState()))); 6299 }); 6300 return [memoizedStore, updateStore]; 6301 } 6302 6303 // node_modules/@ariakit/core/esm/__chunks/CYQWQL4J.js 6304 function getCommonParent(items) { 6305 var _a; 6306 const firstItem = items.find((item) => !!item.element); 6307 const lastItem = [...items].reverse().find((item) => !!item.element); 6308 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement; 6309 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) { 6310 const parent = parentElement; 6311 if (lastItem && parent.contains(lastItem.element)) { 6312 return parentElement; 6313 } 6314 parentElement = parentElement.parentElement; 6315 } 6316 return getDocument(parentElement).body; 6317 } 6318 function getPrivateStore(store) { 6319 return store == null ? void 0 : store.__unstablePrivateStore; 6320 } 6321 function createCollectionStore(props = {}) { 6322 var _a; 6323 throwOnConflictingProps(props, props.store); 6324 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 6325 const items = defaultValue( 6326 props.items, 6327 syncState == null ? void 0 : syncState.items, 6328 props.defaultItems, 6329 [] 6330 ); 6331 const itemsMap = new Map(items.map((item) => [item.id, item])); 6332 const initialState = { 6333 items, 6334 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, []) 6335 }; 6336 const syncPrivateStore = getPrivateStore(props.store); 6337 const privateStore = createStore( 6338 { items, renderedItems: initialState.renderedItems }, 6339 syncPrivateStore 6340 ); 6341 const collection = createStore(initialState, props.store); 6342 const sortItems = (renderedItems) => { 6343 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element); 6344 privateStore.setState("renderedItems", sortedItems); 6345 collection.setState("renderedItems", sortedItems); 6346 }; 6347 setup(collection, () => init(privateStore)); 6348 setup(privateStore, () => { 6349 return batch(privateStore, ["items"], (state) => { 6350 collection.setState("items", state.items); 6351 }); 6352 }); 6353 setup(privateStore, () => { 6354 return batch(privateStore, ["renderedItems"], (state) => { 6355 let firstRun = true; 6356 let raf = requestAnimationFrame(() => { 6357 const { renderedItems } = collection.getState(); 6358 if (state.renderedItems === renderedItems) return; 6359 sortItems(state.renderedItems); 6360 }); 6361 if (typeof IntersectionObserver !== "function") { 6362 return () => cancelAnimationFrame(raf); 6363 } 6364 const ioCallback = () => { 6365 if (firstRun) { 6366 firstRun = false; 6367 return; 6368 } 6369 cancelAnimationFrame(raf); 6370 raf = requestAnimationFrame(() => sortItems(state.renderedItems)); 6371 }; 6372 const root = getCommonParent(state.renderedItems); 6373 const observer = new IntersectionObserver(ioCallback, { root }); 6374 for (const item of state.renderedItems) { 6375 if (!item.element) continue; 6376 observer.observe(item.element); 6377 } 6378 return () => { 6379 cancelAnimationFrame(raf); 6380 observer.disconnect(); 6381 }; 6382 }); 6383 }); 6384 const mergeItem = (item, setItems, canDeleteFromMap = false) => { 6385 let prevItem; 6386 setItems((items2) => { 6387 const index = items2.findIndex(({ id }) => id === item.id); 6388 const nextItems = items2.slice(); 6389 if (index !== -1) { 6390 prevItem = items2[index]; 6391 const nextItem = __spreadValues2(__spreadValues2({}, prevItem), item); 6392 nextItems[index] = nextItem; 6393 itemsMap.set(item.id, nextItem); 6394 } else { 6395 nextItems.push(item); 6396 itemsMap.set(item.id, item); 6397 } 6398 return nextItems; 6399 }); 6400 const unmergeItem = () => { 6401 setItems((items2) => { 6402 if (!prevItem) { 6403 if (canDeleteFromMap) { 6404 itemsMap.delete(item.id); 6405 } 6406 return items2.filter(({ id }) => id !== item.id); 6407 } 6408 const index = items2.findIndex(({ id }) => id === item.id); 6409 if (index === -1) return items2; 6410 const nextItems = items2.slice(); 6411 nextItems[index] = prevItem; 6412 itemsMap.set(item.id, prevItem); 6413 return nextItems; 6414 }); 6415 }; 6416 return unmergeItem; 6417 }; 6418 const registerItem = (item) => mergeItem( 6419 item, 6420 (getItems) => privateStore.setState("items", getItems), 6421 true 6422 ); 6423 return __spreadProps2(__spreadValues2({}, collection), { 6424 registerItem, 6425 renderItem: (item) => chain( 6426 registerItem(item), 6427 mergeItem( 6428 item, 6429 (getItems) => privateStore.setState("renderedItems", getItems) 6430 ) 6431 ), 6432 item: (id) => { 6433 if (!id) return null; 6434 let item = itemsMap.get(id); 6435 if (!item) { 6436 const { items: items2 } = privateStore.getState(); 6437 item = items2.find((item2) => item2.id === id); 6438 if (item) { 6439 itemsMap.set(id, item); 6440 } 6441 } 6442 return item || null; 6443 }, 6444 // @ts-expect-error Internal 6445 __unstablePrivateStore: privateStore 6446 }); 6447 } 6448 6449 // node_modules/@ariakit/react-core/esm/__chunks/C3IKGW5T.js 6450 function useCollectionStoreProps(store, update, props) { 6451 useUpdateEffect(update, [props.store]); 6452 useStoreProps(store, props, "items", "setItems"); 6453 return store; 6454 } 6455 6456 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js 6457 function toArray(arg) { 6458 if (Array.isArray(arg)) { 6459 return arg; 6460 } 6461 return typeof arg !== "undefined" ? [arg] : []; 6462 } 6463 function flatten2DArray(array) { 6464 const flattened = []; 6465 for (const row of array) { 6466 flattened.push(...row); 6467 } 6468 return flattened; 6469 } 6470 function reverseArray(array) { 6471 return array.slice().reverse(); 6472 } 6473 6474 // node_modules/@ariakit/core/esm/__chunks/AJZ4BYF3.js 6475 var NULL_ITEM = { id: null }; 6476 function findFirstEnabledItem(items, excludeId) { 6477 return items.find((item) => { 6478 if (excludeId) { 6479 return !item.disabled && item.id !== excludeId; 6480 } 6481 return !item.disabled; 6482 }); 6483 } 6484 function getEnabledItems(items, excludeId) { 6485 return items.filter((item) => { 6486 if (excludeId) { 6487 return !item.disabled && item.id !== excludeId; 6488 } 6489 return !item.disabled; 6490 }); 6491 } 6492 function getItemsInRow(items, rowId) { 6493 return items.filter((item) => item.rowId === rowId); 6494 } 6495 function flipItems(items, activeId, shouldInsertNullItem = false) { 6496 const index = items.findIndex((item) => item.id === activeId); 6497 return [ 6498 ...items.slice(index + 1), 6499 ...shouldInsertNullItem ? [NULL_ITEM] : [], 6500 ...items.slice(0, index) 6501 ]; 6502 } 6503 function groupItemsByRows(items) { 6504 const rows = []; 6505 for (const item of items) { 6506 const row = rows.find((currentRow) => { 6507 var _a; 6508 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 6509 }); 6510 if (row) { 6511 row.push(item); 6512 } else { 6513 rows.push([item]); 6514 } 6515 } 6516 return rows; 6517 } 6518 function getMaxRowLength(array) { 6519 let maxLength = 0; 6520 for (const { length } of array) { 6521 if (length > maxLength) { 6522 maxLength = length; 6523 } 6524 } 6525 return maxLength; 6526 } 6527 function createEmptyItem(rowId) { 6528 return { 6529 id: "__EMPTY_ITEM__", 6530 disabled: true, 6531 rowId 6532 }; 6533 } 6534 function normalizeRows(rows, activeId, focusShift) { 6535 const maxLength = getMaxRowLength(rows); 6536 for (const row of rows) { 6537 for (let i2 = 0; i2 < maxLength; i2 += 1) { 6538 const item = row[i2]; 6539 if (!item || focusShift && item.disabled) { 6540 const isFirst = i2 === 0; 6541 const previousItem = isFirst && focusShift ? findFirstEnabledItem(row) : row[i2 - 1]; 6542 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId); 6543 } 6544 } 6545 } 6546 return rows; 6547 } 6548 function verticalizeItems(items) { 6549 const rows = groupItemsByRows(items); 6550 const maxLength = getMaxRowLength(rows); 6551 const verticalized = []; 6552 for (let i2 = 0; i2 < maxLength; i2 += 1) { 6553 for (const row of rows) { 6554 const item = row[i2]; 6555 if (item) { 6556 verticalized.push(__spreadProps2(__spreadValues2({}, item), { 6557 // If there's no rowId, it means that it's not a grid composite, but 6558 // a single row instead. So, instead of verticalizing it, that is, 6559 // assigning a different rowId based on the column index, we keep it 6560 // undefined so they will be part of the same row. This is useful 6561 // when using up/down on one-dimensional composites. 6562 rowId: item.rowId ? `$i2}` : void 0 6563 })); 6564 } 6565 } 6566 } 6567 return verticalized; 6568 } 6569 function createCompositeStore(props = {}) { 6570 var _a; 6571 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 6572 const collection = createCollectionStore(props); 6573 const activeId = defaultValue( 6574 props.activeId, 6575 syncState == null ? void 0 : syncState.activeId, 6576 props.defaultActiveId 6577 ); 6578 const initialState = __spreadProps2(__spreadValues2({}, collection.getState()), { 6579 id: defaultValue( 6580 props.id, 6581 syncState == null ? void 0 : syncState.id, 6582 `id-$Math.random().toString(36).slice(2, 8)}` 6583 ), 6584 activeId, 6585 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null), 6586 includesBaseElement: defaultValue( 6587 props.includesBaseElement, 6588 syncState == null ? void 0 : syncState.includesBaseElement, 6589 activeId === null 6590 ), 6591 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0), 6592 orientation: defaultValue( 6593 props.orientation, 6594 syncState == null ? void 0 : syncState.orientation, 6595 "both" 6596 ), 6597 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false), 6598 virtualFocus: defaultValue( 6599 props.virtualFocus, 6600 syncState == null ? void 0 : syncState.virtualFocus, 6601 false 6602 ), 6603 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false), 6604 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false), 6605 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false) 6606 }); 6607 const composite = createStore(initialState, collection, props.store); 6608 setup( 6609 composite, 6610 () => sync(composite, ["renderedItems", "activeId"], (state) => { 6611 composite.setState("activeId", (activeId2) => { 6612 var _a2; 6613 if (activeId2 !== void 0) return activeId2; 6614 return (_a2 = findFirstEnabledItem(state.renderedItems)) == null ? void 0 : _a2.id; 6615 }); 6616 }) 6617 ); 6618 const getNextId = (direction = "next", options = {}) => { 6619 var _a2, _b; 6620 const defaultState = composite.getState(); 6621 const { 6622 skip = 0, 6623 activeId: activeId2 = defaultState.activeId, 6624 focusShift = defaultState.focusShift, 6625 focusLoop = defaultState.focusLoop, 6626 focusWrap = defaultState.focusWrap, 6627 includesBaseElement = defaultState.includesBaseElement, 6628 renderedItems = defaultState.renderedItems, 6629 rtl = defaultState.rtl 6630 } = options; 6631 const isVerticalDirection = direction === "up" || direction === "down"; 6632 const isNextDirection = direction === "next" || direction === "down"; 6633 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection; 6634 const canShift = focusShift && !skip; 6635 let items = !isVerticalDirection ? renderedItems : flatten2DArray( 6636 normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift) 6637 ); 6638 items = canReverse ? reverseArray(items) : items; 6639 items = isVerticalDirection ? verticalizeItems(items) : items; 6640 if (activeId2 == null) { 6641 return (_a2 = findFirstEnabledItem(items)) == null ? void 0 : _a2.id; 6642 } 6643 const activeItem = items.find((item) => item.id === activeId2); 6644 if (!activeItem) { 6645 return (_b = findFirstEnabledItem(items)) == null ? void 0 : _b.id; 6646 } 6647 const isGrid2 = items.some((item) => item.rowId); 6648 const activeIndex = items.indexOf(activeItem); 6649 const nextItems = items.slice(activeIndex + 1); 6650 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId); 6651 if (skip) { 6652 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2); 6653 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one. 6654 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1]; 6655 return nextItem2 == null ? void 0 : nextItem2.id; 6656 } 6657 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"); 6658 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical"); 6659 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false; 6660 if (canLoop) { 6661 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId); 6662 const sortedItems = flipItems(loopItems, activeId2, hasNullItem); 6663 const nextItem2 = findFirstEnabledItem(sortedItems, activeId2); 6664 return nextItem2 == null ? void 0 : nextItem2.id; 6665 } 6666 if (canWrap) { 6667 const nextItem2 = findFirstEnabledItem( 6668 // We can use nextItems, which contains all the next items, including 6669 // items from other rows, to wrap between rows. However, if there is a 6670 // null item (the composite container), we'll only use the next items in 6671 // the row. So moving next from the last item will focus on the 6672 // composite container. On grid composites, horizontal navigation never 6673 // focuses on the composite container, only vertical. 6674 hasNullItem ? nextItemsInRow : nextItems, 6675 activeId2 6676 ); 6677 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id; 6678 return nextId; 6679 } 6680 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2); 6681 if (!nextItem && hasNullItem) { 6682 return null; 6683 } 6684 return nextItem == null ? void 0 : nextItem.id; 6685 }; 6686 return __spreadProps2(__spreadValues2(__spreadValues2({}, collection), composite), { 6687 setBaseElement: (element) => composite.setState("baseElement", element), 6688 setActiveId: (id) => composite.setState("activeId", id), 6689 move: (id) => { 6690 if (id === void 0) return; 6691 composite.setState("activeId", id); 6692 composite.setState("moves", (moves) => moves + 1); 6693 }, 6694 first: () => { 6695 var _a2; 6696 return (_a2 = findFirstEnabledItem(composite.getState().renderedItems)) == null ? void 0 : _a2.id; 6697 }, 6698 last: () => { 6699 var _a2; 6700 return (_a2 = findFirstEnabledItem(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id; 6701 }, 6702 next: (options) => { 6703 if (options !== void 0 && typeof options === "number") { 6704 options = { skip: options }; 6705 } 6706 return getNextId("next", options); 6707 }, 6708 previous: (options) => { 6709 if (options !== void 0 && typeof options === "number") { 6710 options = { skip: options }; 6711 } 6712 return getNextId("previous", options); 6713 }, 6714 down: (options) => { 6715 if (options !== void 0 && typeof options === "number") { 6716 options = { skip: options }; 6717 } 6718 return getNextId("down", options); 6719 }, 6720 up: (options) => { 6721 if (options !== void 0 && typeof options === "number") { 6722 options = { skip: options }; 6723 } 6724 return getNextId("up", options); 6725 } 6726 }); 6727 } 6728 6729 // node_modules/@ariakit/react-core/esm/__chunks/4CMBR7SL.js 6730 function useCompositeStoreOptions(props) { 6731 const id = useId3(props.id); 6732 return __spreadValues({ id }, props); 6733 } 6734 function useCompositeStoreProps(store, update, props) { 6735 store = useCollectionStoreProps(store, update, props); 6736 useStoreProps(store, props, "activeId", "setActiveId"); 6737 useStoreProps(store, props, "includesBaseElement"); 6738 useStoreProps(store, props, "virtualFocus"); 6739 useStoreProps(store, props, "orientation"); 6740 useStoreProps(store, props, "rtl"); 6741 useStoreProps(store, props, "focusLoop"); 6742 useStoreProps(store, props, "focusWrap"); 6743 useStoreProps(store, props, "focusShift"); 6744 return store; 6745 } 6746 6747 // node_modules/@ariakit/core/esm/__chunks/RCQ5P4YE.js 6748 function createDisclosureStore(props = {}) { 6749 const store = mergeStore( 6750 props.store, 6751 omit22(props.disclosure, ["contentElement", "disclosureElement"]) 6752 ); 6753 throwOnConflictingProps(props, store); 6754 const syncState = store == null ? void 0 : store.getState(); 6755 const open = defaultValue( 6756 props.open, 6757 syncState == null ? void 0 : syncState.open, 6758 props.defaultOpen, 6759 false 6760 ); 6761 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false); 6762 const initialState = { 6763 open, 6764 animated, 6765 animating: !!animated && open, 6766 mounted: open, 6767 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null), 6768 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null) 6769 }; 6770 const disclosure = createStore(initialState, store); 6771 setup( 6772 disclosure, 6773 () => sync(disclosure, ["animated", "animating"], (state) => { 6774 if (state.animated) return; 6775 disclosure.setState("animating", false); 6776 }) 6777 ); 6778 setup( 6779 disclosure, 6780 () => subscribe(disclosure, ["open"], () => { 6781 if (!disclosure.getState().animated) return; 6782 disclosure.setState("animating", true); 6783 }) 6784 ); 6785 setup( 6786 disclosure, 6787 () => sync(disclosure, ["open", "animating"], (state) => { 6788 disclosure.setState("mounted", state.open || state.animating); 6789 }) 6790 ); 6791 return __spreadProps2(__spreadValues2({}, disclosure), { 6792 disclosure: props.disclosure, 6793 setOpen: (value) => disclosure.setState("open", value), 6794 show: () => disclosure.setState("open", true), 6795 hide: () => disclosure.setState("open", false), 6796 toggle: () => disclosure.setState("open", (open2) => !open2), 6797 stopAnimation: () => disclosure.setState("animating", false), 6798 setContentElement: (value) => disclosure.setState("contentElement", value), 6799 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value) 6800 }); 6801 } 6802 6803 // node_modules/@ariakit/react-core/esm/__chunks/WYCIER3C.js 6804 function useDisclosureStoreProps(store, update, props) { 6805 useUpdateEffect(update, [props.store, props.disclosure]); 6806 useStoreProps(store, props, "open", "setOpen"); 6807 useStoreProps(store, props, "mounted", "setMounted"); 6808 useStoreProps(store, props, "animated"); 6809 return Object.assign(store, { disclosure: props.disclosure }); 6810 } 6811 6812 // node_modules/@ariakit/core/esm/__chunks/FZZ2AVHF.js 6813 function createDialogStore(props = {}) { 6814 return createDisclosureStore(props); 6815 } 6816 6817 // node_modules/@ariakit/react-core/esm/__chunks/BM6PGYQY.js 6818 function useDialogStoreProps(store, update, props) { 6819 return useDisclosureStoreProps(store, update, props); 6820 } 6821 6822 // node_modules/@ariakit/core/esm/__chunks/ME2CUF3F.js 6823 function createPopoverStore(_a = {}) { 6824 var _b = _a, { 6825 popover: otherPopover 6826 } = _b, props = __objRest2(_b, [ 6827 "popover" 6828 ]); 6829 const store = mergeStore( 6830 props.store, 6831 omit22(otherPopover, [ 6832 "arrowElement", 6833 "anchorElement", 6834 "contentElement", 6835 "popoverElement", 6836 "disclosureElement" 6837 ]) 6838 ); 6839 throwOnConflictingProps(props, store); 6840 const syncState = store == null ? void 0 : store.getState(); 6841 const dialog = createDialogStore(__spreadProps2(__spreadValues2({}, props), { store })); 6842 const placement = defaultValue( 6843 props.placement, 6844 syncState == null ? void 0 : syncState.placement, 6845 "bottom" 6846 ); 6847 const initialState = __spreadProps2(__spreadValues2({}, dialog.getState()), { 6848 placement, 6849 currentPlacement: placement, 6850 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null), 6851 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null), 6852 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null), 6853 rendered: Symbol("rendered") 6854 }); 6855 const popover = createStore(initialState, dialog, store); 6856 return __spreadProps2(__spreadValues2(__spreadValues2({}, dialog), popover), { 6857 setAnchorElement: (element) => popover.setState("anchorElement", element), 6858 setPopoverElement: (element) => popover.setState("popoverElement", element), 6859 setArrowElement: (element) => popover.setState("arrowElement", element), 6860 render: () => popover.setState("rendered", Symbol("rendered")) 6861 }); 6862 } 6863 6864 // node_modules/@ariakit/react-core/esm/__chunks/O2PQ2652.js 6865 function usePopoverStoreProps(store, update, props) { 6866 useUpdateEffect(update, [props.popover]); 6867 useStoreProps(store, props, "placement"); 6868 return useDialogStoreProps(store, update, props); 6869 } 6870 6871 // node_modules/@ariakit/core/esm/combobox/combobox-store.js 6872 var isTouchSafari = isSafari() && isTouchDevice(); 6873 function createComboboxStore(_a = {}) { 6874 var _b = _a, { 6875 tag 6876 } = _b, props = __objRest2(_b, [ 6877 "tag" 6878 ]); 6879 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"])); 6880 throwOnConflictingProps(props, store); 6881 const tagState = tag == null ? void 0 : tag.getState(); 6882 const syncState = store == null ? void 0 : store.getState(); 6883 const activeId = defaultValue( 6884 props.activeId, 6885 syncState == null ? void 0 : syncState.activeId, 6886 props.defaultActiveId, 6887 null 6888 ); 6889 const composite = createCompositeStore(__spreadProps2(__spreadValues2({}, props), { 6890 activeId, 6891 includesBaseElement: defaultValue( 6892 props.includesBaseElement, 6893 syncState == null ? void 0 : syncState.includesBaseElement, 6894 true 6895 ), 6896 orientation: defaultValue( 6897 props.orientation, 6898 syncState == null ? void 0 : syncState.orientation, 6899 "vertical" 6900 ), 6901 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true), 6902 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true), 6903 virtualFocus: defaultValue( 6904 props.virtualFocus, 6905 syncState == null ? void 0 : syncState.virtualFocus, 6906 true 6907 ) 6908 })); 6909 const popover = createPopoverStore(__spreadProps2(__spreadValues2({}, props), { 6910 placement: defaultValue( 6911 props.placement, 6912 syncState == null ? void 0 : syncState.placement, 6913 "bottom-start" 6914 ) 6915 })); 6916 const value = defaultValue( 6917 props.value, 6918 syncState == null ? void 0 : syncState.value, 6919 props.defaultValue, 6920 "" 6921 ); 6922 const selectedValue = defaultValue( 6923 props.selectedValue, 6924 syncState == null ? void 0 : syncState.selectedValue, 6925 tagState == null ? void 0 : tagState.values, 6926 props.defaultSelectedValue, 6927 "" 6928 ); 6929 const multiSelectable = Array.isArray(selectedValue); 6930 const initialState = __spreadProps2(__spreadValues2(__spreadValues2({}, composite.getState()), popover.getState()), { 6931 value, 6932 selectedValue, 6933 resetValueOnSelect: defaultValue( 6934 props.resetValueOnSelect, 6935 syncState == null ? void 0 : syncState.resetValueOnSelect, 6936 multiSelectable 6937 ), 6938 resetValueOnHide: defaultValue( 6939 props.resetValueOnHide, 6940 syncState == null ? void 0 : syncState.resetValueOnHide, 6941 multiSelectable && !tag 6942 ), 6943 activeValue: syncState == null ? void 0 : syncState.activeValue 6944 }); 6945 const combobox = createStore(initialState, composite, popover, store); 6946 if (isTouchSafari) { 6947 setup( 6948 combobox, 6949 () => sync(combobox, ["virtualFocus"], () => { 6950 combobox.setState("virtualFocus", false); 6951 }) 6952 ); 6953 } 6954 setup(combobox, () => { 6955 if (!tag) return; 6956 return chain( 6957 sync(combobox, ["selectedValue"], (state) => { 6958 if (!Array.isArray(state.selectedValue)) return; 6959 tag.setValues(state.selectedValue); 6960 }), 6961 sync(tag, ["values"], (state) => { 6962 combobox.setState("selectedValue", state.values); 6963 }) 6964 ); 6965 }); 6966 setup( 6967 combobox, 6968 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => { 6969 if (!state.resetValueOnHide) return; 6970 if (state.mounted) return; 6971 combobox.setState("value", value); 6972 }) 6973 ); 6974 setup( 6975 combobox, 6976 () => sync(combobox, ["open"], (state) => { 6977 if (state.open) return; 6978 combobox.setState("activeId", activeId); 6979 combobox.setState("moves", 0); 6980 }) 6981 ); 6982 setup( 6983 combobox, 6984 () => sync(combobox, ["moves", "activeId"], (state, prevState) => { 6985 if (state.moves === prevState.moves) { 6986 combobox.setState("activeValue", void 0); 6987 } 6988 }) 6989 ); 6990 setup( 6991 combobox, 6992 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => { 6993 if (state.moves === prev.moves) return; 6994 const { activeId: activeId2 } = combobox.getState(); 6995 const activeItem = composite.item(activeId2); 6996 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value); 6997 }) 6998 ); 6999 return __spreadProps2(__spreadValues2(__spreadValues2(__spreadValues2({}, popover), composite), combobox), { 7000 tag, 7001 setValue: (value2) => combobox.setState("value", value2), 7002 resetValue: () => combobox.setState("value", initialState.value), 7003 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2) 7004 }); 7005 } 7006 7007 // node_modules/@ariakit/react-core/esm/__chunks/FEOFMWBY.js 7008 function useComboboxStoreOptions(props) { 7009 const tag = useTagContext(); 7010 props = __spreadProps(__spreadValues({}, props), { 7011 tag: props.tag !== void 0 ? props.tag : tag 7012 }); 7013 return useCompositeStoreOptions(props); 7014 } 7015 function useComboboxStoreProps(store, update, props) { 7016 useUpdateEffect(update, [props.tag]); 7017 useStoreProps(store, props, "value", "setValue"); 7018 useStoreProps(store, props, "selectedValue", "setSelectedValue"); 7019 useStoreProps(store, props, "resetValueOnHide"); 7020 useStoreProps(store, props, "resetValueOnSelect"); 7021 return Object.assign( 7022 useCompositeStoreProps( 7023 usePopoverStoreProps(store, update, props), 7024 update, 7025 props 7026 ), 7027 { tag: props.tag } 7028 ); 7029 } 7030 function useComboboxStore(props = {}) { 7031 props = useComboboxStoreOptions(props); 7032 const [store, update] = useStore(createComboboxStore, props); 7033 return useComboboxStoreProps(store, update, props); 7034 } 7035 7036 // node_modules/@ariakit/react-core/esm/__chunks/S6EF7IVO.js 7037 var ctx4 = createStoreContext(); 7038 var useDisclosureContext = ctx4.useContext; 7039 var useDisclosureScopedContext = ctx4.useScopedContext; 7040 var useDisclosureProviderContext = ctx4.useProviderContext; 7041 var DisclosureContextProvider = ctx4.ContextProvider; 7042 var DisclosureScopedContextProvider = ctx4.ScopedContextProvider; 7043 7044 // node_modules/@ariakit/react-core/esm/__chunks/RS7LB2H4.js 7045 var import_react6 = __toESM(require_react(), 1); 7046 var ctx5 = createStoreContext( 7047 [DisclosureContextProvider], 7048 [DisclosureScopedContextProvider] 7049 ); 7050 var useDialogContext = ctx5.useContext; 7051 var useDialogScopedContext = ctx5.useScopedContext; 7052 var useDialogProviderContext = ctx5.useProviderContext; 7053 var DialogContextProvider = ctx5.ContextProvider; 7054 var DialogScopedContextProvider = ctx5.ScopedContextProvider; 7055 var DialogHeadingContext = (0, import_react6.createContext)(void 0); 7056 var DialogDescriptionContext = (0, import_react6.createContext)(void 0); 7057 7058 // node_modules/@ariakit/react-core/esm/__chunks/MTZPJQMC.js 7059 var ctx6 = createStoreContext( 7060 [DialogContextProvider], 7061 [DialogScopedContextProvider] 7062 ); 7063 var usePopoverContext = ctx6.useContext; 7064 var usePopoverScopedContext = ctx6.useScopedContext; 7065 var usePopoverProviderContext = ctx6.useProviderContext; 7066 var PopoverContextProvider = ctx6.ContextProvider; 7067 var PopoverScopedContextProvider = ctx6.ScopedContextProvider; 7068 7069 // node_modules/@ariakit/react-core/esm/__chunks/VEVQD5MH.js 7070 var import_react7 = __toESM(require_react(), 1); 7071 var ComboboxListRoleContext = (0, import_react7.createContext)( 7072 void 0 7073 ); 7074 var ctx7 = createStoreContext( 7075 [PopoverContextProvider, CompositeContextProvider], 7076 [PopoverScopedContextProvider, CompositeScopedContextProvider] 7077 ); 7078 var useComboboxContext = ctx7.useContext; 7079 var useComboboxScopedContext = ctx7.useScopedContext; 7080 var useComboboxProviderContext = ctx7.useProviderContext; 7081 var ComboboxContextProvider = ctx7.ContextProvider; 7082 var ComboboxScopedContextProvider = ctx7.ScopedContextProvider; 7083 var ComboboxItemValueContext = (0, import_react7.createContext)( 7084 void 0 7085 ); 7086 var ComboboxItemCheckedContext = (0, import_react7.createContext)(false); 7087 7088 // node_modules/@ariakit/react-core/esm/__chunks/OMU7RWRV.js 7089 var TagName = "div"; 7090 var usePopoverAnchor = createHook( 7091 function usePopoverAnchor2(_a) { 7092 var _b = _a, { store } = _b, props = __objRest(_b, ["store"]); 7093 const context = usePopoverProviderContext(); 7094 store = store || context; 7095 props = __spreadProps(__spreadValues({}, props), { 7096 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref) 7097 }); 7098 return props; 7099 } 7100 ); 7101 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) { 7102 const htmlProps = usePopoverAnchor(props); 7103 return createElement2(TagName, htmlProps); 7104 }); 7105 7106 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js 7107 function findFirstEnabledItem2(items, excludeId) { 7108 return items.find((item) => { 7109 if (excludeId) { 7110 return !item.disabled && item.id !== excludeId; 7111 } 7112 return !item.disabled; 7113 }); 7114 } 7115 function getEnabledItem(store, id) { 7116 if (!id) return null; 7117 return store.item(id) || null; 7118 } 7119 function groupItemsByRows2(items) { 7120 const rows = []; 7121 for (const item of items) { 7122 const row = rows.find((currentRow) => { 7123 var _a; 7124 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 7125 }); 7126 if (row) { 7127 row.push(item); 7128 } else { 7129 rows.push([item]); 7130 } 7131 } 7132 return rows; 7133 } 7134 function selectTextField(element, collapseToEnd = false) { 7135 if (isTextField(element)) { 7136 element.setSelectionRange( 7137 collapseToEnd ? element.value.length : 0, 7138 element.value.length 7139 ); 7140 } else if (element.isContentEditable) { 7141 const selection = getDocument(element).getSelection(); 7142 selection == null ? void 0 : selection.selectAllChildren(element); 7143 if (collapseToEnd) { 7144 selection == null ? void 0 : selection.collapseToEnd(); 7145 } 7146 } 7147 } 7148 var FOCUS_SILENTLY = Symbol("FOCUS_SILENTLY"); 7149 function focusSilently(element) { 7150 element[FOCUS_SILENTLY] = true; 7151 element.focus({ preventScroll: true }); 7152 } 7153 function silentlyFocused(element) { 7154 const isSilentlyFocused = element[FOCUS_SILENTLY]; 7155 delete element[FOCUS_SILENTLY]; 7156 return isSilentlyFocused; 7157 } 7158 function isItem(store, element, exclude) { 7159 if (!element) return false; 7160 if (element === exclude) return false; 7161 const item = store.item(element.id); 7162 if (!item) return false; 7163 if (exclude && item.element === exclude) return false; 7164 return true; 7165 } 7166 7167 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js 7168 var import_react8 = __toESM(require_react(), 1); 7169 var FocusableContext = (0, import_react8.createContext)(true); 7170 7171 // node_modules/@ariakit/core/esm/utils/focus.js 7172 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'])"; 7173 function isFocusable(element) { 7174 if (!element.matches(selector)) return false; 7175 if (!isVisible(element)) return false; 7176 if (element.closest("[inert]")) return false; 7177 return true; 7178 } 7179 function getClosestFocusable(element) { 7180 while (element && !isFocusable(element)) { 7181 element = element.closest(selector); 7182 } 7183 return element || null; 7184 } 7185 function hasFocus(element) { 7186 const activeElement = getActiveElement(element); 7187 if (!activeElement) return false; 7188 if (activeElement === element) return true; 7189 const activeDescendant = activeElement.getAttribute("aria-activedescendant"); 7190 if (!activeDescendant) return false; 7191 return activeDescendant === element.id; 7192 } 7193 function hasFocusWithin(element) { 7194 const activeElement = getActiveElement(element); 7195 if (!activeElement) return false; 7196 if (contains(element, activeElement)) return true; 7197 const activeDescendant = activeElement.getAttribute("aria-activedescendant"); 7198 if (!activeDescendant) return false; 7199 if (!("id" in element)) return false; 7200 if (activeDescendant === element.id) return true; 7201 return !!element.querySelector(`#$CSS.escape(activeDescendant)}`); 7202 } 7203 function focusIfNeeded(element) { 7204 if (!hasFocusWithin(element) && isFocusable(element)) { 7205 element.focus(); 7206 } 7207 } 7208 function focusIntoView(element, options) { 7209 if (!("scrollIntoView" in element)) { 7210 element.focus(); 7211 } else { 7212 element.focus({ preventScroll: true }); 7213 element.scrollIntoView(__spreadValues2({ block: "nearest", inline: "nearest" }, options)); 7214 } 7215 } 7216 7217 // node_modules/@ariakit/react-core/esm/__chunks/LVA2YJMS.js 7218 var import_react9 = __toESM(require_react(), 1); 7219 var TagName2 = "div"; 7220 var isSafariBrowser = isSafari(); 7221 var alwaysFocusVisibleInputTypes = [ 7222 "text", 7223 "search", 7224 "url", 7225 "tel", 7226 "email", 7227 "password", 7228 "number", 7229 "date", 7230 "month", 7231 "week", 7232 "time", 7233 "datetime", 7234 "datetime-local" 7235 ]; 7236 var safariFocusAncestorSymbol = Symbol("safariFocusAncestor"); 7237 function markSafariFocusAncestor(element, value) { 7238 if (!element) return; 7239 element[safariFocusAncestorSymbol] = value; 7240 } 7241 function isAlwaysFocusVisible(element) { 7242 const { tagName, readOnly, type } = element; 7243 if (tagName === "TEXTAREA" && !readOnly) return true; 7244 if (tagName === "SELECT" && !readOnly) return true; 7245 if (tagName === "INPUT" && !readOnly) { 7246 return alwaysFocusVisibleInputTypes.includes(type); 7247 } 7248 if (element.isContentEditable) return true; 7249 const role = element.getAttribute("role"); 7250 if (role === "combobox" && element.dataset.name) { 7251 return true; 7252 } 7253 return false; 7254 } 7255 function getLabels(element) { 7256 if ("labels" in element) { 7257 return element.labels; 7258 } 7259 return null; 7260 } 7261 function isNativeCheckboxOrRadio(element) { 7262 const tagName = element.tagName.toLowerCase(); 7263 if (tagName === "input" && element.type) { 7264 return element.type === "radio" || element.type === "checkbox"; 7265 } 7266 return false; 7267 } 7268 function isNativeTabbable(tagName) { 7269 if (!tagName) return true; 7270 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a"; 7271 } 7272 function supportsDisabledAttribute(tagName) { 7273 if (!tagName) return true; 7274 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea"; 7275 } 7276 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) { 7277 if (!focusable) { 7278 return tabIndexProp; 7279 } 7280 if (trulyDisabled) { 7281 if (nativeTabbable && !supportsDisabled) { 7282 return -1; 7283 } 7284 return; 7285 } 7286 if (nativeTabbable) { 7287 return tabIndexProp; 7288 } 7289 return tabIndexProp || 0; 7290 } 7291 function useDisableEvent(onEvent, disabled) { 7292 return useEvent((event) => { 7293 onEvent == null ? void 0 : onEvent(event); 7294 if (event.defaultPrevented) return; 7295 if (disabled) { 7296 event.stopPropagation(); 7297 event.preventDefault(); 7298 } 7299 }); 7300 } 7301 var isKeyboardModality = true; 7302 function onGlobalMouseDown(event) { 7303 const target = event.target; 7304 if (target && "hasAttribute" in target) { 7305 if (!target.hasAttribute("data-focus-visible")) { 7306 isKeyboardModality = false; 7307 } 7308 } 7309 } 7310 function onGlobalKeyDown(event) { 7311 if (event.metaKey) return; 7312 if (event.ctrlKey) return; 7313 if (event.altKey) return; 7314 isKeyboardModality = true; 7315 } 7316 var useFocusable = createHook( 7317 function useFocusable2(_a) { 7318 var _b = _a, { 7319 focusable = true, 7320 accessibleWhenDisabled, 7321 autoFocus, 7322 onFocusVisible 7323 } = _b, props = __objRest(_b, [ 7324 "focusable", 7325 "accessibleWhenDisabled", 7326 "autoFocus", 7327 "onFocusVisible" 7328 ]); 7329 const ref = (0, import_react9.useRef)(null); 7330 (0, import_react9.useEffect)(() => { 7331 if (!focusable) return; 7332 addGlobalEventListener("mousedown", onGlobalMouseDown, true); 7333 addGlobalEventListener("keydown", onGlobalKeyDown, true); 7334 }, [focusable]); 7335 if (isSafariBrowser) { 7336 (0, import_react9.useEffect)(() => { 7337 if (!focusable) return; 7338 const element = ref.current; 7339 if (!element) return; 7340 if (!isNativeCheckboxOrRadio(element)) return; 7341 const labels = getLabels(element); 7342 if (!labels) return; 7343 const onMouseUp = () => queueMicrotask(() => element.focus()); 7344 for (const label of labels) { 7345 label.addEventListener("mouseup", onMouseUp); 7346 } 7347 return () => { 7348 for (const label of labels) { 7349 label.removeEventListener("mouseup", onMouseUp); 7350 } 7351 }; 7352 }, [focusable]); 7353 } 7354 const disabled = focusable && disabledFromProps(props); 7355 const trulyDisabled = !!disabled && !accessibleWhenDisabled; 7356 const [focusVisible, setFocusVisible] = (0, import_react9.useState)(false); 7357 (0, import_react9.useEffect)(() => { 7358 if (!focusable) return; 7359 if (trulyDisabled && focusVisible) { 7360 setFocusVisible(false); 7361 } 7362 }, [focusable, trulyDisabled, focusVisible]); 7363 (0, import_react9.useEffect)(() => { 7364 if (!focusable) return; 7365 if (!focusVisible) return; 7366 const element = ref.current; 7367 if (!element) return; 7368 if (typeof IntersectionObserver === "undefined") return; 7369 const observer = new IntersectionObserver(() => { 7370 if (!isFocusable(element)) { 7371 setFocusVisible(false); 7372 } 7373 }); 7374 observer.observe(element); 7375 return () => observer.disconnect(); 7376 }, [focusable, focusVisible]); 7377 const onKeyPressCapture = useDisableEvent( 7378 props.onKeyPressCapture, 7379 disabled 7380 ); 7381 const onMouseDownCapture = useDisableEvent( 7382 props.onMouseDownCapture, 7383 disabled 7384 ); 7385 const onClickCapture = useDisableEvent(props.onClickCapture, disabled); 7386 const onMouseDownProp = props.onMouseDown; 7387 const onMouseDown = useEvent((event) => { 7388 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 7389 if (event.defaultPrevented) return; 7390 if (!focusable) return; 7391 const element = event.currentTarget; 7392 if (!isSafariBrowser) return; 7393 if (isPortalEvent(event)) return; 7394 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return; 7395 let receivedFocus = false; 7396 const onFocus = () => { 7397 receivedFocus = true; 7398 }; 7399 const options = { capture: true, once: true }; 7400 element.addEventListener("focusin", onFocus, options); 7401 const focusableContainer = getClosestFocusable(element.parentElement); 7402 markSafariFocusAncestor(focusableContainer, true); 7403 queueBeforeEvent(element, "mouseup", () => { 7404 element.removeEventListener("focusin", onFocus, true); 7405 markSafariFocusAncestor(focusableContainer, false); 7406 if (receivedFocus) return; 7407 focusIfNeeded(element); 7408 }); 7409 }); 7410 const handleFocusVisible = (event, currentTarget) => { 7411 if (currentTarget) { 7412 event.currentTarget = currentTarget; 7413 } 7414 if (!focusable) return; 7415 const element = event.currentTarget; 7416 if (!element) return; 7417 if (!hasFocus(element)) return; 7418 onFocusVisible == null ? void 0 : onFocusVisible(event); 7419 if (event.defaultPrevented) return; 7420 element.dataset.focusVisible = "true"; 7421 setFocusVisible(true); 7422 }; 7423 const onKeyDownCaptureProp = props.onKeyDownCapture; 7424 const onKeyDownCapture = useEvent((event) => { 7425 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event); 7426 if (event.defaultPrevented) return; 7427 if (!focusable) return; 7428 if (focusVisible) return; 7429 if (event.metaKey) return; 7430 if (event.altKey) return; 7431 if (event.ctrlKey) return; 7432 if (!isSelfTarget(event)) return; 7433 const element = event.currentTarget; 7434 const applyFocusVisible = () => handleFocusVisible(event, element); 7435 queueBeforeEvent(element, "focusout", applyFocusVisible); 7436 }); 7437 const onFocusCaptureProp = props.onFocusCapture; 7438 const onFocusCapture = useEvent((event) => { 7439 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 7440 if (event.defaultPrevented) return; 7441 if (!focusable) return; 7442 if (!isSelfTarget(event)) { 7443 setFocusVisible(false); 7444 return; 7445 } 7446 const element = event.currentTarget; 7447 const applyFocusVisible = () => handleFocusVisible(event, element); 7448 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) { 7449 queueBeforeEvent(event.target, "focusout", applyFocusVisible); 7450 } else { 7451 setFocusVisible(false); 7452 } 7453 }); 7454 const onBlurProp = props.onBlur; 7455 const onBlur = useEvent((event) => { 7456 onBlurProp == null ? void 0 : onBlurProp(event); 7457 if (!focusable) return; 7458 if (!isFocusEventOutside(event)) return; 7459 setFocusVisible(false); 7460 }); 7461 const autoFocusOnShow = (0, import_react9.useContext)(FocusableContext); 7462 const autoFocusRef = useEvent((element) => { 7463 if (!focusable) return; 7464 if (!autoFocus) return; 7465 if (!element) return; 7466 if (!autoFocusOnShow) return; 7467 queueMicrotask(() => { 7468 if (hasFocus(element)) return; 7469 if (!isFocusable(element)) return; 7470 element.focus(); 7471 }); 7472 }); 7473 const tagName = useTagName(ref); 7474 const nativeTabbable = focusable && isNativeTabbable(tagName); 7475 const supportsDisabled = focusable && supportsDisabledAttribute(tagName); 7476 const styleProp = props.style; 7477 const style = (0, import_react9.useMemo)(() => { 7478 if (trulyDisabled) { 7479 return __spreadValues({ pointerEvents: "none" }, styleProp); 7480 } 7481 return styleProp; 7482 }, [trulyDisabled, styleProp]); 7483 props = __spreadProps(__spreadValues({ 7484 "data-focus-visible": focusable && focusVisible || void 0, 7485 "data-autofocus": autoFocus || void 0, 7486 "aria-disabled": disabled || void 0 7487 }, props), { 7488 ref: useMergeRefs(ref, autoFocusRef, props.ref), 7489 style, 7490 tabIndex: getTabIndex( 7491 focusable, 7492 trulyDisabled, 7493 nativeTabbable, 7494 supportsDisabled, 7495 props.tabIndex 7496 ), 7497 disabled: supportsDisabled && trulyDisabled ? true : void 0, 7498 // TODO: Test Focusable contentEditable. 7499 contentEditable: disabled ? void 0 : props.contentEditable, 7500 onKeyPressCapture, 7501 onClickCapture, 7502 onMouseDownCapture, 7503 onMouseDown, 7504 onKeyDownCapture, 7505 onFocusCapture, 7506 onBlur 7507 }); 7508 return removeUndefinedValues(props); 7509 } 7510 ); 7511 var Focusable = forwardRef22(function Focusable2(props) { 7512 const htmlProps = useFocusable(props); 7513 return createElement2(TagName2, htmlProps); 7514 }); 7515 7516 // node_modules/@ariakit/react-core/esm/__chunks/ITI7HKP4.js 7517 var import_react10 = __toESM(require_react(), 1); 7518 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1); 7519 var TagName3 = "div"; 7520 function isGrid(items) { 7521 return items.some((item) => !!item.rowId); 7522 } 7523 function isPrintableKey(event) { 7524 const target = event.target; 7525 if (target && !isTextField(target)) return false; 7526 return event.key.length === 1 && !event.ctrlKey && !event.metaKey; 7527 } 7528 function isModifierKey(event) { 7529 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta"; 7530 } 7531 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) { 7532 return useEvent((event) => { 7533 var _a; 7534 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event); 7535 if (event.defaultPrevented) return; 7536 if (event.isPropagationStopped()) return; 7537 if (!isSelfTarget(event)) return; 7538 if (isModifierKey(event)) return; 7539 if (isPrintableKey(event)) return; 7540 const state = store.getState(); 7541 const activeElement = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element; 7542 if (!activeElement) return; 7543 const _b = event, { view } = _b, eventInit = __objRest(_b, ["view"]); 7544 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current; 7545 if (activeElement !== previousElement) { 7546 activeElement.focus(); 7547 } 7548 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) { 7549 event.preventDefault(); 7550 } 7551 if (event.currentTarget.contains(activeElement)) { 7552 event.stopPropagation(); 7553 } 7554 }); 7555 } 7556 function findFirstEnabledItemInTheLastRow(items) { 7557 return findFirstEnabledItem2( 7558 flatten2DArray(reverseArray(groupItemsByRows2(items))) 7559 ); 7560 } 7561 function useScheduleFocus(store) { 7562 const [scheduled, setScheduled] = (0, import_react10.useState)(false); 7563 const schedule = (0, import_react10.useCallback)(() => setScheduled(true), []); 7564 const activeItem = store.useState( 7565 (state) => getEnabledItem(store, state.activeId) 7566 ); 7567 (0, import_react10.useEffect)(() => { 7568 const activeElement = activeItem == null ? void 0 : activeItem.element; 7569 if (!scheduled) return; 7570 if (!activeElement) return; 7571 setScheduled(false); 7572 activeElement.focus({ preventScroll: true }); 7573 }, [activeItem, scheduled]); 7574 return schedule; 7575 } 7576 var useComposite = createHook( 7577 function useComposite2(_a) { 7578 var _b = _a, { 7579 store, 7580 composite = true, 7581 focusOnMove = composite, 7582 moveOnKeyPress = true 7583 } = _b, props = __objRest(_b, [ 7584 "store", 7585 "composite", 7586 "focusOnMove", 7587 "moveOnKeyPress" 7588 ]); 7589 const context = useCompositeProviderContext(); 7590 store = store || context; 7591 invariant( 7592 store, 7593 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component." 7594 ); 7595 const ref = (0, import_react10.useRef)(null); 7596 const previousElementRef = (0, import_react10.useRef)(null); 7597 const scheduleFocus = useScheduleFocus(store); 7598 const moves = store.useState("moves"); 7599 const [, setBaseElement] = useTransactionState( 7600 composite ? store.setBaseElement : null 7601 ); 7602 (0, import_react10.useEffect)(() => { 7603 var _a2; 7604 if (!store) return; 7605 if (!moves) return; 7606 if (!composite) return; 7607 if (!focusOnMove) return; 7608 const { activeId: activeId2 } = store.getState(); 7609 const itemElement = (_a2 = getEnabledItem(store, activeId2)) == null ? void 0 : _a2.element; 7610 if (!itemElement) return; 7611 focusIntoView(itemElement); 7612 }, [store, moves, composite, focusOnMove]); 7613 useSafeLayoutEffect(() => { 7614 if (!store) return; 7615 if (!moves) return; 7616 if (!composite) return; 7617 const { baseElement, activeId: activeId2 } = store.getState(); 7618 const isSelfAcive = activeId2 === null; 7619 if (!isSelfAcive) return; 7620 if (!baseElement) return; 7621 const previousElement = previousElementRef.current; 7622 previousElementRef.current = null; 7623 if (previousElement) { 7624 fireBlurEvent(previousElement, { relatedTarget: baseElement }); 7625 } 7626 if (!hasFocus(baseElement)) { 7627 baseElement.focus(); 7628 } 7629 }, [store, moves, composite]); 7630 const activeId = store.useState("activeId"); 7631 const virtualFocus = store.useState("virtualFocus"); 7632 useSafeLayoutEffect(() => { 7633 var _a2; 7634 if (!store) return; 7635 if (!composite) return; 7636 if (!virtualFocus) return; 7637 const previousElement = previousElementRef.current; 7638 previousElementRef.current = null; 7639 if (!previousElement) return; 7640 const activeElement = (_a2 = getEnabledItem(store, activeId)) == null ? void 0 : _a2.element; 7641 const relatedTarget = activeElement || getActiveElement(previousElement); 7642 if (relatedTarget === previousElement) return; 7643 fireBlurEvent(previousElement, { relatedTarget }); 7644 }, [store, activeId, virtualFocus, composite]); 7645 const onKeyDownCapture = useKeyboardEventProxy( 7646 store, 7647 props.onKeyDownCapture, 7648 previousElementRef 7649 ); 7650 const onKeyUpCapture = useKeyboardEventProxy( 7651 store, 7652 props.onKeyUpCapture, 7653 previousElementRef 7654 ); 7655 const onFocusCaptureProp = props.onFocusCapture; 7656 const onFocusCapture = useEvent((event) => { 7657 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 7658 if (event.defaultPrevented) return; 7659 if (!store) return; 7660 const { virtualFocus: virtualFocus2 } = store.getState(); 7661 if (!virtualFocus2) return; 7662 const previousActiveElement = event.relatedTarget; 7663 const isSilentlyFocused = silentlyFocused(event.currentTarget); 7664 if (isSelfTarget(event) && isSilentlyFocused) { 7665 event.stopPropagation(); 7666 previousElementRef.current = previousActiveElement; 7667 } 7668 }); 7669 const onFocusProp = props.onFocus; 7670 const onFocus = useEvent((event) => { 7671 onFocusProp == null ? void 0 : onFocusProp(event); 7672 if (event.defaultPrevented) return; 7673 if (!composite) return; 7674 if (!store) return; 7675 const { relatedTarget } = event; 7676 const { virtualFocus: virtualFocus2 } = store.getState(); 7677 if (virtualFocus2) { 7678 if (isSelfTarget(event) && !isItem(store, relatedTarget)) { 7679 queueMicrotask(scheduleFocus); 7680 } 7681 } else if (isSelfTarget(event)) { 7682 store.setActiveId(null); 7683 } 7684 }); 7685 const onBlurCaptureProp = props.onBlurCapture; 7686 const onBlurCapture = useEvent((event) => { 7687 var _a2; 7688 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 7689 if (event.defaultPrevented) return; 7690 if (!store) return; 7691 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState(); 7692 if (!virtualFocus2) return; 7693 const activeElement = (_a2 = getEnabledItem(store, activeId2)) == null ? void 0 : _a2.element; 7694 const nextActiveElement = event.relatedTarget; 7695 const nextActiveElementIsItem = isItem(store, nextActiveElement); 7696 const previousElement = previousElementRef.current; 7697 previousElementRef.current = null; 7698 if (isSelfTarget(event) && nextActiveElementIsItem) { 7699 if (nextActiveElement === activeElement) { 7700 if (previousElement && previousElement !== nextActiveElement) { 7701 fireBlurEvent(previousElement, event); 7702 } 7703 } else if (activeElement) { 7704 fireBlurEvent(activeElement, event); 7705 } else if (previousElement) { 7706 fireBlurEvent(previousElement, event); 7707 } 7708 event.stopPropagation(); 7709 } else { 7710 const targetIsItem = isItem(store, event.target); 7711 if (!targetIsItem && activeElement) { 7712 fireBlurEvent(activeElement, event); 7713 } 7714 } 7715 }); 7716 const onKeyDownProp = props.onKeyDown; 7717 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 7718 const onKeyDown = useEvent((event) => { 7719 var _a2; 7720 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 7721 if (event.defaultPrevented) return; 7722 if (!store) return; 7723 if (!isSelfTarget(event)) return; 7724 const { orientation, renderedItems, activeId: activeId2 } = store.getState(); 7725 const activeItem = getEnabledItem(store, activeId2); 7726 if ((_a2 = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a2.isConnected) return; 7727 const isVertical = orientation !== "horizontal"; 7728 const isHorizontal = orientation !== "vertical"; 7729 const grid = isGrid(renderedItems); 7730 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End"; 7731 if (isHorizontalKey && isTextField(event.currentTarget)) return; 7732 const up = () => { 7733 if (grid) { 7734 const item = findFirstEnabledItemInTheLastRow(renderedItems); 7735 return item == null ? void 0 : item.id; 7736 } 7737 return store == null ? void 0 : store.last(); 7738 }; 7739 const keyMap = { 7740 ArrowUp: (grid || isVertical) && up, 7741 ArrowRight: (grid || isHorizontal) && store.first, 7742 ArrowDown: (grid || isVertical) && store.first, 7743 ArrowLeft: (grid || isHorizontal) && store.last, 7744 Home: store.first, 7745 End: store.last, 7746 PageUp: store.first, 7747 PageDown: store.last 7748 }; 7749 const action = keyMap[event.key]; 7750 if (action) { 7751 const id = action(); 7752 if (id !== void 0) { 7753 if (!moveOnKeyPressProp(event)) return; 7754 event.preventDefault(); 7755 store.move(id); 7756 } 7757 } 7758 }); 7759 props = useWrapElement( 7760 props, 7761 (element) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(CompositeContextProvider, { value: store, children: element }), 7762 [store] 7763 ); 7764 const activeDescendant = store.useState((state) => { 7765 var _a2; 7766 if (!store) return; 7767 if (!composite) return; 7768 if (!state.virtualFocus) return; 7769 return (_a2 = getEnabledItem(store, state.activeId)) == null ? void 0 : _a2.id; 7770 }); 7771 props = __spreadProps(__spreadValues({ 7772 "aria-activedescendant": activeDescendant 7773 }, props), { 7774 ref: useMergeRefs(ref, setBaseElement, props.ref), 7775 onKeyDownCapture, 7776 onKeyUpCapture, 7777 onFocusCapture, 7778 onFocus, 7779 onBlurCapture, 7780 onKeyDown 7781 }); 7782 const focusable = store.useState( 7783 (state) => composite && (state.virtualFocus || state.activeId === null) 7784 ); 7785 props = useFocusable(__spreadValues({ focusable }, props)); 7786 return props; 7787 } 7788 ); 7789 var Composite5 = forwardRef22(function Composite22(props) { 7790 const htmlProps = useComposite(props); 7791 return createElement2(TagName3, htmlProps); 7792 }); 7793 7794 // node_modules/@ariakit/react-core/esm/combobox/combobox.js 7795 var import_react11 = __toESM(require_react(), 1); 7796 var TagName4 = "input"; 7797 function isFirstItemAutoSelected(items, activeValue, autoSelect) { 7798 if (!autoSelect) return false; 7799 const firstItem = items.find((item) => !item.disabled && item.value); 7800 return (firstItem == null ? void 0 : firstItem.value) === activeValue; 7801 } 7802 function hasCompletionString(value, activeValue) { 7803 if (!activeValue) return false; 7804 if (value == null) return false; 7805 value = normalizeString(value); 7806 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0; 7807 } 7808 function isInputEvent(event) { 7809 return event.type === "input"; 7810 } 7811 function isAriaAutoCompleteValue(value) { 7812 return value === "inline" || value === "list" || value === "both" || value === "none"; 7813 } 7814 function getDefaultAutoSelectId(items) { 7815 const item = items.find((item2) => { 7816 var _a; 7817 if (item2.disabled) return false; 7818 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab"; 7819 }); 7820 return item == null ? void 0 : item.id; 7821 } 7822 var useCombobox = createHook( 7823 function useCombobox2(_a) { 7824 var _b = _a, { 7825 store, 7826 focusable = true, 7827 autoSelect: autoSelectProp = false, 7828 getAutoSelectId, 7829 setValueOnChange, 7830 showMinLength = 0, 7831 showOnChange, 7832 showOnMouseDown, 7833 showOnClick = showOnMouseDown, 7834 showOnKeyDown, 7835 showOnKeyPress = showOnKeyDown, 7836 blurActiveItemOnClick, 7837 setValueOnClick = true, 7838 moveOnKeyPress = true, 7839 autoComplete = "list" 7840 } = _b, props = __objRest(_b, [ 7841 "store", 7842 "focusable", 7843 "autoSelect", 7844 "getAutoSelectId", 7845 "setValueOnChange", 7846 "showMinLength", 7847 "showOnChange", 7848 "showOnMouseDown", 7849 "showOnClick", 7850 "showOnKeyDown", 7851 "showOnKeyPress", 7852 "blurActiveItemOnClick", 7853 "setValueOnClick", 7854 "moveOnKeyPress", 7855 "autoComplete" 7856 ]); 7857 const context = useComboboxProviderContext(); 7858 store = store || context; 7859 invariant( 7860 store, 7861 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component." 7862 ); 7863 const ref = (0, import_react11.useRef)(null); 7864 const [valueUpdated, forceValueUpdate] = useForceUpdate(); 7865 const canAutoSelectRef = (0, import_react11.useRef)(false); 7866 const composingRef = (0, import_react11.useRef)(false); 7867 const autoSelect = store.useState( 7868 (state) => state.virtualFocus && autoSelectProp 7869 ); 7870 const inline = autoComplete === "inline" || autoComplete === "both"; 7871 const [canInline, setCanInline] = (0, import_react11.useState)(inline); 7872 useUpdateLayoutEffect(() => { 7873 if (!inline) return; 7874 setCanInline(true); 7875 }, [inline]); 7876 const storeValue = store.useState("value"); 7877 const prevSelectedValueRef = (0, import_react11.useRef)(); 7878 (0, import_react11.useEffect)(() => { 7879 return sync(store, ["selectedValue", "activeId"], (_, prev) => { 7880 prevSelectedValueRef.current = prev.selectedValue; 7881 }); 7882 }, []); 7883 const inlineActiveValue = store.useState((state) => { 7884 var _a2; 7885 if (!inline) return; 7886 if (!canInline) return; 7887 if (state.activeValue && Array.isArray(state.selectedValue)) { 7888 if (state.selectedValue.includes(state.activeValue)) return; 7889 if ((_a2 = prevSelectedValueRef.current) == null ? void 0 : _a2.includes(state.activeValue)) return; 7890 } 7891 return state.activeValue; 7892 }); 7893 const items = store.useState("renderedItems"); 7894 const open = store.useState("open"); 7895 const contentElement = store.useState("contentElement"); 7896 const value = (0, import_react11.useMemo)(() => { 7897 if (!inline) return storeValue; 7898 if (!canInline) return storeValue; 7899 const firstItemAutoSelected = isFirstItemAutoSelected( 7900 items, 7901 inlineActiveValue, 7902 autoSelect 7903 ); 7904 if (firstItemAutoSelected) { 7905 if (hasCompletionString(storeValue, inlineActiveValue)) { 7906 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || ""; 7907 return storeValue + slice; 7908 } 7909 return storeValue; 7910 } 7911 return inlineActiveValue || storeValue; 7912 }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]); 7913 (0, import_react11.useEffect)(() => { 7914 const element = ref.current; 7915 if (!element) return; 7916 const onCompositeItemMove = () => setCanInline(true); 7917 element.addEventListener("combobox-item-move", onCompositeItemMove); 7918 return () => { 7919 element.removeEventListener("combobox-item-move", onCompositeItemMove); 7920 }; 7921 }, []); 7922 (0, import_react11.useEffect)(() => { 7923 if (!inline) return; 7924 if (!canInline) return; 7925 if (!inlineActiveValue) return; 7926 const firstItemAutoSelected = isFirstItemAutoSelected( 7927 items, 7928 inlineActiveValue, 7929 autoSelect 7930 ); 7931 if (!firstItemAutoSelected) return; 7932 if (!hasCompletionString(storeValue, inlineActiveValue)) return; 7933 let cleanup = noop; 7934 queueMicrotask(() => { 7935 const element = ref.current; 7936 if (!element) return; 7937 const { start: prevStart, end: prevEnd } = getTextboxSelection(element); 7938 const nextStart = storeValue.length; 7939 const nextEnd = inlineActiveValue.length; 7940 setSelectionRange(element, nextStart, nextEnd); 7941 cleanup = () => { 7942 if (!hasFocus(element)) return; 7943 const { start, end } = getTextboxSelection(element); 7944 if (start !== nextStart) return; 7945 if (end !== nextEnd) return; 7946 setSelectionRange(element, prevStart, prevEnd); 7947 }; 7948 }); 7949 return () => cleanup(); 7950 }, [ 7951 valueUpdated, 7952 inline, 7953 canInline, 7954 inlineActiveValue, 7955 items, 7956 autoSelect, 7957 storeValue 7958 ]); 7959 const scrollingElementRef = (0, import_react11.useRef)(null); 7960 const getAutoSelectIdProp = useEvent(getAutoSelectId); 7961 const autoSelectIdRef = (0, import_react11.useRef)(null); 7962 (0, import_react11.useEffect)(() => { 7963 if (!open) return; 7964 if (!contentElement) return; 7965 const scrollingElement = getScrollingElement(contentElement); 7966 if (!scrollingElement) return; 7967 scrollingElementRef.current = scrollingElement; 7968 const onUserScroll = () => { 7969 canAutoSelectRef.current = false; 7970 }; 7971 const onScroll = () => { 7972 if (!store) return; 7973 if (!canAutoSelectRef.current) return; 7974 const { activeId } = store.getState(); 7975 if (activeId === null) return; 7976 if (activeId === autoSelectIdRef.current) return; 7977 canAutoSelectRef.current = false; 7978 }; 7979 const options = { passive: true, capture: true }; 7980 scrollingElement.addEventListener("wheel", onUserScroll, options); 7981 scrollingElement.addEventListener("touchmove", onUserScroll, options); 7982 scrollingElement.addEventListener("scroll", onScroll, options); 7983 return () => { 7984 scrollingElement.removeEventListener("wheel", onUserScroll, true); 7985 scrollingElement.removeEventListener("touchmove", onUserScroll, true); 7986 scrollingElement.removeEventListener("scroll", onScroll, true); 7987 }; 7988 }, [open, contentElement, store]); 7989 useSafeLayoutEffect(() => { 7990 if (!storeValue) return; 7991 if (composingRef.current) return; 7992 canAutoSelectRef.current = true; 7993 }, [storeValue]); 7994 useSafeLayoutEffect(() => { 7995 if (autoSelect !== "always" && open) return; 7996 canAutoSelectRef.current = open; 7997 }, [autoSelect, open]); 7998 const resetValueOnSelect = store.useState("resetValueOnSelect"); 7999 useUpdateEffect(() => { 8000 var _a2, _b2; 8001 const canAutoSelect = canAutoSelectRef.current; 8002 if (!store) return; 8003 if (!open) return; 8004 if (!canAutoSelect && !resetValueOnSelect) return; 8005 const { baseElement, contentElement: contentElement2, activeId } = store.getState(); 8006 if (baseElement && !hasFocus(baseElement)) return; 8007 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) { 8008 const observer = new MutationObserver(forceValueUpdate); 8009 observer.observe(contentElement2, { attributeFilter: ["data-placing"] }); 8010 return () => observer.disconnect(); 8011 } 8012 if (autoSelect && canAutoSelect) { 8013 const userAutoSelectId = getAutoSelectIdProp(items); 8014 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a2 = getDefaultAutoSelectId(items)) != null ? _a2 : store.first(); 8015 autoSelectIdRef.current = autoSelectId; 8016 store.move(autoSelectId != null ? autoSelectId : null); 8017 } else { 8018 const element = (_b2 = store.item(activeId || store.first())) == null ? void 0 : _b2.element; 8019 if (element && "scrollIntoView" in element) { 8020 element.scrollIntoView({ block: "nearest", inline: "nearest" }); 8021 } 8022 } 8023 return; 8024 }, [ 8025 store, 8026 open, 8027 valueUpdated, 8028 storeValue, 8029 autoSelect, 8030 resetValueOnSelect, 8031 getAutoSelectIdProp, 8032 items 8033 ]); 8034 (0, import_react11.useEffect)(() => { 8035 if (!inline) return; 8036 const combobox = ref.current; 8037 if (!combobox) return; 8038 const elements = [combobox, contentElement].filter( 8039 (value2) => !!value2 8040 ); 8041 const onBlur2 = (event) => { 8042 if (elements.every((el) => isFocusEventOutside(event, el))) { 8043 store == null ? void 0 : store.setValue(value); 8044 } 8045 }; 8046 for (const element of elements) { 8047 element.addEventListener("focusout", onBlur2); 8048 } 8049 return () => { 8050 for (const element of elements) { 8051 element.removeEventListener("focusout", onBlur2); 8052 } 8053 }; 8054 }, [inline, contentElement, store, value]); 8055 const canShow = (event) => { 8056 const currentTarget = event.currentTarget; 8057 return currentTarget.value.length >= showMinLength; 8058 }; 8059 const onChangeProp = props.onChange; 8060 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow); 8061 const setValueOnChangeProp = useBooleanEvent( 8062 // If the combobox is combined with tags, the value will be set by the tag 8063 // input component. 8064 setValueOnChange != null ? setValueOnChange : !store.tag 8065 ); 8066 const onChange = useEvent((event) => { 8067 onChangeProp == null ? void 0 : onChangeProp(event); 8068 if (event.defaultPrevented) return; 8069 if (!store) return; 8070 const currentTarget = event.currentTarget; 8071 const { value: value2, selectionStart, selectionEnd } = currentTarget; 8072 const nativeEvent = event.nativeEvent; 8073 canAutoSelectRef.current = true; 8074 if (isInputEvent(nativeEvent)) { 8075 if (nativeEvent.isComposing) { 8076 canAutoSelectRef.current = false; 8077 composingRef.current = true; 8078 } 8079 if (inline) { 8080 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText"; 8081 const caretAtEnd = selectionStart === value2.length; 8082 setCanInline(textInserted && caretAtEnd); 8083 } 8084 } 8085 if (setValueOnChangeProp(event)) { 8086 const isSameValue = value2 === store.getState().value; 8087 store.setValue(value2); 8088 queueMicrotask(() => { 8089 setSelectionRange(currentTarget, selectionStart, selectionEnd); 8090 }); 8091 if (inline && autoSelect && isSameValue) { 8092 forceValueUpdate(); 8093 } 8094 } 8095 if (showOnChangeProp(event)) { 8096 store.show(); 8097 } 8098 if (!autoSelect || !canAutoSelectRef.current) { 8099 store.setActiveId(null); 8100 } 8101 }); 8102 const onCompositionEndProp = props.onCompositionEnd; 8103 const onCompositionEnd = useEvent((event) => { 8104 canAutoSelectRef.current = true; 8105 composingRef.current = false; 8106 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event); 8107 if (event.defaultPrevented) return; 8108 if (!autoSelect) return; 8109 forceValueUpdate(); 8110 }); 8111 const onMouseDownProp = props.onMouseDown; 8112 const blurActiveItemOnClickProp = useBooleanEvent( 8113 blurActiveItemOnClick != null ? blurActiveItemOnClick : () => !!(store == null ? void 0 : store.getState().includesBaseElement) 8114 ); 8115 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 8116 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow); 8117 const onMouseDown = useEvent((event) => { 8118 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 8119 if (event.defaultPrevented) return; 8120 if (event.button) return; 8121 if (event.ctrlKey) return; 8122 if (!store) return; 8123 if (blurActiveItemOnClickProp(event)) { 8124 store.setActiveId(null); 8125 } 8126 if (setValueOnClickProp(event)) { 8127 store.setValue(value); 8128 } 8129 if (showOnClickProp(event)) { 8130 queueBeforeEvent(event.currentTarget, "mouseup", store.show); 8131 } 8132 }); 8133 const onKeyDownProp = props.onKeyDown; 8134 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow); 8135 const onKeyDown = useEvent((event) => { 8136 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 8137 if (!event.repeat) { 8138 canAutoSelectRef.current = false; 8139 } 8140 if (event.defaultPrevented) return; 8141 if (event.ctrlKey) return; 8142 if (event.altKey) return; 8143 if (event.shiftKey) return; 8144 if (event.metaKey) return; 8145 if (!store) return; 8146 const { open: open2 } = store.getState(); 8147 if (open2) return; 8148 if (event.key === "ArrowUp" || event.key === "ArrowDown") { 8149 if (showOnKeyPressProp(event)) { 8150 event.preventDefault(); 8151 store.show(); 8152 } 8153 } 8154 }); 8155 const onBlurProp = props.onBlur; 8156 const onBlur = useEvent((event) => { 8157 canAutoSelectRef.current = false; 8158 onBlurProp == null ? void 0 : onBlurProp(event); 8159 if (event.defaultPrevented) return; 8160 }); 8161 const id = useId3(props.id); 8162 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0; 8163 const isActiveItem = store.useState((state) => state.activeId === null); 8164 props = __spreadProps(__spreadValues({ 8165 id, 8166 role: "combobox", 8167 "aria-autocomplete": ariaAutoComplete, 8168 "aria-haspopup": getPopupRole(contentElement, "listbox"), 8169 "aria-expanded": open, 8170 "aria-controls": contentElement == null ? void 0 : contentElement.id, 8171 "data-active-item": isActiveItem || void 0, 8172 value 8173 }, props), { 8174 ref: useMergeRefs(ref, props.ref), 8175 onChange, 8176 onCompositionEnd, 8177 onMouseDown, 8178 onKeyDown, 8179 onBlur 8180 }); 8181 props = useComposite(__spreadProps(__spreadValues({ 8182 store, 8183 focusable 8184 }, props), { 8185 // Enable inline autocomplete when the user moves from the combobox input 8186 // to an item. 8187 moveOnKeyPress: (event) => { 8188 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false; 8189 if (inline) setCanInline(true); 8190 return true; 8191 } 8192 })); 8193 props = usePopoverAnchor(__spreadValues({ store }, props)); 8194 return __spreadValues({ autoComplete: "off" }, props); 8195 } 8196 ); 8197 var Combobox = forwardRef22(function Combobox2(props) { 8198 const htmlProps = useCombobox(props); 8199 return createElement2(TagName4, htmlProps); 8200 }); 8201 8202 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js 8203 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1); 8204 function ComboboxProvider(props = {}) { 8205 const store = useComboboxStore(props); 8206 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ComboboxContextProvider, { value: store, children: props.children }); 8207 } 8208 8209 // node_modules/@ariakit/react-core/esm/__chunks/KUU7WJ55.js 8210 var import_react12 = __toESM(require_react(), 1); 8211 var TagName5 = "button"; 8212 function isNativeClick(event) { 8213 if (!event.isTrusted) return false; 8214 const element = event.currentTarget; 8215 if (event.key === "Enter") { 8216 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A"; 8217 } 8218 if (event.key === " ") { 8219 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT"; 8220 } 8221 return false; 8222 } 8223 var symbol = Symbol("command"); 8224 var useCommand = createHook( 8225 function useCommand2(_a) { 8226 var _b = _a, { clickOnEnter = true, clickOnSpace = true } = _b, props = __objRest(_b, ["clickOnEnter", "clickOnSpace"]); 8227 const ref = (0, import_react12.useRef)(null); 8228 const [isNativeButton, setIsNativeButton] = (0, import_react12.useState)(false); 8229 (0, import_react12.useEffect)(() => { 8230 if (!ref.current) return; 8231 setIsNativeButton(isButton(ref.current)); 8232 }, []); 8233 const [active, setActive] = (0, import_react12.useState)(false); 8234 const activeRef = (0, import_react12.useRef)(false); 8235 const disabled = disabledFromProps(props); 8236 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true); 8237 const onKeyDownProp = props.onKeyDown; 8238 const onKeyDown = useEvent((event) => { 8239 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 8240 const element = event.currentTarget; 8241 if (event.defaultPrevented) return; 8242 if (isDuplicate) return; 8243 if (disabled) return; 8244 if (!isSelfTarget(event)) return; 8245 if (isTextField(element)) return; 8246 if (element.isContentEditable) return; 8247 const isEnter = clickOnEnter && event.key === "Enter"; 8248 const isSpace = clickOnSpace && event.key === " "; 8249 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter; 8250 const shouldPreventSpace = event.key === " " && !clickOnSpace; 8251 if (shouldPreventEnter || shouldPreventSpace) { 8252 event.preventDefault(); 8253 return; 8254 } 8255 if (isEnter || isSpace) { 8256 const nativeClick = isNativeClick(event); 8257 if (isEnter) { 8258 if (!nativeClick) { 8259 event.preventDefault(); 8260 const _a2 = event, { view } = _a2, eventInit = __objRest(_a2, ["view"]); 8261 const click = () => fireClickEvent(element, eventInit); 8262 if (isFirefox()) { 8263 queueBeforeEvent(element, "keyup", click); 8264 } else { 8265 queueMicrotask(click); 8266 } 8267 } 8268 } else if (isSpace) { 8269 activeRef.current = true; 8270 if (!nativeClick) { 8271 event.preventDefault(); 8272 setActive(true); 8273 } 8274 } 8275 } 8276 }); 8277 const onKeyUpProp = props.onKeyUp; 8278 const onKeyUp = useEvent((event) => { 8279 onKeyUpProp == null ? void 0 : onKeyUpProp(event); 8280 if (event.defaultPrevented) return; 8281 if (isDuplicate) return; 8282 if (disabled) return; 8283 if (event.metaKey) return; 8284 const isSpace = clickOnSpace && event.key === " "; 8285 if (activeRef.current && isSpace) { 8286 activeRef.current = false; 8287 if (!isNativeClick(event)) { 8288 event.preventDefault(); 8289 setActive(false); 8290 const element = event.currentTarget; 8291 const _a2 = event, { view } = _a2, eventInit = __objRest(_a2, ["view"]); 8292 queueMicrotask(() => fireClickEvent(element, eventInit)); 8293 } 8294 } 8295 }); 8296 props = __spreadProps(__spreadValues(__spreadValues({ 8297 "data-active": active || void 0, 8298 type: isNativeButton ? "button" : void 0 8299 }, metadataProps), props), { 8300 ref: useMergeRefs(ref, props.ref), 8301 onKeyDown, 8302 onKeyUp 8303 }); 8304 props = useFocusable(props); 8305 return props; 8306 } 8307 ); 8308 var Command = forwardRef22(function Command2(props) { 8309 const htmlProps = useCommand(props); 8310 return createElement2(TagName5, htmlProps); 8311 }); 8312 8313 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js 8314 var import_react13 = __toESM(require_react(), 1); 8315 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1); 8316 var TagName6 = "span"; 8317 function normalizeValue(value) { 8318 return normalizeString(value).toLowerCase(); 8319 } 8320 function getOffsets(string, values) { 8321 const offsets = []; 8322 for (const value of values) { 8323 let pos = 0; 8324 const length = value.length; 8325 while (string.indexOf(value, pos) !== -1) { 8326 const index = string.indexOf(value, pos); 8327 if (index !== -1) { 8328 offsets.push([index, length]); 8329 } 8330 pos = index + 1; 8331 } 8332 } 8333 return offsets; 8334 } 8335 function filterOverlappingOffsets(offsets) { 8336 return offsets.filter(([offset, length], i2, arr) => { 8337 return !arr.some( 8338 ([o2, l2], j2) => j2 !== i2 && o2 <= offset && o2 + l2 >= offset + length 8339 ); 8340 }); 8341 } 8342 function sortOffsets(offsets) { 8343 return offsets.sort(([a2], [b2]) => a2 - b2); 8344 } 8345 function splitValue(itemValue, userValue) { 8346 if (!itemValue) return itemValue; 8347 if (!userValue) return itemValue; 8348 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue); 8349 const parts = []; 8350 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 8351 "span", 8352 { 8353 "data-autocomplete-value": autocomplete ? "" : void 0, 8354 "data-user-value": autocomplete ? void 0 : "", 8355 children: value 8356 }, 8357 parts.length 8358 ); 8359 const offsets = sortOffsets( 8360 filterOverlappingOffsets( 8361 // Convert userValues into a set to avoid duplicates 8362 getOffsets(normalizeValue(itemValue), new Set(userValues)) 8363 ) 8364 ); 8365 if (!offsets.length) { 8366 parts.push(span(itemValue, true)); 8367 return parts; 8368 } 8369 const [firstOffset] = offsets[0]; 8370 const values = [ 8371 itemValue.slice(0, firstOffset), 8372 ...offsets.flatMap(([offset, length], i2) => { 8373 var _a; 8374 const value = itemValue.slice(offset, offset + length); 8375 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0]; 8376 const nextValue = itemValue.slice(offset + length, nextOffset); 8377 return [value, nextValue]; 8378 }) 8379 ]; 8380 values.forEach((value, i2) => { 8381 if (!value) return; 8382 parts.push(span(value, i2 % 2 === 0)); 8383 }); 8384 return parts; 8385 } 8386 var useComboboxItemValue = createHook(function useComboboxItemValue2(_a) { 8387 var _b = _a, { store, value, userValue } = _b, props = __objRest(_b, ["store", "value", "userValue"]); 8388 const context = useComboboxScopedContext(); 8389 store = store || context; 8390 const itemContext = (0, import_react13.useContext)(ComboboxItemValueContext); 8391 const itemValue = value != null ? value : itemContext; 8392 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value); 8393 const children = (0, import_react13.useMemo)(() => { 8394 if (!itemValue) return; 8395 if (!inputValue) return itemValue; 8396 return splitValue(itemValue, inputValue); 8397 }, [itemValue, inputValue]); 8398 props = __spreadValues({ 8399 children 8400 }, props); 8401 return removeUndefinedValues(props); 8402 }); 8403 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) { 8404 const htmlProps = useComboboxItemValue(props); 8405 return createElement2(TagName6, htmlProps); 8406 }); 8407 8408 // node_modules/@ariakit/react-core/esm/__chunks/UQQRIHDV.js 8409 var import_react14 = __toESM(require_react(), 1); 8410 var TagName7 = "div"; 8411 function getMouseDestination(event) { 8412 const relatedTarget = event.relatedTarget; 8413 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) { 8414 return relatedTarget; 8415 } 8416 return null; 8417 } 8418 function hoveringInside(event) { 8419 const nextElement = getMouseDestination(event); 8420 if (!nextElement) return false; 8421 return contains(event.currentTarget, nextElement); 8422 } 8423 var symbol2 = Symbol("composite-hover"); 8424 function movingToAnotherItem(event) { 8425 let dest = getMouseDestination(event); 8426 if (!dest) return false; 8427 do { 8428 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true; 8429 dest = dest.parentElement; 8430 } while (dest); 8431 return false; 8432 } 8433 var useCompositeHover = createHook( 8434 function useCompositeHover2(_a) { 8435 var _b = _a, { 8436 store, 8437 focusOnHover = true, 8438 blurOnHoverEnd = !!focusOnHover 8439 } = _b, props = __objRest(_b, [ 8440 "store", 8441 "focusOnHover", 8442 "blurOnHoverEnd" 8443 ]); 8444 const context = useCompositeContext(); 8445 store = store || context; 8446 invariant( 8447 store, 8448 "CompositeHover must be wrapped in a Composite component." 8449 ); 8450 const isMouseMoving = useIsMouseMoving(); 8451 const onMouseMoveProp = props.onMouseMove; 8452 const focusOnHoverProp = useBooleanEvent(focusOnHover); 8453 const onMouseMove = useEvent((event) => { 8454 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event); 8455 if (event.defaultPrevented) return; 8456 if (!isMouseMoving()) return; 8457 if (!focusOnHoverProp(event)) return; 8458 if (!hasFocusWithin(event.currentTarget)) { 8459 const baseElement = store == null ? void 0 : store.getState().baseElement; 8460 if (baseElement && !hasFocus(baseElement)) { 8461 baseElement.focus(); 8462 } 8463 } 8464 store == null ? void 0 : store.setActiveId(event.currentTarget.id); 8465 }); 8466 const onMouseLeaveProp = props.onMouseLeave; 8467 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd); 8468 const onMouseLeave = useEvent((event) => { 8469 var _a2; 8470 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event); 8471 if (event.defaultPrevented) return; 8472 if (!isMouseMoving()) return; 8473 if (hoveringInside(event)) return; 8474 if (movingToAnotherItem(event)) return; 8475 if (!focusOnHoverProp(event)) return; 8476 if (!blurOnHoverEndProp(event)) return; 8477 store == null ? void 0 : store.setActiveId(null); 8478 (_a2 = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a2.focus(); 8479 }); 8480 const ref = (0, import_react14.useCallback)((element) => { 8481 if (!element) return; 8482 element[symbol2] = true; 8483 }, []); 8484 props = __spreadProps(__spreadValues({}, props), { 8485 ref: useMergeRefs(ref, props.ref), 8486 onMouseMove, 8487 onMouseLeave 8488 }); 8489 return removeUndefinedValues(props); 8490 } 8491 ); 8492 var CompositeHover = memo22( 8493 forwardRef22(function CompositeHover2(props) { 8494 const htmlProps = useCompositeHover(props); 8495 return createElement2(TagName7, htmlProps); 8496 }) 8497 ); 8498 8499 // node_modules/@ariakit/react-core/esm/__chunks/RZ4GPYOB.js 8500 var import_react15 = __toESM(require_react(), 1); 8501 var TagName8 = "div"; 8502 var useCollectionItem = createHook( 8503 function useCollectionItem2(_a) { 8504 var _b = _a, { 8505 store, 8506 shouldRegisterItem = true, 8507 getItem = identity, 8508 element 8509 } = _b, props = __objRest(_b, [ 8510 "store", 8511 "shouldRegisterItem", 8512 "getItem", 8513 // @ts-expect-error This prop may come from a collection renderer. 8514 "element" 8515 ]); 8516 const context = useCollectionContext(); 8517 store = store || context; 8518 const id = useId3(props.id); 8519 const ref = (0, import_react15.useRef)(element); 8520 (0, import_react15.useEffect)(() => { 8521 const element2 = ref.current; 8522 if (!id) return; 8523 if (!element2) return; 8524 if (!shouldRegisterItem) return; 8525 const item = getItem({ id, element: element2 }); 8526 return store == null ? void 0 : store.renderItem(item); 8527 }, [id, shouldRegisterItem, getItem, store]); 8528 props = __spreadProps(__spreadValues({}, props), { 8529 ref: useMergeRefs(ref, props.ref) 8530 }); 8531 return removeUndefinedValues(props); 8532 } 8533 ); 8534 var CollectionItem = forwardRef22(function CollectionItem2(props) { 8535 const htmlProps = useCollectionItem(props); 8536 return createElement2(TagName8, htmlProps); 8537 }); 8538 8539 // node_modules/@ariakit/react-core/esm/__chunks/P2CTZE2T.js 8540 var import_react16 = __toESM(require_react(), 1); 8541 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1); 8542 var TagName9 = "button"; 8543 function isEditableElement(element) { 8544 if (isTextbox(element)) return true; 8545 return element.tagName === "INPUT" && !isButton(element); 8546 } 8547 function getNextPageOffset(scrollingElement, pageUp = false) { 8548 const height = scrollingElement.clientHeight; 8549 const { top } = scrollingElement.getBoundingClientRect(); 8550 const pageSize = Math.max(height * 0.875, height - 40) * 1.5; 8551 const pageOffset = pageUp ? height - pageSize + top : pageSize + top; 8552 if (scrollingElement.tagName === "HTML") { 8553 return pageOffset + scrollingElement.scrollTop; 8554 } 8555 return pageOffset; 8556 } 8557 function getItemOffset(itemElement, pageUp = false) { 8558 const { top } = itemElement.getBoundingClientRect(); 8559 if (pageUp) { 8560 return top + itemElement.clientHeight; 8561 } 8562 return top; 8563 } 8564 function findNextPageItemId(element, store, next, pageUp = false) { 8565 var _a; 8566 if (!store) return; 8567 if (!next) return; 8568 const { renderedItems } = store.getState(); 8569 const scrollingElement = getScrollingElement(element); 8570 if (!scrollingElement) return; 8571 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp); 8572 let id; 8573 let prevDifference; 8574 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) { 8575 const previousId = id; 8576 id = next(i2); 8577 if (!id) break; 8578 if (id === previousId) continue; 8579 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element; 8580 if (!itemElement) continue; 8581 const itemOffset = getItemOffset(itemElement, pageUp); 8582 const difference = itemOffset - nextPageOffset; 8583 const absDifference = Math.abs(difference); 8584 if (pageUp && difference <= 0 || !pageUp && difference >= 0) { 8585 if (prevDifference !== void 0 && prevDifference < absDifference) { 8586 id = previousId; 8587 } 8588 break; 8589 } 8590 prevDifference = absDifference; 8591 } 8592 return id; 8593 } 8594 function targetIsAnotherItem(event, store) { 8595 if (isSelfTarget(event)) return false; 8596 return isItem(store, event.target); 8597 } 8598 var useCompositeItem = createHook( 8599 function useCompositeItem2(_a) { 8600 var _b = _a, { 8601 store, 8602 rowId: rowIdProp, 8603 preventScrollOnKeyDown = false, 8604 moveOnKeyPress = true, 8605 tabbable = false, 8606 getItem: getItemProp, 8607 "aria-setsize": ariaSetSizeProp, 8608 "aria-posinset": ariaPosInSetProp 8609 } = _b, props = __objRest(_b, [ 8610 "store", 8611 "rowId", 8612 "preventScrollOnKeyDown", 8613 "moveOnKeyPress", 8614 "tabbable", 8615 "getItem", 8616 "aria-setsize", 8617 "aria-posinset" 8618 ]); 8619 const context = useCompositeContext(); 8620 store = store || context; 8621 const id = useId3(props.id); 8622 const ref = (0, import_react16.useRef)(null); 8623 const row = (0, import_react16.useContext)(CompositeRowContext); 8624 const disabled = disabledFromProps(props); 8625 const trulyDisabled = disabled && !props.accessibleWhenDisabled; 8626 const { 8627 rowId, 8628 baseElement, 8629 isActiveItem, 8630 ariaSetSize, 8631 ariaPosInSet, 8632 isTabbable 8633 } = useStoreStateObject(store, { 8634 rowId(state) { 8635 if (rowIdProp) return rowIdProp; 8636 if (!state) return; 8637 if (!(row == null ? void 0 : row.baseElement)) return; 8638 if (row.baseElement !== state.baseElement) return; 8639 return row.id; 8640 }, 8641 baseElement(state) { 8642 return (state == null ? void 0 : state.baseElement) || void 0; 8643 }, 8644 isActiveItem(state) { 8645 return !!state && state.activeId === id; 8646 }, 8647 ariaSetSize(state) { 8648 if (ariaSetSizeProp != null) return ariaSetSizeProp; 8649 if (!state) return; 8650 if (!(row == null ? void 0 : row.ariaSetSize)) return; 8651 if (row.baseElement !== state.baseElement) return; 8652 return row.ariaSetSize; 8653 }, 8654 ariaPosInSet(state) { 8655 if (ariaPosInSetProp != null) return ariaPosInSetProp; 8656 if (!state) return; 8657 if (!(row == null ? void 0 : row.ariaPosInSet)) return; 8658 if (row.baseElement !== state.baseElement) return; 8659 const itemsInRow = state.renderedItems.filter( 8660 (item) => item.rowId === rowId 8661 ); 8662 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id); 8663 }, 8664 isTabbable(state) { 8665 if (!(state == null ? void 0 : state.renderedItems.length)) return true; 8666 if (state.virtualFocus) return false; 8667 if (tabbable) return true; 8668 if (state.activeId === null) return false; 8669 const item = store == null ? void 0 : store.item(state.activeId); 8670 if (item == null ? void 0 : item.disabled) return true; 8671 if (!(item == null ? void 0 : item.element)) return true; 8672 return state.activeId === id; 8673 } 8674 }); 8675 const getItem = (0, import_react16.useCallback)( 8676 (item) => { 8677 var _a2; 8678 const nextItem = __spreadProps(__spreadValues({}, item), { 8679 id: id || item.id, 8680 rowId, 8681 disabled: !!trulyDisabled, 8682 children: (_a2 = item.element) == null ? void 0 : _a2.textContent 8683 }); 8684 if (getItemProp) { 8685 return getItemProp(nextItem); 8686 } 8687 return nextItem; 8688 }, 8689 [id, rowId, trulyDisabled, getItemProp] 8690 ); 8691 const onFocusProp = props.onFocus; 8692 const hasFocusedComposite = (0, import_react16.useRef)(false); 8693 const onFocus = useEvent((event) => { 8694 onFocusProp == null ? void 0 : onFocusProp(event); 8695 if (event.defaultPrevented) return; 8696 if (isPortalEvent(event)) return; 8697 if (!id) return; 8698 if (!store) return; 8699 if (targetIsAnotherItem(event, store)) return; 8700 const { virtualFocus, baseElement: baseElement2 } = store.getState(); 8701 store.setActiveId(id); 8702 if (isTextbox(event.currentTarget)) { 8703 selectTextField(event.currentTarget); 8704 } 8705 if (!virtualFocus) return; 8706 if (!isSelfTarget(event)) return; 8707 if (isEditableElement(event.currentTarget)) return; 8708 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return; 8709 if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) { 8710 event.currentTarget.scrollIntoView({ 8711 block: "nearest", 8712 inline: "nearest" 8713 }); 8714 } 8715 hasFocusedComposite.current = true; 8716 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget); 8717 if (fromComposite) { 8718 focusSilently(baseElement2); 8719 } else { 8720 baseElement2.focus(); 8721 } 8722 }); 8723 const onBlurCaptureProp = props.onBlurCapture; 8724 const onBlurCapture = useEvent((event) => { 8725 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 8726 if (event.defaultPrevented) return; 8727 const state = store == null ? void 0 : store.getState(); 8728 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) { 8729 hasFocusedComposite.current = false; 8730 event.preventDefault(); 8731 event.stopPropagation(); 8732 } 8733 }); 8734 const onKeyDownProp = props.onKeyDown; 8735 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown); 8736 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 8737 const onKeyDown = useEvent((event) => { 8738 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 8739 if (event.defaultPrevented) return; 8740 if (!isSelfTarget(event)) return; 8741 if (!store) return; 8742 const { currentTarget } = event; 8743 const state = store.getState(); 8744 const item = store.item(id); 8745 const isGrid2 = !!(item == null ? void 0 : item.rowId); 8746 const isVertical = state.orientation !== "horizontal"; 8747 const isHorizontal = state.orientation !== "vertical"; 8748 const canHomeEnd = () => { 8749 if (isGrid2) return true; 8750 if (isHorizontal) return true; 8751 if (!state.baseElement) return true; 8752 if (!isTextField(state.baseElement)) return true; 8753 return false; 8754 }; 8755 const keyMap = { 8756 ArrowUp: (isGrid2 || isVertical) && store.up, 8757 ArrowRight: (isGrid2 || isHorizontal) && store.next, 8758 ArrowDown: (isGrid2 || isVertical) && store.down, 8759 ArrowLeft: (isGrid2 || isHorizontal) && store.previous, 8760 Home: () => { 8761 if (!canHomeEnd()) return; 8762 if (!isGrid2 || event.ctrlKey) { 8763 return store == null ? void 0 : store.first(); 8764 } 8765 return store == null ? void 0 : store.previous(-1); 8766 }, 8767 End: () => { 8768 if (!canHomeEnd()) return; 8769 if (!isGrid2 || event.ctrlKey) { 8770 return store == null ? void 0 : store.last(); 8771 } 8772 return store == null ? void 0 : store.next(-1); 8773 }, 8774 PageUp: () => { 8775 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true); 8776 }, 8777 PageDown: () => { 8778 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down); 8779 } 8780 }; 8781 const action = keyMap[event.key]; 8782 if (action) { 8783 if (isTextbox(currentTarget)) { 8784 const selection = getTextboxSelection(currentTarget); 8785 const isLeft = isHorizontal && event.key === "ArrowLeft"; 8786 const isRight = isHorizontal && event.key === "ArrowRight"; 8787 const isUp = isVertical && event.key === "ArrowUp"; 8788 const isDown = isVertical && event.key === "ArrowDown"; 8789 if (isRight || isDown) { 8790 const { length: valueLength } = getTextboxValue(currentTarget); 8791 if (selection.end !== valueLength) return; 8792 } else if ((isLeft || isUp) && selection.start !== 0) return; 8793 } 8794 const nextId = action(); 8795 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) { 8796 if (!moveOnKeyPressProp(event)) return; 8797 event.preventDefault(); 8798 store.move(nextId); 8799 } 8800 } 8801 }); 8802 const providerValue = (0, import_react16.useMemo)( 8803 () => ({ id, baseElement }), 8804 [id, baseElement] 8805 ); 8806 props = useWrapElement( 8807 props, 8808 (element) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }), 8809 [providerValue] 8810 ); 8811 props = __spreadProps(__spreadValues({ 8812 id, 8813 "data-active-item": isActiveItem || void 0 8814 }, props), { 8815 ref: useMergeRefs(ref, props.ref), 8816 tabIndex: isTabbable ? props.tabIndex : -1, 8817 onFocus, 8818 onBlurCapture, 8819 onKeyDown 8820 }); 8821 props = useCommand(props); 8822 props = useCollectionItem(__spreadProps(__spreadValues({ 8823 store 8824 }, props), { 8825 getItem, 8826 shouldRegisterItem: id ? props.shouldRegisterItem : false 8827 })); 8828 return removeUndefinedValues(__spreadProps(__spreadValues({}, props), { 8829 "aria-setsize": ariaSetSize, 8830 "aria-posinset": ariaPosInSet 8831 })); 8832 } 8833 ); 8834 var CompositeItem = memo22( 8835 forwardRef22(function CompositeItem2(props) { 8836 const htmlProps = useCompositeItem(props); 8837 return createElement2(TagName9, htmlProps); 8838 }) 8839 ); 8840 8841 // node_modules/@ariakit/react-core/esm/__chunks/ZTDSJLD6.js 8842 var import_react17 = __toESM(require_react(), 1); 8843 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1); 8844 var TagName10 = "div"; 8845 function isSelected(storeValue, itemValue) { 8846 if (itemValue == null) return; 8847 if (storeValue == null) return false; 8848 if (Array.isArray(storeValue)) { 8849 return storeValue.includes(itemValue); 8850 } 8851 return storeValue === itemValue; 8852 } 8853 function getItemRole(popupRole) { 8854 var _a; 8855 const itemRoleByPopupRole = { 8856 menu: "menuitem", 8857 listbox: "option", 8858 tree: "treeitem" 8859 }; 8860 const key = popupRole; 8861 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option"; 8862 } 8863 var useComboboxItem = createHook( 8864 function useComboboxItem2(_a) { 8865 var _b = _a, { 8866 store, 8867 value, 8868 hideOnClick, 8869 setValueOnClick, 8870 selectValueOnClick = true, 8871 resetValueOnSelect, 8872 focusOnHover = false, 8873 moveOnKeyPress = true, 8874 getItem: getItemProp 8875 } = _b, props = __objRest(_b, [ 8876 "store", 8877 "value", 8878 "hideOnClick", 8879 "setValueOnClick", 8880 "selectValueOnClick", 8881 "resetValueOnSelect", 8882 "focusOnHover", 8883 "moveOnKeyPress", 8884 "getItem" 8885 ]); 8886 var _a2; 8887 const context = useComboboxScopedContext(); 8888 store = store || context; 8889 invariant( 8890 store, 8891 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component." 8892 ); 8893 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, { 8894 resetValueOnSelectState: "resetValueOnSelect", 8895 multiSelectable(state) { 8896 return Array.isArray(state.selectedValue); 8897 }, 8898 selected(state) { 8899 return isSelected(state.selectedValue, value); 8900 } 8901 }); 8902 const getItem = (0, import_react17.useCallback)( 8903 (item) => { 8904 const nextItem = __spreadProps(__spreadValues({}, item), { value }); 8905 if (getItemProp) { 8906 return getItemProp(nextItem); 8907 } 8908 return nextItem; 8909 }, 8910 [value, getItemProp] 8911 ); 8912 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable; 8913 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable; 8914 const onClickProp = props.onClick; 8915 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 8916 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick); 8917 const resetValueOnSelectProp = useBooleanEvent( 8918 (_a2 = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a2 : multiSelectable 8919 ); 8920 const hideOnClickProp = useBooleanEvent(hideOnClick); 8921 const onClick = useEvent((event) => { 8922 onClickProp == null ? void 0 : onClickProp(event); 8923 if (event.defaultPrevented) return; 8924 if (isDownloading(event)) return; 8925 if (isOpeningInNewTab(event)) return; 8926 if (value != null) { 8927 if (selectValueOnClickProp(event)) { 8928 if (resetValueOnSelectProp(event)) { 8929 store == null ? void 0 : store.resetValue(); 8930 } 8931 store == null ? void 0 : store.setSelectedValue((prevValue) => { 8932 if (!Array.isArray(prevValue)) return value; 8933 if (prevValue.includes(value)) { 8934 return prevValue.filter((v2) => v2 !== value); 8935 } 8936 return [...prevValue, value]; 8937 }); 8938 } 8939 if (setValueOnClickProp(event)) { 8940 store == null ? void 0 : store.setValue(value); 8941 } 8942 } 8943 if (hideOnClickProp(event)) { 8944 store == null ? void 0 : store.hide(); 8945 } 8946 }); 8947 const onKeyDownProp = props.onKeyDown; 8948 const onKeyDown = useEvent((event) => { 8949 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 8950 if (event.defaultPrevented) return; 8951 const baseElement = store == null ? void 0 : store.getState().baseElement; 8952 if (!baseElement) return; 8953 if (hasFocus(baseElement)) return; 8954 const printable = event.key.length === 1; 8955 if (printable || event.key === "Backspace" || event.key === "Delete") { 8956 queueMicrotask(() => baseElement.focus()); 8957 if (isTextField(baseElement)) { 8958 store == null ? void 0 : store.setValue(baseElement.value); 8959 } 8960 } 8961 }); 8962 if (multiSelectable && selected != null) { 8963 props = __spreadValues({ 8964 "aria-selected": selected 8965 }, props); 8966 } 8967 props = useWrapElement( 8968 props, 8969 (element) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }), 8970 [value, selected] 8971 ); 8972 const popupRole = (0, import_react17.useContext)(ComboboxListRoleContext); 8973 props = __spreadProps(__spreadValues({ 8974 role: getItemRole(popupRole), 8975 children: value 8976 }, props), { 8977 onClick, 8978 onKeyDown 8979 }); 8980 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 8981 props = useCompositeItem(__spreadProps(__spreadValues({ 8982 store 8983 }, props), { 8984 getItem, 8985 // Dispatch a custom event on the combobox input when moving to an item 8986 // with the keyboard so the Combobox component can enable inline 8987 // autocompletion. 8988 moveOnKeyPress: (event) => { 8989 if (!moveOnKeyPressProp(event)) return false; 8990 const moveEvent = new Event("combobox-item-move"); 8991 const baseElement = store == null ? void 0 : store.getState().baseElement; 8992 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent); 8993 return true; 8994 } 8995 })); 8996 props = useCompositeHover(__spreadValues({ store, focusOnHover }, props)); 8997 return props; 8998 } 8999 ); 9000 var ComboboxItem = memo22( 9001 forwardRef22(function ComboboxItem2(props) { 9002 const htmlProps = useComboboxItem(props); 9003 return createElement2(TagName10, htmlProps); 9004 }) 9005 ); 9006 9007 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js 9008 var TagName11 = "label"; 9009 var useComboboxLabel = createHook( 9010 function useComboboxLabel2(_a) { 9011 var _b = _a, { store } = _b, props = __objRest(_b, ["store"]); 9012 const context = useComboboxProviderContext(); 9013 store = store || context; 9014 invariant( 9015 store, 9016 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component." 9017 ); 9018 const comboboxId = store.useState((state) => { 9019 var _a2; 9020 return (_a2 = state.baseElement) == null ? void 0 : _a2.id; 9021 }); 9022 props = __spreadValues({ 9023 htmlFor: comboboxId 9024 }, props); 9025 return removeUndefinedValues(props); 9026 } 9027 ); 9028 var ComboboxLabel = memo22( 9029 forwardRef22(function ComboboxLabel2(props) { 9030 const htmlProps = useComboboxLabel(props); 9031 return createElement2(TagName11, htmlProps); 9032 }) 9033 ); 9034 9035 // node_modules/@ariakit/react-core/esm/__chunks/VGCJ63VH.js 9036 var import_react18 = __toESM(require_react(), 1); 9037 var import_react_dom = __toESM(require_react_dom(), 1); 9038 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1); 9039 var TagName12 = "div"; 9040 function afterTimeout(timeoutMs, cb) { 9041 const timeoutId = setTimeout(cb, timeoutMs); 9042 return () => clearTimeout(timeoutId); 9043 } 9044 function afterPaint2(cb) { 9045 let raf = requestAnimationFrame(() => { 9046 raf = requestAnimationFrame(cb); 9047 }); 9048 return () => cancelAnimationFrame(raf); 9049 } 9050 function parseCSSTime(...times) { 9051 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => { 9052 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3; 9053 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier; 9054 if (currentTime > longestTime) return currentTime; 9055 return longestTime; 9056 }, 0); 9057 } 9058 function isHidden(mounted, hidden, alwaysVisible) { 9059 return !alwaysVisible && hidden !== false && (!mounted || !!hidden); 9060 } 9061 var useDisclosureContent = createHook(function useDisclosureContent2(_a) { 9062 var _b = _a, { store, alwaysVisible } = _b, props = __objRest(_b, ["store", "alwaysVisible"]); 9063 const context = useDisclosureProviderContext(); 9064 store = store || context; 9065 invariant( 9066 store, 9067 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component." 9068 ); 9069 const ref = (0, import_react18.useRef)(null); 9070 const id = useId3(props.id); 9071 const [transition, setTransition] = (0, import_react18.useState)(null); 9072 const open = store.useState("open"); 9073 const mounted = store.useState("mounted"); 9074 const animated = store.useState("animated"); 9075 const contentElement = store.useState("contentElement"); 9076 const otherElement = useStoreState(store.disclosure, "contentElement"); 9077 useSafeLayoutEffect(() => { 9078 if (!ref.current) return; 9079 store == null ? void 0 : store.setContentElement(ref.current); 9080 }, [store]); 9081 useSafeLayoutEffect(() => { 9082 let previousAnimated; 9083 store == null ? void 0 : store.setState("animated", (animated2) => { 9084 previousAnimated = animated2; 9085 return true; 9086 }); 9087 return () => { 9088 if (previousAnimated === void 0) return; 9089 store == null ? void 0 : store.setState("animated", previousAnimated); 9090 }; 9091 }, [store]); 9092 useSafeLayoutEffect(() => { 9093 if (!animated) return; 9094 if (!(contentElement == null ? void 0 : contentElement.isConnected)) { 9095 setTransition(null); 9096 return; 9097 } 9098 return afterPaint2(() => { 9099 setTransition(open ? "enter" : mounted ? "leave" : null); 9100 }); 9101 }, [animated, contentElement, open, mounted]); 9102 useSafeLayoutEffect(() => { 9103 if (!store) return; 9104 if (!animated) return; 9105 if (!transition) return; 9106 if (!contentElement) return; 9107 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false); 9108 const stopAnimationSync = () => (0, import_react_dom.flushSync)(stopAnimation); 9109 if (transition === "leave" && open) return; 9110 if (transition === "enter" && !open) return; 9111 if (typeof animated === "number") { 9112 const timeout2 = animated; 9113 return afterTimeout(timeout2, stopAnimationSync); 9114 } 9115 const { 9116 transitionDuration, 9117 animationDuration, 9118 transitionDelay, 9119 animationDelay 9120 } = getComputedStyle(contentElement); 9121 const { 9122 transitionDuration: transitionDuration2 = "0", 9123 animationDuration: animationDuration2 = "0", 9124 transitionDelay: transitionDelay2 = "0", 9125 animationDelay: animationDelay2 = "0" 9126 } = otherElement ? getComputedStyle(otherElement) : {}; 9127 const delay = parseCSSTime( 9128 transitionDelay, 9129 animationDelay, 9130 transitionDelay2, 9131 animationDelay2 9132 ); 9133 const duration = parseCSSTime( 9134 transitionDuration, 9135 animationDuration, 9136 transitionDuration2, 9137 animationDuration2 9138 ); 9139 const timeout = delay + duration; 9140 if (!timeout) { 9141 if (transition === "enter") { 9142 store.setState("animated", false); 9143 } 9144 stopAnimation(); 9145 return; 9146 } 9147 const frameRate = 1e3 / 60; 9148 const maxTimeout = Math.max(timeout - frameRate, 0); 9149 return afterTimeout(maxTimeout, stopAnimationSync); 9150 }, [store, animated, contentElement, otherElement, open, transition]); 9151 props = useWrapElement( 9152 props, 9153 (element) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(DialogScopedContextProvider, { value: store, children: element }), 9154 [store] 9155 ); 9156 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 9157 const styleProp = props.style; 9158 const style = (0, import_react18.useMemo)(() => { 9159 if (hidden) { 9160 return __spreadProps(__spreadValues({}, styleProp), { display: "none" }); 9161 } 9162 return styleProp; 9163 }, [hidden, styleProp]); 9164 props = __spreadProps(__spreadValues({ 9165 id, 9166 "data-open": open || void 0, 9167 "data-enter": transition === "enter" || void 0, 9168 "data-leave": transition === "leave" || void 0, 9169 hidden 9170 }, props), { 9171 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref), 9172 style 9173 }); 9174 return removeUndefinedValues(props); 9175 }); 9176 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) { 9177 const htmlProps = useDisclosureContent(props); 9178 return createElement2(TagName12, htmlProps); 9179 }); 9180 var DisclosureContent = forwardRef22(function DisclosureContent2(_a) { 9181 var _b = _a, { 9182 unmountOnHide 9183 } = _b, props = __objRest(_b, [ 9184 "unmountOnHide" 9185 ]); 9186 const context = useDisclosureProviderContext(); 9187 const store = props.store || context; 9188 const mounted = useStoreState( 9189 store, 9190 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted) 9191 ); 9192 if (mounted === false) return null; 9193 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(DisclosureContentImpl, __spreadValues({}, props)); 9194 }); 9195 9196 // node_modules/@ariakit/react-core/esm/__chunks/HUWAI7RB.js 9197 var import_react19 = __toESM(require_react(), 1); 9198 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1); 9199 var TagName13 = "div"; 9200 var useComboboxList = createHook( 9201 function useComboboxList2(_a) { 9202 var _b = _a, { store, alwaysVisible } = _b, props = __objRest(_b, ["store", "alwaysVisible"]); 9203 const scopedContext = useComboboxScopedContext(true); 9204 const context = useComboboxContext(); 9205 store = store || context; 9206 const scopedContextSameStore = !!store && store === scopedContext; 9207 invariant( 9208 store, 9209 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component." 9210 ); 9211 const ref = (0, import_react19.useRef)(null); 9212 const id = useId3(props.id); 9213 const mounted = store.useState("mounted"); 9214 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 9215 const style = hidden ? __spreadProps(__spreadValues({}, props.style), { display: "none" }) : props.style; 9216 const multiSelectable = store.useState( 9217 (state) => Array.isArray(state.selectedValue) 9218 ); 9219 const role = useAttribute(ref, "role", props.role); 9220 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid"; 9221 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0; 9222 const [hasListboxInside, setHasListboxInside] = (0, import_react19.useState)(false); 9223 const contentElement = store.useState("contentElement"); 9224 useSafeLayoutEffect(() => { 9225 if (!mounted) return; 9226 const element = ref.current; 9227 if (!element) return; 9228 if (contentElement !== element) return; 9229 const callback = () => { 9230 setHasListboxInside(!!element.querySelector("[role='listbox']")); 9231 }; 9232 const observer = new MutationObserver(callback); 9233 observer.observe(element, { 9234 subtree: true, 9235 childList: true, 9236 attributeFilter: ["role"] 9237 }); 9238 callback(); 9239 return () => observer.disconnect(); 9240 }, [mounted, contentElement]); 9241 if (!hasListboxInside) { 9242 props = __spreadValues({ 9243 role: "listbox", 9244 "aria-multiselectable": ariaMultiSelectable 9245 }, props); 9246 } 9247 props = useWrapElement( 9248 props, 9249 (element) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }), 9250 [store, role] 9251 ); 9252 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null; 9253 props = __spreadProps(__spreadValues({ 9254 id, 9255 hidden 9256 }, props), { 9257 ref: useMergeRefs(setContentElement, ref, props.ref), 9258 style 9259 }); 9260 return removeUndefinedValues(props); 9261 } 9262 ); 9263 var ComboboxList = forwardRef22(function ComboboxList2(props) { 9264 const htmlProps = useComboboxList(props); 9265 return createElement2(TagName13, htmlProps); 9266 }); 9267 9268 // packages/dataviews/build-module/components/dataviews-filters/search-widget.js 9269 var import_remove_accents = __toESM(require_remove_accents()); 9270 var import_compose7 = __toESM(require_compose()); 9271 var import_i18n21 = __toESM(require_i18n()); 9272 var import_element23 = __toESM(require_element()); 9273 var import_components21 = __toESM(require_components()); 9274 9275 // packages/dataviews/build-module/components/dataviews-filters/utils.js 9276 var EMPTY_ARRAY2 = []; 9277 var getCurrentValue = (filterDefinition, currentFilter) => { 9278 if (filterDefinition.singleSelection) { 9279 return currentFilter?.value; 9280 } 9281 if (Array.isArray(currentFilter?.value)) { 9282 return currentFilter.value; 9283 } 9284 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) { 9285 return [currentFilter.value]; 9286 } 9287 return EMPTY_ARRAY2; 9288 }; 9289 9290 // packages/dataviews/build-module/hooks/use-elements.js 9291 var import_element22 = __toESM(require_element()); 9292 var EMPTY_ARRAY3 = []; 9293 function useElements({ 9294 elements, 9295 getElements 9296 }) { 9297 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY3; 9298 const [records, setRecords] = (0, import_element22.useState)(staticElements); 9299 const [isLoading, setIsLoading] = (0, import_element22.useState)(false); 9300 (0, import_element22.useEffect)(() => { 9301 if (!getElements) { 9302 setRecords(staticElements); 9303 return; 9304 } 9305 let cancelled = false; 9306 setIsLoading(true); 9307 getElements().then((fetchedElements) => { 9308 if (!cancelled) { 9309 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements; 9310 setRecords(dynamicElements); 9311 } 9312 }).catch(() => { 9313 if (!cancelled) { 9314 setRecords(staticElements); 9315 } 9316 }).finally(() => { 9317 if (!cancelled) { 9318 setIsLoading(false); 9319 } 9320 }); 9321 return () => { 9322 cancelled = true; 9323 }; 9324 }, [getElements, staticElements]); 9325 return { 9326 elements: records, 9327 isLoading 9328 }; 9329 } 9330 9331 // packages/dataviews/build-module/components/dataviews-filters/search-widget.js 9332 var import_jsx_runtime59 = __toESM(require_jsx_runtime()); 9333 function normalizeSearchInput(input = "") { 9334 return (0, import_remove_accents.default)(input.trim().toLowerCase()); 9335 } 9336 var getNewValue = (filterDefinition, currentFilter, value) => { 9337 if (filterDefinition.singleSelection) { 9338 return value; 9339 } 9340 if (Array.isArray(currentFilter?.value)) { 9341 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value]; 9342 } 9343 return [value]; 9344 }; 9345 function generateFilterElementCompositeItemId(prefix, filterElementValue) { 9346 return `$prefix}-$filterElementValue}`; 9347 } 9348 var MultiSelectionOption = ({ selected }) => { 9349 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9350 "span", 9351 { 9352 className: clsx_default( 9353 "dataviews-filters__search-widget-listitem-multi-selection", 9354 { "is-selected": selected } 9355 ), 9356 children: selected && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components21.Icon, { icon: check_default }) 9357 } 9358 ); 9359 }; 9360 var SingleSelectionOption = ({ selected }) => { 9361 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9362 "span", 9363 { 9364 className: clsx_default( 9365 "dataviews-filters__search-widget-listitem-single-selection", 9366 { "is-selected": selected } 9367 ) 9368 } 9369 ); 9370 }; 9371 function ListBox({ view, filter, onChangeView }) { 9372 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box"); 9373 const [activeCompositeId, setActiveCompositeId] = (0, import_element23.useState)( 9374 // When there are one or less operators, the first item is set as active 9375 // (by setting the initial `activeId` to `undefined`). 9376 // With 2 or more operators, the focus is moved on the operators control 9377 // (by setting the initial `activeId` to `null`), meaning that there won't 9378 // be an active item initially. Focus is then managed via the 9379 // `onFocusVisible` callback. 9380 filter.operators?.length === 1 ? void 0 : null 9381 ); 9382 const currentFilter = view.filters?.find( 9383 (f2) => f2.field === filter.field 9384 ); 9385 const currentValue = getCurrentValue(filter, currentFilter); 9386 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9387 import_components21.Composite, 9388 { 9389 virtualFocus: true, 9390 focusLoop: true, 9391 activeId: activeCompositeId, 9392 setActiveId: setActiveCompositeId, 9393 role: "listbox", 9394 className: "dataviews-filters__search-widget-listbox", 9395 "aria-label": (0, import_i18n21.sprintf)( 9396 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */ 9397 (0, import_i18n21.__)("List of: %1$s"), 9398 filter.name 9399 ), 9400 onFocusVisible: () => { 9401 if (!activeCompositeId && filter.elements.length) { 9402 setActiveCompositeId( 9403 generateFilterElementCompositeItemId( 9404 baseId, 9405 filter.elements[0].value 9406 ) 9407 ); 9408 } 9409 }, 9410 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components21.Composite.Typeahead, {}), 9411 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 9412 import_components21.Composite.Hover, 9413 { 9414 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9415 import_components21.Composite.Item, 9416 { 9417 id: generateFilterElementCompositeItemId( 9418 baseId, 9419 element.value 9420 ), 9421 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9422 "div", 9423 { 9424 "aria-label": element.label, 9425 role: "option", 9426 className: "dataviews-filters__search-widget-listitem" 9427 } 9428 ), 9429 onClick: () => { 9430 const newFilters = currentFilter ? [ 9431 ...(view.filters ?? []).map( 9432 (_filter) => { 9433 if (_filter.field === filter.field) { 9434 return { 9435 ..._filter, 9436 operator: currentFilter.operator || filter.operators[0], 9437 value: getNewValue( 9438 filter, 9439 currentFilter, 9440 element.value 9441 ) 9442 }; 9443 } 9444 return _filter; 9445 } 9446 ) 9447 ] : [ 9448 ...view.filters ?? [], 9449 { 9450 field: filter.field, 9451 operator: filter.operators[0], 9452 value: getNewValue( 9453 filter, 9454 currentFilter, 9455 element.value 9456 ) 9457 } 9458 ]; 9459 onChangeView({ 9460 ...view, 9461 page: 1, 9462 filters: newFilters 9463 }); 9464 } 9465 } 9466 ), 9467 children: [ 9468 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9469 SingleSelectionOption, 9470 { 9471 selected: currentValue === element.value 9472 } 9473 ), 9474 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9475 MultiSelectionOption, 9476 { 9477 selected: currentValue.includes(element.value) 9478 } 9479 ), 9480 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { children: element.label }) 9481 ] 9482 }, 9483 element.value 9484 )) 9485 } 9486 ); 9487 } 9488 function ComboboxList22({ view, filter, onChangeView }) { 9489 const [searchValue, setSearchValue] = (0, import_element23.useState)(""); 9490 const deferredSearchValue = (0, import_element23.useDeferredValue)(searchValue); 9491 const currentFilter = view.filters?.find( 9492 (_filter) => _filter.field === filter.field 9493 ); 9494 const currentValue = getCurrentValue(filter, currentFilter); 9495 const matches = (0, import_element23.useMemo)(() => { 9496 const normalizedSearch = normalizeSearchInput(deferredSearchValue); 9497 return filter.elements.filter( 9498 (item) => normalizeSearchInput(item.label).includes(normalizedSearch) 9499 ); 9500 }, [filter.elements, deferredSearchValue]); 9501 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 9502 ComboboxProvider, 9503 { 9504 selectedValue: currentValue, 9505 setSelectedValue: (value) => { 9506 const newFilters = currentFilter ? [ 9507 ...(view.filters ?? []).map((_filter) => { 9508 if (_filter.field === filter.field) { 9509 return { 9510 ..._filter, 9511 operator: currentFilter.operator || filter.operators[0], 9512 value 9513 }; 9514 } 9515 return _filter; 9516 }) 9517 ] : [ 9518 ...view.filters ?? [], 9519 { 9520 field: filter.field, 9521 operator: filter.operators[0], 9522 value 9523 } 9524 ]; 9525 onChangeView({ 9526 ...view, 9527 page: 1, 9528 filters: newFilters 9529 }); 9530 }, 9531 setValue: setSearchValue, 9532 children: [ 9533 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [ 9534 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9535 ComboboxLabel, 9536 { 9537 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components21.VisuallyHidden, { children: (0, import_i18n21.__)("Search items") }), 9538 children: (0, import_i18n21.__)("Search items") 9539 } 9540 ), 9541 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9542 Combobox, 9543 { 9544 autoSelect: "always", 9545 placeholder: (0, import_i18n21.__)("Search"), 9546 className: "dataviews-filters__search-widget-filter-combobox__input" 9547 } 9548 ), 9549 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components21.Icon, { icon: search_default }) }) 9550 ] }), 9551 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 9552 ComboboxList, 9553 { 9554 className: "dataviews-filters__search-widget-filter-combobox-list", 9555 alwaysVisible: true, 9556 children: [ 9557 matches.map((element) => { 9558 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 9559 ComboboxItem, 9560 { 9561 resetValueOnSelect: false, 9562 value: element.value, 9563 className: "dataviews-filters__search-widget-listitem", 9564 hideOnClick: false, 9565 setValueOnClick: false, 9566 focusOnHover: true, 9567 children: [ 9568 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9569 SingleSelectionOption, 9570 { 9571 selected: currentValue === element.value 9572 } 9573 ), 9574 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9575 MultiSelectionOption, 9576 { 9577 selected: currentValue.includes( 9578 element.value 9579 ) 9580 } 9581 ), 9582 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("span", { children: [ 9583 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 9584 ComboboxItemValue, 9585 { 9586 className: "dataviews-filters__search-widget-filter-combobox-item-value", 9587 value: element.label 9588 } 9589 ), 9590 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description }) 9591 ] }) 9592 ] 9593 }, 9594 element.value 9595 ); 9596 }), 9597 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: (0, import_i18n21.__)("No results found") }) 9598 ] 9599 } 9600 ) 9601 ] 9602 } 9603 ); 9604 } 9605 function SearchWidget(props) { 9606 const { elements, isLoading } = useElements({ 9607 elements: props.filter.elements, 9608 getElements: props.filter.getElements 9609 }); 9610 if (isLoading) { 9611 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components21.Spinner, {}) }); 9612 } 9613 if (elements.length === 0) { 9614 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n21.__)("No elements found") }); 9615 } 9616 const Widget = elements.length > 10 ? ComboboxList22 : ListBox; 9617 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Widget, { ...props, filter: { ...props.filter, elements } }); 9618 } 9619 9620 // packages/dataviews/build-module/components/dataviews-filters/input-widget.js 9621 var import_es6 = __toESM(require_es6()); 9622 var import_compose8 = __toESM(require_compose()); 9623 var import_element24 = __toESM(require_element()); 9624 var import_components22 = __toESM(require_components()); 9625 var import_jsx_runtime60 = __toESM(require_jsx_runtime()); 9626 function InputWidget({ 9627 filter, 9628 view, 9629 onChangeView, 9630 fields 9631 }) { 9632 const currentFilter = view.filters?.find( 9633 (f2) => f2.field === filter.field 9634 ); 9635 const currentValue = getCurrentValue(filter, currentFilter); 9636 const field = (0, import_element24.useMemo)(() => { 9637 const currentField = fields.find((f2) => f2.id === filter.field); 9638 if (currentField) { 9639 return { 9640 ...currentField, 9641 // Deactivate validation for filters. 9642 isValid: {}, 9643 // Configure getValue/setValue as if Item was a plain object. 9644 getValue: ({ item }) => item[currentField.id], 9645 setValue: ({ value }) => ({ 9646 [currentField.id]: value 9647 }) 9648 }; 9649 } 9650 return currentField; 9651 }, [fields, filter.field]); 9652 const data = (0, import_element24.useMemo)(() => { 9653 return (view.filters ?? []).reduce( 9654 (acc, activeFilter) => { 9655 acc[activeFilter.field] = activeFilter.value; 9656 return acc; 9657 }, 9658 {} 9659 ); 9660 }, [view.filters]); 9661 const handleChange = (0, import_compose8.useEvent)((updatedData) => { 9662 if (!field || !currentFilter) { 9663 return; 9664 } 9665 const nextValue = field.getValue({ item: updatedData }); 9666 if ((0, import_es6.default)(nextValue, currentValue)) { 9667 return; 9668 } 9669 onChangeView({ 9670 ...view, 9671 filters: (view.filters ?? []).map( 9672 (_filter) => _filter.field === filter.field ? { 9673 ..._filter, 9674 operator: currentFilter.operator || filter.operators[0], 9675 // Consider empty strings as undefined: 9676 // 9677 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records 9678 // - empty string as value means "search empty string": returns only the records that have an empty string as value 9679 // 9680 // In practice, this means the filter will not be able to find an empty string as the value. 9681 value: nextValue === "" ? void 0 : nextValue 9682 } : _filter 9683 ) 9684 }); 9685 }); 9686 if (!field || !field.Edit || !currentFilter) { 9687 return null; 9688 } 9689 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 9690 import_components22.Flex, 9691 { 9692 className: "dataviews-filters__user-input-widget", 9693 gap: 2.5, 9694 direction: "column", 9695 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 9696 field.Edit, 9697 { 9698 hideLabelFromVision: true, 9699 data, 9700 field, 9701 operator: currentFilter.operator, 9702 onChange: handleChange 9703 } 9704 ) 9705 } 9706 ); 9707 } 9708 9709 // packages/dataviews/build-module/utils/operators.js 9710 var import_i18n22 = __toESM(require_i18n()); 9711 var import_element25 = __toESM(require_element()); 9712 var import_jsx_runtime61 = __toESM(require_jsx_runtime()); 9713 var filterTextWrappers = { 9714 Name: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }), 9715 Value: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" }) 9716 }; 9717 var OPERATORS = [ 9718 { 9719 name: OPERATOR_IS_ANY, 9720 /* translators: DataViews operator name */ 9721 label: (0, import_i18n22.__)("Includes"), 9722 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9723 (0, import_i18n22.sprintf)( 9724 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */ 9725 (0, import_i18n22.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"), 9726 filter.name, 9727 activeElements.map((element) => element.label).join(", ") 9728 ), 9729 filterTextWrappers 9730 ), 9731 selection: "multi" 9732 }, 9733 { 9734 name: OPERATOR_IS_NONE, 9735 /* translators: DataViews operator name */ 9736 label: (0, import_i18n22.__)("Is none of"), 9737 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9738 (0, import_i18n22.sprintf)( 9739 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 9740 (0, import_i18n22.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 9741 filter.name, 9742 activeElements.map((element) => element.label).join(", ") 9743 ), 9744 filterTextWrappers 9745 ), 9746 selection: "multi" 9747 }, 9748 { 9749 name: OPERATOR_IS_ALL, 9750 /* translators: DataViews operator name */ 9751 label: (0, import_i18n22.__)("Includes all"), 9752 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9753 (0, import_i18n22.sprintf)( 9754 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */ 9755 (0, import_i18n22.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"), 9756 filter.name, 9757 activeElements.map((element) => element.label).join(", ") 9758 ), 9759 filterTextWrappers 9760 ), 9761 selection: "multi" 9762 }, 9763 { 9764 name: OPERATOR_IS_NOT_ALL, 9765 /* translators: DataViews operator name */ 9766 label: (0, import_i18n22.__)("Is none of"), 9767 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9768 (0, import_i18n22.sprintf)( 9769 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 9770 (0, import_i18n22.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 9771 filter.name, 9772 activeElements.map((element) => element.label).join(", ") 9773 ), 9774 filterTextWrappers 9775 ), 9776 selection: "multi" 9777 }, 9778 { 9779 name: OPERATOR_BETWEEN, 9780 /* translators: DataViews operator name */ 9781 label: (0, import_i18n22.__)("Between (inc)"), 9782 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9783 (0, import_i18n22.sprintf)( 9784 /* 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". */ 9785 (0, import_i18n22.__)( 9786 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>" 9787 ), 9788 filter.name, 9789 activeElements[0].label[0], 9790 activeElements[0].label[1] 9791 ), 9792 filterTextWrappers 9793 ), 9794 selection: "custom" 9795 }, 9796 { 9797 name: OPERATOR_IN_THE_PAST, 9798 /* translators: DataViews operator name */ 9799 label: (0, import_i18n22.__)("In the past"), 9800 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9801 (0, import_i18n22.sprintf)( 9802 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */ 9803 (0, import_i18n22.__)( 9804 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>" 9805 ), 9806 filter.name, 9807 `$activeElements[0].value.value} $activeElements[0].value.unit}` 9808 ), 9809 filterTextWrappers 9810 ), 9811 selection: "custom" 9812 }, 9813 { 9814 name: OPERATOR_OVER, 9815 /* translators: DataViews operator name */ 9816 label: (0, import_i18n22.__)("Over"), 9817 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9818 (0, import_i18n22.sprintf)( 9819 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */ 9820 (0, import_i18n22.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"), 9821 filter.name, 9822 `$activeElements[0].value.value} $activeElements[0].value.unit}` 9823 ), 9824 filterTextWrappers 9825 ), 9826 selection: "custom" 9827 }, 9828 { 9829 name: OPERATOR_IS, 9830 /* translators: DataViews operator name */ 9831 label: (0, import_i18n22.__)("Is"), 9832 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9833 (0, import_i18n22.sprintf)( 9834 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */ 9835 (0, import_i18n22.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 9836 filter.name, 9837 activeElements[0].label 9838 ), 9839 filterTextWrappers 9840 ), 9841 selection: "single" 9842 }, 9843 { 9844 name: OPERATOR_IS_NOT, 9845 /* translators: DataViews operator name */ 9846 label: (0, import_i18n22.__)("Is not"), 9847 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9848 (0, import_i18n22.sprintf)( 9849 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */ 9850 (0, import_i18n22.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 9851 filter.name, 9852 activeElements[0].label 9853 ), 9854 filterTextWrappers 9855 ), 9856 selection: "single" 9857 }, 9858 { 9859 name: OPERATOR_LESS_THAN, 9860 /* translators: DataViews operator name */ 9861 label: (0, import_i18n22.__)("Less than"), 9862 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9863 (0, import_i18n22.sprintf)( 9864 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */ 9865 (0, import_i18n22.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"), 9866 filter.name, 9867 activeElements[0].label 9868 ), 9869 filterTextWrappers 9870 ), 9871 selection: "single" 9872 }, 9873 { 9874 name: OPERATOR_GREATER_THAN, 9875 /* translators: DataViews operator name */ 9876 label: (0, import_i18n22.__)("Greater than"), 9877 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9878 (0, import_i18n22.sprintf)( 9879 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */ 9880 (0, import_i18n22.__)( 9881 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>" 9882 ), 9883 filter.name, 9884 activeElements[0].label 9885 ), 9886 filterTextWrappers 9887 ), 9888 selection: "single" 9889 }, 9890 { 9891 name: OPERATOR_LESS_THAN_OR_EQUAL, 9892 /* translators: DataViews operator name */ 9893 label: (0, import_i18n22.__)("Less than or equal"), 9894 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9895 (0, import_i18n22.sprintf)( 9896 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */ 9897 (0, import_i18n22.__)( 9898 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>" 9899 ), 9900 filter.name, 9901 activeElements[0].label 9902 ), 9903 filterTextWrappers 9904 ), 9905 selection: "single" 9906 }, 9907 { 9908 name: OPERATOR_GREATER_THAN_OR_EQUAL, 9909 /* translators: DataViews operator name */ 9910 label: (0, import_i18n22.__)("Greater than or equal"), 9911 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9912 (0, import_i18n22.sprintf)( 9913 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */ 9914 (0, import_i18n22.__)( 9915 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>" 9916 ), 9917 filter.name, 9918 activeElements[0].label 9919 ), 9920 filterTextWrappers 9921 ), 9922 selection: "single" 9923 }, 9924 { 9925 name: OPERATOR_BEFORE, 9926 /* translators: DataViews operator name */ 9927 label: (0, import_i18n22.__)("Before"), 9928 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9929 (0, import_i18n22.sprintf)( 9930 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */ 9931 (0, import_i18n22.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"), 9932 filter.name, 9933 activeElements[0].label 9934 ), 9935 filterTextWrappers 9936 ), 9937 selection: "single" 9938 }, 9939 { 9940 name: OPERATOR_AFTER, 9941 /* translators: DataViews operator name */ 9942 label: (0, import_i18n22.__)("After"), 9943 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9944 (0, import_i18n22.sprintf)( 9945 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */ 9946 (0, import_i18n22.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"), 9947 filter.name, 9948 activeElements[0].label 9949 ), 9950 filterTextWrappers 9951 ), 9952 selection: "single" 9953 }, 9954 { 9955 name: OPERATOR_BEFORE_INC, 9956 /* translators: DataViews operator name */ 9957 label: (0, import_i18n22.__)("Before (inc)"), 9958 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9959 (0, import_i18n22.sprintf)( 9960 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */ 9961 (0, import_i18n22.__)( 9962 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>" 9963 ), 9964 filter.name, 9965 activeElements[0].label 9966 ), 9967 filterTextWrappers 9968 ), 9969 selection: "single" 9970 }, 9971 { 9972 name: OPERATOR_AFTER_INC, 9973 /* translators: DataViews operator name */ 9974 label: (0, import_i18n22.__)("After (inc)"), 9975 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9976 (0, import_i18n22.sprintf)( 9977 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */ 9978 (0, import_i18n22.__)( 9979 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>" 9980 ), 9981 filter.name, 9982 activeElements[0].label 9983 ), 9984 filterTextWrappers 9985 ), 9986 selection: "single" 9987 }, 9988 { 9989 name: OPERATOR_CONTAINS, 9990 /* translators: DataViews operator name */ 9991 label: (0, import_i18n22.__)("Contains"), 9992 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9993 (0, import_i18n22.sprintf)( 9994 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */ 9995 (0, import_i18n22.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"), 9996 filter.name, 9997 activeElements[0].label 9998 ), 9999 filterTextWrappers 10000 ), 10001 selection: "single" 10002 }, 10003 { 10004 name: OPERATOR_NOT_CONTAINS, 10005 /* translators: DataViews operator name */ 10006 label: (0, import_i18n22.__)("Doesn't contain"), 10007 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10008 (0, import_i18n22.sprintf)( 10009 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */ 10010 (0, import_i18n22.__)( 10011 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>" 10012 ), 10013 filter.name, 10014 activeElements[0].label 10015 ), 10016 filterTextWrappers 10017 ), 10018 selection: "single" 10019 }, 10020 { 10021 name: OPERATOR_STARTS_WITH, 10022 /* translators: DataViews operator name */ 10023 label: (0, import_i18n22.__)("Starts with"), 10024 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10025 (0, import_i18n22.sprintf)( 10026 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */ 10027 (0, import_i18n22.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"), 10028 filter.name, 10029 activeElements[0].label 10030 ), 10031 filterTextWrappers 10032 ), 10033 selection: "single" 10034 }, 10035 { 10036 name: OPERATOR_ON, 10037 /* translators: DataViews operator name */ 10038 label: (0, import_i18n22.__)("On"), 10039 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10040 (0, import_i18n22.sprintf)( 10041 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */ 10042 (0, import_i18n22.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 10043 filter.name, 10044 activeElements[0].label 10045 ), 10046 filterTextWrappers 10047 ), 10048 selection: "single" 10049 }, 10050 { 10051 name: OPERATOR_NOT_ON, 10052 /* translators: DataViews operator name */ 10053 label: (0, import_i18n22.__)("Not on"), 10054 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10055 (0, import_i18n22.sprintf)( 10056 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */ 10057 (0, import_i18n22.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 10058 filter.name, 10059 activeElements[0].label 10060 ), 10061 filterTextWrappers 10062 ), 10063 selection: "single" 10064 } 10065 ]; 10066 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name); 10067 var getAllOperatorNames = () => OPERATORS.map((op) => op.name); 10068 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some( 10069 (op) => op.name === name 10070 ); 10071 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name); 10072 10073 // packages/dataviews/build-module/components/dataviews-filters/filter.js 10074 var import_jsx_runtime62 = __toESM(require_jsx_runtime()); 10075 var ENTER = "Enter"; 10076 var SPACE = " "; 10077 var FilterText = ({ 10078 activeElements, 10079 filterInView, 10080 filter 10081 }) => { 10082 if (activeElements === void 0 || activeElements.length === 0) { 10083 return filter.name; 10084 } 10085 const operator = getOperatorByName(filterInView?.operator); 10086 if (operator !== void 0) { 10087 return operator.filterText(filter, activeElements); 10088 } 10089 return (0, import_i18n23.sprintf)( 10090 /* translators: 1: Filter name e.g.: "Unknown status for Author". */ 10091 (0, import_i18n23.__)("Unknown status for %1$s"), 10092 filter.name 10093 ); 10094 }; 10095 function OperatorSelector({ 10096 filter, 10097 view, 10098 onChangeView 10099 }) { 10100 const operatorOptions = filter.operators?.map((operator) => ({ 10101 value: operator, 10102 label: getOperatorByName(operator)?.label || operator 10103 })); 10104 const currentFilter = view.filters?.find( 10105 (_filter) => _filter.field === filter.field 10106 ); 10107 const value = currentFilter?.operator || filter.operators[0]; 10108 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)( 10109 import_components23.__experimentalHStack, 10110 { 10111 spacing: 2, 10112 justify: "flex-start", 10113 className: "dataviews-filters__summary-operators-container", 10114 children: [ 10115 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components23.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }), 10116 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 10117 import_components23.SelectControl, 10118 { 10119 className: "dataviews-filters__summary-operators-filter-select", 10120 label: (0, import_i18n23.__)("Conditions"), 10121 value, 10122 options: operatorOptions, 10123 onChange: (newValue) => { 10124 const newOperator = newValue; 10125 const currentOperator = currentFilter?.operator; 10126 const newFilters = currentFilter ? [ 10127 ...(view.filters ?? []).map( 10128 (_filter) => { 10129 if (_filter.field === filter.field) { 10130 const currentOpSelectionModel = getOperatorByName( 10131 currentOperator 10132 )?.selection; 10133 const newOpSelectionModel = getOperatorByName( 10134 newOperator 10135 )?.selection; 10136 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [ 10137 currentOpSelectionModel, 10138 newOpSelectionModel 10139 ].includes("custom"); 10140 return { 10141 ..._filter, 10142 value: shouldResetValue ? void 0 : _filter.value, 10143 operator: newOperator 10144 }; 10145 } 10146 return _filter; 10147 } 10148 ) 10149 ] : [ 10150 ...view.filters ?? [], 10151 { 10152 field: filter.field, 10153 operator: newOperator, 10154 value: void 0 10155 } 10156 ]; 10157 onChangeView({ 10158 ...view, 10159 page: 1, 10160 filters: newFilters 10161 }); 10162 }, 10163 size: "small", 10164 variant: "minimal", 10165 hideLabelFromVision: true 10166 } 10167 ) 10168 ] 10169 } 10170 ); 10171 } 10172 function Filter({ 10173 addFilterRef, 10174 openedFilter, 10175 fields, 10176 ...commonProps 10177 }) { 10178 const toggleRef = (0, import_element26.useRef)(null); 10179 const { filter, view, onChangeView } = commonProps; 10180 const filterInView = view.filters?.find( 10181 (f2) => f2.field === filter.field 10182 ); 10183 let activeElements = []; 10184 const field = (0, import_element26.useMemo)(() => { 10185 const currentField = fields.find((f2) => f2.id === filter.field); 10186 if (currentField) { 10187 return { 10188 ...currentField, 10189 // Configure getValue as if Item was a plain object. 10190 // See related input-widget.tsx 10191 getValue: ({ item }) => item[currentField.id] 10192 }; 10193 } 10194 return currentField; 10195 }, [fields, filter.field]); 10196 const { elements } = useElements({ 10197 elements: filter.elements, 10198 getElements: filter.getElements 10199 }); 10200 if (elements.length > 0) { 10201 activeElements = elements.filter((element) => { 10202 if (filter.singleSelection) { 10203 return element.value === filterInView?.value; 10204 } 10205 return filterInView?.value?.includes(element.value); 10206 }); 10207 } else if (Array.isArray(filterInView?.value)) { 10208 const label = filterInView.value.map((v2) => { 10209 const formattedValue = field?.getValueFormatted({ 10210 item: { [field.id]: v2 }, 10211 field 10212 }); 10213 return formattedValue || String(v2); 10214 }); 10215 activeElements = [ 10216 { 10217 value: filterInView.value, 10218 // @ts-ignore 10219 label 10220 } 10221 ]; 10222 } else if (typeof filterInView?.value === "object") { 10223 activeElements = [ 10224 { value: filterInView.value, label: filterInView.value } 10225 ]; 10226 } else if (filterInView?.value !== void 0) { 10227 const label = field !== void 0 ? field.getValueFormatted({ 10228 item: { [field.id]: filterInView.value }, 10229 field 10230 }) : String(filterInView.value); 10231 activeElements = [ 10232 { 10233 value: filterInView.value, 10234 label 10235 } 10236 ]; 10237 } 10238 const isPrimary = filter.isPrimary; 10239 const isLocked = filterInView?.isLocked; 10240 const hasValues = !isLocked && filterInView?.value !== void 0; 10241 const canResetOrRemove = !isLocked && (!isPrimary || hasValues); 10242 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 10243 import_components23.Dropdown, 10244 { 10245 defaultOpen: openedFilter === filter.field, 10246 contentClassName: "dataviews-filters__summary-popover", 10247 popoverProps: { placement: "bottom-start", role: "dialog" }, 10248 onClose: () => { 10249 toggleRef.current?.focus(); 10250 }, 10251 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [ 10252 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 10253 import_components23.Tooltip, 10254 { 10255 text: (0, import_i18n23.sprintf)( 10256 /* translators: 1: Filter name. */ 10257 (0, import_i18n23.__)("Filter by: %1$s"), 10258 filter.name.toLowerCase() 10259 ), 10260 placement: "top", 10261 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 10262 "div", 10263 { 10264 className: clsx_default( 10265 "dataviews-filters__summary-chip", 10266 { 10267 "has-reset": canResetOrRemove, 10268 "has-values": hasValues, 10269 "is-not-clickable": isLocked 10270 } 10271 ), 10272 role: "button", 10273 tabIndex: isLocked ? -1 : 0, 10274 onClick: () => { 10275 if (!isLocked) { 10276 onToggle(); 10277 } 10278 }, 10279 onKeyDown: (event) => { 10280 if (!isLocked && [ENTER, SPACE].includes(event.key)) { 10281 onToggle(); 10282 event.preventDefault(); 10283 } 10284 }, 10285 "aria-disabled": isLocked, 10286 "aria-pressed": isOpen, 10287 "aria-expanded": isOpen, 10288 ref: toggleRef, 10289 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 10290 FilterText, 10291 { 10292 activeElements, 10293 filterInView, 10294 filter 10295 } 10296 ) 10297 } 10298 ) 10299 } 10300 ), 10301 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 10302 import_components23.Tooltip, 10303 { 10304 text: isPrimary ? (0, import_i18n23.__)("Reset") : (0, import_i18n23.__)("Remove"), 10305 placement: "top", 10306 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 10307 "button", 10308 { 10309 className: clsx_default( 10310 "dataviews-filters__summary-chip-remove", 10311 { "has-values": hasValues } 10312 ), 10313 onClick: () => { 10314 onChangeView({ 10315 ...view, 10316 page: 1, 10317 filters: view.filters?.filter( 10318 (_filter) => _filter.field !== filter.field 10319 ) 10320 }); 10321 if (!isPrimary) { 10322 addFilterRef.current?.focus(); 10323 } else { 10324 toggleRef.current?.focus(); 10325 } 10326 }, 10327 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components23.Icon, { icon: close_small_default }) 10328 } 10329 ) 10330 } 10331 ) 10332 ] }), 10333 renderContent: () => { 10334 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_components23.__experimentalVStack, { spacing: 0, justify: "flex-start", children: [ 10335 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(OperatorSelector, { ...commonProps }), 10336 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)( 10337 SearchWidget, 10338 { 10339 ...commonProps, 10340 filter: { 10341 ...commonProps.filter, 10342 elements 10343 } 10344 } 10345 ) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(InputWidget, { ...commonProps, fields }) 10346 ] }); 10347 } 10348 } 10349 ); 10350 } 10351 10352 // packages/dataviews/build-module/components/dataviews-filters/add-filter.js 10353 var import_components24 = __toESM(require_components()); 10354 var import_i18n24 = __toESM(require_i18n()); 10355 var import_element27 = __toESM(require_element()); 10356 var import_jsx_runtime63 = __toESM(require_jsx_runtime()); 10357 var { Menu: Menu4 } = unlock(import_components24.privateApis); 10358 function AddFilterMenu({ 10359 filters, 10360 view, 10361 onChangeView, 10362 setOpenedFilter, 10363 triggerProps 10364 }) { 10365 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 10366 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Menu4, { children: [ 10367 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Menu4.TriggerButton, { ...triggerProps }), 10368 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => { 10369 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)( 10370 Menu4.Item, 10371 { 10372 onClick: () => { 10373 setOpenedFilter(filter.field); 10374 onChangeView({ 10375 ...view, 10376 page: 1, 10377 filters: [ 10378 ...view.filters || [], 10379 { 10380 field: filter.field, 10381 value: void 0, 10382 operator: filter.operators[0] 10383 } 10384 ] 10385 }); 10386 }, 10387 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Menu4.ItemLabel, { children: filter.name }) 10388 }, 10389 filter.field 10390 ); 10391 }) }) 10392 ] }); 10393 } 10394 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) { 10395 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) { 10396 return null; 10397 } 10398 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 10399 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)( 10400 AddFilterMenu, 10401 { 10402 triggerProps: { 10403 render: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)( 10404 import_components24.Button, 10405 { 10406 accessibleWhenDisabled: true, 10407 size: "compact", 10408 className: "dataviews-filters-button", 10409 variant: "tertiary", 10410 disabled: !inactiveFilters.length, 10411 ref 10412 } 10413 ), 10414 children: (0, import_i18n24.__)("Add filter") 10415 }, 10416 ...{ filters, view, onChangeView, setOpenedFilter } 10417 } 10418 ); 10419 } 10420 var add_filter_default = (0, import_element27.forwardRef)(AddFilter); 10421 10422 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.js 10423 var import_components25 = __toESM(require_components()); 10424 var import_i18n25 = __toESM(require_i18n()); 10425 var import_jsx_runtime64 = __toESM(require_jsx_runtime()); 10426 function ResetFilter({ 10427 filters, 10428 view, 10429 onChangeView 10430 }) { 10431 const isPrimary = (field) => filters.some( 10432 (_filter) => _filter.field === field && _filter.isPrimary 10433 ); 10434 const isDisabled = !view.search && !view.filters?.some( 10435 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field)) 10436 ); 10437 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)( 10438 import_components25.Button, 10439 { 10440 disabled: isDisabled, 10441 accessibleWhenDisabled: true, 10442 size: "compact", 10443 variant: "tertiary", 10444 className: "dataviews-filters__reset-button", 10445 onClick: () => { 10446 onChangeView({ 10447 ...view, 10448 page: 1, 10449 search: "", 10450 filters: view.filters?.filter((f2) => !!f2.isLocked) || [] 10451 }); 10452 }, 10453 children: (0, import_i18n25.__)("Reset") 10454 } 10455 ); 10456 } 10457 10458 // packages/dataviews/build-module/components/dataviews-filters/use-filters.js 10459 var import_element28 = __toESM(require_element()); 10460 function useFilters(fields, view) { 10461 return (0, import_element28.useMemo)(() => { 10462 const filters = []; 10463 fields.forEach((field) => { 10464 if (field.filterBy === false || !field.hasElements && !field.Edit) { 10465 return; 10466 } 10467 const operators = field.filterBy.operators; 10468 const isPrimary = !!field.filterBy?.isPrimary; 10469 const isLocked = view.filters?.some( 10470 (f2) => f2.field === field.id && !!f2.isLocked 10471 ) ?? false; 10472 filters.push({ 10473 field: field.id, 10474 name: field.label, 10475 elements: field.elements, 10476 getElements: field.getElements, 10477 hasElements: field.hasElements, 10478 singleSelection: operators.some( 10479 (op) => isSingleSelectionOperator(op) 10480 ), 10481 operators, 10482 isVisible: isLocked || isPrimary || !!view.filters?.some( 10483 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator) 10484 ), 10485 isPrimary, 10486 isLocked 10487 }); 10488 }); 10489 filters.sort((a2, b2) => { 10490 if (a2.isLocked && !b2.isLocked) { 10491 return -1; 10492 } 10493 if (!a2.isLocked && b2.isLocked) { 10494 return 1; 10495 } 10496 if (a2.isPrimary && !b2.isPrimary) { 10497 return -1; 10498 } 10499 if (!a2.isPrimary && b2.isPrimary) { 10500 return 1; 10501 } 10502 return a2.name.localeCompare(b2.name); 10503 }); 10504 return filters; 10505 }, [fields, view]); 10506 } 10507 var use_filters_default = useFilters; 10508 10509 // packages/dataviews/build-module/components/dataviews-filters/filters.js 10510 var import_jsx_runtime65 = __toESM(require_jsx_runtime()); 10511 function Filters({ className }) { 10512 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element29.useContext)(dataviews_context_default); 10513 const addFilterRef = (0, import_element29.useRef)(null); 10514 const filters = use_filters_default(fields, view); 10515 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 10516 add_filter_default, 10517 { 10518 filters, 10519 view, 10520 onChangeView, 10521 ref: addFilterRef, 10522 setOpenedFilter 10523 }, 10524 "add-filter" 10525 ); 10526 const visibleFilters = filters.filter((filter) => filter.isVisible); 10527 if (visibleFilters.length === 0) { 10528 return null; 10529 } 10530 const filterComponents = [ 10531 ...visibleFilters.map((filter) => { 10532 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 10533 Filter, 10534 { 10535 filter, 10536 view, 10537 fields, 10538 onChangeView, 10539 addFilterRef, 10540 openedFilter 10541 }, 10542 filter.field 10543 ); 10544 }), 10545 addFilter 10546 ]; 10547 filterComponents.push( 10548 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 10549 ResetFilter, 10550 { 10551 filters, 10552 view, 10553 onChangeView 10554 }, 10555 "reset-filters" 10556 ) 10557 ); 10558 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 10559 import_components26.__experimentalHStack, 10560 { 10561 justify: "flex-start", 10562 style: { width: "fit-content" }, 10563 wrap: true, 10564 className, 10565 children: filterComponents 10566 } 10567 ); 10568 } 10569 var filters_default = (0, import_element29.memo)(Filters); 10570 10571 // packages/dataviews/build-module/components/dataviews-filters/toggle.js 10572 var import_element30 = __toESM(require_element()); 10573 var import_components27 = __toESM(require_components()); 10574 var import_i18n26 = __toESM(require_i18n()); 10575 var import_jsx_runtime66 = __toESM(require_jsx_runtime()); 10576 function FiltersToggle() { 10577 const { 10578 filters, 10579 view, 10580 onChangeView, 10581 setOpenedFilter, 10582 isShowingFilter, 10583 setIsShowingFilter 10584 } = (0, import_element30.useContext)(dataviews_context_default); 10585 const buttonRef = (0, import_element30.useRef)(null); 10586 const onChangeViewWithFilterVisibility = (0, import_element30.useCallback)( 10587 (_view) => { 10588 onChangeView(_view); 10589 setIsShowingFilter(true); 10590 }, 10591 [onChangeView, setIsShowingFilter] 10592 ); 10593 const visibleFilters = filters.filter((filter) => filter.isVisible); 10594 const hasVisibleFilters = !!visibleFilters.length; 10595 if (filters.length === 0) { 10596 return null; 10597 } 10598 const addFilterButtonProps = { 10599 label: (0, import_i18n26.__)("Add filter"), 10600 "aria-expanded": false, 10601 isPressed: false 10602 }; 10603 const toggleFiltersButtonProps = { 10604 label: (0, import_i18n26._x)("Filter", "verb"), 10605 "aria-expanded": isShowingFilter, 10606 isPressed: isShowingFilter, 10607 onClick: () => { 10608 if (!isShowingFilter) { 10609 setOpenedFilter(null); 10610 } 10611 setIsShowingFilter(!isShowingFilter); 10612 } 10613 }; 10614 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 10615 import_components27.Button, 10616 { 10617 ref: buttonRef, 10618 className: "dataviews-filters__visibility-toggle", 10619 size: "compact", 10620 icon: funnel_default, 10621 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps 10622 } 10623 ); 10624 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 10625 AddFilterMenu, 10626 { 10627 filters, 10628 view, 10629 onChangeView: onChangeViewWithFilterVisibility, 10630 setOpenedFilter, 10631 triggerProps: { render: buttonComponent } 10632 } 10633 ) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)( 10634 FilterVisibilityToggle, 10635 { 10636 buttonRef, 10637 filtersCount: view.filters?.length, 10638 children: buttonComponent 10639 } 10640 ) }); 10641 } 10642 function FilterVisibilityToggle({ 10643 buttonRef, 10644 filtersCount, 10645 children 10646 }) { 10647 (0, import_element30.useEffect)( 10648 () => () => { 10649 buttonRef.current?.focus(); 10650 }, 10651 [buttonRef] 10652 ); 10653 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [ 10654 children, 10655 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount }) 10656 ] }); 10657 } 10658 var toggle_default = FiltersToggle; 10659 10660 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.js 10661 var import_element31 = __toESM(require_element()); 10662 var import_jsx_runtime67 = __toESM(require_jsx_runtime()); 10663 function FiltersToggled(props) { 10664 const { isShowingFilter } = (0, import_element31.useContext)(dataviews_context_default); 10665 if (!isShowingFilter) { 10666 return null; 10667 } 10668 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(filters_default, { ...props }); 10669 } 10670 var filters_toggled_default = FiltersToggled; 10671 10672 // packages/dataviews/build-module/components/dataviews-layout/index.js 10673 var import_element32 = __toESM(require_element()); 10674 var import_i18n27 = __toESM(require_i18n()); 10675 var import_jsx_runtime68 = __toESM(require_jsx_runtime()); 10676 function DataViewsLayout({ className }) { 10677 const { 10678 actions = [], 10679 data, 10680 fields, 10681 getItemId: getItemId2, 10682 getItemLevel, 10683 isLoading, 10684 view, 10685 onChangeView, 10686 selection, 10687 onChangeSelection, 10688 setOpenedFilter, 10689 onClickItem, 10690 isItemClickable, 10691 renderItemLink, 10692 defaultLayouts, 10693 empty = /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { children: (0, import_i18n27.__)("No results") }) 10694 } = (0, import_element32.useContext)(dataviews_context_default); 10695 const ViewComponent = VIEW_LAYOUTS.find( 10696 (v2) => v2.type === view.type && defaultLayouts[v2.type] 10697 )?.component; 10698 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)( 10699 ViewComponent, 10700 { 10701 className, 10702 actions, 10703 data, 10704 fields, 10705 getItemId: getItemId2, 10706 getItemLevel, 10707 isLoading, 10708 onChangeView, 10709 onChangeSelection, 10710 selection, 10711 setOpenedFilter, 10712 onClickItem, 10713 renderItemLink, 10714 isItemClickable, 10715 view, 10716 empty 10717 } 10718 ); 10719 } 10720 10721 // packages/dataviews/build-module/components/dataviews-footer/index.js 10722 var import_components28 = __toESM(require_components()); 10723 var import_element33 = __toESM(require_element()); 10724 var import_jsx_runtime69 = __toESM(require_jsx_runtime()); 10725 var EMPTY_ARRAY4 = []; 10726 function DataViewsFooter() { 10727 const { 10728 view, 10729 paginationInfo: { totalItems = 0, totalPages }, 10730 data, 10731 actions = EMPTY_ARRAY4 10732 } = (0, import_element33.useContext)(dataviews_context_default); 10733 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type); 10734 if (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions) { 10735 return null; 10736 } 10737 return !!totalItems && /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)( 10738 import_components28.__experimentalHStack, 10739 { 10740 expanded: false, 10741 justify: "end", 10742 className: "dataviews-footer", 10743 children: [ 10744 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(BulkActionsFooter, {}), 10745 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(dataviews_pagination_default, {}) 10746 ] 10747 } 10748 ); 10749 } 10750 10751 // packages/dataviews/build-module/components/dataviews-search/index.js 10752 var import_i18n28 = __toESM(require_i18n()); 10753 var import_element34 = __toESM(require_element()); 10754 var import_components29 = __toESM(require_components()); 10755 var import_compose9 = __toESM(require_compose()); 10756 var import_jsx_runtime70 = __toESM(require_jsx_runtime()); 10757 var DataViewsSearch = (0, import_element34.memo)(function Search({ label }) { 10758 const { view, onChangeView } = (0, import_element34.useContext)(dataviews_context_default); 10759 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)( 10760 view.search 10761 ); 10762 (0, import_element34.useEffect)(() => { 10763 setSearch(view.search ?? ""); 10764 }, [view.search, setSearch]); 10765 const onChangeViewRef = (0, import_element34.useRef)(onChangeView); 10766 const viewRef = (0, import_element34.useRef)(view); 10767 (0, import_element34.useEffect)(() => { 10768 onChangeViewRef.current = onChangeView; 10769 viewRef.current = view; 10770 }, [onChangeView, view]); 10771 (0, import_element34.useEffect)(() => { 10772 if (debouncedSearch !== viewRef.current?.search) { 10773 onChangeViewRef.current({ 10774 ...viewRef.current, 10775 page: 1, 10776 search: debouncedSearch 10777 }); 10778 } 10779 }, [debouncedSearch]); 10780 const searchLabel = label || (0, import_i18n28.__)("Search"); 10781 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 10782 import_components29.SearchControl, 10783 { 10784 className: "dataviews-search", 10785 onChange: setSearch, 10786 value: search, 10787 label: searchLabel, 10788 placeholder: searchLabel, 10789 size: "compact" 10790 } 10791 ); 10792 }); 10793 var dataviews_search_default = DataViewsSearch; 10794 10795 // packages/dataviews/build-module/components/dataviews-view-config/index.js 10796 var import_components31 = __toESM(require_components()); 10797 var import_i18n30 = __toESM(require_i18n()); 10798 var import_element36 = __toESM(require_element()); 10799 var import_warning = __toESM(require_warning()); 10800 var import_compose10 = __toESM(require_compose()); 10801 10802 // packages/dataviews/build-module/components/dataviews-view-config/infinite-scroll-toggle.js 10803 var import_components30 = __toESM(require_components()); 10804 var import_i18n29 = __toESM(require_i18n()); 10805 var import_element35 = __toESM(require_element()); 10806 var import_jsx_runtime71 = __toESM(require_jsx_runtime()); 10807 function InfiniteScrollToggle() { 10808 const context = (0, import_element35.useContext)(dataviews_context_default); 10809 const { view, onChangeView } = context; 10810 const infiniteScrollEnabled = view.infiniteScrollEnabled ?? false; 10811 if (!context.hasInfiniteScrollHandler) { 10812 return null; 10813 } 10814 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 10815 import_components30.ToggleControl, 10816 { 10817 label: (0, import_i18n29.__)("Enable infinite scroll"), 10818 help: (0, import_i18n29.__)( 10819 "Automatically load more content as you scroll, instead of showing pagination links." 10820 ), 10821 checked: infiniteScrollEnabled, 10822 onChange: (newValue) => { 10823 onChangeView({ 10824 ...view, 10825 infiniteScrollEnabled: newValue 10826 }); 10827 } 10828 } 10829 ); 10830 } 10831 10832 // packages/dataviews/build-module/components/dataviews-view-config/index.js 10833 var import_jsx_runtime72 = __toESM(require_jsx_runtime()); 10834 var { Menu: Menu5 } = unlock(import_components31.privateApis); 10835 var DATAVIEWS_CONFIG_POPOVER_PROPS = { 10836 className: "dataviews-config__popover", 10837 placement: "bottom-end", 10838 offset: 9 10839 }; 10840 function ViewTypeMenu() { 10841 const { view, onChangeView, defaultLayouts } = (0, import_element36.useContext)(dataviews_context_default); 10842 const availableLayouts = Object.keys(defaultLayouts); 10843 if (availableLayouts.length <= 1) { 10844 return null; 10845 } 10846 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type); 10847 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(Menu5, { children: [ 10848 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 10849 Menu5.TriggerButton, 10850 { 10851 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 10852 import_components31.Button, 10853 { 10854 size: "compact", 10855 icon: activeView?.icon, 10856 label: (0, import_i18n30.__)("Layout") 10857 } 10858 ) 10859 } 10860 ), 10861 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => { 10862 const config = VIEW_LAYOUTS.find( 10863 (v2) => v2.type === layout 10864 ); 10865 if (!config) { 10866 return null; 10867 } 10868 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 10869 Menu5.RadioItem, 10870 { 10871 value: layout, 10872 name: "view-actions-available-view", 10873 checked: layout === view.type, 10874 hideOnClick: true, 10875 onChange: (e2) => { 10876 switch (e2.target.value) { 10877 case "list": 10878 case "grid": 10879 case "table": 10880 case "pickerGrid": 10881 case "pickerTable": 10882 case "activity": 10883 const viewWithoutLayout = { ...view }; 10884 if ("layout" in viewWithoutLayout) { 10885 delete viewWithoutLayout.layout; 10886 } 10887 return onChangeView({ 10888 ...viewWithoutLayout, 10889 type: e2.target.value, 10890 ...defaultLayouts[e2.target.value] 10891 }); 10892 } 10893 (0, import_warning.default)("Invalid dataview"); 10894 }, 10895 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Menu5.ItemLabel, { children: config.label }) 10896 }, 10897 layout 10898 ); 10899 }) }) 10900 ] }); 10901 } 10902 function SortFieldControl() { 10903 const { view, fields, onChangeView } = (0, import_element36.useContext)(dataviews_context_default); 10904 const orderOptions = (0, import_element36.useMemo)(() => { 10905 const sortableFields = fields.filter( 10906 (field) => field.enableSorting !== false 10907 ); 10908 return sortableFields.map((field) => { 10909 return { 10910 label: field.label, 10911 value: field.id 10912 }; 10913 }); 10914 }, [fields]); 10915 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 10916 import_components31.SelectControl, 10917 { 10918 __next40pxDefaultSize: true, 10919 label: (0, import_i18n30.__)("Sort by"), 10920 value: view.sort?.field, 10921 options: orderOptions, 10922 onChange: (value) => { 10923 onChangeView({ 10924 ...view, 10925 sort: { 10926 direction: view?.sort?.direction || "desc", 10927 field: value 10928 }, 10929 showLevels: false 10930 }); 10931 } 10932 } 10933 ); 10934 } 10935 function SortDirectionControl() { 10936 const { view, fields, onChangeView } = (0, import_element36.useContext)(dataviews_context_default); 10937 const sortableFields = fields.filter( 10938 (field) => field.enableSorting !== false 10939 ); 10940 if (sortableFields.length === 0) { 10941 return null; 10942 } 10943 let value = view.sort?.direction; 10944 if (!value && view.sort?.field) { 10945 value = "desc"; 10946 } 10947 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 10948 import_components31.__experimentalToggleGroupControl, 10949 { 10950 className: "dataviews-view-config__sort-direction", 10951 __next40pxDefaultSize: true, 10952 isBlock: true, 10953 label: (0, import_i18n30.__)("Order"), 10954 value, 10955 onChange: (newDirection) => { 10956 if (newDirection === "asc" || newDirection === "desc") { 10957 onChangeView({ 10958 ...view, 10959 sort: { 10960 direction: newDirection, 10961 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field. 10962 fields.find( 10963 (field) => field.enableSorting !== false 10964 )?.id || "" 10965 }, 10966 showLevels: false 10967 }); 10968 return; 10969 } 10970 (0, import_warning.default)("Invalid direction"); 10971 }, 10972 children: SORTING_DIRECTIONS.map((direction) => { 10973 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 10974 import_components31.__experimentalToggleGroupControlOptionIcon, 10975 { 10976 value: direction, 10977 icon: sortIcons[direction], 10978 label: sortLabels[direction] 10979 }, 10980 direction 10981 ); 10982 }) 10983 } 10984 ); 10985 } 10986 function ItemsPerPageControl() { 10987 const { view, config, onChangeView } = (0, import_element36.useContext)(dataviews_context_default); 10988 const { infiniteScrollEnabled } = view; 10989 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) { 10990 return null; 10991 } 10992 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 10993 import_components31.__experimentalToggleGroupControl, 10994 { 10995 __next40pxDefaultSize: true, 10996 isBlock: true, 10997 label: (0, import_i18n30.__)("Items per page"), 10998 value: view.perPage || 10, 10999 disabled: !view?.sort?.field, 11000 onChange: (newItemsPerPage) => { 11001 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10); 11002 onChangeView({ 11003 ...view, 11004 perPage: newItemsPerPageNumber, 11005 page: 1 11006 }); 11007 }, 11008 children: config.perPageSizes.map((value) => { 11009 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 11010 import_components31.__experimentalToggleGroupControlOption, 11011 { 11012 value, 11013 label: value.toString() 11014 }, 11015 value 11016 ); 11017 }) 11018 } 11019 ); 11020 } 11021 function SettingsSection({ 11022 title, 11023 description, 11024 children 11025 }) { 11026 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_components31.__experimentalGrid, { columns: 12, className: "dataviews-settings-section", gap: 4, children: [ 11027 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "dataviews-settings-section__sidebar", children: [ 11028 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 11029 import_components31.__experimentalHeading, 11030 { 11031 level: 2, 11032 className: "dataviews-settings-section__title", 11033 children: title 11034 } 11035 ), 11036 description && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 11037 import_components31.__experimentalText, 11038 { 11039 variant: "muted", 11040 className: "dataviews-settings-section__description", 11041 children: description 11042 } 11043 ) 11044 ] }), 11045 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 11046 import_components31.__experimentalGrid, 11047 { 11048 columns: 8, 11049 gap: 4, 11050 className: "dataviews-settings-section__content", 11051 children 11052 } 11053 ) 11054 ] }); 11055 } 11056 function DataviewsViewConfigDropdown() { 11057 const { view } = (0, import_element36.useContext)(dataviews_context_default); 11058 const popoverId = (0, import_compose10.useInstanceId)( 11059 _DataViewsViewConfig, 11060 "dataviews-view-config-dropdown" 11061 ); 11062 const activeLayout = VIEW_LAYOUTS.find( 11063 (layout) => layout.type === view.type 11064 ); 11065 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 11066 import_components31.Dropdown, 11067 { 11068 expandOnMobile: true, 11069 popoverProps: { 11070 ...DATAVIEWS_CONFIG_POPOVER_PROPS, 11071 id: popoverId 11072 }, 11073 renderToggle: ({ onToggle, isOpen }) => { 11074 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 11075 import_components31.Button, 11076 { 11077 size: "compact", 11078 icon: cog_default, 11079 label: (0, import_i18n30._x)("View options", "View is used as a noun"), 11080 onClick: onToggle, 11081 "aria-expanded": isOpen ? "true" : "false", 11082 "aria-controls": popoverId 11083 } 11084 ); 11085 }, 11086 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)( 11087 import_components31.__experimentalDropdownContentWrapper, 11088 { 11089 paddingSize: "medium", 11090 className: "dataviews-config__popover-content-wrapper", 11091 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components31.__experimentalVStack, { className: "dataviews-view-config", spacing: 6, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(SettingsSection, { title: (0, import_i18n30.__)("Appearance"), children: [ 11092 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_components31.__experimentalHStack, { expanded: true, className: "is-divided-in-two", children: [ 11093 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SortFieldControl, {}), 11094 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SortDirectionControl, {}) 11095 ] }), 11096 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(activeLayout.viewConfigOptions, {}), 11097 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(InfiniteScrollToggle, {}), 11098 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ItemsPerPageControl, {}), 11099 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(PropertiesSection, {}) 11100 ] }) }) 11101 } 11102 ) 11103 } 11104 ); 11105 } 11106 function _DataViewsViewConfig() { 11107 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [ 11108 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ViewTypeMenu, {}), 11109 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DataviewsViewConfigDropdown, {}) 11110 ] }); 11111 } 11112 var DataViewsViewConfig = (0, import_element36.memo)(_DataViewsViewConfig); 11113 var dataviews_view_config_default = DataViewsViewConfig; 11114 11115 // packages/dataviews/build-module/dataform-controls/checkbox.js 11116 var import_components32 = __toESM(require_components()); 11117 var import_element37 = __toESM(require_element()); 11118 11119 // packages/dataviews/build-module/dataform-controls/utils/get-custom-validity.js 11120 function getCustomValidity(isValid2, validity) { 11121 let customValidity; 11122 if (isValid2?.required && validity?.required) { 11123 customValidity = validity?.required?.message ? validity.required : void 0; 11124 } else if (isValid2?.pattern && validity?.pattern) { 11125 customValidity = validity.pattern; 11126 } else if (isValid2?.min && validity?.min) { 11127 customValidity = validity.min; 11128 } else if (isValid2?.max && validity?.max) { 11129 customValidity = validity.max; 11130 } else if (isValid2?.minLength && validity?.minLength) { 11131 customValidity = validity.minLength; 11132 } else if (isValid2?.maxLength && validity?.maxLength) { 11133 customValidity = validity.maxLength; 11134 } else if (isValid2?.elements && validity?.elements) { 11135 customValidity = validity.elements; 11136 } else if (validity?.custom) { 11137 customValidity = validity.custom; 11138 } 11139 return customValidity; 11140 } 11141 11142 // packages/dataviews/build-module/dataform-controls/checkbox.js 11143 var import_jsx_runtime73 = __toESM(require_jsx_runtime()); 11144 var { ValidatedCheckboxControl } = unlock(import_components32.privateApis); 11145 function Checkbox({ 11146 field, 11147 onChange, 11148 data, 11149 hideLabelFromVision, 11150 validity 11151 }) { 11152 const { getValue, setValue, label, description, isValid: isValid2 } = field; 11153 const onChangeControl = (0, import_element37.useCallback)(() => { 11154 onChange( 11155 setValue({ item: data, value: !getValue({ item: data }) }) 11156 ); 11157 }, [data, getValue, onChange, setValue]); 11158 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 11159 ValidatedCheckboxControl, 11160 { 11161 required: !!field.isValid?.required, 11162 customValidity: getCustomValidity(isValid2, validity), 11163 hidden: hideLabelFromVision, 11164 label, 11165 help: description, 11166 checked: getValue({ item: data }), 11167 onChange: onChangeControl 11168 } 11169 ); 11170 } 11171 11172 // packages/dataviews/node_modules/date-fns/constants.js 11173 var daysInYear = 365.2425; 11174 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3; 11175 var minTime = -maxTime; 11176 var millisecondsInWeek = 6048e5; 11177 var millisecondsInDay = 864e5; 11178 var secondsInHour = 3600; 11179 var secondsInDay = secondsInHour * 24; 11180 var secondsInWeek = secondsInDay * 7; 11181 var secondsInYear = secondsInDay * daysInYear; 11182 var secondsInMonth = secondsInYear / 12; 11183 var secondsInQuarter = secondsInMonth * 3; 11184 var constructFromSymbol = Symbol.for("constructDateFrom"); 11185 11186 // packages/dataviews/node_modules/date-fns/constructFrom.js 11187 function constructFrom(date, value) { 11188 if (typeof date === "function") return date(value); 11189 if (date && typeof date === "object" && constructFromSymbol in date) 11190 return date[constructFromSymbol](value); 11191 if (date instanceof Date) return new date.constructor(value); 11192 return new Date(value); 11193 } 11194 11195 // packages/dataviews/node_modules/date-fns/toDate.js 11196 function toDate(argument, context) { 11197 return constructFrom(context || argument, argument); 11198 } 11199 11200 // packages/dataviews/node_modules/date-fns/addDays.js 11201 function addDays(date, amount, options) { 11202 const _date = toDate(date, options?.in); 11203 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 11204 if (!amount) return _date; 11205 _date.setDate(_date.getDate() + amount); 11206 return _date; 11207 } 11208 11209 // packages/dataviews/node_modules/date-fns/addMonths.js 11210 function addMonths(date, amount, options) { 11211 const _date = toDate(date, options?.in); 11212 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 11213 if (!amount) { 11214 return _date; 11215 } 11216 const dayOfMonth = _date.getDate(); 11217 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime()); 11218 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0); 11219 const daysInMonth = endOfDesiredMonth.getDate(); 11220 if (dayOfMonth >= daysInMonth) { 11221 return endOfDesiredMonth; 11222 } else { 11223 _date.setFullYear( 11224 endOfDesiredMonth.getFullYear(), 11225 endOfDesiredMonth.getMonth(), 11226 dayOfMonth 11227 ); 11228 return _date; 11229 } 11230 } 11231 11232 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js 11233 var defaultOptions = {}; 11234 function getDefaultOptions() { 11235 return defaultOptions; 11236 } 11237 11238 // packages/dataviews/node_modules/date-fns/startOfWeek.js 11239 function startOfWeek(date, options) { 11240 const defaultOptions2 = getDefaultOptions(); 11241 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 11242 const _date = toDate(date, options?.in); 11243 const day = _date.getDay(); 11244 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; 11245 _date.setDate(_date.getDate() - diff); 11246 _date.setHours(0, 0, 0, 0); 11247 return _date; 11248 } 11249 11250 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js 11251 function startOfISOWeek(date, options) { 11252 return startOfWeek(date, { ...options, weekStartsOn: 1 }); 11253 } 11254 11255 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js 11256 function getISOWeekYear(date, options) { 11257 const _date = toDate(date, options?.in); 11258 const year = _date.getFullYear(); 11259 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0); 11260 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); 11261 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); 11262 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); 11263 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0); 11264 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); 11265 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); 11266 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); 11267 if (_date.getTime() >= startOfNextYear.getTime()) { 11268 return year + 1; 11269 } else if (_date.getTime() >= startOfThisYear.getTime()) { 11270 return year; 11271 } else { 11272 return year - 1; 11273 } 11274 } 11275 11276 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js 11277 function getTimezoneOffsetInMilliseconds(date) { 11278 const _date = toDate(date); 11279 const utcDate = new Date( 11280 Date.UTC( 11281 _date.getFullYear(), 11282 _date.getMonth(), 11283 _date.getDate(), 11284 _date.getHours(), 11285 _date.getMinutes(), 11286 _date.getSeconds(), 11287 _date.getMilliseconds() 11288 ) 11289 ); 11290 utcDate.setUTCFullYear(_date.getFullYear()); 11291 return +date - +utcDate; 11292 } 11293 11294 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js 11295 function normalizeDates(context, ...dates) { 11296 const normalize = constructFrom.bind( 11297 null, 11298 context || dates.find((date) => typeof date === "object") 11299 ); 11300 return dates.map(normalize); 11301 } 11302 11303 // packages/dataviews/node_modules/date-fns/startOfDay.js 11304 function startOfDay(date, options) { 11305 const _date = toDate(date, options?.in); 11306 _date.setHours(0, 0, 0, 0); 11307 return _date; 11308 } 11309 11310 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js 11311 function differenceInCalendarDays(laterDate, earlierDate, options) { 11312 const [laterDate_, earlierDate_] = normalizeDates( 11313 options?.in, 11314 laterDate, 11315 earlierDate 11316 ); 11317 const laterStartOfDay = startOfDay(laterDate_); 11318 const earlierStartOfDay = startOfDay(earlierDate_); 11319 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay); 11320 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay); 11321 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay); 11322 } 11323 11324 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js 11325 function startOfISOWeekYear(date, options) { 11326 const year = getISOWeekYear(date, options); 11327 const fourthOfJanuary = constructFrom(options?.in || date, 0); 11328 fourthOfJanuary.setFullYear(year, 0, 4); 11329 fourthOfJanuary.setHours(0, 0, 0, 0); 11330 return startOfISOWeek(fourthOfJanuary); 11331 } 11332 11333 // packages/dataviews/node_modules/date-fns/addYears.js 11334 function addYears(date, amount, options) { 11335 return addMonths(date, amount * 12, options); 11336 } 11337 11338 // packages/dataviews/node_modules/date-fns/isDate.js 11339 function isDate(value) { 11340 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"; 11341 } 11342 11343 // packages/dataviews/node_modules/date-fns/isValid.js 11344 function isValid(date) { 11345 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date))); 11346 } 11347 11348 // packages/dataviews/node_modules/date-fns/startOfMonth.js 11349 function startOfMonth(date, options) { 11350 const _date = toDate(date, options?.in); 11351 _date.setDate(1); 11352 _date.setHours(0, 0, 0, 0); 11353 return _date; 11354 } 11355 11356 // packages/dataviews/node_modules/date-fns/startOfYear.js 11357 function startOfYear(date, options) { 11358 const date_ = toDate(date, options?.in); 11359 date_.setFullYear(date_.getFullYear(), 0, 1); 11360 date_.setHours(0, 0, 0, 0); 11361 return date_; 11362 } 11363 11364 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js 11365 var formatDistanceLocale = { 11366 lessThanXSeconds: { 11367 one: "less than a second", 11368 other: "less than {{count}} seconds" 11369 }, 11370 xSeconds: { 11371 one: "1 second", 11372 other: "{{count}} seconds" 11373 }, 11374 halfAMinute: "half a minute", 11375 lessThanXMinutes: { 11376 one: "less than a minute", 11377 other: "less than {{count}} minutes" 11378 }, 11379 xMinutes: { 11380 one: "1 minute", 11381 other: "{{count}} minutes" 11382 }, 11383 aboutXHours: { 11384 one: "about 1 hour", 11385 other: "about {{count}} hours" 11386 }, 11387 xHours: { 11388 one: "1 hour", 11389 other: "{{count}} hours" 11390 }, 11391 xDays: { 11392 one: "1 day", 11393 other: "{{count}} days" 11394 }, 11395 aboutXWeeks: { 11396 one: "about 1 week", 11397 other: "about {{count}} weeks" 11398 }, 11399 xWeeks: { 11400 one: "1 week", 11401 other: "{{count}} weeks" 11402 }, 11403 aboutXMonths: { 11404 one: "about 1 month", 11405 other: "about {{count}} months" 11406 }, 11407 xMonths: { 11408 one: "1 month", 11409 other: "{{count}} months" 11410 }, 11411 aboutXYears: { 11412 one: "about 1 year", 11413 other: "about {{count}} years" 11414 }, 11415 xYears: { 11416 one: "1 year", 11417 other: "{{count}} years" 11418 }, 11419 overXYears: { 11420 one: "over 1 year", 11421 other: "over {{count}} years" 11422 }, 11423 almostXYears: { 11424 one: "almost 1 year", 11425 other: "almost {{count}} years" 11426 } 11427 }; 11428 var formatDistance = (token, count, options) => { 11429 let result; 11430 const tokenValue = formatDistanceLocale[token]; 11431 if (typeof tokenValue === "string") { 11432 result = tokenValue; 11433 } else if (count === 1) { 11434 result = tokenValue.one; 11435 } else { 11436 result = tokenValue.other.replace("{{count}}", count.toString()); 11437 } 11438 if (options?.addSuffix) { 11439 if (options.comparison && options.comparison > 0) { 11440 return "in " + result; 11441 } else { 11442 return result + " ago"; 11443 } 11444 } 11445 return result; 11446 }; 11447 11448 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js 11449 function buildFormatLongFn(args) { 11450 return (options = {}) => { 11451 const width = options.width ? String(options.width) : args.defaultWidth; 11452 const format6 = args.formats[width] || args.formats[args.defaultWidth]; 11453 return format6; 11454 }; 11455 } 11456 11457 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js 11458 var dateFormats = { 11459 full: "EEEE, MMMM do, y", 11460 long: "MMMM do, y", 11461 medium: "MMM d, y", 11462 short: "MM/dd/yyyy" 11463 }; 11464 var timeFormats = { 11465 full: "h:mm:ss a zzzz", 11466 long: "h:mm:ss a z", 11467 medium: "h:mm:ss a", 11468 short: "h:mm a" 11469 }; 11470 var dateTimeFormats = { 11471 full: "{{date}} 'at' {{time}}", 11472 long: "{{date}} 'at' {{time}}", 11473 medium: "{{date}}, {{time}}", 11474 short: "{{date}}, {{time}}" 11475 }; 11476 var formatLong = { 11477 date: buildFormatLongFn({ 11478 formats: dateFormats, 11479 defaultWidth: "full" 11480 }), 11481 time: buildFormatLongFn({ 11482 formats: timeFormats, 11483 defaultWidth: "full" 11484 }), 11485 dateTime: buildFormatLongFn({ 11486 formats: dateTimeFormats, 11487 defaultWidth: "full" 11488 }) 11489 }; 11490 11491 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js 11492 var formatRelativeLocale = { 11493 lastWeek: "'last' eeee 'at' p", 11494 yesterday: "'yesterday at' p", 11495 today: "'today at' p", 11496 tomorrow: "'tomorrow at' p", 11497 nextWeek: "eeee 'at' p", 11498 other: "P" 11499 }; 11500 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token]; 11501 11502 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js 11503 function buildLocalizeFn(args) { 11504 return (value, options) => { 11505 const context = options?.context ? String(options.context) : "standalone"; 11506 let valuesArray; 11507 if (context === "formatting" && args.formattingValues) { 11508 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth; 11509 const width = options?.width ? String(options.width) : defaultWidth; 11510 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; 11511 } else { 11512 const defaultWidth = args.defaultWidth; 11513 const width = options?.width ? String(options.width) : args.defaultWidth; 11514 valuesArray = args.values[width] || args.values[defaultWidth]; 11515 } 11516 const index = args.argumentCallback ? args.argumentCallback(value) : value; 11517 return valuesArray[index]; 11518 }; 11519 } 11520 11521 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js 11522 var eraValues = { 11523 narrow: ["B", "A"], 11524 abbreviated: ["BC", "AD"], 11525 wide: ["Before Christ", "Anno Domini"] 11526 }; 11527 var quarterValues = { 11528 narrow: ["1", "2", "3", "4"], 11529 abbreviated: ["Q1", "Q2", "Q3", "Q4"], 11530 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] 11531 }; 11532 var monthValues = { 11533 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], 11534 abbreviated: [ 11535 "Jan", 11536 "Feb", 11537 "Mar", 11538 "Apr", 11539 "May", 11540 "Jun", 11541 "Jul", 11542 "Aug", 11543 "Sep", 11544 "Oct", 11545 "Nov", 11546 "Dec" 11547 ], 11548 wide: [ 11549 "January", 11550 "February", 11551 "March", 11552 "April", 11553 "May", 11554 "June", 11555 "July", 11556 "August", 11557 "September", 11558 "October", 11559 "November", 11560 "December" 11561 ] 11562 }; 11563 var dayValues = { 11564 narrow: ["S", "M", "T", "W", "T", "F", "S"], 11565 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 11566 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 11567 wide: [ 11568 "Sunday", 11569 "Monday", 11570 "Tuesday", 11571 "Wednesday", 11572 "Thursday", 11573 "Friday", 11574 "Saturday" 11575 ] 11576 }; 11577 var dayPeriodValues = { 11578 narrow: { 11579 am: "a", 11580 pm: "p", 11581 midnight: "mi", 11582 noon: "n", 11583 morning: "morning", 11584 afternoon: "afternoon", 11585 evening: "evening", 11586 night: "night" 11587 }, 11588 abbreviated: { 11589 am: "AM", 11590 pm: "PM", 11591 midnight: "midnight", 11592 noon: "noon", 11593 morning: "morning", 11594 afternoon: "afternoon", 11595 evening: "evening", 11596 night: "night" 11597 }, 11598 wide: { 11599 am: "a.m.", 11600 pm: "p.m.", 11601 midnight: "midnight", 11602 noon: "noon", 11603 morning: "morning", 11604 afternoon: "afternoon", 11605 evening: "evening", 11606 night: "night" 11607 } 11608 }; 11609 var formattingDayPeriodValues = { 11610 narrow: { 11611 am: "a", 11612 pm: "p", 11613 midnight: "mi", 11614 noon: "n", 11615 morning: "in the morning", 11616 afternoon: "in the afternoon", 11617 evening: "in the evening", 11618 night: "at night" 11619 }, 11620 abbreviated: { 11621 am: "AM", 11622 pm: "PM", 11623 midnight: "midnight", 11624 noon: "noon", 11625 morning: "in the morning", 11626 afternoon: "in the afternoon", 11627 evening: "in the evening", 11628 night: "at night" 11629 }, 11630 wide: { 11631 am: "a.m.", 11632 pm: "p.m.", 11633 midnight: "midnight", 11634 noon: "noon", 11635 morning: "in the morning", 11636 afternoon: "in the afternoon", 11637 evening: "in the evening", 11638 night: "at night" 11639 } 11640 }; 11641 var ordinalNumber = (dirtyNumber, _options) => { 11642 const number = Number(dirtyNumber); 11643 const rem100 = number % 100; 11644 if (rem100 > 20 || rem100 < 10) { 11645 switch (rem100 % 10) { 11646 case 1: 11647 return number + "st"; 11648 case 2: 11649 return number + "nd"; 11650 case 3: 11651 return number + "rd"; 11652 } 11653 } 11654 return number + "th"; 11655 }; 11656 var localize = { 11657 ordinalNumber, 11658 era: buildLocalizeFn({ 11659 values: eraValues, 11660 defaultWidth: "wide" 11661 }), 11662 quarter: buildLocalizeFn({ 11663 values: quarterValues, 11664 defaultWidth: "wide", 11665 argumentCallback: (quarter) => quarter - 1 11666 }), 11667 month: buildLocalizeFn({ 11668 values: monthValues, 11669 defaultWidth: "wide" 11670 }), 11671 day: buildLocalizeFn({ 11672 values: dayValues, 11673 defaultWidth: "wide" 11674 }), 11675 dayPeriod: buildLocalizeFn({ 11676 values: dayPeriodValues, 11677 defaultWidth: "wide", 11678 formattingValues: formattingDayPeriodValues, 11679 defaultFormattingWidth: "wide" 11680 }) 11681 }; 11682 11683 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js 11684 function buildMatchFn(args) { 11685 return (string, options = {}) => { 11686 const width = options.width; 11687 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; 11688 const matchResult = string.match(matchPattern); 11689 if (!matchResult) { 11690 return null; 11691 } 11692 const matchedString = matchResult[0]; 11693 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; 11694 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : ( 11695 // [TODO] -- I challenge you to fix the type 11696 findKey(parsePatterns, (pattern) => pattern.test(matchedString)) 11697 ); 11698 let value; 11699 value = args.valueCallback ? args.valueCallback(key) : key; 11700 value = options.valueCallback ? ( 11701 // [TODO] -- I challenge you to fix the type 11702 options.valueCallback(value) 11703 ) : value; 11704 const rest = string.slice(matchedString.length); 11705 return { value, rest }; 11706 }; 11707 } 11708 function findKey(object, predicate) { 11709 for (const key in object) { 11710 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) { 11711 return key; 11712 } 11713 } 11714 return void 0; 11715 } 11716 function findIndex(array, predicate) { 11717 for (let key = 0; key < array.length; key++) { 11718 if (predicate(array[key])) { 11719 return key; 11720 } 11721 } 11722 return void 0; 11723 } 11724 11725 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js 11726 function buildMatchPatternFn(args) { 11727 return (string, options = {}) => { 11728 const matchResult = string.match(args.matchPattern); 11729 if (!matchResult) return null; 11730 const matchedString = matchResult[0]; 11731 const parseResult = string.match(args.parsePattern); 11732 if (!parseResult) return null; 11733 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; 11734 value = options.valueCallback ? options.valueCallback(value) : value; 11735 const rest = string.slice(matchedString.length); 11736 return { value, rest }; 11737 }; 11738 } 11739 11740 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js 11741 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; 11742 var parseOrdinalNumberPattern = /\d+/i; 11743 var matchEraPatterns = { 11744 narrow: /^(b|a)/i, 11745 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, 11746 wide: /^(before christ|before common era|anno domini|common era)/i 11747 }; 11748 var parseEraPatterns = { 11749 any: [/^b/i, /^(a|c)/i] 11750 }; 11751 var matchQuarterPatterns = { 11752 narrow: /^[1234]/i, 11753 abbreviated: /^q[1234]/i, 11754 wide: /^[1234](th|st|nd|rd)? quarter/i 11755 }; 11756 var parseQuarterPatterns = { 11757 any: [/1/i, /2/i, /3/i, /4/i] 11758 }; 11759 var matchMonthPatterns = { 11760 narrow: /^[jfmasond]/i, 11761 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, 11762 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i 11763 }; 11764 var parseMonthPatterns = { 11765 narrow: [ 11766 /^j/i, 11767 /^f/i, 11768 /^m/i, 11769 /^a/i, 11770 /^m/i, 11771 /^j/i, 11772 /^j/i, 11773 /^a/i, 11774 /^s/i, 11775 /^o/i, 11776 /^n/i, 11777 /^d/i 11778 ], 11779 any: [ 11780 /^ja/i, 11781 /^f/i, 11782 /^mar/i, 11783 /^ap/i, 11784 /^may/i, 11785 /^jun/i, 11786 /^jul/i, 11787 /^au/i, 11788 /^s/i, 11789 /^o/i, 11790 /^n/i, 11791 /^d/i 11792 ] 11793 }; 11794 var matchDayPatterns = { 11795 narrow: /^[smtwf]/i, 11796 short: /^(su|mo|tu|we|th|fr|sa)/i, 11797 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, 11798 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i 11799 }; 11800 var parseDayPatterns = { 11801 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], 11802 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] 11803 }; 11804 var matchDayPeriodPatterns = { 11805 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, 11806 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i 11807 }; 11808 var parseDayPeriodPatterns = { 11809 any: { 11810 am: /^a/i, 11811 pm: /^p/i, 11812 midnight: /^mi/i, 11813 noon: /^no/i, 11814 morning: /morning/i, 11815 afternoon: /afternoon/i, 11816 evening: /evening/i, 11817 night: /night/i 11818 } 11819 }; 11820 var match = { 11821 ordinalNumber: buildMatchPatternFn({ 11822 matchPattern: matchOrdinalNumberPattern, 11823 parsePattern: parseOrdinalNumberPattern, 11824 valueCallback: (value) => parseInt(value, 10) 11825 }), 11826 era: buildMatchFn({ 11827 matchPatterns: matchEraPatterns, 11828 defaultMatchWidth: "wide", 11829 parsePatterns: parseEraPatterns, 11830 defaultParseWidth: "any" 11831 }), 11832 quarter: buildMatchFn({ 11833 matchPatterns: matchQuarterPatterns, 11834 defaultMatchWidth: "wide", 11835 parsePatterns: parseQuarterPatterns, 11836 defaultParseWidth: "any", 11837 valueCallback: (index) => index + 1 11838 }), 11839 month: buildMatchFn({ 11840 matchPatterns: matchMonthPatterns, 11841 defaultMatchWidth: "wide", 11842 parsePatterns: parseMonthPatterns, 11843 defaultParseWidth: "any" 11844 }), 11845 day: buildMatchFn({ 11846 matchPatterns: matchDayPatterns, 11847 defaultMatchWidth: "wide", 11848 parsePatterns: parseDayPatterns, 11849 defaultParseWidth: "any" 11850 }), 11851 dayPeriod: buildMatchFn({ 11852 matchPatterns: matchDayPeriodPatterns, 11853 defaultMatchWidth: "any", 11854 parsePatterns: parseDayPeriodPatterns, 11855 defaultParseWidth: "any" 11856 }) 11857 }; 11858 11859 // packages/dataviews/node_modules/date-fns/locale/en-US.js 11860 var enUS = { 11861 code: "en-US", 11862 formatDistance, 11863 formatLong, 11864 formatRelative, 11865 localize, 11866 match, 11867 options: { 11868 weekStartsOn: 0, 11869 firstWeekContainsDate: 1 11870 } 11871 }; 11872 11873 // packages/dataviews/node_modules/date-fns/getDayOfYear.js 11874 function getDayOfYear(date, options) { 11875 const _date = toDate(date, options?.in); 11876 const diff = differenceInCalendarDays(_date, startOfYear(_date)); 11877 const dayOfYear = diff + 1; 11878 return dayOfYear; 11879 } 11880 11881 // packages/dataviews/node_modules/date-fns/getISOWeek.js 11882 function getISOWeek(date, options) { 11883 const _date = toDate(date, options?.in); 11884 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date); 11885 return Math.round(diff / millisecondsInWeek) + 1; 11886 } 11887 11888 // packages/dataviews/node_modules/date-fns/getWeekYear.js 11889 function getWeekYear(date, options) { 11890 const _date = toDate(date, options?.in); 11891 const year = _date.getFullYear(); 11892 const defaultOptions2 = getDefaultOptions(); 11893 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 11894 const firstWeekOfNextYear = constructFrom(options?.in || date, 0); 11895 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); 11896 firstWeekOfNextYear.setHours(0, 0, 0, 0); 11897 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options); 11898 const firstWeekOfThisYear = constructFrom(options?.in || date, 0); 11899 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); 11900 firstWeekOfThisYear.setHours(0, 0, 0, 0); 11901 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options); 11902 if (+_date >= +startOfNextYear) { 11903 return year + 1; 11904 } else if (+_date >= +startOfThisYear) { 11905 return year; 11906 } else { 11907 return year - 1; 11908 } 11909 } 11910 11911 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js 11912 function startOfWeekYear(date, options) { 11913 const defaultOptions2 = getDefaultOptions(); 11914 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 11915 const year = getWeekYear(date, options); 11916 const firstWeek = constructFrom(options?.in || date, 0); 11917 firstWeek.setFullYear(year, 0, firstWeekContainsDate); 11918 firstWeek.setHours(0, 0, 0, 0); 11919 const _date = startOfWeek(firstWeek, options); 11920 return _date; 11921 } 11922 11923 // packages/dataviews/node_modules/date-fns/getWeek.js 11924 function getWeek(date, options) { 11925 const _date = toDate(date, options?.in); 11926 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options); 11927 return Math.round(diff / millisecondsInWeek) + 1; 11928 } 11929 11930 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js 11931 function addLeadingZeros(number, targetLength) { 11932 const sign = number < 0 ? "-" : ""; 11933 const output = Math.abs(number).toString().padStart(targetLength, "0"); 11934 return sign + output; 11935 } 11936 11937 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js 11938 var lightFormatters = { 11939 // Year 11940 y(date, token) { 11941 const signedYear = date.getFullYear(); 11942 const year = signedYear > 0 ? signedYear : 1 - signedYear; 11943 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length); 11944 }, 11945 // Month 11946 M(date, token) { 11947 const month = date.getMonth(); 11948 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2); 11949 }, 11950 // Day of the month 11951 d(date, token) { 11952 return addLeadingZeros(date.getDate(), token.length); 11953 }, 11954 // AM or PM 11955 a(date, token) { 11956 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am"; 11957 switch (token) { 11958 case "a": 11959 case "aa": 11960 return dayPeriodEnumValue.toUpperCase(); 11961 case "aaa": 11962 return dayPeriodEnumValue; 11963 case "aaaaa": 11964 return dayPeriodEnumValue[0]; 11965 case "aaaa": 11966 default: 11967 return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; 11968 } 11969 }, 11970 // Hour [1-12] 11971 h(date, token) { 11972 return addLeadingZeros(date.getHours() % 12 || 12, token.length); 11973 }, 11974 // Hour [0-23] 11975 H(date, token) { 11976 return addLeadingZeros(date.getHours(), token.length); 11977 }, 11978 // Minute 11979 m(date, token) { 11980 return addLeadingZeros(date.getMinutes(), token.length); 11981 }, 11982 // Second 11983 s(date, token) { 11984 return addLeadingZeros(date.getSeconds(), token.length); 11985 }, 11986 // Fraction of second 11987 S(date, token) { 11988 const numberOfDigits = token.length; 11989 const milliseconds = date.getMilliseconds(); 11990 const fractionalSeconds = Math.trunc( 11991 milliseconds * Math.pow(10, numberOfDigits - 3) 11992 ); 11993 return addLeadingZeros(fractionalSeconds, token.length); 11994 } 11995 }; 11996 11997 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js 11998 var dayPeriodEnum = { 11999 am: "am", 12000 pm: "pm", 12001 midnight: "midnight", 12002 noon: "noon", 12003 morning: "morning", 12004 afternoon: "afternoon", 12005 evening: "evening", 12006 night: "night" 12007 }; 12008 var formatters = { 12009 // Era 12010 G: function(date, token, localize2) { 12011 const era = date.getFullYear() > 0 ? 1 : 0; 12012 switch (token) { 12013 // AD, BC 12014 case "G": 12015 case "GG": 12016 case "GGG": 12017 return localize2.era(era, { width: "abbreviated" }); 12018 // A, B 12019 case "GGGGG": 12020 return localize2.era(era, { width: "narrow" }); 12021 // Anno Domini, Before Christ 12022 case "GGGG": 12023 default: 12024 return localize2.era(era, { width: "wide" }); 12025 } 12026 }, 12027 // Year 12028 y: function(date, token, localize2) { 12029 if (token === "yo") { 12030 const signedYear = date.getFullYear(); 12031 const year = signedYear > 0 ? signedYear : 1 - signedYear; 12032 return localize2.ordinalNumber(year, { unit: "year" }); 12033 } 12034 return lightFormatters.y(date, token); 12035 }, 12036 // Local week-numbering year 12037 Y: function(date, token, localize2, options) { 12038 const signedWeekYear = getWeekYear(date, options); 12039 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; 12040 if (token === "YY") { 12041 const twoDigitYear = weekYear % 100; 12042 return addLeadingZeros(twoDigitYear, 2); 12043 } 12044 if (token === "Yo") { 12045 return localize2.ordinalNumber(weekYear, { unit: "year" }); 12046 } 12047 return addLeadingZeros(weekYear, token.length); 12048 }, 12049 // ISO week-numbering year 12050 R: function(date, token) { 12051 const isoWeekYear = getISOWeekYear(date); 12052 return addLeadingZeros(isoWeekYear, token.length); 12053 }, 12054 // Extended year. This is a single number designating the year of this calendar system. 12055 // The main difference between `y` and `u` localizers are B.C. years: 12056 // | Year | `y` | `u` | 12057 // |------|-----|-----| 12058 // | AC 1 | 1 | 1 | 12059 // | BC 1 | 1 | 0 | 12060 // | BC 2 | 2 | -1 | 12061 // Also `yy` always returns the last two digits of a year, 12062 // while `uu` pads single digit years to 2 characters and returns other years unchanged. 12063 u: function(date, token) { 12064 const year = date.getFullYear(); 12065 return addLeadingZeros(year, token.length); 12066 }, 12067 // Quarter 12068 Q: function(date, token, localize2) { 12069 const quarter = Math.ceil((date.getMonth() + 1) / 3); 12070 switch (token) { 12071 // 1, 2, 3, 4 12072 case "Q": 12073 return String(quarter); 12074 // 01, 02, 03, 04 12075 case "QQ": 12076 return addLeadingZeros(quarter, 2); 12077 // 1st, 2nd, 3rd, 4th 12078 case "Qo": 12079 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 12080 // Q1, Q2, Q3, Q4 12081 case "QQQ": 12082 return localize2.quarter(quarter, { 12083 width: "abbreviated", 12084 context: "formatting" 12085 }); 12086 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 12087 case "QQQQQ": 12088 return localize2.quarter(quarter, { 12089 width: "narrow", 12090 context: "formatting" 12091 }); 12092 // 1st quarter, 2nd quarter, ... 12093 case "QQQQ": 12094 default: 12095 return localize2.quarter(quarter, { 12096 width: "wide", 12097 context: "formatting" 12098 }); 12099 } 12100 }, 12101 // Stand-alone quarter 12102 q: function(date, token, localize2) { 12103 const quarter = Math.ceil((date.getMonth() + 1) / 3); 12104 switch (token) { 12105 // 1, 2, 3, 4 12106 case "q": 12107 return String(quarter); 12108 // 01, 02, 03, 04 12109 case "qq": 12110 return addLeadingZeros(quarter, 2); 12111 // 1st, 2nd, 3rd, 4th 12112 case "qo": 12113 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 12114 // Q1, Q2, Q3, Q4 12115 case "qqq": 12116 return localize2.quarter(quarter, { 12117 width: "abbreviated", 12118 context: "standalone" 12119 }); 12120 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 12121 case "qqqqq": 12122 return localize2.quarter(quarter, { 12123 width: "narrow", 12124 context: "standalone" 12125 }); 12126 // 1st quarter, 2nd quarter, ... 12127 case "qqqq": 12128 default: 12129 return localize2.quarter(quarter, { 12130 width: "wide", 12131 context: "standalone" 12132 }); 12133 } 12134 }, 12135 // Month 12136 M: function(date, token, localize2) { 12137 const month = date.getMonth(); 12138 switch (token) { 12139 case "M": 12140 case "MM": 12141 return lightFormatters.M(date, token); 12142 // 1st, 2nd, ..., 12th 12143 case "Mo": 12144 return localize2.ordinalNumber(month + 1, { unit: "month" }); 12145 // Jan, Feb, ..., Dec 12146 case "MMM": 12147 return localize2.month(month, { 12148 width: "abbreviated", 12149 context: "formatting" 12150 }); 12151 // J, F, ..., D 12152 case "MMMMM": 12153 return localize2.month(month, { 12154 width: "narrow", 12155 context: "formatting" 12156 }); 12157 // January, February, ..., December 12158 case "MMMM": 12159 default: 12160 return localize2.month(month, { width: "wide", context: "formatting" }); 12161 } 12162 }, 12163 // Stand-alone month 12164 L: function(date, token, localize2) { 12165 const month = date.getMonth(); 12166 switch (token) { 12167 // 1, 2, ..., 12 12168 case "L": 12169 return String(month + 1); 12170 // 01, 02, ..., 12 12171 case "LL": 12172 return addLeadingZeros(month + 1, 2); 12173 // 1st, 2nd, ..., 12th 12174 case "Lo": 12175 return localize2.ordinalNumber(month + 1, { unit: "month" }); 12176 // Jan, Feb, ..., Dec 12177 case "LLL": 12178 return localize2.month(month, { 12179 width: "abbreviated", 12180 context: "standalone" 12181 }); 12182 // J, F, ..., D 12183 case "LLLLL": 12184 return localize2.month(month, { 12185 width: "narrow", 12186 context: "standalone" 12187 }); 12188 // January, February, ..., December 12189 case "LLLL": 12190 default: 12191 return localize2.month(month, { width: "wide", context: "standalone" }); 12192 } 12193 }, 12194 // Local week of year 12195 w: function(date, token, localize2, options) { 12196 const week = getWeek(date, options); 12197 if (token === "wo") { 12198 return localize2.ordinalNumber(week, { unit: "week" }); 12199 } 12200 return addLeadingZeros(week, token.length); 12201 }, 12202 // ISO week of year 12203 I: function(date, token, localize2) { 12204 const isoWeek = getISOWeek(date); 12205 if (token === "Io") { 12206 return localize2.ordinalNumber(isoWeek, { unit: "week" }); 12207 } 12208 return addLeadingZeros(isoWeek, token.length); 12209 }, 12210 // Day of the month 12211 d: function(date, token, localize2) { 12212 if (token === "do") { 12213 return localize2.ordinalNumber(date.getDate(), { unit: "date" }); 12214 } 12215 return lightFormatters.d(date, token); 12216 }, 12217 // Day of year 12218 D: function(date, token, localize2) { 12219 const dayOfYear = getDayOfYear(date); 12220 if (token === "Do") { 12221 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" }); 12222 } 12223 return addLeadingZeros(dayOfYear, token.length); 12224 }, 12225 // Day of week 12226 E: function(date, token, localize2) { 12227 const dayOfWeek = date.getDay(); 12228 switch (token) { 12229 // Tue 12230 case "E": 12231 case "EE": 12232 case "EEE": 12233 return localize2.day(dayOfWeek, { 12234 width: "abbreviated", 12235 context: "formatting" 12236 }); 12237 // T 12238 case "EEEEE": 12239 return localize2.day(dayOfWeek, { 12240 width: "narrow", 12241 context: "formatting" 12242 }); 12243 // Tu 12244 case "EEEEEE": 12245 return localize2.day(dayOfWeek, { 12246 width: "short", 12247 context: "formatting" 12248 }); 12249 // Tuesday 12250 case "EEEE": 12251 default: 12252 return localize2.day(dayOfWeek, { 12253 width: "wide", 12254 context: "formatting" 12255 }); 12256 } 12257 }, 12258 // Local day of week 12259 e: function(date, token, localize2, options) { 12260 const dayOfWeek = date.getDay(); 12261 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 12262 switch (token) { 12263 // Numerical value (Nth day of week with current locale or weekStartsOn) 12264 case "e": 12265 return String(localDayOfWeek); 12266 // Padded numerical value 12267 case "ee": 12268 return addLeadingZeros(localDayOfWeek, 2); 12269 // 1st, 2nd, ..., 7th 12270 case "eo": 12271 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 12272 case "eee": 12273 return localize2.day(dayOfWeek, { 12274 width: "abbreviated", 12275 context: "formatting" 12276 }); 12277 // T 12278 case "eeeee": 12279 return localize2.day(dayOfWeek, { 12280 width: "narrow", 12281 context: "formatting" 12282 }); 12283 // Tu 12284 case "eeeeee": 12285 return localize2.day(dayOfWeek, { 12286 width: "short", 12287 context: "formatting" 12288 }); 12289 // Tuesday 12290 case "eeee": 12291 default: 12292 return localize2.day(dayOfWeek, { 12293 width: "wide", 12294 context: "formatting" 12295 }); 12296 } 12297 }, 12298 // Stand-alone local day of week 12299 c: function(date, token, localize2, options) { 12300 const dayOfWeek = date.getDay(); 12301 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 12302 switch (token) { 12303 // Numerical value (same as in `e`) 12304 case "c": 12305 return String(localDayOfWeek); 12306 // Padded numerical value 12307 case "cc": 12308 return addLeadingZeros(localDayOfWeek, token.length); 12309 // 1st, 2nd, ..., 7th 12310 case "co": 12311 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 12312 case "ccc": 12313 return localize2.day(dayOfWeek, { 12314 width: "abbreviated", 12315 context: "standalone" 12316 }); 12317 // T 12318 case "ccccc": 12319 return localize2.day(dayOfWeek, { 12320 width: "narrow", 12321 context: "standalone" 12322 }); 12323 // Tu 12324 case "cccccc": 12325 return localize2.day(dayOfWeek, { 12326 width: "short", 12327 context: "standalone" 12328 }); 12329 // Tuesday 12330 case "cccc": 12331 default: 12332 return localize2.day(dayOfWeek, { 12333 width: "wide", 12334 context: "standalone" 12335 }); 12336 } 12337 }, 12338 // ISO day of week 12339 i: function(date, token, localize2) { 12340 const dayOfWeek = date.getDay(); 12341 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; 12342 switch (token) { 12343 // 2 12344 case "i": 12345 return String(isoDayOfWeek); 12346 // 02 12347 case "ii": 12348 return addLeadingZeros(isoDayOfWeek, token.length); 12349 // 2nd 12350 case "io": 12351 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" }); 12352 // Tue 12353 case "iii": 12354 return localize2.day(dayOfWeek, { 12355 width: "abbreviated", 12356 context: "formatting" 12357 }); 12358 // T 12359 case "iiiii": 12360 return localize2.day(dayOfWeek, { 12361 width: "narrow", 12362 context: "formatting" 12363 }); 12364 // Tu 12365 case "iiiiii": 12366 return localize2.day(dayOfWeek, { 12367 width: "short", 12368 context: "formatting" 12369 }); 12370 // Tuesday 12371 case "iiii": 12372 default: 12373 return localize2.day(dayOfWeek, { 12374 width: "wide", 12375 context: "formatting" 12376 }); 12377 } 12378 }, 12379 // AM or PM 12380 a: function(date, token, localize2) { 12381 const hours = date.getHours(); 12382 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 12383 switch (token) { 12384 case "a": 12385 case "aa": 12386 return localize2.dayPeriod(dayPeriodEnumValue, { 12387 width: "abbreviated", 12388 context: "formatting" 12389 }); 12390 case "aaa": 12391 return localize2.dayPeriod(dayPeriodEnumValue, { 12392 width: "abbreviated", 12393 context: "formatting" 12394 }).toLowerCase(); 12395 case "aaaaa": 12396 return localize2.dayPeriod(dayPeriodEnumValue, { 12397 width: "narrow", 12398 context: "formatting" 12399 }); 12400 case "aaaa": 12401 default: 12402 return localize2.dayPeriod(dayPeriodEnumValue, { 12403 width: "wide", 12404 context: "formatting" 12405 }); 12406 } 12407 }, 12408 // AM, PM, midnight, noon 12409 b: function(date, token, localize2) { 12410 const hours = date.getHours(); 12411 let dayPeriodEnumValue; 12412 if (hours === 12) { 12413 dayPeriodEnumValue = dayPeriodEnum.noon; 12414 } else if (hours === 0) { 12415 dayPeriodEnumValue = dayPeriodEnum.midnight; 12416 } else { 12417 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 12418 } 12419 switch (token) { 12420 case "b": 12421 case "bb": 12422 return localize2.dayPeriod(dayPeriodEnumValue, { 12423 width: "abbreviated", 12424 context: "formatting" 12425 }); 12426 case "bbb": 12427 return localize2.dayPeriod(dayPeriodEnumValue, { 12428 width: "abbreviated", 12429 context: "formatting" 12430 }).toLowerCase(); 12431 case "bbbbb": 12432 return localize2.dayPeriod(dayPeriodEnumValue, { 12433 width: "narrow", 12434 context: "formatting" 12435 }); 12436 case "bbbb": 12437 default: 12438 return localize2.dayPeriod(dayPeriodEnumValue, { 12439 width: "wide", 12440 context: "formatting" 12441 }); 12442 } 12443 }, 12444 // in the morning, in the afternoon, in the evening, at night 12445 B: function(date, token, localize2) { 12446 const hours = date.getHours(); 12447 let dayPeriodEnumValue; 12448 if (hours >= 17) { 12449 dayPeriodEnumValue = dayPeriodEnum.evening; 12450 } else if (hours >= 12) { 12451 dayPeriodEnumValue = dayPeriodEnum.afternoon; 12452 } else if (hours >= 4) { 12453 dayPeriodEnumValue = dayPeriodEnum.morning; 12454 } else { 12455 dayPeriodEnumValue = dayPeriodEnum.night; 12456 } 12457 switch (token) { 12458 case "B": 12459 case "BB": 12460 case "BBB": 12461 return localize2.dayPeriod(dayPeriodEnumValue, { 12462 width: "abbreviated", 12463 context: "formatting" 12464 }); 12465 case "BBBBB": 12466 return localize2.dayPeriod(dayPeriodEnumValue, { 12467 width: "narrow", 12468 context: "formatting" 12469 }); 12470 case "BBBB": 12471 default: 12472 return localize2.dayPeriod(dayPeriodEnumValue, { 12473 width: "wide", 12474 context: "formatting" 12475 }); 12476 } 12477 }, 12478 // Hour [1-12] 12479 h: function(date, token, localize2) { 12480 if (token === "ho") { 12481 let hours = date.getHours() % 12; 12482 if (hours === 0) hours = 12; 12483 return localize2.ordinalNumber(hours, { unit: "hour" }); 12484 } 12485 return lightFormatters.h(date, token); 12486 }, 12487 // Hour [0-23] 12488 H: function(date, token, localize2) { 12489 if (token === "Ho") { 12490 return localize2.ordinalNumber(date.getHours(), { unit: "hour" }); 12491 } 12492 return lightFormatters.H(date, token); 12493 }, 12494 // Hour [0-11] 12495 K: function(date, token, localize2) { 12496 const hours = date.getHours() % 12; 12497 if (token === "Ko") { 12498 return localize2.ordinalNumber(hours, { unit: "hour" }); 12499 } 12500 return addLeadingZeros(hours, token.length); 12501 }, 12502 // Hour [1-24] 12503 k: function(date, token, localize2) { 12504 let hours = date.getHours(); 12505 if (hours === 0) hours = 24; 12506 if (token === "ko") { 12507 return localize2.ordinalNumber(hours, { unit: "hour" }); 12508 } 12509 return addLeadingZeros(hours, token.length); 12510 }, 12511 // Minute 12512 m: function(date, token, localize2) { 12513 if (token === "mo") { 12514 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" }); 12515 } 12516 return lightFormatters.m(date, token); 12517 }, 12518 // Second 12519 s: function(date, token, localize2) { 12520 if (token === "so") { 12521 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" }); 12522 } 12523 return lightFormatters.s(date, token); 12524 }, 12525 // Fraction of second 12526 S: function(date, token) { 12527 return lightFormatters.S(date, token); 12528 }, 12529 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) 12530 X: function(date, token, _localize) { 12531 const timezoneOffset = date.getTimezoneOffset(); 12532 if (timezoneOffset === 0) { 12533 return "Z"; 12534 } 12535 switch (token) { 12536 // Hours and optional minutes 12537 case "X": 12538 return formatTimezoneWithOptionalMinutes(timezoneOffset); 12539 // Hours, minutes and optional seconds without `:` delimiter 12540 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 12541 // so this token always has the same output as `XX` 12542 case "XXXX": 12543 case "XX": 12544 return formatTimezone(timezoneOffset); 12545 // Hours, minutes and optional seconds with `:` delimiter 12546 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 12547 // so this token always has the same output as `XXX` 12548 case "XXXXX": 12549 case "XXX": 12550 // Hours and minutes with `:` delimiter 12551 default: 12552 return formatTimezone(timezoneOffset, ":"); 12553 } 12554 }, 12555 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) 12556 x: function(date, token, _localize) { 12557 const timezoneOffset = date.getTimezoneOffset(); 12558 switch (token) { 12559 // Hours and optional minutes 12560 case "x": 12561 return formatTimezoneWithOptionalMinutes(timezoneOffset); 12562 // Hours, minutes and optional seconds without `:` delimiter 12563 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 12564 // so this token always has the same output as `xx` 12565 case "xxxx": 12566 case "xx": 12567 return formatTimezone(timezoneOffset); 12568 // Hours, minutes and optional seconds with `:` delimiter 12569 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 12570 // so this token always has the same output as `xxx` 12571 case "xxxxx": 12572 case "xxx": 12573 // Hours and minutes with `:` delimiter 12574 default: 12575 return formatTimezone(timezoneOffset, ":"); 12576 } 12577 }, 12578 // Timezone (GMT) 12579 O: function(date, token, _localize) { 12580 const timezoneOffset = date.getTimezoneOffset(); 12581 switch (token) { 12582 // Short 12583 case "O": 12584 case "OO": 12585 case "OOO": 12586 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 12587 // Long 12588 case "OOOO": 12589 default: 12590 return "GMT" + formatTimezone(timezoneOffset, ":"); 12591 } 12592 }, 12593 // Timezone (specific non-location) 12594 z: function(date, token, _localize) { 12595 const timezoneOffset = date.getTimezoneOffset(); 12596 switch (token) { 12597 // Short 12598 case "z": 12599 case "zz": 12600 case "zzz": 12601 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 12602 // Long 12603 case "zzzz": 12604 default: 12605 return "GMT" + formatTimezone(timezoneOffset, ":"); 12606 } 12607 }, 12608 // Seconds timestamp 12609 t: function(date, token, _localize) { 12610 const timestamp = Math.trunc(+date / 1e3); 12611 return addLeadingZeros(timestamp, token.length); 12612 }, 12613 // Milliseconds timestamp 12614 T: function(date, token, _localize) { 12615 return addLeadingZeros(+date, token.length); 12616 } 12617 }; 12618 function formatTimezoneShort(offset, delimiter = "") { 12619 const sign = offset > 0 ? "-" : "+"; 12620 const absOffset = Math.abs(offset); 12621 const hours = Math.trunc(absOffset / 60); 12622 const minutes = absOffset % 60; 12623 if (minutes === 0) { 12624 return sign + String(hours); 12625 } 12626 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2); 12627 } 12628 function formatTimezoneWithOptionalMinutes(offset, delimiter) { 12629 if (offset % 60 === 0) { 12630 const sign = offset > 0 ? "-" : "+"; 12631 return sign + addLeadingZeros(Math.abs(offset) / 60, 2); 12632 } 12633 return formatTimezone(offset, delimiter); 12634 } 12635 function formatTimezone(offset, delimiter = "") { 12636 const sign = offset > 0 ? "-" : "+"; 12637 const absOffset = Math.abs(offset); 12638 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2); 12639 const minutes = addLeadingZeros(absOffset % 60, 2); 12640 return sign + hours + delimiter + minutes; 12641 } 12642 12643 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js 12644 var dateLongFormatter = (pattern, formatLong2) => { 12645 switch (pattern) { 12646 case "P": 12647 return formatLong2.date({ width: "short" }); 12648 case "PP": 12649 return formatLong2.date({ width: "medium" }); 12650 case "PPP": 12651 return formatLong2.date({ width: "long" }); 12652 case "PPPP": 12653 default: 12654 return formatLong2.date({ width: "full" }); 12655 } 12656 }; 12657 var timeLongFormatter = (pattern, formatLong2) => { 12658 switch (pattern) { 12659 case "p": 12660 return formatLong2.time({ width: "short" }); 12661 case "pp": 12662 return formatLong2.time({ width: "medium" }); 12663 case "ppp": 12664 return formatLong2.time({ width: "long" }); 12665 case "pppp": 12666 default: 12667 return formatLong2.time({ width: "full" }); 12668 } 12669 }; 12670 var dateTimeLongFormatter = (pattern, formatLong2) => { 12671 const matchResult = pattern.match(/(P+)(p+)?/) || []; 12672 const datePattern = matchResult[1]; 12673 const timePattern = matchResult[2]; 12674 if (!timePattern) { 12675 return dateLongFormatter(pattern, formatLong2); 12676 } 12677 let dateTimeFormat; 12678 switch (datePattern) { 12679 case "P": 12680 dateTimeFormat = formatLong2.dateTime({ width: "short" }); 12681 break; 12682 case "PP": 12683 dateTimeFormat = formatLong2.dateTime({ width: "medium" }); 12684 break; 12685 case "PPP": 12686 dateTimeFormat = formatLong2.dateTime({ width: "long" }); 12687 break; 12688 case "PPPP": 12689 default: 12690 dateTimeFormat = formatLong2.dateTime({ width: "full" }); 12691 break; 12692 } 12693 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); 12694 }; 12695 var longFormatters = { 12696 p: timeLongFormatter, 12697 P: dateTimeLongFormatter 12698 }; 12699 12700 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js 12701 var dayOfYearTokenRE = /^D+$/; 12702 var weekYearTokenRE = /^Y+$/; 12703 var throwTokens = ["D", "DD", "YY", "YYYY"]; 12704 function isProtectedDayOfYearToken(token) { 12705 return dayOfYearTokenRE.test(token); 12706 } 12707 function isProtectedWeekYearToken(token) { 12708 return weekYearTokenRE.test(token); 12709 } 12710 function warnOrThrowProtectedError(token, format6, input) { 12711 const _message = message(token, format6, input); 12712 console.warn(_message); 12713 if (throwTokens.includes(token)) throw new RangeError(_message); 12714 } 12715 function message(token, format6, input) { 12716 const subject = token[0] === "Y" ? "years" : "days of the month"; 12717 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`; 12718 } 12719 12720 // packages/dataviews/node_modules/date-fns/format.js 12721 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; 12722 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; 12723 var escapedStringRegExp = /^'([^]*?)'?$/; 12724 var doubleQuoteRegExp = /''/g; 12725 var unescapedLatinCharacterRegExp = /[a-zA-Z]/; 12726 function format(date, formatStr, options) { 12727 const defaultOptions2 = getDefaultOptions(); 12728 const locale = options?.locale ?? defaultOptions2.locale ?? enUS; 12729 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 12730 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 12731 const originalDate = toDate(date, options?.in); 12732 if (!isValid(originalDate)) { 12733 throw new RangeError("Invalid time value"); 12734 } 12735 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => { 12736 const firstCharacter = substring[0]; 12737 if (firstCharacter === "p" || firstCharacter === "P") { 12738 const longFormatter = longFormatters[firstCharacter]; 12739 return longFormatter(substring, locale.formatLong); 12740 } 12741 return substring; 12742 }).join("").match(formattingTokensRegExp).map((substring) => { 12743 if (substring === "''") { 12744 return { isToken: false, value: "'" }; 12745 } 12746 const firstCharacter = substring[0]; 12747 if (firstCharacter === "'") { 12748 return { isToken: false, value: cleanEscapedString(substring) }; 12749 } 12750 if (formatters[firstCharacter]) { 12751 return { isToken: true, value: substring }; 12752 } 12753 if (firstCharacter.match(unescapedLatinCharacterRegExp)) { 12754 throw new RangeError( 12755 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`" 12756 ); 12757 } 12758 return { isToken: false, value: substring }; 12759 }); 12760 if (locale.localize.preprocessor) { 12761 parts = locale.localize.preprocessor(originalDate, parts); 12762 } 12763 const formatterOptions = { 12764 firstWeekContainsDate, 12765 weekStartsOn, 12766 locale 12767 }; 12768 return parts.map((part) => { 12769 if (!part.isToken) return part.value; 12770 const token = part.value; 12771 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) { 12772 warnOrThrowProtectedError(token, formatStr, String(date)); 12773 } 12774 const formatter = formatters[token[0]]; 12775 return formatter(originalDate, token, locale.localize, formatterOptions); 12776 }).join(""); 12777 } 12778 function cleanEscapedString(input) { 12779 const matched = input.match(escapedStringRegExp); 12780 if (!matched) { 12781 return input; 12782 } 12783 return matched[1].replace(doubleQuoteRegExp, "'"); 12784 } 12785 12786 // packages/dataviews/node_modules/date-fns/subDays.js 12787 function subDays(date, amount, options) { 12788 return addDays(date, -amount, options); 12789 } 12790 12791 // packages/dataviews/node_modules/date-fns/subMonths.js 12792 function subMonths(date, amount, options) { 12793 return addMonths(date, -amount, options); 12794 } 12795 12796 // packages/dataviews/node_modules/date-fns/subYears.js 12797 function subYears(date, amount, options) { 12798 return addYears(date, -amount, options); 12799 } 12800 12801 // packages/dataviews/build-module/dataform-controls/datetime.js 12802 var import_components34 = __toESM(require_components()); 12803 var import_element39 = __toESM(require_element()); 12804 var import_i18n32 = __toESM(require_i18n()); 12805 var import_date2 = __toESM(require_date()); 12806 12807 // packages/dataviews/build-module/dataform-controls/utils/relative-date-control.js 12808 var import_components33 = __toESM(require_components()); 12809 var import_element38 = __toESM(require_element()); 12810 var import_i18n31 = __toESM(require_i18n()); 12811 var import_jsx_runtime74 = __toESM(require_jsx_runtime()); 12812 var TIME_UNITS_OPTIONS = { 12813 [OPERATOR_IN_THE_PAST]: [ 12814 { value: "days", label: (0, import_i18n31.__)("Days") }, 12815 { value: "weeks", label: (0, import_i18n31.__)("Weeks") }, 12816 { value: "months", label: (0, import_i18n31.__)("Months") }, 12817 { value: "years", label: (0, import_i18n31.__)("Years") } 12818 ], 12819 [OPERATOR_OVER]: [ 12820 { value: "days", label: (0, import_i18n31.__)("Days ago") }, 12821 { value: "weeks", label: (0, import_i18n31.__)("Weeks ago") }, 12822 { value: "months", label: (0, import_i18n31.__)("Months ago") }, 12823 { value: "years", label: (0, import_i18n31.__)("Years ago") } 12824 ] 12825 }; 12826 function RelativeDateControl({ 12827 className, 12828 data, 12829 field, 12830 onChange, 12831 hideLabelFromVision, 12832 operator 12833 }) { 12834 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"]; 12835 const { id, label, getValue, setValue } = field; 12836 const fieldValue = getValue({ item: data }); 12837 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {}; 12838 const onChangeValue = (0, import_element38.useCallback)( 12839 (newValue) => onChange( 12840 setValue({ 12841 item: data, 12842 value: { value: Number(newValue), unit } 12843 }) 12844 ), 12845 [onChange, setValue, data, unit] 12846 ); 12847 const onChangeUnit = (0, import_element38.useCallback)( 12848 (newUnit) => onChange( 12849 setValue({ 12850 item: data, 12851 value: { value: relValue, unit: newUnit } 12852 }) 12853 ), 12854 [onChange, setValue, data, relValue] 12855 ); 12856 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 12857 import_components33.BaseControl, 12858 { 12859 id, 12860 className: clsx_default(className, "dataviews-controls__relative-date"), 12861 label, 12862 hideLabelFromVision, 12863 children: /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_components33.__experimentalHStack, { spacing: 2.5, children: [ 12864 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 12865 import_components33.__experimentalNumberControl, 12866 { 12867 __next40pxDefaultSize: true, 12868 className: "dataviews-controls__relative-date-number", 12869 spinControls: "none", 12870 min: 1, 12871 step: 1, 12872 value: relValue, 12873 onChange: onChangeValue 12874 } 12875 ), 12876 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 12877 import_components33.SelectControl, 12878 { 12879 className: "dataviews-controls__relative-date-unit", 12880 __next40pxDefaultSize: true, 12881 label: (0, import_i18n31.__)("Unit"), 12882 value: unit, 12883 options, 12884 onChange: onChangeUnit, 12885 hideLabelFromVision: true 12886 } 12887 ) 12888 ] }) 12889 } 12890 ); 12891 } 12892 12893 // packages/dataviews/build-module/field-types/utils/parse-date-time.js 12894 var import_date = __toESM(require_date()); 12895 function parseDateTime(dateTimeString) { 12896 if (!dateTimeString) { 12897 return null; 12898 } 12899 const parsed = (0, import_date.getDate)(dateTimeString); 12900 return parsed && isValid(parsed) ? parsed : null; 12901 } 12902 12903 // packages/dataviews/build-module/dataform-controls/datetime.js 12904 var import_jsx_runtime75 = __toESM(require_jsx_runtime()); 12905 var { DateCalendar, ValidatedInputControl } = unlock(import_components34.privateApis); 12906 var formatDateTime = (date) => { 12907 if (!date) { 12908 return ""; 12909 } 12910 if (typeof date === "string") { 12911 return date; 12912 } 12913 return format(date, "yyyy-MM-dd'T'HH:mm"); 12914 }; 12915 function CalendarDateTimeControl({ 12916 data, 12917 field, 12918 onChange, 12919 hideLabelFromVision, 12920 validity 12921 }) { 12922 const { id, label, description, setValue, getValue, isValid: isValid2 } = field; 12923 const fieldValue = getValue({ item: data }); 12924 const value = typeof fieldValue === "string" ? fieldValue : void 0; 12925 const [calendarMonth, setCalendarMonth] = (0, import_element39.useState)(() => { 12926 const parsedDate = parseDateTime(value); 12927 return parsedDate || /* @__PURE__ */ new Date(); 12928 }); 12929 const inputControlRef = (0, import_element39.useRef)(null); 12930 const validationTimeoutRef = (0, import_element39.useRef)(); 12931 const previousFocusRef = (0, import_element39.useRef)(null); 12932 const onChangeCallback = (0, import_element39.useCallback)( 12933 (newValue) => onChange(setValue({ item: data, value: newValue })), 12934 [data, onChange, setValue] 12935 ); 12936 (0, import_element39.useEffect)(() => { 12937 return () => { 12938 if (validationTimeoutRef.current) { 12939 clearTimeout(validationTimeoutRef.current); 12940 } 12941 }; 12942 }, []); 12943 const onSelectDate = (0, import_element39.useCallback)( 12944 (newDate) => { 12945 let dateTimeValue; 12946 if (newDate) { 12947 let finalDateTime = newDate; 12948 if (value) { 12949 const currentDateTime = parseDateTime(value); 12950 if (currentDateTime) { 12951 finalDateTime = new Date(newDate); 12952 finalDateTime.setHours(currentDateTime.getHours()); 12953 finalDateTime.setMinutes( 12954 currentDateTime.getMinutes() 12955 ); 12956 } 12957 } 12958 dateTimeValue = finalDateTime.toISOString(); 12959 onChangeCallback(dateTimeValue); 12960 if (validationTimeoutRef.current) { 12961 clearTimeout(validationTimeoutRef.current); 12962 } 12963 } else { 12964 onChangeCallback(void 0); 12965 } 12966 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement; 12967 validationTimeoutRef.current = setTimeout(() => { 12968 if (inputControlRef.current) { 12969 inputControlRef.current.focus(); 12970 inputControlRef.current.blur(); 12971 onChangeCallback(dateTimeValue); 12972 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) { 12973 previousFocusRef.current.focus(); 12974 } 12975 } 12976 }, 0); 12977 }, 12978 [onChangeCallback, value] 12979 ); 12980 const handleManualDateTimeChange = (0, import_element39.useCallback)( 12981 (newValue) => { 12982 if (newValue) { 12983 const dateTime = new Date(newValue); 12984 onChangeCallback(dateTime.toISOString()); 12985 const parsedDate = parseDateTime(dateTime.toISOString()); 12986 if (parsedDate) { 12987 setCalendarMonth(parsedDate); 12988 } 12989 } else { 12990 onChangeCallback(void 0); 12991 } 12992 }, 12993 [onChangeCallback] 12994 ); 12995 const { format: fieldFormat } = field; 12996 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date2.getSettings)().l10n.startOfWeek; 12997 const { 12998 timezone: { string: timezoneString } 12999 } = (0, import_date2.getSettings)(); 13000 const displayLabel = isValid2?.required && !hideLabelFromVision ? `$label} (${(0, import_i18n32.__)("Required")})` : label; 13001 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13002 import_components34.BaseControl, 13003 { 13004 id, 13005 label: displayLabel, 13006 help: description, 13007 hideLabelFromVision, 13008 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_components34.__experimentalVStack, { spacing: 4, children: [ 13009 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13010 DateCalendar, 13011 { 13012 style: { width: "100%" }, 13013 selected: value ? parseDateTime(value) || void 0 : void 0, 13014 onSelect: onSelectDate, 13015 month: calendarMonth, 13016 onMonthChange: setCalendarMonth, 13017 timeZone: timezoneString || void 0, 13018 weekStartsOn 13019 } 13020 ), 13021 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13022 ValidatedInputControl, 13023 { 13024 ref: inputControlRef, 13025 __next40pxDefaultSize: true, 13026 required: !!isValid2?.required, 13027 customValidity: getCustomValidity(isValid2, validity), 13028 type: "datetime-local", 13029 label: (0, import_i18n32.__)("Date time"), 13030 hideLabelFromVision: true, 13031 value: value ? formatDateTime( 13032 parseDateTime(value) || void 0 13033 ) : "", 13034 onChange: handleManualDateTimeChange 13035 } 13036 ) 13037 ] }) 13038 } 13039 ); 13040 } 13041 function DateTime({ 13042 data, 13043 field, 13044 onChange, 13045 hideLabelFromVision, 13046 operator, 13047 validity 13048 }) { 13049 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 13050 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13051 RelativeDateControl, 13052 { 13053 className: "dataviews-controls__datetime", 13054 data, 13055 field, 13056 onChange, 13057 hideLabelFromVision, 13058 operator 13059 } 13060 ); 13061 } 13062 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 13063 CalendarDateTimeControl, 13064 { 13065 data, 13066 field, 13067 onChange, 13068 hideLabelFromVision, 13069 validity 13070 } 13071 ); 13072 } 13073 13074 // packages/dataviews/build-module/dataform-controls/date.js 13075 var import_components35 = __toESM(require_components()); 13076 var import_element40 = __toESM(require_element()); 13077 var import_i18n33 = __toESM(require_i18n()); 13078 var import_date3 = __toESM(require_date()); 13079 var import_jsx_runtime76 = __toESM(require_jsx_runtime()); 13080 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock(import_components35.privateApis); 13081 var DATE_PRESETS = [ 13082 { 13083 id: "today", 13084 label: (0, import_i18n33.__)("Today"), 13085 getValue: () => (0, import_date3.getDate)(null) 13086 }, 13087 { 13088 id: "yesterday", 13089 label: (0, import_i18n33.__)("Yesterday"), 13090 getValue: () => { 13091 const today = (0, import_date3.getDate)(null); 13092 return subDays(today, 1); 13093 } 13094 }, 13095 { 13096 id: "past-week", 13097 label: (0, import_i18n33.__)("Past week"), 13098 getValue: () => { 13099 const today = (0, import_date3.getDate)(null); 13100 return subDays(today, 7); 13101 } 13102 }, 13103 { 13104 id: "past-month", 13105 label: (0, import_i18n33.__)("Past month"), 13106 getValue: () => { 13107 const today = (0, import_date3.getDate)(null); 13108 return subMonths(today, 1); 13109 } 13110 } 13111 ]; 13112 var DATE_RANGE_PRESETS = [ 13113 { 13114 id: "last-7-days", 13115 label: (0, import_i18n33.__)("Last 7 days"), 13116 getValue: () => { 13117 const today = (0, import_date3.getDate)(null); 13118 return [subDays(today, 7), today]; 13119 } 13120 }, 13121 { 13122 id: "last-30-days", 13123 label: (0, import_i18n33.__)("Last 30 days"), 13124 getValue: () => { 13125 const today = (0, import_date3.getDate)(null); 13126 return [subDays(today, 30), today]; 13127 } 13128 }, 13129 { 13130 id: "month-to-date", 13131 label: (0, import_i18n33.__)("Month to date"), 13132 getValue: () => { 13133 const today = (0, import_date3.getDate)(null); 13134 return [startOfMonth(today), today]; 13135 } 13136 }, 13137 { 13138 id: "last-year", 13139 label: (0, import_i18n33.__)("Last year"), 13140 getValue: () => { 13141 const today = (0, import_date3.getDate)(null); 13142 return [subYears(today, 1), today]; 13143 } 13144 }, 13145 { 13146 id: "year-to-date", 13147 label: (0, import_i18n33.__)("Year to date"), 13148 getValue: () => { 13149 const today = (0, import_date3.getDate)(null); 13150 return [startOfYear(today), today]; 13151 } 13152 } 13153 ]; 13154 var parseDate = (dateString) => { 13155 if (!dateString) { 13156 return null; 13157 } 13158 const parsed = (0, import_date3.getDate)(dateString); 13159 return parsed && isValid(parsed) ? parsed : null; 13160 }; 13161 var formatDate = (date) => { 13162 if (!date) { 13163 return ""; 13164 } 13165 return typeof date === "string" ? date : format(date, "yyyy-MM-dd"); 13166 }; 13167 function ValidatedDateControl({ 13168 field, 13169 validity, 13170 inputRefs, 13171 isTouched, 13172 setIsTouched, 13173 children 13174 }) { 13175 const { isValid: isValid2 } = field; 13176 const [customValidity, setCustomValidity] = (0, import_element40.useState)(void 0); 13177 const validateRefs = (0, import_element40.useCallback)(() => { 13178 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 13179 for (const ref of refs) { 13180 const input = ref.current; 13181 if (input && !input.validity.valid) { 13182 setCustomValidity({ 13183 type: "invalid", 13184 message: input.validationMessage 13185 }); 13186 return; 13187 } 13188 } 13189 setCustomValidity(void 0); 13190 }, [inputRefs]); 13191 (0, import_element40.useEffect)(() => { 13192 if (isTouched) { 13193 const timeoutId = setTimeout(() => { 13194 if (validity) { 13195 setCustomValidity(getCustomValidity(isValid2, validity)); 13196 } else { 13197 validateRefs(); 13198 } 13199 }, 0); 13200 return () => clearTimeout(timeoutId); 13201 } 13202 return void 0; 13203 }, [isTouched, isValid2, validity, validateRefs]); 13204 const onBlur = (event) => { 13205 if (isTouched) { 13206 return; 13207 } 13208 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) { 13209 setIsTouched(true); 13210 } 13211 }; 13212 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { onBlur, children: [ 13213 children, 13214 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)( 13215 "p", 13216 { 13217 className: clsx_default( 13218 "components-validated-control__indicator", 13219 customValidity.type === "invalid" ? "is-invalid" : void 0, 13220 customValidity.type === "valid" ? "is-valid" : void 0 13221 ), 13222 children: [ 13223 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13224 import_components35.Icon, 13225 { 13226 className: "components-validated-control__indicator-icon", 13227 icon: error_default, 13228 size: 16, 13229 fill: "currentColor" 13230 } 13231 ), 13232 customValidity.message 13233 ] 13234 } 13235 ) }) 13236 ] }); 13237 } 13238 function CalendarDateControl({ 13239 data, 13240 field, 13241 onChange, 13242 hideLabelFromVision, 13243 validity 13244 }) { 13245 const { 13246 id, 13247 label, 13248 setValue, 13249 getValue, 13250 isValid: isValid2, 13251 format: fieldFormat 13252 } = field; 13253 const [selectedPresetId, setSelectedPresetId] = (0, import_element40.useState)( 13254 null 13255 ); 13256 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 13257 const fieldValue = getValue({ item: data }); 13258 const value = typeof fieldValue === "string" ? fieldValue : void 0; 13259 const [calendarMonth, setCalendarMonth] = (0, import_element40.useState)(() => { 13260 const parsedDate = parseDate(value); 13261 return parsedDate || /* @__PURE__ */ new Date(); 13262 }); 13263 const [isTouched, setIsTouched] = (0, import_element40.useState)(false); 13264 const validityTargetRef = (0, import_element40.useRef)(null); 13265 const onChangeCallback = (0, import_element40.useCallback)( 13266 (newValue) => onChange(setValue({ item: data, value: newValue })), 13267 [data, onChange, setValue] 13268 ); 13269 const onSelectDate = (0, import_element40.useCallback)( 13270 (newDate) => { 13271 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0; 13272 onChangeCallback(dateValue); 13273 setSelectedPresetId(null); 13274 setIsTouched(true); 13275 }, 13276 [onChangeCallback] 13277 ); 13278 const handlePresetClick = (0, import_element40.useCallback)( 13279 (preset) => { 13280 const presetDate = preset.getValue(); 13281 const dateValue = formatDate(presetDate); 13282 setCalendarMonth(presetDate); 13283 onChangeCallback(dateValue); 13284 setSelectedPresetId(preset.id); 13285 setIsTouched(true); 13286 }, 13287 [onChangeCallback] 13288 ); 13289 const handleManualDateChange = (0, import_element40.useCallback)( 13290 (newValue) => { 13291 onChangeCallback(newValue); 13292 if (newValue) { 13293 const parsedDate = parseDate(newValue); 13294 if (parsedDate) { 13295 setCalendarMonth(parsedDate); 13296 } 13297 } 13298 setSelectedPresetId(null); 13299 setIsTouched(true); 13300 }, 13301 [onChangeCallback] 13302 ); 13303 const { 13304 timezone: { string: timezoneString } 13305 } = (0, import_date3.getSettings)(); 13306 const displayLabel = isValid2?.required ? `$label} (${(0, import_i18n33.__)("Required")})` : label; 13307 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13308 ValidatedDateControl, 13309 { 13310 field, 13311 validity, 13312 inputRefs: validityTargetRef, 13313 isTouched, 13314 setIsTouched, 13315 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13316 import_components35.BaseControl, 13317 { 13318 id, 13319 className: "dataviews-controls__date", 13320 label: displayLabel, 13321 hideLabelFromVision, 13322 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_components35.__experimentalVStack, { spacing: 4, children: [ 13323 /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_components35.__experimentalHStack, { spacing: 2, wrap: true, justify: "flex-start", children: [ 13324 DATE_PRESETS.map((preset) => { 13325 const isSelected2 = selectedPresetId === preset.id; 13326 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13327 import_components35.Button, 13328 { 13329 className: "dataviews-controls__date-preset", 13330 variant: "tertiary", 13331 isPressed: isSelected2, 13332 size: "small", 13333 onClick: () => handlePresetClick(preset), 13334 children: preset.label 13335 }, 13336 preset.id 13337 ); 13338 }), 13339 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13340 import_components35.Button, 13341 { 13342 className: "dataviews-controls__date-preset", 13343 variant: "tertiary", 13344 isPressed: !selectedPresetId, 13345 size: "small", 13346 disabled: !!selectedPresetId, 13347 accessibleWhenDisabled: false, 13348 children: (0, import_i18n33.__)("Custom") 13349 } 13350 ) 13351 ] }), 13352 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13353 import_components35.__experimentalInputControl, 13354 { 13355 __next40pxDefaultSize: true, 13356 ref: validityTargetRef, 13357 type: "date", 13358 label: (0, import_i18n33.__)("Date"), 13359 hideLabelFromVision: true, 13360 value, 13361 onChange: handleManualDateChange, 13362 required: !!field.isValid?.required 13363 } 13364 ), 13365 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13366 DateCalendar2, 13367 { 13368 style: { width: "100%" }, 13369 selected: value ? parseDate(value) || void 0 : void 0, 13370 onSelect: onSelectDate, 13371 month: calendarMonth, 13372 onMonthChange: setCalendarMonth, 13373 timeZone: timezoneString || void 0, 13374 weekStartsOn 13375 } 13376 ) 13377 ] }) 13378 } 13379 ) 13380 } 13381 ); 13382 } 13383 function CalendarDateRangeControl({ 13384 data, 13385 field, 13386 onChange, 13387 hideLabelFromVision, 13388 validity 13389 }) { 13390 const { id, label, getValue, setValue, format: fieldFormat } = field; 13391 let value; 13392 const fieldValue = getValue({ item: data }); 13393 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) { 13394 value = fieldValue; 13395 } 13396 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 13397 const onChangeCallback = (0, import_element40.useCallback)( 13398 (newValue) => { 13399 onChange( 13400 setValue({ 13401 item: data, 13402 value: newValue 13403 }) 13404 ); 13405 }, 13406 [data, onChange, setValue] 13407 ); 13408 const [selectedPresetId, setSelectedPresetId] = (0, import_element40.useState)( 13409 null 13410 ); 13411 const selectedRange = (0, import_element40.useMemo)(() => { 13412 if (!value) { 13413 return { from: void 0, to: void 0 }; 13414 } 13415 const [from, to] = value; 13416 return { 13417 from: parseDate(from) || void 0, 13418 to: parseDate(to) || void 0 13419 }; 13420 }, [value]); 13421 const [calendarMonth, setCalendarMonth] = (0, import_element40.useState)(() => { 13422 return selectedRange.from || /* @__PURE__ */ new Date(); 13423 }); 13424 const [isTouched, setIsTouched] = (0, import_element40.useState)(false); 13425 const fromInputRef = (0, import_element40.useRef)(null); 13426 const toInputRef = (0, import_element40.useRef)(null); 13427 const updateDateRange = (0, import_element40.useCallback)( 13428 (fromDate, toDate2) => { 13429 if (fromDate && toDate2) { 13430 onChangeCallback([ 13431 formatDate(fromDate), 13432 formatDate(toDate2) 13433 ]); 13434 } else if (!fromDate && !toDate2) { 13435 onChangeCallback(void 0); 13436 } 13437 }, 13438 [onChangeCallback] 13439 ); 13440 const onSelectCalendarRange = (0, import_element40.useCallback)( 13441 (newRange) => { 13442 updateDateRange(newRange?.from, newRange?.to); 13443 setSelectedPresetId(null); 13444 setIsTouched(true); 13445 }, 13446 [updateDateRange] 13447 ); 13448 const handlePresetClick = (0, import_element40.useCallback)( 13449 (preset) => { 13450 const [startDate, endDate] = preset.getValue(); 13451 setCalendarMonth(startDate); 13452 updateDateRange(startDate, endDate); 13453 setSelectedPresetId(preset.id); 13454 setIsTouched(true); 13455 }, 13456 [updateDateRange] 13457 ); 13458 const handleManualDateChange = (0, import_element40.useCallback)( 13459 (fromOrTo, newValue) => { 13460 const [currentFrom, currentTo] = value || [ 13461 void 0, 13462 void 0 13463 ]; 13464 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom; 13465 const updatedTo = fromOrTo === "to" ? newValue : currentTo; 13466 updateDateRange(updatedFrom, updatedTo); 13467 if (newValue) { 13468 const parsedDate = parseDate(newValue); 13469 if (parsedDate) { 13470 setCalendarMonth(parsedDate); 13471 } 13472 } 13473 setSelectedPresetId(null); 13474 setIsTouched(true); 13475 }, 13476 [value, updateDateRange] 13477 ); 13478 const { timezone } = (0, import_date3.getSettings)(); 13479 const displayLabel = field.isValid?.required ? `$label} (${(0, import_i18n33.__)("Required")})` : label; 13480 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13481 ValidatedDateControl, 13482 { 13483 field, 13484 validity, 13485 inputRefs: [fromInputRef, toInputRef], 13486 isTouched, 13487 setIsTouched, 13488 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13489 import_components35.BaseControl, 13490 { 13491 id, 13492 className: "dataviews-controls__date", 13493 label: displayLabel, 13494 hideLabelFromVision, 13495 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_components35.__experimentalVStack, { spacing: 4, children: [ 13496 /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_components35.__experimentalHStack, { spacing: 2, wrap: true, justify: "flex-start", children: [ 13497 DATE_RANGE_PRESETS.map((preset) => { 13498 const isSelected2 = selectedPresetId === preset.id; 13499 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13500 import_components35.Button, 13501 { 13502 className: "dataviews-controls__date-preset", 13503 variant: "tertiary", 13504 isPressed: isSelected2, 13505 size: "small", 13506 onClick: () => handlePresetClick(preset), 13507 children: preset.label 13508 }, 13509 preset.id 13510 ); 13511 }), 13512 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13513 import_components35.Button, 13514 { 13515 className: "dataviews-controls__date-preset", 13516 variant: "tertiary", 13517 isPressed: !selectedPresetId, 13518 size: "small", 13519 accessibleWhenDisabled: false, 13520 disabled: !!selectedPresetId, 13521 children: (0, import_i18n33.__)("Custom") 13522 } 13523 ) 13524 ] }), 13525 /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_components35.__experimentalHStack, { spacing: 2, children: [ 13526 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13527 import_components35.__experimentalInputControl, 13528 { 13529 __next40pxDefaultSize: true, 13530 ref: fromInputRef, 13531 type: "date", 13532 label: (0, import_i18n33.__)("From"), 13533 hideLabelFromVision: true, 13534 value: value?.[0], 13535 onChange: (newValue) => handleManualDateChange("from", newValue), 13536 required: !!field.isValid?.required 13537 } 13538 ), 13539 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13540 import_components35.__experimentalInputControl, 13541 { 13542 __next40pxDefaultSize: true, 13543 ref: toInputRef, 13544 type: "date", 13545 label: (0, import_i18n33.__)("To"), 13546 hideLabelFromVision: true, 13547 value: value?.[1], 13548 onChange: (newValue) => handleManualDateChange("to", newValue), 13549 required: !!field.isValid?.required 13550 } 13551 ) 13552 ] }), 13553 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13554 DateRangeCalendar, 13555 { 13556 style: { width: "100%" }, 13557 selected: selectedRange, 13558 onSelect: onSelectCalendarRange, 13559 month: calendarMonth, 13560 onMonthChange: setCalendarMonth, 13561 timeZone: timezone.string || void 0, 13562 weekStartsOn 13563 } 13564 ) 13565 ] }) 13566 } 13567 ) 13568 } 13569 ); 13570 } 13571 function DateControl({ 13572 data, 13573 field, 13574 onChange, 13575 hideLabelFromVision, 13576 operator, 13577 validity 13578 }) { 13579 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 13580 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13581 RelativeDateControl, 13582 { 13583 className: "dataviews-controls__date", 13584 data, 13585 field, 13586 onChange, 13587 hideLabelFromVision, 13588 operator 13589 } 13590 ); 13591 } 13592 if (operator === OPERATOR_BETWEEN) { 13593 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13594 CalendarDateRangeControl, 13595 { 13596 data, 13597 field, 13598 onChange, 13599 hideLabelFromVision, 13600 validity 13601 } 13602 ); 13603 } 13604 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 13605 CalendarDateControl, 13606 { 13607 data, 13608 field, 13609 onChange, 13610 hideLabelFromVision, 13611 validity 13612 } 13613 ); 13614 } 13615 13616 // packages/dataviews/build-module/dataform-controls/email.js 13617 var import_components37 = __toESM(require_components()); 13618 13619 // packages/dataviews/build-module/dataform-controls/utils/validated-input.js 13620 var import_components36 = __toESM(require_components()); 13621 var import_element41 = __toESM(require_element()); 13622 var import_jsx_runtime77 = __toESM(require_jsx_runtime()); 13623 var { ValidatedInputControl: ValidatedInputControl2 } = unlock(import_components36.privateApis); 13624 function ValidatedText({ 13625 data, 13626 field, 13627 onChange, 13628 hideLabelFromVision, 13629 type, 13630 prefix, 13631 suffix, 13632 validity 13633 }) { 13634 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 13635 const value = getValue({ item: data }); 13636 const onChangeControl = (0, import_element41.useCallback)( 13637 (newValue) => onChange( 13638 setValue({ 13639 item: data, 13640 value: newValue 13641 }) 13642 ), 13643 [data, setValue, onChange] 13644 ); 13645 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 13646 ValidatedInputControl2, 13647 { 13648 required: !!isValid2.required, 13649 customValidity: getCustomValidity(isValid2, validity), 13650 label, 13651 placeholder, 13652 value: value ?? "", 13653 help: description, 13654 onChange: onChangeControl, 13655 hideLabelFromVision, 13656 type, 13657 prefix, 13658 suffix, 13659 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0, 13660 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 13661 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 13662 __next40pxDefaultSize: true 13663 } 13664 ); 13665 } 13666 13667 // packages/dataviews/build-module/dataform-controls/email.js 13668 var import_jsx_runtime78 = __toESM(require_jsx_runtime()); 13669 function Email({ 13670 data, 13671 field, 13672 onChange, 13673 hideLabelFromVision, 13674 validity 13675 }) { 13676 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)( 13677 ValidatedText, 13678 { 13679 ...{ 13680 data, 13681 field, 13682 onChange, 13683 hideLabelFromVision, 13684 validity, 13685 type: "email", 13686 prefix: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components37.Icon, { icon: envelope_default }) }) 13687 } 13688 } 13689 ); 13690 } 13691 13692 // packages/dataviews/build-module/dataform-controls/telephone.js 13693 var import_components38 = __toESM(require_components()); 13694 var import_jsx_runtime79 = __toESM(require_jsx_runtime()); 13695 function Telephone({ 13696 data, 13697 field, 13698 onChange, 13699 hideLabelFromVision, 13700 validity 13701 }) { 13702 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 13703 ValidatedText, 13704 { 13705 ...{ 13706 data, 13707 field, 13708 onChange, 13709 hideLabelFromVision, 13710 validity, 13711 type: "tel", 13712 prefix: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components38.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components38.Icon, { icon: mobile_default }) }) 13713 } 13714 } 13715 ); 13716 } 13717 13718 // packages/dataviews/build-module/dataform-controls/url.js 13719 var import_components39 = __toESM(require_components()); 13720 var import_jsx_runtime80 = __toESM(require_jsx_runtime()); 13721 function Url({ 13722 data, 13723 field, 13724 onChange, 13725 hideLabelFromVision, 13726 validity 13727 }) { 13728 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)( 13729 ValidatedText, 13730 { 13731 ...{ 13732 data, 13733 field, 13734 onChange, 13735 hideLabelFromVision, 13736 validity, 13737 type: "url", 13738 prefix: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components39.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components39.Icon, { icon: link_default }) }) 13739 } 13740 } 13741 ); 13742 } 13743 13744 // packages/dataviews/build-module/dataform-controls/utils/validated-number.js 13745 var import_components40 = __toESM(require_components()); 13746 var import_element42 = __toESM(require_element()); 13747 var import_i18n34 = __toESM(require_i18n()); 13748 var import_jsx_runtime81 = __toESM(require_jsx_runtime()); 13749 var { ValidatedNumberControl } = unlock(import_components40.privateApis); 13750 function toNumberOrEmpty(value) { 13751 if (value === "" || value === void 0) { 13752 return ""; 13753 } 13754 const number = Number(value); 13755 return Number.isFinite(number) ? number : ""; 13756 } 13757 function BetweenControls({ 13758 value, 13759 onChange, 13760 hideLabelFromVision, 13761 step 13762 }) { 13763 const [min = "", max = ""] = value; 13764 const onChangeMin = (0, import_element42.useCallback)( 13765 (newValue) => onChange([toNumberOrEmpty(newValue), max]), 13766 [onChange, max] 13767 ); 13768 const onChangeMax = (0, import_element42.useCallback)( 13769 (newValue) => onChange([min, toNumberOrEmpty(newValue)]), 13770 [onChange, min] 13771 ); 13772 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)( 13773 import_components40.BaseControl, 13774 { 13775 help: (0, import_i18n34.__)("The max. value must be greater than the min. value."), 13776 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_components40.Flex, { direction: "row", gap: 4, children: [ 13777 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)( 13778 import_components40.__experimentalNumberControl, 13779 { 13780 label: (0, import_i18n34.__)("Min."), 13781 value: min, 13782 max: max ? Number(max) - step : void 0, 13783 onChange: onChangeMin, 13784 __next40pxDefaultSize: true, 13785 hideLabelFromVision, 13786 step 13787 } 13788 ), 13789 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)( 13790 import_components40.__experimentalNumberControl, 13791 { 13792 label: (0, import_i18n34.__)("Max."), 13793 value: max, 13794 min: min ? Number(min) + step : void 0, 13795 onChange: onChangeMax, 13796 __next40pxDefaultSize: true, 13797 hideLabelFromVision, 13798 step 13799 } 13800 ) 13801 ] }) 13802 } 13803 ); 13804 } 13805 function ValidatedNumber({ 13806 data, 13807 field, 13808 onChange, 13809 hideLabelFromVision, 13810 operator, 13811 validity 13812 }) { 13813 const decimals = field.format?.decimals ?? 0; 13814 const step = Math.pow(10, Math.abs(decimals) * -1); 13815 const { label, description, getValue, setValue, isValid: isValid2 } = field; 13816 const value = getValue({ item: data }) ?? ""; 13817 const onChangeControl = (0, import_element42.useCallback)( 13818 (newValue) => { 13819 onChange( 13820 setValue({ 13821 item: data, 13822 // Do not convert an empty string or undefined to a number, 13823 // otherwise there's a mismatch between the UI control (empty) 13824 // and the data relied by onChange (0). 13825 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue) 13826 }) 13827 ); 13828 }, 13829 [data, onChange, setValue] 13830 ); 13831 const onChangeBetweenControls = (0, import_element42.useCallback)( 13832 (newValue) => { 13833 onChange( 13834 setValue({ 13835 item: data, 13836 value: newValue 13837 }) 13838 ); 13839 }, 13840 [data, onChange, setValue] 13841 ); 13842 if (operator === OPERATOR_BETWEEN) { 13843 let valueBetween = ["", ""]; 13844 if (Array.isArray(value) && value.length === 2 && value.every( 13845 (element) => typeof element === "number" || element === "" 13846 )) { 13847 valueBetween = value; 13848 } 13849 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)( 13850 BetweenControls, 13851 { 13852 value: valueBetween, 13853 onChange: onChangeBetweenControls, 13854 hideLabelFromVision, 13855 step 13856 } 13857 ); 13858 } 13859 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)( 13860 ValidatedNumberControl, 13861 { 13862 required: !!isValid2.required, 13863 customValidity: getCustomValidity(isValid2, validity), 13864 label, 13865 help: description, 13866 value, 13867 onChange: onChangeControl, 13868 __next40pxDefaultSize: true, 13869 hideLabelFromVision, 13870 step, 13871 min: isValid2.min ? isValid2.min.constraint : void 0, 13872 max: isValid2.max ? isValid2.max.constraint : void 0 13873 } 13874 ); 13875 } 13876 13877 // packages/dataviews/build-module/dataform-controls/integer.js 13878 var import_jsx_runtime82 = __toESM(require_jsx_runtime()); 13879 function Integer(props) { 13880 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ValidatedNumber, { ...props }); 13881 } 13882 13883 // packages/dataviews/build-module/dataform-controls/number.js 13884 var import_jsx_runtime83 = __toESM(require_jsx_runtime()); 13885 function Number2(props) { 13886 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(ValidatedNumber, { ...props }); 13887 } 13888 13889 // packages/dataviews/build-module/dataform-controls/radio.js 13890 var import_components41 = __toESM(require_components()); 13891 var import_element43 = __toESM(require_element()); 13892 var import_jsx_runtime84 = __toESM(require_jsx_runtime()); 13893 var { ValidatedRadioControl } = unlock(import_components41.privateApis); 13894 function Radio({ 13895 data, 13896 field, 13897 onChange, 13898 hideLabelFromVision, 13899 validity 13900 }) { 13901 const { label, description, getValue, setValue, isValid: isValid2 } = field; 13902 const { elements, isLoading } = useElements({ 13903 elements: field.elements, 13904 getElements: field.getElements 13905 }); 13906 const value = getValue({ item: data }); 13907 const onChangeControl = (0, import_element43.useCallback)( 13908 (newValue) => onChange(setValue({ item: data, value: newValue })), 13909 [data, onChange, setValue] 13910 ); 13911 if (isLoading) { 13912 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_components41.Spinner, {}); 13913 } 13914 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)( 13915 ValidatedRadioControl, 13916 { 13917 required: !!field.isValid?.required, 13918 customValidity: getCustomValidity(isValid2, validity), 13919 label, 13920 help: description, 13921 onChange: onChangeControl, 13922 options: elements, 13923 selected: value, 13924 hideLabelFromVision 13925 } 13926 ); 13927 } 13928 13929 // packages/dataviews/build-module/dataform-controls/select.js 13930 var import_components42 = __toESM(require_components()); 13931 var import_element44 = __toESM(require_element()); 13932 var import_jsx_runtime85 = __toESM(require_jsx_runtime()); 13933 var { ValidatedSelectControl } = unlock(import_components42.privateApis); 13934 function Select({ 13935 data, 13936 field, 13937 onChange, 13938 hideLabelFromVision, 13939 validity 13940 }) { 13941 const { type, label, description, getValue, setValue, isValid: isValid2 } = field; 13942 const isMultiple = type === "array"; 13943 const value = getValue({ item: data }) ?? (isMultiple ? [] : ""); 13944 const onChangeControl = (0, import_element44.useCallback)( 13945 (newValue) => onChange(setValue({ item: data, value: newValue })), 13946 [data, onChange, setValue] 13947 ); 13948 const { elements, isLoading } = useElements({ 13949 elements: field.elements, 13950 getElements: field.getElements 13951 }); 13952 if (isLoading) { 13953 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_components42.Spinner, {}); 13954 } 13955 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 13956 ValidatedSelectControl, 13957 { 13958 required: !!field.isValid?.required, 13959 customValidity: getCustomValidity(isValid2, validity), 13960 label, 13961 value, 13962 help: description, 13963 options: elements, 13964 onChange: onChangeControl, 13965 __next40pxDefaultSize: true, 13966 hideLabelFromVision, 13967 multiple: isMultiple 13968 } 13969 ); 13970 } 13971 13972 // packages/dataviews/build-module/dataform-controls/text.js 13973 var import_element45 = __toESM(require_element()); 13974 var import_jsx_runtime86 = __toESM(require_jsx_runtime()); 13975 function Text2({ 13976 data, 13977 field, 13978 onChange, 13979 hideLabelFromVision, 13980 config, 13981 validity 13982 }) { 13983 const { prefix, suffix } = config || {}; 13984 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 13985 ValidatedText, 13986 { 13987 ...{ 13988 data, 13989 field, 13990 onChange, 13991 hideLabelFromVision, 13992 validity, 13993 prefix: prefix ? (0, import_element45.createElement)(prefix) : void 0, 13994 suffix: suffix ? (0, import_element45.createElement)(suffix) : void 0 13995 } 13996 } 13997 ); 13998 } 13999 14000 // packages/dataviews/build-module/dataform-controls/toggle.js 14001 var import_components43 = __toESM(require_components()); 14002 var import_element46 = __toESM(require_element()); 14003 var import_jsx_runtime87 = __toESM(require_jsx_runtime()); 14004 var { ValidatedToggleControl } = unlock(import_components43.privateApis); 14005 function Toggle({ 14006 field, 14007 onChange, 14008 data, 14009 hideLabelFromVision, 14010 validity 14011 }) { 14012 const { label, description, getValue, setValue, isValid: isValid2 } = field; 14013 const onChangeControl = (0, import_element46.useCallback)(() => { 14014 onChange( 14015 setValue({ item: data, value: !getValue({ item: data }) }) 14016 ); 14017 }, [onChange, setValue, data, getValue]); 14018 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 14019 ValidatedToggleControl, 14020 { 14021 required: !!isValid2.required, 14022 customValidity: getCustomValidity(isValid2, validity), 14023 hidden: hideLabelFromVision, 14024 label, 14025 help: description, 14026 checked: getValue({ item: data }), 14027 onChange: onChangeControl 14028 } 14029 ); 14030 } 14031 14032 // packages/dataviews/build-module/dataform-controls/textarea.js 14033 var import_components44 = __toESM(require_components()); 14034 var import_element47 = __toESM(require_element()); 14035 var import_jsx_runtime88 = __toESM(require_jsx_runtime()); 14036 var { ValidatedTextareaControl } = unlock(import_components44.privateApis); 14037 function Textarea({ 14038 data, 14039 field, 14040 onChange, 14041 hideLabelFromVision, 14042 config, 14043 validity 14044 }) { 14045 const { rows = 4 } = config || {}; 14046 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 14047 const value = field.getValue({ item: data }); 14048 const onChangeControl = (0, import_element47.useCallback)( 14049 (newValue) => onChange(setValue({ item: data, value: newValue })), 14050 [data, onChange, setValue] 14051 ); 14052 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 14053 ValidatedTextareaControl, 14054 { 14055 required: !!isValid2.required, 14056 customValidity: getCustomValidity(isValid2, validity), 14057 label, 14058 placeholder, 14059 value: value ?? "", 14060 help: description, 14061 onChange: onChangeControl, 14062 rows, 14063 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 14064 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 14065 __next40pxDefaultSize: true, 14066 hideLabelFromVision 14067 } 14068 ); 14069 } 14070 14071 // packages/dataviews/build-module/dataform-controls/toggle-group.js 14072 var import_components45 = __toESM(require_components()); 14073 var import_element48 = __toESM(require_element()); 14074 var import_jsx_runtime89 = __toESM(require_jsx_runtime()); 14075 var { ValidatedToggleGroupControl } = unlock(import_components45.privateApis); 14076 function ToggleGroup({ 14077 data, 14078 field, 14079 onChange, 14080 hideLabelFromVision, 14081 validity 14082 }) { 14083 const { getValue, setValue, isValid: isValid2 } = field; 14084 const value = getValue({ item: data }); 14085 const onChangeControl = (0, import_element48.useCallback)( 14086 (newValue) => onChange(setValue({ item: data, value: newValue })), 14087 [data, onChange, setValue] 14088 ); 14089 const { elements, isLoading } = useElements({ 14090 elements: field.elements, 14091 getElements: field.getElements 14092 }); 14093 if (isLoading) { 14094 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components45.Spinner, {}); 14095 } 14096 if (elements.length === 0) { 14097 return null; 14098 } 14099 const selectedOption = elements.find((el) => el.value === value); 14100 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 14101 ValidatedToggleGroupControl, 14102 { 14103 required: !!field.isValid?.required, 14104 customValidity: getCustomValidity(isValid2, validity), 14105 __next40pxDefaultSize: true, 14106 isBlock: true, 14107 label: field.label, 14108 help: selectedOption?.description || field.description, 14109 onChange: onChangeControl, 14110 value, 14111 hideLabelFromVision, 14112 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 14113 import_components45.__experimentalToggleGroupControlOption, 14114 { 14115 label: el.label, 14116 value: el.value 14117 }, 14118 el.value 14119 )) 14120 } 14121 ); 14122 } 14123 14124 // packages/dataviews/build-module/dataform-controls/array.js 14125 var import_components46 = __toESM(require_components()); 14126 var import_element49 = __toESM(require_element()); 14127 var import_jsx_runtime90 = __toESM(require_jsx_runtime()); 14128 var { ValidatedFormTokenField } = unlock(import_components46.privateApis); 14129 function ArrayControl({ 14130 data, 14131 field, 14132 onChange, 14133 hideLabelFromVision, 14134 validity 14135 }) { 14136 const { label, placeholder, getValue, setValue, isValid: isValid2 } = field; 14137 const value = getValue({ item: data }); 14138 const { elements, isLoading } = useElements({ 14139 elements: field.elements, 14140 getElements: field.getElements 14141 }); 14142 const arrayValueAsElements = (0, import_element49.useMemo)( 14143 () => Array.isArray(value) ? value.map((token) => { 14144 const element = elements?.find( 14145 (suggestion) => suggestion.value === token 14146 ); 14147 return element || { value: token, label: token }; 14148 }) : [], 14149 [value, elements] 14150 ); 14151 const onChangeControl = (0, import_element49.useCallback)( 14152 (tokens) => { 14153 const valueTokens = tokens.map((token) => { 14154 if (typeof token === "object" && "value" in token) { 14155 return token.value; 14156 } 14157 return token; 14158 }); 14159 onChange(setValue({ item: data, value: valueTokens })); 14160 }, 14161 [onChange, setValue, data] 14162 ); 14163 if (isLoading) { 14164 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components46.Spinner, {}); 14165 } 14166 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 14167 ValidatedFormTokenField, 14168 { 14169 required: !!isValid2?.required, 14170 customValidity: getCustomValidity(isValid2, validity), 14171 label: hideLabelFromVision ? void 0 : label, 14172 value: arrayValueAsElements, 14173 onChange: onChangeControl, 14174 placeholder, 14175 suggestions: elements?.map((element) => element.value), 14176 __experimentalValidateInput: (token) => { 14177 if (field.isValid?.elements && elements) { 14178 return elements.some( 14179 (element) => element.value === token || element.label === token 14180 ); 14181 } 14182 return true; 14183 }, 14184 __experimentalExpandOnFocus: elements && elements.length > 0, 14185 __experimentalShowHowTo: !field.isValid?.elements, 14186 displayTransform: (token) => { 14187 if (typeof token === "object" && "label" in token) { 14188 return token.label; 14189 } 14190 if (typeof token === "string" && elements) { 14191 const element = elements.find( 14192 (el) => el.value === token 14193 ); 14194 return element?.label || token; 14195 } 14196 return token; 14197 }, 14198 __experimentalRenderItem: ({ item }) => { 14199 if (typeof item === "string" && elements) { 14200 const element = elements.find( 14201 (el) => el.value === item 14202 ); 14203 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { children: element?.label || item }); 14204 } 14205 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { children: item }); 14206 } 14207 } 14208 ); 14209 } 14210 14211 // node_modules/colord/index.mjs 14212 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; 14213 var t = function(r3) { 14214 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3; 14215 }; 14216 var n = function(r3, t2, n2) { 14217 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0; 14218 }; 14219 var e = function(r3, t2, n2) { 14220 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2; 14221 }; 14222 var u = function(r3) { 14223 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360; 14224 }; 14225 var a = function(r3) { 14226 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) }; 14227 }; 14228 var o = function(r3) { 14229 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) }; 14230 }; 14231 var i = /^#([0-9a-f]{3,8})$/i; 14232 var s = function(r3) { 14233 var t2 = r3.toString(16); 14234 return t2.length < 2 ? "0" + t2 : t2; 14235 }; 14236 var h = function(r3) { 14237 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; 14238 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 }; 14239 }; 14240 var b = function(r3) { 14241 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a; 14242 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100; 14243 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; 14244 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 }; 14245 }; 14246 var g = function(r3) { 14247 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) }; 14248 }; 14249 var d = function(r3) { 14250 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) }; 14251 }; 14252 var f = function(r3) { 14253 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 })); 14254 var t2, n2, e2; 14255 }; 14256 var c = function(r3) { 14257 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 }; 14258 var t2, n2, e2, u2; 14259 }; 14260 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 14261 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 14262 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 14263 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 14264 var y = { string: [[function(r3) { 14265 var t2 = i.exec(r3); 14266 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; 14267 }, "hex"], [function(r3) { 14268 var t2 = v.exec(r3) || m.exec(r3); 14269 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; 14270 }, "rgb"], [function(t2) { 14271 var n2 = l.exec(t2) || p.exec(t2); 14272 if (!n2) return null; 14273 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) }); 14274 return f(a2); 14275 }, "hsl"]], object: [[function(r3) { 14276 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2; 14277 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null; 14278 }, "rgb"], [function(r3) { 14279 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2; 14280 if (!t(n2) || !t(e2) || !t(u2)) return null; 14281 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) }); 14282 return f(i2); 14283 }, "hsl"], [function(r3) { 14284 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2; 14285 if (!t(n2) || !t(a2) || !t(o2)) return null; 14286 var h2 = (function(r4) { 14287 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) }; 14288 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) }); 14289 return b(h2); 14290 }, "hsv"]] }; 14291 var N = function(r3, t2) { 14292 for (var n2 = 0; n2 < t2.length; n2++) { 14293 var e2 = t2[n2][0](r3); 14294 if (e2) return [e2, t2[n2][1]]; 14295 } 14296 return [null, void 0]; 14297 }; 14298 var x = function(r3) { 14299 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0]; 14300 }; 14301 var M = function(r3, t2) { 14302 var n2 = c(r3); 14303 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a }; 14304 }; 14305 var H = function(r3) { 14306 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255; 14307 }; 14308 var $ = function(r3, t2) { 14309 var n2 = c(r3); 14310 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a }; 14311 }; 14312 var j = (function() { 14313 function r3(r4) { 14314 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 14315 } 14316 return r3.prototype.isValid = function() { 14317 return null !== this.parsed; 14318 }, r3.prototype.brightness = function() { 14319 return n(H(this.rgba), 2); 14320 }, r3.prototype.isDark = function() { 14321 return H(this.rgba) < 0.5; 14322 }, r3.prototype.isLight = function() { 14323 return H(this.rgba) >= 0.5; 14324 }, r3.prototype.toHex = function() { 14325 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; 14326 var r4, t2, e2, u2, a2, i2; 14327 }, r3.prototype.toRgb = function() { 14328 return o(this.rgba); 14329 }, r3.prototype.toRgbString = function() { 14330 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 + ")"; 14331 var r4, t2, n2, e2, u2; 14332 }, r3.prototype.toHsl = function() { 14333 return d(c(this.rgba)); 14334 }, r3.prototype.toHslString = function() { 14335 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 + "%)"; 14336 var r4, t2, n2, e2, u2; 14337 }, r3.prototype.toHsv = function() { 14338 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) }; 14339 var r4; 14340 }, r3.prototype.invert = function() { 14341 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a }); 14342 var r4; 14343 }, r3.prototype.saturate = function(r4) { 14344 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4)); 14345 }, r3.prototype.desaturate = function(r4) { 14346 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4)); 14347 }, r3.prototype.grayscale = function() { 14348 return w(M(this.rgba, -1)); 14349 }, r3.prototype.lighten = function(r4) { 14350 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4)); 14351 }, r3.prototype.darken = function(r4) { 14352 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4)); 14353 }, r3.prototype.rotate = function(r4) { 14354 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4); 14355 }, r3.prototype.alpha = function(r4) { 14356 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3); 14357 var t2; 14358 }, r3.prototype.hue = function(r4) { 14359 var t2 = c(this.rgba); 14360 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h); 14361 }, r3.prototype.isEqual = function(r4) { 14362 return this.toHex() === w(r4).toHex(); 14363 }, r3; 14364 })(); 14365 var w = function(r3) { 14366 return r3 instanceof j ? r3 : new j(r3); 14367 }; 14368 14369 // packages/dataviews/build-module/dataform-controls/color.js 14370 var import_components47 = __toESM(require_components()); 14371 var import_element50 = __toESM(require_element()); 14372 var import_jsx_runtime91 = __toESM(require_jsx_runtime()); 14373 var { ValidatedInputControl: ValidatedInputControl3, Picker } = unlock(import_components47.privateApis); 14374 var ColorPicker = ({ 14375 color, 14376 onColorChange 14377 }) => { 14378 const validColor = color && w(color).isValid() ? color : "#ffffff"; 14379 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 14380 import_components47.Dropdown, 14381 { 14382 renderToggle: ({ onToggle, isOpen }) => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_components47.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 14383 "button", 14384 { 14385 type: "button", 14386 onClick: onToggle, 14387 style: { 14388 width: "24px", 14389 height: "24px", 14390 borderRadius: "50%", 14391 backgroundColor: validColor, 14392 border: "1px solid #ddd", 14393 cursor: "pointer", 14394 outline: isOpen ? "2px solid #007cba" : "none", 14395 outlineOffset: "2px", 14396 display: "flex", 14397 alignItems: "center", 14398 justifyContent: "center", 14399 padding: 0, 14400 margin: 0 14401 }, 14402 "aria-label": "Open color picker" 14403 } 14404 ) }), 14405 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { style: { padding: "16px" }, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 14406 Picker, 14407 { 14408 color: w(validColor), 14409 onChange: onColorChange, 14410 enableAlpha: true 14411 } 14412 ) }) 14413 } 14414 ); 14415 }; 14416 function Color({ 14417 data, 14418 field, 14419 onChange, 14420 hideLabelFromVision, 14421 validity 14422 }) { 14423 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 14424 const value = field.getValue({ item: data }) || ""; 14425 const handleColorChange = (0, import_element50.useCallback)( 14426 (colorObject) => { 14427 onChange(setValue({ item: data, value: colorObject.toHex() })); 14428 }, 14429 [data, onChange, setValue] 14430 ); 14431 const handleInputChange = (0, import_element50.useCallback)( 14432 (newValue) => { 14433 onChange(setValue({ item: data, value: newValue || "" })); 14434 }, 14435 [data, onChange, setValue] 14436 ); 14437 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 14438 ValidatedInputControl3, 14439 { 14440 required: !!field.isValid?.required, 14441 customValidity: getCustomValidity(isValid2, validity), 14442 label, 14443 placeholder, 14444 value, 14445 help: description, 14446 onChange: handleInputChange, 14447 hideLabelFromVision, 14448 type: "text", 14449 prefix: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 14450 ColorPicker, 14451 { 14452 color: value, 14453 onColorChange: handleColorChange 14454 } 14455 ) 14456 } 14457 ); 14458 } 14459 14460 // packages/dataviews/build-module/dataform-controls/password.js 14461 var import_components48 = __toESM(require_components()); 14462 var import_element51 = __toESM(require_element()); 14463 var import_i18n35 = __toESM(require_i18n()); 14464 var import_jsx_runtime92 = __toESM(require_jsx_runtime()); 14465 function Password({ 14466 data, 14467 field, 14468 onChange, 14469 hideLabelFromVision, 14470 validity 14471 }) { 14472 const [isVisible2, setIsVisible] = (0, import_element51.useState)(false); 14473 const toggleVisibility = (0, import_element51.useCallback)(() => { 14474 setIsVisible((prev) => !prev); 14475 }, []); 14476 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 14477 ValidatedText, 14478 { 14479 ...{ 14480 data, 14481 field, 14482 onChange, 14483 hideLabelFromVision, 14484 validity, 14485 type: isVisible2 ? "text" : "password", 14486 suffix: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components48.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 14487 import_components48.Button, 14488 { 14489 icon: isVisible2 ? unseen_default : seen_default, 14490 onClick: toggleVisibility, 14491 size: "small", 14492 label: isVisible2 ? (0, import_i18n35.__)("Hide password") : (0, import_i18n35.__)("Show password") 14493 } 14494 ) }) 14495 } 14496 } 14497 ); 14498 } 14499 14500 // packages/dataviews/build-module/field-types/utils/has-elements.js 14501 function hasElements(field) { 14502 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function"; 14503 } 14504 14505 // packages/dataviews/build-module/dataform-controls/index.js 14506 var import_jsx_runtime93 = __toESM(require_jsx_runtime()); 14507 var FORM_CONTROLS = { 14508 array: ArrayControl, 14509 checkbox: Checkbox, 14510 color: Color, 14511 datetime: DateTime, 14512 date: DateControl, 14513 email: Email, 14514 telephone: Telephone, 14515 url: Url, 14516 integer: Integer, 14517 number: Number2, 14518 password: Password, 14519 radio: Radio, 14520 select: Select, 14521 text: Text2, 14522 toggle: Toggle, 14523 textarea: Textarea, 14524 toggleGroup: ToggleGroup 14525 }; 14526 function isEditConfig(value) { 14527 return value && typeof value === "object" && typeof value.control === "string"; 14528 } 14529 function createConfiguredControl(config) { 14530 const { control, ...controlConfig } = config; 14531 const BaseControlType = getControlByType(control); 14532 if (BaseControlType === null) { 14533 return null; 14534 } 14535 return function ConfiguredControl(props) { 14536 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(BaseControlType, { ...props, config: controlConfig }); 14537 }; 14538 } 14539 function getControl(field, fallback) { 14540 if (typeof field.Edit === "function") { 14541 return field.Edit; 14542 } 14543 if (typeof field.Edit === "string") { 14544 return getControlByType(field.Edit); 14545 } 14546 if (isEditConfig(field.Edit)) { 14547 return createConfiguredControl(field.Edit); 14548 } 14549 if (hasElements(field) && field.type !== "array") { 14550 return getControlByType("select"); 14551 } 14552 if (fallback === null) { 14553 return null; 14554 } 14555 return getControlByType(fallback); 14556 } 14557 function getControlByType(type) { 14558 if (Object.keys(FORM_CONTROLS).includes(type)) { 14559 return FORM_CONTROLS[type]; 14560 } 14561 return null; 14562 } 14563 14564 // packages/dataviews/build-module/field-types/utils/get-filter-by.js 14565 function getFilterBy(field, defaultOperators, validOperators) { 14566 if (field.filterBy === false) { 14567 return false; 14568 } 14569 const operators = field.filterBy?.operators?.filter( 14570 (op) => validOperators.includes(op) 14571 ) ?? defaultOperators; 14572 if (operators.length === 0) { 14573 return false; 14574 } 14575 return { 14576 isPrimary: !!field.filterBy?.isPrimary, 14577 operators 14578 }; 14579 } 14580 var get_filter_by_default = getFilterBy; 14581 14582 // packages/dataviews/build-module/field-types/utils/get-value-from-id.js 14583 var getValueFromId = (id) => ({ item }) => { 14584 const path = id.split("."); 14585 let value = item; 14586 for (const segment of path) { 14587 if (value.hasOwnProperty(segment)) { 14588 value = value[segment]; 14589 } else { 14590 value = void 0; 14591 } 14592 } 14593 return value; 14594 }; 14595 var get_value_from_id_default = getValueFromId; 14596 14597 // packages/dataviews/build-module/field-types/utils/set-value-from-id.js 14598 var setValueFromId = (id) => ({ value }) => { 14599 const path = id.split("."); 14600 const result = {}; 14601 let current = result; 14602 for (const segment of path.slice(0, -1)) { 14603 current[segment] = {}; 14604 current = current[segment]; 14605 } 14606 current[path.at(-1)] = value; 14607 return result; 14608 }; 14609 var set_value_from_id_default = setValueFromId; 14610 14611 // packages/dataviews/build-module/field-types/email.js 14612 var import_i18n36 = __toESM(require_i18n()); 14613 14614 // packages/dataviews/build-module/field-types/utils/render-from-elements.js 14615 function RenderFromElements({ 14616 item, 14617 field 14618 }) { 14619 const { elements, isLoading } = useElements({ 14620 elements: field.elements, 14621 getElements: field.getElements 14622 }); 14623 const value = field.getValue({ item }); 14624 if (isLoading) { 14625 return value; 14626 } 14627 if (elements.length === 0) { 14628 return value; 14629 } 14630 return elements?.find((element) => element.value === value)?.label || field.getValue({ item }); 14631 } 14632 14633 // packages/dataviews/build-module/field-types/utils/render-default.js 14634 var import_jsx_runtime94 = __toESM(require_jsx_runtime()); 14635 function render({ 14636 item, 14637 field 14638 }) { 14639 if (field.hasElements) { 14640 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(RenderFromElements, { item, field }); 14641 } 14642 return field.getValueFormatted({ item, field }); 14643 } 14644 14645 // packages/dataviews/build-module/field-types/utils/sort-text.js 14646 var sort_text_default = (a2, b2, direction) => { 14647 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2); 14648 }; 14649 14650 // packages/dataviews/build-module/field-types/utils/is-valid-required.js 14651 function isValidRequired(item, field) { 14652 const value = field.getValue({ item }); 14653 return ![void 0, "", null].includes(value); 14654 } 14655 14656 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.js 14657 function isValidMinLength(item, field) { 14658 if (typeof field.isValid.minLength?.constraint !== "number") { 14659 return false; 14660 } 14661 const value = field.getValue({ item }); 14662 if ([void 0, "", null].includes(value)) { 14663 return true; 14664 } 14665 return String(value).length >= field.isValid.minLength.constraint; 14666 } 14667 14668 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.js 14669 function isValidMaxLength(item, field) { 14670 if (typeof field.isValid.maxLength?.constraint !== "number") { 14671 return false; 14672 } 14673 const value = field.getValue({ item }); 14674 if ([void 0, "", null].includes(value)) { 14675 return true; 14676 } 14677 return String(value).length <= field.isValid.maxLength.constraint; 14678 } 14679 14680 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.js 14681 function isValidPattern(item, field) { 14682 if (field.isValid.pattern?.constraint === void 0) { 14683 return true; 14684 } 14685 try { 14686 const regexp = new RegExp(field.isValid.pattern.constraint); 14687 const value = field.getValue({ item }); 14688 if ([void 0, "", null].includes(value)) { 14689 return true; 14690 } 14691 return regexp.test(String(value)); 14692 } catch { 14693 return false; 14694 } 14695 } 14696 14697 // packages/dataviews/build-module/field-types/utils/is-valid-elements.js 14698 function isValidElements(item, field) { 14699 const elements = field.elements ?? []; 14700 const validValues = elements.map((el) => el.value); 14701 if (validValues.length === 0) { 14702 return true; 14703 } 14704 const value = field.getValue({ item }); 14705 return [].concat(value).every((v2) => validValues.includes(v2)); 14706 } 14707 14708 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.js 14709 function getValueFormatted({ 14710 item, 14711 field 14712 }) { 14713 return field.getValue({ item }); 14714 } 14715 var get_value_formatted_default_default = getValueFormatted; 14716 14717 // packages/dataviews/build-module/field-types/email.js 14718 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])?)*$/; 14719 function isValidCustom(item, field) { 14720 const value = field.getValue({ item }); 14721 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) { 14722 return (0, import_i18n36.__)("Value must be a valid email address."); 14723 } 14724 return null; 14725 } 14726 var email_default = { 14727 type: "email", 14728 render, 14729 Edit: "email", 14730 sort: sort_text_default, 14731 enableSorting: true, 14732 enableGlobalSearch: false, 14733 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 14734 validOperators: [ 14735 OPERATOR_IS, 14736 OPERATOR_IS_NOT, 14737 OPERATOR_CONTAINS, 14738 OPERATOR_NOT_CONTAINS, 14739 OPERATOR_STARTS_WITH, 14740 // Multiple selection 14741 OPERATOR_IS_ANY, 14742 OPERATOR_IS_NONE, 14743 OPERATOR_IS_ALL, 14744 OPERATOR_IS_NOT_ALL 14745 ], 14746 format: {}, 14747 getValueFormatted: get_value_formatted_default_default, 14748 validate: { 14749 required: isValidRequired, 14750 pattern: isValidPattern, 14751 minLength: isValidMinLength, 14752 maxLength: isValidMaxLength, 14753 elements: isValidElements, 14754 custom: isValidCustom 14755 } 14756 }; 14757 14758 // packages/dataviews/build-module/field-types/integer.js 14759 var import_i18n37 = __toESM(require_i18n()); 14760 14761 // packages/dataviews/build-module/field-types/utils/sort-number.js 14762 var sort_number_default = (a2, b2, direction) => { 14763 return direction === "asc" ? a2 - b2 : b2 - a2; 14764 }; 14765 14766 // packages/dataviews/build-module/field-types/utils/is-valid-min.js 14767 function isValidMin(item, field) { 14768 if (typeof field.isValid.min?.constraint !== "number") { 14769 return false; 14770 } 14771 const value = field.getValue({ item }); 14772 if ([void 0, "", null].includes(value)) { 14773 return true; 14774 } 14775 return Number(value) >= field.isValid.min.constraint; 14776 } 14777 14778 // packages/dataviews/build-module/field-types/utils/is-valid-max.js 14779 function isValidMax(item, field) { 14780 if (typeof field.isValid.max?.constraint !== "number") { 14781 return false; 14782 } 14783 const value = field.getValue({ item }); 14784 if ([void 0, "", null].includes(value)) { 14785 return true; 14786 } 14787 return Number(value) <= field.isValid.max.constraint; 14788 } 14789 14790 // packages/dataviews/build-module/field-types/integer.js 14791 var format2 = { 14792 separatorThousand: "," 14793 }; 14794 function getValueFormatted2({ 14795 item, 14796 field 14797 }) { 14798 let value = field.getValue({ item }); 14799 if (value === null || value === void 0) { 14800 return ""; 14801 } 14802 value = Number(value); 14803 if (!Number.isFinite(value)) { 14804 return String(value); 14805 } 14806 let formatInteger; 14807 if (field.type !== "integer") { 14808 formatInteger = format2; 14809 } else { 14810 formatInteger = field.format; 14811 } 14812 const { separatorThousand } = formatInteger; 14813 const integerValue = Math.trunc(value); 14814 if (!separatorThousand) { 14815 return String(integerValue); 14816 } 14817 return String(integerValue).replace( 14818 /\B(?=(\d{3})+(?!\d))/g, 14819 separatorThousand 14820 ); 14821 } 14822 function isValidCustom2(item, field) { 14823 const value = field.getValue({ item }); 14824 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) { 14825 return (0, import_i18n37.__)("Value must be an integer."); 14826 } 14827 return null; 14828 } 14829 var integer_default = { 14830 type: "integer", 14831 render, 14832 Edit: "integer", 14833 sort: sort_number_default, 14834 enableSorting: true, 14835 enableGlobalSearch: false, 14836 defaultOperators: [ 14837 OPERATOR_IS, 14838 OPERATOR_IS_NOT, 14839 OPERATOR_LESS_THAN, 14840 OPERATOR_GREATER_THAN, 14841 OPERATOR_LESS_THAN_OR_EQUAL, 14842 OPERATOR_GREATER_THAN_OR_EQUAL, 14843 OPERATOR_BETWEEN 14844 ], 14845 validOperators: [ 14846 // Single-selection 14847 OPERATOR_IS, 14848 OPERATOR_IS_NOT, 14849 OPERATOR_LESS_THAN, 14850 OPERATOR_GREATER_THAN, 14851 OPERATOR_LESS_THAN_OR_EQUAL, 14852 OPERATOR_GREATER_THAN_OR_EQUAL, 14853 OPERATOR_BETWEEN, 14854 // Multiple-selection 14855 OPERATOR_IS_ANY, 14856 OPERATOR_IS_NONE, 14857 OPERATOR_IS_ALL, 14858 OPERATOR_IS_NOT_ALL 14859 ], 14860 format: format2, 14861 getValueFormatted: getValueFormatted2, 14862 validate: { 14863 required: isValidRequired, 14864 min: isValidMin, 14865 max: isValidMax, 14866 elements: isValidElements, 14867 custom: isValidCustom2 14868 } 14869 }; 14870 14871 // packages/dataviews/build-module/field-types/number.js 14872 var import_i18n38 = __toESM(require_i18n()); 14873 var format3 = { 14874 separatorThousand: ",", 14875 separatorDecimal: ".", 14876 decimals: 2 14877 }; 14878 function getValueFormatted3({ 14879 item, 14880 field 14881 }) { 14882 let value = field.getValue({ item }); 14883 if (value === null || value === void 0) { 14884 return ""; 14885 } 14886 value = Number(value); 14887 if (!Number.isFinite(value)) { 14888 return String(value); 14889 } 14890 let formatNumber; 14891 if (field.type !== "number") { 14892 formatNumber = format3; 14893 } else { 14894 formatNumber = field.format; 14895 } 14896 const { separatorThousand, separatorDecimal, decimals } = formatNumber; 14897 const fixedValue = value.toFixed(decimals); 14898 const [integerPart, decimalPart] = fixedValue.split("."); 14899 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart; 14900 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart; 14901 } 14902 function isEmpty2(value) { 14903 return value === "" || value === void 0 || value === null; 14904 } 14905 function isValidCustom3(item, field) { 14906 const value = field.getValue({ item }); 14907 if (!isEmpty2(value) && !Number.isFinite(value)) { 14908 return (0, import_i18n38.__)("Value must be a number."); 14909 } 14910 return null; 14911 } 14912 var number_default = { 14913 type: "number", 14914 render, 14915 Edit: "number", 14916 sort: sort_number_default, 14917 enableSorting: true, 14918 enableGlobalSearch: false, 14919 defaultOperators: [ 14920 OPERATOR_IS, 14921 OPERATOR_IS_NOT, 14922 OPERATOR_LESS_THAN, 14923 OPERATOR_GREATER_THAN, 14924 OPERATOR_LESS_THAN_OR_EQUAL, 14925 OPERATOR_GREATER_THAN_OR_EQUAL, 14926 OPERATOR_BETWEEN 14927 ], 14928 validOperators: [ 14929 // Single-selection 14930 OPERATOR_IS, 14931 OPERATOR_IS_NOT, 14932 OPERATOR_LESS_THAN, 14933 OPERATOR_GREATER_THAN, 14934 OPERATOR_LESS_THAN_OR_EQUAL, 14935 OPERATOR_GREATER_THAN_OR_EQUAL, 14936 OPERATOR_BETWEEN, 14937 // Multiple-selection 14938 OPERATOR_IS_ANY, 14939 OPERATOR_IS_NONE, 14940 OPERATOR_IS_ALL, 14941 OPERATOR_IS_NOT_ALL 14942 ], 14943 format: format3, 14944 getValueFormatted: getValueFormatted3, 14945 validate: { 14946 required: isValidRequired, 14947 min: isValidMin, 14948 max: isValidMax, 14949 elements: isValidElements, 14950 custom: isValidCustom3 14951 } 14952 }; 14953 14954 // packages/dataviews/build-module/field-types/text.js 14955 var text_default = { 14956 type: "text", 14957 render, 14958 Edit: "text", 14959 sort: sort_text_default, 14960 enableSorting: true, 14961 enableGlobalSearch: false, 14962 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 14963 validOperators: [ 14964 // Single selection 14965 OPERATOR_IS, 14966 OPERATOR_IS_NOT, 14967 OPERATOR_CONTAINS, 14968 OPERATOR_NOT_CONTAINS, 14969 OPERATOR_STARTS_WITH, 14970 // Multiple selection 14971 OPERATOR_IS_ANY, 14972 OPERATOR_IS_NONE, 14973 OPERATOR_IS_ALL, 14974 OPERATOR_IS_NOT_ALL 14975 ], 14976 format: {}, 14977 getValueFormatted: get_value_formatted_default_default, 14978 validate: { 14979 required: isValidRequired, 14980 pattern: isValidPattern, 14981 minLength: isValidMinLength, 14982 maxLength: isValidMaxLength, 14983 elements: isValidElements 14984 } 14985 }; 14986 14987 // packages/dataviews/build-module/field-types/datetime.js 14988 var import_date5 = __toESM(require_date()); 14989 var format4 = { 14990 datetime: (0, import_date5.getSettings)().formats.datetime, 14991 weekStartsOn: (0, import_date5.getSettings)().l10n.startOfWeek 14992 }; 14993 function getValueFormatted4({ 14994 item, 14995 field 14996 }) { 14997 const value = field.getValue({ item }); 14998 if (["", void 0, null].includes(value)) { 14999 return ""; 15000 } 15001 let formatDatetime; 15002 if (field.type !== "datetime") { 15003 formatDatetime = format4; 15004 } else { 15005 formatDatetime = field.format; 15006 } 15007 return (0, import_date5.dateI18n)(formatDatetime.datetime, (0, import_date5.getDate)(value)); 15008 } 15009 var sort = (a2, b2, direction) => { 15010 const timeA = new Date(a2).getTime(); 15011 const timeB = new Date(b2).getTime(); 15012 return direction === "asc" ? timeA - timeB : timeB - timeA; 15013 }; 15014 var datetime_default = { 15015 type: "datetime", 15016 render, 15017 Edit: "datetime", 15018 sort, 15019 enableSorting: true, 15020 enableGlobalSearch: false, 15021 defaultOperators: [ 15022 OPERATOR_ON, 15023 OPERATOR_NOT_ON, 15024 OPERATOR_BEFORE, 15025 OPERATOR_AFTER, 15026 OPERATOR_BEFORE_INC, 15027 OPERATOR_AFTER_INC, 15028 OPERATOR_IN_THE_PAST, 15029 OPERATOR_OVER 15030 ], 15031 validOperators: [ 15032 OPERATOR_ON, 15033 OPERATOR_NOT_ON, 15034 OPERATOR_BEFORE, 15035 OPERATOR_AFTER, 15036 OPERATOR_BEFORE_INC, 15037 OPERATOR_AFTER_INC, 15038 OPERATOR_IN_THE_PAST, 15039 OPERATOR_OVER 15040 ], 15041 format: format4, 15042 getValueFormatted: getValueFormatted4, 15043 validate: { 15044 required: isValidRequired, 15045 elements: isValidElements 15046 } 15047 }; 15048 15049 // packages/dataviews/build-module/field-types/date.js 15050 var import_date6 = __toESM(require_date()); 15051 var format5 = { 15052 date: (0, import_date6.getSettings)().formats.date, 15053 weekStartsOn: (0, import_date6.getSettings)().l10n.startOfWeek 15054 }; 15055 function getValueFormatted5({ 15056 item, 15057 field 15058 }) { 15059 const value = field.getValue({ item }); 15060 if (["", void 0, null].includes(value)) { 15061 return ""; 15062 } 15063 let formatDate2; 15064 if (field.type !== "date") { 15065 formatDate2 = format5; 15066 } else { 15067 formatDate2 = field.format; 15068 } 15069 return (0, import_date6.dateI18n)(formatDate2.date, (0, import_date6.getDate)(value)); 15070 } 15071 var sort2 = (a2, b2, direction) => { 15072 const timeA = new Date(a2).getTime(); 15073 const timeB = new Date(b2).getTime(); 15074 return direction === "asc" ? timeA - timeB : timeB - timeA; 15075 }; 15076 var date_default = { 15077 type: "date", 15078 render, 15079 Edit: "date", 15080 sort: sort2, 15081 enableSorting: true, 15082 enableGlobalSearch: false, 15083 defaultOperators: [ 15084 OPERATOR_ON, 15085 OPERATOR_NOT_ON, 15086 OPERATOR_BEFORE, 15087 OPERATOR_AFTER, 15088 OPERATOR_BEFORE_INC, 15089 OPERATOR_AFTER_INC, 15090 OPERATOR_IN_THE_PAST, 15091 OPERATOR_OVER, 15092 OPERATOR_BETWEEN 15093 ], 15094 validOperators: [ 15095 OPERATOR_ON, 15096 OPERATOR_NOT_ON, 15097 OPERATOR_BEFORE, 15098 OPERATOR_AFTER, 15099 OPERATOR_BEFORE_INC, 15100 OPERATOR_AFTER_INC, 15101 OPERATOR_IN_THE_PAST, 15102 OPERATOR_OVER, 15103 OPERATOR_BETWEEN 15104 ], 15105 format: format5, 15106 getValueFormatted: getValueFormatted5, 15107 validate: { 15108 required: isValidRequired, 15109 elements: isValidElements 15110 } 15111 }; 15112 15113 // packages/dataviews/build-module/field-types/boolean.js 15114 var import_i18n39 = __toESM(require_i18n()); 15115 15116 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.js 15117 function isValidRequiredForBool(item, field) { 15118 const value = field.getValue({ item }); 15119 return value === true; 15120 } 15121 15122 // packages/dataviews/build-module/field-types/boolean.js 15123 function getValueFormatted6({ 15124 item, 15125 field 15126 }) { 15127 const value = field.getValue({ item }); 15128 if (value === true) { 15129 return (0, import_i18n39.__)("True"); 15130 } 15131 if (value === false) { 15132 return (0, import_i18n39.__)("False"); 15133 } 15134 return ""; 15135 } 15136 function isValidCustom4(item, field) { 15137 const value = field.getValue({ item }); 15138 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) { 15139 return (0, import_i18n39.__)("Value must be true, false, or undefined"); 15140 } 15141 return null; 15142 } 15143 var sort3 = (a2, b2, direction) => { 15144 const boolA = Boolean(a2); 15145 const boolB = Boolean(b2); 15146 if (boolA === boolB) { 15147 return 0; 15148 } 15149 if (direction === "asc") { 15150 return boolA ? 1 : -1; 15151 } 15152 return boolA ? -1 : 1; 15153 }; 15154 var boolean_default = { 15155 type: "boolean", 15156 render, 15157 Edit: "checkbox", 15158 sort: sort3, 15159 validate: { 15160 required: isValidRequiredForBool, 15161 elements: isValidElements, 15162 custom: isValidCustom4 15163 }, 15164 enableSorting: true, 15165 enableGlobalSearch: false, 15166 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 15167 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 15168 format: {}, 15169 getValueFormatted: getValueFormatted6 15170 }; 15171 15172 // packages/dataviews/build-module/field-types/media.js 15173 var media_default = { 15174 type: "media", 15175 render: () => null, 15176 Edit: null, 15177 sort: () => 0, 15178 enableSorting: false, 15179 enableGlobalSearch: false, 15180 defaultOperators: [], 15181 validOperators: [], 15182 format: {}, 15183 getValueFormatted: get_value_formatted_default_default, 15184 // cannot validate any constraint, so 15185 // the only available validation for the field author 15186 // would be providing a custom validator. 15187 validate: {} 15188 }; 15189 15190 // packages/dataviews/build-module/field-types/array.js 15191 var import_i18n40 = __toESM(require_i18n()); 15192 15193 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.js 15194 function isValidRequiredForArray(item, field) { 15195 const value = field.getValue({ item }); 15196 return Array.isArray(value) && value.length > 0 && value.every( 15197 (element) => ![void 0, "", null].includes(element) 15198 ); 15199 } 15200 15201 // packages/dataviews/build-module/field-types/array.js 15202 function getValueFormatted7({ 15203 item, 15204 field 15205 }) { 15206 const value = field.getValue({ item }); 15207 const arr = Array.isArray(value) ? value : []; 15208 return arr.join(", "); 15209 } 15210 function render2({ item, field }) { 15211 return getValueFormatted7({ item, field }); 15212 } 15213 function isValidCustom5(item, field) { 15214 const value = field.getValue({ item }); 15215 if (![void 0, "", null].includes(value) && !Array.isArray(value)) { 15216 return (0, import_i18n40.__)("Value must be an array."); 15217 } 15218 if (!value.every((v2) => typeof v2 === "string")) { 15219 return (0, import_i18n40.__)("Every value must be a string."); 15220 } 15221 return null; 15222 } 15223 var sort4 = (a2, b2, direction) => { 15224 const arrA = Array.isArray(a2) ? a2 : []; 15225 const arrB = Array.isArray(b2) ? b2 : []; 15226 if (arrA.length !== arrB.length) { 15227 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length; 15228 } 15229 const joinedA = arrA.join(","); 15230 const joinedB = arrB.join(","); 15231 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA); 15232 }; 15233 var array_default = { 15234 type: "array", 15235 render: render2, 15236 Edit: "array", 15237 sort: sort4, 15238 enableSorting: true, 15239 enableGlobalSearch: false, 15240 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15241 validOperators: [ 15242 OPERATOR_IS_ANY, 15243 OPERATOR_IS_NONE, 15244 OPERATOR_IS_ALL, 15245 OPERATOR_IS_NOT_ALL 15246 ], 15247 format: {}, 15248 getValueFormatted: getValueFormatted7, 15249 validate: { 15250 required: isValidRequiredForArray, 15251 elements: isValidElements, 15252 custom: isValidCustom5 15253 } 15254 }; 15255 15256 // packages/dataviews/build-module/field-types/password.js 15257 function getValueFormatted8({ 15258 item, 15259 field 15260 }) { 15261 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : ""; 15262 } 15263 var password_default = { 15264 type: "password", 15265 render, 15266 Edit: "password", 15267 sort: () => 0, 15268 // Passwords should not be sortable for security reasons 15269 enableSorting: false, 15270 enableGlobalSearch: false, 15271 defaultOperators: [], 15272 validOperators: [], 15273 format: {}, 15274 getValueFormatted: getValueFormatted8, 15275 validate: { 15276 required: isValidRequired, 15277 pattern: isValidPattern, 15278 minLength: isValidMinLength, 15279 maxLength: isValidMaxLength, 15280 elements: isValidElements 15281 } 15282 }; 15283 15284 // packages/dataviews/build-module/field-types/telephone.js 15285 var telephone_default = { 15286 type: "telephone", 15287 render, 15288 Edit: "telephone", 15289 sort: sort_text_default, 15290 enableSorting: true, 15291 enableGlobalSearch: false, 15292 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15293 validOperators: [ 15294 OPERATOR_IS, 15295 OPERATOR_IS_NOT, 15296 OPERATOR_CONTAINS, 15297 OPERATOR_NOT_CONTAINS, 15298 OPERATOR_STARTS_WITH, 15299 // Multiple selection 15300 OPERATOR_IS_ANY, 15301 OPERATOR_IS_NONE, 15302 OPERATOR_IS_ALL, 15303 OPERATOR_IS_NOT_ALL 15304 ], 15305 format: {}, 15306 getValueFormatted: get_value_formatted_default_default, 15307 validate: { 15308 required: isValidRequired, 15309 pattern: isValidPattern, 15310 minLength: isValidMinLength, 15311 maxLength: isValidMaxLength, 15312 elements: isValidElements 15313 } 15314 }; 15315 15316 // packages/dataviews/build-module/field-types/color.js 15317 var import_i18n41 = __toESM(require_i18n()); 15318 var import_jsx_runtime95 = __toESM(require_jsx_runtime()); 15319 function render3({ item, field }) { 15320 if (field.hasElements) { 15321 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(RenderFromElements, { item, field }); 15322 } 15323 const value = get_value_formatted_default_default({ item, field }); 15324 if (!value || !w(value).isValid()) { 15325 return value; 15326 } 15327 return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [ 15328 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 15329 "div", 15330 { 15331 style: { 15332 width: "16px", 15333 height: "16px", 15334 borderRadius: "50%", 15335 backgroundColor: value, 15336 border: "1px solid #ddd", 15337 flexShrink: 0 15338 } 15339 } 15340 ), 15341 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { children: value }) 15342 ] }); 15343 } 15344 function isValidCustom6(item, field) { 15345 const value = field.getValue({ item }); 15346 if (![void 0, "", null].includes(value) && !w(value).isValid()) { 15347 return (0, import_i18n41.__)("Value must be a valid color."); 15348 } 15349 return null; 15350 } 15351 var sort5 = (a2, b2, direction) => { 15352 const colorA = w(a2); 15353 const colorB = w(b2); 15354 if (!colorA.isValid() && !colorB.isValid()) { 15355 return 0; 15356 } 15357 if (!colorA.isValid()) { 15358 return direction === "asc" ? 1 : -1; 15359 } 15360 if (!colorB.isValid()) { 15361 return direction === "asc" ? -1 : 1; 15362 } 15363 const hslA = colorA.toHsl(); 15364 const hslB = colorB.toHsl(); 15365 if (hslA.h !== hslB.h) { 15366 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h; 15367 } 15368 if (hslA.s !== hslB.s) { 15369 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s; 15370 } 15371 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l; 15372 }; 15373 var color_default = { 15374 type: "color", 15375 render: render3, 15376 Edit: "color", 15377 sort: sort5, 15378 enableSorting: true, 15379 enableGlobalSearch: false, 15380 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15381 validOperators: [ 15382 OPERATOR_IS, 15383 OPERATOR_IS_NOT, 15384 OPERATOR_IS_ANY, 15385 OPERATOR_IS_NONE 15386 ], 15387 format: {}, 15388 getValueFormatted: get_value_formatted_default_default, 15389 validate: { 15390 required: isValidRequired, 15391 elements: isValidElements, 15392 custom: isValidCustom6 15393 } 15394 }; 15395 15396 // packages/dataviews/build-module/field-types/url.js 15397 var url_default = { 15398 type: "url", 15399 render, 15400 Edit: "url", 15401 sort: sort_text_default, 15402 enableSorting: true, 15403 enableGlobalSearch: false, 15404 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15405 validOperators: [ 15406 OPERATOR_IS, 15407 OPERATOR_IS_NOT, 15408 OPERATOR_CONTAINS, 15409 OPERATOR_NOT_CONTAINS, 15410 OPERATOR_STARTS_WITH, 15411 // Multiple selection 15412 OPERATOR_IS_ANY, 15413 OPERATOR_IS_NONE, 15414 OPERATOR_IS_ALL, 15415 OPERATOR_IS_NOT_ALL 15416 ], 15417 format: {}, 15418 getValueFormatted: get_value_formatted_default_default, 15419 validate: { 15420 required: isValidRequired, 15421 pattern: isValidPattern, 15422 minLength: isValidMinLength, 15423 maxLength: isValidMaxLength, 15424 elements: isValidElements 15425 } 15426 }; 15427 15428 // packages/dataviews/build-module/field-types/no-type.js 15429 var sort6 = (a2, b2, direction) => { 15430 if (typeof a2 === "number" && typeof b2 === "number") { 15431 return sort_number_default(a2, b2, direction); 15432 } 15433 return sort_text_default(a2, b2, direction); 15434 }; 15435 var no_type_default = { 15436 // type: no type for this one 15437 render, 15438 Edit: null, 15439 sort: sort6, 15440 enableSorting: true, 15441 enableGlobalSearch: false, 15442 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 15443 validOperators: getAllOperatorNames(), 15444 format: {}, 15445 getValueFormatted: get_value_formatted_default_default, 15446 validate: { 15447 required: isValidRequired, 15448 elements: isValidElements 15449 } 15450 }; 15451 15452 // packages/dataviews/build-module/field-types/utils/get-is-valid.js 15453 function getIsValid(field, fieldType) { 15454 let required; 15455 if (field.isValid?.required === true && fieldType.validate.required !== void 0) { 15456 required = { 15457 constraint: true, 15458 validate: fieldType.validate.required 15459 }; 15460 } 15461 let elements; 15462 if ((field.isValid?.elements === true || // elements is enabled unless the field opts-out 15463 field.isValid?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) { 15464 elements = { 15465 constraint: true, 15466 validate: fieldType.validate.elements 15467 }; 15468 } 15469 let min; 15470 if (typeof field.isValid?.min === "number" && fieldType.validate.min !== void 0) { 15471 min = { 15472 constraint: field.isValid.min, 15473 validate: fieldType.validate.min 15474 }; 15475 } 15476 let max; 15477 if (typeof field.isValid?.max === "number" && fieldType.validate.max !== void 0) { 15478 max = { 15479 constraint: field.isValid.max, 15480 validate: fieldType.validate.max 15481 }; 15482 } 15483 let minLength; 15484 if (typeof field.isValid?.minLength === "number" && fieldType.validate.minLength !== void 0) { 15485 minLength = { 15486 constraint: field.isValid.minLength, 15487 validate: fieldType.validate.minLength 15488 }; 15489 } 15490 let maxLength; 15491 if (typeof field.isValid?.maxLength === "number" && fieldType.validate.maxLength !== void 0) { 15492 maxLength = { 15493 constraint: field.isValid.maxLength, 15494 validate: fieldType.validate.maxLength 15495 }; 15496 } 15497 let pattern; 15498 if (field.isValid?.pattern !== void 0 && fieldType.validate.pattern !== void 0) { 15499 pattern = { 15500 constraint: field.isValid?.pattern, 15501 validate: fieldType.validate.pattern 15502 }; 15503 } 15504 const custom = field.isValid?.custom ?? fieldType.validate.custom; 15505 return { 15506 required, 15507 elements, 15508 min, 15509 max, 15510 minLength, 15511 maxLength, 15512 pattern, 15513 custom 15514 }; 15515 } 15516 15517 // packages/dataviews/build-module/field-types/utils/get-format.js 15518 function getFormat(field, fieldType) { 15519 return { 15520 ...fieldType.format, 15521 ...field.format 15522 }; 15523 } 15524 var get_format_default = getFormat; 15525 15526 // packages/dataviews/build-module/field-types/index.js 15527 function getFieldTypeByName(type) { 15528 const found = [ 15529 email_default, 15530 integer_default, 15531 number_default, 15532 text_default, 15533 datetime_default, 15534 date_default, 15535 boolean_default, 15536 media_default, 15537 array_default, 15538 password_default, 15539 telephone_default, 15540 color_default, 15541 url_default 15542 ].find((fieldType) => fieldType?.type === type); 15543 if (!!found) { 15544 return found; 15545 } 15546 return no_type_default; 15547 } 15548 function normalizeFields(fields) { 15549 return fields.map((field) => { 15550 const fieldType = getFieldTypeByName(field.type); 15551 const getValue = field.getValue || get_value_from_id_default(field.id); 15552 const sort7 = function(a2, b2, direction) { 15553 const aValue = getValue({ item: a2 }); 15554 const bValue = getValue({ item: b2 }); 15555 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction); 15556 }; 15557 return { 15558 id: field.id, 15559 label: field.label || field.id, 15560 header: field.header || field.label || field.id, 15561 description: field.description, 15562 placeholder: field.placeholder, 15563 getValue, 15564 setValue: field.setValue || set_value_from_id_default(field.id), 15565 elements: field.elements, 15566 getElements: field.getElements, 15567 hasElements: hasElements(field), 15568 isVisible: field.isVisible, 15569 enableHiding: field.enableHiding ?? true, 15570 readOnly: field.readOnly ?? false, 15571 // The type provides defaults for the following props 15572 type: fieldType.type, 15573 render: field.render ?? fieldType.render, 15574 Edit: getControl(field, fieldType.Edit), 15575 sort: sort7, 15576 enableSorting: field.enableSorting ?? fieldType.enableSorting, 15577 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch, 15578 isValid: getIsValid(field, fieldType), 15579 filterBy: get_filter_by_default( 15580 field, 15581 fieldType.defaultOperators, 15582 fieldType.validOperators 15583 ), 15584 format: get_format_default(field, fieldType), 15585 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted 15586 }; 15587 }); 15588 } 15589 15590 // packages/dataviews/build-module/components/dataviews/index.js 15591 var import_jsx_runtime96 = __toESM(require_jsx_runtime()); 15592 var defaultGetItemId = (item) => item.id; 15593 var defaultIsItemClickable = () => true; 15594 var EMPTY_ARRAY5 = []; 15595 var dataViewsLayouts = VIEW_LAYOUTS.filter( 15596 (viewLayout) => !viewLayout.isPicker 15597 ); 15598 function DefaultUI({ 15599 header, 15600 search = true, 15601 searchLabel = void 0 15602 }) { 15603 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(import_jsx_runtime96.Fragment, { children: [ 15604 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)( 15605 import_components49.__experimentalHStack, 15606 { 15607 alignment: "top", 15608 justify: "space-between", 15609 className: "dataviews__view-actions", 15610 spacing: 1, 15611 children: [ 15612 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)( 15613 import_components49.__experimentalHStack, 15614 { 15615 justify: "start", 15616 expanded: false, 15617 className: "dataviews__search", 15618 children: [ 15619 search && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(dataviews_search_default, { label: searchLabel }), 15620 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(toggle_default, {}) 15621 ] 15622 } 15623 ), 15624 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)( 15625 import_components49.__experimentalHStack, 15626 { 15627 spacing: 1, 15628 expanded: false, 15629 style: { flexShrink: 0 }, 15630 children: [ 15631 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(dataviews_view_config_default, {}), 15632 header 15633 ] 15634 } 15635 ) 15636 ] 15637 } 15638 ), 15639 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }), 15640 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(DataViewsLayout, {}), 15641 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(DataViewsFooter, {}) 15642 ] }); 15643 } 15644 function DataViews({ 15645 view, 15646 onChangeView, 15647 fields, 15648 search = true, 15649 searchLabel = void 0, 15650 actions = EMPTY_ARRAY5, 15651 data, 15652 getItemId: getItemId2 = defaultGetItemId, 15653 getItemLevel, 15654 isLoading = false, 15655 paginationInfo, 15656 defaultLayouts: defaultLayoutsProperty, 15657 selection: selectionProperty, 15658 onChangeSelection, 15659 onClickItem, 15660 renderItemLink, 15661 isItemClickable = defaultIsItemClickable, 15662 header, 15663 children, 15664 config = { perPageSizes: [10, 20, 50, 100] }, 15665 empty 15666 }) { 15667 const { infiniteScrollHandler } = paginationInfo; 15668 const containerRef = (0, import_element52.useRef)(null); 15669 const [containerWidth, setContainerWidth] = (0, import_element52.useState)(0); 15670 const resizeObserverRef = (0, import_compose11.useResizeObserver)( 15671 (resizeObserverEntries) => { 15672 setContainerWidth( 15673 resizeObserverEntries[0].borderBoxSize[0].inlineSize 15674 ); 15675 }, 15676 { box: "border-box" } 15677 ); 15678 const [selectionState, setSelectionState] = (0, import_element52.useState)([]); 15679 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0; 15680 const selection = isUncontrolled ? selectionState : selectionProperty; 15681 const [openedFilter, setOpenedFilter] = (0, import_element52.useState)(null); 15682 function setSelectionWithChange(value) { 15683 const newValue = typeof value === "function" ? value(selection) : value; 15684 if (isUncontrolled) { 15685 setSelectionState(newValue); 15686 } 15687 if (onChangeSelection) { 15688 onChangeSelection(newValue); 15689 } 15690 } 15691 const _fields = (0, import_element52.useMemo)(() => normalizeFields(fields), [fields]); 15692 const _selection = (0, import_element52.useMemo)(() => { 15693 return selection.filter( 15694 (id) => data.some((item) => getItemId2(item) === id) 15695 ); 15696 }, [selection, data, getItemId2]); 15697 const filters = use_filters_default(_fields, view); 15698 const hasPrimaryOrLockedFilters = (0, import_element52.useMemo)( 15699 () => (filters || []).some( 15700 (filter) => filter.isPrimary || filter.isLocked 15701 ), 15702 [filters] 15703 ); 15704 const [isShowingFilter, setIsShowingFilter] = (0, import_element52.useState)( 15705 hasPrimaryOrLockedFilters 15706 ); 15707 (0, import_element52.useEffect)(() => { 15708 if (hasPrimaryOrLockedFilters && !isShowingFilter) { 15709 setIsShowingFilter(true); 15710 } 15711 }, [hasPrimaryOrLockedFilters, isShowingFilter]); 15712 (0, import_element52.useEffect)(() => { 15713 if (!view.infiniteScrollEnabled || !containerRef.current) { 15714 return; 15715 } 15716 const handleScroll = (0, import_compose11.throttle)((event) => { 15717 const target = event.target; 15718 const scrollTop = target.scrollTop; 15719 const scrollHeight = target.scrollHeight; 15720 const clientHeight = target.clientHeight; 15721 if (scrollTop + clientHeight >= scrollHeight - 100) { 15722 infiniteScrollHandler?.(); 15723 } 15724 }, 100); 15725 const container = containerRef.current; 15726 container.addEventListener("scroll", handleScroll); 15727 return () => { 15728 container.removeEventListener("scroll", handleScroll); 15729 handleScroll.cancel(); 15730 }; 15731 }, [infiniteScrollHandler, view.infiniteScrollEnabled]); 15732 const defaultLayouts = (0, import_element52.useMemo)( 15733 () => Object.fromEntries( 15734 Object.entries(defaultLayoutsProperty).filter( 15735 ([layoutType]) => { 15736 return dataViewsLayouts.some( 15737 (viewLayout) => viewLayout.type === layoutType 15738 ); 15739 } 15740 ) 15741 ), 15742 [defaultLayoutsProperty] 15743 ); 15744 if (!defaultLayouts[view.type]) { 15745 return null; 15746 } 15747 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 15748 dataviews_context_default.Provider, 15749 { 15750 value: { 15751 view, 15752 onChangeView, 15753 fields: _fields, 15754 actions, 15755 data, 15756 isLoading, 15757 paginationInfo, 15758 selection: _selection, 15759 onChangeSelection: setSelectionWithChange, 15760 openedFilter, 15761 setOpenedFilter, 15762 getItemId: getItemId2, 15763 getItemLevel, 15764 isItemClickable, 15765 onClickItem, 15766 renderItemLink, 15767 containerWidth, 15768 containerRef, 15769 resizeObserverRef, 15770 defaultLayouts, 15771 filters, 15772 isShowingFilter, 15773 setIsShowingFilter, 15774 config, 15775 empty, 15776 hasInfiniteScrollHandler: !!infiniteScrollHandler 15777 }, 15778 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: "dataviews-wrapper", ref: containerRef, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 15779 DefaultUI, 15780 { 15781 header, 15782 search, 15783 searchLabel 15784 } 15785 ) }) 15786 } 15787 ); 15788 } 15789 var DataViewsSubComponents = DataViews; 15790 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter; 15791 DataViewsSubComponents.Filters = filters_default; 15792 DataViewsSubComponents.FiltersToggled = filters_toggled_default; 15793 DataViewsSubComponents.FiltersToggle = toggle_default; 15794 DataViewsSubComponents.Layout = DataViewsLayout; 15795 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu; 15796 DataViewsSubComponents.Pagination = DataViewsPagination; 15797 DataViewsSubComponents.Search = dataviews_search_default; 15798 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown; 15799 DataViewsSubComponents.Footer = DataViewsFooter; 15800 var dataviews_default = DataViewsSubComponents; 15801 15802 // packages/admin-ui/build-module/navigable-region/index.js 15803 var import_element53 = __toESM(require_element()); 15804 var import_jsx_runtime97 = __toESM(require_jsx_runtime()); 15805 var NavigableRegion = (0, import_element53.forwardRef)( 15806 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => { 15807 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 15808 Tag, 15809 { 15810 ref, 15811 className: clsx_default("admin-ui-navigable-region", className), 15812 "aria-label": ariaLabel, 15813 role: "region", 15814 tabIndex: "-1", 15815 ...props, 15816 children 15817 } 15818 ); 15819 } 15820 ); 15821 NavigableRegion.displayName = "NavigableRegion"; 15822 var navigable_region_default = NavigableRegion; 15823 15824 // packages/admin-ui/build-module/page/header.js 15825 var import_components51 = __toESM(require_components()); 15826 15827 // packages/admin-ui/build-module/page/sidebar-toggle-slot.js 15828 var import_components50 = __toESM(require_components()); 15829 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components50.createSlotFill)("SidebarToggle"); 15830 15831 // packages/admin-ui/build-module/page/header.js 15832 var import_jsx_runtime98 = __toESM(require_jsx_runtime()); 15833 function Header({ 15834 breadcrumbs, 15835 badges, 15836 title, 15837 subTitle, 15838 actions, 15839 showSidebarToggle = true 15840 }) { 15841 return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_components51.__experimentalVStack, { className: "admin-ui-page__header", as: "header", children: [ 15842 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_components51.__experimentalHStack, { justify: "space-between", spacing: 2, children: [ 15843 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_components51.__experimentalHStack, { spacing: 2, justify: "left", children: [ 15844 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 15845 SidebarToggleSlot, 15846 { 15847 bubblesVirtually: true, 15848 className: "admin-ui-page__sidebar-toggle-slot" 15849 } 15850 ), 15851 title && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components51.__experimentalHeading, { as: "h2", level: 3, weight: 500, truncate: true, children: title }), 15852 breadcrumbs, 15853 badges 15854 ] }), 15855 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 15856 import_components51.__experimentalHStack, 15857 { 15858 style: { width: "auto", flexShrink: 0 }, 15859 spacing: 2, 15860 className: "admin-ui-page__header-actions", 15861 children: actions 15862 } 15863 ) 15864 ] }), 15865 subTitle && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("p", { className: "admin-ui-page__header-subtitle", children: subTitle }) 15866 ] }); 15867 } 15868 15869 // packages/admin-ui/build-module/page/index.js 15870 var import_jsx_runtime99 = __toESM(require_jsx_runtime()); 15871 function Page({ 15872 breadcrumbs, 15873 badges, 15874 title, 15875 subTitle, 15876 children, 15877 className, 15878 actions, 15879 hasPadding = false, 15880 showSidebarToggle = true 15881 }) { 15882 const classes = clsx_default("admin-ui-page", className); 15883 return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(navigable_region_default, { className: classes, ariaLabel: title, children: [ 15884 (title || breadcrumbs || badges) && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 15885 Header, 15886 { 15887 breadcrumbs, 15888 badges, 15889 title, 15890 subTitle, 15891 actions, 15892 showSidebarToggle 15893 } 15894 ), 15895 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "admin-ui-page__content has-padding", children }) : children 15896 ] }); 15897 } 15898 Page.SidebarToggleFill = SidebarToggleFill; 15899 var page_default = Page; 15900 15901 // routes/template-part-list/stage.tsx 15902 var import_core_data4 = __toESM(require_core_data()); 15903 var import_components53 = __toESM(require_components()); 15904 var import_data11 = __toESM(require_data()); 15905 var import_element55 = __toESM(require_element()); 15906 var import_editor = __toESM(require_editor()); 15907 var import_i18n44 = __toESM(require_i18n()); 15908 15909 // node_modules/tslib/tslib.es6.mjs 15910 var __assign = function() { 15911 __assign = Object.assign || function __assign2(t2) { 15912 for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) { 15913 s2 = arguments[i2]; 15914 for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) t2[p2] = s2[p2]; 15915 } 15916 return t2; 15917 }; 15918 return __assign.apply(this, arguments); 15919 }; 15920 15921 // node_modules/lower-case/dist.es2015/index.js 15922 function lowerCase(str) { 15923 return str.toLowerCase(); 15924 } 15925 15926 // node_modules/no-case/dist.es2015/index.js 15927 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 15928 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 15929 function noCase(input, options) { 15930 if (options === void 0) { 15931 options = {}; 15932 } 15933 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; 15934 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 15935 var start = 0; 15936 var end = result.length; 15937 while (result.charAt(start) === "\0") 15938 start++; 15939 while (result.charAt(end - 1) === "\0") 15940 end--; 15941 return result.slice(start, end).split("\0").map(transform).join(delimiter); 15942 } 15943 function replace(input, re, value) { 15944 if (re instanceof RegExp) 15945 return input.replace(re, value); 15946 return re.reduce(function(input2, re2) { 15947 return input2.replace(re2, value); 15948 }, input); 15949 } 15950 15951 // node_modules/dot-case/dist.es2015/index.js 15952 function dotCase(input, options) { 15953 if (options === void 0) { 15954 options = {}; 15955 } 15956 return noCase(input, __assign({ delimiter: "." }, options)); 15957 } 15958 15959 // node_modules/param-case/dist.es2015/index.js 15960 function paramCase(input, options) { 15961 if (options === void 0) { 15962 options = {}; 15963 } 15964 return dotCase(input, __assign({ delimiter: "-" }, options)); 15965 } 15966 15967 // packages/fields/build-module/components/create-template-part-modal/index.js 15968 var import_components52 = __toESM(require_components()); 15969 var import_compose12 = __toESM(require_compose()); 15970 var import_core_data2 = __toESM(require_core_data()); 15971 var import_data9 = __toESM(require_data()); 15972 var import_element54 = __toESM(require_element()); 15973 var import_i18n42 = __toESM(require_i18n()); 15974 var import_notices = __toESM(require_notices()); 15975 var import_blocks = __toESM(require_blocks()); 15976 15977 // packages/fields/build-module/components/create-template-part-modal/utils.js 15978 var import_data8 = __toESM(require_data()); 15979 var import_core_data = __toESM(require_core_data()); 15980 var useExistingTemplateParts = () => { 15981 return (0, import_data8.useSelect)( 15982 (select2) => select2(import_core_data.store).getEntityRecords( 15983 "postType", 15984 "wp_template_part", 15985 { 15986 per_page: -1 15987 } 15988 ), 15989 [] 15990 ) ?? []; 15991 }; 15992 var getUniqueTemplatePartTitle = (title, templateParts) => { 15993 const lowercaseTitle = title.toLowerCase(); 15994 const existingTitles = templateParts.map( 15995 (templatePart) => templatePart.title.rendered.toLowerCase() 15996 ); 15997 if (!existingTitles.includes(lowercaseTitle)) { 15998 return title; 15999 } 16000 let suffix = 2; 16001 while (existingTitles.includes(`$lowercaseTitle} $suffix}`)) { 16002 suffix++; 16003 } 16004 return `$title} $suffix}`; 16005 }; 16006 var getCleanTemplatePartSlug = (title) => { 16007 return paramCase(title).replace(/[^\w-]+/g, "") || "wp-custom-part"; 16008 }; 16009 16010 // packages/fields/build-module/components/create-template-part-modal/index.js 16011 var import_jsx_runtime100 = __toESM(require_jsx_runtime()); 16012 function getAreaRadioId(value, instanceId) { 16013 return `fields-create-template-part-modal__area-option-$value}-$instanceId}`; 16014 } 16015 function getAreaRadioDescriptionId(value, instanceId) { 16016 return `fields-create-template-part-modal__area-option-description-$value}-$instanceId}`; 16017 } 16018 function CreateTemplatePartModal({ 16019 modalTitle, 16020 ...restProps 16021 }) { 16022 const defaultModalTitle = (0, import_data9.useSelect)( 16023 (select2) => select2(import_core_data2.store).getPostType("wp_template_part")?.labels?.add_new_item, 16024 [] 16025 ); 16026 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 16027 import_components52.Modal, 16028 { 16029 title: modalTitle || defaultModalTitle, 16030 onRequestClose: restProps.closeModal, 16031 overlayClassName: "fields-create-template-part-modal", 16032 focusOnMount: "firstContentElement", 16033 size: "medium", 16034 children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(CreateTemplatePartModalContents, { ...restProps }) 16035 } 16036 ); 16037 } 16038 var getTemplatePartIcon = (areaOrIconName) => { 16039 if ("header" === areaOrIconName) { 16040 return header_default; 16041 } else if ("footer" === areaOrIconName) { 16042 return footer_default; 16043 } else if ("sidebar" === areaOrIconName) { 16044 return sidebar_default; 16045 } else if ("overlay" === areaOrIconName) { 16046 return table_column_after_default; 16047 } 16048 if ("menu" === areaOrIconName) { 16049 return table_column_after_default; 16050 } 16051 return symbol_filled_default; 16052 }; 16053 function CreateTemplatePartModalContents({ 16054 defaultArea = "uncategorized", 16055 blocks = [], 16056 confirmLabel = (0, import_i18n42.__)("Add"), 16057 closeModal, 16058 onCreate, 16059 onError, 16060 defaultTitle = "" 16061 }) { 16062 const { createErrorNotice } = (0, import_data9.useDispatch)(import_notices.store); 16063 const { saveEntityRecord } = (0, import_data9.useDispatch)(import_core_data2.store); 16064 const existingTemplateParts = useExistingTemplateParts(); 16065 const [title, setTitle] = (0, import_element54.useState)(defaultTitle); 16066 const [area, setArea] = (0, import_element54.useState)(defaultArea); 16067 const [isSubmitting, setIsSubmitting] = (0, import_element54.useState)(false); 16068 const instanceId = (0, import_compose12.useInstanceId)(CreateTemplatePartModal); 16069 const defaultTemplatePartAreas = (0, import_data9.useSelect)( 16070 (select2) => select2(import_core_data2.store).getCurrentTheme()?.default_template_part_areas, 16071 [] 16072 ); 16073 async function createTemplatePart() { 16074 if (!title || isSubmitting) { 16075 return; 16076 } 16077 try { 16078 setIsSubmitting(true); 16079 const uniqueTitle = getUniqueTemplatePartTitle( 16080 title, 16081 existingTemplateParts 16082 ); 16083 const cleanSlug = getCleanTemplatePartSlug(uniqueTitle); 16084 const templatePart = await saveEntityRecord( 16085 "postType", 16086 "wp_template_part", 16087 { 16088 slug: cleanSlug, 16089 title: uniqueTitle, 16090 content: (0, import_blocks.serialize)(blocks), 16091 area 16092 }, 16093 { throwOnError: true } 16094 ); 16095 await onCreate(templatePart); 16096 } catch (error) { 16097 const errorMessage = error instanceof Error && "code" in error && error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n42.__)( 16098 "An error occurred while creating the template part." 16099 ); 16100 createErrorNotice(errorMessage, { type: "snackbar" }); 16101 onError?.(); 16102 } finally { 16103 setIsSubmitting(false); 16104 } 16105 } 16106 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 16107 "form", 16108 { 16109 onSubmit: async (event) => { 16110 event.preventDefault(); 16111 await createTemplatePart(); 16112 }, 16113 children: /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(import_components52.__experimentalVStack, { spacing: "4", children: [ 16114 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 16115 import_components52.TextControl, 16116 { 16117 __next40pxDefaultSize: true, 16118 label: (0, import_i18n42.__)("Name"), 16119 value: title, 16120 onChange: setTitle, 16121 required: true 16122 } 16123 ), 16124 /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)("fieldset", { className: "fields-create-template-part-modal__area-fieldset", children: [ 16125 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components52.BaseControl.VisualLabel, { as: "legend", children: (0, import_i18n42.__)("Area") }), 16126 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("div", { className: "fields-create-template-part-modal__area-radio-group", children: (defaultTemplatePartAreas ?? []).map( 16127 (item) => { 16128 const icon = getTemplatePartIcon(item.icon); 16129 return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)( 16130 "div", 16131 { 16132 className: "fields-create-template-part-modal__area-radio-wrapper", 16133 children: [ 16134 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 16135 "input", 16136 { 16137 type: "radio", 16138 id: getAreaRadioId( 16139 item.area, 16140 instanceId 16141 ), 16142 name: `fields-create-template-part-modal__area-$instanceId}`, 16143 value: item.area, 16144 checked: area === item.area, 16145 onChange: () => { 16146 setArea(item.area); 16147 }, 16148 "aria-describedby": getAreaRadioDescriptionId( 16149 item.area, 16150 instanceId 16151 ) 16152 } 16153 ), 16154 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 16155 import_components52.Icon, 16156 { 16157 icon, 16158 className: "fields-create-template-part-modal__area-radio-icon" 16159 } 16160 ), 16161 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 16162 "label", 16163 { 16164 htmlFor: getAreaRadioId( 16165 item.area, 16166 instanceId 16167 ), 16168 className: "fields-create-template-part-modal__area-radio-label", 16169 children: item.label 16170 } 16171 ), 16172 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 16173 import_components52.Icon, 16174 { 16175 icon: check_default, 16176 className: "fields-create-template-part-modal__area-radio-checkmark" 16177 } 16178 ), 16179 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 16180 "p", 16181 { 16182 className: "fields-create-template-part-modal__area-radio-description", 16183 id: getAreaRadioDescriptionId( 16184 item.area, 16185 instanceId 16186 ), 16187 children: item.description 16188 } 16189 ) 16190 ] 16191 }, 16192 item.area 16193 ); 16194 } 16195 ) }) 16196 ] }), 16197 /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(import_components52.__experimentalHStack, { justify: "right", children: [ 16198 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 16199 import_components52.Button, 16200 { 16201 __next40pxDefaultSize: true, 16202 variant: "tertiary", 16203 onClick: () => { 16204 closeModal(); 16205 }, 16206 children: (0, import_i18n42.__)("Cancel") 16207 } 16208 ), 16209 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 16210 import_components52.Button, 16211 { 16212 __next40pxDefaultSize: true, 16213 variant: "primary", 16214 type: "submit", 16215 "aria-disabled": !title || isSubmitting, 16216 isBusy: isSubmitting, 16217 children: confirmLabel 16218 } 16219 ) 16220 ] }) 16221 ] }) 16222 } 16223 ); 16224 } 16225 16226 // routes/lock-unlock.ts 16227 var import_private_apis2 = __toESM(require_private_apis()); 16228 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 16229 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 16230 "@wordpress/routes" 16231 ); 16232 16233 // routes/template-part-list/view-utils.ts 16234 var import_data10 = __toESM(require_data()); 16235 var import_core_data3 = __toESM(require_core_data()); 16236 var DEFAULT_VIEW = { 16237 type: "grid", 16238 sort: { 16239 field: "date", 16240 direction: "desc" 16241 }, 16242 fields: [], 16243 titleField: "title", 16244 mediaField: "preview" 16245 }; 16246 var DEFAULT_LAYOUTS = { 16247 table: {}, 16248 grid: {}, 16249 list: {} 16250 }; 16251 var DEFAULT_VIEWS = [ 16252 { 16253 slug: "all", 16254 label: "All Template Parts", 16255 view: { 16256 ...DEFAULT_VIEW 16257 } 16258 }, 16259 { 16260 slug: "header", 16261 label: "Headers", 16262 view: { 16263 ...DEFAULT_VIEW, 16264 filters: [ 16265 { 16266 field: "area", 16267 operator: "is", 16268 value: "header" 16269 } 16270 ] 16271 } 16272 }, 16273 { 16274 slug: "footer", 16275 label: "Footers", 16276 view: { 16277 ...DEFAULT_VIEW, 16278 filters: [ 16279 { 16280 field: "area", 16281 operator: "is", 16282 value: "footer" 16283 } 16284 ] 16285 } 16286 }, 16287 { 16288 slug: "sidebar", 16289 label: "Sidebars", 16290 view: { 16291 ...DEFAULT_VIEW, 16292 filters: [ 16293 { 16294 field: "area", 16295 operator: "is", 16296 value: "sidebar" 16297 } 16298 ] 16299 } 16300 }, 16301 { 16302 slug: "overlay", 16303 label: "Overlays", 16304 view: { 16305 ...DEFAULT_VIEW, 16306 filters: [ 16307 { 16308 field: "area", 16309 operator: "is", 16310 value: "overlay" 16311 } 16312 ] 16313 } 16314 }, 16315 { 16316 slug: "uncategorized", 16317 label: "General", 16318 view: { 16319 ...DEFAULT_VIEW, 16320 filters: [ 16321 { 16322 field: "area", 16323 operator: "is", 16324 value: "uncategorized" 16325 } 16326 ] 16327 } 16328 } 16329 ]; 16330 function getDefaultView(postType, area) { 16331 const viewConfig = DEFAULT_VIEWS.find((v2) => v2.slug === area); 16332 return viewConfig?.view || DEFAULT_VIEW; 16333 } 16334 function viewToQuery(view) { 16335 const result = {}; 16336 if (void 0 !== view.perPage) { 16337 result.per_page = view.perPage; 16338 } 16339 if (void 0 !== view.page) { 16340 result.page = view.page; 16341 } 16342 if (![void 0, ""].includes(view.search)) { 16343 result.search = view.search; 16344 } 16345 if (void 0 !== view.sort?.field) { 16346 result.orderby = view.sort.field; 16347 } 16348 if (void 0 !== view.sort?.direction) { 16349 result.order = view.sort.direction; 16350 } 16351 const areaFilter = view.filters?.find( 16352 (filter) => filter.field === "area" 16353 ); 16354 if (areaFilter) { 16355 result.area = areaFilter.value; 16356 } 16357 return result; 16358 } 16359 16360 // routes/template-part-list/fields/preview.tsx 16361 var import_i18n43 = __toESM(require_i18n()); 16362 import { Preview } from "@wordpress/lazy-editor"; 16363 function PreviewField({ item }) { 16364 const description = item.description; 16365 return /* @__PURE__ */ React.createElement( 16366 Preview, 16367 { 16368 content: item?.content?.raw, 16369 blocks: item?.blocks, 16370 description 16371 } 16372 ); 16373 } 16374 var previewField = { 16375 label: (0, import_i18n43.__)("Preview"), 16376 id: "preview", 16377 render: PreviewField, 16378 enableSorting: false 16379 }; 16380 16381 // routes/template-part-list/style.scss 16382 var css = `/** 16383 * SCSS Variables. 16384 * 16385 * Please use variables from this sheet to ensure consistency across the UI. 16386 * Don't add to this sheet unless you're pretty sure the value will be reused in many places. 16387 * For example, don't add rules to this sheet that affect block visuals. It's purely for UI. 16388 */ 16389 /** 16390 * Colors 16391 */ 16392 /** 16393 * Fonts & basic variables. 16394 */ 16395 /** 16396 * Typography 16397 */ 16398 /** 16399 * Grid System. 16400 * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/ 16401 */ 16402 /** 16403 * Radius scale. 16404 */ 16405 /** 16406 * Elevation scale. 16407 */ 16408 /** 16409 * Dimensions. 16410 */ 16411 /** 16412 * Mobile specific styles 16413 */ 16414 /** 16415 * Editor styles. 16416 */ 16417 /** 16418 * Block & Editor UI. 16419 */ 16420 /** 16421 * Block paddings. 16422 */ 16423 /** 16424 * React Native specific. 16425 * These variables do not appear to be used anywhere else. 16426 */ 16427 /** 16428 * Typography 16429 */ 16430 /** 16431 * SCSS Variables. 16432 * 16433 * Please use variables from this sheet to ensure consistency across the UI. 16434 * Don't add to this sheet unless you're pretty sure the value will be reused in many places. 16435 * For example, don't add rules to this sheet that affect block visuals. It's purely for UI. 16436 */ 16437 /** 16438 * Colors 16439 */ 16440 /** 16441 * Fonts & basic variables. 16442 */ 16443 /** 16444 * Typography 16445 */ 16446 /** 16447 * Grid System. 16448 * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/ 16449 */ 16450 /** 16451 * Radius scale. 16452 */ 16453 /** 16454 * Elevation scale. 16455 */ 16456 /** 16457 * Dimensions. 16458 */ 16459 /** 16460 * Mobile specific styles 16461 */ 16462 /** 16463 * Editor styles. 16464 */ 16465 /** 16466 * Block & Editor UI. 16467 */ 16468 /** 16469 * Block paddings. 16470 */ 16471 /** 16472 * React Native specific. 16473 * These variables do not appear to be used anywhere else. 16474 */ 16475 /** 16476 * Breakpoints & Media Queries 16477 */ 16478 /** 16479 * Converts a hex value into the rgb equivalent. 16480 * 16481 * @param {string} hex - the hexadecimal value to convert 16482 * @return {string} comma separated rgb values 16483 */ 16484 /** 16485 * Long content fade mixin 16486 * 16487 * Creates a fading overlay to signify that the content is longer 16488 * than the space allows. 16489 */ 16490 /** 16491 * Breakpoint mixins 16492 */ 16493 /** 16494 * Focus styles. 16495 */ 16496 /** 16497 * Applies editor left position to the selector passed as argument 16498 */ 16499 /** 16500 * Styles that are reused verbatim in a few places 16501 */ 16502 /** 16503 * Allows users to opt-out of animations via OS-level preferences. 16504 */ 16505 /** 16506 * Reset default styles for JavaScript UI based pages. 16507 * This is a WP-admin agnostic reset 16508 */ 16509 /** 16510 * Reset the WP Admin page styles for Gutenberg-like pages. 16511 */ 16512 :root { 16513 --wp-block-synced-color: #7a00df; 16514 --wp-block-synced-color--rgb: 122, 0, 223; 16515 --wp-bound-block-color: var(--wp-block-synced-color); 16516 --wp-editor-canvas-background: #ddd; 16517 --wp-admin-theme-color: #007cba; 16518 --wp-admin-theme-color--rgb: 0, 124, 186; 16519 --wp-admin-theme-color-darker-10: rgb(0, 107, 160.5); 16520 --wp-admin-theme-color-darker-10--rgb: 0, 107, 160.5; 16521 --wp-admin-theme-color-darker-20: #005a87; 16522 --wp-admin-theme-color-darker-20--rgb: 0, 90, 135; 16523 --wp-admin-border-width-focus: 2px; 16524 } 16525 16526 @media (min-resolution: 192dpi) { 16527 :root { 16528 --wp-admin-border-width-focus: 1.5px; 16529 } 16530 } 16531 .fields-create-template-part-modal { 16532 z-index: 1000001; 16533 } 16534 16535 .fields-create-template-part-modal__area-fieldset { 16536 border: 0; 16537 padding: 0; 16538 margin: 0; 16539 } 16540 16541 .fields-create-template-part-modal__area-radio-group { 16542 border: 1px solid #949494; 16543 border-radius: 2px; 16544 } 16545 16546 .fields-create-template-part-modal__area-radio-wrapper { 16547 position: relative; 16548 padding: 12px; 16549 display: grid; 16550 align-items: center; 16551 grid-template-columns: min-content 1fr min-content; 16552 grid-gap: 4px 8px; 16553 color: #1e1e1e; 16554 } 16555 16556 .fields-create-template-part-modal__area-radio-wrapper + .fields-create-template-part-modal__area-radio-wrapper { 16557 border-top: 1px solid #949494; 16558 } 16559 16560 .fields-create-template-part-modal__area-radio-wrapper input[type=radio] { 16561 position: absolute; 16562 opacity: 0; 16563 } 16564 16565 .fields-create-template-part-modal__area-radio-wrapper:has(input[type=radio]:checked) { 16566 z-index: 1; 16567 } 16568 16569 .fields-create-template-part-modal__area-radio-wrapper:has(input[type=radio]:not(:checked)):hover { 16570 color: var(--wp-admin-theme-color); 16571 } 16572 16573 .fields-create-template-part-modal__area-radio-wrapper > *:not(.fields-create-template-part-modal__area-radio-label) { 16574 pointer-events: none; 16575 } 16576 16577 .fields-create-template-part-modal__area-radio-label::before { 16578 content: ""; 16579 position: absolute; 16580 inset: 0; 16581 } 16582 16583 input[type=radio]:not(:checked) ~ .fields-create-template-part-modal__area-radio-label::before { 16584 cursor: pointer; 16585 } 16586 16587 input[type=radio]:focus-visible ~ .fields-create-template-part-modal__area-radio-label::before { 16588 outline: 4px solid transparent; 16589 box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); 16590 } 16591 16592 .fields-create-template-part-modal__area-radio-icon, 16593 .fields-create-template-part-modal__area-radio-checkmark { 16594 fill: currentColor; 16595 } 16596 16597 input[type=radio]:not(:checked) ~ .fields-create-template-part-modal__area-radio-checkmark { 16598 opacity: 0; 16599 } 16600 16601 .fields-create-template-part-modal__area-radio-description { 16602 grid-column: 2/3; 16603 margin: 0; 16604 color: #757575; 16605 font-size: 12px; 16606 line-height: normal; 16607 text-wrap: pretty; 16608 } 16609 16610 input[type=radio]:not(:checked):hover ~ .fields-create-template-part-modal__area-radio-description { 16611 color: inherit; 16612 } 16613 16614 .fields-controls__slug { 16615 border: 0; 16616 padding: 0; 16617 margin: 0; 16618 } 16619 16620 .fields-controls__slug .fields-controls__slug-external-icon { 16621 margin-left: 5ch; 16622 } 16623 16624 .fields-controls__slug .fields-controls__slug-input input.components-input-control__input { 16625 padding-inline-start: 0 !important; 16626 } 16627 16628 .fields-controls__slug .fields-controls__slug-help-link { 16629 word-break: break-word; 16630 } 16631 16632 .fields-controls__slug .fields-controls__slug-help { 16633 display: flex; 16634 flex-direction: column; 16635 } 16636 16637 .fields-controls__slug .fields-controls__slug-help .fields-controls__slug-help-slug { 16638 font-weight: 600; 16639 } 16640 16641 .fields-controls__featured-image-placeholder { 16642 border-radius: 2px; 16643 box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); 16644 display: inline-block; 16645 padding: 0; 16646 background: #fff linear-gradient(-45deg, transparent 48%, #ddd 48%, #ddd 52%, transparent 52%); 16647 } 16648 16649 .fields-controls__featured-image-title { 16650 width: 100%; 16651 color: #1e1e1e; 16652 white-space: nowrap; 16653 text-overflow: ellipsis; 16654 overflow: hidden; 16655 } 16656 16657 .fields-controls__featured-image-image { 16658 width: 100%; 16659 height: 100%; 16660 border-radius: 2px; 16661 align-self: center; 16662 } 16663 16664 .fields-controls__featured-image-container .fields-controls__featured-image-placeholder { 16665 margin: 0; 16666 } 16667 16668 .fields-controls__featured-image-container span { 16669 margin-right: auto; 16670 } 16671 16672 fieldset.fields-controls__featured-image { 16673 border: 0; 16674 padding: 0; 16675 margin: 0; 16676 } 16677 16678 fieldset.fields-controls__featured-image .fields-controls__featured-image-container { 16679 border: 1px solid #ddd; 16680 border-radius: 2px; 16681 padding: 8px 12px; 16682 cursor: pointer; 16683 } 16684 16685 fieldset.fields-controls__featured-image .fields-controls__featured-image-container:hover { 16686 background-color: #f0f0f0; 16687 } 16688 16689 fieldset.fields-controls__featured-image .fields-controls__featured-image-placeholder { 16690 width: 24px; 16691 height: 24px; 16692 } 16693 16694 fieldset.fields-controls__featured-image span { 16695 align-self: center; 16696 text-align: start; 16697 white-space: nowrap; 16698 } 16699 16700 fieldset.fields-controls__featured-image .fields-controls__featured-image-upload-button { 16701 padding: 0; 16702 height: fit-content; 16703 } 16704 16705 fieldset.fields-controls__featured-image .fields-controls__featured-image-upload-button:hover, fieldset.fields-controls__featured-image .fields-controls__featured-image-upload-button:focus { 16706 border: 0; 16707 color: unset; 16708 } 16709 16710 fieldset.fields-controls__featured-image .fields-controls__featured-image-remove-button { 16711 place-self: end; 16712 } 16713 16714 .dataforms-layouts-panel__field-control .fields-controls__featured-image-image { 16715 width: 16px; 16716 height: 16px; 16717 } 16718 16719 .dataforms-layouts-panel__field-control .fields-controls__featured-image-placeholder { 16720 width: 16px; 16721 height: 16px; 16722 } 16723 16724 .dataviews-view-grid__media .fields-controls__featured-image-image, 16725 .dataviews-view-grid__media .fields-controls__featured-image-placeholder, 16726 .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-image, 16727 .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-placeholder, 16728 .dataviews-view-list__media-wrapper .fields-controls__featured-image-image, 16729 .dataviews-view-list__media-wrapper .fields-controls__featured-image-placeholder { 16730 width: 100%; 16731 height: 100%; 16732 display: block; 16733 border-radius: 4px; 16734 } 16735 16736 .dataviews-view-grid__media .fields-controls__featured-image-placeholder, 16737 .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-placeholder, 16738 .dataviews-view-list__media-wrapper .fields-controls__featured-image-placeholder { 16739 box-shadow: none; 16740 background: #f0f0f0; 16741 } 16742 16743 .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-image, 16744 .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-placeholder { 16745 width: 32px; 16746 height: 32px; 16747 } 16748 16749 .fields-controls__parent { 16750 border: 0; 16751 padding: 0; 16752 margin: 0; 16753 } 16754 16755 .fields-controls__password { 16756 border: 0; 16757 padding: 0; 16758 margin: 0; 16759 } 16760 16761 .fields-controls__template { 16762 border: 0; 16763 padding: 0; 16764 margin: 0; 16765 } 16766 16767 .fields-controls__template-modal { 16768 z-index: 1000001; 16769 } 16770 16771 .fields-controls__template-content .block-editor-block-patterns-list { 16772 column-count: 2; 16773 column-gap: 24px; 16774 padding-top: 2px; 16775 } 16776 16777 @media (min-width: 782px) { 16778 .fields-controls__template-content .block-editor-block-patterns-list { 16779 column-count: 3; 16780 } 16781 } 16782 @media (min-width: 1280px) { 16783 .fields-controls__template-content .block-editor-block-patterns-list { 16784 column-count: 4; 16785 } 16786 } 16787 .fields-controls__template-content .block-editor-block-patterns-list .block-editor-block-patterns-list__list-item { 16788 break-inside: avoid-column; 16789 } 16790 16791 .fields-field__title > span:first-child { 16792 text-overflow: ellipsis; 16793 overflow: hidden; 16794 text-decoration: none; 16795 white-space: nowrap; 16796 display: block; 16797 flex-grow: 0; 16798 } 16799 16800 .fields-field__pattern-title span:first-child { 16801 flex: 1; 16802 } 16803 16804 .routes-template-part-list__tabs-wrapper { 16805 border-bottom: 1px solid #f0f0f0; 16806 padding: 0 24px; 16807 }`; 16808 document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css)); 16809 16810 // routes/template-part-list/stage.tsx 16811 var { useEntityRecordsWithPermissions } = unlock2(import_core_data4.privateApis); 16812 var { usePostActions, usePostFields } = unlock2(import_editor.privateApis); 16813 var { Tabs } = unlock2(import_components53.privateApis); 16814 function getItemId(item) { 16815 return item.id.toString(); 16816 } 16817 function TemplatePartList() { 16818 const invalidate = useInvalidate(); 16819 const { area = "all" } = useParams({ 16820 from: "/template-parts/list/$area" 16821 }); 16822 const navigate = useNavigate(); 16823 const searchParams = useSearch({ from: "/template-parts/list/$area" }); 16824 const postTypeObject = (0, import_data11.useSelect)( 16825 (select2) => select2(import_core_data4.store).getPostType("wp_template_part"), 16826 [] 16827 ); 16828 const labels = postTypeObject?.labels; 16829 const canCreateRecord = (0, import_data11.useSelect)( 16830 (select2) => select2(import_core_data4.store).canUser("create", { 16831 kind: "postType", 16832 name: "wp_template_part" 16833 }), 16834 [] 16835 ); 16836 const [showTemplatePartModal, setShowTemplatePartModal] = (0, import_element55.useState)(false); 16837 const defaultView = (0, import_element55.useMemo)(() => { 16838 return getDefaultView(postTypeObject, area); 16839 }, [postTypeObject, area]); 16840 const handleQueryParamsChange = (0, import_element55.useCallback)( 16841 (params) => { 16842 navigate({ 16843 search: { 16844 ...searchParams, 16845 ...params 16846 } 16847 }); 16848 }, 16849 [searchParams, navigate] 16850 ); 16851 const { view, isModified, updateView, resetToDefault } = useView({ 16852 kind: "postType", 16853 name: "wp_template_part", 16854 slug: area, 16855 defaultView, 16856 queryParams: searchParams, 16857 onChangeQueryParams: handleQueryParamsChange 16858 }); 16859 const onReset = () => { 16860 resetToDefault(); 16861 invalidate(); 16862 }; 16863 const onChangeView = (newView) => { 16864 updateView(newView); 16865 if (newView.type !== view.type) { 16866 invalidate(); 16867 } 16868 }; 16869 const postTypeQuery = (0, import_element55.useMemo)(() => viewToQuery(view), [view]); 16870 const { 16871 records: posts, 16872 totalItems, 16873 totalPages, 16874 isResolving 16875 } = useEntityRecordsWithPermissions( 16876 "postType", 16877 "wp_template_part", 16878 postTypeQuery 16879 ); 16880 const allFields = usePostFields({ 16881 postType: "wp_template_part" 16882 }); 16883 const fields = (0, import_element55.useMemo)(() => { 16884 return [previewField].concat( 16885 allFields.filter((field) => { 16886 if (field.id === "area" && area !== "all") { 16887 return false; 16888 } 16889 if (field.id === "status") { 16890 return false; 16891 } 16892 return true; 16893 }).map((field) => { 16894 if (field.id === "area") { 16895 return { ...field, filterBy: false }; 16896 } 16897 return field; 16898 }) 16899 ); 16900 }, [allFields, area]); 16901 const cleanupDeletedPostIdsFromUrl = (0, import_element55.useCallback)( 16902 (deletedItems) => { 16903 const deletedIds = deletedItems.map( 16904 (item) => item.id.toString() 16905 ); 16906 const currentPostIds = searchParams.postIds || []; 16907 const remainingPostIds = currentPostIds.filter( 16908 (id) => !deletedIds.includes(id) 16909 ); 16910 if (remainingPostIds.length !== currentPostIds.length) { 16911 navigate({ 16912 search: { 16913 ...searchParams, 16914 postIds: remainingPostIds.length > 0 ? remainingPostIds : void 0 16915 } 16916 }); 16917 } else { 16918 invalidate(); 16919 } 16920 }, 16921 [invalidate, searchParams, navigate] 16922 ); 16923 const postTypeActions = usePostActions({ 16924 postType: "wp_template_part", 16925 context: "list", 16926 onActionPerformed: (actionId, items) => { 16927 if (actionId === "move-to-trash" || actionId === "permanently-delete") { 16928 cleanupDeletedPostIdsFromUrl(items); 16929 } 16930 } 16931 }); 16932 const actions = (0, import_element55.useMemo)(() => { 16933 return [ 16934 ...postTypeActions?.flatMap( 16935 (action) => { 16936 if (action.id === "view-post-revisions") { 16937 return []; 16938 } 16939 return [action]; 16940 } 16941 ) 16942 ]; 16943 }, [postTypeActions]); 16944 const handleTabChange = (0, import_element55.useCallback)( 16945 (areaSlug) => { 16946 navigate({ 16947 to: `/template-parts/list/$areaSlug}` 16948 }); 16949 }, 16950 [navigate] 16951 ); 16952 if (!postTypeObject) { 16953 return null; 16954 } 16955 const selection = searchParams.postIds ?? []; 16956 if (view.type === "list" && selection.length === 0 && posts?.length > 0) { 16957 selection.push(posts[0].id.toString()); 16958 } 16959 if (view.type === "list") { 16960 selection.splice(1); 16961 } 16962 return /* @__PURE__ */ React.createElement( 16963 page_default, 16964 { 16965 title: postTypeObject.labels?.name, 16966 subTitle: postTypeObject.labels?.description, 16967 className: "template-part-page", 16968 actions: /* @__PURE__ */ React.createElement(React.Fragment, null, isModified && /* @__PURE__ */ React.createElement( 16969 import_components53.Button, 16970 { 16971 variant: "tertiary", 16972 size: "compact", 16973 onClick: onReset 16974 }, 16975 (0, import_i18n44.__)("Reset view") 16976 ), labels?.add_new_item && canCreateRecord && /* @__PURE__ */ React.createElement( 16977 import_components53.Button, 16978 { 16979 variant: "primary", 16980 onClick: () => setShowTemplatePartModal(true), 16981 size: "compact" 16982 }, 16983 labels.add_new_item 16984 )), 16985 hasPadding: false 16986 }, 16987 DEFAULT_VIEWS.length > 1 && /* @__PURE__ */ React.createElement("div", { className: "routes-template-part-list__tabs-wrapper" }, /* @__PURE__ */ React.createElement( 16988 Tabs, 16989 { 16990 onSelect: handleTabChange, 16991 selectedTabId: area ?? "all" 16992 }, 16993 /* @__PURE__ */ React.createElement(Tabs.TabList, null, DEFAULT_VIEWS.map( 16994 (filter) => /* @__PURE__ */ React.createElement( 16995 Tabs.Tab, 16996 { 16997 tabId: filter.slug, 16998 key: filter.slug 16999 }, 17000 filter.label 17001 ) 17002 )) 17003 )), 17004 /* @__PURE__ */ React.createElement( 17005 dataviews_default, 17006 { 17007 data: posts, 17008 fields, 17009 view, 17010 onChangeView, 17011 actions, 17012 isLoading: isResolving, 17013 paginationInfo: { 17014 totalItems, 17015 totalPages 17016 }, 17017 defaultLayouts: DEFAULT_LAYOUTS, 17018 getItemId, 17019 selection, 17020 onChangeSelection: (items) => { 17021 navigate({ 17022 search: { 17023 ...searchParams, 17024 postIds: items.length > 0 ? items : void 0, 17025 edit: items.length === 0 ? void 0 : searchParams.edit 17026 } 17027 }); 17028 }, 17029 renderItemLink: ({ 17030 item, 17031 ...props 17032 }) => /* @__PURE__ */ React.createElement( 17033 Link, 17034 { 17035 to: `/types/wp_template_part/edit/$encodeURIComponent( 17036 item.id 17037 )}`, 17038 ...props, 17039 onClick: (event) => { 17040 event.stopPropagation(); 17041 } 17042 } 17043 ) 17044 } 17045 ), 17046 showTemplatePartModal && /* @__PURE__ */ React.createElement( 17047 CreateTemplatePartModal, 17048 { 17049 closeModal: () => setShowTemplatePartModal(false), 17050 blocks: [], 17051 onCreate: (templatePart) => { 17052 setShowTemplatePartModal(false); 17053 navigate({ 17054 to: `/types/wp_template_part/edit/$encodeURIComponent( 17055 templatePart.id 17056 )}` 17057 }); 17058 }, 17059 onError: () => setShowTemplatePartModal(false), 17060 defaultArea: area !== "all" ? area : "uncategorized" 17061 } 17062 ) 17063 ); 17064 } 17065 var stage = TemplatePartList; 17066 export { 17067 stage 17068 }; 17069 /*! Bundled license information: 17070 17071 use-sync-external-store/cjs/use-sync-external-store-shim.development.js: 17072 (** 17073 * @license React 17074 * use-sync-external-store-shim.development.js 17075 * 17076 * Copyright (c) Meta Platforms, Inc. and affiliates. 17077 * 17078 * This source code is licensed under the MIT license found in the 17079 * LICENSE file in the root directory of this source tree. 17080 *) 17081 */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Mon May 25 08:20:05 2026 | Cross-referenced by PHPXref |