| [ 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 = useState27({ 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 useEffect20( 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, useState27 = React5.useState, useEffect20 = 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 removeAccents3 = function(string) { 658 return string.replace(allAccents, matcher); 659 }; 660 var hasAccents = function(string) { 661 return !!string.match(firstAccent); 662 }; 663 module.exports = removeAccents3; 664 module.exports.has = hasAccents; 665 module.exports.remove = removeAccents3; 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/deprecated 740 var require_deprecated = __commonJS({ 741 "package-external:@wordpress/deprecated"(exports, module) { 742 module.exports = window.wp.deprecated; 743 } 744 }); 745 746 // package-external:@wordpress/core-data 747 var require_core_data = __commonJS({ 748 "package-external:@wordpress/core-data"(exports, module) { 749 module.exports = window.wp.coreData; 750 } 751 }); 752 753 // package-external:@wordpress/editor 754 var require_editor = __commonJS({ 755 "package-external:@wordpress/editor"(exports, module) { 756 module.exports = window.wp.editor; 757 } 758 }); 759 760 // package-external:@wordpress/html-entities 761 var require_html_entities = __commonJS({ 762 "package-external:@wordpress/html-entities"(exports, module) { 763 module.exports = window.wp.htmlEntities; 764 } 765 }); 766 767 // package-external:@wordpress/notices 768 var require_notices = __commonJS({ 769 "package-external:@wordpress/notices"(exports, module) { 770 module.exports = window.wp.notices; 771 } 772 }); 773 774 // package-external:@wordpress/dom 775 var require_dom = __commonJS({ 776 "package-external:@wordpress/dom"(exports, module) { 777 module.exports = window.wp.dom; 778 } 779 }); 780 781 // package-external:@wordpress/url 782 var require_url = __commonJS({ 783 "package-external:@wordpress/url"(exports, module) { 784 module.exports = window.wp.url; 785 } 786 }); 787 788 // routes/template-list/stage.tsx 789 import { 790 useParams, 791 useNavigate as useNavigate2, 792 useSearch, 793 useInvalidate as useInvalidate2 794 } from "@wordpress/route"; 795 796 // node_modules/dequal/dist/index.mjs 797 var has = Object.prototype.hasOwnProperty; 798 function find(iter, tar, key) { 799 for (key of iter.keys()) { 800 if (dequal(key, tar)) return key; 801 } 802 } 803 function dequal(foo, bar) { 804 var ctor, len, tmp; 805 if (foo === bar) return true; 806 if (foo && bar && (ctor = foo.constructor) === bar.constructor) { 807 if (ctor === Date) return foo.getTime() === bar.getTime(); 808 if (ctor === RegExp) return foo.toString() === bar.toString(); 809 if (ctor === Array) { 810 if ((len = foo.length) === bar.length) { 811 while (len-- && dequal(foo[len], bar[len])) ; 812 } 813 return len === -1; 814 } 815 if (ctor === Set) { 816 if (foo.size !== bar.size) { 817 return false; 818 } 819 for (len of foo) { 820 tmp = len; 821 if (tmp && typeof tmp === "object") { 822 tmp = find(bar, tmp); 823 if (!tmp) return false; 824 } 825 if (!bar.has(tmp)) return false; 826 } 827 return true; 828 } 829 if (ctor === Map) { 830 if (foo.size !== bar.size) { 831 return false; 832 } 833 for (len of foo) { 834 tmp = len[0]; 835 if (tmp && typeof tmp === "object") { 836 tmp = find(bar, tmp); 837 if (!tmp) return false; 838 } 839 if (!dequal(len[1], bar.get(tmp))) { 840 return false; 841 } 842 } 843 return true; 844 } 845 if (ctor === ArrayBuffer) { 846 foo = new Uint8Array(foo); 847 bar = new Uint8Array(bar); 848 } else if (ctor === DataView) { 849 if ((len = foo.byteLength) === bar.byteLength) { 850 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ; 851 } 852 return len === -1; 853 } 854 if (ArrayBuffer.isView(foo)) { 855 if ((len = foo.byteLength) === bar.byteLength) { 856 while (len-- && foo[len] === bar[len]) ; 857 } 858 return len === -1; 859 } 860 if (!ctor || typeof foo === "object") { 861 len = 0; 862 for (ctor in foo) { 863 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false; 864 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false; 865 } 866 return Object.keys(bar).length === len; 867 } 868 } 869 return foo !== foo && bar !== bar; 870 } 871 872 // packages/views/build-module/preference-keys.js 873 function generatePreferenceKey(kind, name, slug) { 874 return `dataviews-$kind}-$name}-$slug}`; 875 } 876 877 // packages/views/build-module/use-view.js 878 var import_element = __toESM(require_element()); 879 var import_data = __toESM(require_data()); 880 var import_preferences = __toESM(require_preferences()); 881 function omit(obj, keys) { 882 const result = { ...obj }; 883 for (const key of keys) { 884 delete result[key]; 885 } 886 return result; 887 } 888 function useView(config) { 889 const { kind, name, slug, defaultView, queryParams, onChangeQueryParams } = config; 890 const preferenceKey = generatePreferenceKey(kind, name, slug); 891 const persistedView = (0, import_data.useSelect)( 892 (select2) => { 893 return select2(import_preferences.store).get( 894 "core/views", 895 preferenceKey 896 ); 897 }, 898 [preferenceKey] 899 ); 900 const { set } = (0, import_data.useDispatch)(import_preferences.store); 901 const baseView = persistedView ?? defaultView; 902 const page = Number(queryParams?.page ?? baseView.page ?? 1); 903 const search = queryParams?.search ?? baseView.search ?? ""; 904 const view = (0, import_element.useMemo)(() => { 905 return { 906 ...baseView, 907 page, 908 search 909 }; 910 }, [baseView, page, search]); 911 const isModified = !!persistedView; 912 const updateView = (0, import_element.useCallback)( 913 (newView) => { 914 const urlParams = { 915 page: newView?.page, 916 search: newView?.search 917 }; 918 const preferenceView = omit(newView, ["page", "search"]); 919 if (onChangeQueryParams && !dequal(urlParams, { page, search })) { 920 onChangeQueryParams(urlParams); 921 } 922 if (!dequal(baseView, preferenceView)) { 923 if (dequal(preferenceView, defaultView)) { 924 set("core/views", preferenceKey, void 0); 925 } else { 926 set("core/views", preferenceKey, preferenceView); 927 } 928 } 929 }, 930 [ 931 onChangeQueryParams, 932 page, 933 search, 934 baseView, 935 defaultView, 936 set, 937 preferenceKey 938 ] 939 ); 940 const resetToDefault = (0, import_element.useCallback)(() => { 941 set("core/views", preferenceKey, void 0); 942 }, [preferenceKey, set]); 943 return { 944 view, 945 isModified, 946 updateView, 947 resetToDefault 948 }; 949 } 950 951 // packages/views/build-module/load-view.js 952 var import_data2 = __toESM(require_data()); 953 var import_preferences2 = __toESM(require_preferences()); 954 955 // packages/dataviews/build-module/components/dataviews/index.js 956 var import_components49 = __toESM(require_components()); 957 var import_element52 = __toESM(require_element()); 958 var import_compose11 = __toESM(require_compose()); 959 960 // packages/dataviews/build-module/components/dataviews-context/index.js 961 var import_element2 = __toESM(require_element()); 962 963 // packages/dataviews/build-module/constants.js 964 var import_i18n = __toESM(require_i18n()); 965 966 // packages/icons/build-module/library/archive.js 967 var import_primitives = __toESM(require_primitives()); 968 var import_jsx_runtime = __toESM(require_jsx_runtime()); 969 var archive_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( 970 import_primitives.Path, 971 { 972 fillRule: "evenodd", 973 clipRule: "evenodd", 974 d: "M11.934 7.406a1 1 0 0 0 .914.594H19a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5h5.764a.5.5 0 0 1 .447.276l.723 1.63Zm1.064-1.216a.5.5 0 0 0 .462.31H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h5.764a2 2 0 0 1 1.789 1.106l.445 1.084ZM8.5 10.5h7V12h-7v-1.5Zm7 3.5h-7v1.5h7V14Z" 975 } 976 ) }); 977 978 // packages/icons/build-module/library/arrow-down.js 979 var import_primitives2 = __toESM(require_primitives()); 980 var import_jsx_runtime2 = __toESM(require_jsx_runtime()); 981 var arrow_down_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: "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" }) }); 982 983 // packages/icons/build-module/library/arrow-left.js 984 var import_primitives3 = __toESM(require_primitives()); 985 var import_jsx_runtime3 = __toESM(require_jsx_runtime()); 986 var arrow_left_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: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) }); 987 988 // packages/icons/build-module/library/arrow-right.js 989 var import_primitives4 = __toESM(require_primitives()); 990 var import_jsx_runtime4 = __toESM(require_jsx_runtime()); 991 var arrow_right_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: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) }); 992 993 // packages/icons/build-module/library/arrow-up.js 994 var import_primitives5 = __toESM(require_primitives()); 995 var import_jsx_runtime5 = __toESM(require_jsx_runtime()); 996 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) }); 997 998 // packages/icons/build-module/library/block-meta.js 999 var import_primitives6 = __toESM(require_primitives()); 1000 var import_jsx_runtime6 = __toESM(require_jsx_runtime()); 1001 var block_meta_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)( 1002 import_primitives6.Path, 1003 { 1004 fillRule: "evenodd", 1005 d: "M8.95 11.25H4v1.5h4.95v4.5H13V18c0 1.1.9 2 2 2h3c1.1 0 2-.9 2-2v-3c0-1.1-.9-2-2-2h-3c-1.1 0-2 .9-2 2v.75h-2.55v-7.5H13V9c0 1.1.9 2 2 2h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3c-1.1 0-2 .9-2 2v.75H8.95v4.5ZM14.5 15v3c0 .3.2.5.5.5h3c.3 0 .5-.2.5-.5v-3c0-.3-.2-.5-.5-.5h-3c-.3 0-.5.2-.5.5Zm0-6V6c0-.3.2-.5.5-.5h3c.3 0 .5.2.5.5v3c0 .3-.2.5-.5.5h-3c-.3 0-.5-.2-.5-.5Z", 1006 clipRule: "evenodd" 1007 } 1008 ) }); 1009 1010 // packages/icons/build-module/library/block-table.js 1011 var import_primitives7 = __toESM(require_primitives()); 1012 var import_jsx_runtime7 = __toESM(require_jsx_runtime()); 1013 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.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" }) }); 1014 1015 // packages/icons/build-module/library/calendar.js 1016 var import_primitives8 = __toESM(require_primitives()); 1017 var import_jsx_runtime8 = __toESM(require_jsx_runtime()); 1018 var calendar_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.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-2zm.5 16c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7h15v12zM9 10H7v2h2v-2zm0 4H7v2h2v-2zm4-4h-2v2h2v-2zm4 0h-2v2h2v-2zm-4 4h-2v2h2v-2zm4 0h-2v2h2v-2z" }) }); 1019 1020 // packages/icons/build-module/library/category.js 1021 var import_primitives9 = __toESM(require_primitives()); 1022 var import_jsx_runtime9 = __toESM(require_jsx_runtime()); 1023 var category_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( 1024 import_primitives9.Path, 1025 { 1026 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", 1027 fillRule: "evenodd", 1028 clipRule: "evenodd" 1029 } 1030 ) }); 1031 1032 // packages/icons/build-module/library/check.js 1033 var import_primitives10 = __toESM(require_primitives()); 1034 var import_jsx_runtime10 = __toESM(require_jsx_runtime()); 1035 var check_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)(import_primitives10.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) }); 1036 1037 // packages/icons/build-module/library/close-small.js 1038 var import_primitives11 = __toESM(require_primitives()); 1039 var import_jsx_runtime11 = __toESM(require_jsx_runtime()); 1040 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.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" }) }); 1041 1042 // packages/icons/build-module/library/cog.js 1043 var import_primitives12 = __toESM(require_primitives()); 1044 var import_jsx_runtime12 = __toESM(require_jsx_runtime()); 1045 var cog_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)( 1046 import_primitives12.Path, 1047 { 1048 fillRule: "evenodd", 1049 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", 1050 clipRule: "evenodd" 1051 } 1052 ) }); 1053 1054 // packages/icons/build-module/library/comment-author-avatar.js 1055 var import_primitives13 = __toESM(require_primitives()); 1056 var import_jsx_runtime13 = __toESM(require_jsx_runtime()); 1057 var comment_author_avatar_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)( 1058 import_primitives13.Path, 1059 { 1060 fillRule: "evenodd", 1061 d: "M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z", 1062 clipRule: "evenodd" 1063 } 1064 ) }); 1065 1066 // packages/icons/build-module/library/envelope.js 1067 var import_primitives14 = __toESM(require_primitives()); 1068 var import_jsx_runtime14 = __toESM(require_jsx_runtime()); 1069 var envelope_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)( 1070 import_primitives14.Path, 1071 { 1072 fillRule: "evenodd", 1073 clipRule: "evenodd", 1074 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" 1075 } 1076 ) }); 1077 1078 // packages/icons/build-module/library/error.js 1079 var import_primitives15 = __toESM(require_primitives()); 1080 var import_jsx_runtime15 = __toESM(require_jsx_runtime()); 1081 var error_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)( 1082 import_primitives15.Path, 1083 { 1084 fillRule: "evenodd", 1085 clipRule: "evenodd", 1086 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" 1087 } 1088 ) }); 1089 1090 // packages/icons/build-module/library/format-list-bullets-rtl.js 1091 var import_primitives16 = __toESM(require_primitives()); 1092 var import_jsx_runtime16 = __toESM(require_jsx_runtime()); 1093 var format_list_bullets_rtl_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: "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" }) }); 1094 1095 // packages/icons/build-module/library/format-list-bullets.js 1096 var import_primitives17 = __toESM(require_primitives()); 1097 var import_jsx_runtime17 = __toESM(require_jsx_runtime()); 1098 var format_list_bullets_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: "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" }) }); 1099 1100 // packages/icons/build-module/library/funnel.js 1101 var import_primitives18 = __toESM(require_primitives()); 1102 var import_jsx_runtime18 = __toESM(require_jsx_runtime()); 1103 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) }); 1104 1105 // packages/icons/build-module/library/home.js 1106 var import_primitives19 = __toESM(require_primitives()); 1107 var import_jsx_runtime19 = __toESM(require_jsx_runtime()); 1108 var home_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: "M12 4L4 7.9V20h16V7.9L12 4zm6.5 14.5H14V13h-4v5.5H5.5V8.8L12 5.7l6.5 3.1v9.7z" }) }); 1109 1110 // packages/icons/build-module/library/layout.js 1111 var import_primitives20 = __toESM(require_primitives()); 1112 var import_jsx_runtime20 = __toESM(require_jsx_runtime()); 1113 var layout_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: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 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" }) }); 1114 1115 // packages/icons/build-module/library/link.js 1116 var import_primitives21 = __toESM(require_primitives()); 1117 var import_jsx_runtime21 = __toESM(require_jsx_runtime()); 1118 var link_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: "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" }) }); 1119 1120 // packages/icons/build-module/library/list.js 1121 var import_primitives22 = __toESM(require_primitives()); 1122 var import_jsx_runtime22 = __toESM(require_jsx_runtime()); 1123 var list_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { d: "M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z" }) }); 1124 1125 // packages/icons/build-module/library/media.js 1126 var import_primitives23 = __toESM(require_primitives()); 1127 var import_jsx_runtime23 = __toESM(require_jsx_runtime()); 1128 var media_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 1129 /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.Path, { d: "m7 6.5 4 2.5-4 2.5z" }), 1130 /* @__PURE__ */ (0, import_jsx_runtime23.jsx)( 1131 import_primitives23.Path, 1132 { 1133 fillRule: "evenodd", 1134 clipRule: "evenodd", 1135 d: "m5 3c-1.10457 0-2 .89543-2 2v14c0 1.1046.89543 2 2 2h14c1.1046 0 2-.8954 2-2v-14c0-1.10457-.8954-2-2-2zm14 1.5h-14c-.27614 0-.5.22386-.5.5v10.7072l3.62953-2.6465c.25108-.1831.58905-.1924.84981-.0234l2.92666 1.8969 3.5712-3.4719c.2911-.2831.7545-.2831 1.0456 0l2.9772 2.8945v-9.3568c0-.27614-.2239-.5-.5-.5zm-14.5 14.5v-1.4364l4.09643-2.987 2.99567 1.9417c.2936.1903.6798.1523.9307-.0917l3.4772-3.3806 3.4772 3.3806.0228-.0234v2.5968c0 .2761-.2239.5-.5.5h-14c-.27614 0-.5-.2239-.5-.5z" 1136 } 1137 ) 1138 ] }); 1139 1140 // packages/icons/build-module/library/mobile.js 1141 var import_primitives24 = __toESM(require_primitives()); 1142 var import_jsx_runtime24 = __toESM(require_jsx_runtime()); 1143 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.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" }) }); 1144 1145 // packages/icons/build-module/library/more-vertical.js 1146 var import_primitives25 = __toESM(require_primitives()); 1147 var import_jsx_runtime25 = __toESM(require_jsx_runtime()); 1148 var more_vertical_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: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) }); 1149 1150 // packages/icons/build-module/library/next.js 1151 var import_primitives26 = __toESM(require_primitives()); 1152 var import_jsx_runtime26 = __toESM(require_jsx_runtime()); 1153 var next_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: "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" }) }); 1154 1155 // packages/icons/build-module/library/not-found.js 1156 var import_primitives27 = __toESM(require_primitives()); 1157 var import_jsx_runtime27 = __toESM(require_jsx_runtime()); 1158 var not_found_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 5c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2V7c0-1.1.9-2 2-2zM5 6.5c-.3 0-.5.2-.5.5v10c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V7c0-.3-.2-.5-.5-.5zm7.01 2.75q.711 0 1.24.364.533.364.824 1.012.296.645.296 1.488 0 .887-.296 1.556-.292.664-.824 1.036-.528.368-1.24.368-.708 0-1.24-.368-.527-.372-.824-1.036-.296-.668-.296-1.556 0-.848.296-1.492.296-.648.824-1.008a2.14 2.14 0 0 1 1.24-.364m-3.484 3.6h.72v.832h-.72v1.28h-.984v-1.28H4.75l3.08-4.32h.696zm9.522 0h.72v.832h-.72v1.28h-.983v-1.28h-2.793l3.08-4.32h.696zm-6.038-2.696q-.568 0-.952.48-.384.475-.384 1.48 0 .716.176 1.168.176.45.476.66.304.212.684.212t.68-.208q.304-.207.48-.656.176-.451.176-1.176 0-.996-.384-1.476-.38-.484-.952-.484M6.33 12.85h1.212v-1.722zm9.523 0h1.211v-1.722z" }) }); 1159 1160 // packages/icons/build-module/library/page.js 1161 var import_primitives28 = __toESM(require_primitives()); 1162 var import_jsx_runtime28 = __toESM(require_jsx_runtime()); 1163 var page_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 1164 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.Path, { d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" }), 1165 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.Path, { d: "M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z" }) 1166 ] }); 1167 1168 // packages/icons/build-module/library/pencil.js 1169 var import_primitives29 = __toESM(require_primitives()); 1170 var import_jsx_runtime29 = __toESM(require_jsx_runtime()); 1171 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) }); 1172 1173 // packages/icons/build-module/library/pin.js 1174 var import_primitives30 = __toESM(require_primitives()); 1175 var import_jsx_runtime30 = __toESM(require_jsx_runtime()); 1176 var pin_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives30.Path, { d: "m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z" }) }); 1177 1178 // packages/icons/build-module/library/post.js 1179 var import_primitives31 = __toESM(require_primitives()); 1180 var import_jsx_runtime31 = __toESM(require_jsx_runtime()); 1181 var post_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives31.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives31.Path, { d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z" }) }); 1182 1183 // packages/icons/build-module/library/previous.js 1184 var import_primitives32 = __toESM(require_primitives()); 1185 var import_jsx_runtime32 = __toESM(require_jsx_runtime()); 1186 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives32.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives32.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" }) }); 1187 1188 // packages/icons/build-module/library/published.js 1189 var import_primitives33 = __toESM(require_primitives()); 1190 var import_jsx_runtime33 = __toESM(require_jsx_runtime()); 1191 var published_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives33.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)( 1192 import_primitives33.Path, 1193 { 1194 fillRule: "evenodd", 1195 clipRule: "evenodd", 1196 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 0Zm11.53-1.47-1.06-1.06L11 12.94l-1.47-1.47-1.06 1.06L11 15.06l4.53-4.53Z" 1197 } 1198 ) }); 1199 1200 // packages/icons/build-module/library/scheduled.js 1201 var import_primitives34 = __toESM(require_primitives()); 1202 var import_jsx_runtime34 = __toESM(require_jsx_runtime()); 1203 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives34.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)( 1204 import_primitives34.Path, 1205 { 1206 fillRule: "evenodd", 1207 clipRule: "evenodd", 1208 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" 1209 } 1210 ) }); 1211 1212 // packages/icons/build-module/library/search.js 1213 var import_primitives35 = __toESM(require_primitives()); 1214 var import_jsx_runtime35 = __toESM(require_jsx_runtime()); 1215 var search_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives35.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives35.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" }) }); 1216 1217 // packages/icons/build-module/library/seen.js 1218 var import_primitives36 = __toESM(require_primitives()); 1219 var import_jsx_runtime36 = __toESM(require_jsx_runtime()); 1220 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives36.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives36.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" }) }); 1221 1222 // packages/icons/build-module/library/tag.js 1223 var import_primitives37 = __toESM(require_primitives()); 1224 var import_jsx_runtime37 = __toESM(require_jsx_runtime()); 1225 var tag_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives37.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives37.Path, { d: "M4.75 4a.75.75 0 0 0-.75.75v7.826c0 .2.08.39.22.53l6.72 6.716a2.313 2.313 0 0 0 3.276-.001l5.61-5.611-.531-.53.532.528a2.315 2.315 0 0 0 0-3.264L13.104 4.22a.75.75 0 0 0-.53-.22H4.75ZM19 12.576a.815.815 0 0 1-.236.574l-5.61 5.611a.814.814 0 0 1-1.153 0L5.5 12.264V5.5h6.763l6.5 6.502a.816.816 0 0 1 .237.574ZM8.75 9.75a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" }) }); 1226 1227 // packages/icons/build-module/library/unseen.js 1228 var import_primitives38 = __toESM(require_primitives()); 1229 var import_jsx_runtime38 = __toESM(require_jsx_runtime()); 1230 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives38.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives38.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" }) }); 1231 1232 // packages/icons/build-module/library/verse.js 1233 var import_primitives39 = __toESM(require_primitives()); 1234 var import_jsx_runtime39 = __toESM(require_jsx_runtime()); 1235 var verse_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives39.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives39.Path, { d: "M17.8 2l-.9.3c-.1 0-3.6 1-5.2 2.1C10 5.5 9.3 6.5 8.9 7.1c-.6.9-1.7 4.7-1.7 6.3l-.9 2.3c-.2.4 0 .8.4 1 .1 0 .2.1.3.1.3 0 .6-.2.7-.5l.6-1.5c.3 0 .7-.1 1.2-.2.7-.1 1.4-.3 2.2-.5.8-.2 1.6-.5 2.4-.8.7-.3 1.4-.7 1.9-1.2s.8-1.2 1-1.9c.2-.7.3-1.6.4-2.4.1-.8.1-1.7.2-2.5 0-.8.1-1.5.2-2.1V2zm-1.9 5.6c-.1.8-.2 1.5-.3 2.1-.2.6-.4 1-.6 1.3-.3.3-.8.6-1.4.9-.7.3-1.4.5-2.2.8-.6.2-1.3.3-1.8.4L15 7.5c.3-.3.6-.7 1-1.1 0 .4 0 .8-.1 1.2zM6 20h8v-1.5H6V20z" }) }); 1236 1237 // packages/dataviews/build-module/constants.js 1238 var OPERATOR_IS_ANY = "isAny"; 1239 var OPERATOR_IS_NONE = "isNone"; 1240 var OPERATOR_IS_ALL = "isAll"; 1241 var OPERATOR_IS_NOT_ALL = "isNotAll"; 1242 var OPERATOR_BETWEEN = "between"; 1243 var OPERATOR_IN_THE_PAST = "inThePast"; 1244 var OPERATOR_OVER = "over"; 1245 var OPERATOR_IS = "is"; 1246 var OPERATOR_IS_NOT = "isNot"; 1247 var OPERATOR_LESS_THAN = "lessThan"; 1248 var OPERATOR_GREATER_THAN = "greaterThan"; 1249 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual"; 1250 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual"; 1251 var OPERATOR_BEFORE = "before"; 1252 var OPERATOR_AFTER = "after"; 1253 var OPERATOR_BEFORE_INC = "beforeInc"; 1254 var OPERATOR_AFTER_INC = "afterInc"; 1255 var OPERATOR_CONTAINS = "contains"; 1256 var OPERATOR_NOT_CONTAINS = "notContains"; 1257 var OPERATOR_STARTS_WITH = "startsWith"; 1258 var OPERATOR_ON = "on"; 1259 var OPERATOR_NOT_ON = "notOn"; 1260 var SORTING_DIRECTIONS = ["asc", "desc"]; 1261 var sortArrows = { asc: "\u2191", desc: "\u2193" }; 1262 var sortValues = { asc: "ascending", desc: "descending" }; 1263 var sortLabels = { 1264 asc: (0, import_i18n.__)("Sort ascending"), 1265 desc: (0, import_i18n.__)("Sort descending") 1266 }; 1267 var sortIcons = { 1268 asc: arrow_up_default, 1269 desc: arrow_down_default 1270 }; 1271 var LAYOUT_TABLE = "table"; 1272 var LAYOUT_GRID = "grid"; 1273 var LAYOUT_LIST = "list"; 1274 var LAYOUT_ACTIVITY = "activity"; 1275 var LAYOUT_PICKER_GRID = "pickerGrid"; 1276 var LAYOUT_PICKER_TABLE = "pickerTable"; 1277 1278 // packages/dataviews/build-module/components/dataviews-context/index.js 1279 var DataViewsContext = (0, import_element2.createContext)({ 1280 view: { type: LAYOUT_TABLE }, 1281 onChangeView: () => { 1282 }, 1283 fields: [], 1284 data: [], 1285 paginationInfo: { 1286 totalItems: 0, 1287 totalPages: 0 1288 }, 1289 selection: [], 1290 onChangeSelection: () => { 1291 }, 1292 setOpenedFilter: () => { 1293 }, 1294 openedFilter: null, 1295 getItemId: (item) => item.id, 1296 isItemClickable: () => true, 1297 renderItemLink: void 0, 1298 containerWidth: 0, 1299 containerRef: (0, import_element2.createRef)(), 1300 resizeObserverRef: () => { 1301 }, 1302 defaultLayouts: { list: {}, grid: {}, table: {} }, 1303 filters: [], 1304 isShowingFilter: false, 1305 setIsShowingFilter: () => { 1306 }, 1307 hasInfiniteScrollHandler: false, 1308 config: { 1309 perPageSizes: [] 1310 } 1311 }); 1312 DataViewsContext.displayName = "DataViewsContext"; 1313 var dataviews_context_default = DataViewsContext; 1314 1315 // packages/dataviews/build-module/dataviews-layouts/index.js 1316 var import_i18n20 = __toESM(require_i18n()); 1317 1318 // node_modules/clsx/dist/clsx.mjs 1319 function r(e2) { 1320 var t2, f2, n2 = ""; 1321 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2; 1322 else if ("object" == typeof e2) if (Array.isArray(e2)) { 1323 var o2 = e2.length; 1324 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2); 1325 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2); 1326 return n2; 1327 } 1328 function clsx() { 1329 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2); 1330 return n2; 1331 } 1332 var clsx_default = clsx; 1333 1334 // packages/dataviews/build-module/dataviews-layouts/table/index.js 1335 var import_i18n8 = __toESM(require_i18n()); 1336 var import_components7 = __toESM(require_components()); 1337 var import_element9 = __toESM(require_element()); 1338 var import_keycodes = __toESM(require_keycodes()); 1339 1340 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.js 1341 var import_components = __toESM(require_components()); 1342 var import_i18n2 = __toESM(require_i18n()); 1343 var import_jsx_runtime40 = __toESM(require_jsx_runtime()); 1344 function DataViewsSelectionCheckbox({ 1345 selection, 1346 onChangeSelection, 1347 item, 1348 getItemId: getItemId2, 1349 titleField, 1350 disabled, 1351 ...extraProps 1352 }) { 1353 const id = getItemId2(item); 1354 const checked = !disabled && selection.includes(id); 1355 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)"); 1356 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)( 1357 import_components.CheckboxControl, 1358 { 1359 className: "dataviews-selection-checkbox", 1360 "aria-label": selectionLabel, 1361 "aria-disabled": disabled, 1362 checked, 1363 onChange: () => { 1364 if (disabled) { 1365 return; 1366 } 1367 onChangeSelection( 1368 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 1369 ); 1370 }, 1371 ...extraProps 1372 } 1373 ); 1374 } 1375 1376 // packages/dataviews/build-module/components/dataviews-item-actions/index.js 1377 var import_components2 = __toESM(require_components()); 1378 var import_i18n3 = __toESM(require_i18n()); 1379 var import_element3 = __toESM(require_element()); 1380 var import_data3 = __toESM(require_data()); 1381 var import_compose = __toESM(require_compose()); 1382 1383 // packages/dataviews/build-module/lock-unlock.js 1384 var import_private_apis = __toESM(require_private_apis()); 1385 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 1386 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 1387 "@wordpress/dataviews" 1388 ); 1389 1390 // packages/dataviews/build-module/components/dataviews-item-actions/index.js 1391 var import_jsx_runtime41 = __toESM(require_jsx_runtime()); 1392 var { Menu, kebabCase } = unlock(import_components2.privateApis); 1393 function ButtonTrigger({ 1394 action, 1395 onClick, 1396 items, 1397 variant 1398 }) { 1399 const label = typeof action.label === "string" ? action.label : action.label(items); 1400 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 1401 import_components2.Button, 1402 { 1403 disabled: !!action.disabled, 1404 accessibleWhenDisabled: true, 1405 size: "compact", 1406 variant, 1407 onClick, 1408 children: label 1409 } 1410 ); 1411 } 1412 function MenuItemTrigger({ 1413 action, 1414 onClick, 1415 items 1416 }) { 1417 const label = typeof action.label === "string" ? action.label : action.label(items); 1418 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.ItemLabel, { children: label }) }); 1419 } 1420 function ActionModal({ 1421 action, 1422 items, 1423 closeModal 1424 }) { 1425 const label = typeof action.label === "string" ? action.label : action.label(items); 1426 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader; 1427 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 1428 import_components2.Modal, 1429 { 1430 title: modalHeader || label, 1431 __experimentalHideHeader: !!action.hideModalHeader, 1432 onRequestClose: closeModal, 1433 focusOnMount: action.modalFocusOnMount ?? true, 1434 size: action.modalSize || "medium", 1435 overlayClassName: `dataviews-action-modal dataviews-action-modal__$kebabCase( 1436 action.id 1437 )}`, 1438 children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(action.RenderModal, { items, closeModal }) 1439 } 1440 ); 1441 } 1442 function ActionsMenuGroup({ 1443 actions, 1444 item, 1445 registry, 1446 setActiveModalAction 1447 }) { 1448 const { primaryActions, regularActions } = (0, import_element3.useMemo)(() => { 1449 return actions.reduce( 1450 (acc, action) => { 1451 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action); 1452 return acc; 1453 }, 1454 { 1455 primaryActions: [], 1456 regularActions: [] 1457 } 1458 ); 1459 }, [actions]); 1460 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 1461 MenuItemTrigger, 1462 { 1463 action, 1464 onClick: () => { 1465 if ("RenderModal" in action) { 1466 setActiveModalAction(action); 1467 return; 1468 } 1469 action.callback([item], { registry }); 1470 }, 1471 items: [item] 1472 }, 1473 action.id 1474 )); 1475 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu.Group, { children: [ 1476 renderActionGroup(primaryActions), 1477 primaryActions.length > 0 && regularActions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Separator, {}), 1478 renderActionGroup(regularActions) 1479 ] }); 1480 } 1481 function ItemActions({ 1482 item, 1483 actions, 1484 isCompact 1485 }) { 1486 const registry = (0, import_data3.useRegistry)(); 1487 const { primaryActions, eligibleActions } = (0, import_element3.useMemo)(() => { 1488 const _eligibleActions = actions.filter( 1489 (action) => !action.isEligible || action.isEligible(item) 1490 ); 1491 const _primaryActions = _eligibleActions.filter( 1492 (action) => action.isPrimary 1493 ); 1494 return { 1495 primaryActions: _primaryActions, 1496 eligibleActions: _eligibleActions 1497 }; 1498 }, [actions, item]); 1499 if (isCompact) { 1500 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 1501 CompactItemActions, 1502 { 1503 item, 1504 actions: eligibleActions, 1505 isSmall: true, 1506 registry 1507 } 1508 ); 1509 } 1510 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)( 1511 import_components2.__experimentalHStack, 1512 { 1513 spacing: 0, 1514 justify: "flex-end", 1515 className: "dataviews-item-actions", 1516 style: { 1517 flexShrink: 0, 1518 width: "auto" 1519 }, 1520 children: [ 1521 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 1522 PrimaryActions, 1523 { 1524 item, 1525 actions: primaryActions, 1526 registry 1527 } 1528 ), 1529 primaryActions.length < eligibleActions.length && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 1530 CompactItemActions, 1531 { 1532 item, 1533 actions: eligibleActions, 1534 registry 1535 } 1536 ) 1537 ] 1538 } 1539 ); 1540 } 1541 function CompactItemActions({ 1542 item, 1543 actions, 1544 isSmall, 1545 registry 1546 }) { 1547 const [activeModalAction, setActiveModalAction] = (0, import_element3.useState)( 1548 null 1549 ); 1550 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [ 1551 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu, { placement: "bottom-end", children: [ 1552 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 1553 Menu.TriggerButton, 1554 { 1555 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 1556 import_components2.Button, 1557 { 1558 size: isSmall ? "small" : "compact", 1559 icon: more_vertical_default, 1560 label: (0, import_i18n3.__)("Actions"), 1561 accessibleWhenDisabled: true, 1562 disabled: !actions.length, 1563 className: "dataviews-all-actions-button" 1564 } 1565 ) 1566 } 1567 ), 1568 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 1569 ActionsMenuGroup, 1570 { 1571 actions, 1572 item, 1573 registry, 1574 setActiveModalAction 1575 } 1576 ) }) 1577 ] }), 1578 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 1579 ActionModal, 1580 { 1581 action: activeModalAction, 1582 items: [item], 1583 closeModal: () => setActiveModalAction(null) 1584 } 1585 ) 1586 ] }); 1587 } 1588 function PrimaryActions({ 1589 item, 1590 actions, 1591 registry, 1592 buttonVariant 1593 }) { 1594 const [activeModalAction, setActiveModalAction] = (0, import_element3.useState)(null); 1595 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<"); 1596 if (isMobileViewport) { 1597 return null; 1598 } 1599 if (!Array.isArray(actions) || actions.length === 0) { 1600 return null; 1601 } 1602 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [ 1603 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 1604 ButtonTrigger, 1605 { 1606 action, 1607 onClick: () => { 1608 if ("RenderModal" in action) { 1609 setActiveModalAction(action); 1610 return; 1611 } 1612 action.callback([item], { registry }); 1613 }, 1614 items: [item], 1615 variant: buttonVariant 1616 }, 1617 action.id 1618 )), 1619 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)( 1620 ActionModal, 1621 { 1622 action: activeModalAction, 1623 items: [item], 1624 closeModal: () => setActiveModalAction(null) 1625 } 1626 ) 1627 ] }); 1628 } 1629 1630 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.js 1631 var import_components3 = __toESM(require_components()); 1632 var import_i18n4 = __toESM(require_i18n()); 1633 var import_element4 = __toESM(require_element()); 1634 var import_data4 = __toESM(require_data()); 1635 var import_compose2 = __toESM(require_compose()); 1636 var import_jsx_runtime42 = __toESM(require_jsx_runtime()); 1637 function ActionWithModal({ 1638 action, 1639 items, 1640 ActionTriggerComponent 1641 }) { 1642 const [isModalOpen, setIsModalOpen] = (0, import_element4.useState)(false); 1643 const actionTriggerProps = { 1644 action, 1645 onClick: () => { 1646 setIsModalOpen(true); 1647 }, 1648 items 1649 }; 1650 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [ 1651 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ActionTriggerComponent, { ...actionTriggerProps }), 1652 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 1653 ActionModal, 1654 { 1655 action, 1656 items, 1657 closeModal: () => setIsModalOpen(false) 1658 } 1659 ) 1660 ] }); 1661 } 1662 function useHasAPossibleBulkAction(actions, item) { 1663 return (0, import_element4.useMemo)(() => { 1664 return actions.some((action) => { 1665 return action.supportsBulk && (!action.isEligible || action.isEligible(item)); 1666 }); 1667 }, [actions, item]); 1668 } 1669 function useSomeItemHasAPossibleBulkAction(actions, data) { 1670 return (0, import_element4.useMemo)(() => { 1671 return data.some((item) => { 1672 return actions.some((action) => { 1673 return action.supportsBulk && (!action.isEligible || action.isEligible(item)); 1674 }); 1675 }); 1676 }, [actions, data]); 1677 } 1678 function BulkSelectionCheckbox({ 1679 selection, 1680 onChangeSelection, 1681 data, 1682 actions, 1683 getItemId: getItemId2 1684 }) { 1685 const selectableItems = (0, import_element4.useMemo)(() => { 1686 return data.filter((item) => { 1687 return actions.some( 1688 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item)) 1689 ); 1690 }); 1691 }, [data, actions]); 1692 const selectedItems = data.filter( 1693 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item) 1694 ); 1695 const areAllSelected = selectedItems.length === selectableItems.length; 1696 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 1697 import_components3.CheckboxControl, 1698 { 1699 className: "dataviews-view-table-selection-checkbox", 1700 checked: areAllSelected, 1701 indeterminate: !areAllSelected && !!selectedItems.length, 1702 onChange: () => { 1703 if (areAllSelected) { 1704 onChangeSelection([]); 1705 } else { 1706 onChangeSelection( 1707 selectableItems.map((item) => getItemId2(item)) 1708 ); 1709 } 1710 }, 1711 "aria-label": areAllSelected ? (0, import_i18n4.__)("Deselect all") : (0, import_i18n4.__)("Select all") 1712 } 1713 ); 1714 } 1715 function ActionTrigger({ 1716 action, 1717 onClick, 1718 isBusy, 1719 items 1720 }) { 1721 const label = typeof action.label === "string" ? action.label : action.label(items); 1722 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<"); 1723 if (isMobile) { 1724 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 1725 import_components3.Button, 1726 { 1727 disabled: isBusy, 1728 accessibleWhenDisabled: true, 1729 label, 1730 icon: action.icon, 1731 size: "compact", 1732 onClick, 1733 isBusy 1734 } 1735 ); 1736 } 1737 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 1738 import_components3.Button, 1739 { 1740 disabled: isBusy, 1741 accessibleWhenDisabled: true, 1742 size: "compact", 1743 onClick, 1744 isBusy, 1745 children: label 1746 } 1747 ); 1748 } 1749 var EMPTY_ARRAY = []; 1750 function ActionButton({ 1751 action, 1752 selectedItems, 1753 actionInProgress, 1754 setActionInProgress 1755 }) { 1756 const registry = (0, import_data4.useRegistry)(); 1757 const selectedEligibleItems = (0, import_element4.useMemo)(() => { 1758 return selectedItems.filter((item) => { 1759 return !action.isEligible || action.isEligible(item); 1760 }); 1761 }, [action, selectedItems]); 1762 if ("RenderModal" in action) { 1763 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 1764 ActionWithModal, 1765 { 1766 action, 1767 items: selectedEligibleItems, 1768 ActionTriggerComponent: ActionTrigger 1769 }, 1770 action.id 1771 ); 1772 } 1773 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 1774 ActionTrigger, 1775 { 1776 action, 1777 onClick: async () => { 1778 setActionInProgress(action.id); 1779 await action.callback(selectedItems, { 1780 registry 1781 }); 1782 setActionInProgress(null); 1783 }, 1784 items: selectedEligibleItems, 1785 isBusy: actionInProgress === action.id 1786 }, 1787 action.id 1788 ); 1789 } 1790 function renderFooterContent(data, actions, getItemId2, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection) { 1791 const message2 = selectedItems.length > 0 ? (0, import_i18n4.sprintf)( 1792 /* translators: %d: number of items. */ 1793 (0, import_i18n4._n)( 1794 "%d Item selected", 1795 "%d Items selected", 1796 selectedItems.length 1797 ), 1798 selectedItems.length 1799 ) : (0, import_i18n4.sprintf)( 1800 /* translators: %d: number of items. */ 1801 (0, import_i18n4._n)("%d Item", "%d Items", data.length), 1802 data.length 1803 ); 1804 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)( 1805 import_components3.__experimentalHStack, 1806 { 1807 expanded: false, 1808 className: "dataviews-bulk-actions-footer__container", 1809 spacing: 3, 1810 children: [ 1811 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 1812 BulkSelectionCheckbox, 1813 { 1814 selection, 1815 onChangeSelection, 1816 data, 1817 actions, 1818 getItemId: getItemId2 1819 } 1820 ), 1821 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }), 1822 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)( 1823 import_components3.__experimentalHStack, 1824 { 1825 className: "dataviews-bulk-actions-footer__action-buttons", 1826 expanded: false, 1827 spacing: 1, 1828 children: [ 1829 actionsToShow.map((action) => { 1830 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 1831 ActionButton, 1832 { 1833 action, 1834 selectedItems, 1835 actionInProgress, 1836 setActionInProgress 1837 }, 1838 action.id 1839 ); 1840 }), 1841 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 1842 import_components3.Button, 1843 { 1844 icon: close_small_default, 1845 showTooltip: true, 1846 tooltipPosition: "top", 1847 size: "compact", 1848 label: (0, import_i18n4.__)("Cancel"), 1849 disabled: !!actionInProgress, 1850 accessibleWhenDisabled: false, 1851 onClick: () => { 1852 onChangeSelection(EMPTY_ARRAY); 1853 } 1854 } 1855 ) 1856 ] 1857 } 1858 ) 1859 ] 1860 } 1861 ); 1862 } 1863 function FooterContent({ 1864 selection, 1865 actions, 1866 onChangeSelection, 1867 data, 1868 getItemId: getItemId2 1869 }) { 1870 const [actionInProgress, setActionInProgress] = (0, import_element4.useState)( 1871 null 1872 ); 1873 const footerContentRef = (0, import_element4.useRef)(null); 1874 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<"); 1875 const bulkActions = (0, import_element4.useMemo)( 1876 () => actions.filter((action) => action.supportsBulk), 1877 [actions] 1878 ); 1879 const selectableItems = (0, import_element4.useMemo)(() => { 1880 return data.filter((item) => { 1881 return bulkActions.some( 1882 (action) => !action.isEligible || action.isEligible(item) 1883 ); 1884 }); 1885 }, [data, bulkActions]); 1886 const selectedItems = (0, import_element4.useMemo)(() => { 1887 return data.filter( 1888 (item) => selection.includes(getItemId2(item)) && selectableItems.includes(item) 1889 ); 1890 }, [selection, data, getItemId2, selectableItems]); 1891 const actionsToShow = (0, import_element4.useMemo)( 1892 () => actions.filter((action) => { 1893 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some( 1894 (item) => !action.isEligible || action.isEligible(item) 1895 ); 1896 }), 1897 [actions, selectedItems, isMobile] 1898 ); 1899 if (!actionInProgress) { 1900 if (footerContentRef.current) { 1901 footerContentRef.current = null; 1902 } 1903 return renderFooterContent( 1904 data, 1905 actions, 1906 getItemId2, 1907 selection, 1908 actionsToShow, 1909 selectedItems, 1910 actionInProgress, 1911 setActionInProgress, 1912 onChangeSelection 1913 ); 1914 } else if (!footerContentRef.current) { 1915 footerContentRef.current = renderFooterContent( 1916 data, 1917 actions, 1918 getItemId2, 1919 selection, 1920 actionsToShow, 1921 selectedItems, 1922 actionInProgress, 1923 setActionInProgress, 1924 onChangeSelection 1925 ); 1926 } 1927 return footerContentRef.current; 1928 } 1929 function BulkActionsFooter() { 1930 const { 1931 data, 1932 selection, 1933 actions = EMPTY_ARRAY, 1934 onChangeSelection, 1935 getItemId: getItemId2 1936 } = (0, import_element4.useContext)(dataviews_context_default); 1937 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)( 1938 FooterContent, 1939 { 1940 selection, 1941 onChangeSelection, 1942 data, 1943 actions, 1944 getItemId: getItemId2 1945 } 1946 ); 1947 } 1948 1949 // packages/dataviews/build-module/dataviews-layouts/table/column-header-menu.js 1950 var import_i18n5 = __toESM(require_i18n()); 1951 var import_components4 = __toESM(require_components()); 1952 var import_element5 = __toESM(require_element()); 1953 1954 // packages/dataviews/build-module/utils/get-hideable-fields.js 1955 function getHideableFields(view, fields) { 1956 const togglableFields = [ 1957 view?.titleField, 1958 view?.mediaField, 1959 view?.descriptionField 1960 ].filter(Boolean); 1961 return fields.filter( 1962 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false 1963 ); 1964 } 1965 1966 // packages/dataviews/build-module/dataviews-layouts/table/column-header-menu.js 1967 var import_jsx_runtime43 = __toESM(require_jsx_runtime()); 1968 var { Menu: Menu2 } = unlock(import_components4.privateApis); 1969 function WithMenuSeparators({ children }) { 1970 return import_element5.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_element5.Fragment, { children: [ 1971 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Separator, {}), 1972 child 1973 ] }, i2)); 1974 } 1975 var _HeaderMenu = (0, import_element5.forwardRef)(function HeaderMenu({ 1976 fieldId, 1977 view, 1978 fields, 1979 onChangeView, 1980 onHide, 1981 setOpenedFilter, 1982 canMove = true, 1983 canInsertLeft = true, 1984 canInsertRight = true 1985 }, ref) { 1986 const visibleFieldIds = view.fields ?? []; 1987 const index = visibleFieldIds?.indexOf(fieldId); 1988 const isSorted = view.sort?.field === fieldId; 1989 let isHidable = false; 1990 let isSortable = false; 1991 let canAddFilter = false; 1992 let operators = []; 1993 const field = fields.find((f2) => f2.id === fieldId); 1994 const { setIsShowingFilter } = (0, import_element5.useContext)(dataviews_context_default); 1995 if (!field) { 1996 return null; 1997 } 1998 isHidable = field.enableHiding !== false; 1999 isSortable = field.enableSorting !== false; 2000 const header = field.header; 2001 operators = !!field.filterBy && field.filterBy?.operators || []; 2002 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary; 2003 if (!isSortable && !canMove && !isHidable && !canAddFilter) { 2004 return header; 2005 } 2006 const hiddenFields = getHideableFields(view, fields).filter( 2007 (f2) => !visibleFieldIds.includes(f2.id) 2008 ); 2009 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length; 2010 return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [ 2011 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)( 2012 Menu2.TriggerButton, 2013 { 2014 render: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 2015 import_components4.Button, 2016 { 2017 size: "compact", 2018 className: "dataviews-view-table-header-button", 2019 ref, 2020 variant: "tertiary" 2021 } 2022 ), 2023 children: [ 2024 header, 2025 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] }) 2026 ] 2027 } 2028 ), 2029 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(WithMenuSeparators, { children: [ 2030 isSortable && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map( 2031 (direction) => { 2032 const isChecked = view.sort && isSorted && view.sort.direction === direction; 2033 const value = `$fieldId}-$direction}`; 2034 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 2035 Menu2.RadioItem, 2036 { 2037 name: "view-table-sorting", 2038 value, 2039 checked: isChecked, 2040 onChange: () => { 2041 onChangeView({ 2042 ...view, 2043 sort: { 2044 field: fieldId, 2045 direction 2046 }, 2047 showLevels: false 2048 }); 2049 }, 2050 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] }) 2051 }, 2052 value 2053 ); 2054 } 2055 ) }), 2056 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 2057 Menu2.Item, 2058 { 2059 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: funnel_default }), 2060 onClick: () => { 2061 setOpenedFilter(fieldId); 2062 setIsShowingFilter(true); 2063 onChangeView({ 2064 ...view, 2065 page: 1, 2066 filters: [ 2067 ...view.filters || [], 2068 { 2069 field: fieldId, 2070 value: void 0, 2071 operator: operators[0] 2072 } 2073 ] 2074 }); 2075 }, 2076 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Add filter") }) 2077 } 2078 ) }), 2079 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2.Group, { children: [ 2080 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 2081 Menu2.Item, 2082 { 2083 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_left_default }), 2084 disabled: index < 1, 2085 onClick: () => { 2086 onChangeView({ 2087 ...view, 2088 fields: [ 2089 ...visibleFieldIds.slice( 2090 0, 2091 index - 1 2092 ) ?? [], 2093 fieldId, 2094 visibleFieldIds[index - 1], 2095 ...visibleFieldIds.slice( 2096 index + 1 2097 ) 2098 ] 2099 }); 2100 }, 2101 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Move left") }) 2102 } 2103 ), 2104 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 2105 Menu2.Item, 2106 { 2107 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_right_default }), 2108 disabled: index >= visibleFieldIds.length - 1, 2109 onClick: () => { 2110 onChangeView({ 2111 ...view, 2112 fields: [ 2113 ...visibleFieldIds.slice( 2114 0, 2115 index 2116 ) ?? [], 2117 visibleFieldIds[index + 1], 2118 fieldId, 2119 ...visibleFieldIds.slice( 2120 index + 2 2121 ) 2122 ] 2123 }); 2124 }, 2125 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Move right") }) 2126 } 2127 ), 2128 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [ 2129 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Insert left") }) }), 2130 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 2131 Menu2.Item, 2132 { 2133 onClick: () => { 2134 onChangeView({ 2135 ...view, 2136 fields: [ 2137 ...visibleFieldIds.slice( 2138 0, 2139 index 2140 ), 2141 hiddenField.id, 2142 ...visibleFieldIds.slice( 2143 index 2144 ) 2145 ] 2146 }); 2147 }, 2148 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 2149 }, 2150 hiddenField.id 2151 )) }) 2152 ] }), 2153 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [ 2154 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Insert right") }) }), 2155 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 2156 Menu2.Item, 2157 { 2158 onClick: () => { 2159 onChangeView({ 2160 ...view, 2161 fields: [ 2162 ...visibleFieldIds.slice( 2163 0, 2164 index + 1 2165 ), 2166 hiddenField.id, 2167 ...visibleFieldIds.slice( 2168 index + 1 2169 ) 2170 ] 2171 }); 2172 }, 2173 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label }) 2174 }, 2175 hiddenField.id 2176 )) }) 2177 ] }), 2178 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)( 2179 Menu2.Item, 2180 { 2181 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: unseen_default }), 2182 onClick: () => { 2183 onHide(field); 2184 onChangeView({ 2185 ...view, 2186 fields: visibleFieldIds.filter( 2187 (id) => id !== fieldId 2188 ) 2189 }); 2190 }, 2191 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n5.__)("Hide column") }) 2192 } 2193 ) 2194 ] }) 2195 ] }) }) 2196 ] }); 2197 }); 2198 var ColumnHeaderMenu = _HeaderMenu; 2199 var column_header_menu_default = ColumnHeaderMenu; 2200 2201 // packages/dataviews/build-module/dataviews-layouts/table/column-primary.js 2202 var import_components5 = __toESM(require_components()); 2203 2204 // packages/dataviews/build-module/dataviews-layouts/utils/item-click-wrapper.js 2205 var import_element6 = __toESM(require_element()); 2206 var import_jsx_runtime44 = __toESM(require_jsx_runtime()); 2207 function getClickableItemProps({ 2208 item, 2209 isItemClickable, 2210 onClickItem, 2211 className 2212 }) { 2213 if (!isItemClickable(item) || !onClickItem) { 2214 return { className }; 2215 } 2216 return { 2217 className: className ? `$className} $className}--clickable` : void 0, 2218 role: "button", 2219 tabIndex: 0, 2220 onClick: (event) => { 2221 event.stopPropagation(); 2222 onClickItem(item); 2223 }, 2224 onKeyDown: (event) => { 2225 if (event.key === "Enter" || event.key === "" || event.key === " ") { 2226 event.stopPropagation(); 2227 onClickItem(item); 2228 } 2229 } 2230 }; 2231 } 2232 function ItemClickWrapper({ 2233 item, 2234 isItemClickable, 2235 onClickItem, 2236 renderItemLink, 2237 className, 2238 children, 2239 ...extraProps 2240 }) { 2241 if (!isItemClickable(item)) { 2242 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className, ...extraProps, children }); 2243 } 2244 if (renderItemLink) { 2245 const renderedElement = renderItemLink({ 2246 item, 2247 className: `$className} $className}--clickable`, 2248 ...extraProps, 2249 children 2250 }); 2251 return (0, import_element6.cloneElement)(renderedElement, { 2252 onClick: (event) => { 2253 event.stopPropagation(); 2254 if (renderedElement.props.onClick) { 2255 renderedElement.props.onClick(event); 2256 } 2257 }, 2258 onKeyDown: (event) => { 2259 if (event.key === "Enter" || event.key === "" || event.key === " ") { 2260 event.stopPropagation(); 2261 if (renderedElement.props.onKeyDown) { 2262 renderedElement.props.onKeyDown(event); 2263 } 2264 } 2265 } 2266 }); 2267 } 2268 const clickProps = getClickableItemProps({ 2269 item, 2270 isItemClickable, 2271 onClickItem, 2272 className 2273 }); 2274 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ...clickProps, ...extraProps, children }); 2275 } 2276 2277 // packages/dataviews/build-module/dataviews-layouts/table/column-primary.js 2278 var import_jsx_runtime45 = __toESM(require_jsx_runtime()); 2279 function ColumnPrimary({ 2280 item, 2281 level, 2282 titleField, 2283 mediaField, 2284 descriptionField: descriptionField2, 2285 onClickItem, 2286 renderItemLink, 2287 isItemClickable 2288 }) { 2289 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_components5.__experimentalHStack, { spacing: 3, alignment: "flex-start", justify: "flex-start", children: [ 2290 mediaField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 2291 ItemClickWrapper, 2292 { 2293 item, 2294 isItemClickable, 2295 onClickItem, 2296 renderItemLink, 2297 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media", 2298 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0, 2299 children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 2300 mediaField.render, 2301 { 2302 item, 2303 field: mediaField, 2304 config: { sizes: "32px" } 2305 } 2306 ) 2307 } 2308 ), 2309 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)( 2310 import_components5.__experimentalVStack, 2311 { 2312 spacing: 0, 2313 alignment: "flex-start", 2314 className: "dataviews-view-table__primary-column-content", 2315 children: [ 2316 titleField && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)( 2317 ItemClickWrapper, 2318 { 2319 item, 2320 isItemClickable, 2321 onClickItem, 2322 renderItemLink, 2323 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field", 2324 children: [ 2325 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "dataviews-view-table__level", children: [ 2326 "\u2014".repeat(level), 2327 "\xA0" 2328 ] }), 2329 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(titleField.render, { item, field: titleField }) 2330 ] 2331 } 2332 ), 2333 descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)( 2334 descriptionField2.render, 2335 { 2336 item, 2337 field: descriptionField2 2338 } 2339 ) 2340 ] 2341 } 2342 ) 2343 ] }); 2344 } 2345 var column_primary_default = ColumnPrimary; 2346 2347 // packages/dataviews/build-module/dataviews-layouts/table/use-is-horizontal-scroll-end.js 2348 var import_compose3 = __toESM(require_compose()); 2349 var import_element7 = __toESM(require_element()); 2350 var import_i18n6 = __toESM(require_i18n()); 2351 var isScrolledToEnd = (element) => { 2352 if ((0, import_i18n6.isRTL)()) { 2353 const scrollLeft = Math.abs(element.scrollLeft); 2354 return scrollLeft <= 1; 2355 } 2356 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1; 2357 }; 2358 function useIsHorizontalScrollEnd({ 2359 scrollContainerRef, 2360 enabled = false 2361 }) { 2362 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element7.useState)(false); 2363 const handleIsHorizontalScrollEnd = (0, import_compose3.useDebounce)( 2364 (0, import_element7.useCallback)(() => { 2365 const scrollContainer = scrollContainerRef.current; 2366 if (scrollContainer) { 2367 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer)); 2368 } 2369 }, [scrollContainerRef, setIsHorizontalScrollEnd]), 2370 200 2371 ); 2372 (0, import_element7.useEffect)(() => { 2373 if (typeof window === "undefined" || !enabled || !scrollContainerRef.current) { 2374 return () => { 2375 }; 2376 } 2377 handleIsHorizontalScrollEnd(); 2378 scrollContainerRef.current.addEventListener( 2379 "scroll", 2380 handleIsHorizontalScrollEnd 2381 ); 2382 window.addEventListener("resize", handleIsHorizontalScrollEnd); 2383 return () => { 2384 scrollContainerRef.current?.removeEventListener( 2385 "scroll", 2386 handleIsHorizontalScrollEnd 2387 ); 2388 window.removeEventListener("resize", handleIsHorizontalScrollEnd); 2389 }; 2390 }, [scrollContainerRef, enabled]); 2391 return isHorizontalScrollEnd; 2392 } 2393 2394 // packages/dataviews/build-module/dataviews-layouts/utils/get-data-by-group.js 2395 function getDataByGroup(data, groupByField) { 2396 return data.reduce((groups, item) => { 2397 const groupName = groupByField.getValue({ item }); 2398 if (!groups.has(groupName)) { 2399 groups.set(groupName, []); 2400 } 2401 groups.get(groupName)?.push(item); 2402 return groups; 2403 }, /* @__PURE__ */ new Map()); 2404 } 2405 2406 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.js 2407 var import_components6 = __toESM(require_components()); 2408 var import_i18n7 = __toESM(require_i18n()); 2409 var import_element8 = __toESM(require_element()); 2410 var import_jsx_runtime46 = __toESM(require_jsx_runtime()); 2411 function FieldItem({ 2412 field, 2413 isVisible: isVisible2, 2414 onToggleVisibility 2415 }) { 2416 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_components6.__experimentalHStack, { expanded: true, justify: "flex-start", alignment: "center", children: [ 2417 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: check_default }) }), 2418 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "dataviews-view-config__label", children: field.label }) 2419 ] }) }); 2420 } 2421 function isDefined(item) { 2422 return !!item; 2423 } 2424 function PropertiesSection({ 2425 showLabel = true 2426 }) { 2427 const { view, fields, onChangeView } = (0, import_element8.useContext)(dataviews_context_default); 2428 const regularFields = getHideableFields(view, fields); 2429 if (!regularFields?.length) { 2430 return null; 2431 } 2432 const titleField = fields.find((f2) => f2.id === view.titleField); 2433 const previewField2 = fields.find((f2) => f2.id === view.mediaField); 2434 const descriptionField2 = fields.find( 2435 (f2) => f2.id === view.descriptionField 2436 ); 2437 const lockedFields = [ 2438 { 2439 field: titleField, 2440 isVisibleFlag: "showTitle" 2441 }, 2442 { 2443 field: previewField2, 2444 isVisibleFlag: "showMedia" 2445 }, 2446 { 2447 field: descriptionField2, 2448 isVisibleFlag: "showDescription" 2449 } 2450 ].filter(({ field }) => isDefined(field)); 2451 const visibleFieldIds = view.fields ?? []; 2452 const visibleRegularFieldsCount = regularFields.filter( 2453 (f2) => visibleFieldIds.includes(f2.id) 2454 ).length; 2455 let visibleLockedFields = lockedFields.filter( 2456 ({ field, isVisibleFlag }) => ( 2457 // @ts-expect-error 2458 isDefined(field) && (view[isVisibleFlag] ?? true) 2459 ) 2460 ); 2461 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount; 2462 if (totalVisibleFields === 1) { 2463 if (visibleLockedFields.length === 1) { 2464 visibleLockedFields = visibleLockedFields.map((locked) => ({ 2465 ...locked, 2466 field: { ...locked.field, enableHiding: false } 2467 })); 2468 } 2469 } 2470 const hiddenLockedFields = lockedFields.filter( 2471 ({ field, isVisibleFlag }) => ( 2472 // @ts-expect-error 2473 isDefined(field) && !(view[isVisibleFlag] ?? true) 2474 ) 2475 ); 2476 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_components6.__experimentalVStack, { className: "dataviews-field-control", spacing: 0, children: [ 2477 showLabel && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.BaseControl.VisualLabel, { children: (0, import_i18n7.__)("Properties") }), 2478 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.__experimentalVStack, { className: "dataviews-view-config__properties", spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_components6.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [ 2479 visibleLockedFields.map(({ field, isVisibleFlag }) => { 2480 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 2481 FieldItem, 2482 { 2483 field, 2484 isVisible: true, 2485 onToggleVisibility: () => { 2486 onChangeView({ 2487 ...view, 2488 [isVisibleFlag]: false 2489 }); 2490 } 2491 }, 2492 field.id 2493 ); 2494 }), 2495 hiddenLockedFields.map(({ field, isVisibleFlag }) => { 2496 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 2497 FieldItem, 2498 { 2499 field, 2500 isVisible: false, 2501 onToggleVisibility: () => { 2502 onChangeView({ 2503 ...view, 2504 [isVisibleFlag]: true 2505 }); 2506 } 2507 }, 2508 field.id 2509 ); 2510 }), 2511 regularFields.map((field) => { 2512 const isVisible2 = visibleFieldIds.includes(field.id); 2513 const isLastVisible = totalVisibleFields === 1 && isVisible2; 2514 const fieldToRender = isLastVisible ? { ...field, enableHiding: false } : field; 2515 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)( 2516 FieldItem, 2517 { 2518 field: fieldToRender, 2519 isVisible: isVisible2, 2520 onToggleVisibility: () => { 2521 onChangeView({ 2522 ...view, 2523 fields: isVisible2 ? visibleFieldIds.filter( 2524 (fieldId) => fieldId !== field.id 2525 ) : [...visibleFieldIds, field.id] 2526 }); 2527 } 2528 }, 2529 field.id 2530 ); 2531 }) 2532 ] }) }) 2533 ] }); 2534 } 2535 2536 // packages/dataviews/build-module/dataviews-layouts/table/index.js 2537 var import_jsx_runtime47 = __toESM(require_jsx_runtime()); 2538 function TableColumnField({ 2539 item, 2540 fields, 2541 column, 2542 align 2543 }) { 2544 const field = fields.find((f2) => f2.id === column); 2545 if (!field) { 2546 return null; 2547 } 2548 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 2549 "dataviews-view-table__cell-align-end": align === "end", 2550 "dataviews-view-table__cell-align-center": align === "center" 2551 }); 2552 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(field.render, { item, field }) }); 2553 } 2554 function TableRow({ 2555 hasBulkActions, 2556 item, 2557 level, 2558 actions, 2559 fields, 2560 id, 2561 view, 2562 titleField, 2563 mediaField, 2564 descriptionField: descriptionField2, 2565 selection, 2566 getItemId: getItemId2, 2567 isItemClickable, 2568 onClickItem, 2569 renderItemLink, 2570 onChangeSelection, 2571 isActionsColumnSticky, 2572 posinset 2573 }) { 2574 const { paginationInfo } = (0, import_element9.useContext)(dataviews_context_default); 2575 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item); 2576 const isSelected2 = hasPossibleBulkAction && selection.includes(id); 2577 const { 2578 showTitle = true, 2579 showMedia = true, 2580 showDescription = true, 2581 infiniteScrollEnabled 2582 } = view; 2583 const isTouchDeviceRef = (0, import_element9.useRef)(false); 2584 const columns = view.fields ?? []; 2585 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 2586 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)( 2587 "tr", 2588 { 2589 className: clsx_default("dataviews-view-table__row", { 2590 "is-selected": hasPossibleBulkAction && isSelected2, 2591 "has-bulk-actions": hasPossibleBulkAction 2592 }), 2593 onTouchStart: () => { 2594 isTouchDeviceRef.current = true; 2595 }, 2596 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 2597 "aria-posinset": posinset, 2598 role: infiniteScrollEnabled ? "article" : void 0, 2599 onMouseDown: (event) => { 2600 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey; 2601 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) { 2602 event?.preventDefault(); 2603 } 2604 }, 2605 onClick: (event) => { 2606 if (!hasPossibleBulkAction) { 2607 return; 2608 } 2609 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey; 2610 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") { 2611 onChangeSelection( 2612 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 2613 ); 2614 } 2615 }, 2616 children: [ 2617 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2618 DataViewsSelectionCheckbox, 2619 { 2620 item, 2621 selection, 2622 onChangeSelection, 2623 getItemId: getItemId2, 2624 titleField, 2625 disabled: !hasPossibleBulkAction 2626 } 2627 ) }) }), 2628 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2629 column_primary_default, 2630 { 2631 item, 2632 level, 2633 titleField: showTitle ? titleField : void 0, 2634 mediaField: showMedia ? mediaField : void 0, 2635 descriptionField: showDescription ? descriptionField2 : void 0, 2636 isItemClickable, 2637 onClickItem, 2638 renderItemLink 2639 } 2640 ) }), 2641 columns.map((column) => { 2642 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 2643 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2644 "td", 2645 { 2646 style: { 2647 width, 2648 maxWidth, 2649 minWidth 2650 }, 2651 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2652 TableColumnField, 2653 { 2654 fields, 2655 item, 2656 column, 2657 align 2658 } 2659 ) 2660 }, 2661 column 2662 ); 2663 }), 2664 !!actions?.length && // Disable reason: we are not making the element interactive, 2665 // but preventing any click events from bubbling up to the 2666 // table row. This allows us to add a click handler to the row 2667 // itself (to toggle row selection) without erroneously 2668 // intercepting click events from ItemActions. 2669 /* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */ 2670 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2671 "td", 2672 { 2673 className: clsx_default("dataviews-view-table__actions-column", { 2674 "dataviews-view-table__actions-column--sticky": true, 2675 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky 2676 }), 2677 onClick: (e2) => e2.stopPropagation(), 2678 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ItemActions, { item, actions }) 2679 } 2680 ) 2681 ] 2682 } 2683 ); 2684 } 2685 function ViewTable({ 2686 actions, 2687 data, 2688 fields, 2689 getItemId: getItemId2, 2690 getItemLevel, 2691 isLoading = false, 2692 onChangeView, 2693 onChangeSelection, 2694 selection, 2695 setOpenedFilter, 2696 onClickItem, 2697 isItemClickable, 2698 renderItemLink, 2699 view, 2700 className, 2701 empty 2702 }) { 2703 const { containerRef } = (0, import_element9.useContext)(dataviews_context_default); 2704 const headerMenuRefs = (0, import_element9.useRef)(/* @__PURE__ */ new Map()); 2705 const headerMenuToFocusRef = (0, import_element9.useRef)(); 2706 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element9.useState)(); 2707 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 2708 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element9.useState)(null); 2709 (0, import_element9.useEffect)(() => { 2710 if (headerMenuToFocusRef.current) { 2711 headerMenuToFocusRef.current.focus(); 2712 headerMenuToFocusRef.current = void 0; 2713 } 2714 }); 2715 const tableNoticeId = (0, import_element9.useId)(); 2716 const isHorizontalScrollEnd = useIsHorizontalScrollEnd({ 2717 scrollContainerRef: containerRef, 2718 enabled: !!actions?.length 2719 }); 2720 if (nextHeaderMenuToFocus) { 2721 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 2722 setNextHeaderMenuToFocus(void 0); 2723 return; 2724 } 2725 const onHide = (field) => { 2726 const hidden = headerMenuRefs.current.get(field.id); 2727 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 2728 setNextHeaderMenuToFocus(fallback?.node); 2729 }; 2730 const handleHeaderContextMenu = (event) => { 2731 event.preventDefault(); 2732 event.stopPropagation(); 2733 const virtualAnchor = { 2734 getBoundingClientRect: () => ({ 2735 x: event.clientX, 2736 y: event.clientY, 2737 top: event.clientY, 2738 left: event.clientX, 2739 right: event.clientX, 2740 bottom: event.clientY, 2741 width: 0, 2742 height: 0, 2743 toJSON: () => ({}) 2744 }) 2745 }; 2746 window.requestAnimationFrame(() => { 2747 setContextMenuAnchor(virtualAnchor); 2748 }); 2749 }; 2750 const hasData = !!data?.length; 2751 const titleField = fields.find((field) => field.id === view.titleField); 2752 const mediaField = fields.find((field) => field.id === view.mediaField); 2753 const descriptionField2 = fields.find( 2754 (field) => field.id === view.descriptionField 2755 ); 2756 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 2757 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 2758 const { showTitle = true, showMedia = true, showDescription = true } = view; 2759 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 2760 const columns = view.fields ?? []; 2761 const headerMenuRef = (column, index) => (node) => { 2762 if (node) { 2763 headerMenuRefs.current.set(column, { 2764 node, 2765 fallback: columns[index > 0 ? index - 1 : 1] 2766 }); 2767 } else { 2768 headerMenuRefs.current.delete(column); 2769 } 2770 }; 2771 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 2772 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [ 2773 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)( 2774 "table", 2775 { 2776 className: clsx_default("dataviews-view-table", className, { 2777 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 2778 view.layout.density 2779 ), 2780 "has-bulk-actions": hasBulkActions 2781 }), 2782 "aria-busy": isLoading, 2783 "aria-describedby": tableNoticeId, 2784 role: isInfiniteScroll ? "feed" : void 0, 2785 children: [ 2786 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("colgroup", { children: [ 2787 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-checkbox" }), 2788 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-first-data" }), 2789 columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2790 "col", 2791 { 2792 className: clsx_default( 2793 `dataviews-view-table__col-$column}`, 2794 { 2795 "dataviews-view-table__col-first-data": !hasPrimaryColumn && index === 0 2796 } 2797 ) 2798 }, 2799 `col-$column}` 2800 )), 2801 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-actions" }) 2802 ] }), 2803 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2804 import_components7.Popover, 2805 { 2806 anchor: contextMenuAnchor, 2807 onClose: () => setContextMenuAnchor(null), 2808 placement: "bottom-start", 2809 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PropertiesSection, { showLabel: false }) 2810 } 2811 ), 2812 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("thead", { onContextMenu: handleHeaderContextMenu, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tr", { className: "dataviews-view-table__row", children: [ 2813 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2814 "th", 2815 { 2816 className: "dataviews-view-table__checkbox-column", 2817 scope: "col", 2818 onContextMenu: handleHeaderContextMenu, 2819 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2820 BulkSelectionCheckbox, 2821 { 2822 selection, 2823 onChangeSelection, 2824 data, 2825 actions, 2826 getItemId: getItemId2 2827 } 2828 ) 2829 } 2830 ), 2831 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2832 column_header_menu_default, 2833 { 2834 ref: headerMenuRef( 2835 titleField.id, 2836 0 2837 ), 2838 fieldId: titleField.id, 2839 view, 2840 fields, 2841 onChangeView, 2842 onHide, 2843 setOpenedFilter, 2844 canMove: false, 2845 canInsertLeft: false, 2846 canInsertRight: view.layout?.enableMoving ?? true 2847 } 2848 ) }), 2849 columns.map((column, index) => { 2850 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 2851 const canInsertOrMove = view.layout?.enableMoving ?? true; 2852 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2853 "th", 2854 { 2855 style: { 2856 width, 2857 maxWidth, 2858 minWidth, 2859 textAlign: align 2860 }, 2861 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 2862 scope: "col", 2863 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2864 column_header_menu_default, 2865 { 2866 ref: headerMenuRef(column, index), 2867 fieldId: column, 2868 view, 2869 fields, 2870 onChangeView, 2871 onHide, 2872 setOpenedFilter, 2873 canMove: canInsertOrMove, 2874 canInsertLeft: canInsertOrMove, 2875 canInsertRight: canInsertOrMove 2876 } 2877 ) 2878 }, 2879 column 2880 ); 2881 }), 2882 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2883 "th", 2884 { 2885 className: clsx_default( 2886 "dataviews-view-table__actions-column", 2887 { 2888 "dataviews-view-table__actions-column--sticky": true, 2889 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd 2890 } 2891 ), 2892 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n8.__)("Actions") }) 2893 } 2894 ) 2895 ] }) }), 2896 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 2897 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tbody", { children: [ 2898 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2899 "td", 2900 { 2901 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0), 2902 className: "dataviews-view-table__group-header-cell", 2903 children: (0, import_i18n8.sprintf)( 2904 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 2905 (0, import_i18n8.__)("%1$s: %2$s"), 2906 groupField.label, 2907 groupName 2908 ) 2909 } 2910 ) }), 2911 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2912 TableRow, 2913 { 2914 item, 2915 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0, 2916 hasBulkActions, 2917 actions, 2918 fields, 2919 id: getItemId2(item) || index.toString(), 2920 view, 2921 titleField, 2922 mediaField, 2923 descriptionField: descriptionField2, 2924 selection, 2925 getItemId: getItemId2, 2926 onChangeSelection, 2927 onClickItem, 2928 renderItemLink, 2929 isItemClickable, 2930 isActionsColumnSticky: !isHorizontalScrollEnd 2931 }, 2932 getItemId2(item) 2933 )) 2934 ] }, `group-$groupName}`) 2935 ) : /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)( 2936 TableRow, 2937 { 2938 item, 2939 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0, 2940 hasBulkActions, 2941 actions, 2942 fields, 2943 id: getItemId2(item) || index.toString(), 2944 view, 2945 titleField, 2946 mediaField, 2947 descriptionField: descriptionField2, 2948 selection, 2949 getItemId: getItemId2, 2950 onChangeSelection, 2951 onClickItem, 2952 renderItemLink, 2953 isItemClickable, 2954 isActionsColumnSticky: !isHorizontalScrollEnd, 2955 posinset: isInfiniteScroll ? index + 1 : void 0 2956 }, 2957 getItemId2(item) 2958 )) }) 2959 ] 2960 } 2961 ), 2962 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)( 2963 "div", 2964 { 2965 className: clsx_default({ 2966 "dataviews-loading": isLoading, 2967 "dataviews-no-results": !hasData && !isLoading 2968 }), 2969 id: tableNoticeId, 2970 children: [ 2971 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components7.Spinner, {}) }) : empty), 2972 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components7.Spinner, {}) }) 2973 ] 2974 } 2975 ) 2976 ] }); 2977 } 2978 var table_default = ViewTable; 2979 2980 // packages/dataviews/build-module/dataviews-layouts/grid/index.js 2981 var import_components10 = __toESM(require_components()); 2982 var import_i18n11 = __toESM(require_i18n()); 2983 2984 // packages/dataviews/build-module/dataviews-layouts/grid/composite-grid.js 2985 var import_components9 = __toESM(require_components()); 2986 var import_i18n10 = __toESM(require_i18n()); 2987 var import_compose4 = __toESM(require_compose()); 2988 var import_keycodes2 = __toESM(require_keycodes()); 2989 var import_element11 = __toESM(require_element()); 2990 2991 // packages/dataviews/build-module/dataviews-layouts/grid/preview-size-picker.js 2992 var import_components8 = __toESM(require_components()); 2993 var import_i18n9 = __toESM(require_i18n()); 2994 var import_element10 = __toESM(require_element()); 2995 var import_jsx_runtime48 = __toESM(require_jsx_runtime()); 2996 var imageSizes = [ 2997 { 2998 value: 120, 2999 breakpoint: 1 3000 }, 3001 { 3002 value: 170, 3003 breakpoint: 1 3004 }, 3005 { 3006 value: 230, 3007 breakpoint: 1 3008 }, 3009 { 3010 value: 290, 3011 breakpoint: 1112 3012 // at minimum image width, 4 images display at this container size 3013 }, 3014 { 3015 value: 350, 3016 breakpoint: 1636 3017 // at minimum image width, 6 images display at this container size 3018 }, 3019 { 3020 value: 430, 3021 breakpoint: 588 3022 // at minimum image width, 2 images display at this container size 3023 } 3024 ]; 3025 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value; 3026 function useGridColumns() { 3027 const context = (0, import_element10.useContext)(dataviews_context_default); 3028 const view = context.view; 3029 return (0, import_element10.useMemo)(() => { 3030 const containerWidth = context.containerWidth; 3031 const gap = 32; 3032 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE; 3033 const columns = Math.floor( 3034 (containerWidth + gap) / (previewSize + gap) 3035 ); 3036 return Math.max(1, columns); 3037 }, [context.containerWidth, view.layout?.previewSize]); 3038 } 3039 3040 // packages/dataviews/build-module/dataviews-layouts/grid/composite-grid.js 3041 var import_jsx_runtime49 = __toESM(require_jsx_runtime()); 3042 var { Badge } = unlock(import_components9.privateApis); 3043 function chunk(array, size) { 3044 const chunks = []; 3045 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) { 3046 chunks.push(array.slice(i2, i2 + size)); 3047 } 3048 return chunks; 3049 } 3050 var GridItem = (0, import_element11.forwardRef)(function GridItem2({ 3051 view, 3052 selection, 3053 onChangeSelection, 3054 onClickItem, 3055 isItemClickable, 3056 renderItemLink, 3057 getItemId: getItemId2, 3058 item, 3059 actions, 3060 mediaField, 3061 titleField, 3062 descriptionField: descriptionField2, 3063 regularFields, 3064 badgeFields, 3065 hasBulkActions, 3066 config, 3067 ...props 3068 }, ref) { 3069 const { showTitle = true, showMedia = true, showDescription = true } = view; 3070 const hasBulkAction = useHasAPossibleBulkAction(actions, item); 3071 const id = getItemId2(item); 3072 const instanceId = (0, import_compose4.useInstanceId)(GridItem2); 3073 const isSelected2 = selection.includes(id); 3074 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3075 mediaField.render, 3076 { 3077 item, 3078 field: mediaField, 3079 config 3080 } 3081 ) : null; 3082 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(titleField.render, { item, field: titleField }) : null; 3083 const shouldRenderMedia = showMedia && renderedMediaField; 3084 let mediaA11yProps; 3085 let titleA11yProps; 3086 if (isItemClickable(item) && onClickItem) { 3087 if (renderedTitleField) { 3088 mediaA11yProps = { 3089 "aria-labelledby": `dataviews-view-grid__title-field-$instanceId}` 3090 }; 3091 titleA11yProps = { 3092 id: `dataviews-view-grid__title-field-$instanceId}` 3093 }; 3094 } else { 3095 mediaA11yProps = { 3096 "aria-label": (0, import_i18n10.__)("Navigate to item") 3097 }; 3098 } 3099 } 3100 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)( 3101 import_components9.__experimentalVStack, 3102 { 3103 ...props, 3104 ref, 3105 spacing: 0, 3106 className: clsx_default( 3107 props.className, 3108 "dataviews-view-grid__row__gridcell", 3109 "dataviews-view-grid__card", 3110 { 3111 "is-selected": hasBulkAction && isSelected2 3112 } 3113 ), 3114 onClickCapture: (event) => { 3115 props.onClickCapture?.(event); 3116 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) { 3117 event.stopPropagation(); 3118 event.preventDefault(); 3119 if (!hasBulkAction) { 3120 return; 3121 } 3122 onChangeSelection( 3123 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id] 3124 ); 3125 } 3126 }, 3127 children: [ 3128 shouldRenderMedia && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3129 ItemClickWrapper, 3130 { 3131 item, 3132 isItemClickable, 3133 onClickItem, 3134 renderItemLink, 3135 className: "dataviews-view-grid__media", 3136 ...mediaA11yProps, 3137 children: renderedMediaField 3138 } 3139 ), 3140 hasBulkActions && shouldRenderMedia && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3141 DataViewsSelectionCheckbox, 3142 { 3143 item, 3144 selection, 3145 onChangeSelection, 3146 getItemId: getItemId2, 3147 titleField, 3148 disabled: !hasBulkAction 3149 } 3150 ), 3151 !showTitle && shouldRenderMedia && !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(ItemActions, { item, actions, isCompact: true }) }), 3152 showTitle && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)( 3153 import_components9.__experimentalHStack, 3154 { 3155 justify: "space-between", 3156 className: "dataviews-view-grid__title-actions", 3157 children: [ 3158 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3159 ItemClickWrapper, 3160 { 3161 item, 3162 isItemClickable, 3163 onClickItem, 3164 renderItemLink, 3165 className: "dataviews-view-grid__title-field dataviews-title-field", 3166 ...titleA11yProps, 3167 children: renderedTitleField 3168 } 3169 ), 3170 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3171 ItemActions, 3172 { 3173 item, 3174 actions, 3175 isCompact: true 3176 } 3177 ) 3178 ] 3179 } 3180 ), 3181 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_components9.__experimentalVStack, { spacing: 1, children: [ 3182 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3183 descriptionField2.render, 3184 { 3185 item, 3186 field: descriptionField2 3187 } 3188 ), 3189 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3190 import_components9.__experimentalHStack, 3191 { 3192 className: "dataviews-view-grid__badge-fields", 3193 spacing: 2, 3194 wrap: true, 3195 alignment: "top", 3196 justify: "flex-start", 3197 children: badgeFields.map((field) => { 3198 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3199 Badge, 3200 { 3201 className: "dataviews-view-grid__field-value", 3202 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3203 field.render, 3204 { 3205 item, 3206 field 3207 } 3208 ) 3209 }, 3210 field.id 3211 ); 3212 }) 3213 } 3214 ), 3215 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3216 import_components9.__experimentalVStack, 3217 { 3218 className: "dataviews-view-grid__fields", 3219 spacing: 1, 3220 children: regularFields.map((field) => { 3221 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3222 import_components9.Flex, 3223 { 3224 className: "dataviews-view-grid__field", 3225 gap: 1, 3226 justify: "flex-start", 3227 expanded: true, 3228 style: { height: "auto" }, 3229 direction: "row", 3230 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [ 3231 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components9.Tooltip, { text: field.label, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components9.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) }), 3232 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3233 import_components9.FlexItem, 3234 { 3235 className: "dataviews-view-grid__field-value", 3236 style: { maxHeight: "none" }, 3237 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3238 field.render, 3239 { 3240 item, 3241 field 3242 } 3243 ) 3244 } 3245 ) 3246 ] }) 3247 }, 3248 field.id 3249 ); 3250 }) 3251 } 3252 ) 3253 ] }) 3254 ] 3255 } 3256 ); 3257 }); 3258 function CompositeGrid({ 3259 data, 3260 isInfiniteScroll, 3261 className, 3262 isLoading, 3263 view, 3264 fields, 3265 selection, 3266 onChangeSelection, 3267 onClickItem, 3268 isItemClickable, 3269 renderItemLink, 3270 getItemId: getItemId2, 3271 actions 3272 }) { 3273 const { paginationInfo, resizeObserverRef } = (0, import_element11.useContext)(dataviews_context_default); 3274 const gridColumns = useGridColumns(); 3275 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 3276 const titleField = fields.find( 3277 (field) => field.id === view?.titleField 3278 ); 3279 const mediaField = fields.find( 3280 (field) => field.id === view?.mediaField 3281 ); 3282 const descriptionField2 = fields.find( 3283 (field) => field.id === view?.descriptionField 3284 ); 3285 const otherFields = view.fields ?? []; 3286 const { regularFields, badgeFields } = otherFields.reduce( 3287 (accumulator, fieldId) => { 3288 const field = fields.find((f2) => f2.id === fieldId); 3289 if (!field) { 3290 return accumulator; 3291 } 3292 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 3293 accumulator[key].push(field); 3294 return accumulator; 3295 }, 3296 { regularFields: [], badgeFields: [] } 3297 ); 3298 const size = "900px"; 3299 const totalRows = Math.ceil(data.length / gridColumns); 3300 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3301 import_components9.Composite, 3302 { 3303 role: isInfiniteScroll ? "feed" : "grid", 3304 className: clsx_default("dataviews-view-grid", className), 3305 focusWrap: true, 3306 "aria-busy": isLoading, 3307 "aria-rowcount": isInfiniteScroll ? void 0 : totalRows, 3308 ref: resizeObserverRef, 3309 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3310 import_components9.Composite.Row, 3311 { 3312 render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3313 "div", 3314 { 3315 role: "row", 3316 "aria-rowindex": i2 + 1, 3317 "aria-label": (0, import_i18n10.sprintf)( 3318 /* translators: %d: The row number in the grid */ 3319 (0, import_i18n10.__)("Row %d"), 3320 i2 + 1 3321 ), 3322 className: "dataviews-view-grid__row", 3323 style: { 3324 gridTemplateColumns: `repeat( $gridColumns}, minmax(0, 1fr) )` 3325 } 3326 } 3327 ), 3328 children: row.map((item, indexInRow) => { 3329 const index = i2 * gridColumns + indexInRow; 3330 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3331 import_components9.Composite.Item, 3332 { 3333 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)( 3334 GridItem, 3335 { 3336 ...props, 3337 role: isInfiniteScroll ? "article" : "gridcell", 3338 "aria-setsize": isInfiniteScroll ? paginationInfo.totalItems : void 0, 3339 "aria-posinset": isInfiniteScroll ? index + 1 : void 0, 3340 view, 3341 selection, 3342 onChangeSelection, 3343 onClickItem, 3344 isItemClickable, 3345 renderItemLink, 3346 getItemId: getItemId2, 3347 item, 3348 actions, 3349 mediaField, 3350 titleField, 3351 descriptionField: descriptionField2, 3352 regularFields, 3353 badgeFields, 3354 hasBulkActions, 3355 config: { 3356 sizes: size 3357 } 3358 } 3359 ) 3360 }, 3361 getItemId2(item) 3362 ); 3363 }) 3364 }, 3365 i2 3366 )) 3367 } 3368 ); 3369 } 3370 3371 // packages/dataviews/build-module/dataviews-layouts/grid/index.js 3372 var import_jsx_runtime50 = __toESM(require_jsx_runtime()); 3373 function ViewGrid({ 3374 actions, 3375 data, 3376 fields, 3377 getItemId: getItemId2, 3378 isLoading, 3379 onChangeSelection, 3380 onClickItem, 3381 isItemClickable, 3382 renderItemLink, 3383 selection, 3384 view, 3385 className, 3386 empty 3387 }) { 3388 const hasData = !!data?.length; 3389 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 3390 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 3391 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 3392 const gridProps = { 3393 className, 3394 isLoading, 3395 view, 3396 fields, 3397 selection, 3398 onChangeSelection, 3399 onClickItem, 3400 isItemClickable, 3401 renderItemLink, 3402 getItemId: getItemId2, 3403 actions 3404 }; 3405 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { 3406 // Render multiple groups. 3407 children: [ 3408 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components10.__experimentalVStack, { spacing: 4, children: Array.from(dataByGroup.entries()).map( 3409 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_components10.__experimentalVStack, { spacing: 2, children: [ 3410 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("h3", { className: "dataviews-view-grid__group-header", children: (0, import_i18n11.sprintf)( 3411 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 3412 (0, import_i18n11.__)("%1$s: %2$s"), 3413 groupField.label, 3414 groupName 3415 ) }), 3416 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 3417 CompositeGrid, 3418 { 3419 ...gridProps, 3420 data: groupItems, 3421 isInfiniteScroll: false 3422 } 3423 ) 3424 ] }, groupName) 3425 ) }), 3426 // Render a single grid with all data. 3427 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 3428 CompositeGrid, 3429 { 3430 ...gridProps, 3431 data, 3432 isInfiniteScroll: !!isInfiniteScroll 3433 } 3434 ), 3435 // Render empty state. 3436 !hasData && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)( 3437 "div", 3438 { 3439 className: clsx_default({ 3440 "dataviews-loading": isLoading, 3441 "dataviews-no-results": !isLoading 3442 }), 3443 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components10.Spinner, {}) }) : empty 3444 } 3445 ), 3446 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components10.Spinner, {}) }) 3447 ] 3448 }); 3449 } 3450 var grid_default = ViewGrid; 3451 3452 // packages/dataviews/build-module/dataviews-layouts/list/index.js 3453 var import_compose5 = __toESM(require_compose()); 3454 var import_components11 = __toESM(require_components()); 3455 var import_element12 = __toESM(require_element()); 3456 var import_i18n12 = __toESM(require_i18n()); 3457 var import_data5 = __toESM(require_data()); 3458 var import_jsx_runtime51 = __toESM(require_jsx_runtime()); 3459 var { Menu: Menu3 } = unlock(import_components11.privateApis); 3460 function generateItemWrapperCompositeId(idPrefix) { 3461 return `$idPrefix}-item-wrapper`; 3462 } 3463 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) { 3464 return `$idPrefix}-primary-action-$primaryActionId}`; 3465 } 3466 function generateDropdownTriggerCompositeId(idPrefix) { 3467 return `$idPrefix}-dropdown`; 3468 } 3469 function PrimaryActionGridCell({ 3470 idPrefix, 3471 primaryAction, 3472 item 3473 }) { 3474 const registry = (0, import_data5.useRegistry)(); 3475 const [isModalOpen, setIsModalOpen] = (0, import_element12.useState)(false); 3476 const compositeItemId = generatePrimaryActionCompositeId( 3477 idPrefix, 3478 primaryAction.id 3479 ); 3480 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]); 3481 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3482 import_components11.Composite.Item, 3483 { 3484 id: compositeItemId, 3485 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3486 import_components11.Button, 3487 { 3488 disabled: !!primaryAction.disabled, 3489 accessibleWhenDisabled: true, 3490 text: label, 3491 size: "small", 3492 onClick: () => setIsModalOpen(true) 3493 } 3494 ), 3495 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3496 ActionModal, 3497 { 3498 action: primaryAction, 3499 items: [item], 3500 closeModal: () => setIsModalOpen(false) 3501 } 3502 ) 3503 } 3504 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3505 import_components11.Composite.Item, 3506 { 3507 id: compositeItemId, 3508 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3509 import_components11.Button, 3510 { 3511 disabled: !!primaryAction.disabled, 3512 accessibleWhenDisabled: true, 3513 size: "small", 3514 onClick: () => { 3515 primaryAction.callback([item], { registry }); 3516 }, 3517 children: label 3518 } 3519 ) 3520 } 3521 ) }, primaryAction.id); 3522 } 3523 function ListItem({ 3524 view, 3525 actions, 3526 idPrefix, 3527 isSelected: isSelected2, 3528 item, 3529 titleField, 3530 mediaField, 3531 descriptionField: descriptionField2, 3532 onSelect, 3533 otherFields, 3534 onDropdownTriggerKeyDown, 3535 posinset 3536 }) { 3537 const { 3538 showTitle = true, 3539 showMedia = true, 3540 showDescription = true, 3541 infiniteScrollEnabled 3542 } = view; 3543 const itemRef = (0, import_element12.useRef)(null); 3544 const labelId = `$idPrefix}-label`; 3545 const descriptionId = `$idPrefix}-description`; 3546 const registry = (0, import_data5.useRegistry)(); 3547 const [isHovered, setIsHovered] = (0, import_element12.useState)(false); 3548 const [activeModalAction, setActiveModalAction] = (0, import_element12.useState)( 3549 null 3550 ); 3551 const handleHover = ({ type }) => { 3552 const isHover = type === "mouseenter"; 3553 setIsHovered(isHover); 3554 }; 3555 const { paginationInfo } = (0, import_element12.useContext)(dataviews_context_default); 3556 (0, import_element12.useEffect)(() => { 3557 if (isSelected2) { 3558 itemRef.current?.scrollIntoView({ 3559 behavior: "auto", 3560 block: "nearest", 3561 inline: "nearest" 3562 }); 3563 } 3564 }, [isSelected2]); 3565 const { primaryAction, eligibleActions } = (0, import_element12.useMemo)(() => { 3566 const _eligibleActions = actions.filter( 3567 (action) => !action.isEligible || action.isEligible(item) 3568 ); 3569 const _primaryActions = _eligibleActions.filter( 3570 (action) => action.isPrimary 3571 ); 3572 return { 3573 primaryAction: _primaryActions[0], 3574 eligibleActions: _eligibleActions 3575 }; 3576 }, [actions, item]); 3577 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1; 3578 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3579 mediaField.render, 3580 { 3581 item, 3582 field: mediaField, 3583 config: { sizes: "52px" } 3584 } 3585 ) }) : null; 3586 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(titleField.render, { item, field: titleField }) : null; 3587 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_components11.__experimentalHStack, { spacing: 3, className: "dataviews-view-list__item-actions", children: [ 3588 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3589 PrimaryActionGridCell, 3590 { 3591 idPrefix, 3592 primaryAction, 3593 item 3594 } 3595 ), 3596 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { role: "gridcell", children: [ 3597 /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu3, { placement: "bottom-end", children: [ 3598 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3599 Menu3.TriggerButton, 3600 { 3601 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3602 import_components11.Composite.Item, 3603 { 3604 id: generateDropdownTriggerCompositeId( 3605 idPrefix 3606 ), 3607 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3608 import_components11.Button, 3609 { 3610 size: "small", 3611 icon: more_vertical_default, 3612 label: (0, import_i18n12.__)("Actions"), 3613 accessibleWhenDisabled: true, 3614 disabled: !actions.length, 3615 onKeyDown: onDropdownTriggerKeyDown 3616 } 3617 ) 3618 } 3619 ) 3620 } 3621 ), 3622 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3623 ActionsMenuGroup, 3624 { 3625 actions: eligibleActions, 3626 item, 3627 registry, 3628 setActiveModalAction 3629 } 3630 ) }) 3631 ] }), 3632 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3633 ActionModal, 3634 { 3635 action: activeModalAction, 3636 items: [item], 3637 closeModal: () => setActiveModalAction(null) 3638 } 3639 ) 3640 ] }) 3641 ] }); 3642 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3643 import_components11.Composite.Row, 3644 { 3645 ref: itemRef, 3646 render: ( 3647 /* aria-posinset breaks Composite.Row if passed to it directly. */ 3648 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3649 "div", 3650 { 3651 "aria-posinset": posinset, 3652 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0 3653 } 3654 ) 3655 ), 3656 role: infiniteScrollEnabled ? "article" : "row", 3657 className: clsx_default({ 3658 "is-selected": isSelected2, 3659 "is-hovered": isHovered 3660 }), 3661 onMouseEnter: handleHover, 3662 onMouseLeave: handleHover, 3663 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_components11.__experimentalHStack, { className: "dataviews-view-list__item-wrapper", spacing: 0, children: [ 3664 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3665 import_components11.Composite.Item, 3666 { 3667 id: generateItemWrapperCompositeId(idPrefix), 3668 "aria-pressed": isSelected2, 3669 "aria-labelledby": labelId, 3670 "aria-describedby": descriptionId, 3671 className: "dataviews-view-list__item", 3672 onClick: () => onSelect(item) 3673 } 3674 ) }), 3675 /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_components11.__experimentalHStack, { spacing: 3, justify: "start", alignment: "flex-start", children: [ 3676 renderedMediaField, 3677 /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)( 3678 import_components11.__experimentalVStack, 3679 { 3680 spacing: 1, 3681 className: "dataviews-view-list__field-wrapper", 3682 children: [ 3683 /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_components11.__experimentalHStack, { spacing: 0, children: [ 3684 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3685 "div", 3686 { 3687 className: "dataviews-title-field", 3688 id: labelId, 3689 children: renderedTitleField 3690 } 3691 ), 3692 usedActions 3693 ] }), 3694 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3695 descriptionField2.render, 3696 { 3697 item, 3698 field: descriptionField2 3699 } 3700 ) }), 3701 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3702 "div", 3703 { 3704 className: "dataviews-view-list__fields", 3705 id: descriptionId, 3706 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)( 3707 "div", 3708 { 3709 className: "dataviews-view-list__field", 3710 children: [ 3711 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3712 import_components11.VisuallyHidden, 3713 { 3714 as: "span", 3715 className: "dataviews-view-list__field-label", 3716 children: field.label 3717 } 3718 ), 3719 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3720 field.render, 3721 { 3722 item, 3723 field 3724 } 3725 ) }) 3726 ] 3727 }, 3728 field.id 3729 )) 3730 } 3731 ) 3732 ] 3733 } 3734 ) 3735 ] }) 3736 ] }) 3737 } 3738 ); 3739 } 3740 function isDefined2(item) { 3741 return !!item; 3742 } 3743 function ViewList(props) { 3744 const { 3745 actions, 3746 data, 3747 fields, 3748 getItemId: getItemId2, 3749 isLoading, 3750 onChangeSelection, 3751 selection, 3752 view, 3753 className, 3754 empty 3755 } = props; 3756 const baseId = (0, import_compose5.useInstanceId)(ViewList, "view-list"); 3757 const selectedItem = data?.findLast( 3758 (item) => selection.includes(getItemId2(item)) 3759 ); 3760 const titleField = fields.find((field) => field.id === view.titleField); 3761 const mediaField = fields.find((field) => field.id === view.mediaField); 3762 const descriptionField2 = fields.find( 3763 (field) => field.id === view.descriptionField 3764 ); 3765 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2); 3766 const onSelect = (item) => onChangeSelection([getItemId2(item)]); 3767 const generateCompositeItemIdPrefix = (0, import_element12.useCallback)( 3768 (item) => `$baseId}-$getItemId2(item)}`, 3769 [baseId, getItemId2] 3770 ); 3771 const isActiveCompositeItem = (0, import_element12.useCallback)( 3772 (item, idToCheck) => { 3773 return idToCheck.startsWith( 3774 generateCompositeItemIdPrefix(item) 3775 ); 3776 }, 3777 [generateCompositeItemIdPrefix] 3778 ); 3779 const [activeCompositeId, setActiveCompositeId] = (0, import_element12.useState)(void 0); 3780 (0, import_element12.useEffect)(() => { 3781 if (selectedItem) { 3782 setActiveCompositeId( 3783 generateItemWrapperCompositeId( 3784 generateCompositeItemIdPrefix(selectedItem) 3785 ) 3786 ); 3787 } 3788 }, [selectedItem, generateCompositeItemIdPrefix]); 3789 const activeItemIndex = data.findIndex( 3790 (item) => isActiveCompositeItem(item, activeCompositeId ?? "") 3791 ); 3792 const previousActiveItemIndex = (0, import_compose5.usePrevious)(activeItemIndex); 3793 const isActiveIdInList = activeItemIndex !== -1; 3794 const selectCompositeItem = (0, import_element12.useCallback)( 3795 (targetIndex, generateCompositeId) => { 3796 const clampedIndex = Math.min( 3797 data.length - 1, 3798 Math.max(0, targetIndex) 3799 ); 3800 if (!data[clampedIndex]) { 3801 return; 3802 } 3803 const itemIdPrefix = generateCompositeItemIdPrefix( 3804 data[clampedIndex] 3805 ); 3806 const targetCompositeItemId = generateCompositeId(itemIdPrefix); 3807 setActiveCompositeId(targetCompositeItemId); 3808 document.getElementById(targetCompositeItemId)?.focus(); 3809 }, 3810 [data, generateCompositeItemIdPrefix] 3811 ); 3812 (0, import_element12.useEffect)(() => { 3813 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1; 3814 if (!isActiveIdInList && wasActiveIdInList) { 3815 selectCompositeItem( 3816 previousActiveItemIndex, 3817 generateItemWrapperCompositeId 3818 ); 3819 } 3820 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]); 3821 const onDropdownTriggerKeyDown = (0, import_element12.useCallback)( 3822 (event) => { 3823 if (event.key === "ArrowDown") { 3824 event.preventDefault(); 3825 selectCompositeItem( 3826 activeItemIndex + 1, 3827 generateDropdownTriggerCompositeId 3828 ); 3829 } 3830 if (event.key === "ArrowUp") { 3831 event.preventDefault(); 3832 selectCompositeItem( 3833 activeItemIndex - 1, 3834 generateDropdownTriggerCompositeId 3835 ); 3836 } 3837 }, 3838 [selectCompositeItem, activeItemIndex] 3839 ); 3840 const hasData = data?.length; 3841 if (!hasData) { 3842 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3843 "div", 3844 { 3845 className: clsx_default({ 3846 "dataviews-loading": isLoading, 3847 "dataviews-no-results": !hasData && !isLoading 3848 }), 3849 children: !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components11.Spinner, {}) }) : empty) 3850 } 3851 ); 3852 } 3853 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null; 3854 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 3855 if (hasData && groupField && dataByGroup) { 3856 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3857 import_components11.Composite, 3858 { 3859 id: `$baseId}`, 3860 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", {}), 3861 className: "dataviews-view-list__group", 3862 role: "grid", 3863 activeId: activeCompositeId, 3864 setActiveId: setActiveCompositeId, 3865 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3866 import_components11.__experimentalVStack, 3867 { 3868 spacing: 4, 3869 className: clsx_default("dataviews-view-list", className), 3870 children: Array.from(dataByGroup.entries()).map( 3871 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_components11.__experimentalVStack, { spacing: 2, children: [ 3872 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("h3", { className: "dataviews-view-list__group-header", children: (0, import_i18n12.sprintf)( 3873 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 3874 (0, import_i18n12.__)("%1$s: %2$s"), 3875 groupField.label, 3876 groupName 3877 ) }), 3878 groupItems.map((item) => { 3879 const id = generateCompositeItemIdPrefix(item); 3880 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3881 ListItem, 3882 { 3883 view, 3884 idPrefix: id, 3885 actions, 3886 item, 3887 isSelected: item === selectedItem, 3888 onSelect, 3889 mediaField, 3890 titleField, 3891 descriptionField: descriptionField2, 3892 otherFields, 3893 onDropdownTriggerKeyDown 3894 }, 3895 id 3896 ); 3897 }) 3898 ] }, groupName) 3899 ) 3900 } 3901 ) 3902 } 3903 ); 3904 } 3905 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, { children: [ 3906 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3907 import_components11.Composite, 3908 { 3909 id: baseId, 3910 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", {}), 3911 className: clsx_default("dataviews-view-list", className), 3912 role: view.infiniteScrollEnabled ? "feed" : "grid", 3913 activeId: activeCompositeId, 3914 setActiveId: setActiveCompositeId, 3915 children: data.map((item, index) => { 3916 const id = generateCompositeItemIdPrefix(item); 3917 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)( 3918 ListItem, 3919 { 3920 view, 3921 idPrefix: id, 3922 actions, 3923 item, 3924 isSelected: item === selectedItem, 3925 onSelect, 3926 mediaField, 3927 titleField, 3928 descriptionField: descriptionField2, 3929 otherFields, 3930 onDropdownTriggerKeyDown, 3931 posinset: view.infiniteScrollEnabled ? index + 1 : void 0 3932 }, 3933 id 3934 ); 3935 }) 3936 } 3937 ), 3938 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components11.Spinner, {}) }) 3939 ] }); 3940 } 3941 3942 // packages/dataviews/build-module/dataviews-layouts/activity/index.js 3943 var import_components14 = __toESM(require_components()); 3944 3945 // packages/dataviews/build-module/dataviews-layouts/activity/activity-group.js 3946 var import_components12 = __toESM(require_components()); 3947 var import_i18n13 = __toESM(require_i18n()); 3948 var import_element13 = __toESM(require_element()); 3949 var import_jsx_runtime52 = __toESM(require_jsx_runtime()); 3950 function ActivityGroup({ 3951 groupName, 3952 groupData, 3953 groupField, 3954 children 3955 }) { 3956 const groupHeader = (0, import_element13.createInterpolateElement)( 3957 // translators: %s: The label of the field e.g. "Status". 3958 (0, import_i18n13.sprintf)((0, import_i18n13.__)("%s: <groupName />"), groupField.label).trim(), 3959 { 3960 groupName: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)( 3961 groupField.render, 3962 { 3963 item: groupData[0], 3964 field: groupField 3965 } 3966 ) 3967 } 3968 ); 3969 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)( 3970 import_components12.__experimentalVStack, 3971 { 3972 spacing: 0, 3973 className: "dataviews-view-activity__group", 3974 children: [ 3975 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }), 3976 children 3977 ] 3978 }, 3979 groupName 3980 ); 3981 } 3982 3983 // packages/dataviews/build-module/dataviews-layouts/activity/activity-item.js 3984 var import_components13 = __toESM(require_components()); 3985 var import_element14 = __toESM(require_element()); 3986 var import_data6 = __toESM(require_data()); 3987 var import_jsx_runtime53 = __toESM(require_jsx_runtime()); 3988 function ActivityItem(props) { 3989 const { 3990 view, 3991 actions, 3992 item, 3993 titleField, 3994 mediaField, 3995 descriptionField: descriptionField2, 3996 otherFields, 3997 posinset, 3998 onClickItem, 3999 renderItemLink, 4000 isItemClickable 4001 } = props; 4002 const { 4003 showTitle = true, 4004 showMedia = true, 4005 showDescription = true, 4006 infiniteScrollEnabled 4007 } = view; 4008 const itemRef = (0, import_element14.useRef)(null); 4009 const registry = (0, import_data6.useRegistry)(); 4010 const { paginationInfo } = (0, import_element14.useContext)(dataviews_context_default); 4011 const { primaryActions, eligibleActions } = (0, import_element14.useMemo)(() => { 4012 const _eligibleActions = actions.filter( 4013 (action) => !action.isEligible || action.isEligible(item) 4014 ); 4015 const _primaryActions = _eligibleActions.filter( 4016 (action) => action.isPrimary 4017 ); 4018 return { 4019 primaryActions: _primaryActions, 4020 eligibleActions: _eligibleActions 4021 }; 4022 }, [actions, item]); 4023 const density = view.layout?.density ?? "balanced"; 4024 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 4025 mediaField.render, 4026 { 4027 item, 4028 field: mediaField, 4029 config: { 4030 sizes: density === "comfortable" ? "32px" : "24px" 4031 } 4032 } 4033 ) : null; 4034 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 4035 "span", 4036 { 4037 className: "dataviews-view-activity__item-bullet", 4038 "aria-hidden": "true" 4039 } 4040 ) }); 4041 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(titleField.render, { item, field: titleField }) : null; 4042 const verticalSpacing = (0, import_element14.useMemo)(() => { 4043 switch (density) { 4044 case "comfortable": 4045 return "3"; 4046 default: 4047 return "2"; 4048 } 4049 }, [density]); 4050 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 4051 "div", 4052 { 4053 ref: itemRef, 4054 role: infiniteScrollEnabled ? "article" : void 0, 4055 "aria-posinset": posinset, 4056 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0, 4057 className: clsx_default( 4058 "dataviews-view-activity__item", 4059 density === "compact" && "is-compact", 4060 density === "balanced" && "is-balanced", 4061 density === "comfortable" && "is-comfortable" 4062 ), 4063 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_components13.__experimentalHStack, { spacing: 4, justify: "start", alignment: "flex-start", children: [ 4064 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 4065 import_components13.__experimentalVStack, 4066 { 4067 spacing: 1, 4068 alignment: "center", 4069 className: "dataviews-view-activity__item-type", 4070 children: renderedMediaField 4071 } 4072 ), 4073 /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)( 4074 import_components13.__experimentalVStack, 4075 { 4076 spacing: verticalSpacing, 4077 alignment: "flex-start", 4078 className: "dataviews-view-activity__item-content", 4079 children: [ 4080 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 4081 ItemClickWrapper, 4082 { 4083 item, 4084 isItemClickable, 4085 onClickItem, 4086 renderItemLink, 4087 className: "dataviews-view-activity__item-title", 4088 children: renderedTitleField 4089 } 4090 ), 4091 showDescription && descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 4092 descriptionField2.render, 4093 { 4094 item, 4095 field: descriptionField2 4096 } 4097 ) }), 4098 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)( 4099 "div", 4100 { 4101 className: "dataviews-view-activity__item-field", 4102 children: [ 4103 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 4104 import_components13.VisuallyHidden, 4105 { 4106 as: "span", 4107 className: "dataviews-view-activity__item-field-label", 4108 children: field.label 4109 } 4110 ), 4111 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 4112 field.render, 4113 { 4114 item, 4115 field 4116 } 4117 ) }) 4118 ] 4119 }, 4120 field.id 4121 )) }), 4122 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 4123 PrimaryActions, 4124 { 4125 item, 4126 actions: primaryActions, 4127 registry, 4128 buttonVariant: "secondary" 4129 } 4130 ) 4131 ] 4132 } 4133 ), 4134 primaryActions.length < eligibleActions.length && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)( 4135 ItemActions, 4136 { 4137 item, 4138 actions: eligibleActions, 4139 isCompact: true 4140 } 4141 ) }) 4142 ] }) 4143 } 4144 ); 4145 } 4146 var activity_item_default = ActivityItem; 4147 4148 // packages/dataviews/build-module/dataviews-layouts/activity/activity-items.js 4149 var import_react = __toESM(require_react()); 4150 function isDefined3(item) { 4151 return !!item; 4152 } 4153 function ActivityItems(props) { 4154 const { data, fields, getItemId: getItemId2, view } = props; 4155 const titleField = fields.find((field) => field.id === view.titleField); 4156 const mediaField = fields.find((field) => field.id === view.mediaField); 4157 const descriptionField2 = fields.find( 4158 (field) => field.id === view.descriptionField 4159 ); 4160 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3); 4161 return data.map((item, index) => { 4162 return /* @__PURE__ */ (0, import_react.createElement)( 4163 activity_item_default, 4164 { 4165 ...props, 4166 key: getItemId2(item), 4167 item, 4168 mediaField, 4169 titleField, 4170 descriptionField: descriptionField2, 4171 otherFields, 4172 posinset: view.infiniteScrollEnabled ? index + 1 : void 0 4173 } 4174 ); 4175 }); 4176 } 4177 4178 // packages/dataviews/build-module/dataviews-layouts/activity/index.js 4179 var import_jsx_runtime54 = __toESM(require_jsx_runtime()); 4180 function ViewActivity(props) { 4181 const { empty, data, fields, isLoading, view, className } = props; 4182 const hasData = data?.length; 4183 if (!hasData) { 4184 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 4185 "div", 4186 { 4187 className: clsx_default({ 4188 "dataviews-loading": isLoading, 4189 "dataviews-no-results": !hasData && !isLoading 4190 }), 4191 children: !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components14.Spinner, {}) }) : empty) 4192 } 4193 ); 4194 } 4195 const wrapperClassName = clsx_default("dataviews-view-activity", className); 4196 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null; 4197 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 4198 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : []; 4199 if (hasData && groupField && dataByGroup) { 4200 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components14.__experimentalVStack, { spacing: 2, className: wrapperClassName, children: groupedEntries.map( 4201 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 4202 ActivityGroup, 4203 { 4204 groupName, 4205 groupData, 4206 groupField, 4207 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 4208 ActivityItems, 4209 { 4210 ...props, 4211 data: groupData 4212 } 4213 ) 4214 }, 4215 groupName 4216 ) 4217 ) }); 4218 } 4219 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [ 4220 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 4221 "div", 4222 { 4223 className: wrapperClassName, 4224 role: view.infiniteScrollEnabled ? "feed" : void 0, 4225 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ActivityItems, { ...props }) 4226 } 4227 ), 4228 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components14.Spinner, {}) }) 4229 ] }); 4230 } 4231 4232 // packages/dataviews/build-module/dataviews-layouts/picker-grid/index.js 4233 var import_components17 = __toESM(require_components()); 4234 var import_i18n16 = __toESM(require_i18n()); 4235 var import_compose6 = __toESM(require_compose()); 4236 var import_element18 = __toESM(require_element()); 4237 4238 // packages/dataviews/build-module/components/dataviews-picker/footer.js 4239 var import_components16 = __toESM(require_components()); 4240 var import_data7 = __toESM(require_data()); 4241 var import_element16 = __toESM(require_element()); 4242 var import_i18n15 = __toESM(require_i18n()); 4243 4244 // packages/dataviews/build-module/components/dataviews-pagination/index.js 4245 var import_components15 = __toESM(require_components()); 4246 var import_element15 = __toESM(require_element()); 4247 var import_i18n14 = __toESM(require_i18n()); 4248 var import_jsx_runtime55 = __toESM(require_jsx_runtime()); 4249 function DataViewsPagination() { 4250 const { 4251 view, 4252 onChangeView, 4253 paginationInfo: { totalItems = 0, totalPages } 4254 } = (0, import_element15.useContext)(dataviews_context_default); 4255 if (!totalItems || !totalPages || view.infiniteScrollEnabled) { 4256 return null; 4257 } 4258 const currentPage = view.page ?? 1; 4259 const pageSelectOptions = Array.from(Array(totalPages)).map( 4260 (_, i2) => { 4261 const page = i2 + 1; 4262 return { 4263 value: page.toString(), 4264 label: page.toString(), 4265 "aria-label": currentPage === page ? (0, import_i18n14.sprintf)( 4266 // translators: 1: current page number. 2: total number of pages. 4267 (0, import_i18n14.__)("Page %1$d of %2$d"), 4268 currentPage, 4269 totalPages 4270 ) : page.toString() 4271 }; 4272 } 4273 ); 4274 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)( 4275 import_components15.__experimentalHStack, 4276 { 4277 expanded: false, 4278 className: "dataviews-pagination", 4279 justify: "end", 4280 spacing: 6, 4281 children: [ 4282 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)( 4283 import_components15.__experimentalHStack, 4284 { 4285 justify: "flex-start", 4286 expanded: false, 4287 spacing: 1, 4288 className: "dataviews-pagination__page-select", 4289 children: (0, import_element15.createInterpolateElement)( 4290 (0, import_i18n14.sprintf)( 4291 // translators: 1: Current page number, 2: Total number of pages. 4292 (0, import_i18n14._x)( 4293 "<div>Page</div>%1$s<div>of %2$d</div>", 4294 "paging" 4295 ), 4296 "<CurrentPage />", 4297 totalPages 4298 ), 4299 { 4300 div: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { "aria-hidden": true }), 4301 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)( 4302 import_components15.SelectControl, 4303 { 4304 "aria-label": (0, import_i18n14.__)("Current page"), 4305 value: currentPage.toString(), 4306 options: pageSelectOptions, 4307 onChange: (newValue) => { 4308 onChangeView({ 4309 ...view, 4310 page: +newValue 4311 }); 4312 }, 4313 size: "small", 4314 variant: "minimal" 4315 } 4316 ) 4317 } 4318 ) 4319 } 4320 ), 4321 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_components15.__experimentalHStack, { expanded: false, spacing: 1, children: [ 4322 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)( 4323 import_components15.Button, 4324 { 4325 onClick: () => onChangeView({ 4326 ...view, 4327 page: currentPage - 1 4328 }), 4329 disabled: currentPage === 1, 4330 accessibleWhenDisabled: true, 4331 label: (0, import_i18n14.__)("Previous page"), 4332 icon: (0, import_i18n14.isRTL)() ? next_default : previous_default, 4333 showTooltip: true, 4334 size: "compact", 4335 tooltipPosition: "top" 4336 } 4337 ), 4338 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)( 4339 import_components15.Button, 4340 { 4341 onClick: () => onChangeView({ ...view, page: currentPage + 1 }), 4342 disabled: currentPage >= totalPages, 4343 accessibleWhenDisabled: true, 4344 label: (0, import_i18n14.__)("Next page"), 4345 icon: (0, import_i18n14.isRTL)() ? previous_default : next_default, 4346 showTooltip: true, 4347 size: "compact", 4348 tooltipPosition: "top" 4349 } 4350 ) 4351 ] }) 4352 ] 4353 } 4354 ); 4355 } 4356 var dataviews_pagination_default = (0, import_element15.memo)(DataViewsPagination); 4357 4358 // packages/dataviews/build-module/components/dataviews-picker/footer.js 4359 var import_jsx_runtime56 = __toESM(require_jsx_runtime()); 4360 function useIsMultiselectPicker(actions) { 4361 return (0, import_element16.useMemo)(() => { 4362 return actions?.every((action) => action.supportsBulk); 4363 }, [actions]); 4364 } 4365 4366 // packages/dataviews/build-module/dataviews-layouts/utils/grid-items.js 4367 var import_element17 = __toESM(require_element()); 4368 var import_jsx_runtime57 = __toESM(require_jsx_runtime()); 4369 var GridItems = (0, import_element17.forwardRef)(({ className, previewSize, ...props }, ref) => { 4370 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)( 4371 "div", 4372 { 4373 ref, 4374 className: clsx_default("dataviews-view-grid-items", className), 4375 style: { 4376 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax($previewSize}px, 1fr))` 4377 }, 4378 ...props 4379 } 4380 ); 4381 }); 4382 4383 // packages/dataviews/build-module/dataviews-layouts/picker-grid/index.js 4384 var import_jsx_runtime58 = __toESM(require_jsx_runtime()); 4385 var { Badge: Badge2 } = unlock(import_components17.privateApis); 4386 function GridItem3({ 4387 view, 4388 multiselect, 4389 selection, 4390 onChangeSelection, 4391 getItemId: getItemId2, 4392 item, 4393 mediaField, 4394 titleField, 4395 descriptionField: descriptionField2, 4396 regularFields, 4397 badgeFields, 4398 config, 4399 posinset, 4400 setsize 4401 }) { 4402 const { showTitle = true, showMedia = true, showDescription = true } = view; 4403 const id = getItemId2(item); 4404 const isSelected2 = selection.includes(id); 4405 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4406 mediaField.render, 4407 { 4408 item, 4409 field: mediaField, 4410 config 4411 } 4412 ) : null; 4413 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null; 4414 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)( 4415 import_components17.Composite.Item, 4416 { 4417 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n16.__)("(no title)") : void 0, 4418 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components17.__experimentalVStack, { spacing: 0, children, ...props }), 4419 role: "option", 4420 "aria-posinset": posinset, 4421 "aria-setsize": setsize, 4422 className: clsx_default("dataviews-view-picker-grid__card", { 4423 "is-selected": isSelected2 4424 }), 4425 "aria-selected": isSelected2, 4426 onClick: () => { 4427 if (isSelected2) { 4428 onChangeSelection( 4429 selection.filter((itemId) => id !== itemId) 4430 ); 4431 } else { 4432 const newSelection = multiselect ? [...selection, id] : [id]; 4433 onChangeSelection(newSelection); 4434 } 4435 }, 4436 children: [ 4437 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }), 4438 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4439 DataViewsSelectionCheckbox, 4440 { 4441 item, 4442 selection, 4443 onChangeSelection, 4444 getItemId: getItemId2, 4445 titleField, 4446 disabled: false, 4447 "aria-hidden": true, 4448 tabIndex: -1 4449 } 4450 ), 4451 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4452 import_components17.__experimentalHStack, 4453 { 4454 justify: "space-between", 4455 className: "dataviews-view-picker-grid__title-actions", 4456 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField }) 4457 } 4458 ), 4459 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_components17.__experimentalVStack, { spacing: 1, children: [ 4460 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4461 descriptionField2.render, 4462 { 4463 item, 4464 field: descriptionField2 4465 } 4466 ), 4467 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4468 import_components17.__experimentalHStack, 4469 { 4470 className: "dataviews-view-picker-grid__badge-fields", 4471 spacing: 2, 4472 wrap: true, 4473 alignment: "top", 4474 justify: "flex-start", 4475 children: badgeFields.map((field) => { 4476 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4477 Badge2, 4478 { 4479 className: "dataviews-view-picker-grid__field-value", 4480 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4481 field.render, 4482 { 4483 item, 4484 field 4485 } 4486 ) 4487 }, 4488 field.id 4489 ); 4490 }) 4491 } 4492 ), 4493 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4494 import_components17.__experimentalVStack, 4495 { 4496 className: "dataviews-view-picker-grid__fields", 4497 spacing: 1, 4498 children: regularFields.map((field) => { 4499 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4500 import_components17.Flex, 4501 { 4502 className: "dataviews-view-picker-grid__field", 4503 gap: 1, 4504 justify: "flex-start", 4505 expanded: true, 4506 style: { height: "auto" }, 4507 direction: "row", 4508 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [ 4509 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components17.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }), 4510 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4511 import_components17.FlexItem, 4512 { 4513 className: "dataviews-view-picker-grid__field-value", 4514 style: { maxHeight: "none" }, 4515 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4516 field.render, 4517 { 4518 item, 4519 field 4520 } 4521 ) 4522 } 4523 ) 4524 ] }) 4525 }, 4526 field.id 4527 ); 4528 }) 4529 } 4530 ) 4531 ] }) 4532 ] 4533 }, 4534 id 4535 ); 4536 } 4537 function GridGroup({ 4538 groupName, 4539 groupField, 4540 children 4541 }) { 4542 const headerId = (0, import_compose6.useInstanceId)( 4543 GridGroup, 4544 "dataviews-view-picker-grid-group__header" 4545 ); 4546 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)( 4547 import_components17.__experimentalVStack, 4548 { 4549 spacing: 2, 4550 role: "group", 4551 "aria-labelledby": headerId, 4552 children: [ 4553 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4554 "h3", 4555 { 4556 className: "dataviews-view-picker-grid-group__header", 4557 id: headerId, 4558 children: (0, import_i18n16.sprintf)( 4559 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 4560 (0, import_i18n16.__)("%1$s: %2$s"), 4561 groupField.label, 4562 groupName 4563 ) 4564 } 4565 ), 4566 children 4567 ] 4568 }, 4569 groupName 4570 ); 4571 } 4572 function ViewPickerGrid({ 4573 actions, 4574 data, 4575 fields, 4576 getItemId: getItemId2, 4577 isLoading, 4578 onChangeSelection, 4579 selection, 4580 view, 4581 className, 4582 empty 4583 }) { 4584 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element18.useContext)(dataviews_context_default); 4585 const titleField = fields.find( 4586 (field) => field.id === view?.titleField 4587 ); 4588 const mediaField = fields.find( 4589 (field) => field.id === view?.mediaField 4590 ); 4591 const descriptionField2 = fields.find( 4592 (field) => field.id === view?.descriptionField 4593 ); 4594 const otherFields = view.fields ?? []; 4595 const { regularFields, badgeFields } = otherFields.reduce( 4596 (accumulator, fieldId) => { 4597 const field = fields.find((f2) => f2.id === fieldId); 4598 if (!field) { 4599 return accumulator; 4600 } 4601 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields"; 4602 accumulator[key].push(field); 4603 return accumulator; 4604 }, 4605 { regularFields: [], badgeFields: [] } 4606 ); 4607 const hasData = !!data?.length; 4608 const usedPreviewSize = view.layout?.previewSize; 4609 const isMultiselect = useIsMultiselectPicker(actions); 4610 const size = "900px"; 4611 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 4612 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 4613 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 4614 const currentPage = view?.page ?? 1; 4615 const perPage = view?.perPage ?? 0; 4616 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0; 4617 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { 4618 // Render multiple groups. 4619 children: [ 4620 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4621 import_components17.Composite, 4622 { 4623 virtualFocus: true, 4624 orientation: "horizontal", 4625 role: "listbox", 4626 "aria-multiselectable": isMultiselect, 4627 className: clsx_default( 4628 "dataviews-view-picker-grid", 4629 className 4630 ), 4631 "aria-label": itemListLabel, 4632 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4633 import_components17.__experimentalVStack, 4634 { 4635 spacing: 4, 4636 children, 4637 ...props 4638 } 4639 ), 4640 children: Array.from(dataByGroup.entries()).map( 4641 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4642 GridGroup, 4643 { 4644 groupName, 4645 groupField, 4646 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4647 GridItems, 4648 { 4649 previewSize: usedPreviewSize, 4650 style: { 4651 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax($usedPreviewSize}px, 1fr))` 4652 }, 4653 "aria-busy": isLoading, 4654 ref: resizeObserverRef, 4655 children: groupItems.map((item) => { 4656 const posInSet = (currentPage - 1) * perPage + data.indexOf(item) + 1; 4657 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4658 GridItem3, 4659 { 4660 view, 4661 multiselect: isMultiselect, 4662 selection, 4663 onChangeSelection, 4664 getItemId: getItemId2, 4665 item, 4666 mediaField, 4667 titleField, 4668 descriptionField: descriptionField2, 4669 regularFields, 4670 badgeFields, 4671 config: { 4672 sizes: size 4673 }, 4674 posinset: posInSet, 4675 setsize: setSize 4676 }, 4677 getItemId2(item) 4678 ); 4679 }) 4680 } 4681 ) 4682 }, 4683 groupName 4684 ) 4685 ) 4686 } 4687 ), 4688 // Render a single grid with all data. 4689 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4690 import_components17.Composite, 4691 { 4692 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4693 GridItems, 4694 { 4695 className: clsx_default( 4696 "dataviews-view-picker-grid", 4697 className 4698 ), 4699 previewSize: usedPreviewSize, 4700 "aria-busy": isLoading, 4701 ref: resizeObserverRef 4702 } 4703 ), 4704 virtualFocus: true, 4705 orientation: "horizontal", 4706 role: "listbox", 4707 "aria-multiselectable": isMultiselect, 4708 "aria-label": itemListLabel, 4709 children: data.map((item, index) => { 4710 let posinset = isInfiniteScroll ? index + 1 : void 0; 4711 if (!isInfiniteScroll) { 4712 posinset = (currentPage - 1) * perPage + index + 1; 4713 } 4714 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4715 GridItem3, 4716 { 4717 view, 4718 multiselect: isMultiselect, 4719 selection, 4720 onChangeSelection, 4721 getItemId: getItemId2, 4722 item, 4723 mediaField, 4724 titleField, 4725 descriptionField: descriptionField2, 4726 regularFields, 4727 badgeFields, 4728 config: { 4729 sizes: size 4730 }, 4731 posinset, 4732 setsize: setSize 4733 }, 4734 getItemId2(item) 4735 ); 4736 }) 4737 } 4738 ), 4739 // Render empty state. 4740 !hasData && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)( 4741 "div", 4742 { 4743 className: clsx_default({ 4744 "dataviews-loading": isLoading, 4745 "dataviews-no-results": !isLoading 4746 }), 4747 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components17.Spinner, {}) }) : empty 4748 } 4749 ), 4750 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components17.Spinner, {}) }) 4751 ] 4752 }); 4753 } 4754 var picker_grid_default = ViewPickerGrid; 4755 4756 // packages/dataviews/build-module/dataviews-layouts/picker-table/index.js 4757 var import_i18n17 = __toESM(require_i18n()); 4758 var import_components18 = __toESM(require_components()); 4759 var import_element19 = __toESM(require_element()); 4760 var import_jsx_runtime59 = __toESM(require_jsx_runtime()); 4761 function TableColumnField2({ 4762 item, 4763 fields, 4764 column, 4765 align 4766 }) { 4767 const field = fields.find((f2) => f2.id === column); 4768 if (!field) { 4769 return null; 4770 } 4771 const className = clsx_default("dataviews-view-table__cell-content-wrapper", { 4772 "dataviews-view-table__cell-align-end": align === "end", 4773 "dataviews-view-table__cell-align-center": align === "center" 4774 }); 4775 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(field.render, { item, field }) }); 4776 } 4777 function TableRow2({ 4778 item, 4779 fields, 4780 id, 4781 view, 4782 titleField, 4783 mediaField, 4784 descriptionField: descriptionField2, 4785 selection, 4786 getItemId: getItemId2, 4787 onChangeSelection, 4788 multiselect, 4789 posinset 4790 }) { 4791 const { paginationInfo } = (0, import_element19.useContext)(dataviews_context_default); 4792 const isSelected2 = selection.includes(id); 4793 const [isHovered, setIsHovered] = (0, import_element19.useState)(false); 4794 const { 4795 showTitle = true, 4796 showMedia = true, 4797 showDescription = true, 4798 infiniteScrollEnabled 4799 } = view; 4800 const handleMouseEnter = () => { 4801 setIsHovered(true); 4802 }; 4803 const handleMouseLeave = () => { 4804 setIsHovered(false); 4805 }; 4806 const columns = view.fields ?? []; 4807 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 4808 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 4809 import_components18.Composite.Item, 4810 { 4811 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 4812 "tr", 4813 { 4814 className: clsx_default("dataviews-view-table__row", { 4815 "is-selected": isSelected2, 4816 "is-hovered": isHovered 4817 }), 4818 onMouseEnter: handleMouseEnter, 4819 onMouseLeave: handleMouseLeave, 4820 children, 4821 ...props 4822 } 4823 ), 4824 "aria-selected": isSelected2, 4825 "aria-setsize": paginationInfo.totalItems || void 0, 4826 "aria-posinset": posinset, 4827 role: infiniteScrollEnabled ? "article" : "option", 4828 onClick: () => { 4829 if (isSelected2) { 4830 onChangeSelection( 4831 selection.filter((itemId) => id !== itemId) 4832 ); 4833 } else { 4834 const newSelection = multiselect ? [...selection, id] : [id]; 4835 onChangeSelection(newSelection); 4836 } 4837 }, 4838 children: [ 4839 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 4840 "td", 4841 { 4842 className: "dataviews-view-table__checkbox-column", 4843 role: "presentation", 4844 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 4845 DataViewsSelectionCheckbox, 4846 { 4847 item, 4848 selection, 4849 onChangeSelection, 4850 getItemId: getItemId2, 4851 titleField, 4852 disabled: false, 4853 "aria-hidden": true, 4854 tabIndex: -1 4855 } 4856 ) }) 4857 } 4858 ), 4859 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("td", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 4860 column_primary_default, 4861 { 4862 item, 4863 titleField: showTitle ? titleField : void 0, 4864 mediaField: showMedia ? mediaField : void 0, 4865 descriptionField: showDescription ? descriptionField2 : void 0, 4866 isItemClickable: () => false 4867 } 4868 ) }), 4869 columns.map((column) => { 4870 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 4871 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 4872 "td", 4873 { 4874 style: { 4875 width, 4876 maxWidth, 4877 minWidth 4878 }, 4879 role: "presentation", 4880 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 4881 TableColumnField2, 4882 { 4883 fields, 4884 item, 4885 column, 4886 align 4887 } 4888 ) 4889 }, 4890 column 4891 ); 4892 }) 4893 ] 4894 }, 4895 id 4896 ); 4897 } 4898 function ViewPickerTable({ 4899 actions, 4900 data, 4901 fields, 4902 getItemId: getItemId2, 4903 isLoading = false, 4904 onChangeView, 4905 onChangeSelection, 4906 selection, 4907 setOpenedFilter, 4908 view, 4909 className, 4910 empty 4911 }) { 4912 const headerMenuRefs = (0, import_element19.useRef)(/* @__PURE__ */ new Map()); 4913 const headerMenuToFocusRef = (0, import_element19.useRef)(); 4914 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element19.useState)(); 4915 const isMultiselect = useIsMultiselectPicker(actions) ?? false; 4916 (0, import_element19.useEffect)(() => { 4917 if (headerMenuToFocusRef.current) { 4918 headerMenuToFocusRef.current.focus(); 4919 headerMenuToFocusRef.current = void 0; 4920 } 4921 }); 4922 const tableNoticeId = (0, import_element19.useId)(); 4923 if (nextHeaderMenuToFocus) { 4924 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 4925 setNextHeaderMenuToFocus(void 0); 4926 return; 4927 } 4928 const onHide = (field) => { 4929 const hidden = headerMenuRefs.current.get(field.id); 4930 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0; 4931 setNextHeaderMenuToFocus(fallback?.node); 4932 }; 4933 const hasData = !!data?.length; 4934 const titleField = fields.find((field) => field.id === view.titleField); 4935 const mediaField = fields.find((field) => field.id === view.mediaField); 4936 const descriptionField2 = fields.find( 4937 (field) => field.id === view.descriptionField 4938 ); 4939 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null; 4940 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null; 4941 const { showTitle = true, showMedia = true, showDescription = true } = view; 4942 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription; 4943 const columns = view.fields ?? []; 4944 const headerMenuRef = (column, index) => (node) => { 4945 if (node) { 4946 headerMenuRefs.current.set(column, { 4947 node, 4948 fallback: columns[index > 0 ? index - 1 : 1] 4949 }); 4950 } else { 4951 headerMenuRefs.current.delete(column); 4952 } 4953 }; 4954 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup; 4955 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [ 4956 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 4957 "table", 4958 { 4959 className: clsx_default( 4960 "dataviews-view-table", 4961 "dataviews-view-picker-table", 4962 className, 4963 { 4964 [`has-$view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes( 4965 view.layout.density 4966 ) 4967 } 4968 ), 4969 "aria-busy": isLoading, 4970 "aria-describedby": tableNoticeId, 4971 role: isInfiniteScroll ? "feed" : "listbox", 4972 children: [ 4973 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 4974 "tr", 4975 { 4976 className: "dataviews-view-table__row", 4977 role: "presentation", 4978 children: [ 4979 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 4980 BulkSelectionCheckbox, 4981 { 4982 selection, 4983 onChangeSelection, 4984 data, 4985 actions, 4986 getItemId: getItemId2 4987 } 4988 ) }), 4989 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 4990 column_header_menu_default, 4991 { 4992 ref: headerMenuRef( 4993 titleField.id, 4994 0 4995 ), 4996 fieldId: titleField.id, 4997 view, 4998 fields, 4999 onChangeView, 5000 onHide, 5001 setOpenedFilter, 5002 canMove: false 5003 } 5004 ) }), 5005 columns.map((column, index) => { 5006 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {}; 5007 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 5008 "th", 5009 { 5010 style: { 5011 width, 5012 maxWidth, 5013 minWidth, 5014 textAlign: align 5015 }, 5016 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0, 5017 scope: "col", 5018 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 5019 column_header_menu_default, 5020 { 5021 ref: headerMenuRef(column, index), 5022 fieldId: column, 5023 view, 5024 fields, 5025 onChangeView, 5026 onHide, 5027 setOpenedFilter, 5028 canMove: view.layout?.enableMoving ?? true 5029 } 5030 ) 5031 }, 5032 column 5033 ); 5034 }) 5035 ] 5036 } 5037 ) }), 5038 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map( 5039 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 5040 import_components18.Composite, 5041 { 5042 virtualFocus: true, 5043 orientation: "vertical", 5044 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "group" }), 5045 children: [ 5046 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 5047 "tr", 5048 { 5049 className: "dataviews-view-table__group-header-row", 5050 role: "presentation", 5051 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 5052 "td", 5053 { 5054 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1, 5055 className: "dataviews-view-table__group-header-cell", 5056 role: "presentation", 5057 children: (0, import_i18n17.sprintf)( 5058 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". 5059 (0, import_i18n17.__)("%1$s: %2$s"), 5060 groupField.label, 5061 groupName 5062 ) 5063 } 5064 ) 5065 } 5066 ), 5067 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 5068 TableRow2, 5069 { 5070 item, 5071 fields, 5072 id: getItemId2(item) || index.toString(), 5073 view, 5074 titleField, 5075 mediaField, 5076 descriptionField: descriptionField2, 5077 selection, 5078 getItemId: getItemId2, 5079 onChangeSelection, 5080 multiselect: isMultiselect 5081 }, 5082 getItemId2(item) 5083 )) 5084 ] 5085 }, 5086 `group-$groupName}` 5087 ) 5088 ) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 5089 import_components18.Composite, 5090 { 5091 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "presentation" }), 5092 virtualFocus: true, 5093 orientation: "vertical", 5094 children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)( 5095 TableRow2, 5096 { 5097 item, 5098 fields, 5099 id: getItemId2(item) || index.toString(), 5100 view, 5101 titleField, 5102 mediaField, 5103 descriptionField: descriptionField2, 5104 selection, 5105 getItemId: getItemId2, 5106 onChangeSelection, 5107 multiselect: isMultiselect, 5108 posinset: index + 1 5109 }, 5110 getItemId2(item) 5111 )) 5112 } 5113 ) 5114 ] 5115 } 5116 ), 5117 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)( 5118 "div", 5119 { 5120 className: clsx_default({ 5121 "dataviews-loading": isLoading, 5122 "dataviews-no-results": !hasData && !isLoading 5123 }), 5124 id: tableNoticeId, 5125 children: [ 5126 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components18.Spinner, {}) }) : empty), 5127 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components18.Spinner, {}) }) 5128 ] 5129 } 5130 ) 5131 ] }); 5132 } 5133 var picker_table_default = ViewPickerTable; 5134 5135 // packages/dataviews/build-module/dataviews-layouts/utils/preview-size-picker.js 5136 var import_components19 = __toESM(require_components()); 5137 var import_i18n18 = __toESM(require_i18n()); 5138 var import_element20 = __toESM(require_element()); 5139 var import_jsx_runtime60 = __toESM(require_jsx_runtime()); 5140 var imageSizes2 = [ 5141 { 5142 value: 120, 5143 breakpoint: 1 5144 }, 5145 { 5146 value: 170, 5147 breakpoint: 1 5148 }, 5149 { 5150 value: 230, 5151 breakpoint: 1 5152 }, 5153 { 5154 value: 290, 5155 breakpoint: 1112 5156 // at minimum image width, 4 images display at this container size 5157 }, 5158 { 5159 value: 350, 5160 breakpoint: 1636 5161 // at minimum image width, 6 images display at this container size 5162 }, 5163 { 5164 value: 430, 5165 breakpoint: 588 5166 // at minimum image width, 2 images display at this container size 5167 } 5168 ]; 5169 function PreviewSizePicker() { 5170 const context = (0, import_element20.useContext)(dataviews_context_default); 5171 const view = context.view; 5172 const breakValues = imageSizes2.filter((size) => { 5173 return context.containerWidth >= size.breakpoint; 5174 }); 5175 const layoutPreviewSize = view.layout?.previewSize ?? 230; 5176 const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0; 5177 const marks = breakValues.map((size, index) => { 5178 return { 5179 value: index 5180 }; 5181 }); 5182 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)( 5183 import_components19.RangeControl, 5184 { 5185 __next40pxDefaultSize: true, 5186 showTooltip: false, 5187 label: (0, import_i18n18.__)("Preview size"), 5188 value: previewSizeToUse, 5189 min: 0, 5190 max: breakValues.length - 1, 5191 withInputField: false, 5192 onChange: (value = 0) => { 5193 context.onChangeView({ 5194 ...view, 5195 layout: { 5196 ...view.layout, 5197 previewSize: breakValues[value].value 5198 } 5199 }); 5200 }, 5201 step: 1, 5202 marks 5203 } 5204 ); 5205 } 5206 5207 // packages/dataviews/build-module/dataviews-layouts/table/density-picker.js 5208 var import_components20 = __toESM(require_components()); 5209 var import_i18n19 = __toESM(require_i18n()); 5210 var import_element21 = __toESM(require_element()); 5211 var import_jsx_runtime61 = __toESM(require_jsx_runtime()); 5212 function DensityPicker() { 5213 const context = (0, import_element21.useContext)(dataviews_context_default); 5214 const view = context.view; 5215 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)( 5216 import_components20.__experimentalToggleGroupControl, 5217 { 5218 size: "__unstable-large", 5219 label: (0, import_i18n19.__)("Density"), 5220 value: view.layout?.density || "balanced", 5221 onChange: (value) => { 5222 context.onChangeView({ 5223 ...view, 5224 layout: { 5225 ...view.layout, 5226 density: value 5227 } 5228 }); 5229 }, 5230 isBlock: true, 5231 children: [ 5232 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 5233 import_components20.__experimentalToggleGroupControlOption, 5234 { 5235 value: "comfortable", 5236 label: (0, import_i18n19._x)( 5237 "Comfortable", 5238 "Density option for DataView layout" 5239 ) 5240 }, 5241 "comfortable" 5242 ), 5243 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 5244 import_components20.__experimentalToggleGroupControlOption, 5245 { 5246 value: "balanced", 5247 label: (0, import_i18n19._x)("Balanced", "Density option for DataView layout") 5248 }, 5249 "balanced" 5250 ), 5251 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)( 5252 import_components20.__experimentalToggleGroupControlOption, 5253 { 5254 value: "compact", 5255 label: (0, import_i18n19._x)("Compact", "Density option for DataView layout") 5256 }, 5257 "compact" 5258 ) 5259 ] 5260 } 5261 ); 5262 } 5263 5264 // packages/dataviews/build-module/dataviews-layouts/index.js 5265 var VIEW_LAYOUTS = [ 5266 { 5267 type: LAYOUT_TABLE, 5268 label: (0, import_i18n20.__)("Table"), 5269 component: table_default, 5270 icon: block_table_default, 5271 viewConfigOptions: DensityPicker 5272 }, 5273 { 5274 type: LAYOUT_GRID, 5275 label: (0, import_i18n20.__)("Grid"), 5276 component: grid_default, 5277 icon: category_default, 5278 viewConfigOptions: PreviewSizePicker 5279 }, 5280 { 5281 type: LAYOUT_LIST, 5282 label: (0, import_i18n20.__)("List"), 5283 component: ViewList, 5284 icon: (0, import_i18n20.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default 5285 }, 5286 { 5287 type: LAYOUT_ACTIVITY, 5288 label: (0, import_i18n20.__)("Activity"), 5289 component: ViewActivity, 5290 icon: scheduled_default, 5291 viewConfigOptions: DensityPicker 5292 }, 5293 { 5294 type: LAYOUT_PICKER_GRID, 5295 label: (0, import_i18n20.__)("Grid"), 5296 component: picker_grid_default, 5297 icon: category_default, 5298 viewConfigOptions: PreviewSizePicker, 5299 isPicker: true 5300 }, 5301 { 5302 type: LAYOUT_PICKER_TABLE, 5303 label: (0, import_i18n20.__)("Table"), 5304 component: picker_table_default, 5305 icon: block_table_default, 5306 viewConfigOptions: DensityPicker, 5307 isPicker: true 5308 } 5309 ]; 5310 5311 // packages/dataviews/build-module/components/dataviews-filters/filters.js 5312 var import_element29 = __toESM(require_element()); 5313 var import_components26 = __toESM(require_components()); 5314 5315 // packages/dataviews/build-module/components/dataviews-filters/filter.js 5316 var import_components23 = __toESM(require_components()); 5317 var import_i18n23 = __toESM(require_i18n()); 5318 var import_element26 = __toESM(require_element()); 5319 5320 // node_modules/@ariakit/react-core/esm/__chunks/3YLGPPWQ.js 5321 var __defProp2 = Object.defineProperty; 5322 var __defProps = Object.defineProperties; 5323 var __getOwnPropDescs = Object.getOwnPropertyDescriptors; 5324 var __getOwnPropSymbols = Object.getOwnPropertySymbols; 5325 var __hasOwnProp2 = Object.prototype.hasOwnProperty; 5326 var __propIsEnum = Object.prototype.propertyIsEnumerable; 5327 var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 5328 var __spreadValues = (a2, b2) => { 5329 for (var prop in b2 || (b2 = {})) 5330 if (__hasOwnProp2.call(b2, prop)) 5331 __defNormalProp(a2, prop, b2[prop]); 5332 if (__getOwnPropSymbols) 5333 for (var prop of __getOwnPropSymbols(b2)) { 5334 if (__propIsEnum.call(b2, prop)) 5335 __defNormalProp(a2, prop, b2[prop]); 5336 } 5337 return a2; 5338 }; 5339 var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2)); 5340 var __objRest = (source, exclude) => { 5341 var target = {}; 5342 for (var prop in source) 5343 if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0) 5344 target[prop] = source[prop]; 5345 if (source != null && __getOwnPropSymbols) 5346 for (var prop of __getOwnPropSymbols(source)) { 5347 if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) 5348 target[prop] = source[prop]; 5349 } 5350 return target; 5351 }; 5352 5353 // node_modules/@ariakit/core/esm/__chunks/3YLGPPWQ.js 5354 var __defProp3 = Object.defineProperty; 5355 var __defProps2 = Object.defineProperties; 5356 var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors; 5357 var __getOwnPropSymbols2 = Object.getOwnPropertySymbols; 5358 var __hasOwnProp3 = Object.prototype.hasOwnProperty; 5359 var __propIsEnum2 = Object.prototype.propertyIsEnumerable; 5360 var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 5361 var __spreadValues2 = (a2, b2) => { 5362 for (var prop in b2 || (b2 = {})) 5363 if (__hasOwnProp3.call(b2, prop)) 5364 __defNormalProp2(a2, prop, b2[prop]); 5365 if (__getOwnPropSymbols2) 5366 for (var prop of __getOwnPropSymbols2(b2)) { 5367 if (__propIsEnum2.call(b2, prop)) 5368 __defNormalProp2(a2, prop, b2[prop]); 5369 } 5370 return a2; 5371 }; 5372 var __spreadProps2 = (a2, b2) => __defProps2(a2, __getOwnPropDescs2(b2)); 5373 var __objRest2 = (source, exclude) => { 5374 var target = {}; 5375 for (var prop in source) 5376 if (__hasOwnProp3.call(source, prop) && exclude.indexOf(prop) < 0) 5377 target[prop] = source[prop]; 5378 if (source != null && __getOwnPropSymbols2) 5379 for (var prop of __getOwnPropSymbols2(source)) { 5380 if (exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop)) 5381 target[prop] = source[prop]; 5382 } 5383 return target; 5384 }; 5385 5386 // node_modules/@ariakit/core/esm/__chunks/PBFD2E7P.js 5387 function noop(..._) { 5388 } 5389 function applyState(argument, currentValue) { 5390 if (isUpdater(argument)) { 5391 const value = isLazyValue(currentValue) ? currentValue() : currentValue; 5392 return argument(value); 5393 } 5394 return argument; 5395 } 5396 function isUpdater(argument) { 5397 return typeof argument === "function"; 5398 } 5399 function isLazyValue(value) { 5400 return typeof value === "function"; 5401 } 5402 function hasOwnProperty(object, prop) { 5403 if (typeof Object.hasOwn === "function") { 5404 return Object.hasOwn(object, prop); 5405 } 5406 return Object.prototype.hasOwnProperty.call(object, prop); 5407 } 5408 function chain(...fns) { 5409 return (...args) => { 5410 for (const fn of fns) { 5411 if (typeof fn === "function") { 5412 fn(...args); 5413 } 5414 } 5415 }; 5416 } 5417 function normalizeString(str) { 5418 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); 5419 } 5420 function omit2(object, keys) { 5421 const result = __spreadValues2({}, object); 5422 for (const key of keys) { 5423 if (hasOwnProperty(result, key)) { 5424 delete result[key]; 5425 } 5426 } 5427 return result; 5428 } 5429 function pick(object, paths) { 5430 const result = {}; 5431 for (const key of paths) { 5432 if (hasOwnProperty(object, key)) { 5433 result[key] = object[key]; 5434 } 5435 } 5436 return result; 5437 } 5438 function identity(value) { 5439 return value; 5440 } 5441 function invariant(condition, message2) { 5442 if (condition) return; 5443 if (typeof message2 !== "string") throw new Error("Invariant failed"); 5444 throw new Error(message2); 5445 } 5446 function getKeys(obj) { 5447 return Object.keys(obj); 5448 } 5449 function isFalsyBooleanCallback(booleanOrCallback, ...args) { 5450 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback; 5451 if (result == null) return false; 5452 return !result; 5453 } 5454 function disabledFromProps(props) { 5455 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true"; 5456 } 5457 function removeUndefinedValues(obj) { 5458 const result = {}; 5459 for (const key in obj) { 5460 if (obj[key] !== void 0) { 5461 result[key] = obj[key]; 5462 } 5463 } 5464 return result; 5465 } 5466 function defaultValue(...values) { 5467 for (const value of values) { 5468 if (value !== void 0) return value; 5469 } 5470 return void 0; 5471 } 5472 5473 // node_modules/@ariakit/react-core/esm/__chunks/SK3NAZA3.js 5474 var import_react2 = __toESM(require_react(), 1); 5475 function setRef(ref, value) { 5476 if (typeof ref === "function") { 5477 ref(value); 5478 } else if (ref) { 5479 ref.current = value; 5480 } 5481 } 5482 function isValidElementWithRef(element) { 5483 if (!element) return false; 5484 if (!(0, import_react2.isValidElement)(element)) return false; 5485 if ("ref" in element.props) return true; 5486 if ("ref" in element) return true; 5487 return false; 5488 } 5489 function getRefProperty(element) { 5490 if (!isValidElementWithRef(element)) return null; 5491 const props = __spreadValues({}, element.props); 5492 return props.ref || element.ref; 5493 } 5494 function mergeProps(base, overrides) { 5495 const props = __spreadValues({}, base); 5496 for (const key in overrides) { 5497 if (!hasOwnProperty(overrides, key)) continue; 5498 if (key === "className") { 5499 const prop = "className"; 5500 props[prop] = base[prop] ? `$base[prop]} $overrides[prop]}` : overrides[prop]; 5501 continue; 5502 } 5503 if (key === "style") { 5504 const prop = "style"; 5505 props[prop] = base[prop] ? __spreadValues(__spreadValues({}, base[prop]), overrides[prop]) : overrides[prop]; 5506 continue; 5507 } 5508 const overrideValue = overrides[key]; 5509 if (typeof overrideValue === "function" && key.startsWith("on")) { 5510 const baseValue = base[key]; 5511 if (typeof baseValue === "function") { 5512 props[key] = (...args) => { 5513 overrideValue(...args); 5514 baseValue(...args); 5515 }; 5516 continue; 5517 } 5518 } 5519 props[key] = overrideValue; 5520 } 5521 return props; 5522 } 5523 5524 // node_modules/@ariakit/core/esm/__chunks/DTR5TSDJ.js 5525 var canUseDOM = checkIsBrowser(); 5526 function checkIsBrowser() { 5527 var _a; 5528 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement); 5529 } 5530 function getDocument(node) { 5531 if (!node) return document; 5532 if ("self" in node) return node.document; 5533 return node.ownerDocument || document; 5534 } 5535 function getActiveElement(node, activeDescendant = false) { 5536 const { activeElement } = getDocument(node); 5537 if (!(activeElement == null ? void 0 : activeElement.nodeName)) { 5538 return null; 5539 } 5540 if (isFrame(activeElement) && activeElement.contentDocument) { 5541 return getActiveElement( 5542 activeElement.contentDocument.body, 5543 activeDescendant 5544 ); 5545 } 5546 if (activeDescendant) { 5547 const id = activeElement.getAttribute("aria-activedescendant"); 5548 if (id) { 5549 const element = getDocument(activeElement).getElementById(id); 5550 if (element) { 5551 return element; 5552 } 5553 } 5554 } 5555 return activeElement; 5556 } 5557 function contains(parent, child) { 5558 return parent === child || parent.contains(child); 5559 } 5560 function isFrame(element) { 5561 return element.tagName === "IFRAME"; 5562 } 5563 function isButton(element) { 5564 const tagName = element.tagName.toLowerCase(); 5565 if (tagName === "button") return true; 5566 if (tagName === "input" && element.type) { 5567 return buttonInputTypes.indexOf(element.type) !== -1; 5568 } 5569 return false; 5570 } 5571 var buttonInputTypes = [ 5572 "button", 5573 "color", 5574 "file", 5575 "image", 5576 "reset", 5577 "submit" 5578 ]; 5579 function isVisible(element) { 5580 if (typeof element.checkVisibility === "function") { 5581 return element.checkVisibility(); 5582 } 5583 const htmlElement = element; 5584 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0; 5585 } 5586 function isTextField(element) { 5587 try { 5588 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null; 5589 const isTextArea = element.tagName === "TEXTAREA"; 5590 return isTextInput || isTextArea || false; 5591 } catch (error) { 5592 return false; 5593 } 5594 } 5595 function isTextbox(element) { 5596 return element.isContentEditable || isTextField(element); 5597 } 5598 function getTextboxValue(element) { 5599 if (isTextField(element)) { 5600 return element.value; 5601 } 5602 if (element.isContentEditable) { 5603 const range = getDocument(element).createRange(); 5604 range.selectNodeContents(element); 5605 return range.toString(); 5606 } 5607 return ""; 5608 } 5609 function getTextboxSelection(element) { 5610 let start = 0; 5611 let end = 0; 5612 if (isTextField(element)) { 5613 start = element.selectionStart || 0; 5614 end = element.selectionEnd || 0; 5615 } else if (element.isContentEditable) { 5616 const selection = getDocument(element).getSelection(); 5617 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) { 5618 const range = selection.getRangeAt(0); 5619 const nextRange = range.cloneRange(); 5620 nextRange.selectNodeContents(element); 5621 nextRange.setEnd(range.startContainer, range.startOffset); 5622 start = nextRange.toString().length; 5623 nextRange.setEnd(range.endContainer, range.endOffset); 5624 end = nextRange.toString().length; 5625 } 5626 } 5627 return { start, end }; 5628 } 5629 function getPopupRole(element, fallback) { 5630 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"]; 5631 const role = element == null ? void 0 : element.getAttribute("role"); 5632 if (role && allowedPopupRoles.indexOf(role) !== -1) { 5633 return role; 5634 } 5635 return fallback; 5636 } 5637 function getScrollingElement(element) { 5638 if (!element) return null; 5639 const isScrollableOverflow = (overflow) => { 5640 if (overflow === "auto") return true; 5641 if (overflow === "scroll") return true; 5642 return false; 5643 }; 5644 if (element.clientHeight && element.scrollHeight > element.clientHeight) { 5645 const { overflowY } = getComputedStyle(element); 5646 if (isScrollableOverflow(overflowY)) return element; 5647 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) { 5648 const { overflowX } = getComputedStyle(element); 5649 if (isScrollableOverflow(overflowX)) return element; 5650 } 5651 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body; 5652 } 5653 function setSelectionRange(element, ...args) { 5654 if (/text|search|password|tel|url/i.test(element.type)) { 5655 element.setSelectionRange(...args); 5656 } 5657 } 5658 function sortBasedOnDOMPosition(items, getElement) { 5659 const pairs = items.map((item, index) => [index, item]); 5660 let isOrderDifferent = false; 5661 pairs.sort(([indexA, a2], [indexB, b2]) => { 5662 const elementA = getElement(a2); 5663 const elementB = getElement(b2); 5664 if (elementA === elementB) return 0; 5665 if (!elementA || !elementB) return 0; 5666 if (isElementPreceding(elementA, elementB)) { 5667 if (indexA > indexB) { 5668 isOrderDifferent = true; 5669 } 5670 return -1; 5671 } 5672 if (indexA < indexB) { 5673 isOrderDifferent = true; 5674 } 5675 return 1; 5676 }); 5677 if (isOrderDifferent) { 5678 return pairs.map(([_, item]) => item); 5679 } 5680 return items; 5681 } 5682 function isElementPreceding(a2, b2) { 5683 return Boolean( 5684 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING 5685 ); 5686 } 5687 5688 // node_modules/@ariakit/core/esm/__chunks/QAGXQEUG.js 5689 function isTouchDevice() { 5690 return canUseDOM && !!navigator.maxTouchPoints; 5691 } 5692 function isApple() { 5693 if (!canUseDOM) return false; 5694 return /mac|iphone|ipad|ipod/i.test(navigator.platform); 5695 } 5696 function isSafari() { 5697 return canUseDOM && isApple() && /apple/i.test(navigator.vendor); 5698 } 5699 function isFirefox() { 5700 return canUseDOM && /firefox\//i.test(navigator.userAgent); 5701 } 5702 5703 // node_modules/@ariakit/core/esm/utils/events.js 5704 function isPortalEvent(event) { 5705 return Boolean( 5706 event.currentTarget && !contains(event.currentTarget, event.target) 5707 ); 5708 } 5709 function isSelfTarget(event) { 5710 return event.target === event.currentTarget; 5711 } 5712 function isOpeningInNewTab(event) { 5713 const element = event.currentTarget; 5714 if (!element) return false; 5715 const isAppleDevice = isApple(); 5716 if (isAppleDevice && !event.metaKey) return false; 5717 if (!isAppleDevice && !event.ctrlKey) return false; 5718 const tagName = element.tagName.toLowerCase(); 5719 if (tagName === "a") return true; 5720 if (tagName === "button" && element.type === "submit") return true; 5721 if (tagName === "input" && element.type === "submit") return true; 5722 return false; 5723 } 5724 function isDownloading(event) { 5725 const element = event.currentTarget; 5726 if (!element) return false; 5727 const tagName = element.tagName.toLowerCase(); 5728 if (!event.altKey) return false; 5729 if (tagName === "a") return true; 5730 if (tagName === "button" && element.type === "submit") return true; 5731 if (tagName === "input" && element.type === "submit") return true; 5732 return false; 5733 } 5734 function fireBlurEvent(element, eventInit) { 5735 const event = new FocusEvent("blur", eventInit); 5736 const defaultAllowed = element.dispatchEvent(event); 5737 const bubbleInit = __spreadProps2(__spreadValues2({}, eventInit), { bubbles: true }); 5738 element.dispatchEvent(new FocusEvent("focusout", bubbleInit)); 5739 return defaultAllowed; 5740 } 5741 function fireKeyboardEvent(element, type, eventInit) { 5742 const event = new KeyboardEvent(type, eventInit); 5743 return element.dispatchEvent(event); 5744 } 5745 function fireClickEvent(element, eventInit) { 5746 const event = new MouseEvent("click", eventInit); 5747 return element.dispatchEvent(event); 5748 } 5749 function isFocusEventOutside(event, container) { 5750 const containerElement = container || event.currentTarget; 5751 const relatedTarget = event.relatedTarget; 5752 return !relatedTarget || !contains(containerElement, relatedTarget); 5753 } 5754 function queueBeforeEvent(element, type, callback, timeout) { 5755 const createTimer = (callback2) => { 5756 if (timeout) { 5757 const timerId2 = setTimeout(callback2, timeout); 5758 return () => clearTimeout(timerId2); 5759 } 5760 const timerId = requestAnimationFrame(callback2); 5761 return () => cancelAnimationFrame(timerId); 5762 }; 5763 const cancelTimer = createTimer(() => { 5764 element.removeEventListener(type, callSync, true); 5765 callback(); 5766 }); 5767 const callSync = () => { 5768 cancelTimer(); 5769 callback(); 5770 }; 5771 element.addEventListener(type, callSync, { once: true, capture: true }); 5772 return cancelTimer; 5773 } 5774 function addGlobalEventListener(type, listener, options, scope = window) { 5775 const children = []; 5776 try { 5777 scope.document.addEventListener(type, listener, options); 5778 for (const frame of Array.from(scope.frames)) { 5779 children.push(addGlobalEventListener(type, listener, options, frame)); 5780 } 5781 } catch (e2) { 5782 } 5783 const removeEventListener = () => { 5784 try { 5785 scope.document.removeEventListener(type, listener, options); 5786 } catch (e2) { 5787 } 5788 for (const remove of children) { 5789 remove(); 5790 } 5791 }; 5792 return removeEventListener; 5793 } 5794 5795 // node_modules/@ariakit/react-core/esm/__chunks/ABQUS43J.js 5796 var import_react3 = __toESM(require_react(), 1); 5797 var React2 = __toESM(require_react(), 1); 5798 var _React = __spreadValues({}, React2); 5799 var useReactId = _React.useId; 5800 var useReactDeferredValue = _React.useDeferredValue; 5801 var useReactInsertionEffect = _React.useInsertionEffect; 5802 var useSafeLayoutEffect = canUseDOM ? import_react3.useLayoutEffect : import_react3.useEffect; 5803 function useInitialValue(value) { 5804 const [initialValue] = (0, import_react3.useState)(value); 5805 return initialValue; 5806 } 5807 function useLiveRef(value) { 5808 const ref = (0, import_react3.useRef)(value); 5809 useSafeLayoutEffect(() => { 5810 ref.current = value; 5811 }); 5812 return ref; 5813 } 5814 function useEvent(callback) { 5815 const ref = (0, import_react3.useRef)(() => { 5816 throw new Error("Cannot call an event handler while rendering."); 5817 }); 5818 if (useReactInsertionEffect) { 5819 useReactInsertionEffect(() => { 5820 ref.current = callback; 5821 }); 5822 } else { 5823 ref.current = callback; 5824 } 5825 return (0, import_react3.useCallback)((...args) => { 5826 var _a; 5827 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args); 5828 }, []); 5829 } 5830 function useTransactionState(callback) { 5831 const [state, setState] = (0, import_react3.useState)(null); 5832 useSafeLayoutEffect(() => { 5833 if (state == null) return; 5834 if (!callback) return; 5835 let prevState = null; 5836 callback((prev) => { 5837 prevState = prev; 5838 return state; 5839 }); 5840 return () => { 5841 callback(prevState); 5842 }; 5843 }, [state, callback]); 5844 return [state, setState]; 5845 } 5846 function useMergeRefs(...refs) { 5847 return (0, import_react3.useMemo)(() => { 5848 if (!refs.some(Boolean)) return; 5849 return (value) => { 5850 for (const ref of refs) { 5851 setRef(ref, value); 5852 } 5853 }; 5854 }, refs); 5855 } 5856 function useId3(defaultId) { 5857 if (useReactId) { 5858 const reactId = useReactId(); 5859 if (defaultId) return defaultId; 5860 return reactId; 5861 } 5862 const [id, setId] = (0, import_react3.useState)(defaultId); 5863 useSafeLayoutEffect(() => { 5864 if (defaultId || id) return; 5865 const random = Math.random().toString(36).slice(2, 8); 5866 setId(`id-$random}`); 5867 }, [defaultId, id]); 5868 return defaultId || id; 5869 } 5870 function useTagName(refOrElement, type) { 5871 const stringOrUndefined = (type2) => { 5872 if (typeof type2 !== "string") return; 5873 return type2; 5874 }; 5875 const [tagName, setTagName] = (0, import_react3.useState)(() => stringOrUndefined(type)); 5876 useSafeLayoutEffect(() => { 5877 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 5878 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type)); 5879 }, [refOrElement, type]); 5880 return tagName; 5881 } 5882 function useAttribute(refOrElement, attributeName, defaultValue2) { 5883 const initialValue = useInitialValue(defaultValue2); 5884 const [attribute, setAttribute] = (0, import_react3.useState)(initialValue); 5885 (0, import_react3.useEffect)(() => { 5886 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 5887 if (!element) return; 5888 const callback = () => { 5889 const value = element.getAttribute(attributeName); 5890 setAttribute(value == null ? initialValue : value); 5891 }; 5892 const observer = new MutationObserver(callback); 5893 observer.observe(element, { attributeFilter: [attributeName] }); 5894 callback(); 5895 return () => observer.disconnect(); 5896 }, [refOrElement, attributeName, initialValue]); 5897 return attribute; 5898 } 5899 function useUpdateEffect(effect, deps) { 5900 const mounted = (0, import_react3.useRef)(false); 5901 (0, import_react3.useEffect)(() => { 5902 if (mounted.current) { 5903 return effect(); 5904 } 5905 mounted.current = true; 5906 }, deps); 5907 (0, import_react3.useEffect)( 5908 () => () => { 5909 mounted.current = false; 5910 }, 5911 [] 5912 ); 5913 } 5914 function useUpdateLayoutEffect(effect, deps) { 5915 const mounted = (0, import_react3.useRef)(false); 5916 useSafeLayoutEffect(() => { 5917 if (mounted.current) { 5918 return effect(); 5919 } 5920 mounted.current = true; 5921 }, deps); 5922 useSafeLayoutEffect( 5923 () => () => { 5924 mounted.current = false; 5925 }, 5926 [] 5927 ); 5928 } 5929 function useForceUpdate() { 5930 return (0, import_react3.useReducer)(() => [], []); 5931 } 5932 function useBooleanEvent(booleanOrCallback) { 5933 return useEvent( 5934 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback 5935 ); 5936 } 5937 function useWrapElement(props, callback, deps = []) { 5938 const wrapElement = (0, import_react3.useCallback)( 5939 (element) => { 5940 if (props.wrapElement) { 5941 element = props.wrapElement(element); 5942 } 5943 return callback(element); 5944 }, 5945 [...deps, props.wrapElement] 5946 ); 5947 return __spreadProps(__spreadValues({}, props), { wrapElement }); 5948 } 5949 function useMetadataProps(props, key, value) { 5950 const parent = props.onLoadedMetadataCapture; 5951 const onLoadedMetadataCapture = (0, import_react3.useMemo)(() => { 5952 return Object.assign(() => { 5953 }, __spreadProps(__spreadValues({}, parent), { [key]: value })); 5954 }, [parent, key, value]); 5955 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }]; 5956 } 5957 function useIsMouseMoving() { 5958 (0, import_react3.useEffect)(() => { 5959 addGlobalEventListener("mousemove", setMouseMoving, true); 5960 addGlobalEventListener("mousedown", resetMouseMoving, true); 5961 addGlobalEventListener("mouseup", resetMouseMoving, true); 5962 addGlobalEventListener("keydown", resetMouseMoving, true); 5963 addGlobalEventListener("scroll", resetMouseMoving, true); 5964 }, []); 5965 const isMouseMoving = useEvent(() => mouseMoving); 5966 return isMouseMoving; 5967 } 5968 var mouseMoving = false; 5969 var previousScreenX = 0; 5970 var previousScreenY = 0; 5971 function hasMouseMovement(event) { 5972 const movementX = event.movementX || event.screenX - previousScreenX; 5973 const movementY = event.movementY || event.screenY - previousScreenY; 5974 previousScreenX = event.screenX; 5975 previousScreenY = event.screenY; 5976 return movementX || movementY || false; 5977 } 5978 function setMouseMoving(event) { 5979 if (!hasMouseMovement(event)) return; 5980 mouseMoving = true; 5981 } 5982 function resetMouseMoving() { 5983 mouseMoving = false; 5984 } 5985 5986 // node_modules/@ariakit/react-core/esm/__chunks/LMDWO4NN.js 5987 var React3 = __toESM(require_react(), 1); 5988 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1); 5989 function forwardRef22(render4) { 5990 const Role = React3.forwardRef((props, ref) => render4(__spreadProps(__spreadValues({}, props), { ref }))); 5991 Role.displayName = render4.displayName || render4.name; 5992 return Role; 5993 } 5994 function memo22(Component, propsAreEqual) { 5995 return React3.memo(Component, propsAreEqual); 5996 } 5997 function createElement2(Type, props) { 5998 const _a = props, { wrapElement, render: render4 } = _a, rest = __objRest(_a, ["wrapElement", "render"]); 5999 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4)); 6000 let element; 6001 if (React3.isValidElement(render4)) { 6002 const renderProps = __spreadProps(__spreadValues({}, render4.props), { ref: mergedRef }); 6003 element = React3.cloneElement(render4, mergeProps(rest, renderProps)); 6004 } else if (render4) { 6005 element = render4(rest); 6006 } else { 6007 element = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Type, __spreadValues({}, rest)); 6008 } 6009 if (wrapElement) { 6010 return wrapElement(element); 6011 } 6012 return element; 6013 } 6014 function createHook(useProps) { 6015 const useRole = (props = {}) => { 6016 return useProps(props); 6017 }; 6018 useRole.displayName = useProps.name; 6019 return useRole; 6020 } 6021 function createStoreContext(providers = [], scopedProviders = []) { 6022 const context = React3.createContext(void 0); 6023 const scopedContext = React3.createContext(void 0); 6024 const useContext28 = () => React3.useContext(context); 6025 const useScopedContext = (onlyScoped = false) => { 6026 const scoped = React3.useContext(scopedContext); 6027 const store = useContext28(); 6028 if (onlyScoped) return scoped; 6029 return scoped || store; 6030 }; 6031 const useProviderContext = () => { 6032 const scoped = React3.useContext(scopedContext); 6033 const store = useContext28(); 6034 if (scoped && scoped === store) return; 6035 return store; 6036 }; 6037 const ContextProvider = (props) => { 6038 return providers.reduceRight( 6039 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Provider, __spreadProps(__spreadValues({}, props), { children })), 6040 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(context.Provider, __spreadValues({}, props)) 6041 ); 6042 }; 6043 const ScopedContextProvider = (props) => { 6044 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ContextProvider, __spreadProps(__spreadValues({}, props), { children: scopedProviders.reduceRight( 6045 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Provider, __spreadProps(__spreadValues({}, props), { children })), 6046 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(scopedContext.Provider, __spreadValues({}, props)) 6047 ) })); 6048 }; 6049 return { 6050 context, 6051 scopedContext, 6052 useContext: useContext28, 6053 useScopedContext, 6054 useProviderContext, 6055 ContextProvider, 6056 ScopedContextProvider 6057 }; 6058 } 6059 6060 // node_modules/@ariakit/react-core/esm/__chunks/VDHZ5F7K.js 6061 var ctx = createStoreContext(); 6062 var useCollectionContext = ctx.useContext; 6063 var useCollectionScopedContext = ctx.useScopedContext; 6064 var useCollectionProviderContext = ctx.useProviderContext; 6065 var CollectionContextProvider = ctx.ContextProvider; 6066 var CollectionScopedContextProvider = ctx.ScopedContextProvider; 6067 6068 // node_modules/@ariakit/react-core/esm/__chunks/P7GR5CS5.js 6069 var import_react4 = __toESM(require_react(), 1); 6070 var ctx2 = createStoreContext( 6071 [CollectionContextProvider], 6072 [CollectionScopedContextProvider] 6073 ); 6074 var useCompositeContext = ctx2.useContext; 6075 var useCompositeScopedContext = ctx2.useScopedContext; 6076 var useCompositeProviderContext = ctx2.useProviderContext; 6077 var CompositeContextProvider = ctx2.ContextProvider; 6078 var CompositeScopedContextProvider = ctx2.ScopedContextProvider; 6079 var CompositeItemContext = (0, import_react4.createContext)( 6080 void 0 6081 ); 6082 var CompositeRowContext = (0, import_react4.createContext)( 6083 void 0 6084 ); 6085 6086 // node_modules/@ariakit/react-core/esm/__chunks/3XAVFTCA.js 6087 var import_react5 = __toESM(require_react(), 1); 6088 var TagValueContext = (0, import_react5.createContext)(null); 6089 var TagRemoveIdContext = (0, import_react5.createContext)( 6090 null 6091 ); 6092 var ctx3 = createStoreContext( 6093 [CompositeContextProvider], 6094 [CompositeScopedContextProvider] 6095 ); 6096 var useTagContext = ctx3.useContext; 6097 var useTagScopedContext = ctx3.useScopedContext; 6098 var useTagProviderContext = ctx3.useProviderContext; 6099 var TagContextProvider = ctx3.ContextProvider; 6100 var TagScopedContextProvider = ctx3.ScopedContextProvider; 6101 6102 // node_modules/@ariakit/core/esm/__chunks/BCALMBPZ.js 6103 function getInternal(store, key) { 6104 const internals = store.__unstableInternals; 6105 invariant(internals, "Invalid store"); 6106 return internals[key]; 6107 } 6108 function createStore(initialState, ...stores) { 6109 let state = initialState; 6110 let prevStateBatch = state; 6111 let lastUpdate = Symbol(); 6112 let destroy = noop; 6113 const instances = /* @__PURE__ */ new Set(); 6114 const updatedKeys = /* @__PURE__ */ new Set(); 6115 const setups = /* @__PURE__ */ new Set(); 6116 const listeners = /* @__PURE__ */ new Set(); 6117 const batchListeners = /* @__PURE__ */ new Set(); 6118 const disposables = /* @__PURE__ */ new WeakMap(); 6119 const listenerKeys = /* @__PURE__ */ new WeakMap(); 6120 const storeSetup = (callback) => { 6121 setups.add(callback); 6122 return () => setups.delete(callback); 6123 }; 6124 const storeInit = () => { 6125 const initialized = instances.size; 6126 const instance = Symbol(); 6127 instances.add(instance); 6128 const maybeDestroy = () => { 6129 instances.delete(instance); 6130 if (instances.size) return; 6131 destroy(); 6132 }; 6133 if (initialized) return maybeDestroy; 6134 const desyncs = getKeys(state).map( 6135 (key) => chain( 6136 ...stores.map((store) => { 6137 var _a; 6138 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store); 6139 if (!storeState) return; 6140 if (!hasOwnProperty(storeState, key)) return; 6141 return sync(store, [key], (state2) => { 6142 setState( 6143 key, 6144 state2[key], 6145 // @ts-expect-error - Not public API. This is just to prevent 6146 // infinite loops. 6147 true 6148 ); 6149 }); 6150 }) 6151 ) 6152 ); 6153 const teardowns = []; 6154 for (const setup2 of setups) { 6155 teardowns.push(setup2()); 6156 } 6157 const cleanups = stores.map(init); 6158 destroy = chain(...desyncs, ...teardowns, ...cleanups); 6159 return maybeDestroy; 6160 }; 6161 const sub = (keys, listener, set = listeners) => { 6162 set.add(listener); 6163 listenerKeys.set(listener, keys); 6164 return () => { 6165 var _a; 6166 (_a = disposables.get(listener)) == null ? void 0 : _a(); 6167 disposables.delete(listener); 6168 listenerKeys.delete(listener); 6169 set.delete(listener); 6170 }; 6171 }; 6172 const storeSubscribe = (keys, listener) => sub(keys, listener); 6173 const storeSync = (keys, listener) => { 6174 disposables.set(listener, listener(state, state)); 6175 return sub(keys, listener); 6176 }; 6177 const storeBatch = (keys, listener) => { 6178 disposables.set(listener, listener(state, prevStateBatch)); 6179 return sub(keys, listener, batchListeners); 6180 }; 6181 const storePick = (keys) => createStore(pick(state, keys), finalStore); 6182 const storeOmit = (keys) => createStore(omit2(state, keys), finalStore); 6183 const getState = () => state; 6184 const setState = (key, value, fromStores = false) => { 6185 var _a; 6186 if (!hasOwnProperty(state, key)) return; 6187 const nextValue = applyState(value, state[key]); 6188 if (nextValue === state[key]) return; 6189 if (!fromStores) { 6190 for (const store of stores) { 6191 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue); 6192 } 6193 } 6194 const prevState = state; 6195 state = __spreadProps2(__spreadValues2({}, state), { [key]: nextValue }); 6196 const thisUpdate = Symbol(); 6197 lastUpdate = thisUpdate; 6198 updatedKeys.add(key); 6199 const run = (listener, prev, uKeys) => { 6200 var _a2; 6201 const keys = listenerKeys.get(listener); 6202 const updated = (k) => uKeys ? uKeys.has(k) : k === key; 6203 if (!keys || keys.some(updated)) { 6204 (_a2 = disposables.get(listener)) == null ? void 0 : _a2(); 6205 disposables.set(listener, listener(state, prev)); 6206 } 6207 }; 6208 for (const listener of listeners) { 6209 run(listener, prevState); 6210 } 6211 queueMicrotask(() => { 6212 if (lastUpdate !== thisUpdate) return; 6213 const snapshot = state; 6214 for (const listener of batchListeners) { 6215 run(listener, prevStateBatch, updatedKeys); 6216 } 6217 prevStateBatch = snapshot; 6218 updatedKeys.clear(); 6219 }); 6220 }; 6221 const finalStore = { 6222 getState, 6223 setState, 6224 __unstableInternals: { 6225 setup: storeSetup, 6226 init: storeInit, 6227 subscribe: storeSubscribe, 6228 sync: storeSync, 6229 batch: storeBatch, 6230 pick: storePick, 6231 omit: storeOmit 6232 } 6233 }; 6234 return finalStore; 6235 } 6236 function setup(store, ...args) { 6237 if (!store) return; 6238 return getInternal(store, "setup")(...args); 6239 } 6240 function init(store, ...args) { 6241 if (!store) return; 6242 return getInternal(store, "init")(...args); 6243 } 6244 function subscribe(store, ...args) { 6245 if (!store) return; 6246 return getInternal(store, "subscribe")(...args); 6247 } 6248 function sync(store, ...args) { 6249 if (!store) return; 6250 return getInternal(store, "sync")(...args); 6251 } 6252 function batch(store, ...args) { 6253 if (!store) return; 6254 return getInternal(store, "batch")(...args); 6255 } 6256 function omit22(store, ...args) { 6257 if (!store) return; 6258 return getInternal(store, "omit")(...args); 6259 } 6260 function pick2(store, ...args) { 6261 if (!store) return; 6262 return getInternal(store, "pick")(...args); 6263 } 6264 function mergeStore(...stores) { 6265 const initialState = stores.reduce((state, store2) => { 6266 var _a; 6267 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2); 6268 if (!nextState) return state; 6269 return Object.assign(state, nextState); 6270 }, {}); 6271 const store = createStore(initialState, ...stores); 6272 return Object.assign({}, ...stores, store); 6273 } 6274 function throwOnConflictingProps(props, store) { 6275 if (false) return; 6276 if (!store) return; 6277 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => { 6278 var _a; 6279 const stateKey = key.replace("default", ""); 6280 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}$stateKey.slice(1)}`; 6281 }); 6282 if (!defaultKeys.length) return; 6283 const storeState = store.getState(); 6284 const conflictingProps = defaultKeys.filter( 6285 (key) => hasOwnProperty(storeState, key) 6286 ); 6287 if (!conflictingProps.length) return; 6288 throw new Error( 6289 `Passing a store prop in conjunction with a default state is not supported. 6290 6291 const store = useSelectStore(); 6292 <SelectProvider store={store} defaultValue="Apple" /> 6293 ^ ^ 6294 6295 Instead, pass the default state to the topmost store: 6296 6297 const store = useSelectStore({ defaultValue: "Apple" }); 6298 <SelectProvider store={store} /> 6299 6300 See https://github.com/ariakit/ariakit/pull/2745 for more details. 6301 6302 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit 6303 ` 6304 ); 6305 } 6306 6307 // node_modules/@ariakit/react-core/esm/__chunks/YV4JVR4I.js 6308 var React4 = __toESM(require_react(), 1); 6309 var import_shim = __toESM(require_shim(), 1); 6310 var { useSyncExternalStore } = import_shim.default; 6311 var noopSubscribe = () => () => { 6312 }; 6313 function useStoreState(store, keyOrSelector = identity) { 6314 const storeSubscribe = React4.useCallback( 6315 (callback) => { 6316 if (!store) return noopSubscribe(); 6317 return subscribe(store, null, callback); 6318 }, 6319 [store] 6320 ); 6321 const getSnapshot = () => { 6322 const key = typeof keyOrSelector === "string" ? keyOrSelector : null; 6323 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null; 6324 const state = store == null ? void 0 : store.getState(); 6325 if (selector2) return selector2(state); 6326 if (!state) return; 6327 if (!key) return; 6328 if (!hasOwnProperty(state, key)) return; 6329 return state[key]; 6330 }; 6331 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot); 6332 } 6333 function useStoreStateObject(store, object) { 6334 const objRef = React4.useRef( 6335 {} 6336 ); 6337 const storeSubscribe = React4.useCallback( 6338 (callback) => { 6339 if (!store) return noopSubscribe(); 6340 return subscribe(store, null, callback); 6341 }, 6342 [store] 6343 ); 6344 const getSnapshot = () => { 6345 const state = store == null ? void 0 : store.getState(); 6346 let updated = false; 6347 const obj = objRef.current; 6348 for (const prop in object) { 6349 const keyOrSelector = object[prop]; 6350 if (typeof keyOrSelector === "function") { 6351 const value = keyOrSelector(state); 6352 if (value !== obj[prop]) { 6353 obj[prop] = value; 6354 updated = true; 6355 } 6356 } 6357 if (typeof keyOrSelector === "string") { 6358 if (!state) continue; 6359 if (!hasOwnProperty(state, keyOrSelector)) continue; 6360 const value = state[keyOrSelector]; 6361 if (value !== obj[prop]) { 6362 obj[prop] = value; 6363 updated = true; 6364 } 6365 } 6366 } 6367 if (updated) { 6368 objRef.current = __spreadValues({}, obj); 6369 } 6370 return objRef.current; 6371 }; 6372 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot); 6373 } 6374 function useStoreProps(store, props, key, setKey) { 6375 const value = hasOwnProperty(props, key) ? props[key] : void 0; 6376 const setValue = setKey ? props[setKey] : void 0; 6377 const propsRef = useLiveRef({ value, setValue }); 6378 useSafeLayoutEffect(() => { 6379 return sync(store, [key], (state, prev) => { 6380 const { value: value2, setValue: setValue2 } = propsRef.current; 6381 if (!setValue2) return; 6382 if (state[key] === prev[key]) return; 6383 if (state[key] === value2) return; 6384 setValue2(state[key]); 6385 }); 6386 }, [store, key]); 6387 useSafeLayoutEffect(() => { 6388 if (value === void 0) return; 6389 store.setState(key, value); 6390 return batch(store, [key], () => { 6391 if (value === void 0) return; 6392 store.setState(key, value); 6393 }); 6394 }); 6395 } 6396 function useStore(createStore2, props) { 6397 const [store, setStore] = React4.useState(() => createStore2(props)); 6398 useSafeLayoutEffect(() => init(store), [store]); 6399 const useState27 = React4.useCallback( 6400 (keyOrSelector) => useStoreState(store, keyOrSelector), 6401 [store] 6402 ); 6403 const memoizedStore = React4.useMemo( 6404 () => __spreadProps(__spreadValues({}, store), { useState: useState27 }), 6405 [store, useState27] 6406 ); 6407 const updateStore = useEvent(() => { 6408 setStore((store2) => createStore2(__spreadValues(__spreadValues({}, props), store2.getState()))); 6409 }); 6410 return [memoizedStore, updateStore]; 6411 } 6412 6413 // node_modules/@ariakit/core/esm/__chunks/CYQWQL4J.js 6414 function getCommonParent(items) { 6415 var _a; 6416 const firstItem = items.find((item) => !!item.element); 6417 const lastItem = [...items].reverse().find((item) => !!item.element); 6418 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement; 6419 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) { 6420 const parent = parentElement; 6421 if (lastItem && parent.contains(lastItem.element)) { 6422 return parentElement; 6423 } 6424 parentElement = parentElement.parentElement; 6425 } 6426 return getDocument(parentElement).body; 6427 } 6428 function getPrivateStore(store) { 6429 return store == null ? void 0 : store.__unstablePrivateStore; 6430 } 6431 function createCollectionStore(props = {}) { 6432 var _a; 6433 throwOnConflictingProps(props, props.store); 6434 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 6435 const items = defaultValue( 6436 props.items, 6437 syncState == null ? void 0 : syncState.items, 6438 props.defaultItems, 6439 [] 6440 ); 6441 const itemsMap = new Map(items.map((item) => [item.id, item])); 6442 const initialState = { 6443 items, 6444 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, []) 6445 }; 6446 const syncPrivateStore = getPrivateStore(props.store); 6447 const privateStore = createStore( 6448 { items, renderedItems: initialState.renderedItems }, 6449 syncPrivateStore 6450 ); 6451 const collection = createStore(initialState, props.store); 6452 const sortItems = (renderedItems) => { 6453 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element); 6454 privateStore.setState("renderedItems", sortedItems); 6455 collection.setState("renderedItems", sortedItems); 6456 }; 6457 setup(collection, () => init(privateStore)); 6458 setup(privateStore, () => { 6459 return batch(privateStore, ["items"], (state) => { 6460 collection.setState("items", state.items); 6461 }); 6462 }); 6463 setup(privateStore, () => { 6464 return batch(privateStore, ["renderedItems"], (state) => { 6465 let firstRun = true; 6466 let raf = requestAnimationFrame(() => { 6467 const { renderedItems } = collection.getState(); 6468 if (state.renderedItems === renderedItems) return; 6469 sortItems(state.renderedItems); 6470 }); 6471 if (typeof IntersectionObserver !== "function") { 6472 return () => cancelAnimationFrame(raf); 6473 } 6474 const ioCallback = () => { 6475 if (firstRun) { 6476 firstRun = false; 6477 return; 6478 } 6479 cancelAnimationFrame(raf); 6480 raf = requestAnimationFrame(() => sortItems(state.renderedItems)); 6481 }; 6482 const root = getCommonParent(state.renderedItems); 6483 const observer = new IntersectionObserver(ioCallback, { root }); 6484 for (const item of state.renderedItems) { 6485 if (!item.element) continue; 6486 observer.observe(item.element); 6487 } 6488 return () => { 6489 cancelAnimationFrame(raf); 6490 observer.disconnect(); 6491 }; 6492 }); 6493 }); 6494 const mergeItem = (item, setItems, canDeleteFromMap = false) => { 6495 let prevItem; 6496 setItems((items2) => { 6497 const index = items2.findIndex(({ id }) => id === item.id); 6498 const nextItems = items2.slice(); 6499 if (index !== -1) { 6500 prevItem = items2[index]; 6501 const nextItem = __spreadValues2(__spreadValues2({}, prevItem), item); 6502 nextItems[index] = nextItem; 6503 itemsMap.set(item.id, nextItem); 6504 } else { 6505 nextItems.push(item); 6506 itemsMap.set(item.id, item); 6507 } 6508 return nextItems; 6509 }); 6510 const unmergeItem = () => { 6511 setItems((items2) => { 6512 if (!prevItem) { 6513 if (canDeleteFromMap) { 6514 itemsMap.delete(item.id); 6515 } 6516 return items2.filter(({ id }) => id !== item.id); 6517 } 6518 const index = items2.findIndex(({ id }) => id === item.id); 6519 if (index === -1) return items2; 6520 const nextItems = items2.slice(); 6521 nextItems[index] = prevItem; 6522 itemsMap.set(item.id, prevItem); 6523 return nextItems; 6524 }); 6525 }; 6526 return unmergeItem; 6527 }; 6528 const registerItem = (item) => mergeItem( 6529 item, 6530 (getItems) => privateStore.setState("items", getItems), 6531 true 6532 ); 6533 return __spreadProps2(__spreadValues2({}, collection), { 6534 registerItem, 6535 renderItem: (item) => chain( 6536 registerItem(item), 6537 mergeItem( 6538 item, 6539 (getItems) => privateStore.setState("renderedItems", getItems) 6540 ) 6541 ), 6542 item: (id) => { 6543 if (!id) return null; 6544 let item = itemsMap.get(id); 6545 if (!item) { 6546 const { items: items2 } = privateStore.getState(); 6547 item = items2.find((item2) => item2.id === id); 6548 if (item) { 6549 itemsMap.set(id, item); 6550 } 6551 } 6552 return item || null; 6553 }, 6554 // @ts-expect-error Internal 6555 __unstablePrivateStore: privateStore 6556 }); 6557 } 6558 6559 // node_modules/@ariakit/react-core/esm/__chunks/C3IKGW5T.js 6560 function useCollectionStoreProps(store, update, props) { 6561 useUpdateEffect(update, [props.store]); 6562 useStoreProps(store, props, "items", "setItems"); 6563 return store; 6564 } 6565 6566 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js 6567 function toArray(arg) { 6568 if (Array.isArray(arg)) { 6569 return arg; 6570 } 6571 return typeof arg !== "undefined" ? [arg] : []; 6572 } 6573 function flatten2DArray(array) { 6574 const flattened = []; 6575 for (const row of array) { 6576 flattened.push(...row); 6577 } 6578 return flattened; 6579 } 6580 function reverseArray(array) { 6581 return array.slice().reverse(); 6582 } 6583 6584 // node_modules/@ariakit/core/esm/__chunks/AJZ4BYF3.js 6585 var NULL_ITEM = { id: null }; 6586 function findFirstEnabledItem(items, excludeId) { 6587 return items.find((item) => { 6588 if (excludeId) { 6589 return !item.disabled && item.id !== excludeId; 6590 } 6591 return !item.disabled; 6592 }); 6593 } 6594 function getEnabledItems(items, excludeId) { 6595 return items.filter((item) => { 6596 if (excludeId) { 6597 return !item.disabled && item.id !== excludeId; 6598 } 6599 return !item.disabled; 6600 }); 6601 } 6602 function getItemsInRow(items, rowId) { 6603 return items.filter((item) => item.rowId === rowId); 6604 } 6605 function flipItems(items, activeId, shouldInsertNullItem = false) { 6606 const index = items.findIndex((item) => item.id === activeId); 6607 return [ 6608 ...items.slice(index + 1), 6609 ...shouldInsertNullItem ? [NULL_ITEM] : [], 6610 ...items.slice(0, index) 6611 ]; 6612 } 6613 function groupItemsByRows(items) { 6614 const rows = []; 6615 for (const item of items) { 6616 const row = rows.find((currentRow) => { 6617 var _a; 6618 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 6619 }); 6620 if (row) { 6621 row.push(item); 6622 } else { 6623 rows.push([item]); 6624 } 6625 } 6626 return rows; 6627 } 6628 function getMaxRowLength(array) { 6629 let maxLength = 0; 6630 for (const { length } of array) { 6631 if (length > maxLength) { 6632 maxLength = length; 6633 } 6634 } 6635 return maxLength; 6636 } 6637 function createEmptyItem(rowId) { 6638 return { 6639 id: "__EMPTY_ITEM__", 6640 disabled: true, 6641 rowId 6642 }; 6643 } 6644 function normalizeRows(rows, activeId, focusShift) { 6645 const maxLength = getMaxRowLength(rows); 6646 for (const row of rows) { 6647 for (let i2 = 0; i2 < maxLength; i2 += 1) { 6648 const item = row[i2]; 6649 if (!item || focusShift && item.disabled) { 6650 const isFirst = i2 === 0; 6651 const previousItem = isFirst && focusShift ? findFirstEnabledItem(row) : row[i2 - 1]; 6652 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId); 6653 } 6654 } 6655 } 6656 return rows; 6657 } 6658 function verticalizeItems(items) { 6659 const rows = groupItemsByRows(items); 6660 const maxLength = getMaxRowLength(rows); 6661 const verticalized = []; 6662 for (let i2 = 0; i2 < maxLength; i2 += 1) { 6663 for (const row of rows) { 6664 const item = row[i2]; 6665 if (item) { 6666 verticalized.push(__spreadProps2(__spreadValues2({}, item), { 6667 // If there's no rowId, it means that it's not a grid composite, but 6668 // a single row instead. So, instead of verticalizing it, that is, 6669 // assigning a different rowId based on the column index, we keep it 6670 // undefined so they will be part of the same row. This is useful 6671 // when using up/down on one-dimensional composites. 6672 rowId: item.rowId ? `$i2}` : void 0 6673 })); 6674 } 6675 } 6676 } 6677 return verticalized; 6678 } 6679 function createCompositeStore(props = {}) { 6680 var _a; 6681 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 6682 const collection = createCollectionStore(props); 6683 const activeId = defaultValue( 6684 props.activeId, 6685 syncState == null ? void 0 : syncState.activeId, 6686 props.defaultActiveId 6687 ); 6688 const initialState = __spreadProps2(__spreadValues2({}, collection.getState()), { 6689 id: defaultValue( 6690 props.id, 6691 syncState == null ? void 0 : syncState.id, 6692 `id-$Math.random().toString(36).slice(2, 8)}` 6693 ), 6694 activeId, 6695 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null), 6696 includesBaseElement: defaultValue( 6697 props.includesBaseElement, 6698 syncState == null ? void 0 : syncState.includesBaseElement, 6699 activeId === null 6700 ), 6701 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0), 6702 orientation: defaultValue( 6703 props.orientation, 6704 syncState == null ? void 0 : syncState.orientation, 6705 "both" 6706 ), 6707 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false), 6708 virtualFocus: defaultValue( 6709 props.virtualFocus, 6710 syncState == null ? void 0 : syncState.virtualFocus, 6711 false 6712 ), 6713 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false), 6714 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false), 6715 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false) 6716 }); 6717 const composite = createStore(initialState, collection, props.store); 6718 setup( 6719 composite, 6720 () => sync(composite, ["renderedItems", "activeId"], (state) => { 6721 composite.setState("activeId", (activeId2) => { 6722 var _a2; 6723 if (activeId2 !== void 0) return activeId2; 6724 return (_a2 = findFirstEnabledItem(state.renderedItems)) == null ? void 0 : _a2.id; 6725 }); 6726 }) 6727 ); 6728 const getNextId = (direction = "next", options = {}) => { 6729 var _a2, _b; 6730 const defaultState = composite.getState(); 6731 const { 6732 skip = 0, 6733 activeId: activeId2 = defaultState.activeId, 6734 focusShift = defaultState.focusShift, 6735 focusLoop = defaultState.focusLoop, 6736 focusWrap = defaultState.focusWrap, 6737 includesBaseElement = defaultState.includesBaseElement, 6738 renderedItems = defaultState.renderedItems, 6739 rtl = defaultState.rtl 6740 } = options; 6741 const isVerticalDirection = direction === "up" || direction === "down"; 6742 const isNextDirection = direction === "next" || direction === "down"; 6743 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection; 6744 const canShift = focusShift && !skip; 6745 let items = !isVerticalDirection ? renderedItems : flatten2DArray( 6746 normalizeRows(groupItemsByRows(renderedItems), activeId2, canShift) 6747 ); 6748 items = canReverse ? reverseArray(items) : items; 6749 items = isVerticalDirection ? verticalizeItems(items) : items; 6750 if (activeId2 == null) { 6751 return (_a2 = findFirstEnabledItem(items)) == null ? void 0 : _a2.id; 6752 } 6753 const activeItem = items.find((item) => item.id === activeId2); 6754 if (!activeItem) { 6755 return (_b = findFirstEnabledItem(items)) == null ? void 0 : _b.id; 6756 } 6757 const isGrid2 = items.some((item) => item.rowId); 6758 const activeIndex = items.indexOf(activeItem); 6759 const nextItems = items.slice(activeIndex + 1); 6760 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId); 6761 if (skip) { 6762 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2); 6763 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one. 6764 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1]; 6765 return nextItem2 == null ? void 0 : nextItem2.id; 6766 } 6767 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical"); 6768 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical"); 6769 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false; 6770 if (canLoop) { 6771 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId); 6772 const sortedItems = flipItems(loopItems, activeId2, hasNullItem); 6773 const nextItem2 = findFirstEnabledItem(sortedItems, activeId2); 6774 return nextItem2 == null ? void 0 : nextItem2.id; 6775 } 6776 if (canWrap) { 6777 const nextItem2 = findFirstEnabledItem( 6778 // We can use nextItems, which contains all the next items, including 6779 // items from other rows, to wrap between rows. However, if there is a 6780 // null item (the composite container), we'll only use the next items in 6781 // the row. So moving next from the last item will focus on the 6782 // composite container. On grid composites, horizontal navigation never 6783 // focuses on the composite container, only vertical. 6784 hasNullItem ? nextItemsInRow : nextItems, 6785 activeId2 6786 ); 6787 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id; 6788 return nextId; 6789 } 6790 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2); 6791 if (!nextItem && hasNullItem) { 6792 return null; 6793 } 6794 return nextItem == null ? void 0 : nextItem.id; 6795 }; 6796 return __spreadProps2(__spreadValues2(__spreadValues2({}, collection), composite), { 6797 setBaseElement: (element) => composite.setState("baseElement", element), 6798 setActiveId: (id) => composite.setState("activeId", id), 6799 move: (id) => { 6800 if (id === void 0) return; 6801 composite.setState("activeId", id); 6802 composite.setState("moves", (moves) => moves + 1); 6803 }, 6804 first: () => { 6805 var _a2; 6806 return (_a2 = findFirstEnabledItem(composite.getState().renderedItems)) == null ? void 0 : _a2.id; 6807 }, 6808 last: () => { 6809 var _a2; 6810 return (_a2 = findFirstEnabledItem(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id; 6811 }, 6812 next: (options) => { 6813 if (options !== void 0 && typeof options === "number") { 6814 options = { skip: options }; 6815 } 6816 return getNextId("next", options); 6817 }, 6818 previous: (options) => { 6819 if (options !== void 0 && typeof options === "number") { 6820 options = { skip: options }; 6821 } 6822 return getNextId("previous", options); 6823 }, 6824 down: (options) => { 6825 if (options !== void 0 && typeof options === "number") { 6826 options = { skip: options }; 6827 } 6828 return getNextId("down", options); 6829 }, 6830 up: (options) => { 6831 if (options !== void 0 && typeof options === "number") { 6832 options = { skip: options }; 6833 } 6834 return getNextId("up", options); 6835 } 6836 }); 6837 } 6838 6839 // node_modules/@ariakit/react-core/esm/__chunks/4CMBR7SL.js 6840 function useCompositeStoreOptions(props) { 6841 const id = useId3(props.id); 6842 return __spreadValues({ id }, props); 6843 } 6844 function useCompositeStoreProps(store, update, props) { 6845 store = useCollectionStoreProps(store, update, props); 6846 useStoreProps(store, props, "activeId", "setActiveId"); 6847 useStoreProps(store, props, "includesBaseElement"); 6848 useStoreProps(store, props, "virtualFocus"); 6849 useStoreProps(store, props, "orientation"); 6850 useStoreProps(store, props, "rtl"); 6851 useStoreProps(store, props, "focusLoop"); 6852 useStoreProps(store, props, "focusWrap"); 6853 useStoreProps(store, props, "focusShift"); 6854 return store; 6855 } 6856 6857 // node_modules/@ariakit/core/esm/__chunks/RCQ5P4YE.js 6858 function createDisclosureStore(props = {}) { 6859 const store = mergeStore( 6860 props.store, 6861 omit22(props.disclosure, ["contentElement", "disclosureElement"]) 6862 ); 6863 throwOnConflictingProps(props, store); 6864 const syncState = store == null ? void 0 : store.getState(); 6865 const open = defaultValue( 6866 props.open, 6867 syncState == null ? void 0 : syncState.open, 6868 props.defaultOpen, 6869 false 6870 ); 6871 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false); 6872 const initialState = { 6873 open, 6874 animated, 6875 animating: !!animated && open, 6876 mounted: open, 6877 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null), 6878 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null) 6879 }; 6880 const disclosure = createStore(initialState, store); 6881 setup( 6882 disclosure, 6883 () => sync(disclosure, ["animated", "animating"], (state) => { 6884 if (state.animated) return; 6885 disclosure.setState("animating", false); 6886 }) 6887 ); 6888 setup( 6889 disclosure, 6890 () => subscribe(disclosure, ["open"], () => { 6891 if (!disclosure.getState().animated) return; 6892 disclosure.setState("animating", true); 6893 }) 6894 ); 6895 setup( 6896 disclosure, 6897 () => sync(disclosure, ["open", "animating"], (state) => { 6898 disclosure.setState("mounted", state.open || state.animating); 6899 }) 6900 ); 6901 return __spreadProps2(__spreadValues2({}, disclosure), { 6902 disclosure: props.disclosure, 6903 setOpen: (value) => disclosure.setState("open", value), 6904 show: () => disclosure.setState("open", true), 6905 hide: () => disclosure.setState("open", false), 6906 toggle: () => disclosure.setState("open", (open2) => !open2), 6907 stopAnimation: () => disclosure.setState("animating", false), 6908 setContentElement: (value) => disclosure.setState("contentElement", value), 6909 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value) 6910 }); 6911 } 6912 6913 // node_modules/@ariakit/react-core/esm/__chunks/WYCIER3C.js 6914 function useDisclosureStoreProps(store, update, props) { 6915 useUpdateEffect(update, [props.store, props.disclosure]); 6916 useStoreProps(store, props, "open", "setOpen"); 6917 useStoreProps(store, props, "mounted", "setMounted"); 6918 useStoreProps(store, props, "animated"); 6919 return Object.assign(store, { disclosure: props.disclosure }); 6920 } 6921 6922 // node_modules/@ariakit/core/esm/__chunks/FZZ2AVHF.js 6923 function createDialogStore(props = {}) { 6924 return createDisclosureStore(props); 6925 } 6926 6927 // node_modules/@ariakit/react-core/esm/__chunks/BM6PGYQY.js 6928 function useDialogStoreProps(store, update, props) { 6929 return useDisclosureStoreProps(store, update, props); 6930 } 6931 6932 // node_modules/@ariakit/core/esm/__chunks/ME2CUF3F.js 6933 function createPopoverStore(_a = {}) { 6934 var _b = _a, { 6935 popover: otherPopover 6936 } = _b, props = __objRest2(_b, [ 6937 "popover" 6938 ]); 6939 const store = mergeStore( 6940 props.store, 6941 omit22(otherPopover, [ 6942 "arrowElement", 6943 "anchorElement", 6944 "contentElement", 6945 "popoverElement", 6946 "disclosureElement" 6947 ]) 6948 ); 6949 throwOnConflictingProps(props, store); 6950 const syncState = store == null ? void 0 : store.getState(); 6951 const dialog = createDialogStore(__spreadProps2(__spreadValues2({}, props), { store })); 6952 const placement = defaultValue( 6953 props.placement, 6954 syncState == null ? void 0 : syncState.placement, 6955 "bottom" 6956 ); 6957 const initialState = __spreadProps2(__spreadValues2({}, dialog.getState()), { 6958 placement, 6959 currentPlacement: placement, 6960 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null), 6961 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null), 6962 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null), 6963 rendered: Symbol("rendered") 6964 }); 6965 const popover = createStore(initialState, dialog, store); 6966 return __spreadProps2(__spreadValues2(__spreadValues2({}, dialog), popover), { 6967 setAnchorElement: (element) => popover.setState("anchorElement", element), 6968 setPopoverElement: (element) => popover.setState("popoverElement", element), 6969 setArrowElement: (element) => popover.setState("arrowElement", element), 6970 render: () => popover.setState("rendered", Symbol("rendered")) 6971 }); 6972 } 6973 6974 // node_modules/@ariakit/react-core/esm/__chunks/O2PQ2652.js 6975 function usePopoverStoreProps(store, update, props) { 6976 useUpdateEffect(update, [props.popover]); 6977 useStoreProps(store, props, "placement"); 6978 return useDialogStoreProps(store, update, props); 6979 } 6980 6981 // node_modules/@ariakit/core/esm/combobox/combobox-store.js 6982 var isTouchSafari = isSafari() && isTouchDevice(); 6983 function createComboboxStore(_a = {}) { 6984 var _b = _a, { 6985 tag 6986 } = _b, props = __objRest2(_b, [ 6987 "tag" 6988 ]); 6989 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"])); 6990 throwOnConflictingProps(props, store); 6991 const tagState = tag == null ? void 0 : tag.getState(); 6992 const syncState = store == null ? void 0 : store.getState(); 6993 const activeId = defaultValue( 6994 props.activeId, 6995 syncState == null ? void 0 : syncState.activeId, 6996 props.defaultActiveId, 6997 null 6998 ); 6999 const composite = createCompositeStore(__spreadProps2(__spreadValues2({}, props), { 7000 activeId, 7001 includesBaseElement: defaultValue( 7002 props.includesBaseElement, 7003 syncState == null ? void 0 : syncState.includesBaseElement, 7004 true 7005 ), 7006 orientation: defaultValue( 7007 props.orientation, 7008 syncState == null ? void 0 : syncState.orientation, 7009 "vertical" 7010 ), 7011 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true), 7012 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true), 7013 virtualFocus: defaultValue( 7014 props.virtualFocus, 7015 syncState == null ? void 0 : syncState.virtualFocus, 7016 true 7017 ) 7018 })); 7019 const popover = createPopoverStore(__spreadProps2(__spreadValues2({}, props), { 7020 placement: defaultValue( 7021 props.placement, 7022 syncState == null ? void 0 : syncState.placement, 7023 "bottom-start" 7024 ) 7025 })); 7026 const value = defaultValue( 7027 props.value, 7028 syncState == null ? void 0 : syncState.value, 7029 props.defaultValue, 7030 "" 7031 ); 7032 const selectedValue = defaultValue( 7033 props.selectedValue, 7034 syncState == null ? void 0 : syncState.selectedValue, 7035 tagState == null ? void 0 : tagState.values, 7036 props.defaultSelectedValue, 7037 "" 7038 ); 7039 const multiSelectable = Array.isArray(selectedValue); 7040 const initialState = __spreadProps2(__spreadValues2(__spreadValues2({}, composite.getState()), popover.getState()), { 7041 value, 7042 selectedValue, 7043 resetValueOnSelect: defaultValue( 7044 props.resetValueOnSelect, 7045 syncState == null ? void 0 : syncState.resetValueOnSelect, 7046 multiSelectable 7047 ), 7048 resetValueOnHide: defaultValue( 7049 props.resetValueOnHide, 7050 syncState == null ? void 0 : syncState.resetValueOnHide, 7051 multiSelectable && !tag 7052 ), 7053 activeValue: syncState == null ? void 0 : syncState.activeValue 7054 }); 7055 const combobox = createStore(initialState, composite, popover, store); 7056 if (isTouchSafari) { 7057 setup( 7058 combobox, 7059 () => sync(combobox, ["virtualFocus"], () => { 7060 combobox.setState("virtualFocus", false); 7061 }) 7062 ); 7063 } 7064 setup(combobox, () => { 7065 if (!tag) return; 7066 return chain( 7067 sync(combobox, ["selectedValue"], (state) => { 7068 if (!Array.isArray(state.selectedValue)) return; 7069 tag.setValues(state.selectedValue); 7070 }), 7071 sync(tag, ["values"], (state) => { 7072 combobox.setState("selectedValue", state.values); 7073 }) 7074 ); 7075 }); 7076 setup( 7077 combobox, 7078 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => { 7079 if (!state.resetValueOnHide) return; 7080 if (state.mounted) return; 7081 combobox.setState("value", value); 7082 }) 7083 ); 7084 setup( 7085 combobox, 7086 () => sync(combobox, ["open"], (state) => { 7087 if (state.open) return; 7088 combobox.setState("activeId", activeId); 7089 combobox.setState("moves", 0); 7090 }) 7091 ); 7092 setup( 7093 combobox, 7094 () => sync(combobox, ["moves", "activeId"], (state, prevState) => { 7095 if (state.moves === prevState.moves) { 7096 combobox.setState("activeValue", void 0); 7097 } 7098 }) 7099 ); 7100 setup( 7101 combobox, 7102 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => { 7103 if (state.moves === prev.moves) return; 7104 const { activeId: activeId2 } = combobox.getState(); 7105 const activeItem = composite.item(activeId2); 7106 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value); 7107 }) 7108 ); 7109 return __spreadProps2(__spreadValues2(__spreadValues2(__spreadValues2({}, popover), composite), combobox), { 7110 tag, 7111 setValue: (value2) => combobox.setState("value", value2), 7112 resetValue: () => combobox.setState("value", initialState.value), 7113 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2) 7114 }); 7115 } 7116 7117 // node_modules/@ariakit/react-core/esm/__chunks/FEOFMWBY.js 7118 function useComboboxStoreOptions(props) { 7119 const tag = useTagContext(); 7120 props = __spreadProps(__spreadValues({}, props), { 7121 tag: props.tag !== void 0 ? props.tag : tag 7122 }); 7123 return useCompositeStoreOptions(props); 7124 } 7125 function useComboboxStoreProps(store, update, props) { 7126 useUpdateEffect(update, [props.tag]); 7127 useStoreProps(store, props, "value", "setValue"); 7128 useStoreProps(store, props, "selectedValue", "setSelectedValue"); 7129 useStoreProps(store, props, "resetValueOnHide"); 7130 useStoreProps(store, props, "resetValueOnSelect"); 7131 return Object.assign( 7132 useCompositeStoreProps( 7133 usePopoverStoreProps(store, update, props), 7134 update, 7135 props 7136 ), 7137 { tag: props.tag } 7138 ); 7139 } 7140 function useComboboxStore(props = {}) { 7141 props = useComboboxStoreOptions(props); 7142 const [store, update] = useStore(createComboboxStore, props); 7143 return useComboboxStoreProps(store, update, props); 7144 } 7145 7146 // node_modules/@ariakit/react-core/esm/__chunks/S6EF7IVO.js 7147 var ctx4 = createStoreContext(); 7148 var useDisclosureContext = ctx4.useContext; 7149 var useDisclosureScopedContext = ctx4.useScopedContext; 7150 var useDisclosureProviderContext = ctx4.useProviderContext; 7151 var DisclosureContextProvider = ctx4.ContextProvider; 7152 var DisclosureScopedContextProvider = ctx4.ScopedContextProvider; 7153 7154 // node_modules/@ariakit/react-core/esm/__chunks/RS7LB2H4.js 7155 var import_react6 = __toESM(require_react(), 1); 7156 var ctx5 = createStoreContext( 7157 [DisclosureContextProvider], 7158 [DisclosureScopedContextProvider] 7159 ); 7160 var useDialogContext = ctx5.useContext; 7161 var useDialogScopedContext = ctx5.useScopedContext; 7162 var useDialogProviderContext = ctx5.useProviderContext; 7163 var DialogContextProvider = ctx5.ContextProvider; 7164 var DialogScopedContextProvider = ctx5.ScopedContextProvider; 7165 var DialogHeadingContext = (0, import_react6.createContext)(void 0); 7166 var DialogDescriptionContext = (0, import_react6.createContext)(void 0); 7167 7168 // node_modules/@ariakit/react-core/esm/__chunks/MTZPJQMC.js 7169 var ctx6 = createStoreContext( 7170 [DialogContextProvider], 7171 [DialogScopedContextProvider] 7172 ); 7173 var usePopoverContext = ctx6.useContext; 7174 var usePopoverScopedContext = ctx6.useScopedContext; 7175 var usePopoverProviderContext = ctx6.useProviderContext; 7176 var PopoverContextProvider = ctx6.ContextProvider; 7177 var PopoverScopedContextProvider = ctx6.ScopedContextProvider; 7178 7179 // node_modules/@ariakit/react-core/esm/__chunks/VEVQD5MH.js 7180 var import_react7 = __toESM(require_react(), 1); 7181 var ComboboxListRoleContext = (0, import_react7.createContext)( 7182 void 0 7183 ); 7184 var ctx7 = createStoreContext( 7185 [PopoverContextProvider, CompositeContextProvider], 7186 [PopoverScopedContextProvider, CompositeScopedContextProvider] 7187 ); 7188 var useComboboxContext = ctx7.useContext; 7189 var useComboboxScopedContext = ctx7.useScopedContext; 7190 var useComboboxProviderContext = ctx7.useProviderContext; 7191 var ComboboxContextProvider = ctx7.ContextProvider; 7192 var ComboboxScopedContextProvider = ctx7.ScopedContextProvider; 7193 var ComboboxItemValueContext = (0, import_react7.createContext)( 7194 void 0 7195 ); 7196 var ComboboxItemCheckedContext = (0, import_react7.createContext)(false); 7197 7198 // node_modules/@ariakit/react-core/esm/__chunks/OMU7RWRV.js 7199 var TagName = "div"; 7200 var usePopoverAnchor = createHook( 7201 function usePopoverAnchor2(_a) { 7202 var _b = _a, { store } = _b, props = __objRest(_b, ["store"]); 7203 const context = usePopoverProviderContext(); 7204 store = store || context; 7205 props = __spreadProps(__spreadValues({}, props), { 7206 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref) 7207 }); 7208 return props; 7209 } 7210 ); 7211 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) { 7212 const htmlProps = usePopoverAnchor(props); 7213 return createElement2(TagName, htmlProps); 7214 }); 7215 7216 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js 7217 function findFirstEnabledItem2(items, excludeId) { 7218 return items.find((item) => { 7219 if (excludeId) { 7220 return !item.disabled && item.id !== excludeId; 7221 } 7222 return !item.disabled; 7223 }); 7224 } 7225 function getEnabledItem(store, id) { 7226 if (!id) return null; 7227 return store.item(id) || null; 7228 } 7229 function groupItemsByRows2(items) { 7230 const rows = []; 7231 for (const item of items) { 7232 const row = rows.find((currentRow) => { 7233 var _a; 7234 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 7235 }); 7236 if (row) { 7237 row.push(item); 7238 } else { 7239 rows.push([item]); 7240 } 7241 } 7242 return rows; 7243 } 7244 function selectTextField(element, collapseToEnd = false) { 7245 if (isTextField(element)) { 7246 element.setSelectionRange( 7247 collapseToEnd ? element.value.length : 0, 7248 element.value.length 7249 ); 7250 } else if (element.isContentEditable) { 7251 const selection = getDocument(element).getSelection(); 7252 selection == null ? void 0 : selection.selectAllChildren(element); 7253 if (collapseToEnd) { 7254 selection == null ? void 0 : selection.collapseToEnd(); 7255 } 7256 } 7257 } 7258 var FOCUS_SILENTLY = Symbol("FOCUS_SILENTLY"); 7259 function focusSilently(element) { 7260 element[FOCUS_SILENTLY] = true; 7261 element.focus({ preventScroll: true }); 7262 } 7263 function silentlyFocused(element) { 7264 const isSilentlyFocused = element[FOCUS_SILENTLY]; 7265 delete element[FOCUS_SILENTLY]; 7266 return isSilentlyFocused; 7267 } 7268 function isItem(store, element, exclude) { 7269 if (!element) return false; 7270 if (element === exclude) return false; 7271 const item = store.item(element.id); 7272 if (!item) return false; 7273 if (exclude && item.element === exclude) return false; 7274 return true; 7275 } 7276 7277 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js 7278 var import_react8 = __toESM(require_react(), 1); 7279 var FocusableContext = (0, import_react8.createContext)(true); 7280 7281 // node_modules/@ariakit/core/esm/utils/focus.js 7282 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'])"; 7283 function isFocusable(element) { 7284 if (!element.matches(selector)) return false; 7285 if (!isVisible(element)) return false; 7286 if (element.closest("[inert]")) return false; 7287 return true; 7288 } 7289 function getClosestFocusable(element) { 7290 while (element && !isFocusable(element)) { 7291 element = element.closest(selector); 7292 } 7293 return element || null; 7294 } 7295 function hasFocus(element) { 7296 const activeElement = getActiveElement(element); 7297 if (!activeElement) return false; 7298 if (activeElement === element) return true; 7299 const activeDescendant = activeElement.getAttribute("aria-activedescendant"); 7300 if (!activeDescendant) return false; 7301 return activeDescendant === element.id; 7302 } 7303 function hasFocusWithin(element) { 7304 const activeElement = getActiveElement(element); 7305 if (!activeElement) return false; 7306 if (contains(element, activeElement)) return true; 7307 const activeDescendant = activeElement.getAttribute("aria-activedescendant"); 7308 if (!activeDescendant) return false; 7309 if (!("id" in element)) return false; 7310 if (activeDescendant === element.id) return true; 7311 return !!element.querySelector(`#$CSS.escape(activeDescendant)}`); 7312 } 7313 function focusIfNeeded(element) { 7314 if (!hasFocusWithin(element) && isFocusable(element)) { 7315 element.focus(); 7316 } 7317 } 7318 function focusIntoView(element, options) { 7319 if (!("scrollIntoView" in element)) { 7320 element.focus(); 7321 } else { 7322 element.focus({ preventScroll: true }); 7323 element.scrollIntoView(__spreadValues2({ block: "nearest", inline: "nearest" }, options)); 7324 } 7325 } 7326 7327 // node_modules/@ariakit/react-core/esm/__chunks/LVA2YJMS.js 7328 var import_react9 = __toESM(require_react(), 1); 7329 var TagName2 = "div"; 7330 var isSafariBrowser = isSafari(); 7331 var alwaysFocusVisibleInputTypes = [ 7332 "text", 7333 "search", 7334 "url", 7335 "tel", 7336 "email", 7337 "password", 7338 "number", 7339 "date", 7340 "month", 7341 "week", 7342 "time", 7343 "datetime", 7344 "datetime-local" 7345 ]; 7346 var safariFocusAncestorSymbol = Symbol("safariFocusAncestor"); 7347 function markSafariFocusAncestor(element, value) { 7348 if (!element) return; 7349 element[safariFocusAncestorSymbol] = value; 7350 } 7351 function isAlwaysFocusVisible(element) { 7352 const { tagName, readOnly, type } = element; 7353 if (tagName === "TEXTAREA" && !readOnly) return true; 7354 if (tagName === "SELECT" && !readOnly) return true; 7355 if (tagName === "INPUT" && !readOnly) { 7356 return alwaysFocusVisibleInputTypes.includes(type); 7357 } 7358 if (element.isContentEditable) return true; 7359 const role = element.getAttribute("role"); 7360 if (role === "combobox" && element.dataset.name) { 7361 return true; 7362 } 7363 return false; 7364 } 7365 function getLabels(element) { 7366 if ("labels" in element) { 7367 return element.labels; 7368 } 7369 return null; 7370 } 7371 function isNativeCheckboxOrRadio(element) { 7372 const tagName = element.tagName.toLowerCase(); 7373 if (tagName === "input" && element.type) { 7374 return element.type === "radio" || element.type === "checkbox"; 7375 } 7376 return false; 7377 } 7378 function isNativeTabbable(tagName) { 7379 if (!tagName) return true; 7380 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a"; 7381 } 7382 function supportsDisabledAttribute(tagName) { 7383 if (!tagName) return true; 7384 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea"; 7385 } 7386 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) { 7387 if (!focusable) { 7388 return tabIndexProp; 7389 } 7390 if (trulyDisabled) { 7391 if (nativeTabbable && !supportsDisabled) { 7392 return -1; 7393 } 7394 return; 7395 } 7396 if (nativeTabbable) { 7397 return tabIndexProp; 7398 } 7399 return tabIndexProp || 0; 7400 } 7401 function useDisableEvent(onEvent, disabled) { 7402 return useEvent((event) => { 7403 onEvent == null ? void 0 : onEvent(event); 7404 if (event.defaultPrevented) return; 7405 if (disabled) { 7406 event.stopPropagation(); 7407 event.preventDefault(); 7408 } 7409 }); 7410 } 7411 var isKeyboardModality = true; 7412 function onGlobalMouseDown(event) { 7413 const target = event.target; 7414 if (target && "hasAttribute" in target) { 7415 if (!target.hasAttribute("data-focus-visible")) { 7416 isKeyboardModality = false; 7417 } 7418 } 7419 } 7420 function onGlobalKeyDown(event) { 7421 if (event.metaKey) return; 7422 if (event.ctrlKey) return; 7423 if (event.altKey) return; 7424 isKeyboardModality = true; 7425 } 7426 var useFocusable = createHook( 7427 function useFocusable2(_a) { 7428 var _b = _a, { 7429 focusable = true, 7430 accessibleWhenDisabled, 7431 autoFocus, 7432 onFocusVisible 7433 } = _b, props = __objRest(_b, [ 7434 "focusable", 7435 "accessibleWhenDisabled", 7436 "autoFocus", 7437 "onFocusVisible" 7438 ]); 7439 const ref = (0, import_react9.useRef)(null); 7440 (0, import_react9.useEffect)(() => { 7441 if (!focusable) return; 7442 addGlobalEventListener("mousedown", onGlobalMouseDown, true); 7443 addGlobalEventListener("keydown", onGlobalKeyDown, true); 7444 }, [focusable]); 7445 if (isSafariBrowser) { 7446 (0, import_react9.useEffect)(() => { 7447 if (!focusable) return; 7448 const element = ref.current; 7449 if (!element) return; 7450 if (!isNativeCheckboxOrRadio(element)) return; 7451 const labels = getLabels(element); 7452 if (!labels) return; 7453 const onMouseUp = () => queueMicrotask(() => element.focus()); 7454 for (const label of labels) { 7455 label.addEventListener("mouseup", onMouseUp); 7456 } 7457 return () => { 7458 for (const label of labels) { 7459 label.removeEventListener("mouseup", onMouseUp); 7460 } 7461 }; 7462 }, [focusable]); 7463 } 7464 const disabled = focusable && disabledFromProps(props); 7465 const trulyDisabled = !!disabled && !accessibleWhenDisabled; 7466 const [focusVisible, setFocusVisible] = (0, import_react9.useState)(false); 7467 (0, import_react9.useEffect)(() => { 7468 if (!focusable) return; 7469 if (trulyDisabled && focusVisible) { 7470 setFocusVisible(false); 7471 } 7472 }, [focusable, trulyDisabled, focusVisible]); 7473 (0, import_react9.useEffect)(() => { 7474 if (!focusable) return; 7475 if (!focusVisible) return; 7476 const element = ref.current; 7477 if (!element) return; 7478 if (typeof IntersectionObserver === "undefined") return; 7479 const observer = new IntersectionObserver(() => { 7480 if (!isFocusable(element)) { 7481 setFocusVisible(false); 7482 } 7483 }); 7484 observer.observe(element); 7485 return () => observer.disconnect(); 7486 }, [focusable, focusVisible]); 7487 const onKeyPressCapture = useDisableEvent( 7488 props.onKeyPressCapture, 7489 disabled 7490 ); 7491 const onMouseDownCapture = useDisableEvent( 7492 props.onMouseDownCapture, 7493 disabled 7494 ); 7495 const onClickCapture = useDisableEvent(props.onClickCapture, disabled); 7496 const onMouseDownProp = props.onMouseDown; 7497 const onMouseDown = useEvent((event) => { 7498 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 7499 if (event.defaultPrevented) return; 7500 if (!focusable) return; 7501 const element = event.currentTarget; 7502 if (!isSafariBrowser) return; 7503 if (isPortalEvent(event)) return; 7504 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return; 7505 let receivedFocus = false; 7506 const onFocus = () => { 7507 receivedFocus = true; 7508 }; 7509 const options = { capture: true, once: true }; 7510 element.addEventListener("focusin", onFocus, options); 7511 const focusableContainer = getClosestFocusable(element.parentElement); 7512 markSafariFocusAncestor(focusableContainer, true); 7513 queueBeforeEvent(element, "mouseup", () => { 7514 element.removeEventListener("focusin", onFocus, true); 7515 markSafariFocusAncestor(focusableContainer, false); 7516 if (receivedFocus) return; 7517 focusIfNeeded(element); 7518 }); 7519 }); 7520 const handleFocusVisible = (event, currentTarget) => { 7521 if (currentTarget) { 7522 event.currentTarget = currentTarget; 7523 } 7524 if (!focusable) return; 7525 const element = event.currentTarget; 7526 if (!element) return; 7527 if (!hasFocus(element)) return; 7528 onFocusVisible == null ? void 0 : onFocusVisible(event); 7529 if (event.defaultPrevented) return; 7530 element.dataset.focusVisible = "true"; 7531 setFocusVisible(true); 7532 }; 7533 const onKeyDownCaptureProp = props.onKeyDownCapture; 7534 const onKeyDownCapture = useEvent((event) => { 7535 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event); 7536 if (event.defaultPrevented) return; 7537 if (!focusable) return; 7538 if (focusVisible) return; 7539 if (event.metaKey) return; 7540 if (event.altKey) return; 7541 if (event.ctrlKey) return; 7542 if (!isSelfTarget(event)) return; 7543 const element = event.currentTarget; 7544 const applyFocusVisible = () => handleFocusVisible(event, element); 7545 queueBeforeEvent(element, "focusout", applyFocusVisible); 7546 }); 7547 const onFocusCaptureProp = props.onFocusCapture; 7548 const onFocusCapture = useEvent((event) => { 7549 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 7550 if (event.defaultPrevented) return; 7551 if (!focusable) return; 7552 if (!isSelfTarget(event)) { 7553 setFocusVisible(false); 7554 return; 7555 } 7556 const element = event.currentTarget; 7557 const applyFocusVisible = () => handleFocusVisible(event, element); 7558 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) { 7559 queueBeforeEvent(event.target, "focusout", applyFocusVisible); 7560 } else { 7561 setFocusVisible(false); 7562 } 7563 }); 7564 const onBlurProp = props.onBlur; 7565 const onBlur = useEvent((event) => { 7566 onBlurProp == null ? void 0 : onBlurProp(event); 7567 if (!focusable) return; 7568 if (!isFocusEventOutside(event)) return; 7569 setFocusVisible(false); 7570 }); 7571 const autoFocusOnShow = (0, import_react9.useContext)(FocusableContext); 7572 const autoFocusRef = useEvent((element) => { 7573 if (!focusable) return; 7574 if (!autoFocus) return; 7575 if (!element) return; 7576 if (!autoFocusOnShow) return; 7577 queueMicrotask(() => { 7578 if (hasFocus(element)) return; 7579 if (!isFocusable(element)) return; 7580 element.focus(); 7581 }); 7582 }); 7583 const tagName = useTagName(ref); 7584 const nativeTabbable = focusable && isNativeTabbable(tagName); 7585 const supportsDisabled = focusable && supportsDisabledAttribute(tagName); 7586 const styleProp = props.style; 7587 const style = (0, import_react9.useMemo)(() => { 7588 if (trulyDisabled) { 7589 return __spreadValues({ pointerEvents: "none" }, styleProp); 7590 } 7591 return styleProp; 7592 }, [trulyDisabled, styleProp]); 7593 props = __spreadProps(__spreadValues({ 7594 "data-focus-visible": focusable && focusVisible || void 0, 7595 "data-autofocus": autoFocus || void 0, 7596 "aria-disabled": disabled || void 0 7597 }, props), { 7598 ref: useMergeRefs(ref, autoFocusRef, props.ref), 7599 style, 7600 tabIndex: getTabIndex( 7601 focusable, 7602 trulyDisabled, 7603 nativeTabbable, 7604 supportsDisabled, 7605 props.tabIndex 7606 ), 7607 disabled: supportsDisabled && trulyDisabled ? true : void 0, 7608 // TODO: Test Focusable contentEditable. 7609 contentEditable: disabled ? void 0 : props.contentEditable, 7610 onKeyPressCapture, 7611 onClickCapture, 7612 onMouseDownCapture, 7613 onMouseDown, 7614 onKeyDownCapture, 7615 onFocusCapture, 7616 onBlur 7617 }); 7618 return removeUndefinedValues(props); 7619 } 7620 ); 7621 var Focusable = forwardRef22(function Focusable2(props) { 7622 const htmlProps = useFocusable(props); 7623 return createElement2(TagName2, htmlProps); 7624 }); 7625 7626 // node_modules/@ariakit/react-core/esm/__chunks/ITI7HKP4.js 7627 var import_react10 = __toESM(require_react(), 1); 7628 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1); 7629 var TagName3 = "div"; 7630 function isGrid(items) { 7631 return items.some((item) => !!item.rowId); 7632 } 7633 function isPrintableKey(event) { 7634 const target = event.target; 7635 if (target && !isTextField(target)) return false; 7636 return event.key.length === 1 && !event.ctrlKey && !event.metaKey; 7637 } 7638 function isModifierKey(event) { 7639 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta"; 7640 } 7641 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) { 7642 return useEvent((event) => { 7643 var _a; 7644 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event); 7645 if (event.defaultPrevented) return; 7646 if (event.isPropagationStopped()) return; 7647 if (!isSelfTarget(event)) return; 7648 if (isModifierKey(event)) return; 7649 if (isPrintableKey(event)) return; 7650 const state = store.getState(); 7651 const activeElement = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element; 7652 if (!activeElement) return; 7653 const _b = event, { view } = _b, eventInit = __objRest(_b, ["view"]); 7654 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current; 7655 if (activeElement !== previousElement) { 7656 activeElement.focus(); 7657 } 7658 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) { 7659 event.preventDefault(); 7660 } 7661 if (event.currentTarget.contains(activeElement)) { 7662 event.stopPropagation(); 7663 } 7664 }); 7665 } 7666 function findFirstEnabledItemInTheLastRow(items) { 7667 return findFirstEnabledItem2( 7668 flatten2DArray(reverseArray(groupItemsByRows2(items))) 7669 ); 7670 } 7671 function useScheduleFocus(store) { 7672 const [scheduled, setScheduled] = (0, import_react10.useState)(false); 7673 const schedule = (0, import_react10.useCallback)(() => setScheduled(true), []); 7674 const activeItem = store.useState( 7675 (state) => getEnabledItem(store, state.activeId) 7676 ); 7677 (0, import_react10.useEffect)(() => { 7678 const activeElement = activeItem == null ? void 0 : activeItem.element; 7679 if (!scheduled) return; 7680 if (!activeElement) return; 7681 setScheduled(false); 7682 activeElement.focus({ preventScroll: true }); 7683 }, [activeItem, scheduled]); 7684 return schedule; 7685 } 7686 var useComposite = createHook( 7687 function useComposite2(_a) { 7688 var _b = _a, { 7689 store, 7690 composite = true, 7691 focusOnMove = composite, 7692 moveOnKeyPress = true 7693 } = _b, props = __objRest(_b, [ 7694 "store", 7695 "composite", 7696 "focusOnMove", 7697 "moveOnKeyPress" 7698 ]); 7699 const context = useCompositeProviderContext(); 7700 store = store || context; 7701 invariant( 7702 store, 7703 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component." 7704 ); 7705 const ref = (0, import_react10.useRef)(null); 7706 const previousElementRef = (0, import_react10.useRef)(null); 7707 const scheduleFocus = useScheduleFocus(store); 7708 const moves = store.useState("moves"); 7709 const [, setBaseElement] = useTransactionState( 7710 composite ? store.setBaseElement : null 7711 ); 7712 (0, import_react10.useEffect)(() => { 7713 var _a2; 7714 if (!store) return; 7715 if (!moves) return; 7716 if (!composite) return; 7717 if (!focusOnMove) return; 7718 const { activeId: activeId2 } = store.getState(); 7719 const itemElement = (_a2 = getEnabledItem(store, activeId2)) == null ? void 0 : _a2.element; 7720 if (!itemElement) return; 7721 focusIntoView(itemElement); 7722 }, [store, moves, composite, focusOnMove]); 7723 useSafeLayoutEffect(() => { 7724 if (!store) return; 7725 if (!moves) return; 7726 if (!composite) return; 7727 const { baseElement, activeId: activeId2 } = store.getState(); 7728 const isSelfAcive = activeId2 === null; 7729 if (!isSelfAcive) return; 7730 if (!baseElement) return; 7731 const previousElement = previousElementRef.current; 7732 previousElementRef.current = null; 7733 if (previousElement) { 7734 fireBlurEvent(previousElement, { relatedTarget: baseElement }); 7735 } 7736 if (!hasFocus(baseElement)) { 7737 baseElement.focus(); 7738 } 7739 }, [store, moves, composite]); 7740 const activeId = store.useState("activeId"); 7741 const virtualFocus = store.useState("virtualFocus"); 7742 useSafeLayoutEffect(() => { 7743 var _a2; 7744 if (!store) return; 7745 if (!composite) return; 7746 if (!virtualFocus) return; 7747 const previousElement = previousElementRef.current; 7748 previousElementRef.current = null; 7749 if (!previousElement) return; 7750 const activeElement = (_a2 = getEnabledItem(store, activeId)) == null ? void 0 : _a2.element; 7751 const relatedTarget = activeElement || getActiveElement(previousElement); 7752 if (relatedTarget === previousElement) return; 7753 fireBlurEvent(previousElement, { relatedTarget }); 7754 }, [store, activeId, virtualFocus, composite]); 7755 const onKeyDownCapture = useKeyboardEventProxy( 7756 store, 7757 props.onKeyDownCapture, 7758 previousElementRef 7759 ); 7760 const onKeyUpCapture = useKeyboardEventProxy( 7761 store, 7762 props.onKeyUpCapture, 7763 previousElementRef 7764 ); 7765 const onFocusCaptureProp = props.onFocusCapture; 7766 const onFocusCapture = useEvent((event) => { 7767 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 7768 if (event.defaultPrevented) return; 7769 if (!store) return; 7770 const { virtualFocus: virtualFocus2 } = store.getState(); 7771 if (!virtualFocus2) return; 7772 const previousActiveElement = event.relatedTarget; 7773 const isSilentlyFocused = silentlyFocused(event.currentTarget); 7774 if (isSelfTarget(event) && isSilentlyFocused) { 7775 event.stopPropagation(); 7776 previousElementRef.current = previousActiveElement; 7777 } 7778 }); 7779 const onFocusProp = props.onFocus; 7780 const onFocus = useEvent((event) => { 7781 onFocusProp == null ? void 0 : onFocusProp(event); 7782 if (event.defaultPrevented) return; 7783 if (!composite) return; 7784 if (!store) return; 7785 const { relatedTarget } = event; 7786 const { virtualFocus: virtualFocus2 } = store.getState(); 7787 if (virtualFocus2) { 7788 if (isSelfTarget(event) && !isItem(store, relatedTarget)) { 7789 queueMicrotask(scheduleFocus); 7790 } 7791 } else if (isSelfTarget(event)) { 7792 store.setActiveId(null); 7793 } 7794 }); 7795 const onBlurCaptureProp = props.onBlurCapture; 7796 const onBlurCapture = useEvent((event) => { 7797 var _a2; 7798 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 7799 if (event.defaultPrevented) return; 7800 if (!store) return; 7801 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState(); 7802 if (!virtualFocus2) return; 7803 const activeElement = (_a2 = getEnabledItem(store, activeId2)) == null ? void 0 : _a2.element; 7804 const nextActiveElement = event.relatedTarget; 7805 const nextActiveElementIsItem = isItem(store, nextActiveElement); 7806 const previousElement = previousElementRef.current; 7807 previousElementRef.current = null; 7808 if (isSelfTarget(event) && nextActiveElementIsItem) { 7809 if (nextActiveElement === activeElement) { 7810 if (previousElement && previousElement !== nextActiveElement) { 7811 fireBlurEvent(previousElement, event); 7812 } 7813 } else if (activeElement) { 7814 fireBlurEvent(activeElement, event); 7815 } else if (previousElement) { 7816 fireBlurEvent(previousElement, event); 7817 } 7818 event.stopPropagation(); 7819 } else { 7820 const targetIsItem = isItem(store, event.target); 7821 if (!targetIsItem && activeElement) { 7822 fireBlurEvent(activeElement, event); 7823 } 7824 } 7825 }); 7826 const onKeyDownProp = props.onKeyDown; 7827 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 7828 const onKeyDown = useEvent((event) => { 7829 var _a2; 7830 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 7831 if (event.defaultPrevented) return; 7832 if (!store) return; 7833 if (!isSelfTarget(event)) return; 7834 const { orientation, renderedItems, activeId: activeId2 } = store.getState(); 7835 const activeItem = getEnabledItem(store, activeId2); 7836 if ((_a2 = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a2.isConnected) return; 7837 const isVertical = orientation !== "horizontal"; 7838 const isHorizontal = orientation !== "vertical"; 7839 const grid = isGrid(renderedItems); 7840 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End"; 7841 if (isHorizontalKey && isTextField(event.currentTarget)) return; 7842 const up = () => { 7843 if (grid) { 7844 const item = findFirstEnabledItemInTheLastRow(renderedItems); 7845 return item == null ? void 0 : item.id; 7846 } 7847 return store == null ? void 0 : store.last(); 7848 }; 7849 const keyMap = { 7850 ArrowUp: (grid || isVertical) && up, 7851 ArrowRight: (grid || isHorizontal) && store.first, 7852 ArrowDown: (grid || isVertical) && store.first, 7853 ArrowLeft: (grid || isHorizontal) && store.last, 7854 Home: store.first, 7855 End: store.last, 7856 PageUp: store.first, 7857 PageDown: store.last 7858 }; 7859 const action = keyMap[event.key]; 7860 if (action) { 7861 const id = action(); 7862 if (id !== void 0) { 7863 if (!moveOnKeyPressProp(event)) return; 7864 event.preventDefault(); 7865 store.move(id); 7866 } 7867 } 7868 }); 7869 props = useWrapElement( 7870 props, 7871 (element) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(CompositeContextProvider, { value: store, children: element }), 7872 [store] 7873 ); 7874 const activeDescendant = store.useState((state) => { 7875 var _a2; 7876 if (!store) return; 7877 if (!composite) return; 7878 if (!state.virtualFocus) return; 7879 return (_a2 = getEnabledItem(store, state.activeId)) == null ? void 0 : _a2.id; 7880 }); 7881 props = __spreadProps(__spreadValues({ 7882 "aria-activedescendant": activeDescendant 7883 }, props), { 7884 ref: useMergeRefs(ref, setBaseElement, props.ref), 7885 onKeyDownCapture, 7886 onKeyUpCapture, 7887 onFocusCapture, 7888 onFocus, 7889 onBlurCapture, 7890 onKeyDown 7891 }); 7892 const focusable = store.useState( 7893 (state) => composite && (state.virtualFocus || state.activeId === null) 7894 ); 7895 props = useFocusable(__spreadValues({ focusable }, props)); 7896 return props; 7897 } 7898 ); 7899 var Composite5 = forwardRef22(function Composite22(props) { 7900 const htmlProps = useComposite(props); 7901 return createElement2(TagName3, htmlProps); 7902 }); 7903 7904 // node_modules/@ariakit/react-core/esm/combobox/combobox.js 7905 var import_react11 = __toESM(require_react(), 1); 7906 var TagName4 = "input"; 7907 function isFirstItemAutoSelected(items, activeValue, autoSelect) { 7908 if (!autoSelect) return false; 7909 const firstItem = items.find((item) => !item.disabled && item.value); 7910 return (firstItem == null ? void 0 : firstItem.value) === activeValue; 7911 } 7912 function hasCompletionString(value, activeValue) { 7913 if (!activeValue) return false; 7914 if (value == null) return false; 7915 value = normalizeString(value); 7916 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0; 7917 } 7918 function isInputEvent(event) { 7919 return event.type === "input"; 7920 } 7921 function isAriaAutoCompleteValue(value) { 7922 return value === "inline" || value === "list" || value === "both" || value === "none"; 7923 } 7924 function getDefaultAutoSelectId(items) { 7925 const item = items.find((item2) => { 7926 var _a; 7927 if (item2.disabled) return false; 7928 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab"; 7929 }); 7930 return item == null ? void 0 : item.id; 7931 } 7932 var useCombobox = createHook( 7933 function useCombobox2(_a) { 7934 var _b = _a, { 7935 store, 7936 focusable = true, 7937 autoSelect: autoSelectProp = false, 7938 getAutoSelectId, 7939 setValueOnChange, 7940 showMinLength = 0, 7941 showOnChange, 7942 showOnMouseDown, 7943 showOnClick = showOnMouseDown, 7944 showOnKeyDown, 7945 showOnKeyPress = showOnKeyDown, 7946 blurActiveItemOnClick, 7947 setValueOnClick = true, 7948 moveOnKeyPress = true, 7949 autoComplete = "list" 7950 } = _b, props = __objRest(_b, [ 7951 "store", 7952 "focusable", 7953 "autoSelect", 7954 "getAutoSelectId", 7955 "setValueOnChange", 7956 "showMinLength", 7957 "showOnChange", 7958 "showOnMouseDown", 7959 "showOnClick", 7960 "showOnKeyDown", 7961 "showOnKeyPress", 7962 "blurActiveItemOnClick", 7963 "setValueOnClick", 7964 "moveOnKeyPress", 7965 "autoComplete" 7966 ]); 7967 const context = useComboboxProviderContext(); 7968 store = store || context; 7969 invariant( 7970 store, 7971 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component." 7972 ); 7973 const ref = (0, import_react11.useRef)(null); 7974 const [valueUpdated, forceValueUpdate] = useForceUpdate(); 7975 const canAutoSelectRef = (0, import_react11.useRef)(false); 7976 const composingRef = (0, import_react11.useRef)(false); 7977 const autoSelect = store.useState( 7978 (state) => state.virtualFocus && autoSelectProp 7979 ); 7980 const inline = autoComplete === "inline" || autoComplete === "both"; 7981 const [canInline, setCanInline] = (0, import_react11.useState)(inline); 7982 useUpdateLayoutEffect(() => { 7983 if (!inline) return; 7984 setCanInline(true); 7985 }, [inline]); 7986 const storeValue = store.useState("value"); 7987 const prevSelectedValueRef = (0, import_react11.useRef)(); 7988 (0, import_react11.useEffect)(() => { 7989 return sync(store, ["selectedValue", "activeId"], (_, prev) => { 7990 prevSelectedValueRef.current = prev.selectedValue; 7991 }); 7992 }, []); 7993 const inlineActiveValue = store.useState((state) => { 7994 var _a2; 7995 if (!inline) return; 7996 if (!canInline) return; 7997 if (state.activeValue && Array.isArray(state.selectedValue)) { 7998 if (state.selectedValue.includes(state.activeValue)) return; 7999 if ((_a2 = prevSelectedValueRef.current) == null ? void 0 : _a2.includes(state.activeValue)) return; 8000 } 8001 return state.activeValue; 8002 }); 8003 const items = store.useState("renderedItems"); 8004 const open = store.useState("open"); 8005 const contentElement = store.useState("contentElement"); 8006 const value = (0, import_react11.useMemo)(() => { 8007 if (!inline) return storeValue; 8008 if (!canInline) return storeValue; 8009 const firstItemAutoSelected = isFirstItemAutoSelected( 8010 items, 8011 inlineActiveValue, 8012 autoSelect 8013 ); 8014 if (firstItemAutoSelected) { 8015 if (hasCompletionString(storeValue, inlineActiveValue)) { 8016 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || ""; 8017 return storeValue + slice; 8018 } 8019 return storeValue; 8020 } 8021 return inlineActiveValue || storeValue; 8022 }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]); 8023 (0, import_react11.useEffect)(() => { 8024 const element = ref.current; 8025 if (!element) return; 8026 const onCompositeItemMove = () => setCanInline(true); 8027 element.addEventListener("combobox-item-move", onCompositeItemMove); 8028 return () => { 8029 element.removeEventListener("combobox-item-move", onCompositeItemMove); 8030 }; 8031 }, []); 8032 (0, import_react11.useEffect)(() => { 8033 if (!inline) return; 8034 if (!canInline) return; 8035 if (!inlineActiveValue) return; 8036 const firstItemAutoSelected = isFirstItemAutoSelected( 8037 items, 8038 inlineActiveValue, 8039 autoSelect 8040 ); 8041 if (!firstItemAutoSelected) return; 8042 if (!hasCompletionString(storeValue, inlineActiveValue)) return; 8043 let cleanup = noop; 8044 queueMicrotask(() => { 8045 const element = ref.current; 8046 if (!element) return; 8047 const { start: prevStart, end: prevEnd } = getTextboxSelection(element); 8048 const nextStart = storeValue.length; 8049 const nextEnd = inlineActiveValue.length; 8050 setSelectionRange(element, nextStart, nextEnd); 8051 cleanup = () => { 8052 if (!hasFocus(element)) return; 8053 const { start, end } = getTextboxSelection(element); 8054 if (start !== nextStart) return; 8055 if (end !== nextEnd) return; 8056 setSelectionRange(element, prevStart, prevEnd); 8057 }; 8058 }); 8059 return () => cleanup(); 8060 }, [ 8061 valueUpdated, 8062 inline, 8063 canInline, 8064 inlineActiveValue, 8065 items, 8066 autoSelect, 8067 storeValue 8068 ]); 8069 const scrollingElementRef = (0, import_react11.useRef)(null); 8070 const getAutoSelectIdProp = useEvent(getAutoSelectId); 8071 const autoSelectIdRef = (0, import_react11.useRef)(null); 8072 (0, import_react11.useEffect)(() => { 8073 if (!open) return; 8074 if (!contentElement) return; 8075 const scrollingElement = getScrollingElement(contentElement); 8076 if (!scrollingElement) return; 8077 scrollingElementRef.current = scrollingElement; 8078 const onUserScroll = () => { 8079 canAutoSelectRef.current = false; 8080 }; 8081 const onScroll = () => { 8082 if (!store) return; 8083 if (!canAutoSelectRef.current) return; 8084 const { activeId } = store.getState(); 8085 if (activeId === null) return; 8086 if (activeId === autoSelectIdRef.current) return; 8087 canAutoSelectRef.current = false; 8088 }; 8089 const options = { passive: true, capture: true }; 8090 scrollingElement.addEventListener("wheel", onUserScroll, options); 8091 scrollingElement.addEventListener("touchmove", onUserScroll, options); 8092 scrollingElement.addEventListener("scroll", onScroll, options); 8093 return () => { 8094 scrollingElement.removeEventListener("wheel", onUserScroll, true); 8095 scrollingElement.removeEventListener("touchmove", onUserScroll, true); 8096 scrollingElement.removeEventListener("scroll", onScroll, true); 8097 }; 8098 }, [open, contentElement, store]); 8099 useSafeLayoutEffect(() => { 8100 if (!storeValue) return; 8101 if (composingRef.current) return; 8102 canAutoSelectRef.current = true; 8103 }, [storeValue]); 8104 useSafeLayoutEffect(() => { 8105 if (autoSelect !== "always" && open) return; 8106 canAutoSelectRef.current = open; 8107 }, [autoSelect, open]); 8108 const resetValueOnSelect = store.useState("resetValueOnSelect"); 8109 useUpdateEffect(() => { 8110 var _a2, _b2; 8111 const canAutoSelect = canAutoSelectRef.current; 8112 if (!store) return; 8113 if (!open) return; 8114 if (!canAutoSelect && !resetValueOnSelect) return; 8115 const { baseElement, contentElement: contentElement2, activeId } = store.getState(); 8116 if (baseElement && !hasFocus(baseElement)) return; 8117 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) { 8118 const observer = new MutationObserver(forceValueUpdate); 8119 observer.observe(contentElement2, { attributeFilter: ["data-placing"] }); 8120 return () => observer.disconnect(); 8121 } 8122 if (autoSelect && canAutoSelect) { 8123 const userAutoSelectId = getAutoSelectIdProp(items); 8124 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a2 = getDefaultAutoSelectId(items)) != null ? _a2 : store.first(); 8125 autoSelectIdRef.current = autoSelectId; 8126 store.move(autoSelectId != null ? autoSelectId : null); 8127 } else { 8128 const element = (_b2 = store.item(activeId || store.first())) == null ? void 0 : _b2.element; 8129 if (element && "scrollIntoView" in element) { 8130 element.scrollIntoView({ block: "nearest", inline: "nearest" }); 8131 } 8132 } 8133 return; 8134 }, [ 8135 store, 8136 open, 8137 valueUpdated, 8138 storeValue, 8139 autoSelect, 8140 resetValueOnSelect, 8141 getAutoSelectIdProp, 8142 items 8143 ]); 8144 (0, import_react11.useEffect)(() => { 8145 if (!inline) return; 8146 const combobox = ref.current; 8147 if (!combobox) return; 8148 const elements = [combobox, contentElement].filter( 8149 (value2) => !!value2 8150 ); 8151 const onBlur2 = (event) => { 8152 if (elements.every((el) => isFocusEventOutside(event, el))) { 8153 store == null ? void 0 : store.setValue(value); 8154 } 8155 }; 8156 for (const element of elements) { 8157 element.addEventListener("focusout", onBlur2); 8158 } 8159 return () => { 8160 for (const element of elements) { 8161 element.removeEventListener("focusout", onBlur2); 8162 } 8163 }; 8164 }, [inline, contentElement, store, value]); 8165 const canShow = (event) => { 8166 const currentTarget = event.currentTarget; 8167 return currentTarget.value.length >= showMinLength; 8168 }; 8169 const onChangeProp = props.onChange; 8170 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow); 8171 const setValueOnChangeProp = useBooleanEvent( 8172 // If the combobox is combined with tags, the value will be set by the tag 8173 // input component. 8174 setValueOnChange != null ? setValueOnChange : !store.tag 8175 ); 8176 const onChange = useEvent((event) => { 8177 onChangeProp == null ? void 0 : onChangeProp(event); 8178 if (event.defaultPrevented) return; 8179 if (!store) return; 8180 const currentTarget = event.currentTarget; 8181 const { value: value2, selectionStart, selectionEnd } = currentTarget; 8182 const nativeEvent = event.nativeEvent; 8183 canAutoSelectRef.current = true; 8184 if (isInputEvent(nativeEvent)) { 8185 if (nativeEvent.isComposing) { 8186 canAutoSelectRef.current = false; 8187 composingRef.current = true; 8188 } 8189 if (inline) { 8190 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText"; 8191 const caretAtEnd = selectionStart === value2.length; 8192 setCanInline(textInserted && caretAtEnd); 8193 } 8194 } 8195 if (setValueOnChangeProp(event)) { 8196 const isSameValue = value2 === store.getState().value; 8197 store.setValue(value2); 8198 queueMicrotask(() => { 8199 setSelectionRange(currentTarget, selectionStart, selectionEnd); 8200 }); 8201 if (inline && autoSelect && isSameValue) { 8202 forceValueUpdate(); 8203 } 8204 } 8205 if (showOnChangeProp(event)) { 8206 store.show(); 8207 } 8208 if (!autoSelect || !canAutoSelectRef.current) { 8209 store.setActiveId(null); 8210 } 8211 }); 8212 const onCompositionEndProp = props.onCompositionEnd; 8213 const onCompositionEnd = useEvent((event) => { 8214 canAutoSelectRef.current = true; 8215 composingRef.current = false; 8216 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event); 8217 if (event.defaultPrevented) return; 8218 if (!autoSelect) return; 8219 forceValueUpdate(); 8220 }); 8221 const onMouseDownProp = props.onMouseDown; 8222 const blurActiveItemOnClickProp = useBooleanEvent( 8223 blurActiveItemOnClick != null ? blurActiveItemOnClick : () => !!(store == null ? void 0 : store.getState().includesBaseElement) 8224 ); 8225 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 8226 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow); 8227 const onMouseDown = useEvent((event) => { 8228 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 8229 if (event.defaultPrevented) return; 8230 if (event.button) return; 8231 if (event.ctrlKey) return; 8232 if (!store) return; 8233 if (blurActiveItemOnClickProp(event)) { 8234 store.setActiveId(null); 8235 } 8236 if (setValueOnClickProp(event)) { 8237 store.setValue(value); 8238 } 8239 if (showOnClickProp(event)) { 8240 queueBeforeEvent(event.currentTarget, "mouseup", store.show); 8241 } 8242 }); 8243 const onKeyDownProp = props.onKeyDown; 8244 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow); 8245 const onKeyDown = useEvent((event) => { 8246 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 8247 if (!event.repeat) { 8248 canAutoSelectRef.current = false; 8249 } 8250 if (event.defaultPrevented) return; 8251 if (event.ctrlKey) return; 8252 if (event.altKey) return; 8253 if (event.shiftKey) return; 8254 if (event.metaKey) return; 8255 if (!store) return; 8256 const { open: open2 } = store.getState(); 8257 if (open2) return; 8258 if (event.key === "ArrowUp" || event.key === "ArrowDown") { 8259 if (showOnKeyPressProp(event)) { 8260 event.preventDefault(); 8261 store.show(); 8262 } 8263 } 8264 }); 8265 const onBlurProp = props.onBlur; 8266 const onBlur = useEvent((event) => { 8267 canAutoSelectRef.current = false; 8268 onBlurProp == null ? void 0 : onBlurProp(event); 8269 if (event.defaultPrevented) return; 8270 }); 8271 const id = useId3(props.id); 8272 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0; 8273 const isActiveItem = store.useState((state) => state.activeId === null); 8274 props = __spreadProps(__spreadValues({ 8275 id, 8276 role: "combobox", 8277 "aria-autocomplete": ariaAutoComplete, 8278 "aria-haspopup": getPopupRole(contentElement, "listbox"), 8279 "aria-expanded": open, 8280 "aria-controls": contentElement == null ? void 0 : contentElement.id, 8281 "data-active-item": isActiveItem || void 0, 8282 value 8283 }, props), { 8284 ref: useMergeRefs(ref, props.ref), 8285 onChange, 8286 onCompositionEnd, 8287 onMouseDown, 8288 onKeyDown, 8289 onBlur 8290 }); 8291 props = useComposite(__spreadProps(__spreadValues({ 8292 store, 8293 focusable 8294 }, props), { 8295 // Enable inline autocomplete when the user moves from the combobox input 8296 // to an item. 8297 moveOnKeyPress: (event) => { 8298 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false; 8299 if (inline) setCanInline(true); 8300 return true; 8301 } 8302 })); 8303 props = usePopoverAnchor(__spreadValues({ store }, props)); 8304 return __spreadValues({ autoComplete: "off" }, props); 8305 } 8306 ); 8307 var Combobox = forwardRef22(function Combobox2(props) { 8308 const htmlProps = useCombobox(props); 8309 return createElement2(TagName4, htmlProps); 8310 }); 8311 8312 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js 8313 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1); 8314 function ComboboxProvider(props = {}) { 8315 const store = useComboboxStore(props); 8316 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ComboboxContextProvider, { value: store, children: props.children }); 8317 } 8318 8319 // node_modules/@ariakit/react-core/esm/__chunks/KUU7WJ55.js 8320 var import_react12 = __toESM(require_react(), 1); 8321 var TagName5 = "button"; 8322 function isNativeClick(event) { 8323 if (!event.isTrusted) return false; 8324 const element = event.currentTarget; 8325 if (event.key === "Enter") { 8326 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A"; 8327 } 8328 if (event.key === " ") { 8329 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT"; 8330 } 8331 return false; 8332 } 8333 var symbol = Symbol("command"); 8334 var useCommand = createHook( 8335 function useCommand2(_a) { 8336 var _b = _a, { clickOnEnter = true, clickOnSpace = true } = _b, props = __objRest(_b, ["clickOnEnter", "clickOnSpace"]); 8337 const ref = (0, import_react12.useRef)(null); 8338 const [isNativeButton, setIsNativeButton] = (0, import_react12.useState)(false); 8339 (0, import_react12.useEffect)(() => { 8340 if (!ref.current) return; 8341 setIsNativeButton(isButton(ref.current)); 8342 }, []); 8343 const [active, setActive] = (0, import_react12.useState)(false); 8344 const activeRef = (0, import_react12.useRef)(false); 8345 const disabled = disabledFromProps(props); 8346 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true); 8347 const onKeyDownProp = props.onKeyDown; 8348 const onKeyDown = useEvent((event) => { 8349 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 8350 const element = event.currentTarget; 8351 if (event.defaultPrevented) return; 8352 if (isDuplicate) return; 8353 if (disabled) return; 8354 if (!isSelfTarget(event)) return; 8355 if (isTextField(element)) return; 8356 if (element.isContentEditable) return; 8357 const isEnter = clickOnEnter && event.key === "Enter"; 8358 const isSpace = clickOnSpace && event.key === " "; 8359 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter; 8360 const shouldPreventSpace = event.key === " " && !clickOnSpace; 8361 if (shouldPreventEnter || shouldPreventSpace) { 8362 event.preventDefault(); 8363 return; 8364 } 8365 if (isEnter || isSpace) { 8366 const nativeClick = isNativeClick(event); 8367 if (isEnter) { 8368 if (!nativeClick) { 8369 event.preventDefault(); 8370 const _a2 = event, { view } = _a2, eventInit = __objRest(_a2, ["view"]); 8371 const click = () => fireClickEvent(element, eventInit); 8372 if (isFirefox()) { 8373 queueBeforeEvent(element, "keyup", click); 8374 } else { 8375 queueMicrotask(click); 8376 } 8377 } 8378 } else if (isSpace) { 8379 activeRef.current = true; 8380 if (!nativeClick) { 8381 event.preventDefault(); 8382 setActive(true); 8383 } 8384 } 8385 } 8386 }); 8387 const onKeyUpProp = props.onKeyUp; 8388 const onKeyUp = useEvent((event) => { 8389 onKeyUpProp == null ? void 0 : onKeyUpProp(event); 8390 if (event.defaultPrevented) return; 8391 if (isDuplicate) return; 8392 if (disabled) return; 8393 if (event.metaKey) return; 8394 const isSpace = clickOnSpace && event.key === " "; 8395 if (activeRef.current && isSpace) { 8396 activeRef.current = false; 8397 if (!isNativeClick(event)) { 8398 event.preventDefault(); 8399 setActive(false); 8400 const element = event.currentTarget; 8401 const _a2 = event, { view } = _a2, eventInit = __objRest(_a2, ["view"]); 8402 queueMicrotask(() => fireClickEvent(element, eventInit)); 8403 } 8404 } 8405 }); 8406 props = __spreadProps(__spreadValues(__spreadValues({ 8407 "data-active": active || void 0, 8408 type: isNativeButton ? "button" : void 0 8409 }, metadataProps), props), { 8410 ref: useMergeRefs(ref, props.ref), 8411 onKeyDown, 8412 onKeyUp 8413 }); 8414 props = useFocusable(props); 8415 return props; 8416 } 8417 ); 8418 var Command = forwardRef22(function Command2(props) { 8419 const htmlProps = useCommand(props); 8420 return createElement2(TagName5, htmlProps); 8421 }); 8422 8423 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js 8424 var import_react13 = __toESM(require_react(), 1); 8425 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1); 8426 var TagName6 = "span"; 8427 function normalizeValue(value) { 8428 return normalizeString(value).toLowerCase(); 8429 } 8430 function getOffsets(string, values) { 8431 const offsets = []; 8432 for (const value of values) { 8433 let pos = 0; 8434 const length = value.length; 8435 while (string.indexOf(value, pos) !== -1) { 8436 const index = string.indexOf(value, pos); 8437 if (index !== -1) { 8438 offsets.push([index, length]); 8439 } 8440 pos = index + 1; 8441 } 8442 } 8443 return offsets; 8444 } 8445 function filterOverlappingOffsets(offsets) { 8446 return offsets.filter(([offset, length], i2, arr) => { 8447 return !arr.some( 8448 ([o2, l2], j2) => j2 !== i2 && o2 <= offset && o2 + l2 >= offset + length 8449 ); 8450 }); 8451 } 8452 function sortOffsets(offsets) { 8453 return offsets.sort(([a2], [b2]) => a2 - b2); 8454 } 8455 function splitValue(itemValue, userValue) { 8456 if (!itemValue) return itemValue; 8457 if (!userValue) return itemValue; 8458 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue); 8459 const parts = []; 8460 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)( 8461 "span", 8462 { 8463 "data-autocomplete-value": autocomplete ? "" : void 0, 8464 "data-user-value": autocomplete ? void 0 : "", 8465 children: value 8466 }, 8467 parts.length 8468 ); 8469 const offsets = sortOffsets( 8470 filterOverlappingOffsets( 8471 // Convert userValues into a set to avoid duplicates 8472 getOffsets(normalizeValue(itemValue), new Set(userValues)) 8473 ) 8474 ); 8475 if (!offsets.length) { 8476 parts.push(span(itemValue, true)); 8477 return parts; 8478 } 8479 const [firstOffset] = offsets[0]; 8480 const values = [ 8481 itemValue.slice(0, firstOffset), 8482 ...offsets.flatMap(([offset, length], i2) => { 8483 var _a; 8484 const value = itemValue.slice(offset, offset + length); 8485 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0]; 8486 const nextValue = itemValue.slice(offset + length, nextOffset); 8487 return [value, nextValue]; 8488 }) 8489 ]; 8490 values.forEach((value, i2) => { 8491 if (!value) return; 8492 parts.push(span(value, i2 % 2 === 0)); 8493 }); 8494 return parts; 8495 } 8496 var useComboboxItemValue = createHook(function useComboboxItemValue2(_a) { 8497 var _b = _a, { store, value, userValue } = _b, props = __objRest(_b, ["store", "value", "userValue"]); 8498 const context = useComboboxScopedContext(); 8499 store = store || context; 8500 const itemContext = (0, import_react13.useContext)(ComboboxItemValueContext); 8501 const itemValue = value != null ? value : itemContext; 8502 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value); 8503 const children = (0, import_react13.useMemo)(() => { 8504 if (!itemValue) return; 8505 if (!inputValue) return itemValue; 8506 return splitValue(itemValue, inputValue); 8507 }, [itemValue, inputValue]); 8508 props = __spreadValues({ 8509 children 8510 }, props); 8511 return removeUndefinedValues(props); 8512 }); 8513 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) { 8514 const htmlProps = useComboboxItemValue(props); 8515 return createElement2(TagName6, htmlProps); 8516 }); 8517 8518 // node_modules/@ariakit/react-core/esm/__chunks/UQQRIHDV.js 8519 var import_react14 = __toESM(require_react(), 1); 8520 var TagName7 = "div"; 8521 function getMouseDestination(event) { 8522 const relatedTarget = event.relatedTarget; 8523 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) { 8524 return relatedTarget; 8525 } 8526 return null; 8527 } 8528 function hoveringInside(event) { 8529 const nextElement = getMouseDestination(event); 8530 if (!nextElement) return false; 8531 return contains(event.currentTarget, nextElement); 8532 } 8533 var symbol2 = Symbol("composite-hover"); 8534 function movingToAnotherItem(event) { 8535 let dest = getMouseDestination(event); 8536 if (!dest) return false; 8537 do { 8538 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true; 8539 dest = dest.parentElement; 8540 } while (dest); 8541 return false; 8542 } 8543 var useCompositeHover = createHook( 8544 function useCompositeHover2(_a) { 8545 var _b = _a, { 8546 store, 8547 focusOnHover = true, 8548 blurOnHoverEnd = !!focusOnHover 8549 } = _b, props = __objRest(_b, [ 8550 "store", 8551 "focusOnHover", 8552 "blurOnHoverEnd" 8553 ]); 8554 const context = useCompositeContext(); 8555 store = store || context; 8556 invariant( 8557 store, 8558 "CompositeHover must be wrapped in a Composite component." 8559 ); 8560 const isMouseMoving = useIsMouseMoving(); 8561 const onMouseMoveProp = props.onMouseMove; 8562 const focusOnHoverProp = useBooleanEvent(focusOnHover); 8563 const onMouseMove = useEvent((event) => { 8564 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event); 8565 if (event.defaultPrevented) return; 8566 if (!isMouseMoving()) return; 8567 if (!focusOnHoverProp(event)) return; 8568 if (!hasFocusWithin(event.currentTarget)) { 8569 const baseElement = store == null ? void 0 : store.getState().baseElement; 8570 if (baseElement && !hasFocus(baseElement)) { 8571 baseElement.focus(); 8572 } 8573 } 8574 store == null ? void 0 : store.setActiveId(event.currentTarget.id); 8575 }); 8576 const onMouseLeaveProp = props.onMouseLeave; 8577 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd); 8578 const onMouseLeave = useEvent((event) => { 8579 var _a2; 8580 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event); 8581 if (event.defaultPrevented) return; 8582 if (!isMouseMoving()) return; 8583 if (hoveringInside(event)) return; 8584 if (movingToAnotherItem(event)) return; 8585 if (!focusOnHoverProp(event)) return; 8586 if (!blurOnHoverEndProp(event)) return; 8587 store == null ? void 0 : store.setActiveId(null); 8588 (_a2 = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a2.focus(); 8589 }); 8590 const ref = (0, import_react14.useCallback)((element) => { 8591 if (!element) return; 8592 element[symbol2] = true; 8593 }, []); 8594 props = __spreadProps(__spreadValues({}, props), { 8595 ref: useMergeRefs(ref, props.ref), 8596 onMouseMove, 8597 onMouseLeave 8598 }); 8599 return removeUndefinedValues(props); 8600 } 8601 ); 8602 var CompositeHover = memo22( 8603 forwardRef22(function CompositeHover2(props) { 8604 const htmlProps = useCompositeHover(props); 8605 return createElement2(TagName7, htmlProps); 8606 }) 8607 ); 8608 8609 // node_modules/@ariakit/react-core/esm/__chunks/RZ4GPYOB.js 8610 var import_react15 = __toESM(require_react(), 1); 8611 var TagName8 = "div"; 8612 var useCollectionItem = createHook( 8613 function useCollectionItem2(_a) { 8614 var _b = _a, { 8615 store, 8616 shouldRegisterItem = true, 8617 getItem = identity, 8618 element 8619 } = _b, props = __objRest(_b, [ 8620 "store", 8621 "shouldRegisterItem", 8622 "getItem", 8623 // @ts-expect-error This prop may come from a collection renderer. 8624 "element" 8625 ]); 8626 const context = useCollectionContext(); 8627 store = store || context; 8628 const id = useId3(props.id); 8629 const ref = (0, import_react15.useRef)(element); 8630 (0, import_react15.useEffect)(() => { 8631 const element2 = ref.current; 8632 if (!id) return; 8633 if (!element2) return; 8634 if (!shouldRegisterItem) return; 8635 const item = getItem({ id, element: element2 }); 8636 return store == null ? void 0 : store.renderItem(item); 8637 }, [id, shouldRegisterItem, getItem, store]); 8638 props = __spreadProps(__spreadValues({}, props), { 8639 ref: useMergeRefs(ref, props.ref) 8640 }); 8641 return removeUndefinedValues(props); 8642 } 8643 ); 8644 var CollectionItem = forwardRef22(function CollectionItem2(props) { 8645 const htmlProps = useCollectionItem(props); 8646 return createElement2(TagName8, htmlProps); 8647 }); 8648 8649 // node_modules/@ariakit/react-core/esm/__chunks/P2CTZE2T.js 8650 var import_react16 = __toESM(require_react(), 1); 8651 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1); 8652 var TagName9 = "button"; 8653 function isEditableElement(element) { 8654 if (isTextbox(element)) return true; 8655 return element.tagName === "INPUT" && !isButton(element); 8656 } 8657 function getNextPageOffset(scrollingElement, pageUp = false) { 8658 const height = scrollingElement.clientHeight; 8659 const { top } = scrollingElement.getBoundingClientRect(); 8660 const pageSize = Math.max(height * 0.875, height - 40) * 1.5; 8661 const pageOffset = pageUp ? height - pageSize + top : pageSize + top; 8662 if (scrollingElement.tagName === "HTML") { 8663 return pageOffset + scrollingElement.scrollTop; 8664 } 8665 return pageOffset; 8666 } 8667 function getItemOffset(itemElement, pageUp = false) { 8668 const { top } = itemElement.getBoundingClientRect(); 8669 if (pageUp) { 8670 return top + itemElement.clientHeight; 8671 } 8672 return top; 8673 } 8674 function findNextPageItemId(element, store, next, pageUp = false) { 8675 var _a; 8676 if (!store) return; 8677 if (!next) return; 8678 const { renderedItems } = store.getState(); 8679 const scrollingElement = getScrollingElement(element); 8680 if (!scrollingElement) return; 8681 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp); 8682 let id; 8683 let prevDifference; 8684 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) { 8685 const previousId = id; 8686 id = next(i2); 8687 if (!id) break; 8688 if (id === previousId) continue; 8689 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element; 8690 if (!itemElement) continue; 8691 const itemOffset = getItemOffset(itemElement, pageUp); 8692 const difference = itemOffset - nextPageOffset; 8693 const absDifference = Math.abs(difference); 8694 if (pageUp && difference <= 0 || !pageUp && difference >= 0) { 8695 if (prevDifference !== void 0 && prevDifference < absDifference) { 8696 id = previousId; 8697 } 8698 break; 8699 } 8700 prevDifference = absDifference; 8701 } 8702 return id; 8703 } 8704 function targetIsAnotherItem(event, store) { 8705 if (isSelfTarget(event)) return false; 8706 return isItem(store, event.target); 8707 } 8708 var useCompositeItem = createHook( 8709 function useCompositeItem2(_a) { 8710 var _b = _a, { 8711 store, 8712 rowId: rowIdProp, 8713 preventScrollOnKeyDown = false, 8714 moveOnKeyPress = true, 8715 tabbable = false, 8716 getItem: getItemProp, 8717 "aria-setsize": ariaSetSizeProp, 8718 "aria-posinset": ariaPosInSetProp 8719 } = _b, props = __objRest(_b, [ 8720 "store", 8721 "rowId", 8722 "preventScrollOnKeyDown", 8723 "moveOnKeyPress", 8724 "tabbable", 8725 "getItem", 8726 "aria-setsize", 8727 "aria-posinset" 8728 ]); 8729 const context = useCompositeContext(); 8730 store = store || context; 8731 const id = useId3(props.id); 8732 const ref = (0, import_react16.useRef)(null); 8733 const row = (0, import_react16.useContext)(CompositeRowContext); 8734 const disabled = disabledFromProps(props); 8735 const trulyDisabled = disabled && !props.accessibleWhenDisabled; 8736 const { 8737 rowId, 8738 baseElement, 8739 isActiveItem, 8740 ariaSetSize, 8741 ariaPosInSet, 8742 isTabbable 8743 } = useStoreStateObject(store, { 8744 rowId(state) { 8745 if (rowIdProp) return rowIdProp; 8746 if (!state) return; 8747 if (!(row == null ? void 0 : row.baseElement)) return; 8748 if (row.baseElement !== state.baseElement) return; 8749 return row.id; 8750 }, 8751 baseElement(state) { 8752 return (state == null ? void 0 : state.baseElement) || void 0; 8753 }, 8754 isActiveItem(state) { 8755 return !!state && state.activeId === id; 8756 }, 8757 ariaSetSize(state) { 8758 if (ariaSetSizeProp != null) return ariaSetSizeProp; 8759 if (!state) return; 8760 if (!(row == null ? void 0 : row.ariaSetSize)) return; 8761 if (row.baseElement !== state.baseElement) return; 8762 return row.ariaSetSize; 8763 }, 8764 ariaPosInSet(state) { 8765 if (ariaPosInSetProp != null) return ariaPosInSetProp; 8766 if (!state) return; 8767 if (!(row == null ? void 0 : row.ariaPosInSet)) return; 8768 if (row.baseElement !== state.baseElement) return; 8769 const itemsInRow = state.renderedItems.filter( 8770 (item) => item.rowId === rowId 8771 ); 8772 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id); 8773 }, 8774 isTabbable(state) { 8775 if (!(state == null ? void 0 : state.renderedItems.length)) return true; 8776 if (state.virtualFocus) return false; 8777 if (tabbable) return true; 8778 if (state.activeId === null) return false; 8779 const item = store == null ? void 0 : store.item(state.activeId); 8780 if (item == null ? void 0 : item.disabled) return true; 8781 if (!(item == null ? void 0 : item.element)) return true; 8782 return state.activeId === id; 8783 } 8784 }); 8785 const getItem = (0, import_react16.useCallback)( 8786 (item) => { 8787 var _a2; 8788 const nextItem = __spreadProps(__spreadValues({}, item), { 8789 id: id || item.id, 8790 rowId, 8791 disabled: !!trulyDisabled, 8792 children: (_a2 = item.element) == null ? void 0 : _a2.textContent 8793 }); 8794 if (getItemProp) { 8795 return getItemProp(nextItem); 8796 } 8797 return nextItem; 8798 }, 8799 [id, rowId, trulyDisabled, getItemProp] 8800 ); 8801 const onFocusProp = props.onFocus; 8802 const hasFocusedComposite = (0, import_react16.useRef)(false); 8803 const onFocus = useEvent((event) => { 8804 onFocusProp == null ? void 0 : onFocusProp(event); 8805 if (event.defaultPrevented) return; 8806 if (isPortalEvent(event)) return; 8807 if (!id) return; 8808 if (!store) return; 8809 if (targetIsAnotherItem(event, store)) return; 8810 const { virtualFocus, baseElement: baseElement2 } = store.getState(); 8811 store.setActiveId(id); 8812 if (isTextbox(event.currentTarget)) { 8813 selectTextField(event.currentTarget); 8814 } 8815 if (!virtualFocus) return; 8816 if (!isSelfTarget(event)) return; 8817 if (isEditableElement(event.currentTarget)) return; 8818 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return; 8819 if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) { 8820 event.currentTarget.scrollIntoView({ 8821 block: "nearest", 8822 inline: "nearest" 8823 }); 8824 } 8825 hasFocusedComposite.current = true; 8826 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget); 8827 if (fromComposite) { 8828 focusSilently(baseElement2); 8829 } else { 8830 baseElement2.focus(); 8831 } 8832 }); 8833 const onBlurCaptureProp = props.onBlurCapture; 8834 const onBlurCapture = useEvent((event) => { 8835 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 8836 if (event.defaultPrevented) return; 8837 const state = store == null ? void 0 : store.getState(); 8838 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) { 8839 hasFocusedComposite.current = false; 8840 event.preventDefault(); 8841 event.stopPropagation(); 8842 } 8843 }); 8844 const onKeyDownProp = props.onKeyDown; 8845 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown); 8846 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 8847 const onKeyDown = useEvent((event) => { 8848 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 8849 if (event.defaultPrevented) return; 8850 if (!isSelfTarget(event)) return; 8851 if (!store) return; 8852 const { currentTarget } = event; 8853 const state = store.getState(); 8854 const item = store.item(id); 8855 const isGrid2 = !!(item == null ? void 0 : item.rowId); 8856 const isVertical = state.orientation !== "horizontal"; 8857 const isHorizontal = state.orientation !== "vertical"; 8858 const canHomeEnd = () => { 8859 if (isGrid2) return true; 8860 if (isHorizontal) return true; 8861 if (!state.baseElement) return true; 8862 if (!isTextField(state.baseElement)) return true; 8863 return false; 8864 }; 8865 const keyMap = { 8866 ArrowUp: (isGrid2 || isVertical) && store.up, 8867 ArrowRight: (isGrid2 || isHorizontal) && store.next, 8868 ArrowDown: (isGrid2 || isVertical) && store.down, 8869 ArrowLeft: (isGrid2 || isHorizontal) && store.previous, 8870 Home: () => { 8871 if (!canHomeEnd()) return; 8872 if (!isGrid2 || event.ctrlKey) { 8873 return store == null ? void 0 : store.first(); 8874 } 8875 return store == null ? void 0 : store.previous(-1); 8876 }, 8877 End: () => { 8878 if (!canHomeEnd()) return; 8879 if (!isGrid2 || event.ctrlKey) { 8880 return store == null ? void 0 : store.last(); 8881 } 8882 return store == null ? void 0 : store.next(-1); 8883 }, 8884 PageUp: () => { 8885 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true); 8886 }, 8887 PageDown: () => { 8888 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down); 8889 } 8890 }; 8891 const action = keyMap[event.key]; 8892 if (action) { 8893 if (isTextbox(currentTarget)) { 8894 const selection = getTextboxSelection(currentTarget); 8895 const isLeft = isHorizontal && event.key === "ArrowLeft"; 8896 const isRight = isHorizontal && event.key === "ArrowRight"; 8897 const isUp = isVertical && event.key === "ArrowUp"; 8898 const isDown = isVertical && event.key === "ArrowDown"; 8899 if (isRight || isDown) { 8900 const { length: valueLength } = getTextboxValue(currentTarget); 8901 if (selection.end !== valueLength) return; 8902 } else if ((isLeft || isUp) && selection.start !== 0) return; 8903 } 8904 const nextId = action(); 8905 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) { 8906 if (!moveOnKeyPressProp(event)) return; 8907 event.preventDefault(); 8908 store.move(nextId); 8909 } 8910 } 8911 }); 8912 const providerValue = (0, import_react16.useMemo)( 8913 () => ({ id, baseElement }), 8914 [id, baseElement] 8915 ); 8916 props = useWrapElement( 8917 props, 8918 (element) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }), 8919 [providerValue] 8920 ); 8921 props = __spreadProps(__spreadValues({ 8922 id, 8923 "data-active-item": isActiveItem || void 0 8924 }, props), { 8925 ref: useMergeRefs(ref, props.ref), 8926 tabIndex: isTabbable ? props.tabIndex : -1, 8927 onFocus, 8928 onBlurCapture, 8929 onKeyDown 8930 }); 8931 props = useCommand(props); 8932 props = useCollectionItem(__spreadProps(__spreadValues({ 8933 store 8934 }, props), { 8935 getItem, 8936 shouldRegisterItem: id ? props.shouldRegisterItem : false 8937 })); 8938 return removeUndefinedValues(__spreadProps(__spreadValues({}, props), { 8939 "aria-setsize": ariaSetSize, 8940 "aria-posinset": ariaPosInSet 8941 })); 8942 } 8943 ); 8944 var CompositeItem = memo22( 8945 forwardRef22(function CompositeItem2(props) { 8946 const htmlProps = useCompositeItem(props); 8947 return createElement2(TagName9, htmlProps); 8948 }) 8949 ); 8950 8951 // node_modules/@ariakit/react-core/esm/__chunks/ZTDSJLD6.js 8952 var import_react17 = __toESM(require_react(), 1); 8953 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1); 8954 var TagName10 = "div"; 8955 function isSelected(storeValue, itemValue) { 8956 if (itemValue == null) return; 8957 if (storeValue == null) return false; 8958 if (Array.isArray(storeValue)) { 8959 return storeValue.includes(itemValue); 8960 } 8961 return storeValue === itemValue; 8962 } 8963 function getItemRole(popupRole) { 8964 var _a; 8965 const itemRoleByPopupRole = { 8966 menu: "menuitem", 8967 listbox: "option", 8968 tree: "treeitem" 8969 }; 8970 const key = popupRole; 8971 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option"; 8972 } 8973 var useComboboxItem = createHook( 8974 function useComboboxItem2(_a) { 8975 var _b = _a, { 8976 store, 8977 value, 8978 hideOnClick, 8979 setValueOnClick, 8980 selectValueOnClick = true, 8981 resetValueOnSelect, 8982 focusOnHover = false, 8983 moveOnKeyPress = true, 8984 getItem: getItemProp 8985 } = _b, props = __objRest(_b, [ 8986 "store", 8987 "value", 8988 "hideOnClick", 8989 "setValueOnClick", 8990 "selectValueOnClick", 8991 "resetValueOnSelect", 8992 "focusOnHover", 8993 "moveOnKeyPress", 8994 "getItem" 8995 ]); 8996 var _a2; 8997 const context = useComboboxScopedContext(); 8998 store = store || context; 8999 invariant( 9000 store, 9001 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component." 9002 ); 9003 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, { 9004 resetValueOnSelectState: "resetValueOnSelect", 9005 multiSelectable(state) { 9006 return Array.isArray(state.selectedValue); 9007 }, 9008 selected(state) { 9009 return isSelected(state.selectedValue, value); 9010 } 9011 }); 9012 const getItem = (0, import_react17.useCallback)( 9013 (item) => { 9014 const nextItem = __spreadProps(__spreadValues({}, item), { value }); 9015 if (getItemProp) { 9016 return getItemProp(nextItem); 9017 } 9018 return nextItem; 9019 }, 9020 [value, getItemProp] 9021 ); 9022 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable; 9023 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable; 9024 const onClickProp = props.onClick; 9025 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 9026 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick); 9027 const resetValueOnSelectProp = useBooleanEvent( 9028 (_a2 = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a2 : multiSelectable 9029 ); 9030 const hideOnClickProp = useBooleanEvent(hideOnClick); 9031 const onClick = useEvent((event) => { 9032 onClickProp == null ? void 0 : onClickProp(event); 9033 if (event.defaultPrevented) return; 9034 if (isDownloading(event)) return; 9035 if (isOpeningInNewTab(event)) return; 9036 if (value != null) { 9037 if (selectValueOnClickProp(event)) { 9038 if (resetValueOnSelectProp(event)) { 9039 store == null ? void 0 : store.resetValue(); 9040 } 9041 store == null ? void 0 : store.setSelectedValue((prevValue) => { 9042 if (!Array.isArray(prevValue)) return value; 9043 if (prevValue.includes(value)) { 9044 return prevValue.filter((v2) => v2 !== value); 9045 } 9046 return [...prevValue, value]; 9047 }); 9048 } 9049 if (setValueOnClickProp(event)) { 9050 store == null ? void 0 : store.setValue(value); 9051 } 9052 } 9053 if (hideOnClickProp(event)) { 9054 store == null ? void 0 : store.hide(); 9055 } 9056 }); 9057 const onKeyDownProp = props.onKeyDown; 9058 const onKeyDown = useEvent((event) => { 9059 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 9060 if (event.defaultPrevented) return; 9061 const baseElement = store == null ? void 0 : store.getState().baseElement; 9062 if (!baseElement) return; 9063 if (hasFocus(baseElement)) return; 9064 const printable = event.key.length === 1; 9065 if (printable || event.key === "Backspace" || event.key === "Delete") { 9066 queueMicrotask(() => baseElement.focus()); 9067 if (isTextField(baseElement)) { 9068 store == null ? void 0 : store.setValue(baseElement.value); 9069 } 9070 } 9071 }); 9072 if (multiSelectable && selected != null) { 9073 props = __spreadValues({ 9074 "aria-selected": selected 9075 }, props); 9076 } 9077 props = useWrapElement( 9078 props, 9079 (element) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }), 9080 [value, selected] 9081 ); 9082 const popupRole = (0, import_react17.useContext)(ComboboxListRoleContext); 9083 props = __spreadProps(__spreadValues({ 9084 role: getItemRole(popupRole), 9085 children: value 9086 }, props), { 9087 onClick, 9088 onKeyDown 9089 }); 9090 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 9091 props = useCompositeItem(__spreadProps(__spreadValues({ 9092 store 9093 }, props), { 9094 getItem, 9095 // Dispatch a custom event on the combobox input when moving to an item 9096 // with the keyboard so the Combobox component can enable inline 9097 // autocompletion. 9098 moveOnKeyPress: (event) => { 9099 if (!moveOnKeyPressProp(event)) return false; 9100 const moveEvent = new Event("combobox-item-move"); 9101 const baseElement = store == null ? void 0 : store.getState().baseElement; 9102 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent); 9103 return true; 9104 } 9105 })); 9106 props = useCompositeHover(__spreadValues({ store, focusOnHover }, props)); 9107 return props; 9108 } 9109 ); 9110 var ComboboxItem = memo22( 9111 forwardRef22(function ComboboxItem2(props) { 9112 const htmlProps = useComboboxItem(props); 9113 return createElement2(TagName10, htmlProps); 9114 }) 9115 ); 9116 9117 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js 9118 var TagName11 = "label"; 9119 var useComboboxLabel = createHook( 9120 function useComboboxLabel2(_a) { 9121 var _b = _a, { store } = _b, props = __objRest(_b, ["store"]); 9122 const context = useComboboxProviderContext(); 9123 store = store || context; 9124 invariant( 9125 store, 9126 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component." 9127 ); 9128 const comboboxId = store.useState((state) => { 9129 var _a2; 9130 return (_a2 = state.baseElement) == null ? void 0 : _a2.id; 9131 }); 9132 props = __spreadValues({ 9133 htmlFor: comboboxId 9134 }, props); 9135 return removeUndefinedValues(props); 9136 } 9137 ); 9138 var ComboboxLabel = memo22( 9139 forwardRef22(function ComboboxLabel2(props) { 9140 const htmlProps = useComboboxLabel(props); 9141 return createElement2(TagName11, htmlProps); 9142 }) 9143 ); 9144 9145 // node_modules/@ariakit/react-core/esm/__chunks/VGCJ63VH.js 9146 var import_react18 = __toESM(require_react(), 1); 9147 var import_react_dom = __toESM(require_react_dom(), 1); 9148 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1); 9149 var TagName12 = "div"; 9150 function afterTimeout(timeoutMs, cb) { 9151 const timeoutId = setTimeout(cb, timeoutMs); 9152 return () => clearTimeout(timeoutId); 9153 } 9154 function afterPaint2(cb) { 9155 let raf = requestAnimationFrame(() => { 9156 raf = requestAnimationFrame(cb); 9157 }); 9158 return () => cancelAnimationFrame(raf); 9159 } 9160 function parseCSSTime(...times) { 9161 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => { 9162 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3; 9163 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier; 9164 if (currentTime > longestTime) return currentTime; 9165 return longestTime; 9166 }, 0); 9167 } 9168 function isHidden(mounted, hidden, alwaysVisible) { 9169 return !alwaysVisible && hidden !== false && (!mounted || !!hidden); 9170 } 9171 var useDisclosureContent = createHook(function useDisclosureContent2(_a) { 9172 var _b = _a, { store, alwaysVisible } = _b, props = __objRest(_b, ["store", "alwaysVisible"]); 9173 const context = useDisclosureProviderContext(); 9174 store = store || context; 9175 invariant( 9176 store, 9177 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component." 9178 ); 9179 const ref = (0, import_react18.useRef)(null); 9180 const id = useId3(props.id); 9181 const [transition, setTransition] = (0, import_react18.useState)(null); 9182 const open = store.useState("open"); 9183 const mounted = store.useState("mounted"); 9184 const animated = store.useState("animated"); 9185 const contentElement = store.useState("contentElement"); 9186 const otherElement = useStoreState(store.disclosure, "contentElement"); 9187 useSafeLayoutEffect(() => { 9188 if (!ref.current) return; 9189 store == null ? void 0 : store.setContentElement(ref.current); 9190 }, [store]); 9191 useSafeLayoutEffect(() => { 9192 let previousAnimated; 9193 store == null ? void 0 : store.setState("animated", (animated2) => { 9194 previousAnimated = animated2; 9195 return true; 9196 }); 9197 return () => { 9198 if (previousAnimated === void 0) return; 9199 store == null ? void 0 : store.setState("animated", previousAnimated); 9200 }; 9201 }, [store]); 9202 useSafeLayoutEffect(() => { 9203 if (!animated) return; 9204 if (!(contentElement == null ? void 0 : contentElement.isConnected)) { 9205 setTransition(null); 9206 return; 9207 } 9208 return afterPaint2(() => { 9209 setTransition(open ? "enter" : mounted ? "leave" : null); 9210 }); 9211 }, [animated, contentElement, open, mounted]); 9212 useSafeLayoutEffect(() => { 9213 if (!store) return; 9214 if (!animated) return; 9215 if (!transition) return; 9216 if (!contentElement) return; 9217 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false); 9218 const stopAnimationSync = () => (0, import_react_dom.flushSync)(stopAnimation); 9219 if (transition === "leave" && open) return; 9220 if (transition === "enter" && !open) return; 9221 if (typeof animated === "number") { 9222 const timeout2 = animated; 9223 return afterTimeout(timeout2, stopAnimationSync); 9224 } 9225 const { 9226 transitionDuration, 9227 animationDuration, 9228 transitionDelay, 9229 animationDelay 9230 } = getComputedStyle(contentElement); 9231 const { 9232 transitionDuration: transitionDuration2 = "0", 9233 animationDuration: animationDuration2 = "0", 9234 transitionDelay: transitionDelay2 = "0", 9235 animationDelay: animationDelay2 = "0" 9236 } = otherElement ? getComputedStyle(otherElement) : {}; 9237 const delay = parseCSSTime( 9238 transitionDelay, 9239 animationDelay, 9240 transitionDelay2, 9241 animationDelay2 9242 ); 9243 const duration = parseCSSTime( 9244 transitionDuration, 9245 animationDuration, 9246 transitionDuration2, 9247 animationDuration2 9248 ); 9249 const timeout = delay + duration; 9250 if (!timeout) { 9251 if (transition === "enter") { 9252 store.setState("animated", false); 9253 } 9254 stopAnimation(); 9255 return; 9256 } 9257 const frameRate = 1e3 / 60; 9258 const maxTimeout = Math.max(timeout - frameRate, 0); 9259 return afterTimeout(maxTimeout, stopAnimationSync); 9260 }, [store, animated, contentElement, otherElement, open, transition]); 9261 props = useWrapElement( 9262 props, 9263 (element) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(DialogScopedContextProvider, { value: store, children: element }), 9264 [store] 9265 ); 9266 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 9267 const styleProp = props.style; 9268 const style = (0, import_react18.useMemo)(() => { 9269 if (hidden) { 9270 return __spreadProps(__spreadValues({}, styleProp), { display: "none" }); 9271 } 9272 return styleProp; 9273 }, [hidden, styleProp]); 9274 props = __spreadProps(__spreadValues({ 9275 id, 9276 "data-open": open || void 0, 9277 "data-enter": transition === "enter" || void 0, 9278 "data-leave": transition === "leave" || void 0, 9279 hidden 9280 }, props), { 9281 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref), 9282 style 9283 }); 9284 return removeUndefinedValues(props); 9285 }); 9286 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) { 9287 const htmlProps = useDisclosureContent(props); 9288 return createElement2(TagName12, htmlProps); 9289 }); 9290 var DisclosureContent = forwardRef22(function DisclosureContent2(_a) { 9291 var _b = _a, { 9292 unmountOnHide 9293 } = _b, props = __objRest(_b, [ 9294 "unmountOnHide" 9295 ]); 9296 const context = useDisclosureProviderContext(); 9297 const store = props.store || context; 9298 const mounted = useStoreState( 9299 store, 9300 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted) 9301 ); 9302 if (mounted === false) return null; 9303 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(DisclosureContentImpl, __spreadValues({}, props)); 9304 }); 9305 9306 // node_modules/@ariakit/react-core/esm/__chunks/HUWAI7RB.js 9307 var import_react19 = __toESM(require_react(), 1); 9308 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1); 9309 var TagName13 = "div"; 9310 var useComboboxList = createHook( 9311 function useComboboxList2(_a) { 9312 var _b = _a, { store, alwaysVisible } = _b, props = __objRest(_b, ["store", "alwaysVisible"]); 9313 const scopedContext = useComboboxScopedContext(true); 9314 const context = useComboboxContext(); 9315 store = store || context; 9316 const scopedContextSameStore = !!store && store === scopedContext; 9317 invariant( 9318 store, 9319 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component." 9320 ); 9321 const ref = (0, import_react19.useRef)(null); 9322 const id = useId3(props.id); 9323 const mounted = store.useState("mounted"); 9324 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 9325 const style = hidden ? __spreadProps(__spreadValues({}, props.style), { display: "none" }) : props.style; 9326 const multiSelectable = store.useState( 9327 (state) => Array.isArray(state.selectedValue) 9328 ); 9329 const role = useAttribute(ref, "role", props.role); 9330 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid"; 9331 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0; 9332 const [hasListboxInside, setHasListboxInside] = (0, import_react19.useState)(false); 9333 const contentElement = store.useState("contentElement"); 9334 useSafeLayoutEffect(() => { 9335 if (!mounted) return; 9336 const element = ref.current; 9337 if (!element) return; 9338 if (contentElement !== element) return; 9339 const callback = () => { 9340 setHasListboxInside(!!element.querySelector("[role='listbox']")); 9341 }; 9342 const observer = new MutationObserver(callback); 9343 observer.observe(element, { 9344 subtree: true, 9345 childList: true, 9346 attributeFilter: ["role"] 9347 }); 9348 callback(); 9349 return () => observer.disconnect(); 9350 }, [mounted, contentElement]); 9351 if (!hasListboxInside) { 9352 props = __spreadValues({ 9353 role: "listbox", 9354 "aria-multiselectable": ariaMultiSelectable 9355 }, props); 9356 } 9357 props = useWrapElement( 9358 props, 9359 (element) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }), 9360 [store, role] 9361 ); 9362 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null; 9363 props = __spreadProps(__spreadValues({ 9364 id, 9365 hidden 9366 }, props), { 9367 ref: useMergeRefs(setContentElement, ref, props.ref), 9368 style 9369 }); 9370 return removeUndefinedValues(props); 9371 } 9372 ); 9373 var ComboboxList = forwardRef22(function ComboboxList2(props) { 9374 const htmlProps = useComboboxList(props); 9375 return createElement2(TagName13, htmlProps); 9376 }); 9377 9378 // packages/dataviews/build-module/components/dataviews-filters/search-widget.js 9379 var import_remove_accents = __toESM(require_remove_accents()); 9380 var import_compose7 = __toESM(require_compose()); 9381 var import_i18n21 = __toESM(require_i18n()); 9382 var import_element23 = __toESM(require_element()); 9383 var import_components21 = __toESM(require_components()); 9384 9385 // packages/dataviews/build-module/components/dataviews-filters/utils.js 9386 var EMPTY_ARRAY2 = []; 9387 var getCurrentValue = (filterDefinition, currentFilter) => { 9388 if (filterDefinition.singleSelection) { 9389 return currentFilter?.value; 9390 } 9391 if (Array.isArray(currentFilter?.value)) { 9392 return currentFilter.value; 9393 } 9394 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) { 9395 return [currentFilter.value]; 9396 } 9397 return EMPTY_ARRAY2; 9398 }; 9399 9400 // packages/dataviews/build-module/hooks/use-elements.js 9401 var import_element22 = __toESM(require_element()); 9402 var EMPTY_ARRAY3 = []; 9403 function useElements({ 9404 elements, 9405 getElements 9406 }) { 9407 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY3; 9408 const [records, setRecords] = (0, import_element22.useState)(staticElements); 9409 const [isLoading, setIsLoading] = (0, import_element22.useState)(false); 9410 (0, import_element22.useEffect)(() => { 9411 if (!getElements) { 9412 setRecords(staticElements); 9413 return; 9414 } 9415 let cancelled = false; 9416 setIsLoading(true); 9417 getElements().then((fetchedElements) => { 9418 if (!cancelled) { 9419 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements; 9420 setRecords(dynamicElements); 9421 } 9422 }).catch(() => { 9423 if (!cancelled) { 9424 setRecords(staticElements); 9425 } 9426 }).finally(() => { 9427 if (!cancelled) { 9428 setIsLoading(false); 9429 } 9430 }); 9431 return () => { 9432 cancelled = true; 9433 }; 9434 }, [getElements, staticElements]); 9435 return { 9436 elements: records, 9437 isLoading 9438 }; 9439 } 9440 9441 // packages/dataviews/build-module/components/dataviews-filters/search-widget.js 9442 var import_jsx_runtime70 = __toESM(require_jsx_runtime()); 9443 function normalizeSearchInput(input = "") { 9444 return (0, import_remove_accents.default)(input.trim().toLowerCase()); 9445 } 9446 var getNewValue = (filterDefinition, currentFilter, value) => { 9447 if (filterDefinition.singleSelection) { 9448 return value; 9449 } 9450 if (Array.isArray(currentFilter?.value)) { 9451 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value]; 9452 } 9453 return [value]; 9454 }; 9455 function generateFilterElementCompositeItemId(prefix, filterElementValue) { 9456 return `$prefix}-$filterElementValue}`; 9457 } 9458 var MultiSelectionOption = ({ selected }) => { 9459 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 9460 "span", 9461 { 9462 className: clsx_default( 9463 "dataviews-filters__search-widget-listitem-multi-selection", 9464 { "is-selected": selected } 9465 ), 9466 children: selected && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_components21.Icon, { icon: check_default }) 9467 } 9468 ); 9469 }; 9470 var SingleSelectionOption = ({ selected }) => { 9471 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 9472 "span", 9473 { 9474 className: clsx_default( 9475 "dataviews-filters__search-widget-listitem-single-selection", 9476 { "is-selected": selected } 9477 ) 9478 } 9479 ); 9480 }; 9481 function ListBox({ view, filter, onChangeView }) { 9482 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box"); 9483 const [activeCompositeId, setActiveCompositeId] = (0, import_element23.useState)( 9484 // When there are one or less operators, the first item is set as active 9485 // (by setting the initial `activeId` to `undefined`). 9486 // With 2 or more operators, the focus is moved on the operators control 9487 // (by setting the initial `activeId` to `null`), meaning that there won't 9488 // be an active item initially. Focus is then managed via the 9489 // `onFocusVisible` callback. 9490 filter.operators?.length === 1 ? void 0 : null 9491 ); 9492 const currentFilter = view.filters?.find( 9493 (f2) => f2.field === filter.field 9494 ); 9495 const currentValue = getCurrentValue(filter, currentFilter); 9496 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 9497 import_components21.Composite, 9498 { 9499 virtualFocus: true, 9500 focusLoop: true, 9501 activeId: activeCompositeId, 9502 setActiveId: setActiveCompositeId, 9503 role: "listbox", 9504 className: "dataviews-filters__search-widget-listbox", 9505 "aria-label": (0, import_i18n21.sprintf)( 9506 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */ 9507 (0, import_i18n21.__)("List of: %1$s"), 9508 filter.name 9509 ), 9510 onFocusVisible: () => { 9511 if (!activeCompositeId && filter.elements.length) { 9512 setActiveCompositeId( 9513 generateFilterElementCompositeItemId( 9514 baseId, 9515 filter.elements[0].value 9516 ) 9517 ); 9518 } 9519 }, 9520 render: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_components21.Composite.Typeahead, {}), 9521 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)( 9522 import_components21.Composite.Hover, 9523 { 9524 render: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 9525 import_components21.Composite.Item, 9526 { 9527 id: generateFilterElementCompositeItemId( 9528 baseId, 9529 element.value 9530 ), 9531 render: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 9532 "div", 9533 { 9534 "aria-label": element.label, 9535 role: "option", 9536 className: "dataviews-filters__search-widget-listitem" 9537 } 9538 ), 9539 onClick: () => { 9540 const newFilters = currentFilter ? [ 9541 ...(view.filters ?? []).map( 9542 (_filter) => { 9543 if (_filter.field === filter.field) { 9544 return { 9545 ..._filter, 9546 operator: currentFilter.operator || filter.operators[0], 9547 value: getNewValue( 9548 filter, 9549 currentFilter, 9550 element.value 9551 ) 9552 }; 9553 } 9554 return _filter; 9555 } 9556 ) 9557 ] : [ 9558 ...view.filters ?? [], 9559 { 9560 field: filter.field, 9561 operator: filter.operators[0], 9562 value: getNewValue( 9563 filter, 9564 currentFilter, 9565 element.value 9566 ) 9567 } 9568 ]; 9569 onChangeView({ 9570 ...view, 9571 page: 1, 9572 filters: newFilters 9573 }); 9574 } 9575 } 9576 ), 9577 children: [ 9578 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 9579 SingleSelectionOption, 9580 { 9581 selected: currentValue === element.value 9582 } 9583 ), 9584 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 9585 MultiSelectionOption, 9586 { 9587 selected: currentValue.includes(element.value) 9588 } 9589 ), 9590 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { children: element.label }) 9591 ] 9592 }, 9593 element.value 9594 )) 9595 } 9596 ); 9597 } 9598 function ComboboxList22({ view, filter, onChangeView }) { 9599 const [searchValue, setSearchValue] = (0, import_element23.useState)(""); 9600 const deferredSearchValue = (0, import_element23.useDeferredValue)(searchValue); 9601 const currentFilter = view.filters?.find( 9602 (_filter) => _filter.field === filter.field 9603 ); 9604 const currentValue = getCurrentValue(filter, currentFilter); 9605 const matches = (0, import_element23.useMemo)(() => { 9606 const normalizedSearch = normalizeSearchInput(deferredSearchValue); 9607 return filter.elements.filter( 9608 (item) => normalizeSearchInput(item.label).includes(normalizedSearch) 9609 ); 9610 }, [filter.elements, deferredSearchValue]); 9611 return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)( 9612 ComboboxProvider, 9613 { 9614 selectedValue: currentValue, 9615 setSelectedValue: (value) => { 9616 const newFilters = currentFilter ? [ 9617 ...(view.filters ?? []).map((_filter) => { 9618 if (_filter.field === filter.field) { 9619 return { 9620 ..._filter, 9621 operator: currentFilter.operator || filter.operators[0], 9622 value 9623 }; 9624 } 9625 return _filter; 9626 }) 9627 ] : [ 9628 ...view.filters ?? [], 9629 { 9630 field: filter.field, 9631 operator: filter.operators[0], 9632 value 9633 } 9634 ]; 9635 onChangeView({ 9636 ...view, 9637 page: 1, 9638 filters: newFilters 9639 }); 9640 }, 9641 setValue: setSearchValue, 9642 children: [ 9643 /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [ 9644 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 9645 ComboboxLabel, 9646 { 9647 render: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_components21.VisuallyHidden, { children: (0, import_i18n21.__)("Search items") }), 9648 children: (0, import_i18n21.__)("Search items") 9649 } 9650 ), 9651 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 9652 Combobox, 9653 { 9654 autoSelect: "always", 9655 placeholder: (0, import_i18n21.__)("Search"), 9656 className: "dataviews-filters__search-widget-filter-combobox__input" 9657 } 9658 ), 9659 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_components21.Icon, { icon: search_default }) }) 9660 ] }), 9661 /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)( 9662 ComboboxList, 9663 { 9664 className: "dataviews-filters__search-widget-filter-combobox-list", 9665 alwaysVisible: true, 9666 children: [ 9667 matches.map((element) => { 9668 return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)( 9669 ComboboxItem, 9670 { 9671 resetValueOnSelect: false, 9672 value: element.value, 9673 className: "dataviews-filters__search-widget-listitem", 9674 hideOnClick: false, 9675 setValueOnClick: false, 9676 focusOnHover: true, 9677 children: [ 9678 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 9679 SingleSelectionOption, 9680 { 9681 selected: currentValue === element.value 9682 } 9683 ), 9684 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 9685 MultiSelectionOption, 9686 { 9687 selected: currentValue.includes( 9688 element.value 9689 ) 9690 } 9691 ), 9692 /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { children: [ 9693 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)( 9694 ComboboxItemValue, 9695 { 9696 className: "dataviews-filters__search-widget-filter-combobox-item-value", 9697 value: element.label 9698 } 9699 ), 9700 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description }) 9701 ] }) 9702 ] 9703 }, 9704 element.value 9705 ); 9706 }), 9707 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("p", { children: (0, import_i18n21.__)("No results found") }) 9708 ] 9709 } 9710 ) 9711 ] 9712 } 9713 ); 9714 } 9715 function SearchWidget(props) { 9716 const { elements, isLoading } = useElements({ 9717 elements: props.filter.elements, 9718 getElements: props.filter.getElements 9719 }); 9720 if (isLoading) { 9721 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_components21.Spinner, {}) }); 9722 } 9723 if (elements.length === 0) { 9724 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n21.__)("No elements found") }); 9725 } 9726 const Widget = elements.length > 10 ? ComboboxList22 : ListBox; 9727 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Widget, { ...props, filter: { ...props.filter, elements } }); 9728 } 9729 9730 // packages/dataviews/build-module/components/dataviews-filters/input-widget.js 9731 var import_es6 = __toESM(require_es6()); 9732 var import_compose8 = __toESM(require_compose()); 9733 var import_element24 = __toESM(require_element()); 9734 var import_components22 = __toESM(require_components()); 9735 var import_jsx_runtime71 = __toESM(require_jsx_runtime()); 9736 function InputWidget({ 9737 filter, 9738 view, 9739 onChangeView, 9740 fields 9741 }) { 9742 const currentFilter = view.filters?.find( 9743 (f2) => f2.field === filter.field 9744 ); 9745 const currentValue = getCurrentValue(filter, currentFilter); 9746 const field = (0, import_element24.useMemo)(() => { 9747 const currentField = fields.find((f2) => f2.id === filter.field); 9748 if (currentField) { 9749 return { 9750 ...currentField, 9751 // Deactivate validation for filters. 9752 isValid: {}, 9753 // Configure getValue/setValue as if Item was a plain object. 9754 getValue: ({ item }) => item[currentField.id], 9755 setValue: ({ value }) => ({ 9756 [currentField.id]: value 9757 }) 9758 }; 9759 } 9760 return currentField; 9761 }, [fields, filter.field]); 9762 const data = (0, import_element24.useMemo)(() => { 9763 return (view.filters ?? []).reduce( 9764 (acc, activeFilter) => { 9765 acc[activeFilter.field] = activeFilter.value; 9766 return acc; 9767 }, 9768 {} 9769 ); 9770 }, [view.filters]); 9771 const handleChange = (0, import_compose8.useEvent)((updatedData) => { 9772 if (!field || !currentFilter) { 9773 return; 9774 } 9775 const nextValue = field.getValue({ item: updatedData }); 9776 if ((0, import_es6.default)(nextValue, currentValue)) { 9777 return; 9778 } 9779 onChangeView({ 9780 ...view, 9781 filters: (view.filters ?? []).map( 9782 (_filter) => _filter.field === filter.field ? { 9783 ..._filter, 9784 operator: currentFilter.operator || filter.operators[0], 9785 // Consider empty strings as undefined: 9786 // 9787 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records 9788 // - empty string as value means "search empty string": returns only the records that have an empty string as value 9789 // 9790 // In practice, this means the filter will not be able to find an empty string as the value. 9791 value: nextValue === "" ? void 0 : nextValue 9792 } : _filter 9793 ) 9794 }); 9795 }); 9796 if (!field || !field.Edit || !currentFilter) { 9797 return null; 9798 } 9799 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 9800 import_components22.Flex, 9801 { 9802 className: "dataviews-filters__user-input-widget", 9803 gap: 2.5, 9804 direction: "column", 9805 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 9806 field.Edit, 9807 { 9808 hideLabelFromVision: true, 9809 data, 9810 field, 9811 operator: currentFilter.operator, 9812 onChange: handleChange 9813 } 9814 ) 9815 } 9816 ); 9817 } 9818 9819 // packages/dataviews/build-module/utils/operators.js 9820 var import_i18n22 = __toESM(require_i18n()); 9821 var import_element25 = __toESM(require_element()); 9822 var import_jsx_runtime72 = __toESM(require_jsx_runtime()); 9823 var filterTextWrappers = { 9824 Name: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }), 9825 Value: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" }) 9826 }; 9827 var OPERATORS = [ 9828 { 9829 name: OPERATOR_IS_ANY, 9830 /* translators: DataViews operator name */ 9831 label: (0, import_i18n22.__)("Includes"), 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 any: Admin, Editor". */ 9835 (0, import_i18n22.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"), 9836 filter.name, 9837 activeElements.map((element) => element.label).join(", ") 9838 ), 9839 filterTextWrappers 9840 ), 9841 selection: "multi" 9842 }, 9843 { 9844 name: OPERATOR_IS_NONE, 9845 /* translators: DataViews operator name */ 9846 label: (0, import_i18n22.__)("Is none of"), 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 none of: Admin, Editor". */ 9850 (0, import_i18n22.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 9851 filter.name, 9852 activeElements.map((element) => element.label).join(", ") 9853 ), 9854 filterTextWrappers 9855 ), 9856 selection: "multi" 9857 }, 9858 { 9859 name: OPERATOR_IS_ALL, 9860 /* translators: DataViews operator name */ 9861 label: (0, import_i18n22.__)("Includes all"), 9862 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9863 (0, import_i18n22.sprintf)( 9864 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */ 9865 (0, import_i18n22.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"), 9866 filter.name, 9867 activeElements.map((element) => element.label).join(", ") 9868 ), 9869 filterTextWrappers 9870 ), 9871 selection: "multi" 9872 }, 9873 { 9874 name: OPERATOR_IS_NOT_ALL, 9875 /* translators: DataViews operator name */ 9876 label: (0, import_i18n22.__)("Is none of"), 9877 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9878 (0, import_i18n22.sprintf)( 9879 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 9880 (0, import_i18n22.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 9881 filter.name, 9882 activeElements.map((element) => element.label).join(", ") 9883 ), 9884 filterTextWrappers 9885 ), 9886 selection: "multi" 9887 }, 9888 { 9889 name: OPERATOR_BETWEEN, 9890 /* translators: DataViews operator name */ 9891 label: (0, import_i18n22.__)("Between (inc)"), 9892 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9893 (0, import_i18n22.sprintf)( 9894 /* 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". */ 9895 (0, import_i18n22.__)( 9896 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>" 9897 ), 9898 filter.name, 9899 activeElements[0].label[0], 9900 activeElements[0].label[1] 9901 ), 9902 filterTextWrappers 9903 ), 9904 selection: "custom" 9905 }, 9906 { 9907 name: OPERATOR_IN_THE_PAST, 9908 /* translators: DataViews operator name */ 9909 label: (0, import_i18n22.__)("In the past"), 9910 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9911 (0, import_i18n22.sprintf)( 9912 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */ 9913 (0, import_i18n22.__)( 9914 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>" 9915 ), 9916 filter.name, 9917 `$activeElements[0].value.value} $activeElements[0].value.unit}` 9918 ), 9919 filterTextWrappers 9920 ), 9921 selection: "custom" 9922 }, 9923 { 9924 name: OPERATOR_OVER, 9925 /* translators: DataViews operator name */ 9926 label: (0, import_i18n22.__)("Over"), 9927 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9928 (0, import_i18n22.sprintf)( 9929 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */ 9930 (0, import_i18n22.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"), 9931 filter.name, 9932 `$activeElements[0].value.value} $activeElements[0].value.unit}` 9933 ), 9934 filterTextWrappers 9935 ), 9936 selection: "custom" 9937 }, 9938 { 9939 name: OPERATOR_IS, 9940 /* translators: DataViews operator name */ 9941 label: (0, import_i18n22.__)("Is"), 9942 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9943 (0, import_i18n22.sprintf)( 9944 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */ 9945 (0, import_i18n22.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 9946 filter.name, 9947 activeElements[0].label 9948 ), 9949 filterTextWrappers 9950 ), 9951 selection: "single" 9952 }, 9953 { 9954 name: OPERATOR_IS_NOT, 9955 /* translators: DataViews operator name */ 9956 label: (0, import_i18n22.__)("Is not"), 9957 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9958 (0, import_i18n22.sprintf)( 9959 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */ 9960 (0, import_i18n22.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 9961 filter.name, 9962 activeElements[0].label 9963 ), 9964 filterTextWrappers 9965 ), 9966 selection: "single" 9967 }, 9968 { 9969 name: OPERATOR_LESS_THAN, 9970 /* translators: DataViews operator name */ 9971 label: (0, import_i18n22.__)("Less than"), 9972 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9973 (0, import_i18n22.sprintf)( 9974 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */ 9975 (0, import_i18n22.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"), 9976 filter.name, 9977 activeElements[0].label 9978 ), 9979 filterTextWrappers 9980 ), 9981 selection: "single" 9982 }, 9983 { 9984 name: OPERATOR_GREATER_THAN, 9985 /* translators: DataViews operator name */ 9986 label: (0, import_i18n22.__)("Greater than"), 9987 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 9988 (0, import_i18n22.sprintf)( 9989 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */ 9990 (0, import_i18n22.__)( 9991 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>" 9992 ), 9993 filter.name, 9994 activeElements[0].label 9995 ), 9996 filterTextWrappers 9997 ), 9998 selection: "single" 9999 }, 10000 { 10001 name: OPERATOR_LESS_THAN_OR_EQUAL, 10002 /* translators: DataViews operator name */ 10003 label: (0, import_i18n22.__)("Less than or equal"), 10004 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10005 (0, import_i18n22.sprintf)( 10006 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */ 10007 (0, import_i18n22.__)( 10008 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>" 10009 ), 10010 filter.name, 10011 activeElements[0].label 10012 ), 10013 filterTextWrappers 10014 ), 10015 selection: "single" 10016 }, 10017 { 10018 name: OPERATOR_GREATER_THAN_OR_EQUAL, 10019 /* translators: DataViews operator name */ 10020 label: (0, import_i18n22.__)("Greater than or equal"), 10021 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10022 (0, import_i18n22.sprintf)( 10023 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */ 10024 (0, import_i18n22.__)( 10025 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>" 10026 ), 10027 filter.name, 10028 activeElements[0].label 10029 ), 10030 filterTextWrappers 10031 ), 10032 selection: "single" 10033 }, 10034 { 10035 name: OPERATOR_BEFORE, 10036 /* translators: DataViews operator name */ 10037 label: (0, import_i18n22.__)("Before"), 10038 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10039 (0, import_i18n22.sprintf)( 10040 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */ 10041 (0, import_i18n22.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"), 10042 filter.name, 10043 activeElements[0].label 10044 ), 10045 filterTextWrappers 10046 ), 10047 selection: "single" 10048 }, 10049 { 10050 name: OPERATOR_AFTER, 10051 /* translators: DataViews operator name */ 10052 label: (0, import_i18n22.__)("After"), 10053 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10054 (0, import_i18n22.sprintf)( 10055 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */ 10056 (0, import_i18n22.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"), 10057 filter.name, 10058 activeElements[0].label 10059 ), 10060 filterTextWrappers 10061 ), 10062 selection: "single" 10063 }, 10064 { 10065 name: OPERATOR_BEFORE_INC, 10066 /* translators: DataViews operator name */ 10067 label: (0, import_i18n22.__)("Before (inc)"), 10068 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10069 (0, import_i18n22.sprintf)( 10070 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */ 10071 (0, import_i18n22.__)( 10072 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>" 10073 ), 10074 filter.name, 10075 activeElements[0].label 10076 ), 10077 filterTextWrappers 10078 ), 10079 selection: "single" 10080 }, 10081 { 10082 name: OPERATOR_AFTER_INC, 10083 /* translators: DataViews operator name */ 10084 label: (0, import_i18n22.__)("After (inc)"), 10085 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10086 (0, import_i18n22.sprintf)( 10087 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */ 10088 (0, import_i18n22.__)( 10089 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>" 10090 ), 10091 filter.name, 10092 activeElements[0].label 10093 ), 10094 filterTextWrappers 10095 ), 10096 selection: "single" 10097 }, 10098 { 10099 name: OPERATOR_CONTAINS, 10100 /* translators: DataViews operator name */ 10101 label: (0, import_i18n22.__)("Contains"), 10102 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10103 (0, import_i18n22.sprintf)( 10104 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */ 10105 (0, import_i18n22.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"), 10106 filter.name, 10107 activeElements[0].label 10108 ), 10109 filterTextWrappers 10110 ), 10111 selection: "single" 10112 }, 10113 { 10114 name: OPERATOR_NOT_CONTAINS, 10115 /* translators: DataViews operator name */ 10116 label: (0, import_i18n22.__)("Doesn't contain"), 10117 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10118 (0, import_i18n22.sprintf)( 10119 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */ 10120 (0, import_i18n22.__)( 10121 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>" 10122 ), 10123 filter.name, 10124 activeElements[0].label 10125 ), 10126 filterTextWrappers 10127 ), 10128 selection: "single" 10129 }, 10130 { 10131 name: OPERATOR_STARTS_WITH, 10132 /* translators: DataViews operator name */ 10133 label: (0, import_i18n22.__)("Starts with"), 10134 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10135 (0, import_i18n22.sprintf)( 10136 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */ 10137 (0, import_i18n22.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"), 10138 filter.name, 10139 activeElements[0].label 10140 ), 10141 filterTextWrappers 10142 ), 10143 selection: "single" 10144 }, 10145 { 10146 name: OPERATOR_ON, 10147 /* translators: DataViews operator name */ 10148 label: (0, import_i18n22.__)("On"), 10149 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10150 (0, import_i18n22.sprintf)( 10151 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */ 10152 (0, import_i18n22.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 10153 filter.name, 10154 activeElements[0].label 10155 ), 10156 filterTextWrappers 10157 ), 10158 selection: "single" 10159 }, 10160 { 10161 name: OPERATOR_NOT_ON, 10162 /* translators: DataViews operator name */ 10163 label: (0, import_i18n22.__)("Not on"), 10164 filterText: (filter, activeElements) => (0, import_element25.createInterpolateElement)( 10165 (0, import_i18n22.sprintf)( 10166 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */ 10167 (0, import_i18n22.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 10168 filter.name, 10169 activeElements[0].label 10170 ), 10171 filterTextWrappers 10172 ), 10173 selection: "single" 10174 } 10175 ]; 10176 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name); 10177 var getAllOperatorNames = () => OPERATORS.map((op) => op.name); 10178 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some( 10179 (op) => op.name === name 10180 ); 10181 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name); 10182 10183 // packages/dataviews/build-module/components/dataviews-filters/filter.js 10184 var import_jsx_runtime73 = __toESM(require_jsx_runtime()); 10185 var ENTER = "Enter"; 10186 var SPACE = " "; 10187 var FilterText = ({ 10188 activeElements, 10189 filterInView, 10190 filter 10191 }) => { 10192 if (activeElements === void 0 || activeElements.length === 0) { 10193 return filter.name; 10194 } 10195 const operator = getOperatorByName(filterInView?.operator); 10196 if (operator !== void 0) { 10197 return operator.filterText(filter, activeElements); 10198 } 10199 return (0, import_i18n23.sprintf)( 10200 /* translators: 1: Filter name e.g.: "Unknown status for Author". */ 10201 (0, import_i18n23.__)("Unknown status for %1$s"), 10202 filter.name 10203 ); 10204 }; 10205 function OperatorSelector({ 10206 filter, 10207 view, 10208 onChangeView 10209 }) { 10210 const operatorOptions = filter.operators?.map((operator) => ({ 10211 value: operator, 10212 label: getOperatorByName(operator)?.label || operator 10213 })); 10214 const currentFilter = view.filters?.find( 10215 (_filter) => _filter.field === filter.field 10216 ); 10217 const value = currentFilter?.operator || filter.operators[0]; 10218 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)( 10219 import_components23.__experimentalHStack, 10220 { 10221 spacing: 2, 10222 justify: "flex-start", 10223 className: "dataviews-filters__summary-operators-container", 10224 children: [ 10225 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_components23.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }), 10226 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 10227 import_components23.SelectControl, 10228 { 10229 className: "dataviews-filters__summary-operators-filter-select", 10230 label: (0, import_i18n23.__)("Conditions"), 10231 value, 10232 options: operatorOptions, 10233 onChange: (newValue) => { 10234 const newOperator = newValue; 10235 const currentOperator = currentFilter?.operator; 10236 const newFilters = currentFilter ? [ 10237 ...(view.filters ?? []).map( 10238 (_filter) => { 10239 if (_filter.field === filter.field) { 10240 const currentOpSelectionModel = getOperatorByName( 10241 currentOperator 10242 )?.selection; 10243 const newOpSelectionModel = getOperatorByName( 10244 newOperator 10245 )?.selection; 10246 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [ 10247 currentOpSelectionModel, 10248 newOpSelectionModel 10249 ].includes("custom"); 10250 return { 10251 ..._filter, 10252 value: shouldResetValue ? void 0 : _filter.value, 10253 operator: newOperator 10254 }; 10255 } 10256 return _filter; 10257 } 10258 ) 10259 ] : [ 10260 ...view.filters ?? [], 10261 { 10262 field: filter.field, 10263 operator: newOperator, 10264 value: void 0 10265 } 10266 ]; 10267 onChangeView({ 10268 ...view, 10269 page: 1, 10270 filters: newFilters 10271 }); 10272 }, 10273 size: "small", 10274 variant: "minimal", 10275 hideLabelFromVision: true 10276 } 10277 ) 10278 ] 10279 } 10280 ); 10281 } 10282 function Filter({ 10283 addFilterRef, 10284 openedFilter, 10285 fields, 10286 ...commonProps 10287 }) { 10288 const toggleRef = (0, import_element26.useRef)(null); 10289 const { filter, view, onChangeView } = commonProps; 10290 const filterInView = view.filters?.find( 10291 (f2) => f2.field === filter.field 10292 ); 10293 let activeElements = []; 10294 const field = (0, import_element26.useMemo)(() => { 10295 const currentField = fields.find((f2) => f2.id === filter.field); 10296 if (currentField) { 10297 return { 10298 ...currentField, 10299 // Configure getValue as if Item was a plain object. 10300 // See related input-widget.tsx 10301 getValue: ({ item }) => item[currentField.id] 10302 }; 10303 } 10304 return currentField; 10305 }, [fields, filter.field]); 10306 const { elements } = useElements({ 10307 elements: filter.elements, 10308 getElements: filter.getElements 10309 }); 10310 if (elements.length > 0) { 10311 activeElements = elements.filter((element) => { 10312 if (filter.singleSelection) { 10313 return element.value === filterInView?.value; 10314 } 10315 return filterInView?.value?.includes(element.value); 10316 }); 10317 } else if (Array.isArray(filterInView?.value)) { 10318 const label = filterInView.value.map((v2) => { 10319 const formattedValue = field?.getValueFormatted({ 10320 item: { [field.id]: v2 }, 10321 field 10322 }); 10323 return formattedValue || String(v2); 10324 }); 10325 activeElements = [ 10326 { 10327 value: filterInView.value, 10328 // @ts-ignore 10329 label 10330 } 10331 ]; 10332 } else if (typeof filterInView?.value === "object") { 10333 activeElements = [ 10334 { value: filterInView.value, label: filterInView.value } 10335 ]; 10336 } else if (filterInView?.value !== void 0) { 10337 const label = field !== void 0 ? field.getValueFormatted({ 10338 item: { [field.id]: filterInView.value }, 10339 field 10340 }) : String(filterInView.value); 10341 activeElements = [ 10342 { 10343 value: filterInView.value, 10344 label 10345 } 10346 ]; 10347 } 10348 const isPrimary = filter.isPrimary; 10349 const isLocked = filterInView?.isLocked; 10350 const hasValues = !isLocked && filterInView?.value !== void 0; 10351 const canResetOrRemove = !isLocked && (!isPrimary || hasValues); 10352 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 10353 import_components23.Dropdown, 10354 { 10355 defaultOpen: openedFilter === filter.field, 10356 contentClassName: "dataviews-filters__summary-popover", 10357 popoverProps: { placement: "bottom-start", role: "dialog" }, 10358 onClose: () => { 10359 toggleRef.current?.focus(); 10360 }, 10361 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [ 10362 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 10363 import_components23.Tooltip, 10364 { 10365 text: (0, import_i18n23.sprintf)( 10366 /* translators: 1: Filter name. */ 10367 (0, import_i18n23.__)("Filter by: %1$s"), 10368 filter.name.toLowerCase() 10369 ), 10370 placement: "top", 10371 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 10372 "div", 10373 { 10374 className: clsx_default( 10375 "dataviews-filters__summary-chip", 10376 { 10377 "has-reset": canResetOrRemove, 10378 "has-values": hasValues, 10379 "is-not-clickable": isLocked 10380 } 10381 ), 10382 role: "button", 10383 tabIndex: isLocked ? -1 : 0, 10384 onClick: () => { 10385 if (!isLocked) { 10386 onToggle(); 10387 } 10388 }, 10389 onKeyDown: (event) => { 10390 if (!isLocked && [ENTER, SPACE].includes(event.key)) { 10391 onToggle(); 10392 event.preventDefault(); 10393 } 10394 }, 10395 "aria-disabled": isLocked, 10396 "aria-pressed": isOpen, 10397 "aria-expanded": isOpen, 10398 ref: toggleRef, 10399 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 10400 FilterText, 10401 { 10402 activeElements, 10403 filterInView, 10404 filter 10405 } 10406 ) 10407 } 10408 ) 10409 } 10410 ), 10411 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 10412 import_components23.Tooltip, 10413 { 10414 text: isPrimary ? (0, import_i18n23.__)("Reset") : (0, import_i18n23.__)("Remove"), 10415 placement: "top", 10416 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 10417 "button", 10418 { 10419 className: clsx_default( 10420 "dataviews-filters__summary-chip-remove", 10421 { "has-values": hasValues } 10422 ), 10423 onClick: () => { 10424 onChangeView({ 10425 ...view, 10426 page: 1, 10427 filters: view.filters?.filter( 10428 (_filter) => _filter.field !== filter.field 10429 ) 10430 }); 10431 if (!isPrimary) { 10432 addFilterRef.current?.focus(); 10433 } else { 10434 toggleRef.current?.focus(); 10435 } 10436 }, 10437 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_components23.Icon, { icon: close_small_default }) 10438 } 10439 ) 10440 } 10441 ) 10442 ] }), 10443 renderContent: () => { 10444 return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_components23.__experimentalVStack, { spacing: 0, justify: "flex-start", children: [ 10445 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(OperatorSelector, { ...commonProps }), 10446 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 10447 SearchWidget, 10448 { 10449 ...commonProps, 10450 filter: { 10451 ...commonProps.filter, 10452 elements 10453 } 10454 } 10455 ) : /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(InputWidget, { ...commonProps, fields }) 10456 ] }); 10457 } 10458 } 10459 ); 10460 } 10461 10462 // packages/dataviews/build-module/components/dataviews-filters/add-filter.js 10463 var import_components24 = __toESM(require_components()); 10464 var import_i18n24 = __toESM(require_i18n()); 10465 var import_element27 = __toESM(require_element()); 10466 var import_jsx_runtime74 = __toESM(require_jsx_runtime()); 10467 var { Menu: Menu4 } = unlock(import_components24.privateApis); 10468 function AddFilterMenu({ 10469 filters, 10470 view, 10471 onChangeView, 10472 setOpenedFilter, 10473 triggerProps 10474 }) { 10475 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 10476 return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(Menu4, { children: [ 10477 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Menu4.TriggerButton, { ...triggerProps }), 10478 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => { 10479 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 10480 Menu4.Item, 10481 { 10482 onClick: () => { 10483 setOpenedFilter(filter.field); 10484 onChangeView({ 10485 ...view, 10486 page: 1, 10487 filters: [ 10488 ...view.filters || [], 10489 { 10490 field: filter.field, 10491 value: void 0, 10492 operator: filter.operators[0] 10493 } 10494 ] 10495 }); 10496 }, 10497 children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Menu4.ItemLabel, { children: filter.name }) 10498 }, 10499 filter.field 10500 ); 10501 }) }) 10502 ] }); 10503 } 10504 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) { 10505 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) { 10506 return null; 10507 } 10508 const inactiveFilters = filters.filter((filter) => !filter.isVisible); 10509 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 10510 AddFilterMenu, 10511 { 10512 triggerProps: { 10513 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)( 10514 import_components24.Button, 10515 { 10516 accessibleWhenDisabled: true, 10517 size: "compact", 10518 className: "dataviews-filters-button", 10519 variant: "tertiary", 10520 disabled: !inactiveFilters.length, 10521 ref 10522 } 10523 ), 10524 children: (0, import_i18n24.__)("Add filter") 10525 }, 10526 ...{ filters, view, onChangeView, setOpenedFilter } 10527 } 10528 ); 10529 } 10530 var add_filter_default = (0, import_element27.forwardRef)(AddFilter); 10531 10532 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.js 10533 var import_components25 = __toESM(require_components()); 10534 var import_i18n25 = __toESM(require_i18n()); 10535 var import_jsx_runtime75 = __toESM(require_jsx_runtime()); 10536 function ResetFilter({ 10537 filters, 10538 view, 10539 onChangeView 10540 }) { 10541 const isPrimary = (field) => filters.some( 10542 (_filter) => _filter.field === field && _filter.isPrimary 10543 ); 10544 const isDisabled = !view.search && !view.filters?.some( 10545 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field)) 10546 ); 10547 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)( 10548 import_components25.Button, 10549 { 10550 disabled: isDisabled, 10551 accessibleWhenDisabled: true, 10552 size: "compact", 10553 variant: "tertiary", 10554 className: "dataviews-filters__reset-button", 10555 onClick: () => { 10556 onChangeView({ 10557 ...view, 10558 page: 1, 10559 search: "", 10560 filters: view.filters?.filter((f2) => !!f2.isLocked) || [] 10561 }); 10562 }, 10563 children: (0, import_i18n25.__)("Reset") 10564 } 10565 ); 10566 } 10567 10568 // packages/dataviews/build-module/components/dataviews-filters/use-filters.js 10569 var import_element28 = __toESM(require_element()); 10570 function useFilters(fields, view) { 10571 return (0, import_element28.useMemo)(() => { 10572 const filters = []; 10573 fields.forEach((field) => { 10574 if (field.filterBy === false || !field.hasElements && !field.Edit) { 10575 return; 10576 } 10577 const operators = field.filterBy.operators; 10578 const isPrimary = !!field.filterBy?.isPrimary; 10579 const isLocked = view.filters?.some( 10580 (f2) => f2.field === field.id && !!f2.isLocked 10581 ) ?? false; 10582 filters.push({ 10583 field: field.id, 10584 name: field.label, 10585 elements: field.elements, 10586 getElements: field.getElements, 10587 hasElements: field.hasElements, 10588 singleSelection: operators.some( 10589 (op) => isSingleSelectionOperator(op) 10590 ), 10591 operators, 10592 isVisible: isLocked || isPrimary || !!view.filters?.some( 10593 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator) 10594 ), 10595 isPrimary, 10596 isLocked 10597 }); 10598 }); 10599 filters.sort((a2, b2) => { 10600 if (a2.isLocked && !b2.isLocked) { 10601 return -1; 10602 } 10603 if (!a2.isLocked && b2.isLocked) { 10604 return 1; 10605 } 10606 if (a2.isPrimary && !b2.isPrimary) { 10607 return -1; 10608 } 10609 if (!a2.isPrimary && b2.isPrimary) { 10610 return 1; 10611 } 10612 return a2.name.localeCompare(b2.name); 10613 }); 10614 return filters; 10615 }, [fields, view]); 10616 } 10617 var use_filters_default = useFilters; 10618 10619 // packages/dataviews/build-module/components/dataviews-filters/filters.js 10620 var import_jsx_runtime76 = __toESM(require_jsx_runtime()); 10621 function Filters({ className }) { 10622 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element29.useContext)(dataviews_context_default); 10623 const addFilterRef = (0, import_element29.useRef)(null); 10624 const filters = use_filters_default(fields, view); 10625 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 10626 add_filter_default, 10627 { 10628 filters, 10629 view, 10630 onChangeView, 10631 ref: addFilterRef, 10632 setOpenedFilter 10633 }, 10634 "add-filter" 10635 ); 10636 const visibleFilters = filters.filter((filter) => filter.isVisible); 10637 if (visibleFilters.length === 0) { 10638 return null; 10639 } 10640 const filterComponents = [ 10641 ...visibleFilters.map((filter) => { 10642 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 10643 Filter, 10644 { 10645 filter, 10646 view, 10647 fields, 10648 onChangeView, 10649 addFilterRef, 10650 openedFilter 10651 }, 10652 filter.field 10653 ); 10654 }), 10655 addFilter 10656 ]; 10657 filterComponents.push( 10658 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 10659 ResetFilter, 10660 { 10661 filters, 10662 view, 10663 onChangeView 10664 }, 10665 "reset-filters" 10666 ) 10667 ); 10668 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)( 10669 import_components26.__experimentalHStack, 10670 { 10671 justify: "flex-start", 10672 style: { width: "fit-content" }, 10673 wrap: true, 10674 className, 10675 children: filterComponents 10676 } 10677 ); 10678 } 10679 var filters_default = (0, import_element29.memo)(Filters); 10680 10681 // packages/dataviews/build-module/components/dataviews-filters/toggle.js 10682 var import_element30 = __toESM(require_element()); 10683 var import_components27 = __toESM(require_components()); 10684 var import_i18n26 = __toESM(require_i18n()); 10685 var import_jsx_runtime77 = __toESM(require_jsx_runtime()); 10686 function FiltersToggle() { 10687 const { 10688 filters, 10689 view, 10690 onChangeView, 10691 setOpenedFilter, 10692 isShowingFilter, 10693 setIsShowingFilter 10694 } = (0, import_element30.useContext)(dataviews_context_default); 10695 const buttonRef = (0, import_element30.useRef)(null); 10696 const onChangeViewWithFilterVisibility = (0, import_element30.useCallback)( 10697 (_view) => { 10698 onChangeView(_view); 10699 setIsShowingFilter(true); 10700 }, 10701 [onChangeView, setIsShowingFilter] 10702 ); 10703 const visibleFilters = filters.filter((filter) => filter.isVisible); 10704 const hasVisibleFilters = !!visibleFilters.length; 10705 if (filters.length === 0) { 10706 return null; 10707 } 10708 const addFilterButtonProps = { 10709 label: (0, import_i18n26.__)("Add filter"), 10710 "aria-expanded": false, 10711 isPressed: false 10712 }; 10713 const toggleFiltersButtonProps = { 10714 label: (0, import_i18n26._x)("Filter", "verb"), 10715 "aria-expanded": isShowingFilter, 10716 isPressed: isShowingFilter, 10717 onClick: () => { 10718 if (!isShowingFilter) { 10719 setOpenedFilter(null); 10720 } 10721 setIsShowingFilter(!isShowingFilter); 10722 } 10723 }; 10724 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 10725 import_components27.Button, 10726 { 10727 ref: buttonRef, 10728 className: "dataviews-filters__visibility-toggle", 10729 size: "compact", 10730 icon: funnel_default, 10731 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps 10732 } 10733 ); 10734 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 10735 AddFilterMenu, 10736 { 10737 filters, 10738 view, 10739 onChangeView: onChangeViewWithFilterVisibility, 10740 setOpenedFilter, 10741 triggerProps: { render: buttonComponent } 10742 } 10743 ) : /* @__PURE__ */ (0, import_jsx_runtime77.jsx)( 10744 FilterVisibilityToggle, 10745 { 10746 buttonRef, 10747 filtersCount: view.filters?.length, 10748 children: buttonComponent 10749 } 10750 ) }); 10751 } 10752 function FilterVisibilityToggle({ 10753 buttonRef, 10754 filtersCount, 10755 children 10756 }) { 10757 (0, import_element30.useEffect)( 10758 () => () => { 10759 buttonRef.current?.focus(); 10760 }, 10761 [buttonRef] 10762 ); 10763 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_jsx_runtime77.Fragment, { children: [ 10764 children, 10765 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount }) 10766 ] }); 10767 } 10768 var toggle_default = FiltersToggle; 10769 10770 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.js 10771 var import_element31 = __toESM(require_element()); 10772 var import_jsx_runtime78 = __toESM(require_jsx_runtime()); 10773 function FiltersToggled(props) { 10774 const { isShowingFilter } = (0, import_element31.useContext)(dataviews_context_default); 10775 if (!isShowingFilter) { 10776 return null; 10777 } 10778 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(filters_default, { ...props }); 10779 } 10780 var filters_toggled_default = FiltersToggled; 10781 10782 // packages/dataviews/build-module/components/dataviews-layout/index.js 10783 var import_element32 = __toESM(require_element()); 10784 var import_i18n27 = __toESM(require_i18n()); 10785 var import_jsx_runtime79 = __toESM(require_jsx_runtime()); 10786 function DataViewsLayout({ className }) { 10787 const { 10788 actions = [], 10789 data, 10790 fields, 10791 getItemId: getItemId2, 10792 getItemLevel, 10793 isLoading, 10794 view, 10795 onChangeView, 10796 selection, 10797 onChangeSelection, 10798 setOpenedFilter, 10799 onClickItem, 10800 isItemClickable, 10801 renderItemLink, 10802 defaultLayouts, 10803 empty = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { children: (0, import_i18n27.__)("No results") }) 10804 } = (0, import_element32.useContext)(dataviews_context_default); 10805 const ViewComponent = VIEW_LAYOUTS.find( 10806 (v2) => v2.type === view.type && defaultLayouts[v2.type] 10807 )?.component; 10808 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)( 10809 ViewComponent, 10810 { 10811 className, 10812 actions, 10813 data, 10814 fields, 10815 getItemId: getItemId2, 10816 getItemLevel, 10817 isLoading, 10818 onChangeView, 10819 onChangeSelection, 10820 selection, 10821 setOpenedFilter, 10822 onClickItem, 10823 renderItemLink, 10824 isItemClickable, 10825 view, 10826 empty 10827 } 10828 ); 10829 } 10830 10831 // packages/dataviews/build-module/components/dataviews-footer/index.js 10832 var import_components28 = __toESM(require_components()); 10833 var import_element33 = __toESM(require_element()); 10834 var import_jsx_runtime80 = __toESM(require_jsx_runtime()); 10835 var EMPTY_ARRAY4 = []; 10836 function DataViewsFooter() { 10837 const { 10838 view, 10839 paginationInfo: { totalItems = 0, totalPages }, 10840 data, 10841 actions = EMPTY_ARRAY4 10842 } = (0, import_element33.useContext)(dataviews_context_default); 10843 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type); 10844 if (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions) { 10845 return null; 10846 } 10847 return !!totalItems && /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)( 10848 import_components28.__experimentalHStack, 10849 { 10850 expanded: false, 10851 justify: "end", 10852 className: "dataviews-footer", 10853 children: [ 10854 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(BulkActionsFooter, {}), 10855 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(dataviews_pagination_default, {}) 10856 ] 10857 } 10858 ); 10859 } 10860 10861 // packages/dataviews/build-module/components/dataviews-search/index.js 10862 var import_i18n28 = __toESM(require_i18n()); 10863 var import_element34 = __toESM(require_element()); 10864 var import_components29 = __toESM(require_components()); 10865 var import_compose9 = __toESM(require_compose()); 10866 var import_jsx_runtime81 = __toESM(require_jsx_runtime()); 10867 var DataViewsSearch = (0, import_element34.memo)(function Search({ label }) { 10868 const { view, onChangeView } = (0, import_element34.useContext)(dataviews_context_default); 10869 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)( 10870 view.search 10871 ); 10872 (0, import_element34.useEffect)(() => { 10873 setSearch(view.search ?? ""); 10874 }, [view.search, setSearch]); 10875 const onChangeViewRef = (0, import_element34.useRef)(onChangeView); 10876 const viewRef = (0, import_element34.useRef)(view); 10877 (0, import_element34.useEffect)(() => { 10878 onChangeViewRef.current = onChangeView; 10879 viewRef.current = view; 10880 }, [onChangeView, view]); 10881 (0, import_element34.useEffect)(() => { 10882 if (debouncedSearch !== viewRef.current?.search) { 10883 onChangeViewRef.current({ 10884 ...viewRef.current, 10885 page: 1, 10886 search: debouncedSearch 10887 }); 10888 } 10889 }, [debouncedSearch]); 10890 const searchLabel = label || (0, import_i18n28.__)("Search"); 10891 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)( 10892 import_components29.SearchControl, 10893 { 10894 className: "dataviews-search", 10895 onChange: setSearch, 10896 value: search, 10897 label: searchLabel, 10898 placeholder: searchLabel, 10899 size: "compact" 10900 } 10901 ); 10902 }); 10903 var dataviews_search_default = DataViewsSearch; 10904 10905 // packages/dataviews/build-module/components/dataviews-view-config/index.js 10906 var import_components31 = __toESM(require_components()); 10907 var import_i18n30 = __toESM(require_i18n()); 10908 var import_element36 = __toESM(require_element()); 10909 var import_warning = __toESM(require_warning()); 10910 var import_compose10 = __toESM(require_compose()); 10911 10912 // packages/dataviews/build-module/components/dataviews-view-config/infinite-scroll-toggle.js 10913 var import_components30 = __toESM(require_components()); 10914 var import_i18n29 = __toESM(require_i18n()); 10915 var import_element35 = __toESM(require_element()); 10916 var import_jsx_runtime82 = __toESM(require_jsx_runtime()); 10917 function InfiniteScrollToggle() { 10918 const context = (0, import_element35.useContext)(dataviews_context_default); 10919 const { view, onChangeView } = context; 10920 const infiniteScrollEnabled = view.infiniteScrollEnabled ?? false; 10921 if (!context.hasInfiniteScrollHandler) { 10922 return null; 10923 } 10924 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)( 10925 import_components30.ToggleControl, 10926 { 10927 label: (0, import_i18n29.__)("Enable infinite scroll"), 10928 help: (0, import_i18n29.__)( 10929 "Automatically load more content as you scroll, instead of showing pagination links." 10930 ), 10931 checked: infiniteScrollEnabled, 10932 onChange: (newValue) => { 10933 onChangeView({ 10934 ...view, 10935 infiniteScrollEnabled: newValue 10936 }); 10937 } 10938 } 10939 ); 10940 } 10941 10942 // packages/dataviews/build-module/components/dataviews-view-config/index.js 10943 var import_jsx_runtime83 = __toESM(require_jsx_runtime()); 10944 var { Menu: Menu5 } = unlock(import_components31.privateApis); 10945 var DATAVIEWS_CONFIG_POPOVER_PROPS = { 10946 className: "dataviews-config__popover", 10947 placement: "bottom-end", 10948 offset: 9 10949 }; 10950 function ViewTypeMenu() { 10951 const { view, onChangeView, defaultLayouts } = (0, import_element36.useContext)(dataviews_context_default); 10952 const availableLayouts = Object.keys(defaultLayouts); 10953 if (availableLayouts.length <= 1) { 10954 return null; 10955 } 10956 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type); 10957 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Menu5, { children: [ 10958 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 10959 Menu5.TriggerButton, 10960 { 10961 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 10962 import_components31.Button, 10963 { 10964 size: "compact", 10965 icon: activeView?.icon, 10966 label: (0, import_i18n30.__)("Layout") 10967 } 10968 ) 10969 } 10970 ), 10971 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => { 10972 const config = VIEW_LAYOUTS.find( 10973 (v2) => v2.type === layout 10974 ); 10975 if (!config) { 10976 return null; 10977 } 10978 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 10979 Menu5.RadioItem, 10980 { 10981 value: layout, 10982 name: "view-actions-available-view", 10983 checked: layout === view.type, 10984 hideOnClick: true, 10985 onChange: (e2) => { 10986 switch (e2.target.value) { 10987 case "list": 10988 case "grid": 10989 case "table": 10990 case "pickerGrid": 10991 case "pickerTable": 10992 case "activity": 10993 const viewWithoutLayout = { ...view }; 10994 if ("layout" in viewWithoutLayout) { 10995 delete viewWithoutLayout.layout; 10996 } 10997 return onChangeView({ 10998 ...viewWithoutLayout, 10999 type: e2.target.value, 11000 ...defaultLayouts[e2.target.value] 11001 }); 11002 } 11003 (0, import_warning.default)("Invalid dataview"); 11004 }, 11005 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu5.ItemLabel, { children: config.label }) 11006 }, 11007 layout 11008 ); 11009 }) }) 11010 ] }); 11011 } 11012 function SortFieldControl() { 11013 const { view, fields, onChangeView } = (0, import_element36.useContext)(dataviews_context_default); 11014 const orderOptions = (0, import_element36.useMemo)(() => { 11015 const sortableFields = fields.filter( 11016 (field) => field.enableSorting !== false 11017 ); 11018 return sortableFields.map((field) => { 11019 return { 11020 label: field.label, 11021 value: field.id 11022 }; 11023 }); 11024 }, [fields]); 11025 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 11026 import_components31.SelectControl, 11027 { 11028 __next40pxDefaultSize: true, 11029 label: (0, import_i18n30.__)("Sort by"), 11030 value: view.sort?.field, 11031 options: orderOptions, 11032 onChange: (value) => { 11033 onChangeView({ 11034 ...view, 11035 sort: { 11036 direction: view?.sort?.direction || "desc", 11037 field: value 11038 }, 11039 showLevels: false 11040 }); 11041 } 11042 } 11043 ); 11044 } 11045 function SortDirectionControl() { 11046 const { view, fields, onChangeView } = (0, import_element36.useContext)(dataviews_context_default); 11047 const sortableFields = fields.filter( 11048 (field) => field.enableSorting !== false 11049 ); 11050 if (sortableFields.length === 0) { 11051 return null; 11052 } 11053 let value = view.sort?.direction; 11054 if (!value && view.sort?.field) { 11055 value = "desc"; 11056 } 11057 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 11058 import_components31.__experimentalToggleGroupControl, 11059 { 11060 className: "dataviews-view-config__sort-direction", 11061 __next40pxDefaultSize: true, 11062 isBlock: true, 11063 label: (0, import_i18n30.__)("Order"), 11064 value, 11065 onChange: (newDirection) => { 11066 if (newDirection === "asc" || newDirection === "desc") { 11067 onChangeView({ 11068 ...view, 11069 sort: { 11070 direction: newDirection, 11071 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field. 11072 fields.find( 11073 (field) => field.enableSorting !== false 11074 )?.id || "" 11075 }, 11076 showLevels: false 11077 }); 11078 return; 11079 } 11080 (0, import_warning.default)("Invalid direction"); 11081 }, 11082 children: SORTING_DIRECTIONS.map((direction) => { 11083 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 11084 import_components31.__experimentalToggleGroupControlOptionIcon, 11085 { 11086 value: direction, 11087 icon: sortIcons[direction], 11088 label: sortLabels[direction] 11089 }, 11090 direction 11091 ); 11092 }) 11093 } 11094 ); 11095 } 11096 function ItemsPerPageControl() { 11097 const { view, config, onChangeView } = (0, import_element36.useContext)(dataviews_context_default); 11098 const { infiniteScrollEnabled } = view; 11099 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) { 11100 return null; 11101 } 11102 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 11103 import_components31.__experimentalToggleGroupControl, 11104 { 11105 __next40pxDefaultSize: true, 11106 isBlock: true, 11107 label: (0, import_i18n30.__)("Items per page"), 11108 value: view.perPage || 10, 11109 disabled: !view?.sort?.field, 11110 onChange: (newItemsPerPage) => { 11111 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10); 11112 onChangeView({ 11113 ...view, 11114 perPage: newItemsPerPageNumber, 11115 page: 1 11116 }); 11117 }, 11118 children: config.perPageSizes.map((value) => { 11119 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 11120 import_components31.__experimentalToggleGroupControlOption, 11121 { 11122 value, 11123 label: value.toString() 11124 }, 11125 value 11126 ); 11127 }) 11128 } 11129 ); 11130 } 11131 function SettingsSection({ 11132 title, 11133 description, 11134 children 11135 }) { 11136 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_components31.__experimentalGrid, { columns: 12, className: "dataviews-settings-section", gap: 4, children: [ 11137 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "dataviews-settings-section__sidebar", children: [ 11138 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 11139 import_components31.__experimentalHeading, 11140 { 11141 level: 2, 11142 className: "dataviews-settings-section__title", 11143 children: title 11144 } 11145 ), 11146 description && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 11147 import_components31.__experimentalText, 11148 { 11149 variant: "muted", 11150 className: "dataviews-settings-section__description", 11151 children: description 11152 } 11153 ) 11154 ] }), 11155 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 11156 import_components31.__experimentalGrid, 11157 { 11158 columns: 8, 11159 gap: 4, 11160 className: "dataviews-settings-section__content", 11161 children 11162 } 11163 ) 11164 ] }); 11165 } 11166 function DataviewsViewConfigDropdown() { 11167 const { view } = (0, import_element36.useContext)(dataviews_context_default); 11168 const popoverId = (0, import_compose10.useInstanceId)( 11169 _DataViewsViewConfig, 11170 "dataviews-view-config-dropdown" 11171 ); 11172 const activeLayout = VIEW_LAYOUTS.find( 11173 (layout) => layout.type === view.type 11174 ); 11175 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 11176 import_components31.Dropdown, 11177 { 11178 expandOnMobile: true, 11179 popoverProps: { 11180 ...DATAVIEWS_CONFIG_POPOVER_PROPS, 11181 id: popoverId 11182 }, 11183 renderToggle: ({ onToggle, isOpen }) => { 11184 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 11185 import_components31.Button, 11186 { 11187 size: "compact", 11188 icon: cog_default, 11189 label: (0, import_i18n30._x)("View options", "View is used as a noun"), 11190 onClick: onToggle, 11191 "aria-expanded": isOpen ? "true" : "false", 11192 "aria-controls": popoverId 11193 } 11194 ); 11195 }, 11196 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)( 11197 import_components31.__experimentalDropdownContentWrapper, 11198 { 11199 paddingSize: "medium", 11200 className: "dataviews-config__popover-content-wrapper", 11201 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components31.__experimentalVStack, { className: "dataviews-view-config", spacing: 6, children: /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(SettingsSection, { title: (0, import_i18n30.__)("Appearance"), children: [ 11202 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_components31.__experimentalHStack, { expanded: true, className: "is-divided-in-two", children: [ 11203 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(SortFieldControl, {}), 11204 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(SortDirectionControl, {}) 11205 ] }), 11206 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(activeLayout.viewConfigOptions, {}), 11207 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(InfiniteScrollToggle, {}), 11208 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(ItemsPerPageControl, {}), 11209 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(PropertiesSection, {}) 11210 ] }) }) 11211 } 11212 ) 11213 } 11214 ); 11215 } 11216 function _DataViewsViewConfig() { 11217 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_jsx_runtime83.Fragment, { children: [ 11218 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(ViewTypeMenu, {}), 11219 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(DataviewsViewConfigDropdown, {}) 11220 ] }); 11221 } 11222 var DataViewsViewConfig = (0, import_element36.memo)(_DataViewsViewConfig); 11223 var dataviews_view_config_default = DataViewsViewConfig; 11224 11225 // packages/dataviews/build-module/dataform-controls/checkbox.js 11226 var import_components32 = __toESM(require_components()); 11227 var import_element37 = __toESM(require_element()); 11228 11229 // packages/dataviews/build-module/dataform-controls/utils/get-custom-validity.js 11230 function getCustomValidity(isValid2, validity) { 11231 let customValidity; 11232 if (isValid2?.required && validity?.required) { 11233 customValidity = validity?.required?.message ? validity.required : void 0; 11234 } else if (isValid2?.pattern && validity?.pattern) { 11235 customValidity = validity.pattern; 11236 } else if (isValid2?.min && validity?.min) { 11237 customValidity = validity.min; 11238 } else if (isValid2?.max && validity?.max) { 11239 customValidity = validity.max; 11240 } else if (isValid2?.minLength && validity?.minLength) { 11241 customValidity = validity.minLength; 11242 } else if (isValid2?.maxLength && validity?.maxLength) { 11243 customValidity = validity.maxLength; 11244 } else if (isValid2?.elements && validity?.elements) { 11245 customValidity = validity.elements; 11246 } else if (validity?.custom) { 11247 customValidity = validity.custom; 11248 } 11249 return customValidity; 11250 } 11251 11252 // packages/dataviews/build-module/dataform-controls/checkbox.js 11253 var import_jsx_runtime84 = __toESM(require_jsx_runtime()); 11254 var { ValidatedCheckboxControl } = unlock(import_components32.privateApis); 11255 function Checkbox({ 11256 field, 11257 onChange, 11258 data, 11259 hideLabelFromVision, 11260 validity 11261 }) { 11262 const { getValue, setValue, label, description, isValid: isValid2 } = field; 11263 const onChangeControl = (0, import_element37.useCallback)(() => { 11264 onChange( 11265 setValue({ item: data, value: !getValue({ item: data }) }) 11266 ); 11267 }, [data, getValue, onChange, setValue]); 11268 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)( 11269 ValidatedCheckboxControl, 11270 { 11271 required: !!field.isValid?.required, 11272 customValidity: getCustomValidity(isValid2, validity), 11273 hidden: hideLabelFromVision, 11274 label, 11275 help: description, 11276 checked: getValue({ item: data }), 11277 onChange: onChangeControl 11278 } 11279 ); 11280 } 11281 11282 // packages/dataviews/node_modules/date-fns/constants.js 11283 var daysInYear = 365.2425; 11284 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3; 11285 var minTime = -maxTime; 11286 var millisecondsInWeek = 6048e5; 11287 var millisecondsInDay = 864e5; 11288 var secondsInHour = 3600; 11289 var secondsInDay = secondsInHour * 24; 11290 var secondsInWeek = secondsInDay * 7; 11291 var secondsInYear = secondsInDay * daysInYear; 11292 var secondsInMonth = secondsInYear / 12; 11293 var secondsInQuarter = secondsInMonth * 3; 11294 var constructFromSymbol = Symbol.for("constructDateFrom"); 11295 11296 // packages/dataviews/node_modules/date-fns/constructFrom.js 11297 function constructFrom(date, value) { 11298 if (typeof date === "function") return date(value); 11299 if (date && typeof date === "object" && constructFromSymbol in date) 11300 return date[constructFromSymbol](value); 11301 if (date instanceof Date) return new date.constructor(value); 11302 return new Date(value); 11303 } 11304 11305 // packages/dataviews/node_modules/date-fns/toDate.js 11306 function toDate(argument, context) { 11307 return constructFrom(context || argument, argument); 11308 } 11309 11310 // packages/dataviews/node_modules/date-fns/addDays.js 11311 function addDays(date, amount, options) { 11312 const _date = toDate(date, options?.in); 11313 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 11314 if (!amount) return _date; 11315 _date.setDate(_date.getDate() + amount); 11316 return _date; 11317 } 11318 11319 // packages/dataviews/node_modules/date-fns/addMonths.js 11320 function addMonths(date, amount, options) { 11321 const _date = toDate(date, options?.in); 11322 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 11323 if (!amount) { 11324 return _date; 11325 } 11326 const dayOfMonth = _date.getDate(); 11327 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime()); 11328 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0); 11329 const daysInMonth = endOfDesiredMonth.getDate(); 11330 if (dayOfMonth >= daysInMonth) { 11331 return endOfDesiredMonth; 11332 } else { 11333 _date.setFullYear( 11334 endOfDesiredMonth.getFullYear(), 11335 endOfDesiredMonth.getMonth(), 11336 dayOfMonth 11337 ); 11338 return _date; 11339 } 11340 } 11341 11342 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js 11343 var defaultOptions = {}; 11344 function getDefaultOptions() { 11345 return defaultOptions; 11346 } 11347 11348 // packages/dataviews/node_modules/date-fns/startOfWeek.js 11349 function startOfWeek(date, options) { 11350 const defaultOptions2 = getDefaultOptions(); 11351 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 11352 const _date = toDate(date, options?.in); 11353 const day = _date.getDay(); 11354 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; 11355 _date.setDate(_date.getDate() - diff); 11356 _date.setHours(0, 0, 0, 0); 11357 return _date; 11358 } 11359 11360 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js 11361 function startOfISOWeek(date, options) { 11362 return startOfWeek(date, { ...options, weekStartsOn: 1 }); 11363 } 11364 11365 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js 11366 function getISOWeekYear(date, options) { 11367 const _date = toDate(date, options?.in); 11368 const year = _date.getFullYear(); 11369 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0); 11370 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); 11371 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); 11372 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); 11373 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0); 11374 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); 11375 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); 11376 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); 11377 if (_date.getTime() >= startOfNextYear.getTime()) { 11378 return year + 1; 11379 } else if (_date.getTime() >= startOfThisYear.getTime()) { 11380 return year; 11381 } else { 11382 return year - 1; 11383 } 11384 } 11385 11386 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js 11387 function getTimezoneOffsetInMilliseconds(date) { 11388 const _date = toDate(date); 11389 const utcDate = new Date( 11390 Date.UTC( 11391 _date.getFullYear(), 11392 _date.getMonth(), 11393 _date.getDate(), 11394 _date.getHours(), 11395 _date.getMinutes(), 11396 _date.getSeconds(), 11397 _date.getMilliseconds() 11398 ) 11399 ); 11400 utcDate.setUTCFullYear(_date.getFullYear()); 11401 return +date - +utcDate; 11402 } 11403 11404 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js 11405 function normalizeDates(context, ...dates) { 11406 const normalize = constructFrom.bind( 11407 null, 11408 context || dates.find((date) => typeof date === "object") 11409 ); 11410 return dates.map(normalize); 11411 } 11412 11413 // packages/dataviews/node_modules/date-fns/startOfDay.js 11414 function startOfDay(date, options) { 11415 const _date = toDate(date, options?.in); 11416 _date.setHours(0, 0, 0, 0); 11417 return _date; 11418 } 11419 11420 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js 11421 function differenceInCalendarDays(laterDate, earlierDate, options) { 11422 const [laterDate_, earlierDate_] = normalizeDates( 11423 options?.in, 11424 laterDate, 11425 earlierDate 11426 ); 11427 const laterStartOfDay = startOfDay(laterDate_); 11428 const earlierStartOfDay = startOfDay(earlierDate_); 11429 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay); 11430 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay); 11431 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay); 11432 } 11433 11434 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js 11435 function startOfISOWeekYear(date, options) { 11436 const year = getISOWeekYear(date, options); 11437 const fourthOfJanuary = constructFrom(options?.in || date, 0); 11438 fourthOfJanuary.setFullYear(year, 0, 4); 11439 fourthOfJanuary.setHours(0, 0, 0, 0); 11440 return startOfISOWeek(fourthOfJanuary); 11441 } 11442 11443 // packages/dataviews/node_modules/date-fns/addWeeks.js 11444 function addWeeks(date, amount, options) { 11445 return addDays(date, amount * 7, options); 11446 } 11447 11448 // packages/dataviews/node_modules/date-fns/addYears.js 11449 function addYears(date, amount, options) { 11450 return addMonths(date, amount * 12, options); 11451 } 11452 11453 // packages/dataviews/node_modules/date-fns/isDate.js 11454 function isDate(value) { 11455 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"; 11456 } 11457 11458 // packages/dataviews/node_modules/date-fns/isValid.js 11459 function isValid(date) { 11460 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date))); 11461 } 11462 11463 // packages/dataviews/node_modules/date-fns/startOfMonth.js 11464 function startOfMonth(date, options) { 11465 const _date = toDate(date, options?.in); 11466 _date.setDate(1); 11467 _date.setHours(0, 0, 0, 0); 11468 return _date; 11469 } 11470 11471 // packages/dataviews/node_modules/date-fns/startOfYear.js 11472 function startOfYear(date, options) { 11473 const date_ = toDate(date, options?.in); 11474 date_.setFullYear(date_.getFullYear(), 0, 1); 11475 date_.setHours(0, 0, 0, 0); 11476 return date_; 11477 } 11478 11479 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js 11480 var formatDistanceLocale = { 11481 lessThanXSeconds: { 11482 one: "less than a second", 11483 other: "less than {{count}} seconds" 11484 }, 11485 xSeconds: { 11486 one: "1 second", 11487 other: "{{count}} seconds" 11488 }, 11489 halfAMinute: "half a minute", 11490 lessThanXMinutes: { 11491 one: "less than a minute", 11492 other: "less than {{count}} minutes" 11493 }, 11494 xMinutes: { 11495 one: "1 minute", 11496 other: "{{count}} minutes" 11497 }, 11498 aboutXHours: { 11499 one: "about 1 hour", 11500 other: "about {{count}} hours" 11501 }, 11502 xHours: { 11503 one: "1 hour", 11504 other: "{{count}} hours" 11505 }, 11506 xDays: { 11507 one: "1 day", 11508 other: "{{count}} days" 11509 }, 11510 aboutXWeeks: { 11511 one: "about 1 week", 11512 other: "about {{count}} weeks" 11513 }, 11514 xWeeks: { 11515 one: "1 week", 11516 other: "{{count}} weeks" 11517 }, 11518 aboutXMonths: { 11519 one: "about 1 month", 11520 other: "about {{count}} months" 11521 }, 11522 xMonths: { 11523 one: "1 month", 11524 other: "{{count}} months" 11525 }, 11526 aboutXYears: { 11527 one: "about 1 year", 11528 other: "about {{count}} years" 11529 }, 11530 xYears: { 11531 one: "1 year", 11532 other: "{{count}} years" 11533 }, 11534 overXYears: { 11535 one: "over 1 year", 11536 other: "over {{count}} years" 11537 }, 11538 almostXYears: { 11539 one: "almost 1 year", 11540 other: "almost {{count}} years" 11541 } 11542 }; 11543 var formatDistance = (token, count, options) => { 11544 let result; 11545 const tokenValue = formatDistanceLocale[token]; 11546 if (typeof tokenValue === "string") { 11547 result = tokenValue; 11548 } else if (count === 1) { 11549 result = tokenValue.one; 11550 } else { 11551 result = tokenValue.other.replace("{{count}}", count.toString()); 11552 } 11553 if (options?.addSuffix) { 11554 if (options.comparison && options.comparison > 0) { 11555 return "in " + result; 11556 } else { 11557 return result + " ago"; 11558 } 11559 } 11560 return result; 11561 }; 11562 11563 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js 11564 function buildFormatLongFn(args) { 11565 return (options = {}) => { 11566 const width = options.width ? String(options.width) : args.defaultWidth; 11567 const format6 = args.formats[width] || args.formats[args.defaultWidth]; 11568 return format6; 11569 }; 11570 } 11571 11572 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js 11573 var dateFormats = { 11574 full: "EEEE, MMMM do, y", 11575 long: "MMMM do, y", 11576 medium: "MMM d, y", 11577 short: "MM/dd/yyyy" 11578 }; 11579 var timeFormats = { 11580 full: "h:mm:ss a zzzz", 11581 long: "h:mm:ss a z", 11582 medium: "h:mm:ss a", 11583 short: "h:mm a" 11584 }; 11585 var dateTimeFormats = { 11586 full: "{{date}} 'at' {{time}}", 11587 long: "{{date}} 'at' {{time}}", 11588 medium: "{{date}}, {{time}}", 11589 short: "{{date}}, {{time}}" 11590 }; 11591 var formatLong = { 11592 date: buildFormatLongFn({ 11593 formats: dateFormats, 11594 defaultWidth: "full" 11595 }), 11596 time: buildFormatLongFn({ 11597 formats: timeFormats, 11598 defaultWidth: "full" 11599 }), 11600 dateTime: buildFormatLongFn({ 11601 formats: dateTimeFormats, 11602 defaultWidth: "full" 11603 }) 11604 }; 11605 11606 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js 11607 var formatRelativeLocale = { 11608 lastWeek: "'last' eeee 'at' p", 11609 yesterday: "'yesterday at' p", 11610 today: "'today at' p", 11611 tomorrow: "'tomorrow at' p", 11612 nextWeek: "eeee 'at' p", 11613 other: "P" 11614 }; 11615 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token]; 11616 11617 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js 11618 function buildLocalizeFn(args) { 11619 return (value, options) => { 11620 const context = options?.context ? String(options.context) : "standalone"; 11621 let valuesArray; 11622 if (context === "formatting" && args.formattingValues) { 11623 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth; 11624 const width = options?.width ? String(options.width) : defaultWidth; 11625 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; 11626 } else { 11627 const defaultWidth = args.defaultWidth; 11628 const width = options?.width ? String(options.width) : args.defaultWidth; 11629 valuesArray = args.values[width] || args.values[defaultWidth]; 11630 } 11631 const index = args.argumentCallback ? args.argumentCallback(value) : value; 11632 return valuesArray[index]; 11633 }; 11634 } 11635 11636 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js 11637 var eraValues = { 11638 narrow: ["B", "A"], 11639 abbreviated: ["BC", "AD"], 11640 wide: ["Before Christ", "Anno Domini"] 11641 }; 11642 var quarterValues = { 11643 narrow: ["1", "2", "3", "4"], 11644 abbreviated: ["Q1", "Q2", "Q3", "Q4"], 11645 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] 11646 }; 11647 var monthValues = { 11648 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], 11649 abbreviated: [ 11650 "Jan", 11651 "Feb", 11652 "Mar", 11653 "Apr", 11654 "May", 11655 "Jun", 11656 "Jul", 11657 "Aug", 11658 "Sep", 11659 "Oct", 11660 "Nov", 11661 "Dec" 11662 ], 11663 wide: [ 11664 "January", 11665 "February", 11666 "March", 11667 "April", 11668 "May", 11669 "June", 11670 "July", 11671 "August", 11672 "September", 11673 "October", 11674 "November", 11675 "December" 11676 ] 11677 }; 11678 var dayValues = { 11679 narrow: ["S", "M", "T", "W", "T", "F", "S"], 11680 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 11681 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 11682 wide: [ 11683 "Sunday", 11684 "Monday", 11685 "Tuesday", 11686 "Wednesday", 11687 "Thursday", 11688 "Friday", 11689 "Saturday" 11690 ] 11691 }; 11692 var dayPeriodValues = { 11693 narrow: { 11694 am: "a", 11695 pm: "p", 11696 midnight: "mi", 11697 noon: "n", 11698 morning: "morning", 11699 afternoon: "afternoon", 11700 evening: "evening", 11701 night: "night" 11702 }, 11703 abbreviated: { 11704 am: "AM", 11705 pm: "PM", 11706 midnight: "midnight", 11707 noon: "noon", 11708 morning: "morning", 11709 afternoon: "afternoon", 11710 evening: "evening", 11711 night: "night" 11712 }, 11713 wide: { 11714 am: "a.m.", 11715 pm: "p.m.", 11716 midnight: "midnight", 11717 noon: "noon", 11718 morning: "morning", 11719 afternoon: "afternoon", 11720 evening: "evening", 11721 night: "night" 11722 } 11723 }; 11724 var formattingDayPeriodValues = { 11725 narrow: { 11726 am: "a", 11727 pm: "p", 11728 midnight: "mi", 11729 noon: "n", 11730 morning: "in the morning", 11731 afternoon: "in the afternoon", 11732 evening: "in the evening", 11733 night: "at night" 11734 }, 11735 abbreviated: { 11736 am: "AM", 11737 pm: "PM", 11738 midnight: "midnight", 11739 noon: "noon", 11740 morning: "in the morning", 11741 afternoon: "in the afternoon", 11742 evening: "in the evening", 11743 night: "at night" 11744 }, 11745 wide: { 11746 am: "a.m.", 11747 pm: "p.m.", 11748 midnight: "midnight", 11749 noon: "noon", 11750 morning: "in the morning", 11751 afternoon: "in the afternoon", 11752 evening: "in the evening", 11753 night: "at night" 11754 } 11755 }; 11756 var ordinalNumber = (dirtyNumber, _options) => { 11757 const number = Number(dirtyNumber); 11758 const rem100 = number % 100; 11759 if (rem100 > 20 || rem100 < 10) { 11760 switch (rem100 % 10) { 11761 case 1: 11762 return number + "st"; 11763 case 2: 11764 return number + "nd"; 11765 case 3: 11766 return number + "rd"; 11767 } 11768 } 11769 return number + "th"; 11770 }; 11771 var localize = { 11772 ordinalNumber, 11773 era: buildLocalizeFn({ 11774 values: eraValues, 11775 defaultWidth: "wide" 11776 }), 11777 quarter: buildLocalizeFn({ 11778 values: quarterValues, 11779 defaultWidth: "wide", 11780 argumentCallback: (quarter) => quarter - 1 11781 }), 11782 month: buildLocalizeFn({ 11783 values: monthValues, 11784 defaultWidth: "wide" 11785 }), 11786 day: buildLocalizeFn({ 11787 values: dayValues, 11788 defaultWidth: "wide" 11789 }), 11790 dayPeriod: buildLocalizeFn({ 11791 values: dayPeriodValues, 11792 defaultWidth: "wide", 11793 formattingValues: formattingDayPeriodValues, 11794 defaultFormattingWidth: "wide" 11795 }) 11796 }; 11797 11798 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js 11799 function buildMatchFn(args) { 11800 return (string, options = {}) => { 11801 const width = options.width; 11802 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; 11803 const matchResult = string.match(matchPattern); 11804 if (!matchResult) { 11805 return null; 11806 } 11807 const matchedString = matchResult[0]; 11808 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; 11809 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : ( 11810 // [TODO] -- I challenge you to fix the type 11811 findKey(parsePatterns, (pattern) => pattern.test(matchedString)) 11812 ); 11813 let value; 11814 value = args.valueCallback ? args.valueCallback(key) : key; 11815 value = options.valueCallback ? ( 11816 // [TODO] -- I challenge you to fix the type 11817 options.valueCallback(value) 11818 ) : value; 11819 const rest = string.slice(matchedString.length); 11820 return { value, rest }; 11821 }; 11822 } 11823 function findKey(object, predicate) { 11824 for (const key in object) { 11825 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) { 11826 return key; 11827 } 11828 } 11829 return void 0; 11830 } 11831 function findIndex(array, predicate) { 11832 for (let key = 0; key < array.length; key++) { 11833 if (predicate(array[key])) { 11834 return key; 11835 } 11836 } 11837 return void 0; 11838 } 11839 11840 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js 11841 function buildMatchPatternFn(args) { 11842 return (string, options = {}) => { 11843 const matchResult = string.match(args.matchPattern); 11844 if (!matchResult) return null; 11845 const matchedString = matchResult[0]; 11846 const parseResult = string.match(args.parsePattern); 11847 if (!parseResult) return null; 11848 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; 11849 value = options.valueCallback ? options.valueCallback(value) : value; 11850 const rest = string.slice(matchedString.length); 11851 return { value, rest }; 11852 }; 11853 } 11854 11855 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js 11856 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; 11857 var parseOrdinalNumberPattern = /\d+/i; 11858 var matchEraPatterns = { 11859 narrow: /^(b|a)/i, 11860 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, 11861 wide: /^(before christ|before common era|anno domini|common era)/i 11862 }; 11863 var parseEraPatterns = { 11864 any: [/^b/i, /^(a|c)/i] 11865 }; 11866 var matchQuarterPatterns = { 11867 narrow: /^[1234]/i, 11868 abbreviated: /^q[1234]/i, 11869 wide: /^[1234](th|st|nd|rd)? quarter/i 11870 }; 11871 var parseQuarterPatterns = { 11872 any: [/1/i, /2/i, /3/i, /4/i] 11873 }; 11874 var matchMonthPatterns = { 11875 narrow: /^[jfmasond]/i, 11876 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, 11877 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i 11878 }; 11879 var parseMonthPatterns = { 11880 narrow: [ 11881 /^j/i, 11882 /^f/i, 11883 /^m/i, 11884 /^a/i, 11885 /^m/i, 11886 /^j/i, 11887 /^j/i, 11888 /^a/i, 11889 /^s/i, 11890 /^o/i, 11891 /^n/i, 11892 /^d/i 11893 ], 11894 any: [ 11895 /^ja/i, 11896 /^f/i, 11897 /^mar/i, 11898 /^ap/i, 11899 /^may/i, 11900 /^jun/i, 11901 /^jul/i, 11902 /^au/i, 11903 /^s/i, 11904 /^o/i, 11905 /^n/i, 11906 /^d/i 11907 ] 11908 }; 11909 var matchDayPatterns = { 11910 narrow: /^[smtwf]/i, 11911 short: /^(su|mo|tu|we|th|fr|sa)/i, 11912 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, 11913 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i 11914 }; 11915 var parseDayPatterns = { 11916 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], 11917 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] 11918 }; 11919 var matchDayPeriodPatterns = { 11920 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, 11921 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i 11922 }; 11923 var parseDayPeriodPatterns = { 11924 any: { 11925 am: /^a/i, 11926 pm: /^p/i, 11927 midnight: /^mi/i, 11928 noon: /^no/i, 11929 morning: /morning/i, 11930 afternoon: /afternoon/i, 11931 evening: /evening/i, 11932 night: /night/i 11933 } 11934 }; 11935 var match = { 11936 ordinalNumber: buildMatchPatternFn({ 11937 matchPattern: matchOrdinalNumberPattern, 11938 parsePattern: parseOrdinalNumberPattern, 11939 valueCallback: (value) => parseInt(value, 10) 11940 }), 11941 era: buildMatchFn({ 11942 matchPatterns: matchEraPatterns, 11943 defaultMatchWidth: "wide", 11944 parsePatterns: parseEraPatterns, 11945 defaultParseWidth: "any" 11946 }), 11947 quarter: buildMatchFn({ 11948 matchPatterns: matchQuarterPatterns, 11949 defaultMatchWidth: "wide", 11950 parsePatterns: parseQuarterPatterns, 11951 defaultParseWidth: "any", 11952 valueCallback: (index) => index + 1 11953 }), 11954 month: buildMatchFn({ 11955 matchPatterns: matchMonthPatterns, 11956 defaultMatchWidth: "wide", 11957 parsePatterns: parseMonthPatterns, 11958 defaultParseWidth: "any" 11959 }), 11960 day: buildMatchFn({ 11961 matchPatterns: matchDayPatterns, 11962 defaultMatchWidth: "wide", 11963 parsePatterns: parseDayPatterns, 11964 defaultParseWidth: "any" 11965 }), 11966 dayPeriod: buildMatchFn({ 11967 matchPatterns: matchDayPeriodPatterns, 11968 defaultMatchWidth: "any", 11969 parsePatterns: parseDayPeriodPatterns, 11970 defaultParseWidth: "any" 11971 }) 11972 }; 11973 11974 // packages/dataviews/node_modules/date-fns/locale/en-US.js 11975 var enUS = { 11976 code: "en-US", 11977 formatDistance, 11978 formatLong, 11979 formatRelative, 11980 localize, 11981 match, 11982 options: { 11983 weekStartsOn: 0, 11984 firstWeekContainsDate: 1 11985 } 11986 }; 11987 11988 // packages/dataviews/node_modules/date-fns/getDayOfYear.js 11989 function getDayOfYear(date, options) { 11990 const _date = toDate(date, options?.in); 11991 const diff = differenceInCalendarDays(_date, startOfYear(_date)); 11992 const dayOfYear = diff + 1; 11993 return dayOfYear; 11994 } 11995 11996 // packages/dataviews/node_modules/date-fns/getISOWeek.js 11997 function getISOWeek(date, options) { 11998 const _date = toDate(date, options?.in); 11999 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date); 12000 return Math.round(diff / millisecondsInWeek) + 1; 12001 } 12002 12003 // packages/dataviews/node_modules/date-fns/getWeekYear.js 12004 function getWeekYear(date, options) { 12005 const _date = toDate(date, options?.in); 12006 const year = _date.getFullYear(); 12007 const defaultOptions2 = getDefaultOptions(); 12008 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 12009 const firstWeekOfNextYear = constructFrom(options?.in || date, 0); 12010 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); 12011 firstWeekOfNextYear.setHours(0, 0, 0, 0); 12012 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options); 12013 const firstWeekOfThisYear = constructFrom(options?.in || date, 0); 12014 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); 12015 firstWeekOfThisYear.setHours(0, 0, 0, 0); 12016 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options); 12017 if (+_date >= +startOfNextYear) { 12018 return year + 1; 12019 } else if (+_date >= +startOfThisYear) { 12020 return year; 12021 } else { 12022 return year - 1; 12023 } 12024 } 12025 12026 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js 12027 function startOfWeekYear(date, options) { 12028 const defaultOptions2 = getDefaultOptions(); 12029 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 12030 const year = getWeekYear(date, options); 12031 const firstWeek = constructFrom(options?.in || date, 0); 12032 firstWeek.setFullYear(year, 0, firstWeekContainsDate); 12033 firstWeek.setHours(0, 0, 0, 0); 12034 const _date = startOfWeek(firstWeek, options); 12035 return _date; 12036 } 12037 12038 // packages/dataviews/node_modules/date-fns/getWeek.js 12039 function getWeek(date, options) { 12040 const _date = toDate(date, options?.in); 12041 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options); 12042 return Math.round(diff / millisecondsInWeek) + 1; 12043 } 12044 12045 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js 12046 function addLeadingZeros(number, targetLength) { 12047 const sign = number < 0 ? "-" : ""; 12048 const output = Math.abs(number).toString().padStart(targetLength, "0"); 12049 return sign + output; 12050 } 12051 12052 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js 12053 var lightFormatters = { 12054 // Year 12055 y(date, token) { 12056 const signedYear = date.getFullYear(); 12057 const year = signedYear > 0 ? signedYear : 1 - signedYear; 12058 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length); 12059 }, 12060 // Month 12061 M(date, token) { 12062 const month = date.getMonth(); 12063 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2); 12064 }, 12065 // Day of the month 12066 d(date, token) { 12067 return addLeadingZeros(date.getDate(), token.length); 12068 }, 12069 // AM or PM 12070 a(date, token) { 12071 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am"; 12072 switch (token) { 12073 case "a": 12074 case "aa": 12075 return dayPeriodEnumValue.toUpperCase(); 12076 case "aaa": 12077 return dayPeriodEnumValue; 12078 case "aaaaa": 12079 return dayPeriodEnumValue[0]; 12080 case "aaaa": 12081 default: 12082 return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; 12083 } 12084 }, 12085 // Hour [1-12] 12086 h(date, token) { 12087 return addLeadingZeros(date.getHours() % 12 || 12, token.length); 12088 }, 12089 // Hour [0-23] 12090 H(date, token) { 12091 return addLeadingZeros(date.getHours(), token.length); 12092 }, 12093 // Minute 12094 m(date, token) { 12095 return addLeadingZeros(date.getMinutes(), token.length); 12096 }, 12097 // Second 12098 s(date, token) { 12099 return addLeadingZeros(date.getSeconds(), token.length); 12100 }, 12101 // Fraction of second 12102 S(date, token) { 12103 const numberOfDigits = token.length; 12104 const milliseconds = date.getMilliseconds(); 12105 const fractionalSeconds = Math.trunc( 12106 milliseconds * Math.pow(10, numberOfDigits - 3) 12107 ); 12108 return addLeadingZeros(fractionalSeconds, token.length); 12109 } 12110 }; 12111 12112 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js 12113 var dayPeriodEnum = { 12114 am: "am", 12115 pm: "pm", 12116 midnight: "midnight", 12117 noon: "noon", 12118 morning: "morning", 12119 afternoon: "afternoon", 12120 evening: "evening", 12121 night: "night" 12122 }; 12123 var formatters = { 12124 // Era 12125 G: function(date, token, localize2) { 12126 const era = date.getFullYear() > 0 ? 1 : 0; 12127 switch (token) { 12128 // AD, BC 12129 case "G": 12130 case "GG": 12131 case "GGG": 12132 return localize2.era(era, { width: "abbreviated" }); 12133 // A, B 12134 case "GGGGG": 12135 return localize2.era(era, { width: "narrow" }); 12136 // Anno Domini, Before Christ 12137 case "GGGG": 12138 default: 12139 return localize2.era(era, { width: "wide" }); 12140 } 12141 }, 12142 // Year 12143 y: function(date, token, localize2) { 12144 if (token === "yo") { 12145 const signedYear = date.getFullYear(); 12146 const year = signedYear > 0 ? signedYear : 1 - signedYear; 12147 return localize2.ordinalNumber(year, { unit: "year" }); 12148 } 12149 return lightFormatters.y(date, token); 12150 }, 12151 // Local week-numbering year 12152 Y: function(date, token, localize2, options) { 12153 const signedWeekYear = getWeekYear(date, options); 12154 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; 12155 if (token === "YY") { 12156 const twoDigitYear = weekYear % 100; 12157 return addLeadingZeros(twoDigitYear, 2); 12158 } 12159 if (token === "Yo") { 12160 return localize2.ordinalNumber(weekYear, { unit: "year" }); 12161 } 12162 return addLeadingZeros(weekYear, token.length); 12163 }, 12164 // ISO week-numbering year 12165 R: function(date, token) { 12166 const isoWeekYear = getISOWeekYear(date); 12167 return addLeadingZeros(isoWeekYear, token.length); 12168 }, 12169 // Extended year. This is a single number designating the year of this calendar system. 12170 // The main difference between `y` and `u` localizers are B.C. years: 12171 // | Year | `y` | `u` | 12172 // |------|-----|-----| 12173 // | AC 1 | 1 | 1 | 12174 // | BC 1 | 1 | 0 | 12175 // | BC 2 | 2 | -1 | 12176 // Also `yy` always returns the last two digits of a year, 12177 // while `uu` pads single digit years to 2 characters and returns other years unchanged. 12178 u: function(date, token) { 12179 const year = date.getFullYear(); 12180 return addLeadingZeros(year, token.length); 12181 }, 12182 // Quarter 12183 Q: function(date, token, localize2) { 12184 const quarter = Math.ceil((date.getMonth() + 1) / 3); 12185 switch (token) { 12186 // 1, 2, 3, 4 12187 case "Q": 12188 return String(quarter); 12189 // 01, 02, 03, 04 12190 case "QQ": 12191 return addLeadingZeros(quarter, 2); 12192 // 1st, 2nd, 3rd, 4th 12193 case "Qo": 12194 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 12195 // Q1, Q2, Q3, Q4 12196 case "QQQ": 12197 return localize2.quarter(quarter, { 12198 width: "abbreviated", 12199 context: "formatting" 12200 }); 12201 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 12202 case "QQQQQ": 12203 return localize2.quarter(quarter, { 12204 width: "narrow", 12205 context: "formatting" 12206 }); 12207 // 1st quarter, 2nd quarter, ... 12208 case "QQQQ": 12209 default: 12210 return localize2.quarter(quarter, { 12211 width: "wide", 12212 context: "formatting" 12213 }); 12214 } 12215 }, 12216 // Stand-alone quarter 12217 q: function(date, token, localize2) { 12218 const quarter = Math.ceil((date.getMonth() + 1) / 3); 12219 switch (token) { 12220 // 1, 2, 3, 4 12221 case "q": 12222 return String(quarter); 12223 // 01, 02, 03, 04 12224 case "qq": 12225 return addLeadingZeros(quarter, 2); 12226 // 1st, 2nd, 3rd, 4th 12227 case "qo": 12228 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 12229 // Q1, Q2, Q3, Q4 12230 case "qqq": 12231 return localize2.quarter(quarter, { 12232 width: "abbreviated", 12233 context: "standalone" 12234 }); 12235 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 12236 case "qqqqq": 12237 return localize2.quarter(quarter, { 12238 width: "narrow", 12239 context: "standalone" 12240 }); 12241 // 1st quarter, 2nd quarter, ... 12242 case "qqqq": 12243 default: 12244 return localize2.quarter(quarter, { 12245 width: "wide", 12246 context: "standalone" 12247 }); 12248 } 12249 }, 12250 // Month 12251 M: function(date, token, localize2) { 12252 const month = date.getMonth(); 12253 switch (token) { 12254 case "M": 12255 case "MM": 12256 return lightFormatters.M(date, token); 12257 // 1st, 2nd, ..., 12th 12258 case "Mo": 12259 return localize2.ordinalNumber(month + 1, { unit: "month" }); 12260 // Jan, Feb, ..., Dec 12261 case "MMM": 12262 return localize2.month(month, { 12263 width: "abbreviated", 12264 context: "formatting" 12265 }); 12266 // J, F, ..., D 12267 case "MMMMM": 12268 return localize2.month(month, { 12269 width: "narrow", 12270 context: "formatting" 12271 }); 12272 // January, February, ..., December 12273 case "MMMM": 12274 default: 12275 return localize2.month(month, { width: "wide", context: "formatting" }); 12276 } 12277 }, 12278 // Stand-alone month 12279 L: function(date, token, localize2) { 12280 const month = date.getMonth(); 12281 switch (token) { 12282 // 1, 2, ..., 12 12283 case "L": 12284 return String(month + 1); 12285 // 01, 02, ..., 12 12286 case "LL": 12287 return addLeadingZeros(month + 1, 2); 12288 // 1st, 2nd, ..., 12th 12289 case "Lo": 12290 return localize2.ordinalNumber(month + 1, { unit: "month" }); 12291 // Jan, Feb, ..., Dec 12292 case "LLL": 12293 return localize2.month(month, { 12294 width: "abbreviated", 12295 context: "standalone" 12296 }); 12297 // J, F, ..., D 12298 case "LLLLL": 12299 return localize2.month(month, { 12300 width: "narrow", 12301 context: "standalone" 12302 }); 12303 // January, February, ..., December 12304 case "LLLL": 12305 default: 12306 return localize2.month(month, { width: "wide", context: "standalone" }); 12307 } 12308 }, 12309 // Local week of year 12310 w: function(date, token, localize2, options) { 12311 const week = getWeek(date, options); 12312 if (token === "wo") { 12313 return localize2.ordinalNumber(week, { unit: "week" }); 12314 } 12315 return addLeadingZeros(week, token.length); 12316 }, 12317 // ISO week of year 12318 I: function(date, token, localize2) { 12319 const isoWeek = getISOWeek(date); 12320 if (token === "Io") { 12321 return localize2.ordinalNumber(isoWeek, { unit: "week" }); 12322 } 12323 return addLeadingZeros(isoWeek, token.length); 12324 }, 12325 // Day of the month 12326 d: function(date, token, localize2) { 12327 if (token === "do") { 12328 return localize2.ordinalNumber(date.getDate(), { unit: "date" }); 12329 } 12330 return lightFormatters.d(date, token); 12331 }, 12332 // Day of year 12333 D: function(date, token, localize2) { 12334 const dayOfYear = getDayOfYear(date); 12335 if (token === "Do") { 12336 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" }); 12337 } 12338 return addLeadingZeros(dayOfYear, token.length); 12339 }, 12340 // Day of week 12341 E: function(date, token, localize2) { 12342 const dayOfWeek = date.getDay(); 12343 switch (token) { 12344 // Tue 12345 case "E": 12346 case "EE": 12347 case "EEE": 12348 return localize2.day(dayOfWeek, { 12349 width: "abbreviated", 12350 context: "formatting" 12351 }); 12352 // T 12353 case "EEEEE": 12354 return localize2.day(dayOfWeek, { 12355 width: "narrow", 12356 context: "formatting" 12357 }); 12358 // Tu 12359 case "EEEEEE": 12360 return localize2.day(dayOfWeek, { 12361 width: "short", 12362 context: "formatting" 12363 }); 12364 // Tuesday 12365 case "EEEE": 12366 default: 12367 return localize2.day(dayOfWeek, { 12368 width: "wide", 12369 context: "formatting" 12370 }); 12371 } 12372 }, 12373 // Local day of week 12374 e: function(date, token, localize2, options) { 12375 const dayOfWeek = date.getDay(); 12376 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 12377 switch (token) { 12378 // Numerical value (Nth day of week with current locale or weekStartsOn) 12379 case "e": 12380 return String(localDayOfWeek); 12381 // Padded numerical value 12382 case "ee": 12383 return addLeadingZeros(localDayOfWeek, 2); 12384 // 1st, 2nd, ..., 7th 12385 case "eo": 12386 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 12387 case "eee": 12388 return localize2.day(dayOfWeek, { 12389 width: "abbreviated", 12390 context: "formatting" 12391 }); 12392 // T 12393 case "eeeee": 12394 return localize2.day(dayOfWeek, { 12395 width: "narrow", 12396 context: "formatting" 12397 }); 12398 // Tu 12399 case "eeeeee": 12400 return localize2.day(dayOfWeek, { 12401 width: "short", 12402 context: "formatting" 12403 }); 12404 // Tuesday 12405 case "eeee": 12406 default: 12407 return localize2.day(dayOfWeek, { 12408 width: "wide", 12409 context: "formatting" 12410 }); 12411 } 12412 }, 12413 // Stand-alone local day of week 12414 c: function(date, token, localize2, options) { 12415 const dayOfWeek = date.getDay(); 12416 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 12417 switch (token) { 12418 // Numerical value (same as in `e`) 12419 case "c": 12420 return String(localDayOfWeek); 12421 // Padded numerical value 12422 case "cc": 12423 return addLeadingZeros(localDayOfWeek, token.length); 12424 // 1st, 2nd, ..., 7th 12425 case "co": 12426 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 12427 case "ccc": 12428 return localize2.day(dayOfWeek, { 12429 width: "abbreviated", 12430 context: "standalone" 12431 }); 12432 // T 12433 case "ccccc": 12434 return localize2.day(dayOfWeek, { 12435 width: "narrow", 12436 context: "standalone" 12437 }); 12438 // Tu 12439 case "cccccc": 12440 return localize2.day(dayOfWeek, { 12441 width: "short", 12442 context: "standalone" 12443 }); 12444 // Tuesday 12445 case "cccc": 12446 default: 12447 return localize2.day(dayOfWeek, { 12448 width: "wide", 12449 context: "standalone" 12450 }); 12451 } 12452 }, 12453 // ISO day of week 12454 i: function(date, token, localize2) { 12455 const dayOfWeek = date.getDay(); 12456 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; 12457 switch (token) { 12458 // 2 12459 case "i": 12460 return String(isoDayOfWeek); 12461 // 02 12462 case "ii": 12463 return addLeadingZeros(isoDayOfWeek, token.length); 12464 // 2nd 12465 case "io": 12466 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" }); 12467 // Tue 12468 case "iii": 12469 return localize2.day(dayOfWeek, { 12470 width: "abbreviated", 12471 context: "formatting" 12472 }); 12473 // T 12474 case "iiiii": 12475 return localize2.day(dayOfWeek, { 12476 width: "narrow", 12477 context: "formatting" 12478 }); 12479 // Tu 12480 case "iiiiii": 12481 return localize2.day(dayOfWeek, { 12482 width: "short", 12483 context: "formatting" 12484 }); 12485 // Tuesday 12486 case "iiii": 12487 default: 12488 return localize2.day(dayOfWeek, { 12489 width: "wide", 12490 context: "formatting" 12491 }); 12492 } 12493 }, 12494 // AM or PM 12495 a: function(date, token, localize2) { 12496 const hours = date.getHours(); 12497 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 12498 switch (token) { 12499 case "a": 12500 case "aa": 12501 return localize2.dayPeriod(dayPeriodEnumValue, { 12502 width: "abbreviated", 12503 context: "formatting" 12504 }); 12505 case "aaa": 12506 return localize2.dayPeriod(dayPeriodEnumValue, { 12507 width: "abbreviated", 12508 context: "formatting" 12509 }).toLowerCase(); 12510 case "aaaaa": 12511 return localize2.dayPeriod(dayPeriodEnumValue, { 12512 width: "narrow", 12513 context: "formatting" 12514 }); 12515 case "aaaa": 12516 default: 12517 return localize2.dayPeriod(dayPeriodEnumValue, { 12518 width: "wide", 12519 context: "formatting" 12520 }); 12521 } 12522 }, 12523 // AM, PM, midnight, noon 12524 b: function(date, token, localize2) { 12525 const hours = date.getHours(); 12526 let dayPeriodEnumValue; 12527 if (hours === 12) { 12528 dayPeriodEnumValue = dayPeriodEnum.noon; 12529 } else if (hours === 0) { 12530 dayPeriodEnumValue = dayPeriodEnum.midnight; 12531 } else { 12532 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 12533 } 12534 switch (token) { 12535 case "b": 12536 case "bb": 12537 return localize2.dayPeriod(dayPeriodEnumValue, { 12538 width: "abbreviated", 12539 context: "formatting" 12540 }); 12541 case "bbb": 12542 return localize2.dayPeriod(dayPeriodEnumValue, { 12543 width: "abbreviated", 12544 context: "formatting" 12545 }).toLowerCase(); 12546 case "bbbbb": 12547 return localize2.dayPeriod(dayPeriodEnumValue, { 12548 width: "narrow", 12549 context: "formatting" 12550 }); 12551 case "bbbb": 12552 default: 12553 return localize2.dayPeriod(dayPeriodEnumValue, { 12554 width: "wide", 12555 context: "formatting" 12556 }); 12557 } 12558 }, 12559 // in the morning, in the afternoon, in the evening, at night 12560 B: function(date, token, localize2) { 12561 const hours = date.getHours(); 12562 let dayPeriodEnumValue; 12563 if (hours >= 17) { 12564 dayPeriodEnumValue = dayPeriodEnum.evening; 12565 } else if (hours >= 12) { 12566 dayPeriodEnumValue = dayPeriodEnum.afternoon; 12567 } else if (hours >= 4) { 12568 dayPeriodEnumValue = dayPeriodEnum.morning; 12569 } else { 12570 dayPeriodEnumValue = dayPeriodEnum.night; 12571 } 12572 switch (token) { 12573 case "B": 12574 case "BB": 12575 case "BBB": 12576 return localize2.dayPeriod(dayPeriodEnumValue, { 12577 width: "abbreviated", 12578 context: "formatting" 12579 }); 12580 case "BBBBB": 12581 return localize2.dayPeriod(dayPeriodEnumValue, { 12582 width: "narrow", 12583 context: "formatting" 12584 }); 12585 case "BBBB": 12586 default: 12587 return localize2.dayPeriod(dayPeriodEnumValue, { 12588 width: "wide", 12589 context: "formatting" 12590 }); 12591 } 12592 }, 12593 // Hour [1-12] 12594 h: function(date, token, localize2) { 12595 if (token === "ho") { 12596 let hours = date.getHours() % 12; 12597 if (hours === 0) hours = 12; 12598 return localize2.ordinalNumber(hours, { unit: "hour" }); 12599 } 12600 return lightFormatters.h(date, token); 12601 }, 12602 // Hour [0-23] 12603 H: function(date, token, localize2) { 12604 if (token === "Ho") { 12605 return localize2.ordinalNumber(date.getHours(), { unit: "hour" }); 12606 } 12607 return lightFormatters.H(date, token); 12608 }, 12609 // Hour [0-11] 12610 K: function(date, token, localize2) { 12611 const hours = date.getHours() % 12; 12612 if (token === "Ko") { 12613 return localize2.ordinalNumber(hours, { unit: "hour" }); 12614 } 12615 return addLeadingZeros(hours, token.length); 12616 }, 12617 // Hour [1-24] 12618 k: function(date, token, localize2) { 12619 let hours = date.getHours(); 12620 if (hours === 0) hours = 24; 12621 if (token === "ko") { 12622 return localize2.ordinalNumber(hours, { unit: "hour" }); 12623 } 12624 return addLeadingZeros(hours, token.length); 12625 }, 12626 // Minute 12627 m: function(date, token, localize2) { 12628 if (token === "mo") { 12629 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" }); 12630 } 12631 return lightFormatters.m(date, token); 12632 }, 12633 // Second 12634 s: function(date, token, localize2) { 12635 if (token === "so") { 12636 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" }); 12637 } 12638 return lightFormatters.s(date, token); 12639 }, 12640 // Fraction of second 12641 S: function(date, token) { 12642 return lightFormatters.S(date, token); 12643 }, 12644 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) 12645 X: function(date, token, _localize) { 12646 const timezoneOffset = date.getTimezoneOffset(); 12647 if (timezoneOffset === 0) { 12648 return "Z"; 12649 } 12650 switch (token) { 12651 // Hours and optional minutes 12652 case "X": 12653 return formatTimezoneWithOptionalMinutes(timezoneOffset); 12654 // Hours, minutes and optional seconds without `:` delimiter 12655 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 12656 // so this token always has the same output as `XX` 12657 case "XXXX": 12658 case "XX": 12659 return formatTimezone(timezoneOffset); 12660 // Hours, minutes and optional seconds with `:` delimiter 12661 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 12662 // so this token always has the same output as `XXX` 12663 case "XXXXX": 12664 case "XXX": 12665 // Hours and minutes with `:` delimiter 12666 default: 12667 return formatTimezone(timezoneOffset, ":"); 12668 } 12669 }, 12670 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) 12671 x: function(date, token, _localize) { 12672 const timezoneOffset = date.getTimezoneOffset(); 12673 switch (token) { 12674 // Hours and optional minutes 12675 case "x": 12676 return formatTimezoneWithOptionalMinutes(timezoneOffset); 12677 // Hours, minutes and optional seconds without `:` delimiter 12678 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 12679 // so this token always has the same output as `xx` 12680 case "xxxx": 12681 case "xx": 12682 return formatTimezone(timezoneOffset); 12683 // Hours, minutes and optional seconds with `:` delimiter 12684 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 12685 // so this token always has the same output as `xxx` 12686 case "xxxxx": 12687 case "xxx": 12688 // Hours and minutes with `:` delimiter 12689 default: 12690 return formatTimezone(timezoneOffset, ":"); 12691 } 12692 }, 12693 // Timezone (GMT) 12694 O: function(date, token, _localize) { 12695 const timezoneOffset = date.getTimezoneOffset(); 12696 switch (token) { 12697 // Short 12698 case "O": 12699 case "OO": 12700 case "OOO": 12701 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 12702 // Long 12703 case "OOOO": 12704 default: 12705 return "GMT" + formatTimezone(timezoneOffset, ":"); 12706 } 12707 }, 12708 // Timezone (specific non-location) 12709 z: function(date, token, _localize) { 12710 const timezoneOffset = date.getTimezoneOffset(); 12711 switch (token) { 12712 // Short 12713 case "z": 12714 case "zz": 12715 case "zzz": 12716 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 12717 // Long 12718 case "zzzz": 12719 default: 12720 return "GMT" + formatTimezone(timezoneOffset, ":"); 12721 } 12722 }, 12723 // Seconds timestamp 12724 t: function(date, token, _localize) { 12725 const timestamp = Math.trunc(+date / 1e3); 12726 return addLeadingZeros(timestamp, token.length); 12727 }, 12728 // Milliseconds timestamp 12729 T: function(date, token, _localize) { 12730 return addLeadingZeros(+date, token.length); 12731 } 12732 }; 12733 function formatTimezoneShort(offset, delimiter = "") { 12734 const sign = offset > 0 ? "-" : "+"; 12735 const absOffset = Math.abs(offset); 12736 const hours = Math.trunc(absOffset / 60); 12737 const minutes = absOffset % 60; 12738 if (minutes === 0) { 12739 return sign + String(hours); 12740 } 12741 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2); 12742 } 12743 function formatTimezoneWithOptionalMinutes(offset, delimiter) { 12744 if (offset % 60 === 0) { 12745 const sign = offset > 0 ? "-" : "+"; 12746 return sign + addLeadingZeros(Math.abs(offset) / 60, 2); 12747 } 12748 return formatTimezone(offset, delimiter); 12749 } 12750 function formatTimezone(offset, delimiter = "") { 12751 const sign = offset > 0 ? "-" : "+"; 12752 const absOffset = Math.abs(offset); 12753 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2); 12754 const minutes = addLeadingZeros(absOffset % 60, 2); 12755 return sign + hours + delimiter + minutes; 12756 } 12757 12758 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js 12759 var dateLongFormatter = (pattern, formatLong2) => { 12760 switch (pattern) { 12761 case "P": 12762 return formatLong2.date({ width: "short" }); 12763 case "PP": 12764 return formatLong2.date({ width: "medium" }); 12765 case "PPP": 12766 return formatLong2.date({ width: "long" }); 12767 case "PPPP": 12768 default: 12769 return formatLong2.date({ width: "full" }); 12770 } 12771 }; 12772 var timeLongFormatter = (pattern, formatLong2) => { 12773 switch (pattern) { 12774 case "p": 12775 return formatLong2.time({ width: "short" }); 12776 case "pp": 12777 return formatLong2.time({ width: "medium" }); 12778 case "ppp": 12779 return formatLong2.time({ width: "long" }); 12780 case "pppp": 12781 default: 12782 return formatLong2.time({ width: "full" }); 12783 } 12784 }; 12785 var dateTimeLongFormatter = (pattern, formatLong2) => { 12786 const matchResult = pattern.match(/(P+)(p+)?/) || []; 12787 const datePattern = matchResult[1]; 12788 const timePattern = matchResult[2]; 12789 if (!timePattern) { 12790 return dateLongFormatter(pattern, formatLong2); 12791 } 12792 let dateTimeFormat; 12793 switch (datePattern) { 12794 case "P": 12795 dateTimeFormat = formatLong2.dateTime({ width: "short" }); 12796 break; 12797 case "PP": 12798 dateTimeFormat = formatLong2.dateTime({ width: "medium" }); 12799 break; 12800 case "PPP": 12801 dateTimeFormat = formatLong2.dateTime({ width: "long" }); 12802 break; 12803 case "PPPP": 12804 default: 12805 dateTimeFormat = formatLong2.dateTime({ width: "full" }); 12806 break; 12807 } 12808 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); 12809 }; 12810 var longFormatters = { 12811 p: timeLongFormatter, 12812 P: dateTimeLongFormatter 12813 }; 12814 12815 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js 12816 var dayOfYearTokenRE = /^D+$/; 12817 var weekYearTokenRE = /^Y+$/; 12818 var throwTokens = ["D", "DD", "YY", "YYYY"]; 12819 function isProtectedDayOfYearToken(token) { 12820 return dayOfYearTokenRE.test(token); 12821 } 12822 function isProtectedWeekYearToken(token) { 12823 return weekYearTokenRE.test(token); 12824 } 12825 function warnOrThrowProtectedError(token, format6, input) { 12826 const _message = message(token, format6, input); 12827 console.warn(_message); 12828 if (throwTokens.includes(token)) throw new RangeError(_message); 12829 } 12830 function message(token, format6, input) { 12831 const subject = token[0] === "Y" ? "years" : "days of the month"; 12832 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`; 12833 } 12834 12835 // packages/dataviews/node_modules/date-fns/format.js 12836 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; 12837 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; 12838 var escapedStringRegExp = /^'([^]*?)'?$/; 12839 var doubleQuoteRegExp = /''/g; 12840 var unescapedLatinCharacterRegExp = /[a-zA-Z]/; 12841 function format(date, formatStr, options) { 12842 const defaultOptions2 = getDefaultOptions(); 12843 const locale = options?.locale ?? defaultOptions2.locale ?? enUS; 12844 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 12845 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 12846 const originalDate = toDate(date, options?.in); 12847 if (!isValid(originalDate)) { 12848 throw new RangeError("Invalid time value"); 12849 } 12850 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => { 12851 const firstCharacter = substring[0]; 12852 if (firstCharacter === "p" || firstCharacter === "P") { 12853 const longFormatter = longFormatters[firstCharacter]; 12854 return longFormatter(substring, locale.formatLong); 12855 } 12856 return substring; 12857 }).join("").match(formattingTokensRegExp).map((substring) => { 12858 if (substring === "''") { 12859 return { isToken: false, value: "'" }; 12860 } 12861 const firstCharacter = substring[0]; 12862 if (firstCharacter === "'") { 12863 return { isToken: false, value: cleanEscapedString(substring) }; 12864 } 12865 if (formatters[firstCharacter]) { 12866 return { isToken: true, value: substring }; 12867 } 12868 if (firstCharacter.match(unescapedLatinCharacterRegExp)) { 12869 throw new RangeError( 12870 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`" 12871 ); 12872 } 12873 return { isToken: false, value: substring }; 12874 }); 12875 if (locale.localize.preprocessor) { 12876 parts = locale.localize.preprocessor(originalDate, parts); 12877 } 12878 const formatterOptions = { 12879 firstWeekContainsDate, 12880 weekStartsOn, 12881 locale 12882 }; 12883 return parts.map((part) => { 12884 if (!part.isToken) return part.value; 12885 const token = part.value; 12886 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) { 12887 warnOrThrowProtectedError(token, formatStr, String(date)); 12888 } 12889 const formatter = formatters[token[0]]; 12890 return formatter(originalDate, token, locale.localize, formatterOptions); 12891 }).join(""); 12892 } 12893 function cleanEscapedString(input) { 12894 const matched = input.match(escapedStringRegExp); 12895 if (!matched) { 12896 return input; 12897 } 12898 return matched[1].replace(doubleQuoteRegExp, "'"); 12899 } 12900 12901 // packages/dataviews/node_modules/date-fns/subDays.js 12902 function subDays(date, amount, options) { 12903 return addDays(date, -amount, options); 12904 } 12905 12906 // packages/dataviews/node_modules/date-fns/subMonths.js 12907 function subMonths(date, amount, options) { 12908 return addMonths(date, -amount, options); 12909 } 12910 12911 // packages/dataviews/node_modules/date-fns/subWeeks.js 12912 function subWeeks(date, amount, options) { 12913 return addWeeks(date, -amount, options); 12914 } 12915 12916 // packages/dataviews/node_modules/date-fns/subYears.js 12917 function subYears(date, amount, options) { 12918 return addYears(date, -amount, options); 12919 } 12920 12921 // packages/dataviews/build-module/dataform-controls/datetime.js 12922 var import_components34 = __toESM(require_components()); 12923 var import_element39 = __toESM(require_element()); 12924 var import_i18n32 = __toESM(require_i18n()); 12925 var import_date2 = __toESM(require_date()); 12926 12927 // packages/dataviews/build-module/dataform-controls/utils/relative-date-control.js 12928 var import_components33 = __toESM(require_components()); 12929 var import_element38 = __toESM(require_element()); 12930 var import_i18n31 = __toESM(require_i18n()); 12931 var import_jsx_runtime85 = __toESM(require_jsx_runtime()); 12932 var TIME_UNITS_OPTIONS = { 12933 [OPERATOR_IN_THE_PAST]: [ 12934 { value: "days", label: (0, import_i18n31.__)("Days") }, 12935 { value: "weeks", label: (0, import_i18n31.__)("Weeks") }, 12936 { value: "months", label: (0, import_i18n31.__)("Months") }, 12937 { value: "years", label: (0, import_i18n31.__)("Years") } 12938 ], 12939 [OPERATOR_OVER]: [ 12940 { value: "days", label: (0, import_i18n31.__)("Days ago") }, 12941 { value: "weeks", label: (0, import_i18n31.__)("Weeks ago") }, 12942 { value: "months", label: (0, import_i18n31.__)("Months ago") }, 12943 { value: "years", label: (0, import_i18n31.__)("Years ago") } 12944 ] 12945 }; 12946 function RelativeDateControl({ 12947 className, 12948 data, 12949 field, 12950 onChange, 12951 hideLabelFromVision, 12952 operator 12953 }) { 12954 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"]; 12955 const { id, label, getValue, setValue } = field; 12956 const fieldValue = getValue({ item: data }); 12957 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {}; 12958 const onChangeValue = (0, import_element38.useCallback)( 12959 (newValue) => onChange( 12960 setValue({ 12961 item: data, 12962 value: { value: Number(newValue), unit } 12963 }) 12964 ), 12965 [onChange, setValue, data, unit] 12966 ); 12967 const onChangeUnit = (0, import_element38.useCallback)( 12968 (newUnit) => onChange( 12969 setValue({ 12970 item: data, 12971 value: { value: relValue, unit: newUnit } 12972 }) 12973 ), 12974 [onChange, setValue, data, relValue] 12975 ); 12976 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 12977 import_components33.BaseControl, 12978 { 12979 id, 12980 className: clsx_default(className, "dataviews-controls__relative-date"), 12981 label, 12982 hideLabelFromVision, 12983 children: /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(import_components33.__experimentalHStack, { spacing: 2.5, children: [ 12984 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 12985 import_components33.__experimentalNumberControl, 12986 { 12987 __next40pxDefaultSize: true, 12988 className: "dataviews-controls__relative-date-number", 12989 spinControls: "none", 12990 min: 1, 12991 step: 1, 12992 value: relValue, 12993 onChange: onChangeValue 12994 } 12995 ), 12996 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)( 12997 import_components33.SelectControl, 12998 { 12999 className: "dataviews-controls__relative-date-unit", 13000 __next40pxDefaultSize: true, 13001 label: (0, import_i18n31.__)("Unit"), 13002 value: unit, 13003 options, 13004 onChange: onChangeUnit, 13005 hideLabelFromVision: true 13006 } 13007 ) 13008 ] }) 13009 } 13010 ); 13011 } 13012 13013 // packages/dataviews/build-module/field-types/utils/parse-date-time.js 13014 var import_date = __toESM(require_date()); 13015 function parseDateTime(dateTimeString) { 13016 if (!dateTimeString) { 13017 return null; 13018 } 13019 const parsed = (0, import_date.getDate)(dateTimeString); 13020 return parsed && isValid(parsed) ? parsed : null; 13021 } 13022 13023 // packages/dataviews/build-module/dataform-controls/datetime.js 13024 var import_jsx_runtime86 = __toESM(require_jsx_runtime()); 13025 var { DateCalendar, ValidatedInputControl } = unlock(import_components34.privateApis); 13026 var formatDateTime = (date) => { 13027 if (!date) { 13028 return ""; 13029 } 13030 if (typeof date === "string") { 13031 return date; 13032 } 13033 return format(date, "yyyy-MM-dd'T'HH:mm"); 13034 }; 13035 function CalendarDateTimeControl({ 13036 data, 13037 field, 13038 onChange, 13039 hideLabelFromVision, 13040 validity 13041 }) { 13042 const { id, label, description, setValue, getValue, isValid: isValid2 } = field; 13043 const fieldValue = getValue({ item: data }); 13044 const value = typeof fieldValue === "string" ? fieldValue : void 0; 13045 const [calendarMonth, setCalendarMonth] = (0, import_element39.useState)(() => { 13046 const parsedDate = parseDateTime(value); 13047 return parsedDate || /* @__PURE__ */ new Date(); 13048 }); 13049 const inputControlRef = (0, import_element39.useRef)(null); 13050 const validationTimeoutRef = (0, import_element39.useRef)(); 13051 const previousFocusRef = (0, import_element39.useRef)(null); 13052 const onChangeCallback = (0, import_element39.useCallback)( 13053 (newValue) => onChange(setValue({ item: data, value: newValue })), 13054 [data, onChange, setValue] 13055 ); 13056 (0, import_element39.useEffect)(() => { 13057 return () => { 13058 if (validationTimeoutRef.current) { 13059 clearTimeout(validationTimeoutRef.current); 13060 } 13061 }; 13062 }, []); 13063 const onSelectDate = (0, import_element39.useCallback)( 13064 (newDate) => { 13065 let dateTimeValue; 13066 if (newDate) { 13067 let finalDateTime = newDate; 13068 if (value) { 13069 const currentDateTime = parseDateTime(value); 13070 if (currentDateTime) { 13071 finalDateTime = new Date(newDate); 13072 finalDateTime.setHours(currentDateTime.getHours()); 13073 finalDateTime.setMinutes( 13074 currentDateTime.getMinutes() 13075 ); 13076 } 13077 } 13078 dateTimeValue = finalDateTime.toISOString(); 13079 onChangeCallback(dateTimeValue); 13080 if (validationTimeoutRef.current) { 13081 clearTimeout(validationTimeoutRef.current); 13082 } 13083 } else { 13084 onChangeCallback(void 0); 13085 } 13086 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement; 13087 validationTimeoutRef.current = setTimeout(() => { 13088 if (inputControlRef.current) { 13089 inputControlRef.current.focus(); 13090 inputControlRef.current.blur(); 13091 onChangeCallback(dateTimeValue); 13092 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) { 13093 previousFocusRef.current.focus(); 13094 } 13095 } 13096 }, 0); 13097 }, 13098 [onChangeCallback, value] 13099 ); 13100 const handleManualDateTimeChange = (0, import_element39.useCallback)( 13101 (newValue) => { 13102 if (newValue) { 13103 const dateTime = new Date(newValue); 13104 onChangeCallback(dateTime.toISOString()); 13105 const parsedDate = parseDateTime(dateTime.toISOString()); 13106 if (parsedDate) { 13107 setCalendarMonth(parsedDate); 13108 } 13109 } else { 13110 onChangeCallback(void 0); 13111 } 13112 }, 13113 [onChangeCallback] 13114 ); 13115 const { format: fieldFormat } = field; 13116 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date2.getSettings)().l10n.startOfWeek; 13117 const { 13118 timezone: { string: timezoneString } 13119 } = (0, import_date2.getSettings)(); 13120 const displayLabel = isValid2?.required && !hideLabelFromVision ? `$label} (${(0, import_i18n32.__)("Required")})` : label; 13121 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 13122 import_components34.BaseControl, 13123 { 13124 id, 13125 label: displayLabel, 13126 help: description, 13127 hideLabelFromVision, 13128 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_components34.__experimentalVStack, { spacing: 4, children: [ 13129 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 13130 DateCalendar, 13131 { 13132 style: { width: "100%" }, 13133 selected: value ? parseDateTime(value) || void 0 : void 0, 13134 onSelect: onSelectDate, 13135 month: calendarMonth, 13136 onMonthChange: setCalendarMonth, 13137 timeZone: timezoneString || void 0, 13138 weekStartsOn 13139 } 13140 ), 13141 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 13142 ValidatedInputControl, 13143 { 13144 ref: inputControlRef, 13145 __next40pxDefaultSize: true, 13146 required: !!isValid2?.required, 13147 customValidity: getCustomValidity(isValid2, validity), 13148 type: "datetime-local", 13149 label: (0, import_i18n32.__)("Date time"), 13150 hideLabelFromVision: true, 13151 value: value ? formatDateTime( 13152 parseDateTime(value) || void 0 13153 ) : "", 13154 onChange: handleManualDateTimeChange 13155 } 13156 ) 13157 ] }) 13158 } 13159 ); 13160 } 13161 function DateTime({ 13162 data, 13163 field, 13164 onChange, 13165 hideLabelFromVision, 13166 operator, 13167 validity 13168 }) { 13169 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 13170 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 13171 RelativeDateControl, 13172 { 13173 className: "dataviews-controls__datetime", 13174 data, 13175 field, 13176 onChange, 13177 hideLabelFromVision, 13178 operator 13179 } 13180 ); 13181 } 13182 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)( 13183 CalendarDateTimeControl, 13184 { 13185 data, 13186 field, 13187 onChange, 13188 hideLabelFromVision, 13189 validity 13190 } 13191 ); 13192 } 13193 13194 // packages/dataviews/build-module/dataform-controls/date.js 13195 var import_components35 = __toESM(require_components()); 13196 var import_element40 = __toESM(require_element()); 13197 var import_i18n33 = __toESM(require_i18n()); 13198 var import_date3 = __toESM(require_date()); 13199 var import_jsx_runtime87 = __toESM(require_jsx_runtime()); 13200 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock(import_components35.privateApis); 13201 var DATE_PRESETS = [ 13202 { 13203 id: "today", 13204 label: (0, import_i18n33.__)("Today"), 13205 getValue: () => (0, import_date3.getDate)(null) 13206 }, 13207 { 13208 id: "yesterday", 13209 label: (0, import_i18n33.__)("Yesterday"), 13210 getValue: () => { 13211 const today = (0, import_date3.getDate)(null); 13212 return subDays(today, 1); 13213 } 13214 }, 13215 { 13216 id: "past-week", 13217 label: (0, import_i18n33.__)("Past week"), 13218 getValue: () => { 13219 const today = (0, import_date3.getDate)(null); 13220 return subDays(today, 7); 13221 } 13222 }, 13223 { 13224 id: "past-month", 13225 label: (0, import_i18n33.__)("Past month"), 13226 getValue: () => { 13227 const today = (0, import_date3.getDate)(null); 13228 return subMonths(today, 1); 13229 } 13230 } 13231 ]; 13232 var DATE_RANGE_PRESETS = [ 13233 { 13234 id: "last-7-days", 13235 label: (0, import_i18n33.__)("Last 7 days"), 13236 getValue: () => { 13237 const today = (0, import_date3.getDate)(null); 13238 return [subDays(today, 7), today]; 13239 } 13240 }, 13241 { 13242 id: "last-30-days", 13243 label: (0, import_i18n33.__)("Last 30 days"), 13244 getValue: () => { 13245 const today = (0, import_date3.getDate)(null); 13246 return [subDays(today, 30), today]; 13247 } 13248 }, 13249 { 13250 id: "month-to-date", 13251 label: (0, import_i18n33.__)("Month to date"), 13252 getValue: () => { 13253 const today = (0, import_date3.getDate)(null); 13254 return [startOfMonth(today), today]; 13255 } 13256 }, 13257 { 13258 id: "last-year", 13259 label: (0, import_i18n33.__)("Last year"), 13260 getValue: () => { 13261 const today = (0, import_date3.getDate)(null); 13262 return [subYears(today, 1), today]; 13263 } 13264 }, 13265 { 13266 id: "year-to-date", 13267 label: (0, import_i18n33.__)("Year to date"), 13268 getValue: () => { 13269 const today = (0, import_date3.getDate)(null); 13270 return [startOfYear(today), today]; 13271 } 13272 } 13273 ]; 13274 var parseDate = (dateString) => { 13275 if (!dateString) { 13276 return null; 13277 } 13278 const parsed = (0, import_date3.getDate)(dateString); 13279 return parsed && isValid(parsed) ? parsed : null; 13280 }; 13281 var formatDate = (date) => { 13282 if (!date) { 13283 return ""; 13284 } 13285 return typeof date === "string" ? date : format(date, "yyyy-MM-dd"); 13286 }; 13287 function ValidatedDateControl({ 13288 field, 13289 validity, 13290 inputRefs, 13291 isTouched, 13292 setIsTouched, 13293 children 13294 }) { 13295 const { isValid: isValid2 } = field; 13296 const [customValidity, setCustomValidity] = (0, import_element40.useState)(void 0); 13297 const validateRefs = (0, import_element40.useCallback)(() => { 13298 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 13299 for (const ref of refs) { 13300 const input = ref.current; 13301 if (input && !input.validity.valid) { 13302 setCustomValidity({ 13303 type: "invalid", 13304 message: input.validationMessage 13305 }); 13306 return; 13307 } 13308 } 13309 setCustomValidity(void 0); 13310 }, [inputRefs]); 13311 (0, import_element40.useEffect)(() => { 13312 if (isTouched) { 13313 const timeoutId = setTimeout(() => { 13314 if (validity) { 13315 setCustomValidity(getCustomValidity(isValid2, validity)); 13316 } else { 13317 validateRefs(); 13318 } 13319 }, 0); 13320 return () => clearTimeout(timeoutId); 13321 } 13322 return void 0; 13323 }, [isTouched, isValid2, validity, validateRefs]); 13324 const onBlur = (event) => { 13325 if (isTouched) { 13326 return; 13327 } 13328 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) { 13329 setIsTouched(true); 13330 } 13331 }; 13332 return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { onBlur, children: [ 13333 children, 13334 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)( 13335 "p", 13336 { 13337 className: clsx_default( 13338 "components-validated-control__indicator", 13339 customValidity.type === "invalid" ? "is-invalid" : void 0, 13340 customValidity.type === "valid" ? "is-valid" : void 0 13341 ), 13342 children: [ 13343 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13344 import_components35.Icon, 13345 { 13346 className: "components-validated-control__indicator-icon", 13347 icon: error_default, 13348 size: 16, 13349 fill: "currentColor" 13350 } 13351 ), 13352 customValidity.message 13353 ] 13354 } 13355 ) }) 13356 ] }); 13357 } 13358 function CalendarDateControl({ 13359 data, 13360 field, 13361 onChange, 13362 hideLabelFromVision, 13363 validity 13364 }) { 13365 const { 13366 id, 13367 label, 13368 setValue, 13369 getValue, 13370 isValid: isValid2, 13371 format: fieldFormat 13372 } = field; 13373 const [selectedPresetId, setSelectedPresetId] = (0, import_element40.useState)( 13374 null 13375 ); 13376 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 13377 const fieldValue = getValue({ item: data }); 13378 const value = typeof fieldValue === "string" ? fieldValue : void 0; 13379 const [calendarMonth, setCalendarMonth] = (0, import_element40.useState)(() => { 13380 const parsedDate = parseDate(value); 13381 return parsedDate || /* @__PURE__ */ new Date(); 13382 }); 13383 const [isTouched, setIsTouched] = (0, import_element40.useState)(false); 13384 const validityTargetRef = (0, import_element40.useRef)(null); 13385 const onChangeCallback = (0, import_element40.useCallback)( 13386 (newValue) => onChange(setValue({ item: data, value: newValue })), 13387 [data, onChange, setValue] 13388 ); 13389 const onSelectDate = (0, import_element40.useCallback)( 13390 (newDate) => { 13391 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0; 13392 onChangeCallback(dateValue); 13393 setSelectedPresetId(null); 13394 setIsTouched(true); 13395 }, 13396 [onChangeCallback] 13397 ); 13398 const handlePresetClick = (0, import_element40.useCallback)( 13399 (preset) => { 13400 const presetDate = preset.getValue(); 13401 const dateValue = formatDate(presetDate); 13402 setCalendarMonth(presetDate); 13403 onChangeCallback(dateValue); 13404 setSelectedPresetId(preset.id); 13405 setIsTouched(true); 13406 }, 13407 [onChangeCallback] 13408 ); 13409 const handleManualDateChange = (0, import_element40.useCallback)( 13410 (newValue) => { 13411 onChangeCallback(newValue); 13412 if (newValue) { 13413 const parsedDate = parseDate(newValue); 13414 if (parsedDate) { 13415 setCalendarMonth(parsedDate); 13416 } 13417 } 13418 setSelectedPresetId(null); 13419 setIsTouched(true); 13420 }, 13421 [onChangeCallback] 13422 ); 13423 const { 13424 timezone: { string: timezoneString } 13425 } = (0, import_date3.getSettings)(); 13426 const displayLabel = isValid2?.required ? `$label} (${(0, import_i18n33.__)("Required")})` : label; 13427 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13428 ValidatedDateControl, 13429 { 13430 field, 13431 validity, 13432 inputRefs: validityTargetRef, 13433 isTouched, 13434 setIsTouched, 13435 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13436 import_components35.BaseControl, 13437 { 13438 id, 13439 className: "dataviews-controls__date", 13440 label: displayLabel, 13441 hideLabelFromVision, 13442 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_components35.__experimentalVStack, { spacing: 4, children: [ 13443 /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_components35.__experimentalHStack, { spacing: 2, wrap: true, justify: "flex-start", children: [ 13444 DATE_PRESETS.map((preset) => { 13445 const isSelected2 = selectedPresetId === preset.id; 13446 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13447 import_components35.Button, 13448 { 13449 className: "dataviews-controls__date-preset", 13450 variant: "tertiary", 13451 isPressed: isSelected2, 13452 size: "small", 13453 onClick: () => handlePresetClick(preset), 13454 children: preset.label 13455 }, 13456 preset.id 13457 ); 13458 }), 13459 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13460 import_components35.Button, 13461 { 13462 className: "dataviews-controls__date-preset", 13463 variant: "tertiary", 13464 isPressed: !selectedPresetId, 13465 size: "small", 13466 disabled: !!selectedPresetId, 13467 accessibleWhenDisabled: false, 13468 children: (0, import_i18n33.__)("Custom") 13469 } 13470 ) 13471 ] }), 13472 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13473 import_components35.__experimentalInputControl, 13474 { 13475 __next40pxDefaultSize: true, 13476 ref: validityTargetRef, 13477 type: "date", 13478 label: (0, import_i18n33.__)("Date"), 13479 hideLabelFromVision: true, 13480 value, 13481 onChange: handleManualDateChange, 13482 required: !!field.isValid?.required 13483 } 13484 ), 13485 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13486 DateCalendar2, 13487 { 13488 style: { width: "100%" }, 13489 selected: value ? parseDate(value) || void 0 : void 0, 13490 onSelect: onSelectDate, 13491 month: calendarMonth, 13492 onMonthChange: setCalendarMonth, 13493 timeZone: timezoneString || void 0, 13494 weekStartsOn 13495 } 13496 ) 13497 ] }) 13498 } 13499 ) 13500 } 13501 ); 13502 } 13503 function CalendarDateRangeControl({ 13504 data, 13505 field, 13506 onChange, 13507 hideLabelFromVision, 13508 validity 13509 }) { 13510 const { id, label, getValue, setValue, format: fieldFormat } = field; 13511 let value; 13512 const fieldValue = getValue({ item: data }); 13513 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) { 13514 value = fieldValue; 13515 } 13516 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 13517 const onChangeCallback = (0, import_element40.useCallback)( 13518 (newValue) => { 13519 onChange( 13520 setValue({ 13521 item: data, 13522 value: newValue 13523 }) 13524 ); 13525 }, 13526 [data, onChange, setValue] 13527 ); 13528 const [selectedPresetId, setSelectedPresetId] = (0, import_element40.useState)( 13529 null 13530 ); 13531 const selectedRange = (0, import_element40.useMemo)(() => { 13532 if (!value) { 13533 return { from: void 0, to: void 0 }; 13534 } 13535 const [from, to] = value; 13536 return { 13537 from: parseDate(from) || void 0, 13538 to: parseDate(to) || void 0 13539 }; 13540 }, [value]); 13541 const [calendarMonth, setCalendarMonth] = (0, import_element40.useState)(() => { 13542 return selectedRange.from || /* @__PURE__ */ new Date(); 13543 }); 13544 const [isTouched, setIsTouched] = (0, import_element40.useState)(false); 13545 const fromInputRef = (0, import_element40.useRef)(null); 13546 const toInputRef = (0, import_element40.useRef)(null); 13547 const updateDateRange = (0, import_element40.useCallback)( 13548 (fromDate, toDate2) => { 13549 if (fromDate && toDate2) { 13550 onChangeCallback([ 13551 formatDate(fromDate), 13552 formatDate(toDate2) 13553 ]); 13554 } else if (!fromDate && !toDate2) { 13555 onChangeCallback(void 0); 13556 } 13557 }, 13558 [onChangeCallback] 13559 ); 13560 const onSelectCalendarRange = (0, import_element40.useCallback)( 13561 (newRange) => { 13562 updateDateRange(newRange?.from, newRange?.to); 13563 setSelectedPresetId(null); 13564 setIsTouched(true); 13565 }, 13566 [updateDateRange] 13567 ); 13568 const handlePresetClick = (0, import_element40.useCallback)( 13569 (preset) => { 13570 const [startDate, endDate] = preset.getValue(); 13571 setCalendarMonth(startDate); 13572 updateDateRange(startDate, endDate); 13573 setSelectedPresetId(preset.id); 13574 setIsTouched(true); 13575 }, 13576 [updateDateRange] 13577 ); 13578 const handleManualDateChange = (0, import_element40.useCallback)( 13579 (fromOrTo, newValue) => { 13580 const [currentFrom, currentTo] = value || [ 13581 void 0, 13582 void 0 13583 ]; 13584 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom; 13585 const updatedTo = fromOrTo === "to" ? newValue : currentTo; 13586 updateDateRange(updatedFrom, updatedTo); 13587 if (newValue) { 13588 const parsedDate = parseDate(newValue); 13589 if (parsedDate) { 13590 setCalendarMonth(parsedDate); 13591 } 13592 } 13593 setSelectedPresetId(null); 13594 setIsTouched(true); 13595 }, 13596 [value, updateDateRange] 13597 ); 13598 const { timezone } = (0, import_date3.getSettings)(); 13599 const displayLabel = field.isValid?.required ? `$label} (${(0, import_i18n33.__)("Required")})` : label; 13600 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13601 ValidatedDateControl, 13602 { 13603 field, 13604 validity, 13605 inputRefs: [fromInputRef, toInputRef], 13606 isTouched, 13607 setIsTouched, 13608 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13609 import_components35.BaseControl, 13610 { 13611 id, 13612 className: "dataviews-controls__date", 13613 label: displayLabel, 13614 hideLabelFromVision, 13615 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_components35.__experimentalVStack, { spacing: 4, children: [ 13616 /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_components35.__experimentalHStack, { spacing: 2, wrap: true, justify: "flex-start", children: [ 13617 DATE_RANGE_PRESETS.map((preset) => { 13618 const isSelected2 = selectedPresetId === preset.id; 13619 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13620 import_components35.Button, 13621 { 13622 className: "dataviews-controls__date-preset", 13623 variant: "tertiary", 13624 isPressed: isSelected2, 13625 size: "small", 13626 onClick: () => handlePresetClick(preset), 13627 children: preset.label 13628 }, 13629 preset.id 13630 ); 13631 }), 13632 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13633 import_components35.Button, 13634 { 13635 className: "dataviews-controls__date-preset", 13636 variant: "tertiary", 13637 isPressed: !selectedPresetId, 13638 size: "small", 13639 accessibleWhenDisabled: false, 13640 disabled: !!selectedPresetId, 13641 children: (0, import_i18n33.__)("Custom") 13642 } 13643 ) 13644 ] }), 13645 /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_components35.__experimentalHStack, { spacing: 2, children: [ 13646 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13647 import_components35.__experimentalInputControl, 13648 { 13649 __next40pxDefaultSize: true, 13650 ref: fromInputRef, 13651 type: "date", 13652 label: (0, import_i18n33.__)("From"), 13653 hideLabelFromVision: true, 13654 value: value?.[0], 13655 onChange: (newValue) => handleManualDateChange("from", newValue), 13656 required: !!field.isValid?.required 13657 } 13658 ), 13659 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13660 import_components35.__experimentalInputControl, 13661 { 13662 __next40pxDefaultSize: true, 13663 ref: toInputRef, 13664 type: "date", 13665 label: (0, import_i18n33.__)("To"), 13666 hideLabelFromVision: true, 13667 value: value?.[1], 13668 onChange: (newValue) => handleManualDateChange("to", newValue), 13669 required: !!field.isValid?.required 13670 } 13671 ) 13672 ] }), 13673 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13674 DateRangeCalendar, 13675 { 13676 style: { width: "100%" }, 13677 selected: selectedRange, 13678 onSelect: onSelectCalendarRange, 13679 month: calendarMonth, 13680 onMonthChange: setCalendarMonth, 13681 timeZone: timezone.string || void 0, 13682 weekStartsOn 13683 } 13684 ) 13685 ] }) 13686 } 13687 ) 13688 } 13689 ); 13690 } 13691 function DateControl({ 13692 data, 13693 field, 13694 onChange, 13695 hideLabelFromVision, 13696 operator, 13697 validity 13698 }) { 13699 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 13700 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13701 RelativeDateControl, 13702 { 13703 className: "dataviews-controls__date", 13704 data, 13705 field, 13706 onChange, 13707 hideLabelFromVision, 13708 operator 13709 } 13710 ); 13711 } 13712 if (operator === OPERATOR_BETWEEN) { 13713 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13714 CalendarDateRangeControl, 13715 { 13716 data, 13717 field, 13718 onChange, 13719 hideLabelFromVision, 13720 validity 13721 } 13722 ); 13723 } 13724 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)( 13725 CalendarDateControl, 13726 { 13727 data, 13728 field, 13729 onChange, 13730 hideLabelFromVision, 13731 validity 13732 } 13733 ); 13734 } 13735 13736 // packages/dataviews/build-module/dataform-controls/email.js 13737 var import_components37 = __toESM(require_components()); 13738 13739 // packages/dataviews/build-module/dataform-controls/utils/validated-input.js 13740 var import_components36 = __toESM(require_components()); 13741 var import_element41 = __toESM(require_element()); 13742 var import_jsx_runtime88 = __toESM(require_jsx_runtime()); 13743 var { ValidatedInputControl: ValidatedInputControl2 } = unlock(import_components36.privateApis); 13744 function ValidatedText({ 13745 data, 13746 field, 13747 onChange, 13748 hideLabelFromVision, 13749 type, 13750 prefix, 13751 suffix, 13752 validity 13753 }) { 13754 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 13755 const value = getValue({ item: data }); 13756 const onChangeControl = (0, import_element41.useCallback)( 13757 (newValue) => onChange( 13758 setValue({ 13759 item: data, 13760 value: newValue 13761 }) 13762 ), 13763 [data, setValue, onChange] 13764 ); 13765 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)( 13766 ValidatedInputControl2, 13767 { 13768 required: !!isValid2.required, 13769 customValidity: getCustomValidity(isValid2, validity), 13770 label, 13771 placeholder, 13772 value: value ?? "", 13773 help: description, 13774 onChange: onChangeControl, 13775 hideLabelFromVision, 13776 type, 13777 prefix, 13778 suffix, 13779 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0, 13780 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 13781 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 13782 __next40pxDefaultSize: true 13783 } 13784 ); 13785 } 13786 13787 // packages/dataviews/build-module/dataform-controls/email.js 13788 var import_jsx_runtime89 = __toESM(require_jsx_runtime()); 13789 function Email({ 13790 data, 13791 field, 13792 onChange, 13793 hideLabelFromVision, 13794 validity 13795 }) { 13796 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)( 13797 ValidatedText, 13798 { 13799 ...{ 13800 data, 13801 field, 13802 onChange, 13803 hideLabelFromVision, 13804 validity, 13805 type: "email", 13806 prefix: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components37.Icon, { icon: envelope_default }) }) 13807 } 13808 } 13809 ); 13810 } 13811 13812 // packages/dataviews/build-module/dataform-controls/telephone.js 13813 var import_components38 = __toESM(require_components()); 13814 var import_jsx_runtime90 = __toESM(require_jsx_runtime()); 13815 function Telephone({ 13816 data, 13817 field, 13818 onChange, 13819 hideLabelFromVision, 13820 validity 13821 }) { 13822 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)( 13823 ValidatedText, 13824 { 13825 ...{ 13826 data, 13827 field, 13828 onChange, 13829 hideLabelFromVision, 13830 validity, 13831 type: "tel", 13832 prefix: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components38.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components38.Icon, { icon: mobile_default }) }) 13833 } 13834 } 13835 ); 13836 } 13837 13838 // packages/dataviews/build-module/dataform-controls/url.js 13839 var import_components39 = __toESM(require_components()); 13840 var import_jsx_runtime91 = __toESM(require_jsx_runtime()); 13841 function Url({ 13842 data, 13843 field, 13844 onChange, 13845 hideLabelFromVision, 13846 validity 13847 }) { 13848 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)( 13849 ValidatedText, 13850 { 13851 ...{ 13852 data, 13853 field, 13854 onChange, 13855 hideLabelFromVision, 13856 validity, 13857 type: "url", 13858 prefix: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_components39.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_components39.Icon, { icon: link_default }) }) 13859 } 13860 } 13861 ); 13862 } 13863 13864 // packages/dataviews/build-module/dataform-controls/utils/validated-number.js 13865 var import_components40 = __toESM(require_components()); 13866 var import_element42 = __toESM(require_element()); 13867 var import_i18n34 = __toESM(require_i18n()); 13868 var import_jsx_runtime92 = __toESM(require_jsx_runtime()); 13869 var { ValidatedNumberControl } = unlock(import_components40.privateApis); 13870 function toNumberOrEmpty(value) { 13871 if (value === "" || value === void 0) { 13872 return ""; 13873 } 13874 const number = Number(value); 13875 return Number.isFinite(number) ? number : ""; 13876 } 13877 function BetweenControls({ 13878 value, 13879 onChange, 13880 hideLabelFromVision, 13881 step 13882 }) { 13883 const [min = "", max = ""] = value; 13884 const onChangeMin = (0, import_element42.useCallback)( 13885 (newValue) => onChange([toNumberOrEmpty(newValue), max]), 13886 [onChange, max] 13887 ); 13888 const onChangeMax = (0, import_element42.useCallback)( 13889 (newValue) => onChange([min, toNumberOrEmpty(newValue)]), 13890 [onChange, min] 13891 ); 13892 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 13893 import_components40.BaseControl, 13894 { 13895 help: (0, import_i18n34.__)("The max. value must be greater than the min. value."), 13896 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_components40.Flex, { direction: "row", gap: 4, children: [ 13897 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 13898 import_components40.__experimentalNumberControl, 13899 { 13900 label: (0, import_i18n34.__)("Min."), 13901 value: min, 13902 max: max ? Number(max) - step : void 0, 13903 onChange: onChangeMin, 13904 __next40pxDefaultSize: true, 13905 hideLabelFromVision, 13906 step 13907 } 13908 ), 13909 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 13910 import_components40.__experimentalNumberControl, 13911 { 13912 label: (0, import_i18n34.__)("Max."), 13913 value: max, 13914 min: min ? Number(min) + step : void 0, 13915 onChange: onChangeMax, 13916 __next40pxDefaultSize: true, 13917 hideLabelFromVision, 13918 step 13919 } 13920 ) 13921 ] }) 13922 } 13923 ); 13924 } 13925 function ValidatedNumber({ 13926 data, 13927 field, 13928 onChange, 13929 hideLabelFromVision, 13930 operator, 13931 validity 13932 }) { 13933 const decimals = field.format?.decimals ?? 0; 13934 const step = Math.pow(10, Math.abs(decimals) * -1); 13935 const { label, description, getValue, setValue, isValid: isValid2 } = field; 13936 const value = getValue({ item: data }) ?? ""; 13937 const onChangeControl = (0, import_element42.useCallback)( 13938 (newValue) => { 13939 onChange( 13940 setValue({ 13941 item: data, 13942 // Do not convert an empty string or undefined to a number, 13943 // otherwise there's a mismatch between the UI control (empty) 13944 // and the data relied by onChange (0). 13945 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue) 13946 }) 13947 ); 13948 }, 13949 [data, onChange, setValue] 13950 ); 13951 const onChangeBetweenControls = (0, import_element42.useCallback)( 13952 (newValue) => { 13953 onChange( 13954 setValue({ 13955 item: data, 13956 value: newValue 13957 }) 13958 ); 13959 }, 13960 [data, onChange, setValue] 13961 ); 13962 if (operator === OPERATOR_BETWEEN) { 13963 let valueBetween = ["", ""]; 13964 if (Array.isArray(value) && value.length === 2 && value.every( 13965 (element) => typeof element === "number" || element === "" 13966 )) { 13967 valueBetween = value; 13968 } 13969 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 13970 BetweenControls, 13971 { 13972 value: valueBetween, 13973 onChange: onChangeBetweenControls, 13974 hideLabelFromVision, 13975 step 13976 } 13977 ); 13978 } 13979 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)( 13980 ValidatedNumberControl, 13981 { 13982 required: !!isValid2.required, 13983 customValidity: getCustomValidity(isValid2, validity), 13984 label, 13985 help: description, 13986 value, 13987 onChange: onChangeControl, 13988 __next40pxDefaultSize: true, 13989 hideLabelFromVision, 13990 step, 13991 min: isValid2.min ? isValid2.min.constraint : void 0, 13992 max: isValid2.max ? isValid2.max.constraint : void 0 13993 } 13994 ); 13995 } 13996 13997 // packages/dataviews/build-module/dataform-controls/integer.js 13998 var import_jsx_runtime93 = __toESM(require_jsx_runtime()); 13999 function Integer(props) { 14000 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ValidatedNumber, { ...props }); 14001 } 14002 14003 // packages/dataviews/build-module/dataform-controls/number.js 14004 var import_jsx_runtime94 = __toESM(require_jsx_runtime()); 14005 function Number2(props) { 14006 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ValidatedNumber, { ...props }); 14007 } 14008 14009 // packages/dataviews/build-module/dataform-controls/radio.js 14010 var import_components41 = __toESM(require_components()); 14011 var import_element43 = __toESM(require_element()); 14012 var import_jsx_runtime95 = __toESM(require_jsx_runtime()); 14013 var { ValidatedRadioControl } = unlock(import_components41.privateApis); 14014 function Radio({ 14015 data, 14016 field, 14017 onChange, 14018 hideLabelFromVision, 14019 validity 14020 }) { 14021 const { label, description, getValue, setValue, isValid: isValid2 } = field; 14022 const { elements, isLoading } = useElements({ 14023 elements: field.elements, 14024 getElements: field.getElements 14025 }); 14026 const value = getValue({ item: data }); 14027 const onChangeControl = (0, import_element43.useCallback)( 14028 (newValue) => onChange(setValue({ item: data, value: newValue })), 14029 [data, onChange, setValue] 14030 ); 14031 if (isLoading) { 14032 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components41.Spinner, {}); 14033 } 14034 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 14035 ValidatedRadioControl, 14036 { 14037 required: !!field.isValid?.required, 14038 customValidity: getCustomValidity(isValid2, validity), 14039 label, 14040 help: description, 14041 onChange: onChangeControl, 14042 options: elements, 14043 selected: value, 14044 hideLabelFromVision 14045 } 14046 ); 14047 } 14048 14049 // packages/dataviews/build-module/dataform-controls/select.js 14050 var import_components42 = __toESM(require_components()); 14051 var import_element44 = __toESM(require_element()); 14052 var import_jsx_runtime96 = __toESM(require_jsx_runtime()); 14053 var { ValidatedSelectControl } = unlock(import_components42.privateApis); 14054 function Select({ 14055 data, 14056 field, 14057 onChange, 14058 hideLabelFromVision, 14059 validity 14060 }) { 14061 const { type, label, description, getValue, setValue, isValid: isValid2 } = field; 14062 const isMultiple = type === "array"; 14063 const value = getValue({ item: data }) ?? (isMultiple ? [] : ""); 14064 const onChangeControl = (0, import_element44.useCallback)( 14065 (newValue) => onChange(setValue({ item: data, value: newValue })), 14066 [data, onChange, setValue] 14067 ); 14068 const { elements, isLoading } = useElements({ 14069 elements: field.elements, 14070 getElements: field.getElements 14071 }); 14072 if (isLoading) { 14073 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_components42.Spinner, {}); 14074 } 14075 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 14076 ValidatedSelectControl, 14077 { 14078 required: !!field.isValid?.required, 14079 customValidity: getCustomValidity(isValid2, validity), 14080 label, 14081 value, 14082 help: description, 14083 options: elements, 14084 onChange: onChangeControl, 14085 __next40pxDefaultSize: true, 14086 hideLabelFromVision, 14087 multiple: isMultiple 14088 } 14089 ); 14090 } 14091 14092 // packages/dataviews/build-module/dataform-controls/text.js 14093 var import_element45 = __toESM(require_element()); 14094 var import_jsx_runtime97 = __toESM(require_jsx_runtime()); 14095 function Text2({ 14096 data, 14097 field, 14098 onChange, 14099 hideLabelFromVision, 14100 config, 14101 validity 14102 }) { 14103 const { prefix, suffix } = config || {}; 14104 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 14105 ValidatedText, 14106 { 14107 ...{ 14108 data, 14109 field, 14110 onChange, 14111 hideLabelFromVision, 14112 validity, 14113 prefix: prefix ? (0, import_element45.createElement)(prefix) : void 0, 14114 suffix: suffix ? (0, import_element45.createElement)(suffix) : void 0 14115 } 14116 } 14117 ); 14118 } 14119 14120 // packages/dataviews/build-module/dataform-controls/toggle.js 14121 var import_components43 = __toESM(require_components()); 14122 var import_element46 = __toESM(require_element()); 14123 var import_jsx_runtime98 = __toESM(require_jsx_runtime()); 14124 var { ValidatedToggleControl } = unlock(import_components43.privateApis); 14125 function Toggle({ 14126 field, 14127 onChange, 14128 data, 14129 hideLabelFromVision, 14130 validity 14131 }) { 14132 const { label, description, getValue, setValue, isValid: isValid2 } = field; 14133 const onChangeControl = (0, import_element46.useCallback)(() => { 14134 onChange( 14135 setValue({ item: data, value: !getValue({ item: data }) }) 14136 ); 14137 }, [onChange, setValue, data, getValue]); 14138 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 14139 ValidatedToggleControl, 14140 { 14141 required: !!isValid2.required, 14142 customValidity: getCustomValidity(isValid2, validity), 14143 hidden: hideLabelFromVision, 14144 label, 14145 help: description, 14146 checked: getValue({ item: data }), 14147 onChange: onChangeControl 14148 } 14149 ); 14150 } 14151 14152 // packages/dataviews/build-module/dataform-controls/textarea.js 14153 var import_components44 = __toESM(require_components()); 14154 var import_element47 = __toESM(require_element()); 14155 var import_jsx_runtime99 = __toESM(require_jsx_runtime()); 14156 var { ValidatedTextareaControl } = unlock(import_components44.privateApis); 14157 function Textarea({ 14158 data, 14159 field, 14160 onChange, 14161 hideLabelFromVision, 14162 config, 14163 validity 14164 }) { 14165 const { rows = 4 } = config || {}; 14166 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 14167 const value = field.getValue({ item: data }); 14168 const onChangeControl = (0, import_element47.useCallback)( 14169 (newValue) => onChange(setValue({ item: data, value: newValue })), 14170 [data, onChange, setValue] 14171 ); 14172 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 14173 ValidatedTextareaControl, 14174 { 14175 required: !!isValid2.required, 14176 customValidity: getCustomValidity(isValid2, validity), 14177 label, 14178 placeholder, 14179 value: value ?? "", 14180 help: description, 14181 onChange: onChangeControl, 14182 rows, 14183 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 14184 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 14185 __next40pxDefaultSize: true, 14186 hideLabelFromVision 14187 } 14188 ); 14189 } 14190 14191 // packages/dataviews/build-module/dataform-controls/toggle-group.js 14192 var import_components45 = __toESM(require_components()); 14193 var import_element48 = __toESM(require_element()); 14194 var import_jsx_runtime100 = __toESM(require_jsx_runtime()); 14195 var { ValidatedToggleGroupControl } = unlock(import_components45.privateApis); 14196 function ToggleGroup({ 14197 data, 14198 field, 14199 onChange, 14200 hideLabelFromVision, 14201 validity 14202 }) { 14203 const { getValue, setValue, isValid: isValid2 } = field; 14204 const value = getValue({ item: data }); 14205 const onChangeControl = (0, import_element48.useCallback)( 14206 (newValue) => onChange(setValue({ item: data, value: newValue })), 14207 [data, onChange, setValue] 14208 ); 14209 const { elements, isLoading } = useElements({ 14210 elements: field.elements, 14211 getElements: field.getElements 14212 }); 14213 if (isLoading) { 14214 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components45.Spinner, {}); 14215 } 14216 if (elements.length === 0) { 14217 return null; 14218 } 14219 const selectedOption = elements.find((el) => el.value === value); 14220 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 14221 ValidatedToggleGroupControl, 14222 { 14223 required: !!field.isValid?.required, 14224 customValidity: getCustomValidity(isValid2, validity), 14225 __next40pxDefaultSize: true, 14226 isBlock: true, 14227 label: field.label, 14228 help: selectedOption?.description || field.description, 14229 onChange: onChangeControl, 14230 value, 14231 hideLabelFromVision, 14232 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 14233 import_components45.__experimentalToggleGroupControlOption, 14234 { 14235 label: el.label, 14236 value: el.value 14237 }, 14238 el.value 14239 )) 14240 } 14241 ); 14242 } 14243 14244 // packages/dataviews/build-module/dataform-controls/array.js 14245 var import_components46 = __toESM(require_components()); 14246 var import_element49 = __toESM(require_element()); 14247 var import_jsx_runtime101 = __toESM(require_jsx_runtime()); 14248 var { ValidatedFormTokenField } = unlock(import_components46.privateApis); 14249 function ArrayControl({ 14250 data, 14251 field, 14252 onChange, 14253 hideLabelFromVision, 14254 validity 14255 }) { 14256 const { label, placeholder, getValue, setValue, isValid: isValid2 } = field; 14257 const value = getValue({ item: data }); 14258 const { elements, isLoading } = useElements({ 14259 elements: field.elements, 14260 getElements: field.getElements 14261 }); 14262 const arrayValueAsElements = (0, import_element49.useMemo)( 14263 () => Array.isArray(value) ? value.map((token) => { 14264 const element = elements?.find( 14265 (suggestion) => suggestion.value === token 14266 ); 14267 return element || { value: token, label: token }; 14268 }) : [], 14269 [value, elements] 14270 ); 14271 const onChangeControl = (0, import_element49.useCallback)( 14272 (tokens) => { 14273 const valueTokens = tokens.map((token) => { 14274 if (typeof token === "object" && "value" in token) { 14275 return token.value; 14276 } 14277 return token; 14278 }); 14279 onChange(setValue({ item: data, value: valueTokens })); 14280 }, 14281 [onChange, setValue, data] 14282 ); 14283 if (isLoading) { 14284 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components46.Spinner, {}); 14285 } 14286 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)( 14287 ValidatedFormTokenField, 14288 { 14289 required: !!isValid2?.required, 14290 customValidity: getCustomValidity(isValid2, validity), 14291 label: hideLabelFromVision ? void 0 : label, 14292 value: arrayValueAsElements, 14293 onChange: onChangeControl, 14294 placeholder, 14295 suggestions: elements?.map((element) => element.value), 14296 __experimentalValidateInput: (token) => { 14297 if (field.isValid?.elements && elements) { 14298 return elements.some( 14299 (element) => element.value === token || element.label === token 14300 ); 14301 } 14302 return true; 14303 }, 14304 __experimentalExpandOnFocus: elements && elements.length > 0, 14305 __experimentalShowHowTo: !field.isValid?.elements, 14306 displayTransform: (token) => { 14307 if (typeof token === "object" && "label" in token) { 14308 return token.label; 14309 } 14310 if (typeof token === "string" && elements) { 14311 const element = elements.find( 14312 (el) => el.value === token 14313 ); 14314 return element?.label || token; 14315 } 14316 return token; 14317 }, 14318 __experimentalRenderItem: ({ item }) => { 14319 if (typeof item === "string" && elements) { 14320 const element = elements.find( 14321 (el) => el.value === item 14322 ); 14323 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("span", { children: element?.label || item }); 14324 } 14325 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("span", { children: item }); 14326 } 14327 } 14328 ); 14329 } 14330 14331 // node_modules/colord/index.mjs 14332 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; 14333 var t = function(r3) { 14334 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3; 14335 }; 14336 var n = function(r3, t2, n2) { 14337 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0; 14338 }; 14339 var e = function(r3, t2, n2) { 14340 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2; 14341 }; 14342 var u = function(r3) { 14343 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360; 14344 }; 14345 var a = function(r3) { 14346 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) }; 14347 }; 14348 var o = function(r3) { 14349 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) }; 14350 }; 14351 var i = /^#([0-9a-f]{3,8})$/i; 14352 var s = function(r3) { 14353 var t2 = r3.toString(16); 14354 return t2.length < 2 ? "0" + t2 : t2; 14355 }; 14356 var h = function(r3) { 14357 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; 14358 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 }; 14359 }; 14360 var b = function(r3) { 14361 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a; 14362 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100; 14363 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; 14364 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 }; 14365 }; 14366 var g = function(r3) { 14367 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) }; 14368 }; 14369 var d = function(r3) { 14370 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) }; 14371 }; 14372 var f = function(r3) { 14373 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 })); 14374 var t2, n2, e2; 14375 }; 14376 var c = function(r3) { 14377 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 }; 14378 var t2, n2, e2, u2; 14379 }; 14380 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 14381 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 14382 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 14383 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 14384 var y = { string: [[function(r3) { 14385 var t2 = i.exec(r3); 14386 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; 14387 }, "hex"], [function(r3) { 14388 var t2 = v.exec(r3) || m.exec(r3); 14389 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; 14390 }, "rgb"], [function(t2) { 14391 var n2 = l.exec(t2) || p.exec(t2); 14392 if (!n2) return null; 14393 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) }); 14394 return f(a2); 14395 }, "hsl"]], object: [[function(r3) { 14396 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2; 14397 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null; 14398 }, "rgb"], [function(r3) { 14399 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2; 14400 if (!t(n2) || !t(e2) || !t(u2)) return null; 14401 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) }); 14402 return f(i2); 14403 }, "hsl"], [function(r3) { 14404 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2; 14405 if (!t(n2) || !t(a2) || !t(o2)) return null; 14406 var h2 = (function(r4) { 14407 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) }; 14408 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) }); 14409 return b(h2); 14410 }, "hsv"]] }; 14411 var N = function(r3, t2) { 14412 for (var n2 = 0; n2 < t2.length; n2++) { 14413 var e2 = t2[n2][0](r3); 14414 if (e2) return [e2, t2[n2][1]]; 14415 } 14416 return [null, void 0]; 14417 }; 14418 var x = function(r3) { 14419 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0]; 14420 }; 14421 var M = function(r3, t2) { 14422 var n2 = c(r3); 14423 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a }; 14424 }; 14425 var H = function(r3) { 14426 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255; 14427 }; 14428 var $ = function(r3, t2) { 14429 var n2 = c(r3); 14430 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a }; 14431 }; 14432 var j = (function() { 14433 function r3(r4) { 14434 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 14435 } 14436 return r3.prototype.isValid = function() { 14437 return null !== this.parsed; 14438 }, r3.prototype.brightness = function() { 14439 return n(H(this.rgba), 2); 14440 }, r3.prototype.isDark = function() { 14441 return H(this.rgba) < 0.5; 14442 }, r3.prototype.isLight = function() { 14443 return H(this.rgba) >= 0.5; 14444 }, r3.prototype.toHex = function() { 14445 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; 14446 var r4, t2, e2, u2, a2, i2; 14447 }, r3.prototype.toRgb = function() { 14448 return o(this.rgba); 14449 }, r3.prototype.toRgbString = function() { 14450 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 + ")"; 14451 var r4, t2, n2, e2, u2; 14452 }, r3.prototype.toHsl = function() { 14453 return d(c(this.rgba)); 14454 }, r3.prototype.toHslString = function() { 14455 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 + "%)"; 14456 var r4, t2, n2, e2, u2; 14457 }, r3.prototype.toHsv = function() { 14458 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) }; 14459 var r4; 14460 }, r3.prototype.invert = function() { 14461 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a }); 14462 var r4; 14463 }, r3.prototype.saturate = function(r4) { 14464 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4)); 14465 }, r3.prototype.desaturate = function(r4) { 14466 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4)); 14467 }, r3.prototype.grayscale = function() { 14468 return w(M(this.rgba, -1)); 14469 }, r3.prototype.lighten = function(r4) { 14470 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4)); 14471 }, r3.prototype.darken = function(r4) { 14472 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4)); 14473 }, r3.prototype.rotate = function(r4) { 14474 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4); 14475 }, r3.prototype.alpha = function(r4) { 14476 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3); 14477 var t2; 14478 }, r3.prototype.hue = function(r4) { 14479 var t2 = c(this.rgba); 14480 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h); 14481 }, r3.prototype.isEqual = function(r4) { 14482 return this.toHex() === w(r4).toHex(); 14483 }, r3; 14484 })(); 14485 var w = function(r3) { 14486 return r3 instanceof j ? r3 : new j(r3); 14487 }; 14488 14489 // packages/dataviews/build-module/dataform-controls/color.js 14490 var import_components47 = __toESM(require_components()); 14491 var import_element50 = __toESM(require_element()); 14492 var import_jsx_runtime102 = __toESM(require_jsx_runtime()); 14493 var { ValidatedInputControl: ValidatedInputControl3, Picker } = unlock(import_components47.privateApis); 14494 var ColorPicker = ({ 14495 color, 14496 onColorChange 14497 }) => { 14498 const validColor = color && w(color).isValid() ? color : "#ffffff"; 14499 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 14500 import_components47.Dropdown, 14501 { 14502 renderToggle: ({ onToggle, isOpen }) => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components47.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 14503 "button", 14504 { 14505 type: "button", 14506 onClick: onToggle, 14507 style: { 14508 width: "24px", 14509 height: "24px", 14510 borderRadius: "50%", 14511 backgroundColor: validColor, 14512 border: "1px solid #ddd", 14513 cursor: "pointer", 14514 outline: isOpen ? "2px solid #007cba" : "none", 14515 outlineOffset: "2px", 14516 display: "flex", 14517 alignItems: "center", 14518 justifyContent: "center", 14519 padding: 0, 14520 margin: 0 14521 }, 14522 "aria-label": "Open color picker" 14523 } 14524 ) }), 14525 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { style: { padding: "16px" }, children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 14526 Picker, 14527 { 14528 color: w(validColor), 14529 onChange: onColorChange, 14530 enableAlpha: true 14531 } 14532 ) }) 14533 } 14534 ); 14535 }; 14536 function Color({ 14537 data, 14538 field, 14539 onChange, 14540 hideLabelFromVision, 14541 validity 14542 }) { 14543 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 14544 const value = field.getValue({ item: data }) || ""; 14545 const handleColorChange = (0, import_element50.useCallback)( 14546 (colorObject) => { 14547 onChange(setValue({ item: data, value: colorObject.toHex() })); 14548 }, 14549 [data, onChange, setValue] 14550 ); 14551 const handleInputChange = (0, import_element50.useCallback)( 14552 (newValue) => { 14553 onChange(setValue({ item: data, value: newValue || "" })); 14554 }, 14555 [data, onChange, setValue] 14556 ); 14557 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 14558 ValidatedInputControl3, 14559 { 14560 required: !!field.isValid?.required, 14561 customValidity: getCustomValidity(isValid2, validity), 14562 label, 14563 placeholder, 14564 value, 14565 help: description, 14566 onChange: handleInputChange, 14567 hideLabelFromVision, 14568 type: "text", 14569 prefix: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)( 14570 ColorPicker, 14571 { 14572 color: value, 14573 onColorChange: handleColorChange 14574 } 14575 ) 14576 } 14577 ); 14578 } 14579 14580 // packages/dataviews/build-module/dataform-controls/password.js 14581 var import_components48 = __toESM(require_components()); 14582 var import_element51 = __toESM(require_element()); 14583 var import_i18n35 = __toESM(require_i18n()); 14584 var import_jsx_runtime103 = __toESM(require_jsx_runtime()); 14585 function Password({ 14586 data, 14587 field, 14588 onChange, 14589 hideLabelFromVision, 14590 validity 14591 }) { 14592 const [isVisible2, setIsVisible] = (0, import_element51.useState)(false); 14593 const toggleVisibility = (0, import_element51.useCallback)(() => { 14594 setIsVisible((prev) => !prev); 14595 }, []); 14596 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 14597 ValidatedText, 14598 { 14599 ...{ 14600 data, 14601 field, 14602 onChange, 14603 hideLabelFromVision, 14604 validity, 14605 type: isVisible2 ? "text" : "password", 14606 suffix: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components48.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)( 14607 import_components48.Button, 14608 { 14609 icon: isVisible2 ? unseen_default : seen_default, 14610 onClick: toggleVisibility, 14611 size: "small", 14612 label: isVisible2 ? (0, import_i18n35.__)("Hide password") : (0, import_i18n35.__)("Show password") 14613 } 14614 ) }) 14615 } 14616 } 14617 ); 14618 } 14619 14620 // packages/dataviews/build-module/field-types/utils/has-elements.js 14621 function hasElements(field) { 14622 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function"; 14623 } 14624 14625 // packages/dataviews/build-module/dataform-controls/index.js 14626 var import_jsx_runtime104 = __toESM(require_jsx_runtime()); 14627 var FORM_CONTROLS = { 14628 array: ArrayControl, 14629 checkbox: Checkbox, 14630 color: Color, 14631 datetime: DateTime, 14632 date: DateControl, 14633 email: Email, 14634 telephone: Telephone, 14635 url: Url, 14636 integer: Integer, 14637 number: Number2, 14638 password: Password, 14639 radio: Radio, 14640 select: Select, 14641 text: Text2, 14642 toggle: Toggle, 14643 textarea: Textarea, 14644 toggleGroup: ToggleGroup 14645 }; 14646 function isEditConfig(value) { 14647 return value && typeof value === "object" && typeof value.control === "string"; 14648 } 14649 function createConfiguredControl(config) { 14650 const { control, ...controlConfig } = config; 14651 const BaseControlType = getControlByType(control); 14652 if (BaseControlType === null) { 14653 return null; 14654 } 14655 return function ConfiguredControl(props) { 14656 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(BaseControlType, { ...props, config: controlConfig }); 14657 }; 14658 } 14659 function getControl(field, fallback) { 14660 if (typeof field.Edit === "function") { 14661 return field.Edit; 14662 } 14663 if (typeof field.Edit === "string") { 14664 return getControlByType(field.Edit); 14665 } 14666 if (isEditConfig(field.Edit)) { 14667 return createConfiguredControl(field.Edit); 14668 } 14669 if (hasElements(field) && field.type !== "array") { 14670 return getControlByType("select"); 14671 } 14672 if (fallback === null) { 14673 return null; 14674 } 14675 return getControlByType(fallback); 14676 } 14677 function getControlByType(type) { 14678 if (Object.keys(FORM_CONTROLS).includes(type)) { 14679 return FORM_CONTROLS[type]; 14680 } 14681 return null; 14682 } 14683 14684 // packages/dataviews/build-module/field-types/utils/get-filter-by.js 14685 function getFilterBy(field, defaultOperators, validOperators) { 14686 if (field.filterBy === false) { 14687 return false; 14688 } 14689 const operators = field.filterBy?.operators?.filter( 14690 (op) => validOperators.includes(op) 14691 ) ?? defaultOperators; 14692 if (operators.length === 0) { 14693 return false; 14694 } 14695 return { 14696 isPrimary: !!field.filterBy?.isPrimary, 14697 operators 14698 }; 14699 } 14700 var get_filter_by_default = getFilterBy; 14701 14702 // packages/dataviews/build-module/field-types/utils/get-value-from-id.js 14703 var getValueFromId = (id) => ({ item }) => { 14704 const path = id.split("."); 14705 let value = item; 14706 for (const segment of path) { 14707 if (value.hasOwnProperty(segment)) { 14708 value = value[segment]; 14709 } else { 14710 value = void 0; 14711 } 14712 } 14713 return value; 14714 }; 14715 var get_value_from_id_default = getValueFromId; 14716 14717 // packages/dataviews/build-module/field-types/utils/set-value-from-id.js 14718 var setValueFromId = (id) => ({ value }) => { 14719 const path = id.split("."); 14720 const result = {}; 14721 let current = result; 14722 for (const segment of path.slice(0, -1)) { 14723 current[segment] = {}; 14724 current = current[segment]; 14725 } 14726 current[path.at(-1)] = value; 14727 return result; 14728 }; 14729 var set_value_from_id_default = setValueFromId; 14730 14731 // packages/dataviews/build-module/field-types/email.js 14732 var import_i18n36 = __toESM(require_i18n()); 14733 14734 // packages/dataviews/build-module/field-types/utils/render-from-elements.js 14735 function RenderFromElements({ 14736 item, 14737 field 14738 }) { 14739 const { elements, isLoading } = useElements({ 14740 elements: field.elements, 14741 getElements: field.getElements 14742 }); 14743 const value = field.getValue({ item }); 14744 if (isLoading) { 14745 return value; 14746 } 14747 if (elements.length === 0) { 14748 return value; 14749 } 14750 return elements?.find((element) => element.value === value)?.label || field.getValue({ item }); 14751 } 14752 14753 // packages/dataviews/build-module/field-types/utils/render-default.js 14754 var import_jsx_runtime105 = __toESM(require_jsx_runtime()); 14755 function render({ 14756 item, 14757 field 14758 }) { 14759 if (field.hasElements) { 14760 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(RenderFromElements, { item, field }); 14761 } 14762 return field.getValueFormatted({ item, field }); 14763 } 14764 14765 // packages/dataviews/build-module/field-types/utils/sort-text.js 14766 var sort_text_default = (a2, b2, direction) => { 14767 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2); 14768 }; 14769 14770 // packages/dataviews/build-module/field-types/utils/is-valid-required.js 14771 function isValidRequired(item, field) { 14772 const value = field.getValue({ item }); 14773 return ![void 0, "", null].includes(value); 14774 } 14775 14776 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.js 14777 function isValidMinLength(item, field) { 14778 if (typeof field.isValid.minLength?.constraint !== "number") { 14779 return false; 14780 } 14781 const value = field.getValue({ item }); 14782 if ([void 0, "", null].includes(value)) { 14783 return true; 14784 } 14785 return String(value).length >= field.isValid.minLength.constraint; 14786 } 14787 14788 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.js 14789 function isValidMaxLength(item, field) { 14790 if (typeof field.isValid.maxLength?.constraint !== "number") { 14791 return false; 14792 } 14793 const value = field.getValue({ item }); 14794 if ([void 0, "", null].includes(value)) { 14795 return true; 14796 } 14797 return String(value).length <= field.isValid.maxLength.constraint; 14798 } 14799 14800 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.js 14801 function isValidPattern(item, field) { 14802 if (field.isValid.pattern?.constraint === void 0) { 14803 return true; 14804 } 14805 try { 14806 const regexp = new RegExp(field.isValid.pattern.constraint); 14807 const value = field.getValue({ item }); 14808 if ([void 0, "", null].includes(value)) { 14809 return true; 14810 } 14811 return regexp.test(String(value)); 14812 } catch { 14813 return false; 14814 } 14815 } 14816 14817 // packages/dataviews/build-module/field-types/utils/is-valid-elements.js 14818 function isValidElements(item, field) { 14819 const elements = field.elements ?? []; 14820 const validValues = elements.map((el) => el.value); 14821 if (validValues.length === 0) { 14822 return true; 14823 } 14824 const value = field.getValue({ item }); 14825 return [].concat(value).every((v2) => validValues.includes(v2)); 14826 } 14827 14828 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.js 14829 function getValueFormatted({ 14830 item, 14831 field 14832 }) { 14833 return field.getValue({ item }); 14834 } 14835 var get_value_formatted_default_default = getValueFormatted; 14836 14837 // packages/dataviews/build-module/field-types/email.js 14838 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])?)*$/; 14839 function isValidCustom(item, field) { 14840 const value = field.getValue({ item }); 14841 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) { 14842 return (0, import_i18n36.__)("Value must be a valid email address."); 14843 } 14844 return null; 14845 } 14846 var email_default = { 14847 type: "email", 14848 render, 14849 Edit: "email", 14850 sort: sort_text_default, 14851 enableSorting: true, 14852 enableGlobalSearch: false, 14853 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 14854 validOperators: [ 14855 OPERATOR_IS, 14856 OPERATOR_IS_NOT, 14857 OPERATOR_CONTAINS, 14858 OPERATOR_NOT_CONTAINS, 14859 OPERATOR_STARTS_WITH, 14860 // Multiple selection 14861 OPERATOR_IS_ANY, 14862 OPERATOR_IS_NONE, 14863 OPERATOR_IS_ALL, 14864 OPERATOR_IS_NOT_ALL 14865 ], 14866 format: {}, 14867 getValueFormatted: get_value_formatted_default_default, 14868 validate: { 14869 required: isValidRequired, 14870 pattern: isValidPattern, 14871 minLength: isValidMinLength, 14872 maxLength: isValidMaxLength, 14873 elements: isValidElements, 14874 custom: isValidCustom 14875 } 14876 }; 14877 14878 // packages/dataviews/build-module/field-types/integer.js 14879 var import_i18n37 = __toESM(require_i18n()); 14880 14881 // packages/dataviews/build-module/field-types/utils/sort-number.js 14882 var sort_number_default = (a2, b2, direction) => { 14883 return direction === "asc" ? a2 - b2 : b2 - a2; 14884 }; 14885 14886 // packages/dataviews/build-module/field-types/utils/is-valid-min.js 14887 function isValidMin(item, field) { 14888 if (typeof field.isValid.min?.constraint !== "number") { 14889 return false; 14890 } 14891 const value = field.getValue({ item }); 14892 if ([void 0, "", null].includes(value)) { 14893 return true; 14894 } 14895 return Number(value) >= field.isValid.min.constraint; 14896 } 14897 14898 // packages/dataviews/build-module/field-types/utils/is-valid-max.js 14899 function isValidMax(item, field) { 14900 if (typeof field.isValid.max?.constraint !== "number") { 14901 return false; 14902 } 14903 const value = field.getValue({ item }); 14904 if ([void 0, "", null].includes(value)) { 14905 return true; 14906 } 14907 return Number(value) <= field.isValid.max.constraint; 14908 } 14909 14910 // packages/dataviews/build-module/field-types/integer.js 14911 var format2 = { 14912 separatorThousand: "," 14913 }; 14914 function getValueFormatted2({ 14915 item, 14916 field 14917 }) { 14918 let value = field.getValue({ item }); 14919 if (value === null || value === void 0) { 14920 return ""; 14921 } 14922 value = Number(value); 14923 if (!Number.isFinite(value)) { 14924 return String(value); 14925 } 14926 let formatInteger; 14927 if (field.type !== "integer") { 14928 formatInteger = format2; 14929 } else { 14930 formatInteger = field.format; 14931 } 14932 const { separatorThousand } = formatInteger; 14933 const integerValue = Math.trunc(value); 14934 if (!separatorThousand) { 14935 return String(integerValue); 14936 } 14937 return String(integerValue).replace( 14938 /\B(?=(\d{3})+(?!\d))/g, 14939 separatorThousand 14940 ); 14941 } 14942 function isValidCustom2(item, field) { 14943 const value = field.getValue({ item }); 14944 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) { 14945 return (0, import_i18n37.__)("Value must be an integer."); 14946 } 14947 return null; 14948 } 14949 var integer_default = { 14950 type: "integer", 14951 render, 14952 Edit: "integer", 14953 sort: sort_number_default, 14954 enableSorting: true, 14955 enableGlobalSearch: false, 14956 defaultOperators: [ 14957 OPERATOR_IS, 14958 OPERATOR_IS_NOT, 14959 OPERATOR_LESS_THAN, 14960 OPERATOR_GREATER_THAN, 14961 OPERATOR_LESS_THAN_OR_EQUAL, 14962 OPERATOR_GREATER_THAN_OR_EQUAL, 14963 OPERATOR_BETWEEN 14964 ], 14965 validOperators: [ 14966 // Single-selection 14967 OPERATOR_IS, 14968 OPERATOR_IS_NOT, 14969 OPERATOR_LESS_THAN, 14970 OPERATOR_GREATER_THAN, 14971 OPERATOR_LESS_THAN_OR_EQUAL, 14972 OPERATOR_GREATER_THAN_OR_EQUAL, 14973 OPERATOR_BETWEEN, 14974 // Multiple-selection 14975 OPERATOR_IS_ANY, 14976 OPERATOR_IS_NONE, 14977 OPERATOR_IS_ALL, 14978 OPERATOR_IS_NOT_ALL 14979 ], 14980 format: format2, 14981 getValueFormatted: getValueFormatted2, 14982 validate: { 14983 required: isValidRequired, 14984 min: isValidMin, 14985 max: isValidMax, 14986 elements: isValidElements, 14987 custom: isValidCustom2 14988 } 14989 }; 14990 14991 // packages/dataviews/build-module/field-types/number.js 14992 var import_i18n38 = __toESM(require_i18n()); 14993 var format3 = { 14994 separatorThousand: ",", 14995 separatorDecimal: ".", 14996 decimals: 2 14997 }; 14998 function getValueFormatted3({ 14999 item, 15000 field 15001 }) { 15002 let value = field.getValue({ item }); 15003 if (value === null || value === void 0) { 15004 return ""; 15005 } 15006 value = Number(value); 15007 if (!Number.isFinite(value)) { 15008 return String(value); 15009 } 15010 let formatNumber; 15011 if (field.type !== "number") { 15012 formatNumber = format3; 15013 } else { 15014 formatNumber = field.format; 15015 } 15016 const { separatorThousand, separatorDecimal, decimals } = formatNumber; 15017 const fixedValue = value.toFixed(decimals); 15018 const [integerPart, decimalPart] = fixedValue.split("."); 15019 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart; 15020 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart; 15021 } 15022 function isEmpty2(value) { 15023 return value === "" || value === void 0 || value === null; 15024 } 15025 function isValidCustom3(item, field) { 15026 const value = field.getValue({ item }); 15027 if (!isEmpty2(value) && !Number.isFinite(value)) { 15028 return (0, import_i18n38.__)("Value must be a number."); 15029 } 15030 return null; 15031 } 15032 var number_default = { 15033 type: "number", 15034 render, 15035 Edit: "number", 15036 sort: sort_number_default, 15037 enableSorting: true, 15038 enableGlobalSearch: false, 15039 defaultOperators: [ 15040 OPERATOR_IS, 15041 OPERATOR_IS_NOT, 15042 OPERATOR_LESS_THAN, 15043 OPERATOR_GREATER_THAN, 15044 OPERATOR_LESS_THAN_OR_EQUAL, 15045 OPERATOR_GREATER_THAN_OR_EQUAL, 15046 OPERATOR_BETWEEN 15047 ], 15048 validOperators: [ 15049 // Single-selection 15050 OPERATOR_IS, 15051 OPERATOR_IS_NOT, 15052 OPERATOR_LESS_THAN, 15053 OPERATOR_GREATER_THAN, 15054 OPERATOR_LESS_THAN_OR_EQUAL, 15055 OPERATOR_GREATER_THAN_OR_EQUAL, 15056 OPERATOR_BETWEEN, 15057 // Multiple-selection 15058 OPERATOR_IS_ANY, 15059 OPERATOR_IS_NONE, 15060 OPERATOR_IS_ALL, 15061 OPERATOR_IS_NOT_ALL 15062 ], 15063 format: format3, 15064 getValueFormatted: getValueFormatted3, 15065 validate: { 15066 required: isValidRequired, 15067 min: isValidMin, 15068 max: isValidMax, 15069 elements: isValidElements, 15070 custom: isValidCustom3 15071 } 15072 }; 15073 15074 // packages/dataviews/build-module/field-types/text.js 15075 var text_default = { 15076 type: "text", 15077 render, 15078 Edit: "text", 15079 sort: sort_text_default, 15080 enableSorting: true, 15081 enableGlobalSearch: false, 15082 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15083 validOperators: [ 15084 // Single selection 15085 OPERATOR_IS, 15086 OPERATOR_IS_NOT, 15087 OPERATOR_CONTAINS, 15088 OPERATOR_NOT_CONTAINS, 15089 OPERATOR_STARTS_WITH, 15090 // Multiple selection 15091 OPERATOR_IS_ANY, 15092 OPERATOR_IS_NONE, 15093 OPERATOR_IS_ALL, 15094 OPERATOR_IS_NOT_ALL 15095 ], 15096 format: {}, 15097 getValueFormatted: get_value_formatted_default_default, 15098 validate: { 15099 required: isValidRequired, 15100 pattern: isValidPattern, 15101 minLength: isValidMinLength, 15102 maxLength: isValidMaxLength, 15103 elements: isValidElements 15104 } 15105 }; 15106 15107 // packages/dataviews/build-module/field-types/datetime.js 15108 var import_date5 = __toESM(require_date()); 15109 var format4 = { 15110 datetime: (0, import_date5.getSettings)().formats.datetime, 15111 weekStartsOn: (0, import_date5.getSettings)().l10n.startOfWeek 15112 }; 15113 function getValueFormatted4({ 15114 item, 15115 field 15116 }) { 15117 const value = field.getValue({ item }); 15118 if (["", void 0, null].includes(value)) { 15119 return ""; 15120 } 15121 let formatDatetime; 15122 if (field.type !== "datetime") { 15123 formatDatetime = format4; 15124 } else { 15125 formatDatetime = field.format; 15126 } 15127 return (0, import_date5.dateI18n)(formatDatetime.datetime, (0, import_date5.getDate)(value)); 15128 } 15129 var sort = (a2, b2, direction) => { 15130 const timeA = new Date(a2).getTime(); 15131 const timeB = new Date(b2).getTime(); 15132 return direction === "asc" ? timeA - timeB : timeB - timeA; 15133 }; 15134 var datetime_default = { 15135 type: "datetime", 15136 render, 15137 Edit: "datetime", 15138 sort, 15139 enableSorting: true, 15140 enableGlobalSearch: false, 15141 defaultOperators: [ 15142 OPERATOR_ON, 15143 OPERATOR_NOT_ON, 15144 OPERATOR_BEFORE, 15145 OPERATOR_AFTER, 15146 OPERATOR_BEFORE_INC, 15147 OPERATOR_AFTER_INC, 15148 OPERATOR_IN_THE_PAST, 15149 OPERATOR_OVER 15150 ], 15151 validOperators: [ 15152 OPERATOR_ON, 15153 OPERATOR_NOT_ON, 15154 OPERATOR_BEFORE, 15155 OPERATOR_AFTER, 15156 OPERATOR_BEFORE_INC, 15157 OPERATOR_AFTER_INC, 15158 OPERATOR_IN_THE_PAST, 15159 OPERATOR_OVER 15160 ], 15161 format: format4, 15162 getValueFormatted: getValueFormatted4, 15163 validate: { 15164 required: isValidRequired, 15165 elements: isValidElements 15166 } 15167 }; 15168 15169 // packages/dataviews/build-module/field-types/date.js 15170 var import_date6 = __toESM(require_date()); 15171 var format5 = { 15172 date: (0, import_date6.getSettings)().formats.date, 15173 weekStartsOn: (0, import_date6.getSettings)().l10n.startOfWeek 15174 }; 15175 function getValueFormatted5({ 15176 item, 15177 field 15178 }) { 15179 const value = field.getValue({ item }); 15180 if (["", void 0, null].includes(value)) { 15181 return ""; 15182 } 15183 let formatDate2; 15184 if (field.type !== "date") { 15185 formatDate2 = format5; 15186 } else { 15187 formatDate2 = field.format; 15188 } 15189 return (0, import_date6.dateI18n)(formatDate2.date, (0, import_date6.getDate)(value)); 15190 } 15191 var sort2 = (a2, b2, direction) => { 15192 const timeA = new Date(a2).getTime(); 15193 const timeB = new Date(b2).getTime(); 15194 return direction === "asc" ? timeA - timeB : timeB - timeA; 15195 }; 15196 var date_default = { 15197 type: "date", 15198 render, 15199 Edit: "date", 15200 sort: sort2, 15201 enableSorting: true, 15202 enableGlobalSearch: false, 15203 defaultOperators: [ 15204 OPERATOR_ON, 15205 OPERATOR_NOT_ON, 15206 OPERATOR_BEFORE, 15207 OPERATOR_AFTER, 15208 OPERATOR_BEFORE_INC, 15209 OPERATOR_AFTER_INC, 15210 OPERATOR_IN_THE_PAST, 15211 OPERATOR_OVER, 15212 OPERATOR_BETWEEN 15213 ], 15214 validOperators: [ 15215 OPERATOR_ON, 15216 OPERATOR_NOT_ON, 15217 OPERATOR_BEFORE, 15218 OPERATOR_AFTER, 15219 OPERATOR_BEFORE_INC, 15220 OPERATOR_AFTER_INC, 15221 OPERATOR_IN_THE_PAST, 15222 OPERATOR_OVER, 15223 OPERATOR_BETWEEN 15224 ], 15225 format: format5, 15226 getValueFormatted: getValueFormatted5, 15227 validate: { 15228 required: isValidRequired, 15229 elements: isValidElements 15230 } 15231 }; 15232 15233 // packages/dataviews/build-module/field-types/boolean.js 15234 var import_i18n39 = __toESM(require_i18n()); 15235 15236 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.js 15237 function isValidRequiredForBool(item, field) { 15238 const value = field.getValue({ item }); 15239 return value === true; 15240 } 15241 15242 // packages/dataviews/build-module/field-types/boolean.js 15243 function getValueFormatted6({ 15244 item, 15245 field 15246 }) { 15247 const value = field.getValue({ item }); 15248 if (value === true) { 15249 return (0, import_i18n39.__)("True"); 15250 } 15251 if (value === false) { 15252 return (0, import_i18n39.__)("False"); 15253 } 15254 return ""; 15255 } 15256 function isValidCustom4(item, field) { 15257 const value = field.getValue({ item }); 15258 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) { 15259 return (0, import_i18n39.__)("Value must be true, false, or undefined"); 15260 } 15261 return null; 15262 } 15263 var sort3 = (a2, b2, direction) => { 15264 const boolA = Boolean(a2); 15265 const boolB = Boolean(b2); 15266 if (boolA === boolB) { 15267 return 0; 15268 } 15269 if (direction === "asc") { 15270 return boolA ? 1 : -1; 15271 } 15272 return boolA ? -1 : 1; 15273 }; 15274 var boolean_default = { 15275 type: "boolean", 15276 render, 15277 Edit: "checkbox", 15278 sort: sort3, 15279 validate: { 15280 required: isValidRequiredForBool, 15281 elements: isValidElements, 15282 custom: isValidCustom4 15283 }, 15284 enableSorting: true, 15285 enableGlobalSearch: false, 15286 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 15287 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 15288 format: {}, 15289 getValueFormatted: getValueFormatted6 15290 }; 15291 15292 // packages/dataviews/build-module/field-types/media.js 15293 var media_default2 = { 15294 type: "media", 15295 render: () => null, 15296 Edit: null, 15297 sort: () => 0, 15298 enableSorting: false, 15299 enableGlobalSearch: false, 15300 defaultOperators: [], 15301 validOperators: [], 15302 format: {}, 15303 getValueFormatted: get_value_formatted_default_default, 15304 // cannot validate any constraint, so 15305 // the only available validation for the field author 15306 // would be providing a custom validator. 15307 validate: {} 15308 }; 15309 15310 // packages/dataviews/build-module/field-types/array.js 15311 var import_i18n40 = __toESM(require_i18n()); 15312 15313 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.js 15314 function isValidRequiredForArray(item, field) { 15315 const value = field.getValue({ item }); 15316 return Array.isArray(value) && value.length > 0 && value.every( 15317 (element) => ![void 0, "", null].includes(element) 15318 ); 15319 } 15320 15321 // packages/dataviews/build-module/field-types/array.js 15322 function getValueFormatted7({ 15323 item, 15324 field 15325 }) { 15326 const value = field.getValue({ item }); 15327 const arr = Array.isArray(value) ? value : []; 15328 return arr.join(", "); 15329 } 15330 function render2({ item, field }) { 15331 return getValueFormatted7({ item, field }); 15332 } 15333 function isValidCustom5(item, field) { 15334 const value = field.getValue({ item }); 15335 if (![void 0, "", null].includes(value) && !Array.isArray(value)) { 15336 return (0, import_i18n40.__)("Value must be an array."); 15337 } 15338 if (!value.every((v2) => typeof v2 === "string")) { 15339 return (0, import_i18n40.__)("Every value must be a string."); 15340 } 15341 return null; 15342 } 15343 var sort4 = (a2, b2, direction) => { 15344 const arrA = Array.isArray(a2) ? a2 : []; 15345 const arrB = Array.isArray(b2) ? b2 : []; 15346 if (arrA.length !== arrB.length) { 15347 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length; 15348 } 15349 const joinedA = arrA.join(","); 15350 const joinedB = arrB.join(","); 15351 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA); 15352 }; 15353 var array_default = { 15354 type: "array", 15355 render: render2, 15356 Edit: "array", 15357 sort: sort4, 15358 enableSorting: true, 15359 enableGlobalSearch: false, 15360 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15361 validOperators: [ 15362 OPERATOR_IS_ANY, 15363 OPERATOR_IS_NONE, 15364 OPERATOR_IS_ALL, 15365 OPERATOR_IS_NOT_ALL 15366 ], 15367 format: {}, 15368 getValueFormatted: getValueFormatted7, 15369 validate: { 15370 required: isValidRequiredForArray, 15371 elements: isValidElements, 15372 custom: isValidCustom5 15373 } 15374 }; 15375 15376 // packages/dataviews/build-module/field-types/password.js 15377 function getValueFormatted8({ 15378 item, 15379 field 15380 }) { 15381 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : ""; 15382 } 15383 var password_default = { 15384 type: "password", 15385 render, 15386 Edit: "password", 15387 sort: () => 0, 15388 // Passwords should not be sortable for security reasons 15389 enableSorting: false, 15390 enableGlobalSearch: false, 15391 defaultOperators: [], 15392 validOperators: [], 15393 format: {}, 15394 getValueFormatted: getValueFormatted8, 15395 validate: { 15396 required: isValidRequired, 15397 pattern: isValidPattern, 15398 minLength: isValidMinLength, 15399 maxLength: isValidMaxLength, 15400 elements: isValidElements 15401 } 15402 }; 15403 15404 // packages/dataviews/build-module/field-types/telephone.js 15405 var telephone_default = { 15406 type: "telephone", 15407 render, 15408 Edit: "telephone", 15409 sort: sort_text_default, 15410 enableSorting: true, 15411 enableGlobalSearch: false, 15412 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15413 validOperators: [ 15414 OPERATOR_IS, 15415 OPERATOR_IS_NOT, 15416 OPERATOR_CONTAINS, 15417 OPERATOR_NOT_CONTAINS, 15418 OPERATOR_STARTS_WITH, 15419 // Multiple selection 15420 OPERATOR_IS_ANY, 15421 OPERATOR_IS_NONE, 15422 OPERATOR_IS_ALL, 15423 OPERATOR_IS_NOT_ALL 15424 ], 15425 format: {}, 15426 getValueFormatted: get_value_formatted_default_default, 15427 validate: { 15428 required: isValidRequired, 15429 pattern: isValidPattern, 15430 minLength: isValidMinLength, 15431 maxLength: isValidMaxLength, 15432 elements: isValidElements 15433 } 15434 }; 15435 15436 // packages/dataviews/build-module/field-types/color.js 15437 var import_i18n41 = __toESM(require_i18n()); 15438 var import_jsx_runtime106 = __toESM(require_jsx_runtime()); 15439 function render3({ item, field }) { 15440 if (field.hasElements) { 15441 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(RenderFromElements, { item, field }); 15442 } 15443 const value = get_value_formatted_default_default({ item, field }); 15444 if (!value || !w(value).isValid()) { 15445 return value; 15446 } 15447 return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [ 15448 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)( 15449 "div", 15450 { 15451 style: { 15452 width: "16px", 15453 height: "16px", 15454 borderRadius: "50%", 15455 backgroundColor: value, 15456 border: "1px solid #ddd", 15457 flexShrink: 0 15458 } 15459 } 15460 ), 15461 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("span", { children: value }) 15462 ] }); 15463 } 15464 function isValidCustom6(item, field) { 15465 const value = field.getValue({ item }); 15466 if (![void 0, "", null].includes(value) && !w(value).isValid()) { 15467 return (0, import_i18n41.__)("Value must be a valid color."); 15468 } 15469 return null; 15470 } 15471 var sort5 = (a2, b2, direction) => { 15472 const colorA = w(a2); 15473 const colorB = w(b2); 15474 if (!colorA.isValid() && !colorB.isValid()) { 15475 return 0; 15476 } 15477 if (!colorA.isValid()) { 15478 return direction === "asc" ? 1 : -1; 15479 } 15480 if (!colorB.isValid()) { 15481 return direction === "asc" ? -1 : 1; 15482 } 15483 const hslA = colorA.toHsl(); 15484 const hslB = colorB.toHsl(); 15485 if (hslA.h !== hslB.h) { 15486 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h; 15487 } 15488 if (hslA.s !== hslB.s) { 15489 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s; 15490 } 15491 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l; 15492 }; 15493 var color_default = { 15494 type: "color", 15495 render: render3, 15496 Edit: "color", 15497 sort: sort5, 15498 enableSorting: true, 15499 enableGlobalSearch: false, 15500 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15501 validOperators: [ 15502 OPERATOR_IS, 15503 OPERATOR_IS_NOT, 15504 OPERATOR_IS_ANY, 15505 OPERATOR_IS_NONE 15506 ], 15507 format: {}, 15508 getValueFormatted: get_value_formatted_default_default, 15509 validate: { 15510 required: isValidRequired, 15511 elements: isValidElements, 15512 custom: isValidCustom6 15513 } 15514 }; 15515 15516 // packages/dataviews/build-module/field-types/url.js 15517 var url_default = { 15518 type: "url", 15519 render, 15520 Edit: "url", 15521 sort: sort_text_default, 15522 enableSorting: true, 15523 enableGlobalSearch: false, 15524 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 15525 validOperators: [ 15526 OPERATOR_IS, 15527 OPERATOR_IS_NOT, 15528 OPERATOR_CONTAINS, 15529 OPERATOR_NOT_CONTAINS, 15530 OPERATOR_STARTS_WITH, 15531 // Multiple selection 15532 OPERATOR_IS_ANY, 15533 OPERATOR_IS_NONE, 15534 OPERATOR_IS_ALL, 15535 OPERATOR_IS_NOT_ALL 15536 ], 15537 format: {}, 15538 getValueFormatted: get_value_formatted_default_default, 15539 validate: { 15540 required: isValidRequired, 15541 pattern: isValidPattern, 15542 minLength: isValidMinLength, 15543 maxLength: isValidMaxLength, 15544 elements: isValidElements 15545 } 15546 }; 15547 15548 // packages/dataviews/build-module/field-types/no-type.js 15549 var sort6 = (a2, b2, direction) => { 15550 if (typeof a2 === "number" && typeof b2 === "number") { 15551 return sort_number_default(a2, b2, direction); 15552 } 15553 return sort_text_default(a2, b2, direction); 15554 }; 15555 var no_type_default = { 15556 // type: no type for this one 15557 render, 15558 Edit: null, 15559 sort: sort6, 15560 enableSorting: true, 15561 enableGlobalSearch: false, 15562 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 15563 validOperators: getAllOperatorNames(), 15564 format: {}, 15565 getValueFormatted: get_value_formatted_default_default, 15566 validate: { 15567 required: isValidRequired, 15568 elements: isValidElements 15569 } 15570 }; 15571 15572 // packages/dataviews/build-module/field-types/utils/get-is-valid.js 15573 function getIsValid(field, fieldType) { 15574 let required; 15575 if (field.isValid?.required === true && fieldType.validate.required !== void 0) { 15576 required = { 15577 constraint: true, 15578 validate: fieldType.validate.required 15579 }; 15580 } 15581 let elements; 15582 if ((field.isValid?.elements === true || // elements is enabled unless the field opts-out 15583 field.isValid?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) { 15584 elements = { 15585 constraint: true, 15586 validate: fieldType.validate.elements 15587 }; 15588 } 15589 let min; 15590 if (typeof field.isValid?.min === "number" && fieldType.validate.min !== void 0) { 15591 min = { 15592 constraint: field.isValid.min, 15593 validate: fieldType.validate.min 15594 }; 15595 } 15596 let max; 15597 if (typeof field.isValid?.max === "number" && fieldType.validate.max !== void 0) { 15598 max = { 15599 constraint: field.isValid.max, 15600 validate: fieldType.validate.max 15601 }; 15602 } 15603 let minLength; 15604 if (typeof field.isValid?.minLength === "number" && fieldType.validate.minLength !== void 0) { 15605 minLength = { 15606 constraint: field.isValid.minLength, 15607 validate: fieldType.validate.minLength 15608 }; 15609 } 15610 let maxLength; 15611 if (typeof field.isValid?.maxLength === "number" && fieldType.validate.maxLength !== void 0) { 15612 maxLength = { 15613 constraint: field.isValid.maxLength, 15614 validate: fieldType.validate.maxLength 15615 }; 15616 } 15617 let pattern; 15618 if (field.isValid?.pattern !== void 0 && fieldType.validate.pattern !== void 0) { 15619 pattern = { 15620 constraint: field.isValid?.pattern, 15621 validate: fieldType.validate.pattern 15622 }; 15623 } 15624 const custom = field.isValid?.custom ?? fieldType.validate.custom; 15625 return { 15626 required, 15627 elements, 15628 min, 15629 max, 15630 minLength, 15631 maxLength, 15632 pattern, 15633 custom 15634 }; 15635 } 15636 15637 // packages/dataviews/build-module/field-types/utils/get-format.js 15638 function getFormat(field, fieldType) { 15639 return { 15640 ...fieldType.format, 15641 ...field.format 15642 }; 15643 } 15644 var get_format_default = getFormat; 15645 15646 // packages/dataviews/build-module/field-types/index.js 15647 function getFieldTypeByName(type) { 15648 const found = [ 15649 email_default, 15650 integer_default, 15651 number_default, 15652 text_default, 15653 datetime_default, 15654 date_default, 15655 boolean_default, 15656 media_default2, 15657 array_default, 15658 password_default, 15659 telephone_default, 15660 color_default, 15661 url_default 15662 ].find((fieldType) => fieldType?.type === type); 15663 if (!!found) { 15664 return found; 15665 } 15666 return no_type_default; 15667 } 15668 function normalizeFields(fields) { 15669 return fields.map((field) => { 15670 const fieldType = getFieldTypeByName(field.type); 15671 const getValue = field.getValue || get_value_from_id_default(field.id); 15672 const sort7 = function(a2, b2, direction) { 15673 const aValue = getValue({ item: a2 }); 15674 const bValue = getValue({ item: b2 }); 15675 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction); 15676 }; 15677 return { 15678 id: field.id, 15679 label: field.label || field.id, 15680 header: field.header || field.label || field.id, 15681 description: field.description, 15682 placeholder: field.placeholder, 15683 getValue, 15684 setValue: field.setValue || set_value_from_id_default(field.id), 15685 elements: field.elements, 15686 getElements: field.getElements, 15687 hasElements: hasElements(field), 15688 isVisible: field.isVisible, 15689 enableHiding: field.enableHiding ?? true, 15690 readOnly: field.readOnly ?? false, 15691 // The type provides defaults for the following props 15692 type: fieldType.type, 15693 render: field.render ?? fieldType.render, 15694 Edit: getControl(field, fieldType.Edit), 15695 sort: sort7, 15696 enableSorting: field.enableSorting ?? fieldType.enableSorting, 15697 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch, 15698 isValid: getIsValid(field, fieldType), 15699 filterBy: get_filter_by_default( 15700 field, 15701 fieldType.defaultOperators, 15702 fieldType.validOperators 15703 ), 15704 format: get_format_default(field, fieldType), 15705 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted 15706 }; 15707 }); 15708 } 15709 15710 // packages/dataviews/build-module/components/dataviews/index.js 15711 var import_jsx_runtime107 = __toESM(require_jsx_runtime()); 15712 var defaultGetItemId = (item) => item.id; 15713 var defaultIsItemClickable = () => true; 15714 var EMPTY_ARRAY5 = []; 15715 var dataViewsLayouts = VIEW_LAYOUTS.filter( 15716 (viewLayout) => !viewLayout.isPicker 15717 ); 15718 function DefaultUI({ 15719 header, 15720 search = true, 15721 searchLabel = void 0 15722 }) { 15723 return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(import_jsx_runtime107.Fragment, { children: [ 15724 /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)( 15725 import_components49.__experimentalHStack, 15726 { 15727 alignment: "top", 15728 justify: "space-between", 15729 className: "dataviews__view-actions", 15730 spacing: 1, 15731 children: [ 15732 /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)( 15733 import_components49.__experimentalHStack, 15734 { 15735 justify: "start", 15736 expanded: false, 15737 className: "dataviews__search", 15738 children: [ 15739 search && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(dataviews_search_default, { label: searchLabel }), 15740 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(toggle_default, {}) 15741 ] 15742 } 15743 ), 15744 /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)( 15745 import_components49.__experimentalHStack, 15746 { 15747 spacing: 1, 15748 expanded: false, 15749 style: { flexShrink: 0 }, 15750 children: [ 15751 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(dataviews_view_config_default, {}), 15752 header 15753 ] 15754 } 15755 ) 15756 ] 15757 } 15758 ), 15759 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }), 15760 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(DataViewsLayout, {}), 15761 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(DataViewsFooter, {}) 15762 ] }); 15763 } 15764 function DataViews({ 15765 view, 15766 onChangeView, 15767 fields, 15768 search = true, 15769 searchLabel = void 0, 15770 actions = EMPTY_ARRAY5, 15771 data, 15772 getItemId: getItemId2 = defaultGetItemId, 15773 getItemLevel, 15774 isLoading = false, 15775 paginationInfo, 15776 defaultLayouts: defaultLayoutsProperty, 15777 selection: selectionProperty, 15778 onChangeSelection, 15779 onClickItem, 15780 renderItemLink, 15781 isItemClickable = defaultIsItemClickable, 15782 header, 15783 children, 15784 config = { perPageSizes: [10, 20, 50, 100] }, 15785 empty 15786 }) { 15787 const { infiniteScrollHandler } = paginationInfo; 15788 const containerRef = (0, import_element52.useRef)(null); 15789 const [containerWidth, setContainerWidth] = (0, import_element52.useState)(0); 15790 const resizeObserverRef = (0, import_compose11.useResizeObserver)( 15791 (resizeObserverEntries) => { 15792 setContainerWidth( 15793 resizeObserverEntries[0].borderBoxSize[0].inlineSize 15794 ); 15795 }, 15796 { box: "border-box" } 15797 ); 15798 const [selectionState, setSelectionState] = (0, import_element52.useState)([]); 15799 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0; 15800 const selection = isUncontrolled ? selectionState : selectionProperty; 15801 const [openedFilter, setOpenedFilter] = (0, import_element52.useState)(null); 15802 function setSelectionWithChange(value) { 15803 const newValue = typeof value === "function" ? value(selection) : value; 15804 if (isUncontrolled) { 15805 setSelectionState(newValue); 15806 } 15807 if (onChangeSelection) { 15808 onChangeSelection(newValue); 15809 } 15810 } 15811 const _fields = (0, import_element52.useMemo)(() => normalizeFields(fields), [fields]); 15812 const _selection = (0, import_element52.useMemo)(() => { 15813 return selection.filter( 15814 (id) => data.some((item) => getItemId2(item) === id) 15815 ); 15816 }, [selection, data, getItemId2]); 15817 const filters = use_filters_default(_fields, view); 15818 const hasPrimaryOrLockedFilters = (0, import_element52.useMemo)( 15819 () => (filters || []).some( 15820 (filter) => filter.isPrimary || filter.isLocked 15821 ), 15822 [filters] 15823 ); 15824 const [isShowingFilter, setIsShowingFilter] = (0, import_element52.useState)( 15825 hasPrimaryOrLockedFilters 15826 ); 15827 (0, import_element52.useEffect)(() => { 15828 if (hasPrimaryOrLockedFilters && !isShowingFilter) { 15829 setIsShowingFilter(true); 15830 } 15831 }, [hasPrimaryOrLockedFilters, isShowingFilter]); 15832 (0, import_element52.useEffect)(() => { 15833 if (!view.infiniteScrollEnabled || !containerRef.current) { 15834 return; 15835 } 15836 const handleScroll = (0, import_compose11.throttle)((event) => { 15837 const target = event.target; 15838 const scrollTop = target.scrollTop; 15839 const scrollHeight = target.scrollHeight; 15840 const clientHeight = target.clientHeight; 15841 if (scrollTop + clientHeight >= scrollHeight - 100) { 15842 infiniteScrollHandler?.(); 15843 } 15844 }, 100); 15845 const container = containerRef.current; 15846 container.addEventListener("scroll", handleScroll); 15847 return () => { 15848 container.removeEventListener("scroll", handleScroll); 15849 handleScroll.cancel(); 15850 }; 15851 }, [infiniteScrollHandler, view.infiniteScrollEnabled]); 15852 const defaultLayouts = (0, import_element52.useMemo)( 15853 () => Object.fromEntries( 15854 Object.entries(defaultLayoutsProperty).filter( 15855 ([layoutType]) => { 15856 return dataViewsLayouts.some( 15857 (viewLayout) => viewLayout.type === layoutType 15858 ); 15859 } 15860 ) 15861 ), 15862 [defaultLayoutsProperty] 15863 ); 15864 if (!defaultLayouts[view.type]) { 15865 return null; 15866 } 15867 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 15868 dataviews_context_default.Provider, 15869 { 15870 value: { 15871 view, 15872 onChangeView, 15873 fields: _fields, 15874 actions, 15875 data, 15876 isLoading, 15877 paginationInfo, 15878 selection: _selection, 15879 onChangeSelection: setSelectionWithChange, 15880 openedFilter, 15881 setOpenedFilter, 15882 getItemId: getItemId2, 15883 getItemLevel, 15884 isItemClickable, 15885 onClickItem, 15886 renderItemLink, 15887 containerWidth, 15888 containerRef, 15889 resizeObserverRef, 15890 defaultLayouts, 15891 filters, 15892 isShowingFilter, 15893 setIsShowingFilter, 15894 config, 15895 empty, 15896 hasInfiniteScrollHandler: !!infiniteScrollHandler 15897 }, 15898 children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("div", { className: "dataviews-wrapper", ref: containerRef, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime107.jsx)( 15899 DefaultUI, 15900 { 15901 header, 15902 search, 15903 searchLabel 15904 } 15905 ) }) 15906 } 15907 ); 15908 } 15909 var DataViewsSubComponents = DataViews; 15910 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter; 15911 DataViewsSubComponents.Filters = filters_default; 15912 DataViewsSubComponents.FiltersToggled = filters_toggled_default; 15913 DataViewsSubComponents.FiltersToggle = toggle_default; 15914 DataViewsSubComponents.Layout = DataViewsLayout; 15915 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu; 15916 DataViewsSubComponents.Pagination = DataViewsPagination; 15917 DataViewsSubComponents.Search = dataviews_search_default; 15918 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown; 15919 DataViewsSubComponents.Footer = DataViewsFooter; 15920 var dataviews_default = DataViewsSubComponents; 15921 15922 // packages/dataviews/build-module/utils/filter-sort-and-paginate.js 15923 var import_remove_accents2 = __toESM(require_remove_accents()); 15924 var import_deprecated = __toESM(require_deprecated()); 15925 var import_date8 = __toESM(require_date()); 15926 function normalizeSearchInput2(input = "") { 15927 return (0, import_remove_accents2.default)(input.trim().toLowerCase()); 15928 } 15929 var EMPTY_ARRAY6 = []; 15930 function getRelativeDate(value, unit) { 15931 switch (unit) { 15932 case "days": 15933 return subDays(/* @__PURE__ */ new Date(), value); 15934 case "weeks": 15935 return subWeeks(/* @__PURE__ */ new Date(), value); 15936 case "months": 15937 return subMonths(/* @__PURE__ */ new Date(), value); 15938 case "years": 15939 return subYears(/* @__PURE__ */ new Date(), value); 15940 default: 15941 return /* @__PURE__ */ new Date(); 15942 } 15943 } 15944 function filterSortAndPaginate(data, view, fields) { 15945 if (!data) { 15946 return { 15947 data: EMPTY_ARRAY6, 15948 paginationInfo: { totalItems: 0, totalPages: 0 } 15949 }; 15950 } 15951 const _fields = normalizeFields(fields); 15952 let filteredData = [...data]; 15953 if (view.search) { 15954 const normalizedSearch = normalizeSearchInput2(view.search); 15955 filteredData = filteredData.filter((item) => { 15956 return _fields.filter((field) => field.enableGlobalSearch).some((field) => { 15957 const fieldValue = field.getValue({ item }); 15958 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue]; 15959 return values.some( 15960 (value) => normalizeSearchInput2(String(value)).includes( 15961 normalizedSearch 15962 ) 15963 ); 15964 }); 15965 }); 15966 } 15967 if (view.filters && view.filters?.length > 0) { 15968 view.filters.forEach((filter) => { 15969 const field = _fields.find( 15970 (_field) => _field.id === filter.field 15971 ); 15972 if (field) { 15973 if (filter.operator === OPERATOR_IS_ANY && filter?.value?.length > 0) { 15974 filteredData = filteredData.filter((item) => { 15975 const fieldValue = field.getValue({ item }); 15976 if (Array.isArray(fieldValue)) { 15977 return filter.value.some( 15978 (filterValue) => fieldValue.includes(filterValue) 15979 ); 15980 } else if (typeof fieldValue === "string") { 15981 return filter.value.includes(fieldValue); 15982 } 15983 return false; 15984 }); 15985 } else if (filter.operator === OPERATOR_IS_NONE && filter?.value?.length > 0) { 15986 filteredData = filteredData.filter((item) => { 15987 const fieldValue = field.getValue({ item }); 15988 if (Array.isArray(fieldValue)) { 15989 return !filter.value.some( 15990 (filterValue) => fieldValue.includes(filterValue) 15991 ); 15992 } else if (typeof fieldValue === "string") { 15993 return !filter.value.includes(fieldValue); 15994 } 15995 return false; 15996 }); 15997 } else if (filter.operator === OPERATOR_IS_ALL && filter?.value?.length > 0) { 15998 filteredData = filteredData.filter((item) => { 15999 return filter.value.every((value) => { 16000 return field.getValue({ item })?.includes(value); 16001 }); 16002 }); 16003 } else if (filter.operator === OPERATOR_IS_NOT_ALL && filter?.value?.length > 0) { 16004 (0, import_deprecated.default)("The 'isNotAll' filter operator", { 16005 since: "7.0", 16006 alternative: "'isNone'" 16007 }); 16008 filteredData = filteredData.filter((item) => { 16009 return filter.value.every((value) => { 16010 return !field.getValue({ item })?.includes(value); 16011 }); 16012 }); 16013 } else if (filter.operator === OPERATOR_IS) { 16014 filteredData = filteredData.filter((item) => { 16015 return filter.value === field.getValue({ item }) || filter.value === void 0; 16016 }); 16017 } else if (filter.operator === OPERATOR_IS_NOT) { 16018 filteredData = filteredData.filter((item) => { 16019 return filter.value !== field.getValue({ item }); 16020 }); 16021 } else if (filter.operator === OPERATOR_ON && filter.value !== void 0) { 16022 const filterDate = (0, import_date8.getDate)(filter.value); 16023 filteredData = filteredData.filter((item) => { 16024 const fieldDate = (0, import_date8.getDate)(field.getValue({ item })); 16025 return filterDate.getTime() === fieldDate.getTime(); 16026 }); 16027 } else if (filter.operator === OPERATOR_NOT_ON && filter.value !== void 0) { 16028 const filterDate = (0, import_date8.getDate)(filter.value); 16029 filteredData = filteredData.filter((item) => { 16030 const fieldDate = (0, import_date8.getDate)(field.getValue({ item })); 16031 return filterDate.getTime() !== fieldDate.getTime(); 16032 }); 16033 } else if (filter.operator === OPERATOR_LESS_THAN && filter.value !== void 0) { 16034 filteredData = filteredData.filter((item) => { 16035 const fieldValue = field.getValue({ item }); 16036 return fieldValue < filter.value; 16037 }); 16038 } else if (filter.operator === OPERATOR_GREATER_THAN && filter.value !== void 0) { 16039 filteredData = filteredData.filter((item) => { 16040 const fieldValue = field.getValue({ item }); 16041 return fieldValue > filter.value; 16042 }); 16043 } else if (filter.operator === OPERATOR_LESS_THAN_OR_EQUAL && filter.value !== void 0) { 16044 filteredData = filteredData.filter((item) => { 16045 const fieldValue = field.getValue({ item }); 16046 return fieldValue <= filter.value; 16047 }); 16048 } else if (filter.operator === OPERATOR_GREATER_THAN_OR_EQUAL && filter.value !== void 0) { 16049 filteredData = filteredData.filter((item) => { 16050 const fieldValue = field.getValue({ item }); 16051 return fieldValue >= filter.value; 16052 }); 16053 } else if (filter.operator === OPERATOR_CONTAINS && filter?.value !== void 0) { 16054 filteredData = filteredData.filter((item) => { 16055 const fieldValue = field.getValue({ item }); 16056 return typeof fieldValue === "string" && filter.value && fieldValue.toLowerCase().includes( 16057 String(filter.value).toLowerCase() 16058 ); 16059 }); 16060 } else if (filter.operator === OPERATOR_NOT_CONTAINS && filter?.value !== void 0) { 16061 filteredData = filteredData.filter((item) => { 16062 const fieldValue = field.getValue({ item }); 16063 return typeof fieldValue === "string" && filter.value && !fieldValue.toLowerCase().includes( 16064 String(filter.value).toLowerCase() 16065 ); 16066 }); 16067 } else if (filter.operator === OPERATOR_STARTS_WITH && filter?.value !== void 0) { 16068 filteredData = filteredData.filter((item) => { 16069 const fieldValue = field.getValue({ item }); 16070 return typeof fieldValue === "string" && filter.value && fieldValue.toLowerCase().startsWith( 16071 String(filter.value).toLowerCase() 16072 ); 16073 }); 16074 } else if (filter.operator === OPERATOR_BEFORE && filter.value !== void 0) { 16075 const filterValue = (0, import_date8.getDate)(filter.value); 16076 filteredData = filteredData.filter((item) => { 16077 const fieldValue = (0, import_date8.getDate)( 16078 field.getValue({ item }) 16079 ); 16080 return fieldValue < filterValue; 16081 }); 16082 } else if (filter.operator === OPERATOR_AFTER && filter.value !== void 0) { 16083 const filterValue = (0, import_date8.getDate)(filter.value); 16084 filteredData = filteredData.filter((item) => { 16085 const fieldValue = (0, import_date8.getDate)( 16086 field.getValue({ item }) 16087 ); 16088 return fieldValue > filterValue; 16089 }); 16090 } else if (filter.operator === OPERATOR_BEFORE_INC && filter.value !== void 0) { 16091 const filterValue = (0, import_date8.getDate)(filter.value); 16092 filteredData = filteredData.filter((item) => { 16093 const fieldValue = (0, import_date8.getDate)( 16094 field.getValue({ item }) 16095 ); 16096 return fieldValue <= filterValue; 16097 }); 16098 } else if (filter.operator === OPERATOR_AFTER_INC && filter.value !== void 0) { 16099 const filterValue = (0, import_date8.getDate)(filter.value); 16100 filteredData = filteredData.filter((item) => { 16101 const fieldValue = (0, import_date8.getDate)( 16102 field.getValue({ item }) 16103 ); 16104 return fieldValue >= filterValue; 16105 }); 16106 } else if (filter.operator === OPERATOR_BETWEEN && Array.isArray(filter.value) && filter.value.length === 2 && filter.value[0] !== void 0 && filter.value[1] !== void 0) { 16107 filteredData = filteredData.filter((item) => { 16108 const fieldValue = field.getValue({ item }); 16109 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") { 16110 return fieldValue >= filter.value[0] && fieldValue <= filter.value[1]; 16111 } 16112 return false; 16113 }); 16114 } else if (filter.operator === OPERATOR_IN_THE_PAST && filter.value?.value !== void 0 && filter.value?.unit !== void 0) { 16115 const targetDate = getRelativeDate( 16116 filter.value.value, 16117 filter.value.unit 16118 ); 16119 filteredData = filteredData.filter((item) => { 16120 const fieldValue = (0, import_date8.getDate)( 16121 field.getValue({ item }) 16122 ); 16123 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date(); 16124 }); 16125 } else if (filter.operator === OPERATOR_OVER && filter.value?.value !== void 0 && filter.value?.unit !== void 0) { 16126 const targetDate = getRelativeDate( 16127 filter.value.value, 16128 filter.value.unit 16129 ); 16130 filteredData = filteredData.filter((item) => { 16131 const fieldValue = (0, import_date8.getDate)( 16132 field.getValue({ item }) 16133 ); 16134 return fieldValue < targetDate; 16135 }); 16136 } 16137 } 16138 }); 16139 } 16140 const sortByField = view.sort?.field ? _fields.find((field) => { 16141 return field.enableSorting !== false && field.id === view.sort?.field; 16142 }) : null; 16143 const groupByField = view.groupBy?.field ? _fields.find((field) => { 16144 return field.enableSorting !== false && field.id === view.groupBy?.field; 16145 }) : null; 16146 if (sortByField || groupByField) { 16147 filteredData.sort((a2, b2) => { 16148 if (groupByField) { 16149 const groupCompare = groupByField.sort( 16150 a2, 16151 b2, 16152 view.groupBy?.direction ?? "asc" 16153 ); 16154 if (groupCompare !== 0) { 16155 return groupCompare; 16156 } 16157 } 16158 if (sortByField) { 16159 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc"); 16160 } 16161 return 0; 16162 }); 16163 } 16164 let totalItems = filteredData.length; 16165 let totalPages = 1; 16166 if (view.page !== void 0 && view.perPage !== void 0) { 16167 const start = (view.page - 1) * view.perPage; 16168 totalItems = filteredData?.length || 0; 16169 totalPages = Math.ceil(totalItems / view.perPage); 16170 filteredData = filteredData?.slice(start, start + view.perPage); 16171 } 16172 return { 16173 data: filteredData, 16174 paginationInfo: { 16175 totalItems, 16176 totalPages 16177 } 16178 }; 16179 } 16180 16181 // packages/admin-ui/build-module/navigable-region/index.js 16182 var import_element53 = __toESM(require_element()); 16183 var import_jsx_runtime108 = __toESM(require_jsx_runtime()); 16184 var NavigableRegion = (0, import_element53.forwardRef)( 16185 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => { 16186 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)( 16187 Tag, 16188 { 16189 ref, 16190 className: clsx_default("admin-ui-navigable-region", className), 16191 "aria-label": ariaLabel, 16192 role: "region", 16193 tabIndex: "-1", 16194 ...props, 16195 children 16196 } 16197 ); 16198 } 16199 ); 16200 NavigableRegion.displayName = "NavigableRegion"; 16201 var navigable_region_default = NavigableRegion; 16202 16203 // packages/admin-ui/build-module/page/header.js 16204 var import_components51 = __toESM(require_components()); 16205 16206 // packages/admin-ui/build-module/page/sidebar-toggle-slot.js 16207 var import_components50 = __toESM(require_components()); 16208 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components50.createSlotFill)("SidebarToggle"); 16209 16210 // packages/admin-ui/build-module/page/header.js 16211 var import_jsx_runtime109 = __toESM(require_jsx_runtime()); 16212 function Header({ 16213 breadcrumbs, 16214 badges, 16215 title, 16216 subTitle, 16217 actions, 16218 showSidebarToggle = true 16219 }) { 16220 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_components51.__experimentalVStack, { className: "admin-ui-page__header", as: "header", children: [ 16221 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_components51.__experimentalHStack, { justify: "space-between", spacing: 2, children: [ 16222 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_components51.__experimentalHStack, { spacing: 2, justify: "left", children: [ 16223 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 16224 SidebarToggleSlot, 16225 { 16226 bubblesVirtually: true, 16227 className: "admin-ui-page__sidebar-toggle-slot" 16228 } 16229 ), 16230 title && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components51.__experimentalHeading, { as: "h2", level: 3, weight: 500, truncate: true, children: title }), 16231 breadcrumbs, 16232 badges 16233 ] }), 16234 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 16235 import_components51.__experimentalHStack, 16236 { 16237 style: { width: "auto", flexShrink: 0 }, 16238 spacing: 2, 16239 className: "admin-ui-page__header-actions", 16240 children: actions 16241 } 16242 ) 16243 ] }), 16244 subTitle && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { className: "admin-ui-page__header-subtitle", children: subTitle }) 16245 ] }); 16246 } 16247 16248 // packages/admin-ui/build-module/page/index.js 16249 var import_jsx_runtime110 = __toESM(require_jsx_runtime()); 16250 function Page({ 16251 breadcrumbs, 16252 badges, 16253 title, 16254 subTitle, 16255 children, 16256 className, 16257 actions, 16258 hasPadding = false, 16259 showSidebarToggle = true 16260 }) { 16261 const classes = clsx_default("admin-ui-page", className); 16262 return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(navigable_region_default, { className: classes, ariaLabel: title, children: [ 16263 (title || breadcrumbs || badges) && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)( 16264 Header, 16265 { 16266 breadcrumbs, 16267 badges, 16268 title, 16269 subTitle, 16270 actions, 16271 showSidebarToggle 16272 } 16273 ), 16274 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "admin-ui-page__content has-padding", children }) : children 16275 ] }); 16276 } 16277 Page.SidebarToggleFill = SidebarToggleFill; 16278 var page_default2 = Page; 16279 16280 // routes/template-list/stage.tsx 16281 var import_core_data9 = __toESM(require_core_data()); 16282 var import_components57 = __toESM(require_components()); 16283 var import_data13 = __toESM(require_data()); 16284 var import_element61 = __toESM(require_element()); 16285 var import_editor = __toESM(require_editor()); 16286 var import_i18n52 = __toESM(require_i18n()); 16287 16288 // routes/lock-unlock.ts 16289 var import_private_apis2 = __toESM(require_private_apis()); 16290 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 16291 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 16292 "@wordpress/routes" 16293 ); 16294 16295 // routes/template-list/view-utils.ts 16296 var DEFAULT_VIEW = { 16297 type: "grid", 16298 perPage: 20, 16299 sort: { 16300 field: "title", 16301 direction: "asc" 16302 }, 16303 fields: ["author", "active", "slug"], 16304 titleField: "title", 16305 descriptionField: "description", 16306 mediaField: "preview", 16307 filters: [] 16308 }; 16309 var DEFAULT_LAYOUTS = { 16310 table: { 16311 showMedia: false 16312 }, 16313 grid: { 16314 showMedia: true 16315 }, 16316 list: { 16317 showMedia: false 16318 } 16319 }; 16320 function getDefaultView(activeView) { 16321 if (activeView === "user") { 16322 return { 16323 ...DEFAULT_VIEW, 16324 sort: { 16325 field: "date", 16326 direction: "desc" 16327 }, 16328 fields: ["author", "active", "slug", "theme"] 16329 }; 16330 } 16331 if (activeView === "active" || !activeView) { 16332 return { 16333 ...DEFAULT_VIEW 16334 }; 16335 } 16336 return { 16337 ...DEFAULT_VIEW, 16338 filters: [ 16339 { 16340 field: "author", 16341 operator: "isAny", 16342 value: [activeView] 16343 } 16344 ] 16345 }; 16346 } 16347 16348 // routes/template-list/fields/preview.tsx 16349 var import_i18n42 = __toESM(require_i18n()); 16350 import { Preview } from "@wordpress/lazy-editor"; 16351 function PreviewField({ item }) { 16352 const description = item.description; 16353 return /* @__PURE__ */ React.createElement( 16354 Preview, 16355 { 16356 content: item?.content?.raw, 16357 blocks: item?.blocks, 16358 description 16359 } 16360 ); 16361 } 16362 var previewField = { 16363 label: (0, import_i18n42.__)("Preview"), 16364 id: "preview", 16365 render: PreviewField, 16366 enableSorting: false 16367 }; 16368 16369 // routes/template-list/fields/author.tsx 16370 var import_components52 = __toESM(require_components()); 16371 var import_i18n43 = __toESM(require_i18n()); 16372 var import_element54 = __toESM(require_element()); 16373 var import_core_data = __toESM(require_core_data()); 16374 var import_data8 = __toESM(require_data()); 16375 function useAddedBy(type, id) { 16376 const { author, authorText } = (0, import_data8.useSelect)( 16377 (select2) => { 16378 const { getUser, getEditedEntityRecord } = select2(import_core_data.store); 16379 const _record = getEditedEntityRecord("postType", type, id); 16380 return { 16381 author: _record?.author ? getUser(_record.author) : null, 16382 authorText: _record?.author_text 16383 }; 16384 }, 16385 [type, id] 16386 ); 16387 return (0, import_element54.useMemo)(() => { 16388 if (authorText) { 16389 return { 16390 text: authorText, 16391 icon: "admin-plugins" 16392 }; 16393 } 16394 if (author) { 16395 return { 16396 text: author.name, 16397 icon: "admin-users", 16398 imageUrl: author.avatar_urls?.[48] 16399 }; 16400 } 16401 return { 16402 text: (0, import_i18n43.__)("Unknown"), 16403 icon: "admin-users" 16404 }; 16405 }, [author, authorText]); 16406 } 16407 function AuthorField({ item }) { 16408 const [isImageLoaded, setIsImageLoaded] = (0, import_element54.useState)(false); 16409 const { text, icon, imageUrl } = useAddedBy(item.type, item.id); 16410 return /* @__PURE__ */ React.createElement(import_components52.__experimentalHStack, { alignment: "left", spacing: 0 }, imageUrl && /* @__PURE__ */ React.createElement( 16411 "div", 16412 { 16413 className: clsx_default( 16414 "routes-template-list-author-field__avatar", 16415 { 16416 "is-loaded": isImageLoaded 16417 } 16418 ) 16419 }, 16420 /* @__PURE__ */ React.createElement( 16421 "img", 16422 { 16423 onLoad: () => setIsImageLoaded(true), 16424 alt: "", 16425 src: imageUrl 16426 } 16427 ) 16428 ), !imageUrl && /* @__PURE__ */ React.createElement("div", { className: "routes-template-list-author-field__icon" }, /* @__PURE__ */ React.createElement(import_components52.Icon, { icon })), /* @__PURE__ */ React.createElement("span", { className: "routes-template-list-author-field__name" }, text)); 16429 } 16430 var authorField = { 16431 label: (0, import_i18n43.__)("Author"), 16432 id: "author", 16433 getValue: ({ item }) => item.author_text ?? item.author, 16434 render: AuthorField 16435 }; 16436 16437 // routes/template-list/fields/description.tsx 16438 var import_i18n44 = __toESM(require_i18n()); 16439 var import_html_entities = __toESM(require_html_entities()); 16440 var import_core_data2 = __toESM(require_core_data()); 16441 var { useEntityRecordsWithPermissions } = unlock2(import_core_data2.privateApis); 16442 function useAllDefaultTemplateTypes() { 16443 const { records: staticRecords } = useEntityRecordsWithPermissions( 16444 "root", 16445 "registeredTemplate" 16446 ); 16447 return staticRecords?.filter((record) => !record.is_custom).map((record) => { 16448 return { 16449 slug: record.slug, 16450 title: record.title.rendered, 16451 description: record.description 16452 }; 16453 }); 16454 } 16455 var descriptionField = { 16456 label: (0, import_i18n44.__)("Description"), 16457 id: "description", 16458 render: function RenderDescription({ item }) { 16459 const defaultTemplateTypes = useAllDefaultTemplateTypes(); 16460 const defaultTemplateType = defaultTemplateTypes?.find( 16461 (type) => type.slug === item.slug 16462 ); 16463 return item.description ? (0, import_html_entities.decodeEntities)(item.description) : defaultTemplateType?.description; 16464 }, 16465 enableSorting: false, 16466 enableGlobalSearch: true 16467 }; 16468 16469 // routes/template-list/fields/active.tsx 16470 var import_i18n45 = __toESM(require_i18n()); 16471 var import_components53 = __toESM(require_components()); 16472 var { Badge: Badge3 } = unlock2(import_components53.privateApis); 16473 var activeField = { 16474 label: (0, import_i18n45.__)("Status"), 16475 id: "active", 16476 type: "boolean", 16477 getValue: ({ item }) => item._isActive, 16478 render: function Render({ item }) { 16479 const activeLabel = item._isCustom ? (0, import_i18n45._x)("Active when used", "template") : (0, import_i18n45._x)("Active", "template"); 16480 const activeIntent = item._isCustom ? "info" : "success"; 16481 const isActive = item._isActive; 16482 return /* @__PURE__ */ React.createElement(Badge3, { intent: isActive ? activeIntent : "default" }, isActive ? activeLabel : (0, import_i18n45._x)("Inactive", "template")); 16483 } 16484 }; 16485 16486 // routes/template-list/fields/slug.tsx 16487 var import_i18n46 = __toESM(require_i18n()); 16488 var import_core_data3 = __toESM(require_core_data()); 16489 var { useEntityRecordsWithPermissions: useEntityRecordsWithPermissions2 } = unlock2(import_core_data3.privateApis); 16490 function useAllDefaultTemplateTypes2() { 16491 const { records: staticRecords } = useEntityRecordsWithPermissions2( 16492 "root", 16493 "registeredTemplate" 16494 ); 16495 return staticRecords?.filter((record) => !record.is_custom).map((record) => { 16496 return { 16497 slug: record.slug, 16498 title: record.title.rendered, 16499 description: record.description 16500 }; 16501 }); 16502 } 16503 var slugField = { 16504 label: (0, import_i18n46.__)("Template Type"), 16505 id: "slug", 16506 getValue: ({ item }) => item.slug, 16507 render: function Render2({ item }) { 16508 const defaultTemplateTypes = useAllDefaultTemplateTypes2(); 16509 const defaultTemplateType = defaultTemplateTypes?.find( 16510 (type) => type.slug === item.slug 16511 ); 16512 return defaultTemplateType?.title || (0, import_i18n46._x)("Custom", "template type"); 16513 } 16514 }; 16515 16516 // routes/template-list/use-templates.ts 16517 var import_element55 = __toESM(require_element()); 16518 var import_data9 = __toESM(require_data()); 16519 var import_core_data4 = __toESM(require_core_data()); 16520 var { useEntityRecordsWithPermissions: useEntityRecordsWithPermissions3 } = unlock2(import_core_data4.privateApis); 16521 function useTemplates(activeView = "active") { 16522 const { activeTemplatesOption, activeTheme, defaultTemplateTypes } = (0, import_data9.useSelect)((select2) => { 16523 const { getEntityRecord, getCurrentTheme } = select2(import_core_data4.store); 16524 return { 16525 activeTemplatesOption: getEntityRecord("root", "site")?.active_templates, 16526 activeTheme: getCurrentTheme(), 16527 defaultTemplateTypes: select2(import_core_data4.store).getCurrentTheme()?.default_template_types 16528 }; 16529 }, []); 16530 const { records: userRecords, isResolving: isLoadingUserRecords } = useEntityRecordsWithPermissions3("postType", "wp_template", { 16531 per_page: -1, 16532 combinedTemplates: false 16533 }); 16534 const { records: staticRecords, isResolving: isLoadingStaticData } = useEntityRecordsWithPermissions3("root", "registeredTemplate", { 16535 per_page: -1 16536 }); 16537 const activeTemplates = (0, import_element55.useMemo)(() => { 16538 const _active = [...staticRecords]; 16539 if (activeTemplatesOption) { 16540 for (const activeSlug in activeTemplatesOption) { 16541 const activeId = activeTemplatesOption[activeSlug]; 16542 const template = userRecords.find( 16543 (userRecord) => userRecord.id === activeId && userRecord.theme === activeTheme.stylesheet 16544 ); 16545 if (template) { 16546 const index = _active.findIndex( 16547 ({ slug }) => slug === template.slug 16548 ); 16549 if (index !== -1) { 16550 _active[index] = template; 16551 } else { 16552 _active.push(template); 16553 } 16554 } 16555 } 16556 } 16557 return _active; 16558 }, [userRecords, staticRecords, activeTemplatesOption, activeTheme]); 16559 const records = (0, import_element55.useMemo)(() => { 16560 function isCustom(record) { 16561 return record.is_custom ?? // For user templates it's custom if the is_wp_suggestion meta 16562 // field is not set and the slug is not found in the default 16563 // template types. 16564 (!record.meta?.is_wp_suggestion && !defaultTemplateTypes.some( 16565 (type) => type.slug === record.slug 16566 )); 16567 } 16568 let _records; 16569 if (activeView === "active") { 16570 _records = activeTemplates.filter( 16571 (record) => !isCustom(record) 16572 ); 16573 } else if (activeView === "user") { 16574 _records = userRecords; 16575 } else { 16576 _records = staticRecords; 16577 } 16578 return _records.map((record) => ({ 16579 ...record, 16580 _isActive: activeTemplates.some( 16581 (template) => template.id === record.id 16582 ), 16583 _isCustom: isCustom(record) 16584 })); 16585 }, [ 16586 activeTemplates, 16587 defaultTemplateTypes, 16588 userRecords, 16589 staticRecords, 16590 activeView 16591 ]); 16592 return { 16593 records, 16594 isLoading: isLoadingUserRecords || isLoadingStaticData, 16595 staticRecords, 16596 userRecords, 16597 activeTemplates 16598 }; 16599 } 16600 16601 // routes/template-list/actions/set-active-template.tsx 16602 var import_i18n47 = __toESM(require_i18n()); 16603 var import_element56 = __toESM(require_element()); 16604 var import_data10 = __toESM(require_data()); 16605 var import_core_data5 = __toESM(require_core_data()); 16606 function useSetActiveTemplateAction() { 16607 const activeTheme = (0, import_data10.useSelect)( 16608 (select2) => select2(import_core_data5.store).getCurrentTheme() 16609 ); 16610 const { getEntityRecord } = (0, import_data10.useSelect)(import_core_data5.store); 16611 const { editEntityRecord, saveEditedEntityRecord } = (0, import_data10.useDispatch)(import_core_data5.store); 16612 return (0, import_element56.useMemo)( 16613 () => ({ 16614 id: "set-active-template", 16615 label(items) { 16616 return items.some((item) => item._isActive) ? (0, import_i18n47.__)("Deactivate") : (0, import_i18n47.__)("Activate"); 16617 }, 16618 isPrimary: true, 16619 icon: pencil_default, 16620 isEligible(item) { 16621 if (!activeTheme) { 16622 return false; 16623 } 16624 if (item.theme !== activeTheme.stylesheet) { 16625 return false; 16626 } 16627 if (typeof item.id !== "number") { 16628 return item._isActive === false; 16629 } 16630 return true; 16631 }, 16632 async callback(items) { 16633 const deactivate = items.some((item) => item._isActive); 16634 const activeTemplates = { 16635 ...(await getEntityRecord("root", "site"))?.active_templates ?? {} 16636 }; 16637 for (const item of items) { 16638 if (deactivate) { 16639 delete activeTemplates[item.slug]; 16640 } else { 16641 activeTemplates[item.slug] = item.id; 16642 } 16643 } 16644 await editEntityRecord("root", "site", void 0, { 16645 active_templates: activeTemplates 16646 }); 16647 await saveEditedEntityRecord("root", "site"); 16648 } 16649 }), 16650 [ 16651 editEntityRecord, 16652 saveEditedEntityRecord, 16653 getEntityRecord, 16654 activeTheme 16655 ] 16656 ); 16657 } 16658 16659 // routes/template-list/add-new-template/index.tsx 16660 var import_components56 = __toESM(require_components()); 16661 var import_html_entities4 = __toESM(require_html_entities()); 16662 var import_element60 = __toESM(require_element()); 16663 var import_data12 = __toESM(require_data()); 16664 var import_core_data8 = __toESM(require_core_data()); 16665 var import_compose13 = __toESM(require_compose()); 16666 var import_i18n51 = __toESM(require_i18n()); 16667 var import_notices = __toESM(require_notices()); 16668 var import_dom11 = __toESM(require_dom()); 16669 import { useNavigate, useInvalidate } from "@wordpress/route"; 16670 16671 // routes/template-list/add-new-template/add-custom-template-modal-content.tsx 16672 var import_element58 = __toESM(require_element()); 16673 var import_i18n49 = __toESM(require_i18n()); 16674 var import_components54 = __toESM(require_components()); 16675 var import_core_data7 = __toESM(require_core_data()); 16676 var import_html_entities3 = __toESM(require_html_entities()); 16677 var import_compose12 = __toESM(require_compose()); 16678 var import_dom10 = __toESM(require_dom()); 16679 var import_url4 = __toESM(require_url()); 16680 16681 // routes/template-list/add-new-template/utils.ts 16682 var import_data11 = __toESM(require_data()); 16683 var import_core_data6 = __toESM(require_core_data()); 16684 var import_html_entities2 = __toESM(require_html_entities()); 16685 var import_element57 = __toESM(require_element()); 16686 var import_i18n48 = __toESM(require_i18n()); 16687 var import_url3 = __toESM(require_url()); 16688 var TEMPLATE_POST_TYPE = "wp_template"; 16689 var EMPTY_OBJECT = {}; 16690 var getValueFromObjectPath = (object, path) => { 16691 let value = object; 16692 path.split(".").forEach((fieldName) => { 16693 value = value?.[fieldName]; 16694 }); 16695 return value; 16696 }; 16697 function prefixSlug(prefix, slug) { 16698 return `$prefix}-${(0, import_url3.safeDecodeURI)(slug)}`; 16699 } 16700 function mapToIHasNameAndId(entities, path) { 16701 return (entities || []).map((entity) => ({ 16702 ...entity, 16703 name: (0, import_html_entities2.decodeEntities)(getValueFromObjectPath(entity, path)) 16704 })); 16705 } 16706 var useExistingTemplates = () => { 16707 return (0, import_data11.useSelect)( 16708 (select2) => select2(import_core_data6.store).getEntityRecords( 16709 "postType", 16710 TEMPLATE_POST_TYPE, 16711 { 16712 per_page: -1 16713 } 16714 ), 16715 [] 16716 ); 16717 }; 16718 var useDefaultTemplateTypes = () => { 16719 return (0, import_data11.useSelect)( 16720 (select2) => select2(import_core_data6.store).getCurrentTheme()?.default_template_types || [], 16721 [] 16722 ); 16723 }; 16724 var usePublicPostTypes = () => { 16725 const postTypes = (0, import_data11.useSelect)( 16726 (select2) => select2(import_core_data6.store).getPostTypes({ per_page: -1 }), 16727 [] 16728 ); 16729 return (0, import_element57.useMemo)(() => { 16730 const excludedPostTypes = ["attachment"]; 16731 return postTypes?.filter( 16732 ({ viewable, slug }) => viewable && !excludedPostTypes.includes(slug) 16733 ).sort((a2, b2) => { 16734 if (a2.slug === "post" || b2.slug === "post") { 16735 return 0; 16736 } 16737 return a2.name.localeCompare(b2.name); 16738 }); 16739 }, [postTypes]); 16740 }; 16741 var usePublicTaxonomies = () => { 16742 const taxonomies = (0, import_data11.useSelect)( 16743 (select2) => select2(import_core_data6.store).getTaxonomies({ per_page: -1 }), 16744 [] 16745 ); 16746 return (0, import_element57.useMemo)(() => { 16747 return taxonomies?.filter( 16748 ({ visibility }) => visibility?.publicly_queryable 16749 ); 16750 }, [taxonomies]); 16751 }; 16752 function usePostTypeArchiveMenuItems() { 16753 const publicPostTypes = usePublicPostTypes(); 16754 const postTypesWithArchives = (0, import_element57.useMemo)( 16755 () => publicPostTypes?.filter( 16756 (postType) => postType.has_archive 16757 ), 16758 [publicPostTypes] 16759 ); 16760 const existingTemplates = useExistingTemplates(); 16761 const postTypeLabels = (0, import_element57.useMemo)( 16762 () => publicPostTypes?.reduce((accumulator, { labels }) => { 16763 const singularName = labels.singular_name.toLowerCase(); 16764 accumulator[singularName] = (accumulator[singularName] || 0) + 1; 16765 return accumulator; 16766 }, {}), 16767 [publicPostTypes] 16768 ); 16769 const needsUniqueIdentifier = (0, import_element57.useCallback)( 16770 ({ labels, slug }) => { 16771 const singularName = labels.singular_name.toLowerCase(); 16772 return postTypeLabels[singularName] > 1 && singularName !== slug; 16773 }, 16774 [postTypeLabels] 16775 ); 16776 return (0, import_element57.useMemo)( 16777 () => postTypesWithArchives?.filter( 16778 (postType) => !(existingTemplates || []).some( 16779 (existingTemplate) => existingTemplate.slug === "archive-" + postType.slug 16780 ) 16781 ).map((postType) => { 16782 let title; 16783 if (needsUniqueIdentifier(postType)) { 16784 title = (0, import_i18n48.sprintf)( 16785 // translators: %1s: Name of the post type e.g: "Post"; %2s: Slug of the post type e.g: "book". 16786 (0, import_i18n48.__)("Archive: %1$s (%2$s)"), 16787 postType.labels.singular_name, 16788 postType.slug 16789 ); 16790 } else { 16791 title = (0, import_i18n48.sprintf)( 16792 // translators: %s: Name of the post type e.g: "Post". 16793 (0, import_i18n48.__)("Archive: %s"), 16794 postType.labels.singular_name 16795 ); 16796 } 16797 return { 16798 slug: "archive-" + postType.slug, 16799 description: (0, import_i18n48.sprintf)( 16800 // translators: %s: Name of the post type e.g: "Post". 16801 (0, import_i18n48.__)( 16802 "Displays an archive with the latest posts of type: %s." 16803 ), 16804 postType.labels.singular_name 16805 ), 16806 title, 16807 // `icon` is the `menu_icon` property of a post type. We 16808 // only handle `dashicons` for now, even if the `menu_icon` 16809 // also supports urls and svg as values. 16810 icon: typeof postType.icon === "string" && postType.icon.startsWith("dashicons-") ? postType.icon.slice(10) : archive_default, 16811 templatePrefix: "archive" 16812 }; 16813 }) || [], 16814 [postTypesWithArchives, existingTemplates, needsUniqueIdentifier] 16815 ); 16816 } 16817 var usePostTypeMenuItems = (onClickMenuItem) => { 16818 const publicPostTypes = usePublicPostTypes(); 16819 const defaultTemplateTypes = useDefaultTemplateTypes(); 16820 const templateLabels = (0, import_element57.useMemo)( 16821 () => publicPostTypes?.reduce((accumulator, { labels }) => { 16822 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 16823 accumulator[templateName] = (accumulator[templateName] || 0) + 1; 16824 return accumulator; 16825 }, {}), 16826 [publicPostTypes] 16827 ); 16828 const needsUniqueIdentifier = (0, import_element57.useCallback)( 16829 ({ labels, slug }) => { 16830 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 16831 return templateLabels[templateName] > 1 && templateName !== slug; 16832 }, 16833 [templateLabels] 16834 ); 16835 const templatePrefixes = (0, import_element57.useMemo)( 16836 () => publicPostTypes?.reduce((accumulator, { slug }) => { 16837 let suffix = slug; 16838 if (slug !== "page") { 16839 suffix = `single-$suffix}`; 16840 } 16841 accumulator[slug] = suffix; 16842 return accumulator; 16843 }, {}), 16844 [publicPostTypes] 16845 ); 16846 const postTypesInfo = useEntitiesInfo("postType", templatePrefixes); 16847 const menuItems = (publicPostTypes || []).reduce( 16848 (accumulator, postType) => { 16849 const { slug, labels, icon } = postType; 16850 const generalTemplateSlug = templatePrefixes[slug]; 16851 const defaultTemplateType = defaultTemplateTypes?.find( 16852 ({ slug: _slug }) => _slug === generalTemplateSlug 16853 ); 16854 const _needsUniqueIdentifier = needsUniqueIdentifier(postType); 16855 let menuItemTitle = labels.template_name || (0, import_i18n48.sprintf)( 16856 // translators: %s: Name of the post type e.g: "Post". 16857 (0, import_i18n48.__)("Single item: %s"), 16858 labels.singular_name 16859 ); 16860 if (_needsUniqueIdentifier) { 16861 menuItemTitle = labels.template_name ? (0, import_i18n48.sprintf)( 16862 // translators: 1: Name of the template e.g: "Single Item: Post". 2: Slug of the post type e.g: "book". 16863 (0, import_i18n48._x)("%1$s (%2$s)", "post type menu label"), 16864 labels.template_name, 16865 slug 16866 ) : (0, import_i18n48.sprintf)( 16867 // translators: 1: Name of the post type e.g: "Post". 2: Slug of the post type e.g: "book". 16868 (0, import_i18n48._x)( 16869 "Single item: %1$s (%2$s)", 16870 "post type menu label" 16871 ), 16872 labels.singular_name, 16873 slug 16874 ); 16875 } 16876 const menuItem = defaultTemplateType ? { 16877 ...defaultTemplateType, 16878 templatePrefix: templatePrefixes[slug] 16879 } : { 16880 slug: generalTemplateSlug, 16881 title: menuItemTitle, 16882 description: (0, import_i18n48.sprintf)( 16883 // translators: %s: Name of the post type e.g: "Post". 16884 (0, import_i18n48.__)("Displays a single item: %s."), 16885 labels.singular_name 16886 ), 16887 // `icon` is the `menu_icon` property of a post type. We 16888 // only handle `dashicons` for now, even if the `menu_icon` 16889 // also supports urls and svg as values. 16890 icon: typeof icon === "string" && icon.startsWith("dashicons-") ? icon.slice(10) : post_default, 16891 templatePrefix: templatePrefixes[slug] 16892 }; 16893 const hasEntities = postTypesInfo?.[slug]?.hasEntities; 16894 if (hasEntities) { 16895 menuItem.onClick = (template) => { 16896 onClickMenuItem({ 16897 type: "postType", 16898 slug, 16899 config: { 16900 recordNamePath: "title.rendered", 16901 queryArgs: ({ search }) => { 16902 return { 16903 _fields: "id,title,slug,link", 16904 orderBy: search ? "relevance" : "modified", 16905 exclude: postTypesInfo[slug].existingEntitiesIds 16906 }; 16907 }, 16908 getSpecificTemplate: (suggestion) => { 16909 const templateSlug = prefixSlug( 16910 templatePrefixes[slug], 16911 suggestion.slug 16912 ); 16913 return { 16914 title: templateSlug, 16915 slug: templateSlug, 16916 templatePrefix: templatePrefixes[slug] 16917 }; 16918 } 16919 }, 16920 labels, 16921 template 16922 }); 16923 }; 16924 } 16925 if (hasEntities) { 16926 accumulator.push(menuItem); 16927 } 16928 return accumulator; 16929 }, 16930 [] 16931 ); 16932 const postTypesMenuItems = (0, import_element57.useMemo)( 16933 () => menuItems.reduce( 16934 (accumulator, postType) => { 16935 const { slug } = postType; 16936 let key = "postTypesMenuItems"; 16937 if (slug === "page") { 16938 key = "defaultPostTypesMenuItems"; 16939 } 16940 accumulator[key].push(postType); 16941 return accumulator; 16942 }, 16943 { defaultPostTypesMenuItems: [], postTypesMenuItems: [] } 16944 ), 16945 [menuItems] 16946 ); 16947 return postTypesMenuItems; 16948 }; 16949 var useTaxonomiesMenuItems = (onClickMenuItem) => { 16950 const publicTaxonomies = usePublicTaxonomies(); 16951 const existingTemplates = useExistingTemplates(); 16952 const defaultTemplateTypes = useDefaultTemplateTypes(); 16953 const templatePrefixes = (0, import_element57.useMemo)( 16954 () => publicTaxonomies?.reduce((accumulator, { slug }) => { 16955 let suffix = slug; 16956 if (!["category", "post_tag"].includes(slug)) { 16957 suffix = `taxonomy-$suffix}`; 16958 } 16959 if (slug === "post_tag") { 16960 suffix = `tag`; 16961 } 16962 accumulator[slug] = suffix; 16963 return accumulator; 16964 }, {}), 16965 [publicTaxonomies] 16966 ); 16967 const taxonomyLabels = publicTaxonomies?.reduce( 16968 (accumulator, { labels }) => { 16969 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 16970 accumulator[templateName] = (accumulator[templateName] || 0) + 1; 16971 return accumulator; 16972 }, 16973 {} 16974 ); 16975 const needsUniqueIdentifier = (labels, slug) => { 16976 if (["category", "post_tag"].includes(slug)) { 16977 return false; 16978 } 16979 const templateName = (labels.template_name || labels.singular_name).toLowerCase(); 16980 return taxonomyLabels[templateName] > 1 && templateName !== slug; 16981 }; 16982 const taxonomiesInfo = useEntitiesInfo("taxonomy", templatePrefixes); 16983 const existingTemplateSlugs = (existingTemplates || []).map( 16984 ({ slug }) => slug 16985 ); 16986 const menuItems = (publicTaxonomies || []).reduce( 16987 (accumulator, taxonomy) => { 16988 const { slug, labels } = taxonomy; 16989 const generalTemplateSlug = templatePrefixes[slug]; 16990 const defaultTemplateType = defaultTemplateTypes?.find( 16991 ({ slug: _slug }) => _slug === generalTemplateSlug 16992 ); 16993 const hasGeneralTemplate = existingTemplateSlugs?.includes(generalTemplateSlug); 16994 const _needsUniqueIdentifier = needsUniqueIdentifier( 16995 labels, 16996 slug 16997 ); 16998 let menuItemTitle = labels.template_name || labels.singular_name; 16999 if (_needsUniqueIdentifier) { 17000 menuItemTitle = labels.template_name ? (0, import_i18n48.sprintf)( 17001 // translators: 1: Name of the template e.g: "Products by Category". 2: Slug of the taxonomy e.g: "product_cat". 17002 (0, import_i18n48._x)("%1$s (%2$s)", "taxonomy template menu label"), 17003 labels.template_name, 17004 slug 17005 ) : (0, import_i18n48.sprintf)( 17006 // translators: 1: Name of the taxonomy e.g: "Category". 2: Slug of the taxonomy e.g: "product_cat". 17007 (0, import_i18n48._x)("%1$s (%2$s)", "taxonomy menu label"), 17008 labels.singular_name, 17009 slug 17010 ); 17011 } 17012 const menuItem = defaultTemplateType ? { 17013 ...defaultTemplateType, 17014 templatePrefix: templatePrefixes[slug] 17015 } : { 17016 slug: generalTemplateSlug, 17017 title: menuItemTitle, 17018 description: (0, import_i18n48.sprintf)( 17019 // translators: %s: Name of the taxonomy e.g: "Product Categories". 17020 (0, import_i18n48.__)("Displays taxonomy: %s."), 17021 labels.singular_name 17022 ), 17023 icon: block_meta_default, 17024 templatePrefix: templatePrefixes[slug] 17025 }; 17026 const hasEntities = taxonomiesInfo?.[slug]?.hasEntities; 17027 if (hasEntities) { 17028 menuItem.onClick = (template) => { 17029 onClickMenuItem({ 17030 type: "taxonomy", 17031 slug, 17032 config: { 17033 queryArgs: ({ search }) => { 17034 return { 17035 _fields: "id,name,slug,link", 17036 orderBy: search ? "name" : "count", 17037 exclude: taxonomiesInfo[slug].existingEntitiesIds 17038 }; 17039 }, 17040 getSpecificTemplate: (suggestion) => { 17041 const templateSlug = prefixSlug( 17042 templatePrefixes[slug], 17043 suggestion.slug 17044 ); 17045 return { 17046 title: templateSlug, 17047 slug: templateSlug, 17048 templatePrefix: templatePrefixes[slug] 17049 }; 17050 } 17051 }, 17052 labels, 17053 hasGeneralTemplate, 17054 template 17055 }); 17056 }; 17057 } 17058 if (!hasGeneralTemplate || hasEntities) { 17059 accumulator.push(menuItem); 17060 } 17061 return accumulator; 17062 }, 17063 [] 17064 ); 17065 const taxonomiesMenuItems = (0, import_element57.useMemo)( 17066 () => menuItems.reduce( 17067 (accumulator, taxonomy) => { 17068 const { slug } = taxonomy; 17069 let key = "taxonomiesMenuItems"; 17070 if (["category", "tag"].includes(slug)) { 17071 key = "defaultTaxonomiesMenuItems"; 17072 } 17073 accumulator[key].push(taxonomy); 17074 return accumulator; 17075 }, 17076 { defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] } 17077 ), 17078 [menuItems] 17079 ); 17080 return taxonomiesMenuItems; 17081 }; 17082 var USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { 17083 user: "author" 17084 }; 17085 var USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { 17086 user: { who: "authors" } 17087 }; 17088 function useAuthorMenuItem(onClickMenuItem) { 17089 const existingTemplates = useExistingTemplates(); 17090 const defaultTemplateTypes = useDefaultTemplateTypes(); 17091 const authorInfo = useEntitiesInfo( 17092 "root", 17093 USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX, 17094 USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS 17095 ); 17096 let authorMenuItem = defaultTemplateTypes?.find( 17097 ({ slug }) => slug === "author" 17098 ); 17099 if (!authorMenuItem) { 17100 authorMenuItem = { 17101 description: (0, import_i18n48.__)( 17102 "Displays latest posts written by a single author." 17103 ), 17104 slug: "author", 17105 title: "Author" 17106 }; 17107 } 17108 const hasGeneralTemplate = !!existingTemplates?.find( 17109 ({ slug }) => slug === "author" 17110 ); 17111 if (authorInfo.user?.hasEntities) { 17112 authorMenuItem = { ...authorMenuItem, templatePrefix: "author" }; 17113 authorMenuItem.onClick = (template) => { 17114 onClickMenuItem({ 17115 type: "root", 17116 slug: "user", 17117 config: { 17118 queryArgs: ({ search }) => { 17119 return { 17120 _fields: "id,name,slug,link", 17121 orderBy: search ? "name" : "registered_date", 17122 exclude: authorInfo.user.existingEntitiesIds, 17123 who: "authors" 17124 }; 17125 }, 17126 getSpecificTemplate: (suggestion) => { 17127 const templateSlug = prefixSlug( 17128 "author", 17129 suggestion.slug 17130 ); 17131 return { 17132 title: (0, import_i18n48.sprintf)( 17133 // translators: %s: Name of the author e.g: "Admin". 17134 (0, import_i18n48.__)("Author: %s"), 17135 suggestion.name 17136 ), 17137 slug: templateSlug, 17138 templatePrefix: "author" 17139 }; 17140 } 17141 }, 17142 labels: { 17143 singular_name: (0, import_i18n48.__)("Author"), 17144 search_items: (0, import_i18n48.__)("Search Authors"), 17145 not_found: (0, import_i18n48.__)("No authors found."), 17146 all_items: (0, import_i18n48.__)("All Authors") 17147 }, 17148 hasGeneralTemplate, 17149 template 17150 }); 17151 }; 17152 } 17153 if (!hasGeneralTemplate || authorInfo.user?.hasEntities) { 17154 return authorMenuItem; 17155 } 17156 } 17157 var useEntitiesInfo = (entityName, templatePrefixes, additionalQueryParameters = EMPTY_OBJECT) => { 17158 const entitiesHasRecords = (0, import_data11.useSelect)( 17159 (select2) => { 17160 return Object.keys(templatePrefixes || {}).reduce( 17161 (accumulator, slug) => { 17162 accumulator[slug] = !!select2( 17163 import_core_data6.store 17164 ).getEntityRecords(entityName, slug, { 17165 per_page: 1, 17166 _fields: "id", 17167 context: "view", 17168 ...additionalQueryParameters[slug] 17169 })?.length; 17170 return accumulator; 17171 }, 17172 {} 17173 ); 17174 }, 17175 [templatePrefixes, entityName, additionalQueryParameters] 17176 ); 17177 const entitiesInfo = (0, import_element57.useMemo)(() => { 17178 return Object.keys(templatePrefixes || {}).reduce( 17179 (accumulator, slug) => { 17180 accumulator[slug] = { 17181 hasEntities: entitiesHasRecords[slug] 17182 }; 17183 return accumulator; 17184 }, 17185 {} 17186 ); 17187 }, [templatePrefixes, entitiesHasRecords]); 17188 return entitiesInfo; 17189 }; 17190 17191 // routes/template-list/add-new-template/add-custom-template-modal-content.tsx 17192 var EMPTY_ARRAY7 = []; 17193 function SuggestionListItem({ 17194 suggestion, 17195 search, 17196 onSelect, 17197 entityForSuggestions 17198 }) { 17199 const baseCssClass = "template-list-custom-template-modal__suggestions_list__list-item"; 17200 return /* @__PURE__ */ React.createElement( 17201 import_components54.Composite.Item, 17202 { 17203 render: /* @__PURE__ */ React.createElement( 17204 import_components54.Button, 17205 { 17206 __next40pxDefaultSize: true, 17207 role: "option", 17208 className: baseCssClass, 17209 onClick: () => onSelect( 17210 entityForSuggestions.config.getSpecificTemplate( 17211 suggestion 17212 ) 17213 ) 17214 } 17215 ) 17216 }, 17217 /* @__PURE__ */ React.createElement( 17218 import_components54.__experimentalText, 17219 { 17220 size: "body", 17221 lineHeight: 1.53846153846, 17222 weight: 500, 17223 className: `$baseCssClass}__title` 17224 }, 17225 /* @__PURE__ */ React.createElement( 17226 import_components54.TextHighlight, 17227 { 17228 text: (0, import_html_entities3.decodeEntities)(suggestion.name), 17229 highlight: search 17230 } 17231 ) 17232 ), 17233 suggestion.link && /* @__PURE__ */ React.createElement( 17234 import_components54.__experimentalText, 17235 { 17236 size: "body", 17237 lineHeight: 1.53846153846, 17238 className: `$baseCssClass}__info` 17239 }, 17240 (0, import_url4.safeDecodeURI)(suggestion.link) 17241 ) 17242 ); 17243 } 17244 function useSearchSuggestions(entityForSuggestions, search) { 17245 const { config } = entityForSuggestions; 17246 const query = (0, import_element58.useMemo)( 17247 () => ({ 17248 order: "asc", 17249 context: "view", 17250 search, 17251 per_page: search ? 20 : 10, 17252 ...config.queryArgs({ search }) 17253 }), 17254 [search, config] 17255 ); 17256 const { records: searchResults, hasResolved: searchHasResolved } = (0, import_core_data7.useEntityRecords)( 17257 entityForSuggestions.type, 17258 entityForSuggestions.slug, 17259 query 17260 ); 17261 const [suggestions, setSuggestions] = (0, import_element58.useState)(EMPTY_ARRAY7); 17262 (0, import_element58.useEffect)(() => { 17263 if (!searchHasResolved) { 17264 return; 17265 } 17266 let newSuggestions = EMPTY_ARRAY7; 17267 if (searchResults?.length) { 17268 newSuggestions = searchResults; 17269 if (config.recordNamePath) { 17270 newSuggestions = mapToIHasNameAndId( 17271 newSuggestions, 17272 config.recordNamePath 17273 ); 17274 } 17275 } 17276 setSuggestions(newSuggestions); 17277 }, [searchResults, searchHasResolved, config.recordNamePath]); 17278 return suggestions; 17279 } 17280 function SuggestionList({ 17281 entityForSuggestions, 17282 onSelect 17283 }) { 17284 const [search, setSearch, debouncedSearch] = (0, import_compose12.useDebouncedInput)(); 17285 const suggestions = useSearchSuggestions( 17286 entityForSuggestions, 17287 debouncedSearch 17288 ); 17289 const { labels } = entityForSuggestions; 17290 const [showSearchControl, setShowSearchControl] = (0, import_element58.useState)(false); 17291 if (!showSearchControl && suggestions?.length > 9) { 17292 setShowSearchControl(true); 17293 } 17294 return /* @__PURE__ */ React.createElement(React.Fragment, null, showSearchControl && /* @__PURE__ */ React.createElement( 17295 import_components54.SearchControl, 17296 { 17297 onChange: setSearch, 17298 value: search, 17299 label: labels.search_items, 17300 placeholder: labels.search_items 17301 } 17302 ), !!suggestions?.length && /* @__PURE__ */ React.createElement( 17303 import_components54.Composite, 17304 { 17305 orientation: "vertical", 17306 role: "listbox", 17307 className: "template-list-custom-template-modal__suggestions_list", 17308 "aria-label": (0, import_i18n49.__)("Suggestions list") 17309 }, 17310 suggestions.map((suggestion) => /* @__PURE__ */ React.createElement( 17311 SuggestionListItem, 17312 { 17313 key: suggestion.slug, 17314 suggestion, 17315 search: debouncedSearch, 17316 onSelect, 17317 entityForSuggestions 17318 } 17319 )) 17320 ), debouncedSearch && !suggestions?.length && /* @__PURE__ */ React.createElement( 17321 import_components54.__experimentalText, 17322 { 17323 as: "p", 17324 className: "template-list-custom-template-modal__no-results" 17325 }, 17326 labels.not_found 17327 )); 17328 } 17329 function AddCustomTemplateModalContent({ 17330 onSelect, 17331 entityForSuggestions, 17332 onBack, 17333 containerRef 17334 }) { 17335 const [showSearchEntities, setShowSearchEntities] = (0, import_element58.useState)(false); 17336 (0, import_element58.useEffect)(() => { 17337 if (containerRef.current) { 17338 const [firstFocusable] = import_dom10.focus.focusable.find( 17339 containerRef.current 17340 ); 17341 firstFocusable?.focus(); 17342 } 17343 }, [showSearchEntities, containerRef]); 17344 return /* @__PURE__ */ React.createElement( 17345 import_components54.__experimentalVStack, 17346 { 17347 spacing: 4, 17348 className: "template-list-custom-template-modal__contents-wrapper", 17349 alignment: "left" 17350 }, 17351 !showSearchEntities && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(import_components54.__experimentalText, { as: "p" }, (0, import_i18n49.__)( 17352 "Select whether to create a single template for all items or a specific one." 17353 )), /* @__PURE__ */ React.createElement( 17354 import_components54.Flex, 17355 { 17356 className: "template-list-custom-template-modal__contents", 17357 gap: "4", 17358 align: "initial" 17359 }, 17360 /* @__PURE__ */ React.createElement( 17361 import_components54.FlexItem, 17362 { 17363 isBlock: true, 17364 as: import_components54.Button, 17365 onClick: () => { 17366 const { 17367 slug, 17368 title, 17369 description, 17370 templatePrefix 17371 } = entityForSuggestions.template; 17372 onSelect({ 17373 slug, 17374 title, 17375 description, 17376 templatePrefix 17377 }); 17378 } 17379 }, 17380 /* @__PURE__ */ React.createElement( 17381 import_components54.__experimentalText, 17382 { 17383 as: "span", 17384 weight: 500, 17385 lineHeight: 1.53846153846 17386 }, 17387 entityForSuggestions.labels.all_items 17388 ), 17389 /* @__PURE__ */ React.createElement( 17390 import_components54.__experimentalText, 17391 { 17392 as: "span", 17393 lineHeight: 1.53846153846 17394 }, 17395 // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one. 17396 (0, import_i18n49.__)("For all items") 17397 ) 17398 ), 17399 /* @__PURE__ */ React.createElement( 17400 import_components54.FlexItem, 17401 { 17402 isBlock: true, 17403 as: import_components54.Button, 17404 onClick: () => { 17405 setShowSearchEntities(true); 17406 } 17407 }, 17408 /* @__PURE__ */ React.createElement( 17409 import_components54.__experimentalText, 17410 { 17411 as: "span", 17412 weight: 500, 17413 lineHeight: 1.53846153846 17414 }, 17415 entityForSuggestions.labels.singular_name 17416 ), 17417 /* @__PURE__ */ React.createElement( 17418 import_components54.__experimentalText, 17419 { 17420 as: "span", 17421 lineHeight: 1.53846153846 17422 }, 17423 // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one. 17424 (0, import_i18n49.__)("For a specific item") 17425 ) 17426 ) 17427 ), /* @__PURE__ */ React.createElement(import_components54.Flex, { justify: "right" }, /* @__PURE__ */ React.createElement( 17428 import_components54.Button, 17429 { 17430 __next40pxDefaultSize: true, 17431 variant: "tertiary", 17432 onClick: onBack 17433 }, 17434 (0, import_i18n49.__)("Back") 17435 ))), 17436 showSearchEntities && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(import_components54.__experimentalText, { as: "p" }, (0, import_i18n49.__)( 17437 "This template will be used only for the specific item chosen." 17438 )), /* @__PURE__ */ React.createElement( 17439 SuggestionList, 17440 { 17441 entityForSuggestions, 17442 onSelect 17443 } 17444 ), /* @__PURE__ */ React.createElement(import_components54.Flex, { justify: "right" }, /* @__PURE__ */ React.createElement( 17445 import_components54.Button, 17446 { 17447 __next40pxDefaultSize: true, 17448 variant: "tertiary", 17449 onClick: () => { 17450 if (entityForSuggestions.hasGeneralTemplate) { 17451 onBack(); 17452 } else { 17453 setShowSearchEntities(false); 17454 } 17455 } 17456 }, 17457 (0, import_i18n49.__)("Back") 17458 ))) 17459 ); 17460 } 17461 var add_custom_template_modal_content_default = AddCustomTemplateModalContent; 17462 17463 // node_modules/tslib/tslib.es6.mjs 17464 var __assign = function() { 17465 __assign = Object.assign || function __assign2(t2) { 17466 for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) { 17467 s2 = arguments[i2]; 17468 for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) t2[p2] = s2[p2]; 17469 } 17470 return t2; 17471 }; 17472 return __assign.apply(this, arguments); 17473 }; 17474 17475 // node_modules/lower-case/dist.es2015/index.js 17476 function lowerCase(str) { 17477 return str.toLowerCase(); 17478 } 17479 17480 // node_modules/no-case/dist.es2015/index.js 17481 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 17482 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 17483 function noCase(input, options) { 17484 if (options === void 0) { 17485 options = {}; 17486 } 17487 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; 17488 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 17489 var start = 0; 17490 var end = result.length; 17491 while (result.charAt(start) === "\0") 17492 start++; 17493 while (result.charAt(end - 1) === "\0") 17494 end--; 17495 return result.slice(start, end).split("\0").map(transform).join(delimiter); 17496 } 17497 function replace(input, re, value) { 17498 if (re instanceof RegExp) 17499 return input.replace(re, value); 17500 return re.reduce(function(input2, re2) { 17501 return input2.replace(re2, value); 17502 }, input); 17503 } 17504 17505 // node_modules/dot-case/dist.es2015/index.js 17506 function dotCase(input, options) { 17507 if (options === void 0) { 17508 options = {}; 17509 } 17510 return noCase(input, __assign({ delimiter: "." }, options)); 17511 } 17512 17513 // node_modules/param-case/dist.es2015/index.js 17514 function paramCase(input, options) { 17515 if (options === void 0) { 17516 options = {}; 17517 } 17518 return dotCase(input, __assign({ delimiter: "-" }, options)); 17519 } 17520 17521 // routes/template-list/add-new-template/add-custom-generic-template-modal-content.tsx 17522 var import_element59 = __toESM(require_element()); 17523 var import_i18n50 = __toESM(require_i18n()); 17524 var import_components55 = __toESM(require_components()); 17525 function AddCustomGenericTemplateModalContent({ 17526 createTemplate, 17527 onBack 17528 }) { 17529 const [title, setTitle] = (0, import_element59.useState)(""); 17530 const defaultTitle = (0, import_i18n50.__)("Custom Template"); 17531 const [isBusy, setIsBusy] = (0, import_element59.useState)(false); 17532 const inputRef = (0, import_element59.useRef)(null); 17533 (0, import_element59.useEffect)(() => { 17534 if (inputRef.current) { 17535 inputRef.current.focus(); 17536 } 17537 }, []); 17538 async function onCreateTemplate(event) { 17539 event.preventDefault(); 17540 if (isBusy) { 17541 return; 17542 } 17543 setIsBusy(true); 17544 try { 17545 await createTemplate( 17546 { 17547 slug: paramCase(title || defaultTitle) || "wp-custom-template", 17548 title: title || defaultTitle 17549 }, 17550 false 17551 ); 17552 } finally { 17553 setIsBusy(false); 17554 } 17555 } 17556 return /* @__PURE__ */ React.createElement("form", { onSubmit: onCreateTemplate }, /* @__PURE__ */ React.createElement(import_components55.__experimentalVStack, { spacing: 6 }, /* @__PURE__ */ React.createElement( 17557 import_components55.TextControl, 17558 { 17559 __next40pxDefaultSize: true, 17560 label: (0, import_i18n50.__)("Name"), 17561 value: title, 17562 onChange: setTitle, 17563 placeholder: defaultTitle, 17564 disabled: isBusy, 17565 ref: inputRef, 17566 help: (0, import_i18n50.__)( 17567 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts 17568 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.' 17569 ) 17570 } 17571 ), /* @__PURE__ */ React.createElement( 17572 import_components55.__experimentalHStack, 17573 { 17574 className: "template-list-custom-generic-template__modal-actions", 17575 justify: "right" 17576 }, 17577 /* @__PURE__ */ React.createElement( 17578 import_components55.Button, 17579 { 17580 __next40pxDefaultSize: true, 17581 variant: "tertiary", 17582 onClick: onBack 17583 }, 17584 (0, import_i18n50.__)("Back") 17585 ), 17586 /* @__PURE__ */ React.createElement( 17587 import_components55.Button, 17588 { 17589 __next40pxDefaultSize: true, 17590 variant: "primary", 17591 type: "submit", 17592 isBusy, 17593 "aria-disabled": isBusy 17594 }, 17595 (0, import_i18n50.__)("Create") 17596 ) 17597 ))); 17598 } 17599 var add_custom_generic_template_modal_content_default = AddCustomGenericTemplateModalContent; 17600 17601 // routes/template-list/add-new-template/index.tsx 17602 var TEMPLATE_POST_TYPE2 = "wp_template"; 17603 var DEFAULT_TEMPLATE_SLUGS = [ 17604 "front-page", 17605 "home", 17606 "single", 17607 "page", 17608 "index", 17609 "archive", 17610 "author", 17611 "category", 17612 "date", 17613 "tag", 17614 "search", 17615 "404" 17616 ]; 17617 var TEMPLATE_ICONS = { 17618 "front-page": home_default, 17619 home: verse_default, 17620 single: pin_default, 17621 page: page_default, 17622 archive: archive_default, 17623 search: search_default, 17624 404: not_found_default, 17625 index: list_default, 17626 category: category_default, 17627 author: comment_author_avatar_default, 17628 taxonomy: block_meta_default, 17629 date: calendar_default, 17630 tag: tag_default, 17631 attachment: media_default 17632 }; 17633 function TemplateListItem({ 17634 title, 17635 direction, 17636 className, 17637 description, 17638 icon, 17639 onClick, 17640 children 17641 }) { 17642 return /* @__PURE__ */ React.createElement( 17643 import_components56.Button, 17644 { 17645 __next40pxDefaultSize: true, 17646 className, 17647 onClick, 17648 label: description, 17649 showTooltip: !!description 17650 }, 17651 /* @__PURE__ */ React.createElement( 17652 import_components56.Flex, 17653 { 17654 as: "span", 17655 align: "center", 17656 justify: "center", 17657 style: { width: "100%" }, 17658 direction 17659 }, 17660 /* @__PURE__ */ React.createElement("div", { className: "template-list-add-new-template__template-icon" }, /* @__PURE__ */ React.createElement(import_components56.Icon, { icon })), 17661 /* @__PURE__ */ React.createElement( 17662 import_components56.__experimentalVStack, 17663 { 17664 className: "template-list-add-new-template__template-name", 17665 alignment: "center", 17666 spacing: 0 17667 }, 17668 /* @__PURE__ */ React.createElement( 17669 import_components56.__experimentalText, 17670 { 17671 align: "center", 17672 weight: 500, 17673 lineHeight: 1.53846153846 17674 }, 17675 title 17676 ), 17677 children 17678 ) 17679 ) 17680 ); 17681 } 17682 var modalContentMap = { 17683 templatesList: 1, 17684 customTemplate: 2, 17685 customGenericTemplate: 3 17686 }; 17687 function NewTemplateModal({ onClose }) { 17688 const [modalContent, setModalContent] = (0, import_element60.useState)(modalContentMap.templatesList); 17689 const [entityForSuggestions, setEntityForSuggestions] = (0, import_element60.useState)(); 17690 const [isSubmitting, setIsSubmitting] = (0, import_element60.useState)(false); 17691 const missingTemplates = useMissingTemplates( 17692 setEntityForSuggestions, 17693 () => setModalContent(modalContentMap.customTemplate) 17694 ); 17695 const navigate = useNavigate(); 17696 const invalidate = useInvalidate(); 17697 const { saveEntityRecord } = (0, import_data12.useDispatch)(import_core_data8.store); 17698 const { createErrorNotice, createSuccessNotice } = (0, import_data12.useDispatch)(import_notices.store); 17699 const containerRef = (0, import_element60.useRef)(null); 17700 const isMobile = (0, import_compose13.useViewportMatch)("medium", "<"); 17701 const homeUrl = (0, import_data12.useSelect)((select2) => { 17702 return select2(import_core_data8.store).getEntityRecord("root", "__unstableBase")?.home; 17703 }, []); 17704 const TEMPLATE_SHORT_DESCRIPTIONS = { 17705 "front-page": homeUrl, 17706 date: (0, import_i18n51.sprintf)( 17707 // translators: %s: The homepage url. 17708 (0, import_i18n51.__)("E.g. %s"), 17709 homeUrl + "/" + (/* @__PURE__ */ new Date()).getFullYear() 17710 ) 17711 }; 17712 (0, import_element60.useEffect)(() => { 17713 if (containerRef.current && modalContent === modalContentMap.templatesList) { 17714 const [firstFocusable] = import_dom11.focus.focusable.find( 17715 containerRef.current 17716 ); 17717 firstFocusable?.focus(); 17718 } 17719 }, [modalContent]); 17720 async function createTemplate(template, isWPSuggestion = true) { 17721 if (isSubmitting) { 17722 return; 17723 } 17724 setIsSubmitting(true); 17725 try { 17726 const { title, description, slug } = template; 17727 const newTemplate = await saveEntityRecord( 17728 "postType", 17729 TEMPLATE_POST_TYPE2, 17730 { 17731 description, 17732 // Slugs need to be strings, so this is for template `404` 17733 slug: slug.toString(), 17734 status: "publish", 17735 title, 17736 // This adds post meta fields in template 17737 meta: { 17738 is_wp_suggestion: isWPSuggestion, 17739 // Mark as inactive by default when template activation is enabled 17740 is_inactive_by_default: true 17741 } 17742 }, 17743 { throwOnError: true } 17744 ); 17745 navigate({ 17746 to: `/types/wp_template/edit/$encodeURIComponent( 17747 String(newTemplate.id) 17748 )}` 17749 }); 17750 invalidate(); 17751 createSuccessNotice( 17752 (0, import_i18n51.sprintf)( 17753 // translators: %s: Title of the created post or template, e.g: "Hello world". 17754 (0, import_i18n51.__)('"%s" successfully created.'), 17755 (0, import_html_entities4.decodeEntities)(newTemplate.title?.rendered || title) || (0, import_i18n51.__)("(no title)") 17756 ), 17757 { 17758 type: "snackbar" 17759 } 17760 ); 17761 } catch (error) { 17762 const errorMessage = error.message && error.code !== "unknown_error" ? error.message : (0, import_i18n51.__)("An error occurred while creating the template."); 17763 createErrorNotice(errorMessage, { 17764 type: "snackbar" 17765 }); 17766 } finally { 17767 setIsSubmitting(false); 17768 } 17769 } 17770 const onModalClose = () => { 17771 onClose(); 17772 setModalContent(modalContentMap.templatesList); 17773 }; 17774 let modalTitle = (0, import_i18n51.__)("Add template"); 17775 if (modalContent === modalContentMap.customTemplate && entityForSuggestions) { 17776 modalTitle = (0, import_i18n51.sprintf)( 17777 // translators: %s: Name of the post type e.g: "Post". 17778 (0, import_i18n51.__)("Add template: %s"), 17779 entityForSuggestions.labels.singular_name 17780 ); 17781 } else if (modalContent === modalContentMap.customGenericTemplate) { 17782 modalTitle = (0, import_i18n51.__)("Create custom template"); 17783 } 17784 return /* @__PURE__ */ React.createElement( 17785 import_components56.Modal, 17786 { 17787 title: modalTitle, 17788 className: clsx_default("template-list-add-new-template__modal", { 17789 "template-list-add-new-template__modal_template_list": modalContent === modalContentMap.templatesList, 17790 "template-list-custom-template-modal": modalContent === modalContentMap.customTemplate 17791 }), 17792 onRequestClose: onModalClose, 17793 overlayClassName: modalContent === modalContentMap.customGenericTemplate ? "template-list-custom-generic-template__modal" : void 0, 17794 ref: containerRef 17795 }, 17796 modalContent === modalContentMap.templatesList && /* @__PURE__ */ React.createElement( 17797 import_components56.__experimentalGrid, 17798 { 17799 columns: isMobile ? 2 : 3, 17800 gap: 4, 17801 align: "flex-start", 17802 justify: "center", 17803 className: "template-list-add-new-template__template-list__contents" 17804 }, 17805 /* @__PURE__ */ React.createElement(import_components56.Flex, { className: "template-list-add-new-template__template-list__prompt" }, (0, import_i18n51.__)( 17806 "Select what the new template should apply to:" 17807 )), 17808 missingTemplates.map((template) => { 17809 const { title, slug, onClick } = template; 17810 return /* @__PURE__ */ React.createElement( 17811 TemplateListItem, 17812 { 17813 key: slug, 17814 title, 17815 direction: "column", 17816 className: "template-list-add-new-template__template-button", 17817 description: TEMPLATE_SHORT_DESCRIPTIONS[slug], 17818 icon: TEMPLATE_ICONS[slug] || layout_default, 17819 onClick: () => onClick ? onClick(template) : createTemplate(template) 17820 } 17821 ); 17822 }), 17823 /* @__PURE__ */ React.createElement( 17824 TemplateListItem, 17825 { 17826 title: (0, import_i18n51.__)("Custom template"), 17827 direction: "row", 17828 className: "template-list-add-new-template__custom-template-button", 17829 icon: pencil_default, 17830 onClick: () => setModalContent( 17831 modalContentMap.customGenericTemplate 17832 ) 17833 }, 17834 /* @__PURE__ */ React.createElement( 17835 import_components56.__experimentalText, 17836 { 17837 lineHeight: 1.53846153846 17838 }, 17839 (0, import_i18n51.__)( 17840 "A custom template can be manually applied to any post or page." 17841 ) 17842 ) 17843 ) 17844 ), 17845 modalContent === modalContentMap.customTemplate && entityForSuggestions && /* @__PURE__ */ React.createElement( 17846 add_custom_template_modal_content_default, 17847 { 17848 onSelect: createTemplate, 17849 entityForSuggestions, 17850 onBack: () => setModalContent(modalContentMap.templatesList), 17851 containerRef 17852 } 17853 ), 17854 modalContent === modalContentMap.customGenericTemplate && /* @__PURE__ */ React.createElement( 17855 add_custom_generic_template_modal_content_default, 17856 { 17857 createTemplate, 17858 onBack: () => setModalContent(modalContentMap.templatesList) 17859 } 17860 ) 17861 ); 17862 } 17863 function NewTemplate() { 17864 const [showModal, setShowModal] = (0, import_element60.useState)(false); 17865 const { postType } = (0, import_data12.useSelect)((select2) => { 17866 const { getPostType } = select2(import_core_data8.store); 17867 return { 17868 postType: getPostType(TEMPLATE_POST_TYPE2) 17869 }; 17870 }, []); 17871 if (!postType) { 17872 return null; 17873 } 17874 return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement( 17875 import_components56.Button, 17876 { 17877 variant: "primary", 17878 onClick: () => setShowModal(true), 17879 label: postType.labels.add_new_item, 17880 size: "compact" 17881 }, 17882 postType.labels.add_new_item 17883 ), showModal && /* @__PURE__ */ React.createElement(NewTemplateModal, { onClose: () => setShowModal(false) })); 17884 } 17885 function useMissingTemplates(setEntityForSuggestions, onClick) { 17886 const defaultTemplateTypes = useDefaultTemplateTypes(); 17887 const missingDefaultTemplates = (defaultTemplateTypes || []).filter( 17888 (template) => DEFAULT_TEMPLATE_SLUGS.includes(template.slug) 17889 ); 17890 const onClickMenuItem = (_entityForSuggestions) => { 17891 onClick?.(); 17892 setEntityForSuggestions(_entityForSuggestions); 17893 }; 17894 const enhancedMissingDefaultTemplateTypes = [ 17895 ...missingDefaultTemplates 17896 ]; 17897 const { defaultTaxonomiesMenuItems, taxonomiesMenuItems } = useTaxonomiesMenuItems(onClickMenuItem); 17898 const { defaultPostTypesMenuItems, postTypesMenuItems } = usePostTypeMenuItems(onClickMenuItem); 17899 const authorMenuItem = useAuthorMenuItem(onClickMenuItem); 17900 [ 17901 ...defaultTaxonomiesMenuItems, 17902 ...defaultPostTypesMenuItems, 17903 authorMenuItem 17904 ].forEach((menuItem) => { 17905 if (!menuItem) { 17906 return; 17907 } 17908 const matchIndex = enhancedMissingDefaultTemplateTypes.findIndex( 17909 (template) => template.slug === menuItem.slug 17910 ); 17911 if (matchIndex > -1) { 17912 enhancedMissingDefaultTemplateTypes[matchIndex] = menuItem; 17913 } else { 17914 enhancedMissingDefaultTemplateTypes.push(menuItem); 17915 } 17916 }); 17917 enhancedMissingDefaultTemplateTypes?.sort((template1, template2) => { 17918 return DEFAULT_TEMPLATE_SLUGS.indexOf(template1.slug) - DEFAULT_TEMPLATE_SLUGS.indexOf(template2.slug); 17919 }); 17920 const missingTemplates = [ 17921 ...enhancedMissingDefaultTemplateTypes, 17922 ...usePostTypeArchiveMenuItems(), 17923 ...postTypesMenuItems, 17924 ...taxonomiesMenuItems 17925 ]; 17926 return missingTemplates; 17927 } 17928 var add_new_template_default = (0, import_element60.memo)(NewTemplate); 17929 17930 // routes/template-list/style.scss 17931 var css = `/** 17932 * SCSS Variables. 17933 * 17934 * Please use variables from this sheet to ensure consistency across the UI. 17935 * Don't add to this sheet unless you're pretty sure the value will be reused in many places. 17936 * For example, don't add rules to this sheet that affect block visuals. It's purely for UI. 17937 */ 17938 /** 17939 * Colors 17940 */ 17941 /** 17942 * Fonts & basic variables. 17943 */ 17944 /** 17945 * Typography 17946 */ 17947 /** 17948 * Grid System. 17949 * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/ 17950 */ 17951 /** 17952 * Radius scale. 17953 */ 17954 /** 17955 * Elevation scale. 17956 */ 17957 /** 17958 * Dimensions. 17959 */ 17960 /** 17961 * Mobile specific styles 17962 */ 17963 /** 17964 * Editor styles. 17965 */ 17966 /** 17967 * Block & Editor UI. 17968 */ 17969 /** 17970 * Block paddings. 17971 */ 17972 /** 17973 * React Native specific. 17974 * These variables do not appear to be used anywhere else. 17975 */ 17976 /** 17977 * Typography 17978 */ 17979 /** 17980 * SCSS Variables. 17981 * 17982 * Please use variables from this sheet to ensure consistency across the UI. 17983 * Don't add to this sheet unless you're pretty sure the value will be reused in many places. 17984 * For example, don't add rules to this sheet that affect block visuals. It's purely for UI. 17985 */ 17986 /** 17987 * Colors 17988 */ 17989 /** 17990 * Fonts & basic variables. 17991 */ 17992 /** 17993 * Typography 17994 */ 17995 /** 17996 * Grid System. 17997 * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/ 17998 */ 17999 /** 18000 * Radius scale. 18001 */ 18002 /** 18003 * Elevation scale. 18004 */ 18005 /** 18006 * Dimensions. 18007 */ 18008 /** 18009 * Mobile specific styles 18010 */ 18011 /** 18012 * Editor styles. 18013 */ 18014 /** 18015 * Block & Editor UI. 18016 */ 18017 /** 18018 * Block paddings. 18019 */ 18020 /** 18021 * React Native specific. 18022 * These variables do not appear to be used anywhere else. 18023 */ 18024 /** 18025 * Breakpoints & Media Queries 18026 */ 18027 /** 18028 * Converts a hex value into the rgb equivalent. 18029 * 18030 * @param {string} hex - the hexadecimal value to convert 18031 * @return {string} comma separated rgb values 18032 */ 18033 /** 18034 * Long content fade mixin 18035 * 18036 * Creates a fading overlay to signify that the content is longer 18037 * than the space allows. 18038 */ 18039 /** 18040 * Breakpoint mixins 18041 */ 18042 /** 18043 * Focus styles. 18044 */ 18045 /** 18046 * Applies editor left position to the selector passed as argument 18047 */ 18048 /** 18049 * Styles that are reused verbatim in a few places 18050 */ 18051 /** 18052 * Allows users to opt-out of animations via OS-level preferences. 18053 */ 18054 /** 18055 * Reset default styles for JavaScript UI based pages. 18056 * This is a WP-admin agnostic reset 18057 */ 18058 /** 18059 * Reset the WP Admin page styles for Gutenberg-like pages. 18060 */ 18061 :root { 18062 --wp-block-synced-color: #7a00df; 18063 --wp-block-synced-color--rgb: 122, 0, 223; 18064 --wp-bound-block-color: var(--wp-block-synced-color); 18065 --wp-editor-canvas-background: #ddd; 18066 --wp-admin-theme-color: #007cba; 18067 --wp-admin-theme-color--rgb: 0, 124, 186; 18068 --wp-admin-theme-color-darker-10: rgb(0, 107, 160.5); 18069 --wp-admin-theme-color-darker-10--rgb: 0, 107, 160.5; 18070 --wp-admin-theme-color-darker-20: #005a87; 18071 --wp-admin-theme-color-darker-20--rgb: 0, 90, 135; 18072 --wp-admin-border-width-focus: 2px; 18073 } 18074 18075 @media (min-resolution: 192dpi) { 18076 :root { 18077 --wp-admin-border-width-focus: 1.5px; 18078 } 18079 } 18080 .fields-create-template-part-modal { 18081 z-index: 1000001; 18082 } 18083 18084 .fields-create-template-part-modal__area-fieldset { 18085 border: 0; 18086 padding: 0; 18087 margin: 0; 18088 } 18089 18090 .fields-create-template-part-modal__area-radio-group { 18091 border: 1px solid #949494; 18092 border-radius: 2px; 18093 } 18094 18095 .fields-create-template-part-modal__area-radio-wrapper { 18096 position: relative; 18097 padding: 12px; 18098 display: grid; 18099 align-items: center; 18100 grid-template-columns: min-content 1fr min-content; 18101 grid-gap: 4px 8px; 18102 color: #1e1e1e; 18103 } 18104 18105 .fields-create-template-part-modal__area-radio-wrapper + .fields-create-template-part-modal__area-radio-wrapper { 18106 border-top: 1px solid #949494; 18107 } 18108 18109 .fields-create-template-part-modal__area-radio-wrapper input[type=radio] { 18110 position: absolute; 18111 opacity: 0; 18112 } 18113 18114 .fields-create-template-part-modal__area-radio-wrapper:has(input[type=radio]:checked) { 18115 z-index: 1; 18116 } 18117 18118 .fields-create-template-part-modal__area-radio-wrapper:has(input[type=radio]:not(:checked)):hover { 18119 color: var(--wp-admin-theme-color); 18120 } 18121 18122 .fields-create-template-part-modal__area-radio-wrapper > *:not(.fields-create-template-part-modal__area-radio-label) { 18123 pointer-events: none; 18124 } 18125 18126 .fields-create-template-part-modal__area-radio-label::before { 18127 content: ""; 18128 position: absolute; 18129 inset: 0; 18130 } 18131 18132 input[type=radio]:not(:checked) ~ .fields-create-template-part-modal__area-radio-label::before { 18133 cursor: pointer; 18134 } 18135 18136 input[type=radio]:focus-visible ~ .fields-create-template-part-modal__area-radio-label::before { 18137 outline: 4px solid transparent; 18138 box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); 18139 } 18140 18141 .fields-create-template-part-modal__area-radio-icon, 18142 .fields-create-template-part-modal__area-radio-checkmark { 18143 fill: currentColor; 18144 } 18145 18146 input[type=radio]:not(:checked) ~ .fields-create-template-part-modal__area-radio-checkmark { 18147 opacity: 0; 18148 } 18149 18150 .fields-create-template-part-modal__area-radio-description { 18151 grid-column: 2/3; 18152 margin: 0; 18153 color: #757575; 18154 font-size: 12px; 18155 line-height: normal; 18156 text-wrap: pretty; 18157 } 18158 18159 input[type=radio]:not(:checked):hover ~ .fields-create-template-part-modal__area-radio-description { 18160 color: inherit; 18161 } 18162 18163 .fields-controls__slug { 18164 border: 0; 18165 padding: 0; 18166 margin: 0; 18167 } 18168 18169 .fields-controls__slug .fields-controls__slug-external-icon { 18170 margin-left: 5ch; 18171 } 18172 18173 .fields-controls__slug .fields-controls__slug-input input.components-input-control__input { 18174 padding-inline-start: 0 !important; 18175 } 18176 18177 .fields-controls__slug .fields-controls__slug-help-link { 18178 word-break: break-word; 18179 } 18180 18181 .fields-controls__slug .fields-controls__slug-help { 18182 display: flex; 18183 flex-direction: column; 18184 } 18185 18186 .fields-controls__slug .fields-controls__slug-help .fields-controls__slug-help-slug { 18187 font-weight: 600; 18188 } 18189 18190 .fields-controls__featured-image-placeholder { 18191 border-radius: 2px; 18192 box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); 18193 display: inline-block; 18194 padding: 0; 18195 background: #fff linear-gradient(-45deg, transparent 48%, #ddd 48%, #ddd 52%, transparent 52%); 18196 } 18197 18198 .fields-controls__featured-image-title { 18199 width: 100%; 18200 color: #1e1e1e; 18201 white-space: nowrap; 18202 text-overflow: ellipsis; 18203 overflow: hidden; 18204 } 18205 18206 .fields-controls__featured-image-image { 18207 width: 100%; 18208 height: 100%; 18209 border-radius: 2px; 18210 align-self: center; 18211 } 18212 18213 .fields-controls__featured-image-container .fields-controls__featured-image-placeholder { 18214 margin: 0; 18215 } 18216 18217 .fields-controls__featured-image-container span { 18218 margin-right: auto; 18219 } 18220 18221 fieldset.fields-controls__featured-image { 18222 border: 0; 18223 padding: 0; 18224 margin: 0; 18225 } 18226 18227 fieldset.fields-controls__featured-image .fields-controls__featured-image-container { 18228 border: 1px solid #ddd; 18229 border-radius: 2px; 18230 padding: 8px 12px; 18231 cursor: pointer; 18232 } 18233 18234 fieldset.fields-controls__featured-image .fields-controls__featured-image-container:hover { 18235 background-color: #f0f0f0; 18236 } 18237 18238 fieldset.fields-controls__featured-image .fields-controls__featured-image-placeholder { 18239 width: 24px; 18240 height: 24px; 18241 } 18242 18243 fieldset.fields-controls__featured-image span { 18244 align-self: center; 18245 text-align: start; 18246 white-space: nowrap; 18247 } 18248 18249 fieldset.fields-controls__featured-image .fields-controls__featured-image-upload-button { 18250 padding: 0; 18251 height: fit-content; 18252 } 18253 18254 fieldset.fields-controls__featured-image .fields-controls__featured-image-upload-button:hover, fieldset.fields-controls__featured-image .fields-controls__featured-image-upload-button:focus { 18255 border: 0; 18256 color: unset; 18257 } 18258 18259 fieldset.fields-controls__featured-image .fields-controls__featured-image-remove-button { 18260 place-self: end; 18261 } 18262 18263 .dataforms-layouts-panel__field-control .fields-controls__featured-image-image { 18264 width: 16px; 18265 height: 16px; 18266 } 18267 18268 .dataforms-layouts-panel__field-control .fields-controls__featured-image-placeholder { 18269 width: 16px; 18270 height: 16px; 18271 } 18272 18273 .dataviews-view-grid__media .fields-controls__featured-image-image, 18274 .dataviews-view-grid__media .fields-controls__featured-image-placeholder, 18275 .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-image, 18276 .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-placeholder, 18277 .dataviews-view-list__media-wrapper .fields-controls__featured-image-image, 18278 .dataviews-view-list__media-wrapper .fields-controls__featured-image-placeholder { 18279 width: 100%; 18280 height: 100%; 18281 display: block; 18282 border-radius: 4px; 18283 } 18284 18285 .dataviews-view-grid__media .fields-controls__featured-image-placeholder, 18286 .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-placeholder, 18287 .dataviews-view-list__media-wrapper .fields-controls__featured-image-placeholder { 18288 box-shadow: none; 18289 background: #f0f0f0; 18290 } 18291 18292 .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-image, 18293 .dataviews-view-table__cell-content-wrapper.dataviews-column-primary__media .fields-controls__featured-image-placeholder { 18294 width: 32px; 18295 height: 32px; 18296 } 18297 18298 .fields-controls__parent { 18299 border: 0; 18300 padding: 0; 18301 margin: 0; 18302 } 18303 18304 .fields-controls__password { 18305 border: 0; 18306 padding: 0; 18307 margin: 0; 18308 } 18309 18310 .fields-controls__template { 18311 border: 0; 18312 padding: 0; 18313 margin: 0; 18314 } 18315 18316 .fields-controls__template-modal { 18317 z-index: 1000001; 18318 } 18319 18320 .fields-controls__template-content .block-editor-block-patterns-list { 18321 column-count: 2; 18322 column-gap: 24px; 18323 padding-top: 2px; 18324 } 18325 18326 @media (min-width: 782px) { 18327 .fields-controls__template-content .block-editor-block-patterns-list { 18328 column-count: 3; 18329 } 18330 } 18331 @media (min-width: 1280px) { 18332 .fields-controls__template-content .block-editor-block-patterns-list { 18333 column-count: 4; 18334 } 18335 } 18336 .fields-controls__template-content .block-editor-block-patterns-list .block-editor-block-patterns-list__list-item { 18337 break-inside: avoid-column; 18338 } 18339 18340 .fields-field__title > span:first-child { 18341 text-overflow: ellipsis; 18342 overflow: hidden; 18343 text-decoration: none; 18344 white-space: nowrap; 18345 display: block; 18346 flex-grow: 0; 18347 } 18348 18349 .fields-field__pattern-title span:first-child { 18350 flex: 1; 18351 } 18352 18353 .routes-template-list__tabs-wrapper { 18354 border-bottom: 1px solid #f0f0f0; 18355 padding: 0 24px; 18356 } 18357 18358 .routes-template-list-author-field__avatar { 18359 width: 24px; 18360 height: 24px; 18361 border-radius: 50%; 18362 overflow: hidden; 18363 margin-right: 8px; 18364 opacity: 0; 18365 transition: opacity 0.1s ease-in; 18366 } 18367 .routes-template-list-author-field__avatar.is-loaded { 18368 opacity: 1; 18369 } 18370 .routes-template-list-author-field__avatar img { 18371 width: 100%; 18372 height: 100%; 18373 object-fit: cover; 18374 } 18375 18376 .routes-template-list-author-field__icon { 18377 width: 24px; 18378 height: 24px; 18379 display: flex; 18380 align-items: center; 18381 justify-content: center; 18382 margin-right: 8px; 18383 color: #757575; 18384 } 18385 18386 .routes-template-list-author-field__name { 18387 color: #1e1e1e; 18388 }`; 18389 document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css)); 18390 18391 // routes/template-list/add-new-template/style.scss 18392 var css2 = `/** 18393 * Colors 18394 */ 18395 /** 18396 * Typography 18397 */ 18398 /** 18399 * SCSS Variables. 18400 * 18401 * Please use variables from this sheet to ensure consistency across the UI. 18402 * Don't add to this sheet unless you're pretty sure the value will be reused in many places. 18403 * For example, don't add rules to this sheet that affect block visuals. It's purely for UI. 18404 */ 18405 /** 18406 * Fonts & basic variables. 18407 */ 18408 /** 18409 * Typography 18410 */ 18411 /** 18412 * Grid System. 18413 * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/ 18414 */ 18415 /** 18416 * Radius scale. 18417 */ 18418 /** 18419 * Elevation scale. 18420 */ 18421 /** 18422 * Dimensions. 18423 */ 18424 /** 18425 * Mobile specific styles 18426 */ 18427 /** 18428 * Editor styles. 18429 */ 18430 /** 18431 * Block & Editor UI. 18432 */ 18433 /** 18434 * Block paddings. 18435 */ 18436 /** 18437 * React Native specific. 18438 * These variables do not appear to be used anywhere else. 18439 */ 18440 /** 18441 * Breakpoints & Media Queries 18442 */ 18443 /** 18444 * Converts a hex value into the rgb equivalent. 18445 * 18446 * @param {string} hex - the hexadecimal value to convert 18447 * @return {string} comma separated rgb values 18448 */ 18449 /** 18450 * Long content fade mixin 18451 * 18452 * Creates a fading overlay to signify that the content is longer 18453 * than the space allows. 18454 */ 18455 /** 18456 * Breakpoint mixins 18457 */ 18458 /** 18459 * Focus styles. 18460 */ 18461 /** 18462 * Applies editor left position to the selector passed as argument 18463 */ 18464 /** 18465 * Styles that are reused verbatim in a few places 18466 */ 18467 /** 18468 * Allows users to opt-out of animations via OS-level preferences. 18469 */ 18470 /** 18471 * Reset default styles for JavaScript UI based pages. 18472 * This is a WP-admin agnostic reset 18473 */ 18474 /** 18475 * Reset the WP Admin page styles for Gutenberg-like pages. 18476 */ 18477 .template-list-custom-template-modal__contents-wrapper { 18478 height: 100%; 18479 justify-content: flex-start !important; 18480 } 18481 .template-list-custom-template-modal__contents-wrapper > * { 18482 width: 100%; 18483 } 18484 .template-list-custom-template-modal__contents-wrapper__suggestions_list { 18485 margin-left: -12px; 18486 margin-right: -12px; 18487 width: calc(100% + 24px); 18488 } 18489 .template-list-custom-template-modal__contents > .components-button { 18490 height: auto; 18491 justify-content: center; 18492 } 18493 @media (min-width: 782px) { 18494 .template-list-custom-template-modal { 18495 width: 456px; 18496 } 18497 } 18498 @media (min-width: 600px) { 18499 .template-list-custom-template-modal .template-list-custom-template-modal__suggestions_list { 18500 max-height: 224px; 18501 overflow-y: auto; 18502 } 18503 } 18504 .template-list-custom-template-modal .template-list-custom-template-modal__suggestions_list__list-item { 18505 display: block; 18506 width: 100%; 18507 text-align: left; 18508 white-space: pre-wrap; 18509 overflow-wrap: break-word; 18510 height: auto; 18511 padding: 8px 12px; 18512 } 18513 .template-list-custom-template-modal .template-list-custom-template-modal__suggestions_list__list-item mark { 18514 font-weight: 700; 18515 background: none; 18516 } 18517 .template-list-custom-template-modal .template-list-custom-template-modal__suggestions_list__list-item:hover { 18518 background: rgba(var(--wp-admin-theme-color--rgb), 0.04); 18519 } 18520 .template-list-custom-template-modal .template-list-custom-template-modal__suggestions_list__list-item:hover * { 18521 color: var(--wp-admin-theme-color); 18522 } 18523 .template-list-custom-template-modal .template-list-custom-template-modal__suggestions_list__list-item:hover mark { 18524 color: var(--wp-admin-theme-color); 18525 } 18526 .template-list-custom-template-modal .template-list-custom-template-modal__suggestions_list__list-item:focus { 18527 background-color: #f0f0f0; 18528 } 18529 .template-list-custom-template-modal .template-list-custom-template-modal__suggestions_list__list-item:focus:not(:disabled) { 18530 box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color) inset; 18531 } 18532 .template-list-custom-template-modal .template-list-custom-template-modal__suggestions_list__list-item__title, .template-list-custom-template-modal .template-list-custom-template-modal__suggestions_list__list-item__info { 18533 overflow: hidden; 18534 text-overflow: ellipsis; 18535 display: block; 18536 } 18537 .template-list-custom-template-modal .template-list-custom-template-modal__suggestions_list__list-item__info { 18538 word-break: break-all; 18539 color: #757575; 18540 } 18541 18542 .template-list-custom-template-modal__no-results { 18543 border: 1px solid #ccc; 18544 border-radius: 2px; 18545 padding: 16px; 18546 } 18547 18548 .template-list-custom-generic-template__modal .components-modal__header { 18549 border-bottom: none; 18550 } 18551 .template-list-custom-generic-template__modal .components-modal__content::before { 18552 margin-bottom: 4px; 18553 } 18554 18555 @media (min-width: 960px) { 18556 .template-list-add-new-template__modal { 18557 max-width: 832px; 18558 margin-top: 64px; 18559 width: calc(100% - 128px); 18560 max-height: calc(100% - 128px); 18561 } 18562 } 18563 .template-list-add-new-template__modal .template-list-add-new-template__template-button svg, 18564 .template-list-add-new-template__modal .template-list-add-new-template__custom-template-button svg { 18565 fill: var(--wp-admin-theme-color); 18566 } 18567 .template-list-add-new-template__modal .template-list-add-new-template__custom-template-button .template-list-add-new-template__template-name { 18568 flex-grow: 1; 18569 align-items: flex-start; 18570 } 18571 .template-list-add-new-template__modal .template-list-add-new-template__template-icon { 18572 padding: 8px; 18573 background: rgba(var(--wp-admin-theme-color--rgb), 0.04); 18574 border-radius: 100%; 18575 max-height: 40px; 18576 max-width: 40px; 18577 } 18578 18579 .template-list-custom-template-modal__contents > .components-button, 18580 .template-list-add-new-template__template-list__contents > .components-button { 18581 padding: 32px; 18582 display: flex; 18583 flex-direction: column; 18584 border: 1px solid #ddd; 18585 justify-content: center; 18586 outline: 1px solid transparent; 18587 } 18588 .template-list-custom-template-modal__contents > .components-button span:first-child, 18589 .template-list-add-new-template__template-list__contents > .components-button span:first-child { 18590 color: #1e1e1e; 18591 } 18592 .template-list-custom-template-modal__contents > .components-button span, 18593 .template-list-add-new-template__template-list__contents > .components-button span { 18594 color: #757575; 18595 } 18596 .template-list-custom-template-modal__contents > .components-button:hover, 18597 .template-list-add-new-template__template-list__contents > .components-button:hover { 18598 color: var(--wp-admin-theme-color-darker-10); 18599 background: rgba(var(--wp-admin-theme-color--rgb), 0.04); 18600 border-color: transparent; 18601 } 18602 .template-list-custom-template-modal__contents > .components-button:hover span, 18603 .template-list-add-new-template__template-list__contents > .components-button:hover span { 18604 color: var(--wp-admin-theme-color); 18605 } 18606 .template-list-custom-template-modal__contents > .components-button:focus, 18607 .template-list-add-new-template__template-list__contents > .components-button:focus { 18608 box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); 18609 border-color: transparent; 18610 outline: 3px solid transparent; 18611 } 18612 .template-list-custom-template-modal__contents > .components-button:focus span:first-child, 18613 .template-list-add-new-template__template-list__contents > .components-button:focus span:first-child { 18614 color: var(--wp-admin-theme-color); 18615 } 18616 .template-list-custom-template-modal__contents .template-list-add-new-template__custom-template-button, 18617 .template-list-custom-template-modal__contents .template-list-add-new-template__template-list__prompt, 18618 .template-list-add-new-template__template-list__contents .template-list-add-new-template__custom-template-button, 18619 .template-list-add-new-template__template-list__contents .template-list-add-new-template__template-list__prompt { 18620 grid-column: 1/-1; 18621 } 18622 18623 .template-list-add-new-template__template-list__contents > .components-button { 18624 height: 100%; 18625 text-align: start; 18626 align-items: flex-start; 18627 }`; 18628 document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css2)); 18629 18630 // routes/template-list/stage.tsx 18631 var { usePostActions, templateTitleField } = unlock2(import_editor.privateApis); 18632 var { Tabs } = unlock2(import_components57.privateApis); 18633 function getItemId(item) { 18634 return item.id.toString(); 18635 } 18636 function TemplateList() { 18637 const invalidate = useInvalidate2(); 18638 const { activeView = "active" } = useParams({ 18639 from: "/templates/list/$activeView" 18640 }); 18641 const navigate = useNavigate2(); 18642 const searchParams = useSearch({ from: "/templates/list/$activeView" }); 18643 const postTypeObject = (0, import_data13.useSelect)( 18644 (select2) => select2(import_core_data9.store).getPostType("wp_template"), 18645 [] 18646 ); 18647 const [selectedRegisteredTemplate, setSelectedRegisteredTemplate] = (0, import_element61.useState)(null); 18648 const defaultView = (0, import_element61.useMemo)(() => { 18649 return getDefaultView(activeView); 18650 }, [activeView]); 18651 const handleQueryParamsChange = (0, import_element61.useCallback)( 18652 (params) => { 18653 navigate({ 18654 search: { 18655 ...searchParams, 18656 ...params 18657 } 18658 }); 18659 }, 18660 [searchParams, navigate] 18661 ); 18662 const { view, isModified, updateView, resetToDefault } = useView({ 18663 kind: "postType", 18664 name: "wp_template", 18665 slug: activeView, 18666 defaultView, 18667 queryParams: searchParams, 18668 onChangeQueryParams: handleQueryParamsChange 18669 }); 18670 const onReset = () => { 18671 resetToDefault(); 18672 invalidate(); 18673 }; 18674 const onChangeView = (newView) => { 18675 updateView(newView); 18676 if (newView.type !== view.type) { 18677 invalidate(); 18678 } 18679 }; 18680 const { records, isLoading, staticRecords } = useTemplates(activeView); 18681 const users = (0, import_data13.useSelect)( 18682 (select2) => { 18683 const { getUser } = select2(import_core_data9.store); 18684 return records.reduce((acc, record) => { 18685 if (record.author_text) { 18686 if (!acc[record.author_text]) { 18687 acc[record.author_text] = record.author_text; 18688 } 18689 } else if (record.author) { 18690 if (!acc[record.author]) { 18691 acc[record.author] = getUser(record.author); 18692 } 18693 } 18694 return acc; 18695 }, {}); 18696 }, 18697 [records] 18698 ); 18699 const fields = (0, import_element61.useMemo)(() => { 18700 const elements = []; 18701 for (const author in users) { 18702 elements.push({ 18703 value: users[author]?.id ?? author, 18704 label: users[author]?.name ?? author 18705 }); 18706 } 18707 return [ 18708 previewField, 18709 templateTitleField, 18710 descriptionField, 18711 activeField, 18712 slugField, 18713 { 18714 ...authorField, 18715 elements 18716 } 18717 ]; 18718 }, [users]); 18719 const { data: posts, paginationInfo } = (0, import_element61.useMemo)(() => { 18720 return filterSortAndPaginate(records, view, fields); 18721 }, [records, view, fields]); 18722 const cleanupDeletedPostIdsFromUrl = (0, import_element61.useCallback)( 18723 (deletedItems) => { 18724 const deletedIds = deletedItems.map( 18725 (item) => item.id.toString() 18726 ); 18727 const currentPostIds = searchParams.postIds || []; 18728 const remainingPostIds = currentPostIds.filter( 18729 (id) => !deletedIds.includes(id) 18730 ); 18731 if (remainingPostIds.length !== currentPostIds.length) { 18732 navigate({ 18733 search: { 18734 ...searchParams, 18735 postIds: remainingPostIds.length > 0 ? remainingPostIds : void 0 18736 } 18737 }); 18738 } else { 18739 invalidate(); 18740 } 18741 }, 18742 [invalidate, searchParams, navigate] 18743 ); 18744 const onActionPerformed = (0, import_element61.useCallback)( 18745 (actionId, items) => { 18746 if (actionId === "move-to-trash" || actionId === "permanently-delete") { 18747 cleanupDeletedPostIdsFromUrl(items); 18748 } 18749 if (actionId === "duplicate-post") { 18750 navigate({ 18751 to: `/templates/list/user` 18752 }); 18753 } 18754 }, 18755 [cleanupDeletedPostIdsFromUrl, navigate] 18756 ); 18757 const setActiveTemplateAction = useSetActiveTemplateAction(); 18758 const postTypeActions = usePostActions({ 18759 postType: "wp_template", 18760 context: "list", 18761 onActionPerformed 18762 }); 18763 const actions = (0, import_element61.useMemo)(() => { 18764 return [ 18765 setActiveTemplateAction, 18766 ...postTypeActions?.flatMap((action) => { 18767 if (action.id === "view-post-revisions") { 18768 return []; 18769 } 18770 return [action]; 18771 }) 18772 ]; 18773 }, [setActiveTemplateAction, postTypeActions]); 18774 const tabs = (0, import_element61.useMemo)(() => { 18775 const baseTabs = [ 18776 { 18777 slug: "active", 18778 label: (0, import_i18n52.__)("Active"), 18779 icon: published_default 18780 }, 18781 { 18782 slug: "user", 18783 label: (0, import_i18n52.__)("Created templates"), 18784 icon: comment_author_avatar_default 18785 } 18786 ]; 18787 const authorMap = /* @__PURE__ */ new Map(); 18788 staticRecords.forEach((record) => { 18789 if (record.author_text && !authorMap.has(record.author_text)) { 18790 authorMap.set(record.author_text, { 18791 slug: record.author_text, 18792 label: record.author_text 18793 }); 18794 } 18795 }); 18796 const authorTabs = Array.from(authorMap.values()); 18797 return [...baseTabs, ...authorTabs]; 18798 }, [staticRecords]); 18799 const handleTabChange = (0, import_element61.useCallback)( 18800 (viewSlug) => { 18801 navigate({ 18802 to: `/templates/list/$viewSlug}` 18803 }); 18804 }, 18805 [navigate] 18806 ); 18807 if (!postTypeObject) { 18808 return null; 18809 } 18810 const selection = searchParams.postIds ?? []; 18811 if (view.type === "list" && selection.length === 0 && posts?.length > 0) { 18812 selection.push(posts[0].id.toString()); 18813 } 18814 if (view.type === "list") { 18815 selection.splice(1); 18816 } 18817 const duplicateAction = actions.find( 18818 (action) => action.id === "duplicate-post" 18819 ); 18820 if (duplicateAction && !("RenderModal" in duplicateAction)) { 18821 throw new Error( 18822 "Expected duplicate action to have a RenderModal component" 18823 ); 18824 } 18825 return /* @__PURE__ */ React.createElement( 18826 page_default2, 18827 { 18828 title: (0, import_i18n52.__)("Templates"), 18829 className: "template-page", 18830 actions: /* @__PURE__ */ React.createElement(React.Fragment, null, isModified && /* @__PURE__ */ React.createElement( 18831 import_components57.Button, 18832 { 18833 variant: "tertiary", 18834 size: "compact", 18835 onClick: onReset 18836 }, 18837 (0, import_i18n52.__)("Reset view") 18838 ), /* @__PURE__ */ React.createElement(add_new_template_default, null)), 18839 hasPadding: false 18840 }, 18841 tabs.length > 1 && /* @__PURE__ */ React.createElement("div", { className: "routes-template-list__tabs-wrapper" }, /* @__PURE__ */ React.createElement( 18842 Tabs, 18843 { 18844 onSelect: handleTabChange, 18845 selectedTabId: activeView ?? "active" 18846 }, 18847 /* @__PURE__ */ React.createElement(Tabs.TabList, null, tabs.map((tab) => /* @__PURE__ */ React.createElement(Tabs.Tab, { tabId: tab.slug, key: tab.slug }, tab.label))) 18848 )), 18849 /* @__PURE__ */ React.createElement( 18850 dataviews_default, 18851 { 18852 data: posts, 18853 fields, 18854 view, 18855 onChangeView, 18856 actions, 18857 isLoading, 18858 paginationInfo, 18859 defaultLayouts: DEFAULT_LAYOUTS, 18860 getItemId, 18861 selection, 18862 onChangeSelection: (items) => { 18863 navigate({ 18864 search: { 18865 ...searchParams, 18866 postIds: items.length > 0 ? items : void 0, 18867 edit: items.length === 0 ? void 0 : searchParams.edit 18868 } 18869 }); 18870 }, 18871 isItemClickable: () => true, 18872 onClickItem: (item) => { 18873 if (typeof item.id === "string") { 18874 setSelectedRegisteredTemplate(item); 18875 } else { 18876 navigate({ 18877 to: `/types/wp_template/edit/$encodeURIComponent( 18878 item.id 18879 )}` 18880 }); 18881 } 18882 } 18883 } 18884 ), 18885 selectedRegisteredTemplate && duplicateAction && /* @__PURE__ */ React.createElement( 18886 import_components57.Modal, 18887 { 18888 title: (0, import_i18n52.__)("Duplicate"), 18889 onRequestClose: () => setSelectedRegisteredTemplate(null), 18890 size: "small" 18891 }, 18892 /* @__PURE__ */ React.createElement( 18893 duplicateAction.RenderModal, 18894 { 18895 items: [selectedRegisteredTemplate], 18896 closeModal: () => setSelectedRegisteredTemplate(null) 18897 } 18898 ) 18899 ) 18900 ); 18901 } 18902 var stage = TemplateList; 18903 export { 18904 stage 18905 }; 18906 /*! Bundled license information: 18907 18908 use-sync-external-store/cjs/use-sync-external-store-shim.development.js: 18909 (** 18910 * @license React 18911 * use-sync-external-store-shim.development.js 18912 * 18913 * Copyright (c) Meta Platforms, Inc. and affiliates. 18914 * 18915 * This source code is licensed under the MIT license found in the 18916 * LICENSE file in the root directory of this source tree. 18917 *) 18918 */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Wed May 6 08:20:15 2026 | Cross-referenced by PHPXref |