@42-central/ui-react 0.28.0 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/{chunk-I53TMAV2.js → chunk-2RQLPN4U.js} +3 -3
  2. package/dist/{chunk-I53TMAV2.js.map → chunk-2RQLPN4U.js.map} +1 -1
  3. package/dist/{chunk-SOUDKESO.js → chunk-37HYN7PC.js} +3 -3
  4. package/dist/{chunk-SOUDKESO.js.map → chunk-37HYN7PC.js.map} +1 -1
  5. package/dist/{chunk-TGGNSSOJ.js → chunk-5EOMSWNO.js} +4 -4
  6. package/dist/{chunk-TGGNSSOJ.js.map → chunk-5EOMSWNO.js.map} +1 -1
  7. package/dist/{chunk-K3FZHYJL.js → chunk-7FPSQBWB.js} +3 -3
  8. package/dist/{chunk-K3FZHYJL.js.map → chunk-7FPSQBWB.js.map} +1 -1
  9. package/dist/{chunk-WERJ44ZN.js → chunk-DTFSCR3U.js} +3 -3
  10. package/dist/{chunk-WERJ44ZN.js.map → chunk-DTFSCR3U.js.map} +1 -1
  11. package/dist/{chunk-PFZMB3US.js → chunk-FQJNQW3G.js} +3 -3
  12. package/dist/{chunk-PFZMB3US.js.map → chunk-FQJNQW3G.js.map} +1 -1
  13. package/dist/{chunk-ASKQ6N5V.js → chunk-FSPS7TVD.js} +4 -4
  14. package/dist/{chunk-ASKQ6N5V.js.map → chunk-FSPS7TVD.js.map} +1 -1
  15. package/dist/{chunk-GJFCIG34.js → chunk-GEZYGBXY.js} +5 -5
  16. package/dist/{chunk-GJFCIG34.js.map → chunk-GEZYGBXY.js.map} +1 -1
  17. package/dist/{chunk-ULF5LOBS.js → chunk-HMNXNKDA.js} +3 -3
  18. package/dist/{chunk-ULF5LOBS.js.map → chunk-HMNXNKDA.js.map} +1 -1
  19. package/dist/{chunk-NF2PBGD3.js → chunk-IANYMDKH.js} +3 -3
  20. package/dist/{chunk-NF2PBGD3.js.map → chunk-IANYMDKH.js.map} +1 -1
  21. package/dist/{chunk-QEMXXQQO.js → chunk-JKFPRQB2.js} +3 -3
  22. package/dist/{chunk-QEMXXQQO.js.map → chunk-JKFPRQB2.js.map} +1 -1
  23. package/dist/{chunk-P7SH3XWY.js → chunk-MQHD3EJE.js} +3 -3
  24. package/dist/{chunk-P7SH3XWY.js.map → chunk-MQHD3EJE.js.map} +1 -1
  25. package/dist/{chunk-IUK7OJXZ.js → chunk-OBSZ4NE2.js} +5 -4
  26. package/dist/chunk-OBSZ4NE2.js.map +1 -0
  27. package/dist/{chunk-DJ72KP32.js → chunk-OXR7BXZA.js} +3 -3
  28. package/dist/{chunk-DJ72KP32.js.map → chunk-OXR7BXZA.js.map} +1 -1
  29. package/dist/{chunk-LIZWCWED.js → chunk-PQZSTI3R.js} +3 -3
  30. package/dist/{chunk-LIZWCWED.js.map → chunk-PQZSTI3R.js.map} +1 -1
  31. package/dist/{chunk-7BY5I2RB.js → chunk-S5CQRCTF.js} +4 -4
  32. package/dist/{chunk-7BY5I2RB.js.map → chunk-S5CQRCTF.js.map} +1 -1
  33. package/dist/{chunk-BGDVUC3B.js → chunk-TUP7WXQE.js} +3 -3
  34. package/dist/{chunk-BGDVUC3B.js.map → chunk-TUP7WXQE.js.map} +1 -1
  35. package/dist/{chunk-KYVXPSNW.js → chunk-V2QZG4IT.js} +3 -3
  36. package/dist/{chunk-KYVXPSNW.js.map → chunk-V2QZG4IT.js.map} +1 -1
  37. package/dist/components/alert/index.js +1 -1
  38. package/dist/components/ambient-background/index.js +1 -1
  39. package/dist/components/app-shell/index.js +3 -3
  40. package/dist/components/avatar/index.js +2 -2
  41. package/dist/components/calendar/index.js +3 -3
  42. package/dist/components/calendar-heatmap/index.js +2 -2
  43. package/dist/components/camera/index.js +3 -3
  44. package/dist/components/carousel/index.js +2 -2
  45. package/dist/components/code-block/index.js +1 -1
  46. package/dist/components/code-block/static.js.map +1 -1
  47. package/dist/components/compare/index.js +2 -2
  48. package/dist/components/data-table/index.js +10 -10
  49. package/dist/components/date-picker/index.js +7 -7
  50. package/dist/components/drawer/index.js +3 -3
  51. package/dist/components/file-item/index.js +4 -4
  52. package/dist/components/file-preview/index.js +3 -3
  53. package/dist/components/file-upload/index.js +4 -4
  54. package/dist/components/gallery/index.js +2 -2
  55. package/dist/components/image-cropper/index.js +4 -4
  56. package/dist/components/indicator/index.js +1 -1
  57. package/dist/components/kbd/index.js +3 -3
  58. package/dist/components/lightbox/index.js +4 -4
  59. package/dist/components/menu/index.js +2 -2
  60. package/dist/components/modal/index.js +3 -3
  61. package/dist/components/multi-select/index.js +3 -3
  62. package/dist/components/overlays/index.js +4 -4
  63. package/dist/components/password-input/index.js +1 -1
  64. package/dist/components/phone-input/flag.d.ts +9 -0
  65. package/dist/components/phone-input/flag.d.ts.map +1 -0
  66. package/dist/components/phone-input/index.d.ts +4 -0
  67. package/dist/components/phone-input/index.d.ts.map +1 -0
  68. package/dist/components/phone-input/index.js +503 -0
  69. package/dist/components/phone-input/index.js.map +1 -0
  70. package/dist/components/phone-input/phone-input.d.ts +125 -0
  71. package/dist/components/phone-input/phone-input.d.ts.map +1 -0
  72. package/dist/components/phone-input/phone.d.ts +117 -0
  73. package/dist/components/phone-input/phone.d.ts.map +1 -0
  74. package/dist/components/photo-capture/index.js +5 -5
  75. package/dist/components/pills-input/index.js +3 -3
  76. package/dist/components/schedule/index.js +3 -3
  77. package/dist/components/segment-group/index.js +3 -3
  78. package/dist/components/spotlight/index.js +5 -5
  79. package/dist/components/tabs/index.js +3 -3
  80. package/dist/components/tags-input/index.js +3 -3
  81. package/dist/components/time-input/index.js +4 -4
  82. package/dist/components/timeline/index.d.ts +1 -1
  83. package/dist/components/timeline/index.d.ts.map +1 -1
  84. package/dist/components/timeline/index.js +48 -12
  85. package/dist/components/timeline/index.js.map +1 -1
  86. package/dist/components/timeline/timeline.d.ts +8 -3
  87. package/dist/components/timeline/timeline.d.ts.map +1 -1
  88. package/dist/components/tree-multi-select/index.js +3 -3
  89. package/dist/index.js +4 -4
  90. package/dist/lib/dev-warn.d.ts +1 -0
  91. package/dist/lib/dev-warn.d.ts.map +1 -1
  92. package/dist/lib/intl.d.ts +5 -0
  93. package/dist/lib/intl.d.ts.map +1 -1
  94. package/package.json +3 -1
  95. package/src/as-child.contract.test.tsx +2 -0
  96. package/src/components/phone-input/flag.tsx +86 -0
  97. package/src/components/phone-input/index.ts +14 -0
  98. package/src/components/phone-input/phone-input.test.tsx +285 -0
  99. package/src/components/phone-input/phone-input.tsx +527 -0
  100. package/src/components/phone-input/phone.test.ts +187 -0
  101. package/src/components/phone-input/phone.ts +298 -0
  102. package/src/components/timeline/index.ts +1 -0
  103. package/src/components/timeline/timeline.test.tsx +127 -4
  104. package/src/components/timeline/timeline.tsx +56 -12
  105. package/src/lib/dev-warn.ts +1 -1
  106. package/src/lib/intl-direction.test.tsx +23 -0
  107. package/src/lib/intl.tsx +8 -2
  108. package/dist/chunk-IUK7OJXZ.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/files.ts","../src/lib/open-file.ts","../src/lib/use-object-url.ts"],"names":["started","win","mimeOf"],"mappings":";;;;;;AAQA,IAAM,aAAa,CAAC,MAAA,EAAQ,YAAY,UAAA,EAAY,UAAA,EAAY,YAAY,UAAU,CAAA;AAc/E,IAAM,cAAA,GAAiB,CAAC,KAAA,EAAe,MAAA,GAAiB,cAAA,KAA2B;AAExF,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,WAAW,MAAA,CAAO,CAAC,CAAA,EAAG,KAAA,KAAU,KAAA,IAAS,GAAA,IAAQ,KAAK,CAAA,CAAE,SAAS,CAAC,CAAA;AAC/F,EAAA,MAAM,KAAA,GAAQ,OAAO,UAAA,CAAA,CAAY,KAAA,GAAQ,OAAQ,QAAA,EAAU,WAAA,CAAY,CAAC,CAAC,CAAA;AACzE,EAAA,OAAO,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ;AAAA,IACnC,KAA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;AAC5D,MAAA,QAAA,CAAS,EAAE,IAAA,EAAM,EAAA,EAAI,GAAA,EAAK,CAAA;AAC1B,MAAA,OAAO,MAAM,GAAA,CAAI,eAAA,CAAgB,GAAG,CAAA;AAAA,IACtC;AACA,IAAA,MAAM,MAAA,GAAS,IAAI,UAAA,EAAW;AAC9B,IAAA,MAAA,CAAO,SAAS,MAAM;AACpB,MAAA,IAAI,OAAO,MAAA,CAAO,MAAA,KAAW,QAAA,EAAU,QAAA,CAAS,EAAE,IAAA,EAAM,EAAA,EAAI,GAAA,EAAK,MAAA,CAAO,MAAA,EAAQ,CAAA;AAAA,IAClF,CAAA;AACA,IAAA,MAAA,CAAO,cAAc,IAAA,CAAK,KAAA,CAAM,GAAG,IAAA,CAAK,IAAA,EAAM,QAAQ,CAAC,CAAA;AACvD,IAAA,OAAO,MAAM,OAAO,KAAA,EAAM;AAAA,EAC5B,CAAA,EAAG,CAAC,IAAA,EAAM,EAAE,CAAC,CAAA;AAEb,EAAA,IAAI,IAAA,SAAa,KAAA,EAAO,IAAA,KAAS,QAAQ,KAAA,CAAM,EAAA,KAAO,EAAA,GAAK,KAAA,CAAM,GAAA,GAAM,MAAA;AACvE,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,GAAW,MAAA,GAAS,MAAA;AAC/C","file":"chunk-WERJ44ZN.js","sourcesContent":["import { DEFAULT_LOCALE } from \"./intl\"\n\n/**\n * Helpers for showing a file: its size as people read it, and what kind of\n * file it is. Plain functions, no React, so they work in a loader, a table\n * cell or a test as well as in `FileItem` and `FileUpload`, which use them.\n */\n\nconst BYTE_UNITS = [\"byte\", \"kilobyte\", \"megabyte\", \"gigabyte\", \"terabyte\", \"petabyte\"] as const\n\n/**\n * A byte count as people read it: decimal units (1 MB is 1,000,000 bytes),\n * three significant digits, in the locale's own unit names.\n *\n * formatFileSize(48_213) // \"48.2 kB\"\n * formatFileSize(48_213, \"fr-FR\") // \"48,2 ko\"\n * formatFileSize(file.size, useLocale()) // in a component, following IntlProvider\n *\n * zag's own `formatBytes` algorithm, on `Intl`. `locale` defaults to the\n * kit's `DEFAULT_LOCALE` rather than the runtime's, so the server and the\n * browser never disagree; inside a component, pass `useLocale()`.\n */\nexport const formatFileSize = (bytes: number, locale: string = DEFAULT_LOCALE): string => {\n // The largest unit the count reaches; below 1 byte (an empty file) stays in bytes.\n const exponent = Math.max(0, BYTE_UNITS.filter((_, index) => bytes >= 1000 ** index).length - 1)\n const value = Number.parseFloat((bytes / 1000 ** exponent).toPrecision(3))\n return new Intl.NumberFormat(locale, {\n style: \"unit\",\n unit: BYTE_UNITS[exponent],\n unitDisplay: \"short\",\n }).format(value)\n}\n\n/** What a file is, coarsely: enough to pick its icon. */\nexport const FILE_KINDS = [\n \"image\",\n \"video\",\n \"audio\",\n \"pdf\",\n \"text\",\n \"archive\",\n \"spreadsheet\",\n \"document\",\n \"code\",\n \"font\",\n \"other\",\n] as const\n\nexport type FileKind = (typeof FILE_KINDS)[number]\n\n/**\n * The one lookup behind `fileKind`. Three shapes of key share it, tried in\n * this order: an exact MIME type (`application/pdf`), a MIME family\n * (`image/*`), then an extension (`.csv`). The exact type comes first so a\n * specific `text/csv` is a spreadsheet before the `text/*` family makes it\n * text; extensions are last because a browser-provided type is better\n * evidence than a name, when there is one.\n */\nconst KINDS: Record<string, FileKind> = {\n // Families\n \"image/*\": \"image\",\n \"video/*\": \"video\",\n \"audio/*\": \"audio\",\n \"font/*\": \"font\",\n \"text/*\": \"text\",\n\n // PDF\n \"application/pdf\": \"pdf\",\n \".pdf\": \"pdf\",\n\n // Archives\n \"application/zip\": \"archive\",\n \"application/x-zip-compressed\": \"archive\",\n \"application/gzip\": \"archive\",\n \"application/x-gzip\": \"archive\",\n \"application/x-tar\": \"archive\",\n \"application/x-7z-compressed\": \"archive\",\n \"application/x-rar-compressed\": \"archive\",\n \"application/vnd.rar\": \"archive\",\n \".zip\": \"archive\",\n \".gz\": \"archive\",\n \".tgz\": \"archive\",\n \".tar\": \"archive\",\n \".7z\": \"archive\",\n \".rar\": \"archive\",\n\n // Spreadsheets\n \"text/csv\": \"spreadsheet\",\n \"text/tab-separated-values\": \"spreadsheet\",\n \"application/vnd.ms-excel\": \"spreadsheet\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\": \"spreadsheet\",\n \"application/vnd.oasis.opendocument.spreadsheet\": \"spreadsheet\",\n \"application/vnd.apple.numbers\": \"spreadsheet\",\n \".csv\": \"spreadsheet\",\n \".tsv\": \"spreadsheet\",\n \".xls\": \"spreadsheet\",\n \".xlsx\": \"spreadsheet\",\n \".ods\": \"spreadsheet\",\n \".numbers\": \"spreadsheet\",\n\n // Documents (word processing and slides)\n \"application/msword\": \"document\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\": \"document\",\n \"application/vnd.oasis.opendocument.text\": \"document\",\n \"application/rtf\": \"document\",\n \"text/rtf\": \"document\",\n \"application/vnd.ms-powerpoint\": \"document\",\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\": \"document\",\n \"application/vnd.oasis.opendocument.presentation\": \"document\",\n \"application/vnd.apple.pages\": \"document\",\n \"application/vnd.apple.keynote\": \"document\",\n \".doc\": \"document\",\n \".docx\": \"document\",\n \".odt\": \"document\",\n \".rtf\": \"document\",\n \".ppt\": \"document\",\n \".pptx\": \"document\",\n \".odp\": \"document\",\n \".pages\": \"document\",\n \".key\": \"document\",\n\n // Code and structured data\n \"application/json\": \"code\",\n \"application/ld+json\": \"code\",\n \"application/xml\": \"code\",\n \"text/xml\": \"code\",\n \"text/html\": \"code\",\n \"text/css\": \"code\",\n \"text/javascript\": \"code\",\n \"application/javascript\": \"code\",\n \"application/x-yaml\": \"code\",\n \"application/yaml\": \"code\",\n \"application/x-sh\": \"code\",\n \"application/sql\": \"code\",\n \".json\": \"code\",\n \".xml\": \"code\",\n \".html\": \"code\",\n \".css\": \"code\",\n \".js\": \"code\",\n \".jsx\": \"code\",\n \".ts\": \"code\",\n \".tsx\": \"code\",\n \".yml\": \"code\",\n \".yaml\": \"code\",\n \".sh\": \"code\",\n \".sql\": \"code\",\n \".py\": \"code\",\n \".c\": \"code\",\n \".h\": \"code\",\n \".cpp\": \"code\",\n \".rs\": \"code\",\n \".go\": \"code\",\n\n // Plain text by name\n \".txt\": \"text\",\n \".md\": \"text\",\n \".log\": \"text\",\n\n // Media and fonts by name, for an empty or generic type\n \".png\": \"image\",\n \".jpg\": \"image\",\n \".jpeg\": \"image\",\n \".gif\": \"image\",\n \".webp\": \"image\",\n \".avif\": \"image\",\n \".svg\": \"image\",\n \".heic\": \"image\",\n \".mp4\": \"video\",\n \".mov\": \"video\",\n \".webm\": \"video\",\n \".mkv\": \"video\",\n \".mp3\": \"audio\",\n \".wav\": \"audio\",\n \".m4a\": \"audio\",\n \".ogg\": \"audio\",\n \".flac\": \"audio\",\n \".woff\": \"font\",\n \".woff2\": \"font\",\n \".ttf\": \"font\",\n \".otf\": \"font\",\n}\n\n/** Own keys only, so a type like `\"constructor\"` can't reach `Object.prototype`. */\nconst kindOf = (key: string): FileKind | undefined =>\n Object.hasOwn(KINDS, key) ? KINDS[key] : undefined\n\n/** Types that say nothing about the content, so the name decides instead. */\nconst GENERIC_TYPES = new Set([\"\", \"application/octet-stream\", \"binary/octet-stream\"])\n\n/** `.pdf` for `\"Report.FINAL.PDF\"`, `\"\"` for a name without an extension. */\nexport const extensionOf = (name: string): string => {\n const dot = name.lastIndexOf(\".\")\n return dot > 0 ? name.slice(dot).toLowerCase() : \"\"\n}\n\n/**\n * The kind of a file, from its MIME type, or from its name's extension when\n * the type is missing or generic. Browsers often report `\"\"` for a `.csv`\n * or a `.docx`, and servers send `application/octet-stream`.\n *\n * fileKind(\"application/pdf\") // \"pdf\"\n * fileKind(\"\", \"grades.csv\") // \"spreadsheet\"\n * fileKind(file.type, file.name) // a picked File\n */\nexport const fileKind = (type = \"\", name = \"\"): FileKind => {\n const mime = type.toLowerCase().split(\";\")[0]?.trim() ?? \"\"\n const typed = GENERIC_TYPES.has(mime)\n ? undefined\n : (kindOf(mime) ?? kindOf(`${mime.split(\"/\")[0]}/*`))\n return typed ?? kindOf(extensionOf(name)) ?? \"other\"\n}\n","import { match } from \"ts-pattern\"\nimport { extensionOf, fileKind } from \"./files\"\nimport { saveFile } from \"./save-file\"\n\n/**\n * Opening a file in a new browser tab, safely: the one \"pre-open a tab, point\n * it at the file\" the kit and its apps share, plus the allowlist that decides\n * what a browser may render at all.\n *\n * Never a network request: a Blob is shown through an object URL, and a URL is\n * handed to the tab. Fetching with a token or asking for a presigned link is\n * the app's job, in the function `openFile` takes.\n */\n\n// ---------------------------------------------------------------------------\n// The allowlist\n// ---------------------------------------------------------------------------\n\n/**\n * Why there is an allowlist: an object URL has the APP's origin. An uploaded\n * `.html` or `.svg` loaded from one, in a frame or a tab, runs its script as\n * the app: stored XSS. Measured in Chromium and WebKit (Playwright), a blob of\n * HTML ran with the page's origin when typed `text/html`, and SVG markup when\n * typed `image/svg+xml`, `application/xml` or `text/xml`. WebKit went further:\n * it sniffed HTML out of a blob typed `application/octet-stream`, `\"\"` or\n * `application/zip` and ran it, so re-typing a file as \"binary\" is no defence.\n *\n * What held in both engines: the same markup re-typed as `application/pdf`,\n * `text/plain`, a raster image, a video or an audio type stayed inert. So the\n * kit never trusts a file's own type for rendering. It picks one of the types\n * below and re-wraps the Blob under it (`blob.slice(0, size, type)`), and a\n * file that maps to none of them is never rendered or navigated to: it is\n * saved instead, through a `download` link, which stayed inert everywhere.\n */\nconst RASTER: Record<string, string> = {\n \"image/png\": \"image/png\",\n \"image/jpeg\": \"image/jpeg\",\n \"image/gif\": \"image/gif\",\n \"image/webp\": \"image/webp\",\n \"image/avif\": \"image/avif\",\n \"image/bmp\": \"image/bmp\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".bmp\": \"image/bmp\",\n}\n\nconst MEDIA: Record<string, string> = {\n \"video/mp4\": \"video/mp4\",\n \"video/webm\": \"video/webm\",\n \"video/ogg\": \"video/ogg\",\n \"video/quicktime\": \"video/quicktime\",\n \"audio/mpeg\": \"audio/mpeg\",\n \"audio/mp4\": \"audio/mp4\",\n \"audio/aac\": \"audio/aac\",\n \"audio/wav\": \"audio/wav\",\n \"audio/x-wav\": \"audio/wav\",\n \"audio/ogg\": \"audio/ogg\",\n \"audio/webm\": \"audio/webm\",\n \"audio/flac\": \"audio/flac\",\n \".mp4\": \"video/mp4\",\n \".m4v\": \"video/mp4\",\n \".webm\": \"video/webm\",\n \".mov\": \"video/quicktime\",\n \".ogv\": \"video/ogg\",\n \".mp3\": \"audio/mpeg\",\n \".m4a\": \"audio/mp4\",\n \".aac\": \"audio/aac\",\n \".wav\": \"audio/wav\",\n \".ogg\": \"audio/ogg\",\n \".oga\": \"audio/ogg\",\n \".flac\": \"audio/flac\",\n}\n\n/** Text a tab may show as plain text: never markup, which could be sniffed or parsed. */\nconst PLAIN_TEXT: Record<string, true> = {\n \"text/plain\": true,\n \"text/markdown\": true,\n \"text/csv\": true,\n \"text/tab-separated-values\": true,\n \"application/json\": true,\n \".txt\": true,\n \".md\": true,\n \".log\": true,\n \".csv\": true,\n \".tsv\": true,\n \".json\": true,\n}\n\n/** The kit's one text type: re-typed so a tab shows the characters, never parses them. */\nconst TEXT_TYPE = \"text/plain;charset=utf-8\"\n\n/** Own keys only, so a type like `\"constructor\"` can't reach `Object.prototype`. */\nconst lookup = <T>(table: Record<string, T>, key: string): T | undefined =>\n Object.hasOwn(table, key) ? table[key] : undefined\n\nconst mimeOf = (type: string) => type.toLowerCase().split(\";\")[0]?.trim() ?? \"\"\n\n/**\n * The type a browser may render a file under, from the kit's allowlist, or\n * `undefined` when it must not be rendered: saved, never shown.\n *\n * viewableType(\"application/pdf\", \"contract.pdf\") // \"application/pdf\"\n * viewableType(\"\", \"scan.JPG\") // \"image/jpeg\"\n * viewableType(\"text/csv\", \"grades.csv\") // \"text/plain;charset=utf-8\"\n * viewableType(\"text/html\", \"contract.pdf\") // undefined: the type says HTML\n * viewableType(\"image/svg+xml\", \"logo.svg\") // undefined: SVG runs script\n *\n * The kind comes from `fileKind`, so a specific type wins over the name, and\n * the name decides for a missing or generic type. The result is always one of\n * a fixed set (PDF, PNG/JPEG/GIF/WebP/AVIF/BMP, common video and audio types,\n * plain text), never the file's own type passed through. Re-wrap the Blob\n * under it before making an object URL:\n *\n * const safe = viewableType(file.type, file.name)\n * if (safe) url = URL.createObjectURL(file.slice(0, file.size, safe))\n */\nexport const viewableType = (type = \"\", name = \"\"): string | undefined => {\n const mime = mimeOf(type)\n const extension = extensionOf(name)\n // The specific type first, like `fileKind`; the extension only for a type that says nothing.\n const pick = <T>(table: Record<string, T>) => lookup(table, mime) ?? lookup(table, extension)\n return match(fileKind(type, name))\n .with(\"pdf\", () => \"application/pdf\")\n .with(\"image\", () => pick(RASTER))\n .with(\"video\", \"audio\", () => pick(MEDIA))\n .with(\"text\", \"spreadsheet\", \"code\", () => (pick(PLAIN_TEXT) ? TEXT_TYPE : undefined))\n .otherwise(() => undefined)\n}\n\n// ---------------------------------------------------------------------------\n// openFile\n// ---------------------------------------------------------------------------\n\n/**\n * How often an open tab is checked, in milliseconds: 2 s. The object URL is\n * revoked at the first check that finds the tab closed or showing something\n * else. Browsers throttle timers in a background tab (Chrome to once a\n * minute after five minutes), which only delays the revoke: nothing breaks.\n */\nexport const OPEN_FILE_POLL = 2_000\n\n/**\n * The longest an object URL is kept for an open tab, in milliseconds: one hour.\n * After it the tab still shows the file, but reloading it, or saving it from\n * the browser's PDF viewer, fails. A safety net for a tab left open all day:\n * the Blob stays in memory as long as its URL lives. Closing or reloading the\n * app's own page revokes every object URL it made, whatever this says.\n */\nexport const OPEN_FILE_MAX_AGE = 3_600_000\n\n/** What can be opened: a Blob (or File), or a URL. */\nexport type OpenFileData = Blob | string\n\n/** Resolves the file on click. `signal` is `options.signal`, when there is one. */\nexport type OpenFileLoader = (context: {\n signal: AbortSignal\n}) => OpenFileData | Promise<OpenFileData>\n\nexport type OpenFileOptions = {\n /** The file name: the tab's title while it loads, the saved file's name, and, with\n * `type`, what decides whether the file may be shown. A File's own name by default. */\n name?: string\n /** The MIME type, when the Blob's own is missing, or for a URL. */\n type?: string\n /** Aborts a pending function: the tab closes and the promise rejects. */\n signal?: AbortSignal\n}\n\n/** `\"opened\"` in a tab, or `\"saved\"`: the popup was blocked, or the file isn't allowed in one. */\nexport type OpenFileResult = \"opened\" | \"saved\"\n\n/** Where the tab goes: the Blob under its allowlisted type, or a URL to follow. */\ntype Target = { blob: Blob; type: string } | { url: string }\n\nconst isSameOrigin = (url: URL) =>\n url.protocol === \"blob:\" || url.protocol === \"data:\" || url.origin === window.location.origin\n\n/** The last path segment of a URL, as a fallback name. */\nconst lastSegment = (url: URL) =>\n decodeURIComponent(url.pathname.split(\"/\").filter(Boolean).at(-1) ?? \"\")\n\n/**\n * Where a tab may go for `data`, or `undefined` to save it instead.\n *\n * - **A Blob** only under its `viewableType`, re-wrapped.\n * - **A cross-origin URL** (a presigned S3 link) always: whatever it serves runs\n * with its own origin, not the app's, and the tab has no `opener`.\n * - **A same-origin URL** only when its `type` or name is viewable. The server's\n * `Content-Type` decides what the browser does then, so it must be honest.\n * - **A `blob:` or `data:` string** never: its real type can't be checked. Pass the\n * Blob itself.\n */\nconst targetOf = (data: OpenFileData, name: string, type: string): Target | undefined => {\n if (typeof data !== \"string\") {\n const safe = viewableType(type || data.type, name)\n return safe ? { blob: data, type: safe } : undefined\n }\n const url = new URL(data, window.location.href)\n if (url.protocol === \"blob:\" || url.protocol === \"data:\") return undefined\n if (!isSameOrigin(url)) return { url: url.href }\n return viewableType(type, name || lastSegment(url)) ? { url: url.href } : undefined\n}\n\n/** Reads the tab's address, or `undefined` once it has left for another origin. */\nconst addressOf = (win: Window): string | undefined => {\n try {\n return win.location.href\n } catch {\n return undefined\n }\n}\n\n/**\n * Keeps an object URL alive while its tab shows it. Revoked when the tab is\n * closed, navigates away (including to another origin, where its address can't\n * be read), or after `OPEN_FILE_MAX_AGE`. `about:blank` counts as still\n * loading: the navigation is asynchronous, and revoking during it would break\n * the very load it waits for.\n */\nconst watch = (win: Window, url: string) => {\n const started = Date.now()\n const timer = setInterval(() => {\n const address = win.closed ? undefined : addressOf(win)\n const showing = address === url || address === \"about:blank\"\n if (showing && Date.now() - started < OPEN_FILE_MAX_AGE) return\n clearInterval(timer)\n URL.revokeObjectURL(url)\n }, OPEN_FILE_POLL)\n}\n\n/** Points the tab at the file, replacing its blank page in history. A Blob is re-wrapped\n * under its allowlisted type first, so the type it claims never reaches the browser. */\nconst show = (win: Window, target: Target) => {\n if (\"url\" in target) return win.location.replace(target.url)\n const url = URL.createObjectURL(target.blob.slice(0, target.blob.size, target.type))\n win.location.replace(url)\n watch(win, url)\n}\n\n/** A blank tab, cut off from this page, or `null` when a popup blocker stopped it. */\nconst blankTab = (name: string): Window | null => {\n const win = window.open(\"\", \"_blank\")\n if (!win || win.closed) return null\n // Before anything loads: the tab can't reach back into the app. Not `noopener` in\n // `window.open`, which would hand back `null` and leave nothing to point at the file.\n win.opener = null\n try {\n // The tab's title while a slow function resolves, rather than \"Untitled\".\n if (name) win.document.title = name\n } catch {\n // A browser that gave the blank tab its own origin: the title is cosmetic.\n }\n return win\n}\n\n/** Calls the loader inside the click, and treats a synchronous throw as a rejection. */\nconst started = (load: OpenFileLoader, signal: AbortSignal): Promise<OpenFileData> => {\n try {\n return Promise.resolve(load({ signal }))\n } catch (error) {\n return Promise.reject(error)\n }\n}\n\nconst nameOf = (data: OpenFileData, name: string | undefined) =>\n name ?? (typeof data !== \"string\" && data instanceof File ? data.name : \"\")\n\n/**\n * Opens a file in a new tab: a Blob, a URL, or what a function of yours\n * resolves to. Call it in a click handler.\n *\n * openFile(file) // a picked File\n * openFile(presignedUrl, { name: \"consent.pdf\" })\n * openFile(({ signal }) => api.blob(`/documents/${id}`, { signal }), { name: \"contract.pdf\" })\n *\n * - **Popup-safe.** The tab opens synchronously, inside the click, before a\n * function is called; browsers block a popup opened after an `await`. It\n * shows the file once the promise resolves, and closes if it rejects.\n * - **Blocked popup → saved.** When the browser blocks the tab, the file is\n * saved with `saveFile` instead, and the promise resolves `\"saved\"`.\n * - **Only safe types are shown.** A file outside the allowlist (`viewableType`:\n * PDF, raster images, common video and audio, plain text) is saved, never\n * navigated to, so an uploaded HTML or SVG can't run as the app. A Blob is\n * re-wrapped under the allowlisted type, whatever type it claims.\n * - **The object URL lives as long as the tab shows it**, so saving from the\n * browser's PDF viewer and reloading keep working: it is revoked once the tab\n * closes or navigates away, and after `OPEN_FILE_MAX_AGE` (an hour) at most.\n *\n * The tab's title is the PDF's own `Title` metadata when it has one, and the\n * object URL's id otherwise: have your PDF generator set the title. Hosting the\n * PDF in a titled page of our own would fix the title, but it breaks reloading\n * the tab and shows only the first page on iOS.\n *\n * Rejects when the function rejects or `signal` aborts, after closing the tab.\n */\nexport const openFile = (\n source: OpenFileData | OpenFileLoader,\n options: OpenFileOptions = {},\n): Promise<OpenFileResult> => {\n if (typeof window === \"undefined\") {\n return Promise.reject(new Error(\"openFile runs in a browser, in a click handler.\"))\n }\n const type = options.type ?? \"\"\n\n // A value is decided now: a file that can't be shown never opens a tab at all.\n if (typeof source !== \"function\") {\n const name = nameOf(source, options.name)\n const target = targetOf(source, name, type)\n const win = target && blankTab(name)\n if (!target || !win) {\n saveFile(source, name || undefined, { type: options.type })\n return Promise.resolve(\"saved\")\n }\n show(win, target)\n return Promise.resolve(\"opened\")\n }\n\n // A function: the tab opens now, while the click still allows it.\n const signal = options.signal ?? new AbortController().signal\n const win = blankTab(options.name ?? \"\")\n const aborted = () => Promise.reject(signal.reason)\n if (signal.aborted) {\n win?.close()\n return aborted()\n }\n return started(source, signal).then(\n (data): OpenFileResult | Promise<never> => {\n if (signal.aborted) {\n win?.close()\n return aborted()\n }\n const name = nameOf(data, options.name)\n const target = win ? targetOf(data, name, type) : undefined\n if (!win || !target) {\n win?.close()\n saveFile(data, name || undefined, { type: options.type })\n return \"saved\"\n }\n show(win, target)\n return \"opened\"\n },\n (error: unknown) => {\n win?.close()\n throw error\n },\n )\n}\n","\"use client\"\n\nimport { useEffect, useState } from \"react\"\nimport { extensionOf, fileKind } from \"./files\"\nimport { viewableType } from \"./open-file\"\n\n/**\n * The largest SVG `useObjectUrl` shows, in bytes: 5 MB. An SVG is shown from\n * a `data:` URL, which lives as a JavaScript string (a third larger than the\n * file, in base64) and again as the `<img>`'s attribute, for every mounted\n * thumbnail. Past this an SVG gets no URL, so the caller's fallback shows: an\n * icon in FileItem, the download panel in FilePreview.\n */\nexport const SVG_DATA_URL_LIMIT = 5_000_000\n\nconst SVG_TYPE = \"image/svg+xml\"\n\nconst mimeOf = (type: string) => type.toLowerCase().split(\";\")[0]?.trim() ?? \"\"\n\n/**\n * The type a file may be shown under IN the page, or `undefined` for none:\n * `viewableType`'s, or SVG, which `useObjectUrl` draws from a `data:` URL and\n * never from an object URL. SVG when the type says so, or, for a missing or\n * generic type, the name does; at most `SVG_DATA_URL_LIMIT` bytes.\n *\n * inlineType(\"image/png\", \"scan.png\") // \"image/png\"\n * inlineType(\"\", \"logo.svg\", 2_000) // \"image/svg+xml\": a data: URL\n * inlineType(\"text/html\", \"logo.svg\") // undefined: the type says HTML\n */\nexport const inlineType = (type = \"\", name = \"\", size = 0): string | undefined => {\n const safe = viewableType(type, name)\n if (safe) return safe\n const svg =\n fileKind(type, name) === \"image\" && (mimeOf(type) === SVG_TYPE || extensionOf(name) === \".svg\")\n return svg && size <= SVG_DATA_URL_LIMIT ? SVG_TYPE : undefined\n}\n\nexport type UseObjectUrlOptions = {\n /** The file name, when the type is missing or generic. A File's own name by default. */\n name?: string\n /** The MIME type, in place of the Blob's own. */\n type?: string\n}\n\ntype Entry = { blob: Blob; as: string; url: string }\n\n/**\n * A URL an `<img>`, `<video>` or `<object>` can load for `source`, safe to put\n * in the page. A string passes through untouched. A `Blob` (a `File` from an\n * input or a drop) is shown only under a type the kit allows, never the type\n * it claims:\n *\n * - **PDF, raster images, common video and audio, plain text** (`viewableType`):\n * an object URL for the Blob re-wrapped under that type, revoked when the\n * source changes or the component unmounts.\n * - **SVG**, up to `SVG_DATA_URL_LIMIT`: a `data:` URL.\n * - **Anything else**: `undefined`, so nothing is shown.\n *\n * const url = useObjectUrl(file)\n * <img src={url} alt=\"\" />\n *\n * Why: an object URL has the app's origin. \"Open image in new tab\" (or\n * dragging the image to the tab bar, or copying its address) navigates to it,\n * and an uploaded `.svg` or `.html` there runs its script as the app, even\n * though the `<img>` itself never would. Under an allowlisted type the bytes\n * are inert, and a `data:` URL's document has an opaque origin. WebKit sniffs\n * HTML out of `application/octet-stream`, `\"\"` and `application/zip`, so no\n * \"binary\" type is safe: an unknown file gets no URL at all. See\n * `viewableType`, and the security section of FilePreview's docs.\n *\n * The URL is created in an effect, never during render: render may run twice\n * (Strict Mode, a discarded concurrent render) and only an effect's cleanup is\n * guaranteed to pair with it, so nothing leaks. That makes a `Blob` source\n * `undefined` for its first render (an SVG's until it's read), and on the\n * server, where object URLs don't exist anyway.\n *\n * The URL is remembered beside the blob it was made for, so the render after\n * a source change never hands out the previous blob's URL, already revoked by\n * the time it would load.\n */\nexport function useObjectUrl(\n source: string | Blob | null | undefined,\n options: UseObjectUrlOptions = {},\n): string | undefined {\n const [entry, setEntry] = useState<Entry>()\n const blob = source instanceof Blob ? source : undefined\n const name = options.name ?? (blob instanceof File ? blob.name : \"\")\n const as = blob ? inlineType(options.type || blob.type, name, blob.size) : undefined\n\n useEffect(() => {\n if (!blob || !as) return\n if (as !== SVG_TYPE) {\n // Re-wrapped, so the type the file claims never reaches the browser.\n const url = URL.createObjectURL(blob.slice(0, blob.size, as))\n setEntry({ blob, as, url })\n return () => URL.revokeObjectURL(url)\n }\n const reader = new FileReader()\n reader.onload = () => {\n if (typeof reader.result === \"string\") setEntry({ blob, as, url: reader.result })\n }\n reader.readAsDataURL(blob.slice(0, blob.size, SVG_TYPE))\n return () => reader.abort()\n }, [blob, as])\n\n if (blob) return entry?.blob === blob && entry.as === as ? entry.url : undefined\n return typeof source === \"string\" ? source : undefined\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/files.ts","../src/lib/open-file.ts","../src/lib/use-object-url.ts"],"names":["started","win","mimeOf"],"mappings":";;;;;;AAQA,IAAM,aAAa,CAAC,MAAA,EAAQ,YAAY,UAAA,EAAY,UAAA,EAAY,YAAY,UAAU,CAAA;AAc/E,IAAM,cAAA,GAAiB,CAAC,KAAA,EAAe,MAAA,GAAiB,cAAA,KAA2B;AAExF,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,WAAW,MAAA,CAAO,CAAC,CAAA,EAAG,KAAA,KAAU,KAAA,IAAS,GAAA,IAAQ,KAAK,CAAA,CAAE,SAAS,CAAC,CAAA;AAC/F,EAAA,MAAM,KAAA,GAAQ,OAAO,UAAA,CAAA,CAAY,KAAA,GAAQ,OAAQ,QAAA,EAAU,WAAA,CAAY,CAAC,CAAC,CAAA;AACzE,EAAA,OAAO,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ;AAAA,IACnC,KAAA,EAAO,MAAA;AAAA,IACP,IAAA,EAAM,WAAW,QAAQ,CAAA;AAAA,IACzB,WAAA,EAAa;AAAA,GACd,CAAA,CAAE,MAAA,CAAO,KAAK,CAAA;AACjB;AAGO,IAAM,UAAA,GAAa;AAAA,EACxB,OAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF;AAYA,IAAM,KAAA,GAAkC;AAAA;AAAA,EAEtC,SAAA,EAAW,OAAA;AAAA,EACX,SAAA,EAAW,OAAA;AAAA,EACX,SAAA,EAAW,OAAA;AAAA,EACX,QAAA,EAAU,MAAA;AAAA,EACV,QAAA,EAAU,MAAA;AAAA;AAAA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AA,EAAM;AAAA,EAC5B,CAAA,EAAG,CAAC,IAAA,EAAM,EAAE,CAAC,CAAA;AAEb,EAAA,IAAI,IAAA,SAAa,KAAA,EAAO,IAAA,KAAS,QAAQ,KAAA,CAAM,EAAA,KAAO,EAAA,GAAK,KAAA,CAAM,GAAA,GAAM,MAAA;AACvE,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,GAAW,MAAA,GAAS,MAAA;AAC/C","file":"chunk-DTFSCR3U.js","sourcesContent":["import { DEFAULT_LOCALE } from \"./intl\"\n\n/**\n * Helpers for showing a file: its size as people read it, and what kind of\n * file it is. Plain functions, no React, so they work in a loader, a table\n * cell or a test as well as in `FileItem` and `FileUpload`, which use them.\n */\n\nconst BYTE_UNITS = [\"byte\", \"kilobyte\", \"megabyte\", \"gigabyte\", \"terabyte\", \"petabyte\"] as const\n\n/**\n * A byte count as people read it: decimal units (1 MB is 1,000,000 bytes),\n * three significant digits, in the locale's own unit names.\n *\n * formatFileSize(48_213) // \"48.2 kB\"\n * formatFileSize(48_213, \"fr-FR\") // \"48,2 ko\"\n * formatFileSize(file.size, useLocale()) // in a component, following IntlProvider\n *\n * zag's own `formatBytes` algorithm, on `Intl`. `locale` defaults to the\n * kit's `DEFAULT_LOCALE` rather than the runtime's, so the server and the\n * browser never disagree; inside a component, pass `useLocale()`.\n */\nexport const formatFileSize = (bytes: number, locale: string = DEFAULT_LOCALE): string => {\n // The largest unit the count reaches; below 1 byte (an empty file) stays in bytes.\n const exponent = Math.max(0, BYTE_UNITS.filter((_, index) => bytes >= 1000 ** index).length - 1)\n const value = Number.parseFloat((bytes / 1000 ** exponent).toPrecision(3))\n return new Intl.NumberFormat(locale, {\n style: \"unit\",\n unit: BYTE_UNITS[exponent],\n unitDisplay: \"short\",\n }).format(value)\n}\n\n/** What a file is, coarsely: enough to pick its icon. */\nexport const FILE_KINDS = [\n \"image\",\n \"video\",\n \"audio\",\n \"pdf\",\n \"text\",\n \"archive\",\n \"spreadsheet\",\n \"document\",\n \"code\",\n \"font\",\n \"other\",\n] as const\n\nexport type FileKind = (typeof FILE_KINDS)[number]\n\n/**\n * The one lookup behind `fileKind`. Three shapes of key share it, tried in\n * this order: an exact MIME type (`application/pdf`), a MIME family\n * (`image/*`), then an extension (`.csv`). The exact type comes first so a\n * specific `text/csv` is a spreadsheet before the `text/*` family makes it\n * text; extensions are last because a browser-provided type is better\n * evidence than a name, when there is one.\n */\nconst KINDS: Record<string, FileKind> = {\n // Families\n \"image/*\": \"image\",\n \"video/*\": \"video\",\n \"audio/*\": \"audio\",\n \"font/*\": \"font\",\n \"text/*\": \"text\",\n\n // PDF\n \"application/pdf\": \"pdf\",\n \".pdf\": \"pdf\",\n\n // Archives\n \"application/zip\": \"archive\",\n \"application/x-zip-compressed\": \"archive\",\n \"application/gzip\": \"archive\",\n \"application/x-gzip\": \"archive\",\n \"application/x-tar\": \"archive\",\n \"application/x-7z-compressed\": \"archive\",\n \"application/x-rar-compressed\": \"archive\",\n \"application/vnd.rar\": \"archive\",\n \".zip\": \"archive\",\n \".gz\": \"archive\",\n \".tgz\": \"archive\",\n \".tar\": \"archive\",\n \".7z\": \"archive\",\n \".rar\": \"archive\",\n\n // Spreadsheets\n \"text/csv\": \"spreadsheet\",\n \"text/tab-separated-values\": \"spreadsheet\",\n \"application/vnd.ms-excel\": \"spreadsheet\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\": \"spreadsheet\",\n \"application/vnd.oasis.opendocument.spreadsheet\": \"spreadsheet\",\n \"application/vnd.apple.numbers\": \"spreadsheet\",\n \".csv\": \"spreadsheet\",\n \".tsv\": \"spreadsheet\",\n \".xls\": \"spreadsheet\",\n \".xlsx\": \"spreadsheet\",\n \".ods\": \"spreadsheet\",\n \".numbers\": \"spreadsheet\",\n\n // Documents (word processing and slides)\n \"application/msword\": \"document\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\": \"document\",\n \"application/vnd.oasis.opendocument.text\": \"document\",\n \"application/rtf\": \"document\",\n \"text/rtf\": \"document\",\n \"application/vnd.ms-powerpoint\": \"document\",\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\": \"document\",\n \"application/vnd.oasis.opendocument.presentation\": \"document\",\n \"application/vnd.apple.pages\": \"document\",\n \"application/vnd.apple.keynote\": \"document\",\n \".doc\": \"document\",\n \".docx\": \"document\",\n \".odt\": \"document\",\n \".rtf\": \"document\",\n \".ppt\": \"document\",\n \".pptx\": \"document\",\n \".odp\": \"document\",\n \".pages\": \"document\",\n \".key\": \"document\",\n\n // Code and structured data\n \"application/json\": \"code\",\n \"application/ld+json\": \"code\",\n \"application/xml\": \"code\",\n \"text/xml\": \"code\",\n \"text/html\": \"code\",\n \"text/css\": \"code\",\n \"text/javascript\": \"code\",\n \"application/javascript\": \"code\",\n \"application/x-yaml\": \"code\",\n \"application/yaml\": \"code\",\n \"application/x-sh\": \"code\",\n \"application/sql\": \"code\",\n \".json\": \"code\",\n \".xml\": \"code\",\n \".html\": \"code\",\n \".css\": \"code\",\n \".js\": \"code\",\n \".jsx\": \"code\",\n \".ts\": \"code\",\n \".tsx\": \"code\",\n \".yml\": \"code\",\n \".yaml\": \"code\",\n \".sh\": \"code\",\n \".sql\": \"code\",\n \".py\": \"code\",\n \".c\": \"code\",\n \".h\": \"code\",\n \".cpp\": \"code\",\n \".rs\": \"code\",\n \".go\": \"code\",\n\n // Plain text by name\n \".txt\": \"text\",\n \".md\": \"text\",\n \".log\": \"text\",\n\n // Media and fonts by name, for an empty or generic type\n \".png\": \"image\",\n \".jpg\": \"image\",\n \".jpeg\": \"image\",\n \".gif\": \"image\",\n \".webp\": \"image\",\n \".avif\": \"image\",\n \".svg\": \"image\",\n \".heic\": \"image\",\n \".mp4\": \"video\",\n \".mov\": \"video\",\n \".webm\": \"video\",\n \".mkv\": \"video\",\n \".mp3\": \"audio\",\n \".wav\": \"audio\",\n \".m4a\": \"audio\",\n \".ogg\": \"audio\",\n \".flac\": \"audio\",\n \".woff\": \"font\",\n \".woff2\": \"font\",\n \".ttf\": \"font\",\n \".otf\": \"font\",\n}\n\n/** Own keys only, so a type like `\"constructor\"` can't reach `Object.prototype`. */\nconst kindOf = (key: string): FileKind | undefined =>\n Object.hasOwn(KINDS, key) ? KINDS[key] : undefined\n\n/** Types that say nothing about the content, so the name decides instead. */\nconst GENERIC_TYPES = new Set([\"\", \"application/octet-stream\", \"binary/octet-stream\"])\n\n/** `.pdf` for `\"Report.FINAL.PDF\"`, `\"\"` for a name without an extension. */\nexport const extensionOf = (name: string): string => {\n const dot = name.lastIndexOf(\".\")\n return dot > 0 ? name.slice(dot).toLowerCase() : \"\"\n}\n\n/**\n * The kind of a file, from its MIME type, or from its name's extension when\n * the type is missing or generic. Browsers often report `\"\"` for a `.csv`\n * or a `.docx`, and servers send `application/octet-stream`.\n *\n * fileKind(\"application/pdf\") // \"pdf\"\n * fileKind(\"\", \"grades.csv\") // \"spreadsheet\"\n * fileKind(file.type, file.name) // a picked File\n */\nexport const fileKind = (type = \"\", name = \"\"): FileKind => {\n const mime = type.toLowerCase().split(\";\")[0]?.trim() ?? \"\"\n const typed = GENERIC_TYPES.has(mime)\n ? undefined\n : (kindOf(mime) ?? kindOf(`${mime.split(\"/\")[0]}/*`))\n return typed ?? kindOf(extensionOf(name)) ?? \"other\"\n}\n","import { match } from \"ts-pattern\"\nimport { extensionOf, fileKind } from \"./files\"\nimport { saveFile } from \"./save-file\"\n\n/**\n * Opening a file in a new browser tab, safely: the one \"pre-open a tab, point\n * it at the file\" the kit and its apps share, plus the allowlist that decides\n * what a browser may render at all.\n *\n * Never a network request: a Blob is shown through an object URL, and a URL is\n * handed to the tab. Fetching with a token or asking for a presigned link is\n * the app's job, in the function `openFile` takes.\n */\n\n// ---------------------------------------------------------------------------\n// The allowlist\n// ---------------------------------------------------------------------------\n\n/**\n * Why there is an allowlist: an object URL has the APP's origin. An uploaded\n * `.html` or `.svg` loaded from one, in a frame or a tab, runs its script as\n * the app: stored XSS. Measured in Chromium and WebKit (Playwright), a blob of\n * HTML ran with the page's origin when typed `text/html`, and SVG markup when\n * typed `image/svg+xml`, `application/xml` or `text/xml`. WebKit went further:\n * it sniffed HTML out of a blob typed `application/octet-stream`, `\"\"` or\n * `application/zip` and ran it, so re-typing a file as \"binary\" is no defence.\n *\n * What held in both engines: the same markup re-typed as `application/pdf`,\n * `text/plain`, a raster image, a video or an audio type stayed inert. So the\n * kit never trusts a file's own type for rendering. It picks one of the types\n * below and re-wraps the Blob under it (`blob.slice(0, size, type)`), and a\n * file that maps to none of them is never rendered or navigated to: it is\n * saved instead, through a `download` link, which stayed inert everywhere.\n */\nconst RASTER: Record<string, string> = {\n \"image/png\": \"image/png\",\n \"image/jpeg\": \"image/jpeg\",\n \"image/gif\": \"image/gif\",\n \"image/webp\": \"image/webp\",\n \"image/avif\": \"image/avif\",\n \"image/bmp\": \"image/bmp\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".bmp\": \"image/bmp\",\n}\n\nconst MEDIA: Record<string, string> = {\n \"video/mp4\": \"video/mp4\",\n \"video/webm\": \"video/webm\",\n \"video/ogg\": \"video/ogg\",\n \"video/quicktime\": \"video/quicktime\",\n \"audio/mpeg\": \"audio/mpeg\",\n \"audio/mp4\": \"audio/mp4\",\n \"audio/aac\": \"audio/aac\",\n \"audio/wav\": \"audio/wav\",\n \"audio/x-wav\": \"audio/wav\",\n \"audio/ogg\": \"audio/ogg\",\n \"audio/webm\": \"audio/webm\",\n \"audio/flac\": \"audio/flac\",\n \".mp4\": \"video/mp4\",\n \".m4v\": \"video/mp4\",\n \".webm\": \"video/webm\",\n \".mov\": \"video/quicktime\",\n \".ogv\": \"video/ogg\",\n \".mp3\": \"audio/mpeg\",\n \".m4a\": \"audio/mp4\",\n \".aac\": \"audio/aac\",\n \".wav\": \"audio/wav\",\n \".ogg\": \"audio/ogg\",\n \".oga\": \"audio/ogg\",\n \".flac\": \"audio/flac\",\n}\n\n/** Text a tab may show as plain text: never markup, which could be sniffed or parsed. */\nconst PLAIN_TEXT: Record<string, true> = {\n \"text/plain\": true,\n \"text/markdown\": true,\n \"text/csv\": true,\n \"text/tab-separated-values\": true,\n \"application/json\": true,\n \".txt\": true,\n \".md\": true,\n \".log\": true,\n \".csv\": true,\n \".tsv\": true,\n \".json\": true,\n}\n\n/** The kit's one text type: re-typed so a tab shows the characters, never parses them. */\nconst TEXT_TYPE = \"text/plain;charset=utf-8\"\n\n/** Own keys only, so a type like `\"constructor\"` can't reach `Object.prototype`. */\nconst lookup = <T>(table: Record<string, T>, key: string): T | undefined =>\n Object.hasOwn(table, key) ? table[key] : undefined\n\nconst mimeOf = (type: string) => type.toLowerCase().split(\";\")[0]?.trim() ?? \"\"\n\n/**\n * The type a browser may render a file under, from the kit's allowlist, or\n * `undefined` when it must not be rendered: saved, never shown.\n *\n * viewableType(\"application/pdf\", \"contract.pdf\") // \"application/pdf\"\n * viewableType(\"\", \"scan.JPG\") // \"image/jpeg\"\n * viewableType(\"text/csv\", \"grades.csv\") // \"text/plain;charset=utf-8\"\n * viewableType(\"text/html\", \"contract.pdf\") // undefined: the type says HTML\n * viewableType(\"image/svg+xml\", \"logo.svg\") // undefined: SVG runs script\n *\n * The kind comes from `fileKind`, so a specific type wins over the name, and\n * the name decides for a missing or generic type. The result is always one of\n * a fixed set (PDF, PNG/JPEG/GIF/WebP/AVIF/BMP, common video and audio types,\n * plain text), never the file's own type passed through. Re-wrap the Blob\n * under it before making an object URL:\n *\n * const safe = viewableType(file.type, file.name)\n * if (safe) url = URL.createObjectURL(file.slice(0, file.size, safe))\n */\nexport const viewableType = (type = \"\", name = \"\"): string | undefined => {\n const mime = mimeOf(type)\n const extension = extensionOf(name)\n // The specific type first, like `fileKind`; the extension only for a type that says nothing.\n const pick = <T>(table: Record<string, T>) => lookup(table, mime) ?? lookup(table, extension)\n return match(fileKind(type, name))\n .with(\"pdf\", () => \"application/pdf\")\n .with(\"image\", () => pick(RASTER))\n .with(\"video\", \"audio\", () => pick(MEDIA))\n .with(\"text\", \"spreadsheet\", \"code\", () => (pick(PLAIN_TEXT) ? TEXT_TYPE : undefined))\n .otherwise(() => undefined)\n}\n\n// ---------------------------------------------------------------------------\n// openFile\n// ---------------------------------------------------------------------------\n\n/**\n * How often an open tab is checked, in milliseconds: 2 s. The object URL is\n * revoked at the first check that finds the tab closed or showing something\n * else. Browsers throttle timers in a background tab (Chrome to once a\n * minute after five minutes), which only delays the revoke: nothing breaks.\n */\nexport const OPEN_FILE_POLL = 2_000\n\n/**\n * The longest an object URL is kept for an open tab, in milliseconds: one hour.\n * After it the tab still shows the file, but reloading it, or saving it from\n * the browser's PDF viewer, fails. A safety net for a tab left open all day:\n * the Blob stays in memory as long as its URL lives. Closing or reloading the\n * app's own page revokes every object URL it made, whatever this says.\n */\nexport const OPEN_FILE_MAX_AGE = 3_600_000\n\n/** What can be opened: a Blob (or File), or a URL. */\nexport type OpenFileData = Blob | string\n\n/** Resolves the file on click. `signal` is `options.signal`, when there is one. */\nexport type OpenFileLoader = (context: {\n signal: AbortSignal\n}) => OpenFileData | Promise<OpenFileData>\n\nexport type OpenFileOptions = {\n /** The file name: the tab's title while it loads, the saved file's name, and, with\n * `type`, what decides whether the file may be shown. A File's own name by default. */\n name?: string\n /** The MIME type, when the Blob's own is missing, or for a URL. */\n type?: string\n /** Aborts a pending function: the tab closes and the promise rejects. */\n signal?: AbortSignal\n}\n\n/** `\"opened\"` in a tab, or `\"saved\"`: the popup was blocked, or the file isn't allowed in one. */\nexport type OpenFileResult = \"opened\" | \"saved\"\n\n/** Where the tab goes: the Blob under its allowlisted type, or a URL to follow. */\ntype Target = { blob: Blob; type: string } | { url: string }\n\nconst isSameOrigin = (url: URL) =>\n url.protocol === \"blob:\" || url.protocol === \"data:\" || url.origin === window.location.origin\n\n/** The last path segment of a URL, as a fallback name. */\nconst lastSegment = (url: URL) =>\n decodeURIComponent(url.pathname.split(\"/\").filter(Boolean).at(-1) ?? \"\")\n\n/**\n * Where a tab may go for `data`, or `undefined` to save it instead.\n *\n * - **A Blob** only under its `viewableType`, re-wrapped.\n * - **A cross-origin URL** (a presigned S3 link) always: whatever it serves runs\n * with its own origin, not the app's, and the tab has no `opener`.\n * - **A same-origin URL** only when its `type` or name is viewable. The server's\n * `Content-Type` decides what the browser does then, so it must be honest.\n * - **A `blob:` or `data:` string** never: its real type can't be checked. Pass the\n * Blob itself.\n */\nconst targetOf = (data: OpenFileData, name: string, type: string): Target | undefined => {\n if (typeof data !== \"string\") {\n const safe = viewableType(type || data.type, name)\n return safe ? { blob: data, type: safe } : undefined\n }\n const url = new URL(data, window.location.href)\n if (url.protocol === \"blob:\" || url.protocol === \"data:\") return undefined\n if (!isSameOrigin(url)) return { url: url.href }\n return viewableType(type, name || lastSegment(url)) ? { url: url.href } : undefined\n}\n\n/** Reads the tab's address, or `undefined` once it has left for another origin. */\nconst addressOf = (win: Window): string | undefined => {\n try {\n return win.location.href\n } catch {\n return undefined\n }\n}\n\n/**\n * Keeps an object URL alive while its tab shows it. Revoked when the tab is\n * closed, navigates away (including to another origin, where its address can't\n * be read), or after `OPEN_FILE_MAX_AGE`. `about:blank` counts as still\n * loading: the navigation is asynchronous, and revoking during it would break\n * the very load it waits for.\n */\nconst watch = (win: Window, url: string) => {\n const started = Date.now()\n const timer = setInterval(() => {\n const address = win.closed ? undefined : addressOf(win)\n const showing = address === url || address === \"about:blank\"\n if (showing && Date.now() - started < OPEN_FILE_MAX_AGE) return\n clearInterval(timer)\n URL.revokeObjectURL(url)\n }, OPEN_FILE_POLL)\n}\n\n/** Points the tab at the file, replacing its blank page in history. A Blob is re-wrapped\n * under its allowlisted type first, so the type it claims never reaches the browser. */\nconst show = (win: Window, target: Target) => {\n if (\"url\" in target) return win.location.replace(target.url)\n const url = URL.createObjectURL(target.blob.slice(0, target.blob.size, target.type))\n win.location.replace(url)\n watch(win, url)\n}\n\n/** A blank tab, cut off from this page, or `null` when a popup blocker stopped it. */\nconst blankTab = (name: string): Window | null => {\n const win = window.open(\"\", \"_blank\")\n if (!win || win.closed) return null\n // Before anything loads: the tab can't reach back into the app. Not `noopener` in\n // `window.open`, which would hand back `null` and leave nothing to point at the file.\n win.opener = null\n try {\n // The tab's title while a slow function resolves, rather than \"Untitled\".\n if (name) win.document.title = name\n } catch {\n // A browser that gave the blank tab its own origin: the title is cosmetic.\n }\n return win\n}\n\n/** Calls the loader inside the click, and treats a synchronous throw as a rejection. */\nconst started = (load: OpenFileLoader, signal: AbortSignal): Promise<OpenFileData> => {\n try {\n return Promise.resolve(load({ signal }))\n } catch (error) {\n return Promise.reject(error)\n }\n}\n\nconst nameOf = (data: OpenFileData, name: string | undefined) =>\n name ?? (typeof data !== \"string\" && data instanceof File ? data.name : \"\")\n\n/**\n * Opens a file in a new tab: a Blob, a URL, or what a function of yours\n * resolves to. Call it in a click handler.\n *\n * openFile(file) // a picked File\n * openFile(presignedUrl, { name: \"consent.pdf\" })\n * openFile(({ signal }) => api.blob(`/documents/${id}`, { signal }), { name: \"contract.pdf\" })\n *\n * - **Popup-safe.** The tab opens synchronously, inside the click, before a\n * function is called; browsers block a popup opened after an `await`. It\n * shows the file once the promise resolves, and closes if it rejects.\n * - **Blocked popup → saved.** When the browser blocks the tab, the file is\n * saved with `saveFile` instead, and the promise resolves `\"saved\"`.\n * - **Only safe types are shown.** A file outside the allowlist (`viewableType`:\n * PDF, raster images, common video and audio, plain text) is saved, never\n * navigated to, so an uploaded HTML or SVG can't run as the app. A Blob is\n * re-wrapped under the allowlisted type, whatever type it claims.\n * - **The object URL lives as long as the tab shows it**, so saving from the\n * browser's PDF viewer and reloading keep working: it is revoked once the tab\n * closes or navigates away, and after `OPEN_FILE_MAX_AGE` (an hour) at most.\n *\n * The tab's title is the PDF's own `Title` metadata when it has one, and the\n * object URL's id otherwise: have your PDF generator set the title. Hosting the\n * PDF in a titled page of our own would fix the title, but it breaks reloading\n * the tab and shows only the first page on iOS.\n *\n * Rejects when the function rejects or `signal` aborts, after closing the tab.\n */\nexport const openFile = (\n source: OpenFileData | OpenFileLoader,\n options: OpenFileOptions = {},\n): Promise<OpenFileResult> => {\n if (typeof window === \"undefined\") {\n return Promise.reject(new Error(\"openFile runs in a browser, in a click handler.\"))\n }\n const type = options.type ?? \"\"\n\n // A value is decided now: a file that can't be shown never opens a tab at all.\n if (typeof source !== \"function\") {\n const name = nameOf(source, options.name)\n const target = targetOf(source, name, type)\n const win = target && blankTab(name)\n if (!target || !win) {\n saveFile(source, name || undefined, { type: options.type })\n return Promise.resolve(\"saved\")\n }\n show(win, target)\n return Promise.resolve(\"opened\")\n }\n\n // A function: the tab opens now, while the click still allows it.\n const signal = options.signal ?? new AbortController().signal\n const win = blankTab(options.name ?? \"\")\n const aborted = () => Promise.reject(signal.reason)\n if (signal.aborted) {\n win?.close()\n return aborted()\n }\n return started(source, signal).then(\n (data): OpenFileResult | Promise<never> => {\n if (signal.aborted) {\n win?.close()\n return aborted()\n }\n const name = nameOf(data, options.name)\n const target = win ? targetOf(data, name, type) : undefined\n if (!win || !target) {\n win?.close()\n saveFile(data, name || undefined, { type: options.type })\n return \"saved\"\n }\n show(win, target)\n return \"opened\"\n },\n (error: unknown) => {\n win?.close()\n throw error\n },\n )\n}\n","\"use client\"\n\nimport { useEffect, useState } from \"react\"\nimport { extensionOf, fileKind } from \"./files\"\nimport { viewableType } from \"./open-file\"\n\n/**\n * The largest SVG `useObjectUrl` shows, in bytes: 5 MB. An SVG is shown from\n * a `data:` URL, which lives as a JavaScript string (a third larger than the\n * file, in base64) and again as the `<img>`'s attribute, for every mounted\n * thumbnail. Past this an SVG gets no URL, so the caller's fallback shows: an\n * icon in FileItem, the download panel in FilePreview.\n */\nexport const SVG_DATA_URL_LIMIT = 5_000_000\n\nconst SVG_TYPE = \"image/svg+xml\"\n\nconst mimeOf = (type: string) => type.toLowerCase().split(\";\")[0]?.trim() ?? \"\"\n\n/**\n * The type a file may be shown under IN the page, or `undefined` for none:\n * `viewableType`'s, or SVG, which `useObjectUrl` draws from a `data:` URL and\n * never from an object URL. SVG when the type says so, or, for a missing or\n * generic type, the name does; at most `SVG_DATA_URL_LIMIT` bytes.\n *\n * inlineType(\"image/png\", \"scan.png\") // \"image/png\"\n * inlineType(\"\", \"logo.svg\", 2_000) // \"image/svg+xml\": a data: URL\n * inlineType(\"text/html\", \"logo.svg\") // undefined: the type says HTML\n */\nexport const inlineType = (type = \"\", name = \"\", size = 0): string | undefined => {\n const safe = viewableType(type, name)\n if (safe) return safe\n const svg =\n fileKind(type, name) === \"image\" && (mimeOf(type) === SVG_TYPE || extensionOf(name) === \".svg\")\n return svg && size <= SVG_DATA_URL_LIMIT ? SVG_TYPE : undefined\n}\n\nexport type UseObjectUrlOptions = {\n /** The file name, when the type is missing or generic. A File's own name by default. */\n name?: string\n /** The MIME type, in place of the Blob's own. */\n type?: string\n}\n\ntype Entry = { blob: Blob; as: string; url: string }\n\n/**\n * A URL an `<img>`, `<video>` or `<object>` can load for `source`, safe to put\n * in the page. A string passes through untouched. A `Blob` (a `File` from an\n * input or a drop) is shown only under a type the kit allows, never the type\n * it claims:\n *\n * - **PDF, raster images, common video and audio, plain text** (`viewableType`):\n * an object URL for the Blob re-wrapped under that type, revoked when the\n * source changes or the component unmounts.\n * - **SVG**, up to `SVG_DATA_URL_LIMIT`: a `data:` URL.\n * - **Anything else**: `undefined`, so nothing is shown.\n *\n * const url = useObjectUrl(file)\n * <img src={url} alt=\"\" />\n *\n * Why: an object URL has the app's origin. \"Open image in new tab\" (or\n * dragging the image to the tab bar, or copying its address) navigates to it,\n * and an uploaded `.svg` or `.html` there runs its script as the app, even\n * though the `<img>` itself never would. Under an allowlisted type the bytes\n * are inert, and a `data:` URL's document has an opaque origin. WebKit sniffs\n * HTML out of `application/octet-stream`, `\"\"` and `application/zip`, so no\n * \"binary\" type is safe: an unknown file gets no URL at all. See\n * `viewableType`, and the security section of FilePreview's docs.\n *\n * The URL is created in an effect, never during render: render may run twice\n * (Strict Mode, a discarded concurrent render) and only an effect's cleanup is\n * guaranteed to pair with it, so nothing leaks. That makes a `Blob` source\n * `undefined` for its first render (an SVG's until it's read), and on the\n * server, where object URLs don't exist anyway.\n *\n * The URL is remembered beside the blob it was made for, so the render after\n * a source change never hands out the previous blob's URL, already revoked by\n * the time it would load.\n */\nexport function useObjectUrl(\n source: string | Blob | null | undefined,\n options: UseObjectUrlOptions = {},\n): string | undefined {\n const [entry, setEntry] = useState<Entry>()\n const blob = source instanceof Blob ? source : undefined\n const name = options.name ?? (blob instanceof File ? blob.name : \"\")\n const as = blob ? inlineType(options.type || blob.type, name, blob.size) : undefined\n\n useEffect(() => {\n if (!blob || !as) return\n if (as !== SVG_TYPE) {\n // Re-wrapped, so the type the file claims never reaches the browser.\n const url = URL.createObjectURL(blob.slice(0, blob.size, as))\n setEntry({ blob, as, url })\n return () => URL.revokeObjectURL(url)\n }\n const reader = new FileReader()\n reader.onload = () => {\n if (typeof reader.result === \"string\") setEntry({ blob, as, url: reader.result })\n }\n reader.readAsDataURL(blob.slice(0, blob.size, SVG_TYPE))\n return () => reader.abort()\n }, [blob, as])\n\n if (blob) return entry?.blob === blob && entry.as === as ? entry.url : undefined\n return typeof source === \"string\" ? source : undefined\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { PillGroupContext, pill } from './chunk-6M6YZ3PQ.js';
2
2
  import { inputSlot, inputShell, inputControlClasses } from './chunk-I4B3N3UX.js';
3
3
  import { useElementSize } from './chunk-2LI3VPDP.js';
4
- import { useLocale } from './chunk-IUK7OJXZ.js';
4
+ import { useLocale } from './chunk-OBSZ4NE2.js';
5
5
  import { props } from './chunk-WYCMIIRR.js';
6
6
  import { cn } from './chunk-4ASNIDV7.js';
7
7
  import { ark } from '@ark-ui/react';
@@ -230,5 +230,5 @@ var PillsInput = Object.assign(PillsInputBase, {
230
230
  });
231
231
 
232
232
  export { PillOverflowCounter, PillsInput, pillsContent, pillsShell, usePillOverflow };
233
- //# sourceMappingURL=chunk-PFZMB3US.js.map
234
- //# sourceMappingURL=chunk-PFZMB3US.js.map
233
+ //# sourceMappingURL=chunk-FQJNQW3G.js.map
234
+ //# sourceMappingURL=chunk-FQJNQW3G.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/pills-input/pills-input.tsx"],"names":[],"mappings":";;;;;;;;;;;AAsDO,IAAM,UAAA,GAAa,GAAG,aAAa;AAMnC,IAAM,YAAA,GAAe,IAAI,2DAAA,EAA6D;AAAA,EAC3F,QAAA,EAAU;AAAA,IACR,IAAA,EAAM;AAAA,MACJ,EAAA,EAAI,SAAA;AAAA,MACJ,EAAA,EAAI,SAAA;AAAA,MACJ,EAAA,EAAI,OAAA;AAAA,MACJ,EAAA,EAAI,SAAA;AAAA,MACJ,EAAA,EAAI;AAAA;AACN,GACF;AAAA,EACA,eAAA,EAAiB,EAAE,IAAA,EAAM,IAAA;AAC3B,CAAC;AAKD,IAAM,kBAAA,GAAqB,OAAO,QAAA,KAAa,WAAA,GAAc,eAAA,GAAkB,SAAA;AAWxE,SAAS,gBAAA,CAAiB,YAAsB,QAAA,EAA0B;AAC/E,EAAA,IAAI,IAAA,GAAO,CAAA;AACX,EAAA,IAAI,UAAU,MAAA,CAAO,iBAAA;AACrB,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,UAAA,CAAW,QAAQ,CAAA,EAAA,EAAK;AAC1C,IAAA,MAAM,GAAA,GAAM,UAAA,CAAW,CAAC,CAAA,IAAK,OAAA;AAC7B,IAAA,IAAI,GAAA,GAAM,UAAU,CAAA,EAAG;AACrB,MAAA,IAAA,IAAQ,CAAA;AACR,MAAA,OAAA,GAAU,GAAA;AACV,MAAA,IAAI,OAAO,QAAA,EAAU;AAGnB,QAAA,OAAO,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,CAAA,GAAI,CAAC,CAAA;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,UAAA,CAAW,MAAA;AACpB;AAkB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AA;AAAA,GACpF,EACF,CAAA;AAEJ,CAAA;AAQA,IAAM,kBAAkB,CAAC;AAAA,EACvB,SAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,EACA,GAAG;AACL,CAAA,qBACE,GAAA;AAAA,EAAC,OAAA;AAAA,EAAA;AAAA,IAEC,qBAAA,EAAmB,IAAA;AAAA,IAGnB,SAAA,EAAW,EAAA,CAAG,mBAAA,EAAqB,iBAAA,EAAmB,SAAS,CAAA;AAAA,IAC/D,SAAA,EAAW,CAAC,KAAA,KAAU;AACpB,MAAA,IAAI,gBAAgB,KAAA,CAAM,GAAA,KAAQ,eAAe,KAAA,CAAM,aAAA,CAAc,UAAU,EAAA,EAAI;AACjF,QAAA,YAAA,EAAa;AAAA,MACf;AACA,MAAA,SAAA,GAAY,KAAK,CAAA;AAAA,IACnB,CAAA;AAAA,IACC,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,IAClC,GAAG;AAAA;AACN,CAAA;AAGK,IAAM,UAAA,GAAa,MAAA,CAAO,MAAA,CAAO,cAAA,EAAgB;AAAA,EACtD,KAAA,EAAO;AACT,CAAC","file":"chunk-PFZMB3US.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva } from \"class-variance-authority\"\nimport {\n Children,\n type ComponentPropsWithoutRef,\n cloneElement,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type RefObject,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\"\nimport type { NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { useLocale } from \"../../lib/intl\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { useElementSize } from \"../../lib/use-element-size\"\nimport {\n type InputSize,\n type InputVariant,\n inputControlClasses,\n inputShell,\n inputSlot,\n} from \"../input/input\"\nimport { PillGroupContext, type PillSize, pill } from \"../pill/pill\"\n\n/**\n * PillsInput — a multi-line input shell that lays out `Pill`s alongside a search\n * field. Same chrome as `Input` (border, focus ring, invalid / disabled states)\n * but it wraps as values accumulate. It's the visual `MultiSelect` and\n * `TagsInput` mount as their target.\n *\n * - It reuses `Input`'s slot layout: a `startSlot` / `endSlot` flank a\n * `pillsContent` region that holds the `Pill`s + the field and is the only\n * thing that wraps, so a trailing control (chevron, clear) pins to the edge\n * instead of wrapping inline with the pills.\n * - Host `Pill`s + a single `PillsInputField` inside it (pills first, field\n * last). The shell sets the pill `size` / `disabled` through context, so the\n * pills match with no prop drilling.\n * - `maxLines` caps the pills at N rows and collapses the rest into a static\n * \"+N\" counter (measured, since pills have variable widths).\n *\n * Presentational by design: the value state lives with the consumer.\n */\n\n/** The pills *row*: same single-line flex shell as `inputShell`, just text-cursor\n * for the click-to-focus affordance. Layout/wrap live on `pillsContent`. */\nexport const pillsShell = cn(\"cursor-text\")\n\n/** The wrapping region inside a pills shell — holds the pills + field, grows to\n * fill the row (`flex-1`), and is the only element that wraps, so the shell's\n * start/end slots stay pinned as `shrink-0` siblings. Gap tracks `inputShell`'s\n * per-size gap so pill spacing is unchanged from the flat layout. */\nexport const pillsContent = cva(\"flex min-w-0 flex-1 flex-wrap items-center py-1 gap-y-0.5\", {\n variants: {\n size: {\n xs: \"gap-1.5\",\n sm: \"gap-1.5\",\n md: \"gap-2\",\n lg: \"gap-2.5\",\n xl: \"gap-3\",\n },\n },\n defaultVariants: { size: \"md\" },\n})\n\n// `useLayoutEffect` measures before paint (no flash); fall back to `useEffect`\n// on the server so SSR doesn't warn. Measurement is client-only anyway — the\n// server render shows every pill, which is the correct no-cap fallback.\nconst useIsoLayoutEffect = typeof document !== \"undefined\" ? useLayoutEffect : useEffect\n\n/**\n * Pure row-grouping math behind `usePillOverflow` (exported for testing).\n *\n * Given each measured pill's `offsetTop` (in document order), count how many\n * fit within `maxLines` wrapped rows. A jump in `offsetTop` (beyond a sub-pixel\n * epsilon) marks a new row. When the pills overflow, reserve one slot on the\n * last visible row for the \"+N\" counter (it's narrower than a typical pill, so\n * dropping one always makes room).\n */\nexport function visiblePillCount(offsetTops: number[], maxLines: number): number {\n let rows = 0\n let lastTop = Number.NEGATIVE_INFINITY\n for (let i = 0; i < offsetTops.length; i++) {\n const top = offsetTops[i] ?? lastTop\n if (top - lastTop > 1) {\n rows += 1\n lastTop = top\n if (rows > maxLines) {\n // `i` begins the row past the cap — keep the rows before it, minus one\n // for the counter.\n return Math.max(0, i - 1)\n }\n }\n }\n return offsetTops.length\n}\n\n/**\n * Like `visiblePillCount`, but also keeps the trailing input field on the last\n * visible row (exported for testing).\n *\n * `visiblePillCount` only reasons about pills, so when the last visible row is\n * packed, the field — which is `min-w-16` and the last flex child — can't claim\n * its minimum width and wraps onto a new line. A flex item wraps exactly when\n * the space left on its row drops below its `min-width`, so we drop pills until\n * the last visible pill leaves room on its row for `gap + fieldMinWidth` (plus\n * the `+N` counter, once anything is hidden). Pills are passed as `{ top, end }`,\n * where `end` is how far the pill's inline-end edge sits from the row's\n * inline-start edge, and `rowEnd` is the row's inline length — logical, so the\n * same math holds in RTL, where the free space is on the pill's left. Removing a\n * trailing pill never reflows the ones before it, so each drop is checked\n * against real geometry.\n */\nexport function pillCountWithField(\n pills: { top: number; end: number }[],\n maxLines: number,\n rowEnd: number,\n trailing: { fieldMinWidth: number; counterWidth: number; gap: number },\n): number {\n const total = pills.length\n const { fieldMinWidth, counterWidth, gap } = trailing\n // Start from the pill-only cap (already reserves one slot for the counter on\n // overflow), then back off until the field's minimum fits on the last row.\n let visible = visiblePillCount(\n pills.map((p) => p.top),\n maxLines,\n )\n while (visible > 0) {\n const last = pills[visible - 1]\n if (last == null) break\n // Hiding any pill surfaces the \"+N\" counter, which shares the last row.\n const needsCounter = visible < total\n const trailingWidth = gap + fieldMinWidth + (needsCounter ? counterWidth + gap : 0)\n if (last.end + trailingWidth <= rowEnd) break\n visible--\n }\n return visible\n}\n\n/**\n * Measure how many pills fit within `maxLines` rows and how many overflow.\n *\n * Line caps are width-dependent (pills vary in width), so this measures the DOM.\n * Pills to be measured must carry `data-overflow-item`; the trailing field and\n * the counter must NOT (they would corrupt row detection) — instead the field\n * carries `data-overflow-field` and the counter `data-overflow-counter` so the\n * hook can locate and measure them without mistaking them for pills. The hook\n * renders the full set during a pre-paint \"measuring\" pass, groups pills into\n * rows, then settles on a `visibleCount` — reserving the last row for the \"+N\"\n * chip and, when a field is present, its `min-width` too, so the field never\n * wraps onto a new line (see `pillCountWithField`). Re-measures on width change\n * only (ignoring the height change our own slicing causes, which would loop).\n *\n * `measuring` is exposed so consumers can render the counter during the\n * measuring pass (it is otherwise hidden when nothing overflows), letting the\n * hook measure its real width for the last-row reservation.\n */\nexport function usePillOverflow({\n maxLines,\n count,\n}: {\n /** Cap the rendered pills at this many rows. Omit to render every pill. */\n maxLines?: number\n /** Total number of pills — drives re-measurement on add / remove. */\n count: number\n}): {\n containerRef: RefObject<HTMLDivElement | null>\n visibleCount: number\n hiddenCount: number\n measuring: boolean\n} {\n const containerRef = useRef<HTMLDivElement>(null)\n const [visibleCount, setVisibleCount] = useState(count)\n // While true, every pill is rendered so the DOM reflects the full set; flipped\n // off (pre-paint) once the cutoff is computed.\n const [measuring, setMeasuring] = useState(true)\n const lastWidth = useRef(0)\n\n // Any change to the inputs re-enters a full-render measuring pass.\n useIsoLayoutEffect(() => {\n setMeasuring(true)\n }, [count, maxLines])\n\n useIsoLayoutEffect(() => {\n if (!measuring) return\n const container = containerRef.current\n if (maxLines == null || container == null) {\n setVisibleCount(count)\n setMeasuring(false)\n return\n }\n const items = Array.from(container.querySelectorAll<HTMLElement>(\"[data-overflow-item]\"))\n lastWidth.current = container.clientWidth\n\n const fieldEl = container.querySelector<HTMLElement>(\"[data-overflow-field]\")\n if (fieldEl == null) {\n // No trailing field (e.g. TreeMultiSelect's read-only trigger) — pills +\n // counter only, the original behavior.\n setVisibleCount(\n visiblePillCount(\n items.map((el) => el.offsetTop),\n maxLines,\n ),\n )\n setMeasuring(false)\n return\n }\n\n // Field-aware: reserve the field's min width (and the counter slot) on the\n // last visible row. Measure in viewport coords via `getBoundingClientRect`\n // so pill edges and the row's edges share one coordinate space regardless\n // of `offsetParent` (the positioned shell, not this container), then turn\n // them into inline offsets from the row's start: under RTL the row fills\n // from the right, and a physical `right` would read every pill as already\n // touching the row's end.\n const style = getComputedStyle(container)\n const gap = Number.parseFloat(style.columnGap || style.gap) || 0\n const row = container.getBoundingClientRect()\n const rtl = style.direction === \"rtl\"\n const inlineEnd = (rect: DOMRect) => (rtl ? row.right - rect.left : rect.right - row.left)\n const fieldMinWidth = Number.parseFloat(getComputedStyle(fieldEl).minWidth) || 0\n const counterEl = container.querySelector<HTMLElement>(\"[data-overflow-counter]\")\n const counterWidth = counterEl?.getBoundingClientRect().width ?? 0\n const pills = items.map((el) => {\n const rect = el.getBoundingClientRect()\n return { top: rect.top, end: inlineEnd(rect) }\n })\n setVisibleCount(\n pillCountWithField(pills, maxLines, row.width, { fieldMinWidth, counterWidth, gap }),\n )\n setMeasuring(false)\n }, [measuring, count, maxLines])\n\n // Re-measure when the field's width changes (a wider field reveals more\n // pills again). Ignore height-only changes — our own slicing shrinks the\n // height and would otherwise feed back into an infinite measure loop.\n const width = useElementSize(containerRef, { enabled: maxLines != null })?.width\n useIsoLayoutEffect(() => {\n if (width === undefined || Math.abs(width - lastWidth.current) < 1) return\n lastWidth.current = width\n setMeasuring(true)\n }, [width])\n\n const resolved = maxLines == null || measuring ? count : Math.min(visibleCount, count)\n return {\n containerRef,\n visibleCount: resolved,\n hiddenCount: Math.max(0, count - resolved),\n measuring,\n }\n}\n\n/** The wording of the pill controls' \"+N\" counter — shared by `PillsInput`, `MultiSelect`,\n * `TagsInput` and `TreeMultiSelect`, each taking it on its own `translations`. */\nexport type PillsInputTranslations = {\n /** What a screen reader hears for the \"+N\" counter, instead of \"plus 3\". Gets the hidden\n * count (for plural rules) and that count formatted for the locale.\n * Default `(count, n) => \\`${n} more items\\`` (\"item\" for one). */\n overflowCount?: (count: number, formatted: string) => string\n}\n\nconst englishPlural = new Intl.PluralRules(\"en-US\")\n\nexport const PILLS_INPUT_DEFAULT_TRANSLATIONS = {\n overflowCount: (count, formatted) =>\n `${formatted} more ${englishPlural.select(count) === \"one\" ? \"item\" : \"items\"}`,\n} as const satisfies Required<PillsInputTranslations>\n\nexport type PillOverflowCounterProps = {\n /** How many pills are hidden. */\n count: number\n size?: PillSize\n className?: string\n /** The owning control's `translations`; only `overflowCount` is read. */\n translations?: PillsInputTranslations\n}\n\n/** Static \"+N\" chip the pill controls render at the end of the visible rows.\n * Non-interactive: the \"+N\" is drawn in the locale's digits and sign (`+٣` in\n * `ar-EG`) and hidden from screen readers, which read `overflowCount` instead.\n * The full set stays reachable via the dropdown (where one exists) or the\n * consumer's own state. */\nexport const PillOverflowCounter = ({\n count,\n size = \"md\",\n className,\n translations,\n}: PillOverflowCounterProps) => {\n const locale = useLocale()\n // The one key it reads; an owner forwarding `{ overflowCount: undefined }` keeps the default.\n const overflowCount =\n translations?.overflowCount ?? PILLS_INPUT_DEFAULT_TRANSLATIONS.overflowCount\n return (\n // `relative`: contains the absolutely positioned `sr-only` text.\n <span data-overflow-counter className={cn(pill({ size }), \"relative tabular-nums\", className)}>\n <span aria-hidden>\n {new Intl.NumberFormat(locale, { signDisplay: \"always\" }).format(count)}\n </span>\n <span className=\"sr-only\">\n {overflowCount(count, new Intl.NumberFormat(locale).format(count))}\n </span>\n </span>\n )\n}\n\ntype PillsInputClassNames = {\n root?: string\n content?: string\n startSlot?: string\n endSlot?: string\n}\n\nexport type PillsInputProps = NoAsChild<Omit<HTMLArkProps<\"div\">, \"color\">> &\n WithTestId & {\n size?: InputSize\n variant?: InputVariant\n color?: Color\n invalid?: boolean\n disabled?: boolean\n pointer?: boolean\n /** Cap the pills at N rows; the rest collapse into a static \"+N\" counter. */\n maxLines?: number\n /** Inline-start adornment (icon, label). */\n startSlot?: ReactNode\n /** Inline-end adornment — rendered before any trailing control. */\n endSlot?: ReactNode\n classNames?: PillsInputClassNames\n /** The \"+N\" counter's screen-reader wording — see `PillsInputTranslations`. */\n translations?: PillsInputTranslations\n }\n\n/**\n * PillsInput — the wrapping input shell for multi-value fields. Host `Pill`s\n * and a single `PillsInput.Field` inside; the shell sizes and disables them\n * through context. Presentational by design: it holds no value state.\n *\n * `testId` here lands on the shell `<div>` itself — useful when `PillsInput`\n * is used bare. `PillsInput.Field` has its own `testId`, landing on the real\n * focusable `<input>`; prefer that one when targeting the field.\n */\nconst PillsInputBase = ({\n size = \"md\",\n variant = \"default\",\n color,\n invalid,\n disabled,\n pointer,\n maxLines,\n startSlot,\n endSlot,\n className,\n classNames,\n children,\n testId,\n translations,\n asChild: _asChild,\n ...rest\n}: PillsInputProps) => {\n // Convention: pills first, the field last. Only the pills feed the line cap;\n // the field always stays visible (it is never sliced away).\n const items = Children.toArray(children)\n const field = items.length > 0 ? items[items.length - 1] : null\n const pills = items.length > 0 ? items.slice(0, -1) : []\n\n const { containerRef, visibleCount, hiddenCount, measuring } = usePillOverflow({\n maxLines,\n count: pills.length,\n })\n\n const renderedPills = (maxLines == null ? pills : pills.slice(0, visibleCount)).map((child, i) =>\n isValidElement(child)\n ? cloneElement(child as ReactElement<Record<string, unknown>>, {\n key: child.key ?? i,\n \"data-overflow-item\": true,\n })\n : child,\n )\n\n return (\n <PillGroupContext.Provider value={{ size, disabled }}>\n <ark.div\n data-color={color}\n {...props({\n \"data-invalid\": invalid,\n \"data-disabled\": disabled,\n \"data-pointer\": pointer,\n // Slot-aware padding in `inputShell` — see InputBase for the rationale.\n \"data-with-start-slot\": startSlot != null,\n \"data-with-end-slot\": endSlot != null,\n \"data-testid\": testId,\n })}\n className={cn(inputShell({ size, variant }), pillsShell, className, classNames?.root)}\n {...rest}\n >\n {startSlot != null && (\n <span className={cn(inputSlot, classNames?.startSlot)} aria-hidden>\n {startSlot}\n </span>\n )}\n <div ref={containerRef} className={cn(pillsContent({ size }), classNames?.content)}>\n {renderedPills}\n {/* Mounted during the measuring pass so the hook can size the last-row\n reservation off the real counter, but kept `invisible` then (still\n measurable) so it never paints on the SSR HTML before the first\n measure. Only mounts while measuring when a cap is configured. */}\n {(hiddenCount > 0 || (measuring && maxLines != null)) && (\n <PillOverflowCounter\n count={measuring ? pills.length : hiddenCount}\n size={size}\n className={measuring ? \"invisible\" : undefined}\n translations={translations}\n />\n )}\n {field}\n </div>\n {endSlot != null && <span className={cn(inputSlot, classNames?.endSlot)}>{endSlot}</span>}\n </ark.div>\n </PillGroupContext.Provider>\n )\n}\n\nexport type PillsInputFieldProps = ComponentPropsWithoutRef<\"input\"> &\n WithTestId & {\n /** Fired on Backspace when the field is empty — pop the last value. */\n onRemoveLast?: () => void\n }\n\nconst PillsInputField = ({\n className,\n onRemoveLast,\n onKeyDown,\n testId,\n ...rest\n}: PillsInputFieldProps) => (\n <input\n // The trailing field the overflow hook keeps on the last visible row.\n data-overflow-field\n // Grow to fill the line, but keep a clickable minimum when empty. Overrides\n // `inputControlClasses`' `w-full min-w-0` so pills can share the row.\n className={cn(inputControlClasses, \"w-auto min-w-16\", className)}\n onKeyDown={(event) => {\n if (onRemoveLast && event.key === \"Backspace\" && event.currentTarget.value === \"\") {\n onRemoveLast()\n }\n onKeyDown?.(event)\n }}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport const PillsInput = Object.assign(PillsInputBase, {\n Field: PillsInputField,\n})\n"]}
1
+ {"version":3,"sources":["../src/components/pills-input/pills-input.tsx"],"names":[],"mappings":";;;;;;;;;;;AAsDO,IAAM,UAAA,GAAa,GAAG,aAAa;AAMnC,IAAM,YAAA,GAAe,IAAI,2DAAA,EAA6D;AAAA,EAC3F,QAAA,EAAU;AAAA,IACR,IAAA,EAAM;AAAA,MACJ,EAAA,EAAI,SAAA;AAAA,MACJ,EAAA,EAAI,SAAA;AAAA,MACJ,EAAA,EAAI,OAAA;AAAA,MACJ,EAAA,EAAI,SAAA;AAAA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,QAAA,YAAA,EAAa;AAAA,MACf;AACA,MAAA,SAAA,GAAY,KAAK,CAAA;AAAA,IACnB,CAAA;AAAA,IACC,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,IAClC,GAAG;AAAA;AACN,CAAA;AAGK,IAAM,UAAA,GAAa,MAAA,CAAO,MAAA,CAAO,cAAA,EAAgB;AAAA,EACtD,KAAA,EAAO;AACT,CAAC","file":"chunk-FQJNQW3G.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva } from \"class-variance-authority\"\nimport {\n Children,\n type ComponentPropsWithoutRef,\n cloneElement,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type RefObject,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\"\nimport type { NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { useLocale } from \"../../lib/intl\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { useElementSize } from \"../../lib/use-element-size\"\nimport {\n type InputSize,\n type InputVariant,\n inputControlClasses,\n inputShell,\n inputSlot,\n} from \"../input/input\"\nimport { PillGroupContext, type PillSize, pill } from \"../pill/pill\"\n\n/**\n * PillsInput — a multi-line input shell that lays out `Pill`s alongside a search\n * field. Same chrome as `Input` (border, focus ring, invalid / disabled states)\n * but it wraps as values accumulate. It's the visual `MultiSelect` and\n * `TagsInput` mount as their target.\n *\n * - It reuses `Input`'s slot layout: a `startSlot` / `endSlot` flank a\n * `pillsContent` region that holds the `Pill`s + the field and is the only\n * thing that wraps, so a trailing control (chevron, clear) pins to the edge\n * instead of wrapping inline with the pills.\n * - Host `Pill`s + a single `PillsInputField` inside it (pills first, field\n * last). The shell sets the pill `size` / `disabled` through context, so the\n * pills match with no prop drilling.\n * - `maxLines` caps the pills at N rows and collapses the rest into a static\n * \"+N\" counter (measured, since pills have variable widths).\n *\n * Presentational by design: the value state lives with the consumer.\n */\n\n/** The pills *row*: same single-line flex shell as `inputShell`, just text-cursor\n * for the click-to-focus affordance. Layout/wrap live on `pillsContent`. */\nexport const pillsShell = cn(\"cursor-text\")\n\n/** The wrapping region inside a pills shell — holds the pills + field, grows to\n * fill the row (`flex-1`), and is the only element that wraps, so the shell's\n * start/end slots stay pinned as `shrink-0` siblings. Gap tracks `inputShell`'s\n * per-size gap so pill spacing is unchanged from the flat layout. */\nexport const pillsContent = cva(\"flex min-w-0 flex-1 flex-wrap items-center py-1 gap-y-0.5\", {\n variants: {\n size: {\n xs: \"gap-1.5\",\n sm: \"gap-1.5\",\n md: \"gap-2\",\n lg: \"gap-2.5\",\n xl: \"gap-3\",\n },\n },\n defaultVariants: { size: \"md\" },\n})\n\n// `useLayoutEffect` measures before paint (no flash); fall back to `useEffect`\n// on the server so SSR doesn't warn. Measurement is client-only anyway — the\n// server render shows every pill, which is the correct no-cap fallback.\nconst useIsoLayoutEffect = typeof document !== \"undefined\" ? useLayoutEffect : useEffect\n\n/**\n * Pure row-grouping math behind `usePillOverflow` (exported for testing).\n *\n * Given each measured pill's `offsetTop` (in document order), count how many\n * fit within `maxLines` wrapped rows. A jump in `offsetTop` (beyond a sub-pixel\n * epsilon) marks a new row. When the pills overflow, reserve one slot on the\n * last visible row for the \"+N\" counter (it's narrower than a typical pill, so\n * dropping one always makes room).\n */\nexport function visiblePillCount(offsetTops: number[], maxLines: number): number {\n let rows = 0\n let lastTop = Number.NEGATIVE_INFINITY\n for (let i = 0; i < offsetTops.length; i++) {\n const top = offsetTops[i] ?? lastTop\n if (top - lastTop > 1) {\n rows += 1\n lastTop = top\n if (rows > maxLines) {\n // `i` begins the row past the cap — keep the rows before it, minus one\n // for the counter.\n return Math.max(0, i - 1)\n }\n }\n }\n return offsetTops.length\n}\n\n/**\n * Like `visiblePillCount`, but also keeps the trailing input field on the last\n * visible row (exported for testing).\n *\n * `visiblePillCount` only reasons about pills, so when the last visible row is\n * packed, the field — which is `min-w-16` and the last flex child — can't claim\n * its minimum width and wraps onto a new line. A flex item wraps exactly when\n * the space left on its row drops below its `min-width`, so we drop pills until\n * the last visible pill leaves room on its row for `gap + fieldMinWidth` (plus\n * the `+N` counter, once anything is hidden). Pills are passed as `{ top, end }`,\n * where `end` is how far the pill's inline-end edge sits from the row's\n * inline-start edge, and `rowEnd` is the row's inline length — logical, so the\n * same math holds in RTL, where the free space is on the pill's left. Removing a\n * trailing pill never reflows the ones before it, so each drop is checked\n * against real geometry.\n */\nexport function pillCountWithField(\n pills: { top: number; end: number }[],\n maxLines: number,\n rowEnd: number,\n trailing: { fieldMinWidth: number; counterWidth: number; gap: number },\n): number {\n const total = pills.length\n const { fieldMinWidth, counterWidth, gap } = trailing\n // Start from the pill-only cap (already reserves one slot for the counter on\n // overflow), then back off until the field's minimum fits on the last row.\n let visible = visiblePillCount(\n pills.map((p) => p.top),\n maxLines,\n )\n while (visible > 0) {\n const last = pills[visible - 1]\n if (last == null) break\n // Hiding any pill surfaces the \"+N\" counter, which shares the last row.\n const needsCounter = visible < total\n const trailingWidth = gap + fieldMinWidth + (needsCounter ? counterWidth + gap : 0)\n if (last.end + trailingWidth <= rowEnd) break\n visible--\n }\n return visible\n}\n\n/**\n * Measure how many pills fit within `maxLines` rows and how many overflow.\n *\n * Line caps are width-dependent (pills vary in width), so this measures the DOM.\n * Pills to be measured must carry `data-overflow-item`; the trailing field and\n * the counter must NOT (they would corrupt row detection) — instead the field\n * carries `data-overflow-field` and the counter `data-overflow-counter` so the\n * hook can locate and measure them without mistaking them for pills. The hook\n * renders the full set during a pre-paint \"measuring\" pass, groups pills into\n * rows, then settles on a `visibleCount` — reserving the last row for the \"+N\"\n * chip and, when a field is present, its `min-width` too, so the field never\n * wraps onto a new line (see `pillCountWithField`). Re-measures on width change\n * only (ignoring the height change our own slicing causes, which would loop).\n *\n * `measuring` is exposed so consumers can render the counter during the\n * measuring pass (it is otherwise hidden when nothing overflows), letting the\n * hook measure its real width for the last-row reservation.\n */\nexport function usePillOverflow({\n maxLines,\n count,\n}: {\n /** Cap the rendered pills at this many rows. Omit to render every pill. */\n maxLines?: number\n /** Total number of pills — drives re-measurement on add / remove. */\n count: number\n}): {\n containerRef: RefObject<HTMLDivElement | null>\n visibleCount: number\n hiddenCount: number\n measuring: boolean\n} {\n const containerRef = useRef<HTMLDivElement>(null)\n const [visibleCount, setVisibleCount] = useState(count)\n // While true, every pill is rendered so the DOM reflects the full set; flipped\n // off (pre-paint) once the cutoff is computed.\n const [measuring, setMeasuring] = useState(true)\n const lastWidth = useRef(0)\n\n // Any change to the inputs re-enters a full-render measuring pass.\n useIsoLayoutEffect(() => {\n setMeasuring(true)\n }, [count, maxLines])\n\n useIsoLayoutEffect(() => {\n if (!measuring) return\n const container = containerRef.current\n if (maxLines == null || container == null) {\n setVisibleCount(count)\n setMeasuring(false)\n return\n }\n const items = Array.from(container.querySelectorAll<HTMLElement>(\"[data-overflow-item]\"))\n lastWidth.current = container.clientWidth\n\n const fieldEl = container.querySelector<HTMLElement>(\"[data-overflow-field]\")\n if (fieldEl == null) {\n // No trailing field (e.g. TreeMultiSelect's read-only trigger) — pills +\n // counter only, the original behavior.\n setVisibleCount(\n visiblePillCount(\n items.map((el) => el.offsetTop),\n maxLines,\n ),\n )\n setMeasuring(false)\n return\n }\n\n // Field-aware: reserve the field's min width (and the counter slot) on the\n // last visible row. Measure in viewport coords via `getBoundingClientRect`\n // so pill edges and the row's edges share one coordinate space regardless\n // of `offsetParent` (the positioned shell, not this container), then turn\n // them into inline offsets from the row's start: under RTL the row fills\n // from the right, and a physical `right` would read every pill as already\n // touching the row's end.\n const style = getComputedStyle(container)\n const gap = Number.parseFloat(style.columnGap || style.gap) || 0\n const row = container.getBoundingClientRect()\n const rtl = style.direction === \"rtl\"\n const inlineEnd = (rect: DOMRect) => (rtl ? row.right - rect.left : rect.right - row.left)\n const fieldMinWidth = Number.parseFloat(getComputedStyle(fieldEl).minWidth) || 0\n const counterEl = container.querySelector<HTMLElement>(\"[data-overflow-counter]\")\n const counterWidth = counterEl?.getBoundingClientRect().width ?? 0\n const pills = items.map((el) => {\n const rect = el.getBoundingClientRect()\n return { top: rect.top, end: inlineEnd(rect) }\n })\n setVisibleCount(\n pillCountWithField(pills, maxLines, row.width, { fieldMinWidth, counterWidth, gap }),\n )\n setMeasuring(false)\n }, [measuring, count, maxLines])\n\n // Re-measure when the field's width changes (a wider field reveals more\n // pills again). Ignore height-only changes — our own slicing shrinks the\n // height and would otherwise feed back into an infinite measure loop.\n const width = useElementSize(containerRef, { enabled: maxLines != null })?.width\n useIsoLayoutEffect(() => {\n if (width === undefined || Math.abs(width - lastWidth.current) < 1) return\n lastWidth.current = width\n setMeasuring(true)\n }, [width])\n\n const resolved = maxLines == null || measuring ? count : Math.min(visibleCount, count)\n return {\n containerRef,\n visibleCount: resolved,\n hiddenCount: Math.max(0, count - resolved),\n measuring,\n }\n}\n\n/** The wording of the pill controls' \"+N\" counter — shared by `PillsInput`, `MultiSelect`,\n * `TagsInput` and `TreeMultiSelect`, each taking it on its own `translations`. */\nexport type PillsInputTranslations = {\n /** What a screen reader hears for the \"+N\" counter, instead of \"plus 3\". Gets the hidden\n * count (for plural rules) and that count formatted for the locale.\n * Default `(count, n) => \\`${n} more items\\`` (\"item\" for one). */\n overflowCount?: (count: number, formatted: string) => string\n}\n\nconst englishPlural = new Intl.PluralRules(\"en-US\")\n\nexport const PILLS_INPUT_DEFAULT_TRANSLATIONS = {\n overflowCount: (count, formatted) =>\n `${formatted} more ${englishPlural.select(count) === \"one\" ? \"item\" : \"items\"}`,\n} as const satisfies Required<PillsInputTranslations>\n\nexport type PillOverflowCounterProps = {\n /** How many pills are hidden. */\n count: number\n size?: PillSize\n className?: string\n /** The owning control's `translations`; only `overflowCount` is read. */\n translations?: PillsInputTranslations\n}\n\n/** Static \"+N\" chip the pill controls render at the end of the visible rows.\n * Non-interactive: the \"+N\" is drawn in the locale's digits and sign (`+٣` in\n * `ar-EG`) and hidden from screen readers, which read `overflowCount` instead.\n * The full set stays reachable via the dropdown (where one exists) or the\n * consumer's own state. */\nexport const PillOverflowCounter = ({\n count,\n size = \"md\",\n className,\n translations,\n}: PillOverflowCounterProps) => {\n const locale = useLocale()\n // The one key it reads; an owner forwarding `{ overflowCount: undefined }` keeps the default.\n const overflowCount =\n translations?.overflowCount ?? PILLS_INPUT_DEFAULT_TRANSLATIONS.overflowCount\n return (\n // `relative`: contains the absolutely positioned `sr-only` text.\n <span data-overflow-counter className={cn(pill({ size }), \"relative tabular-nums\", className)}>\n <span aria-hidden>\n {new Intl.NumberFormat(locale, { signDisplay: \"always\" }).format(count)}\n </span>\n <span className=\"sr-only\">\n {overflowCount(count, new Intl.NumberFormat(locale).format(count))}\n </span>\n </span>\n )\n}\n\ntype PillsInputClassNames = {\n root?: string\n content?: string\n startSlot?: string\n endSlot?: string\n}\n\nexport type PillsInputProps = NoAsChild<Omit<HTMLArkProps<\"div\">, \"color\">> &\n WithTestId & {\n size?: InputSize\n variant?: InputVariant\n color?: Color\n invalid?: boolean\n disabled?: boolean\n pointer?: boolean\n /** Cap the pills at N rows; the rest collapse into a static \"+N\" counter. */\n maxLines?: number\n /** Inline-start adornment (icon, label). */\n startSlot?: ReactNode\n /** Inline-end adornment — rendered before any trailing control. */\n endSlot?: ReactNode\n classNames?: PillsInputClassNames\n /** The \"+N\" counter's screen-reader wording — see `PillsInputTranslations`. */\n translations?: PillsInputTranslations\n }\n\n/**\n * PillsInput — the wrapping input shell for multi-value fields. Host `Pill`s\n * and a single `PillsInput.Field` inside; the shell sizes and disables them\n * through context. Presentational by design: it holds no value state.\n *\n * `testId` here lands on the shell `<div>` itself — useful when `PillsInput`\n * is used bare. `PillsInput.Field` has its own `testId`, landing on the real\n * focusable `<input>`; prefer that one when targeting the field.\n */\nconst PillsInputBase = ({\n size = \"md\",\n variant = \"default\",\n color,\n invalid,\n disabled,\n pointer,\n maxLines,\n startSlot,\n endSlot,\n className,\n classNames,\n children,\n testId,\n translations,\n asChild: _asChild,\n ...rest\n}: PillsInputProps) => {\n // Convention: pills first, the field last. Only the pills feed the line cap;\n // the field always stays visible (it is never sliced away).\n const items = Children.toArray(children)\n const field = items.length > 0 ? items[items.length - 1] : null\n const pills = items.length > 0 ? items.slice(0, -1) : []\n\n const { containerRef, visibleCount, hiddenCount, measuring } = usePillOverflow({\n maxLines,\n count: pills.length,\n })\n\n const renderedPills = (maxLines == null ? pills : pills.slice(0, visibleCount)).map((child, i) =>\n isValidElement(child)\n ? cloneElement(child as ReactElement<Record<string, unknown>>, {\n key: child.key ?? i,\n \"data-overflow-item\": true,\n })\n : child,\n )\n\n return (\n <PillGroupContext.Provider value={{ size, disabled }}>\n <ark.div\n data-color={color}\n {...props({\n \"data-invalid\": invalid,\n \"data-disabled\": disabled,\n \"data-pointer\": pointer,\n // Slot-aware padding in `inputShell` — see InputBase for the rationale.\n \"data-with-start-slot\": startSlot != null,\n \"data-with-end-slot\": endSlot != null,\n \"data-testid\": testId,\n })}\n className={cn(inputShell({ size, variant }), pillsShell, className, classNames?.root)}\n {...rest}\n >\n {startSlot != null && (\n <span className={cn(inputSlot, classNames?.startSlot)} aria-hidden>\n {startSlot}\n </span>\n )}\n <div ref={containerRef} className={cn(pillsContent({ size }), classNames?.content)}>\n {renderedPills}\n {/* Mounted during the measuring pass so the hook can size the last-row\n reservation off the real counter, but kept `invisible` then (still\n measurable) so it never paints on the SSR HTML before the first\n measure. Only mounts while measuring when a cap is configured. */}\n {(hiddenCount > 0 || (measuring && maxLines != null)) && (\n <PillOverflowCounter\n count={measuring ? pills.length : hiddenCount}\n size={size}\n className={measuring ? \"invisible\" : undefined}\n translations={translations}\n />\n )}\n {field}\n </div>\n {endSlot != null && <span className={cn(inputSlot, classNames?.endSlot)}>{endSlot}</span>}\n </ark.div>\n </PillGroupContext.Provider>\n )\n}\n\nexport type PillsInputFieldProps = ComponentPropsWithoutRef<\"input\"> &\n WithTestId & {\n /** Fired on Backspace when the field is empty — pop the last value. */\n onRemoveLast?: () => void\n }\n\nconst PillsInputField = ({\n className,\n onRemoveLast,\n onKeyDown,\n testId,\n ...rest\n}: PillsInputFieldProps) => (\n <input\n // The trailing field the overflow hook keeps on the last visible row.\n data-overflow-field\n // Grow to fill the line, but keep a clickable minimum when empty. Overrides\n // `inputControlClasses`' `w-full min-w-0` so pills can share the row.\n className={cn(inputControlClasses, \"w-auto min-w-16\", className)}\n onKeyDown={(event) => {\n if (onRemoveLast && event.key === \"Backspace\" && event.currentTarget.value === \"\") {\n onRemoveLast()\n }\n onKeyDown?.(event)\n }}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport const PillsInput = Object.assign(PillsInputBase, {\n Field: PillsInputField,\n})\n"]}
@@ -2,8 +2,8 @@ import { Progress } from './chunk-QKSLDQM2.js';
2
2
  import { FILE_KIND_ICONS } from './chunk-SDVZFXQ2.js';
3
3
  import { Image } from './chunk-Y57NW6G7.js';
4
4
  import { Button } from './chunk-SP6LCCTZ.js';
5
- import { formatFileSize, useObjectUrl, fileKind } from './chunk-WERJ44ZN.js';
6
- import { useLocale, useTimeZone } from './chunk-IUK7OJXZ.js';
5
+ import { formatFileSize, useObjectUrl, fileKind } from './chunk-DTFSCR3U.js';
6
+ import { useLocale, useTimeZone } from './chunk-OBSZ4NE2.js';
7
7
  import { CloseIcon } from './chunk-6YNLRQ25.js';
8
8
  import { mergeIcons, iconStroke } from './chunk-XXOR34T4.js';
9
9
  import { withAsChildContent, composeChildren } from './chunk-R5LYFTHA.js';
@@ -336,5 +336,5 @@ var FileItem = Object.assign(FileItemComponent, {
336
336
  });
337
337
 
338
338
  export { FileItem, isInFlight };
339
- //# sourceMappingURL=chunk-ASKQ6N5V.js.map
340
- //# sourceMappingURL=chunk-ASKQ6N5V.js.map
339
+ //# sourceMappingURL=chunk-FSPS7TVD.js.map
340
+ //# sourceMappingURL=chunk-FSPS7TVD.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/file-item/file-item.tsx"],"names":["Frag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AA,CAAC,SAAM,OAAA,EAAS,OAAA,EAAS,SAAA,EAAW,UAAA,EAAY,KAAA,EAAO,CAAA;AAAA,IAExD,2BAAW,GAAA,CAAC,MAAA,EAAA,EAAO,SAAS,OAAA,EAAS,SAAA,EAAW,YAAY,MAAA,EAAQ;AAAA,GAAA,EACvE,CAAA;AAEF,EAAA;AAAA;AAAA;AAAA,wBAGG,IAAA,EAAA,EAAM,GAAG,MAAM,OAAA,EAAkB,SAAA,EAAW,GAAG,SAAA,EAAW,UAAA,EAAY,IAAI,CAAA,EACxE,oBACC,kBAAA,CAAmB,QAAA,EAAU,CAAC,GAAA,qBAC5B,IAAA,CAAAA,UAAA,EACG,QAAA,EAAA;AAAA,MAAA,GAAA;AAAA,MACA;AAAA,KAAA,EACH,CACD,CAAA,mBAED,IAAA,CAAAA,QAAAA,EAAA,EACG,QAAA,EAAA;AAAA,MAAA,GAAA;AAAA,MACA;AAAA,KAAA,EACH,CAAA,EAEJ;AAAA;AAEJ;AAOO,IAAM,QAAA,GAAW,MAAA,CAAO,MAAA,CAAO,iBAAA,EAAmB;AAAA,EACvD,IAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA,EAAU,WAAA;AAAA,EACV,OAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAC","file":"chunk-ASKQ6N5V.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { CircleCheck, RotateCw } from \"lucide-react\"\nimport {\n createContext,\n Fragment,\n type ReactNode,\n type Ref,\n useContext,\n useId,\n useState,\n} from \"react\"\nimport { match } from \"ts-pattern\"\nimport { composeChildren, type NoAsChild, withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { FILE_KIND_ICONS } from \"../../lib/file-kind-icons\"\nimport { type FileKind, fileKind, formatFileSize } from \"../../lib/files\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { useLocale, useTimeZone } from \"../../lib/intl\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES, TYPOGRAPHY_SHADE_CLASSES } from \"../../lib/typography-size\"\nimport { useObjectUrl } from \"../../lib/use-object-url\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Image } from \"../image/image\"\nimport { CloseIcon } from \"../popover/icons\"\nimport { Progress, type ProgressProps } from \"../progress/progress\"\n\n/**\n * FileItem — one file as a row: its icon or thumbnail, its name, a meta line\n * (size, date, upload status) and its actions.\n *\n * <FileItem file={pickedFile} onRemove={() => remove(pickedFile)} />\n * <FileItem file={{ name: \"contract.pdf\", size: 248_213, date: doc.signedAt }} actions={…} />\n *\n * The same row serves a `File` the visitor just picked and a document stored\n * on a server, described by `{ name, size?, type?, date?, src? }` (`src` is a\n * thumbnail or preview URL). `FileUpload` renders its list with it.\n *\n * Upload state comes in through `status` (`queued → uploading → processing →\n * done | error`) and `progress` (0–1), so a queue only has to feed them:\n * uploading shows a determinate bar named after the file, processing an\n * indeterminate one, an error its message and a Retry button. Screen readers\n * hear the start, the end and a failure through a polite status region,\n * never each progress tick. A row a queue drives (`itemProps`) stays quiet\n * instead (`announce={false}`), and `FileQueueSummary` speaks for the run.\n *\n * Sizes and dates follow the `IntlProvider` locale and time zone; every\n * string goes through `translations`, every icon through `icons`.\n */\n\nexport type FileItemStatus = \"idle\" | \"queued\" | \"uploading\" | \"processing\" | \"done\" | \"error\"\n\n/** A file that lives on a server: a stored document rather than a picked `File`. */\nexport type FileDescriptor = {\n name: string\n /** In bytes. */\n size?: number\n /** MIME type. Picks the icon, with the name's extension as the fallback. */\n type?: string\n /** When it was uploaded, signed, last changed: whatever the app's meta line means. A date-only\n * ISO string (`\"2026-10-01\"`) is UTC midnight, so it can read as the day before west of UTC;\n * pass a full timestamp or a `Date`. */\n date?: Date | string | number\n /** A thumbnail or preview URL, shown in place of the kind icon. */\n src?: string\n}\n\nexport type FileItemFile = File | FileDescriptor\n\nexport type FileItemIconSlot = FileKind | \"remove\" | \"retry\" | \"done\"\nexport type FileItemIcons = IconMap<FileItemIconSlot>\n\n/** The statuses the status region speaks up for. The others are steps in between. */\nexport type FileItemAnnouncedStatus = \"uploading\" | \"done\" | \"error\"\n\nexport type FileItemTranslations = {\n /** The remove button's accessible name. @default (name) => `Remove ${name}` */\n remove?: (name: string) => string\n /** The same button's name while the file is queued or in flight.\n * @default (name) => `Cancel upload of ${name}` */\n cancel?: (name: string) => string\n /** The retry button's text (it is described by the file name). @default \"Retry\" */\n retry?: string\n /** @default \"Queued\" */\n queued?: string\n /** The meta line and the indeterminate bar's value text. @default \"Processing…\" */\n processing?: string\n /** @default \"Uploaded\" */\n done?: string\n /** Shown for an error without an `error` message. @default \"Upload failed\" */\n failed?: string\n /** What the status region says on each announced transition. The `error` message, when\n * there is one, follows it. */\n announcement?: (status: FileItemAnnouncedStatus, name: string) => string\n}\n\nconst DEFAULT_TRANSLATIONS: Required<FileItemTranslations> = {\n remove: (name) => `Remove ${name}`,\n cancel: (name) => `Cancel upload of ${name}`,\n retry: \"Retry\",\n queued: \"Queued\",\n processing: \"Processing…\",\n done: \"Uploaded\",\n failed: \"Upload failed\",\n announcement: (status, name) =>\n match(status)\n .with(\"uploading\", () => `Uploading ${name}`)\n .with(\"done\", () => `${name} uploaded`)\n .with(\"error\", () => `${name} failed to upload`)\n .exhaustive(),\n}\n\n/** The default icons, one per kind plus the row's own buttons. */\nconst DEFAULT_ICONS: Record<FileItemIconSlot, ReactNode> = {\n ...FILE_KIND_ICONS,\n remove: <CloseIcon />,\n retry: <RotateCw aria-hidden className={iconStroke} />,\n done: <CircleCheck aria-hidden className={iconStroke} />,\n}\n\nconst ANNOUNCED = new Set<FileItemStatus>([\"uploading\", \"done\", \"error\"])\nconst isAnnounced = (status: FileItemStatus | undefined): status is FileItemAnnouncedStatus =>\n status !== undefined && ANNOUNCED.has(status)\n\n/** Statuses where the remove button stops the upload rather than dropping a finished file. */\nconst IN_FLIGHT = new Set<FileItemStatus>([\"queued\", \"uploading\", \"processing\"])\n\n/** Whether the × stops an upload (and calls `onCancel`) rather than dropping the file. For a\n * layout composed from the parts, which wires `Remove` itself. */\nexport const isInFlight = (status: FileItemStatus | undefined): boolean =>\n status !== undefined && IN_FLIGHT.has(status)\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\ntype Shared = {\n name: string\n kind: FileKind\n size?: number\n date?: Date\n src?: string\n /** The picked file itself, for an object-URL thumbnail. */\n blob?: File\n status?: FileItemStatus\n progress?: number\n error?: ReactNode\n disabled: boolean\n thumbnails: boolean\n nameId: string\n locale: string\n timeZone: string\n t: Required<FileItemTranslations>\n icons: Record<FileItemIconSlot, ReactNode>\n}\n\nconst SharedContext = createContext<Shared | null>(null)\n\nconst useShared = () => {\n const shared = useContext(SharedContext)\n if (!shared) throw new Error(\"FileItem parts must be rendered within <FileItem.Root>.\")\n return shared\n}\n\n/** A `File` and a descriptor, read the same way. */\ntype FileFacts = Omit<FileDescriptor, \"date\"> & { date?: Date; blob?: File }\n\n/** An unparseable `date` is dropped rather than shown as \"Invalid Date\". */\nconst toDate = (value: FileDescriptor[\"date\"]): Date | undefined => {\n const date = value === undefined ? undefined : new Date(value)\n return date && !Number.isNaN(date.getTime()) ? date : undefined\n}\n\nconst readFile = (file: FileItemFile): FileFacts =>\n file instanceof File\n ? { name: file.name, size: file.size, type: file.type, blob: file }\n : { name: file.name, size: file.size, type: file.type, src: file.src, date: toDate(file.date) }\n\n// ---------------------------------------------------------------------------\n// Parts\n// ---------------------------------------------------------------------------\n\nexport type FileItemRootProps = HTMLArkProps<\"div\"> &\n WithTestId & {\n /** A picked `File`, or a stored document's `{ name, size?, type?, date?, src? }`. */\n file: FileItemFile\n /** Upload state. Pass it from the first render (`\"idle\"` or `\"queued\"`): the status\n * region exists only with a status, and announces changes, not its first value. */\n status?: FileItemStatus\n /** Upload progress from 0 to 1, read while `status` is `\"uploading\"`. Without it the bar\n * is indeterminate. */\n progress?: number\n /** Why the upload failed, shown and announced while `status` is `\"error\"`. */\n error?: ReactNode\n /** Keep a status region that announces this row's upload. Off for a row a queue drives:\n * `useFileQueue`'s `itemProps` pass `false`, and one `FileQueueSummary` speaks for every\n * row, so 400 rows don't announce 800 times. @default true */\n announce?: boolean\n /** Disables the row's own buttons (remove, retry). */\n disabled?: boolean\n /** Show image files and `src` as thumbnails. Off, every file shows its kind icon, and no\n * object URL is created. @default true */\n thumbnails?: boolean\n /** Replaces the default icons: one per `FileKind`, plus `remove`, `retry` and `done`. */\n icons?: FileItemIcons\n /** Overrides the row's strings. A partial override keeps the other defaults. */\n translations?: FileItemTranslations\n ref?: Ref<HTMLDivElement>\n }\n\nconst Root = ({\n file,\n status,\n progress,\n error,\n announce = true,\n disabled = false,\n thumbnails = true,\n icons,\n translations,\n asChild,\n children,\n className,\n testId,\n ...rest\n}: FileItemRootProps) => {\n const locale = useLocale()\n const timeZone = useTimeZone()\n const nameId = useId()\n const t = { ...DEFAULT_TRANSLATIONS, ...translations }\n const { type, ...facts } = readFile(file)\n const kind = fileKind(type, facts.name)\n\n // Only a change of status is announced, never the first one (a stored document mounting as\n // \"done\" is not news) and never a progress tick. State adjusted during render, React's own\n // pattern for \"remember the previous prop\", so the region's text lands in the same commit.\n const [seen, setSeen] = useState(status)\n const [announced, setAnnounced] = useState<FileItemAnnouncedStatus | null>(null)\n if (seen !== status) {\n setSeen(status)\n setAnnounced(isAnnounced(status) ? status : null)\n }\n\n const shared: Shared = {\n ...facts,\n kind,\n status,\n progress,\n error,\n disabled,\n thumbnails,\n nameId,\n locale,\n timeZone,\n t,\n icons: mergeIcons(DEFAULT_ICONS, icons),\n }\n\n const region = announce && status !== undefined && (\n // A sibling of the busy Body rather than inside it: assistive tech may hold back a live\n // region's changes while it sits in an `aria-busy` subtree.\n <span role=\"status\" className=\"sr-only\">\n {announced && t.announcement(announced, facts.name)}\n {announced === \"error\" && error != null && <> {error}</>}\n </span>\n )\n\n return (\n <SharedContext.Provider value={shared}>\n <ark.div\n data-kind={kind}\n {...props({ \"data-status\": status, \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\n // `relative` contains the status region's sr-only box.\n \"relative flex items-center gap-1 rounded-input border p-2\",\n // The kit's hairline, the same as FileUpload's dropzone above its list.\n \"border-brand-900/20 dark:border-white/15\",\n // Figma's file-upload item: `Border/border-error-secondary`, Error/500 at 30%.\n \"data-[status=error]:border-red-500/30\",\n className,\n )}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {own}\n {region}\n </>\n ))}\n </ark.div>\n </SharedContext.Provider>\n )\n}\n\nexport type FileItemPreviewProps = NoAsChild<HTMLArkProps<\"div\">> & WithTestId\n\n/** The kind icon, or the thumbnail: `src`, or an image `File` through an object URL. Lazy, and\n * decorative (the name sits next to it), so it is hidden from assistive tech. */\nconst Preview = ({ className, testId, asChild: _asChild, ...rest }: FileItemPreviewProps) => {\n const { kind, src, blob, thumbnails, icons } = useShared()\n const pictured = thumbnails && (src !== undefined || (blob !== undefined && kind === \"image\"))\n // `null` when no thumbnail is wanted, so a list with thumbnails off makes no object URLs.\n const objectUrl = useObjectUrl(pictured && src === undefined ? blob : null)\n return (\n <ark.div\n aria-hidden\n data-part=\"preview\"\n {...props({ \"data-testid\": testId })}\n className={cn(\"flex size-9 shrink-0 items-center justify-center [&>svg]:size-6\", className)}\n {...rest}\n >\n {pictured ? (\n <Image src={src ?? objectUrl} alt=\"\" fallback={icons[kind]} className=\"size-9\" />\n ) : (\n icons[kind]\n )}\n </ark.div>\n )\n}\n\nexport type FileItemBodyProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** The name, meta and progress column. Busy while the file uploads or is processed. */\nconst Body = ({ className, testId, ...rest }: FileItemBodyProps) => {\n const { status } = useShared()\n return (\n <ark.div\n {...props({\n \"aria-busy\": status === \"uploading\" || status === \"processing\",\n \"data-testid\": testId,\n })}\n // `relative` anchors the progress bar, which sits in the row's bottom padding.\n className={cn(\"relative min-w-0 flex-1\", className)}\n {...rest}\n />\n )\n}\n\nexport type FileItemNameProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** The file name, on one line. The full name stays in the text (truncation is CSS only) and in\n * a `title`. `asChild` turns it into your link: `<FileItem.Name asChild><a href={url}>{name}</a></…>`\n * (an empty link would fall back to the name, but linters rightly flag one). */\nconst Name = ({ asChild, children, className, testId, ...rest }: FileItemNameProps) => {\n const { name, nameId } = useShared()\n return (\n <ark.div\n title={name}\n {...props({ \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\"block truncate text-sm\", className)}\n {...rest}\n // Last, so a composing part's own id (Ark's item name) can't detach the bar and buttons\n // that are named and described by it.\n id={nameId}\n >\n {composeChildren(asChild, children, (own) => own ?? name)}\n </ark.div>\n )\n}\n\nexport type FileItemMetaProps = NoAsChild<HTMLArkProps<\"div\">> & WithTestId\n\n/** The dot is hidden, the spaces aren't: screen readers get \"248 kB Queued\", not \"248 kBQueued\". */\nconst Separator = () => (\n <>\n {\" \"}\n <span aria-hidden>·</span>{\" \"}\n </>\n)\n\n/**\n * The size and date, then the status. `children` replace the size and date and keep the\n * status; an error replaces the whole line with its message.\n */\nconst Meta = ({ children, className, testId, asChild: _asChild, ...rest }: FileItemMetaProps) => {\n const { size, date, status, progress, error, locale, timeZone, t, icons } = useShared()\n const details =\n children === undefined\n ? [\n size === undefined ? null : formatFileSize(size, locale),\n date === undefined\n ? null\n : new Intl.DateTimeFormat(locale, { dateStyle: \"medium\", timeZone }).format(date),\n ]\n : [children]\n const state = match(status)\n .with(\"queued\", () => t.queued)\n .with(\"uploading\", () =>\n progress === undefined\n ? null\n : new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }).format(\n Math.min(Math.max(progress, 0), 1),\n ),\n )\n .with(\"processing\", () => t.processing)\n .with(\"done\", () => (\n <span\n data-color=\"green\"\n className=\"inline-flex items-center gap-1 align-bottom text-(--c-text) [&_svg]:size-3.5\"\n >\n {icons.done}\n {t.done}\n </span>\n ))\n .otherwise(() => null)\n const segments = [...details, state].filter((segment) => segment != null && segment !== \"\")\n\n return (\n <ark.div\n data-part=\"meta\"\n {...props({ \"data-testid\": testId })}\n className={cn(\"truncate text-xs\", TYPOGRAPHY_SHADE_CLASSES.muted, className)}\n {...rest}\n >\n {status === \"error\" ? (\n <span className={TEXT_COLOR_CLASSES.error}>{error ?? t.failed}</span>\n ) : (\n segments.map((segment, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: a fixed sequence, rebuilt per render\n <Fragment key={index}>\n {index > 0 && <Separator />}\n <span>{segment}</span>\n </Fragment>\n ))\n )}\n </ark.div>\n )\n}\n\nexport type FileItemProgressProps = Omit<ProgressProps, \"value\" | \"defaultValue\" | \"onChange\">\n\n/** The upload bar: determinate while uploading with a `progress`, indeterminate otherwise and\n * while processing, absent in every other status. Named after the file. It sits under the\n * name and meta, out of flow, so the row doesn't change height. */\nconst ProgressBar = ({ className, ...rest }: FileItemProgressProps) => {\n const { status, progress, nameId, t } = useShared()\n if (status !== \"uploading\" && status !== \"processing\") return null\n const determinate = status === \"uploading\" && progress !== undefined\n return (\n <Progress\n size=\"xs\"\n value={determinate ? Math.min(Math.max(progress, 0), 1) * 100 : null}\n aria-labelledby={nameId}\n aria-valuetext={status === \"processing\" ? t.processing : undefined}\n // Out of flow, in the row's bottom padding under the text: a row keeps its height as its\n // upload starts and ends, so a list of uploads doesn't jump.\n className={cn(\"absolute inset-x-0 -bottom-1\", className)}\n {...rest}\n />\n )\n}\n\nexport type FileItemActionsProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** Your buttons for the file: download, view, open in a tab. */\nconst Actions = ({ className, testId, ...rest }: FileItemActionsProps) => (\n <ark.div\n {...props({ \"data-testid\": testId })}\n className={cn(\"ms-1 flex shrink-0 items-center gap-2\", className)}\n {...rest}\n />\n)\n\nexport type FileItemRemoveProps = HTMLArkProps<\"button\"> & WithTestId\n\n/** The × button, named \"Remove {name}\", or \"Cancel upload of {name}\" while the file is queued\n * or in flight. Wire `onClick`; a composing trigger's own name (Ark's) wins over the default. */\nconst Remove = ({\n asChild,\n children,\n className,\n testId,\n disabled,\n ...rest\n}: FileItemRemoveProps) => {\n const { name, status, disabled: rowDisabled, t, icons } = useShared()\n const label = isInFlight(status) ? t.cancel(name) : t.remove(name)\n return (\n <ark.button\n type=\"button\"\n aria-label={label}\n disabled={disabled ?? rowDisabled}\n {...props({ \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\n \"inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-sm me-1\",\n // The neutral washes rows and options use for hover (`popoverOption`, Table):\n // translucent, so the button reads on whatever the row sits on.\n TYPOGRAPHY_SHADE_CLASSES.muted,\n \"transition-colors hover:bg-black/5 hover:text-black dark:hover:bg-white/8 dark:hover:text-white\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n focusStyles(),\n \"[&_svg]:size-3.5\",\n className,\n )}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => own ?? icons.remove)}\n </ark.button>\n )\n}\n\nexport type FileItemRetryProps = ButtonProps\n\n/** A small \"Retry\" button, described by the file name (\"Retry, cv.pdf\"). Wire `onClick`. */\nconst Retry = ({ children, disabled, ...rest }: FileItemRetryProps) => {\n const { nameId, disabled: rowDisabled, t, icons } = useShared()\n return (\n <Button\n type=\"button\"\n size=\"xs\"\n variant=\"subtle\"\n color=\"neutral\"\n startSlot={icons.retry}\n aria-describedby={nameId}\n disabled={disabled ?? rowDisabled}\n {...rest}\n >\n {children ?? t.retry}\n </Button>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Convenience\n// ---------------------------------------------------------------------------\n\ntype FileItemClassNames = {\n root?: string\n preview?: string\n body?: string\n name?: string\n meta?: string\n progress?: string\n actions?: string\n retry?: string\n remove?: string\n}\n\nexport type FileItemProps = FileItemRootProps & {\n /** Replaces the size and date on the meta line; the status still follows. */\n meta?: ReactNode\n /** Your buttons (download, view…), before the retry and remove buttons. */\n actions?: ReactNode\n /** Renders the × button. While the file is queued or in flight it is named as a cancel, and\n * calls `onCancel` when there is one. */\n onRemove?: () => void\n /** What the × does while the file is queued or in flight: stop the upload. Falls back to\n * `onRemove`; on its own, the × shows only while there is an upload to stop. */\n onCancel?: () => void\n /** Renders a Retry button while `status` is `\"error\"`. */\n onRetry?: () => void\n classNames?: FileItemClassNames\n}\n\nfunction FileItemComponent({\n meta,\n actions,\n onRemove,\n onCancel,\n onRetry,\n classNames,\n className,\n asChild,\n children,\n ...root\n}: FileItemProps) {\n const dismiss = isInFlight(root.status) ? (onCancel ?? onRemove) : onRemove\n const row = (\n <>\n <Preview className={classNames?.preview} />\n <Body className={classNames?.body}>\n <Name className={classNames?.name} />\n <Meta className={classNames?.meta}>{meta}</Meta>\n <ProgressBar className={classNames?.progress} />\n </Body>\n {actions != null && <Actions className={classNames?.actions}>{actions}</Actions>}\n {onRetry && root.status === \"error\" && (\n <Retry onClick={onRetry} className={classNames?.retry} />\n )}\n {dismiss && <Remove onClick={dismiss} className={classNames?.remove} />}\n </>\n )\n return (\n // Under `asChild` the row becomes your element (an `<li>` in your list), with the row\n // folded in ahead of that element's own content.\n <Root {...root} asChild={asChild} className={cn(className, classNames?.root)}>\n {asChild ? (\n withAsChildContent(children, (own) => (\n <>\n {row}\n {own}\n </>\n ))\n ) : (\n <>\n {row}\n {children}\n </>\n )}\n </Root>\n )\n}\n\n/**\n * `FileItem` — the ready-made row, with the parts attached for your own layout:\n * `Root` (the file, status and context), `Preview`, `Body`, `Name`, `Meta`, `Progress`,\n * `Actions`, `Retry` and `Remove`.\n */\nexport const FileItem = Object.assign(FileItemComponent, {\n Root,\n Preview,\n Body,\n Name,\n Meta,\n Progress: ProgressBar,\n Actions,\n Retry,\n Remove,\n})\n"]}
1
+ {"version":3,"sources":["../src/components/file-item/file-item.tsx"],"names":["Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;AAmGA,IAAM,oBAAA,G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AA,EAAY,KAAA,EAAO,CAAA;AAAA,IAExD,2BAAW,GAAA,CAAC,MAAA,EAAA,EAAO,SAAS,OAAA,EAAS,SAAA,EAAW,YAAY,MAAA,EAAQ;AAAA,GAAA,EACvE,CAAA;AAEF,EAAA;AAAA;AAAA;AAAA,wBAGG,IAAA,EAAA,EAAM,GAAG,MAAM,OAAA,EAAkB,SAAA,EAAW,GAAG,SAAA,EAAW,UAAA,EAAY,IAAI,CAAA,EACxE,oBACC,kBAAA,CAAmB,QAAA,EAAU,CAAC,GAAA,qBAC5B,IAAA,CAAAA,UAAA,EACG,QAAA,EAAA;AAAA,MAAA,GAAA;AAAA,MACA;AAAA,KAAA,EACH,CACD,CAAA,mBAED,IAAA,CAAAA,QAAAA,EAAA,EACG,QAAA,EAAA;AAAA,MAAA,GAAA;AAAA,MACA;AAAA,KAAA,EACH,CAAA,EAEJ;AAAA;AAEJ;AAOO,IAAM,QAAA,GAAW,MAAA,CAAO,MAAA,CAAO,iBAAA,EAAmB;AAAA,EACvD,IAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA,EAAU,WAAA;AAAA,EACV,OAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAC","file":"chunk-FSPS7TVD.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { CircleCheck, RotateCw } from \"lucide-react\"\nimport {\n createContext,\n Fragment,\n type ReactNode,\n type Ref,\n useContext,\n useId,\n useState,\n} from \"react\"\nimport { match } from \"ts-pattern\"\nimport { composeChildren, type NoAsChild, withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { FILE_KIND_ICONS } from \"../../lib/file-kind-icons\"\nimport { type FileKind, fileKind, formatFileSize } from \"../../lib/files\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { useLocale, useTimeZone } from \"../../lib/intl\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES, TYPOGRAPHY_SHADE_CLASSES } from \"../../lib/typography-size\"\nimport { useObjectUrl } from \"../../lib/use-object-url\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Image } from \"../image/image\"\nimport { CloseIcon } from \"../popover/icons\"\nimport { Progress, type ProgressProps } from \"../progress/progress\"\n\n/**\n * FileItem — one file as a row: its icon or thumbnail, its name, a meta line\n * (size, date, upload status) and its actions.\n *\n * <FileItem file={pickedFile} onRemove={() => remove(pickedFile)} />\n * <FileItem file={{ name: \"contract.pdf\", size: 248_213, date: doc.signedAt }} actions={…} />\n *\n * The same row serves a `File` the visitor just picked and a document stored\n * on a server, described by `{ name, size?, type?, date?, src? }` (`src` is a\n * thumbnail or preview URL). `FileUpload` renders its list with it.\n *\n * Upload state comes in through `status` (`queued → uploading → processing →\n * done | error`) and `progress` (0–1), so a queue only has to feed them:\n * uploading shows a determinate bar named after the file, processing an\n * indeterminate one, an error its message and a Retry button. Screen readers\n * hear the start, the end and a failure through a polite status region,\n * never each progress tick. A row a queue drives (`itemProps`) stays quiet\n * instead (`announce={false}`), and `FileQueueSummary` speaks for the run.\n *\n * Sizes and dates follow the `IntlProvider` locale and time zone; every\n * string goes through `translations`, every icon through `icons`.\n */\n\nexport type FileItemStatus = \"idle\" | \"queued\" | \"uploading\" | \"processing\" | \"done\" | \"error\"\n\n/** A file that lives on a server: a stored document rather than a picked `File`. */\nexport type FileDescriptor = {\n name: string\n /** In bytes. */\n size?: number\n /** MIME type. Picks the icon, with the name's extension as the fallback. */\n type?: string\n /** When it was uploaded, signed, last changed: whatever the app's meta line means. A date-only\n * ISO string (`\"2026-10-01\"`) is UTC midnight, so it can read as the day before west of UTC;\n * pass a full timestamp or a `Date`. */\n date?: Date | string | number\n /** A thumbnail or preview URL, shown in place of the kind icon. */\n src?: string\n}\n\nexport type FileItemFile = File | FileDescriptor\n\nexport type FileItemIconSlot = FileKind | \"remove\" | \"retry\" | \"done\"\nexport type FileItemIcons = IconMap<FileItemIconSlot>\n\n/** The statuses the status region speaks up for. The others are steps in between. */\nexport type FileItemAnnouncedStatus = \"uploading\" | \"done\" | \"error\"\n\nexport type FileItemTranslations = {\n /** The remove button's accessible name. @default (name) => `Remove ${name}` */\n remove?: (name: string) => string\n /** The same button's name while the file is queued or in flight.\n * @default (name) => `Cancel upload of ${name}` */\n cancel?: (name: string) => string\n /** The retry button's text (it is described by the file name). @default \"Retry\" */\n retry?: string\n /** @default \"Queued\" */\n queued?: string\n /** The meta line and the indeterminate bar's value text. @default \"Processing…\" */\n processing?: string\n /** @default \"Uploaded\" */\n done?: string\n /** Shown for an error without an `error` message. @default \"Upload failed\" */\n failed?: string\n /** What the status region says on each announced transition. The `error` message, when\n * there is one, follows it. */\n announcement?: (status: FileItemAnnouncedStatus, name: string) => string\n}\n\nconst DEFAULT_TRANSLATIONS: Required<FileItemTranslations> = {\n remove: (name) => `Remove ${name}`,\n cancel: (name) => `Cancel upload of ${name}`,\n retry: \"Retry\",\n queued: \"Queued\",\n processing: \"Processing…\",\n done: \"Uploaded\",\n failed: \"Upload failed\",\n announcement: (status, name) =>\n match(status)\n .with(\"uploading\", () => `Uploading ${name}`)\n .with(\"done\", () => `${name} uploaded`)\n .with(\"error\", () => `${name} failed to upload`)\n .exhaustive(),\n}\n\n/** The default icons, one per kind plus the row's own buttons. */\nconst DEFAULT_ICONS: Record<FileItemIconSlot, ReactNode> = {\n ...FILE_KIND_ICONS,\n remove: <CloseIcon />,\n retry: <RotateCw aria-hidden className={iconStroke} />,\n done: <CircleCheck aria-hidden className={iconStroke} />,\n}\n\nconst ANNOUNCED = new Set<FileItemStatus>([\"uploading\", \"done\", \"error\"])\nconst isAnnounced = (status: FileItemStatus | undefined): status is FileItemAnnouncedStatus =>\n status !== undefined && ANNOUNCED.has(status)\n\n/** Statuses where the remove button stops the upload rather than dropping a finished file. */\nconst IN_FLIGHT = new Set<FileItemStatus>([\"queued\", \"uploading\", \"processing\"])\n\n/** Whether the × stops an upload (and calls `onCancel`) rather than dropping the file. For a\n * layout composed from the parts, which wires `Remove` itself. */\nexport const isInFlight = (status: FileItemStatus | undefined): boolean =>\n status !== undefined && IN_FLIGHT.has(status)\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\ntype Shared = {\n name: string\n kind: FileKind\n size?: number\n date?: Date\n src?: string\n /** The picked file itself, for an object-URL thumbnail. */\n blob?: File\n status?: FileItemStatus\n progress?: number\n error?: ReactNode\n disabled: boolean\n thumbnails: boolean\n nameId: string\n locale: string\n timeZone: string\n t: Required<FileItemTranslations>\n icons: Record<FileItemIconSlot, ReactNode>\n}\n\nconst SharedContext = createContext<Shared | null>(null)\n\nconst useShared = () => {\n const shared = useContext(SharedContext)\n if (!shared) throw new Error(\"FileItem parts must be rendered within <FileItem.Root>.\")\n return shared\n}\n\n/** A `File` and a descriptor, read the same way. */\ntype FileFacts = Omit<FileDescriptor, \"date\"> & { date?: Date; blob?: File }\n\n/** An unparseable `date` is dropped rather than shown as \"Invalid Date\". */\nconst toDate = (value: FileDescriptor[\"date\"]): Date | undefined => {\n const date = value === undefined ? undefined : new Date(value)\n return date && !Number.isNaN(date.getTime()) ? date : undefined\n}\n\nconst readFile = (file: FileItemFile): FileFacts =>\n file instanceof File\n ? { name: file.name, size: file.size, type: file.type, blob: file }\n : { name: file.name, size: file.size, type: file.type, src: file.src, date: toDate(file.date) }\n\n// ---------------------------------------------------------------------------\n// Parts\n// ---------------------------------------------------------------------------\n\nexport type FileItemRootProps = HTMLArkProps<\"div\"> &\n WithTestId & {\n /** A picked `File`, or a stored document's `{ name, size?, type?, date?, src? }`. */\n file: FileItemFile\n /** Upload state. Pass it from the first render (`\"idle\"` or `\"queued\"`): the status\n * region exists only with a status, and announces changes, not its first value. */\n status?: FileItemStatus\n /** Upload progress from 0 to 1, read while `status` is `\"uploading\"`. Without it the bar\n * is indeterminate. */\n progress?: number\n /** Why the upload failed, shown and announced while `status` is `\"error\"`. */\n error?: ReactNode\n /** Keep a status region that announces this row's upload. Off for a row a queue drives:\n * `useFileQueue`'s `itemProps` pass `false`, and one `FileQueueSummary` speaks for every\n * row, so 400 rows don't announce 800 times. @default true */\n announce?: boolean\n /** Disables the row's own buttons (remove, retry). */\n disabled?: boolean\n /** Show image files and `src` as thumbnails. Off, every file shows its kind icon, and no\n * object URL is created. @default true */\n thumbnails?: boolean\n /** Replaces the default icons: one per `FileKind`, plus `remove`, `retry` and `done`. */\n icons?: FileItemIcons\n /** Overrides the row's strings. A partial override keeps the other defaults. */\n translations?: FileItemTranslations\n ref?: Ref<HTMLDivElement>\n }\n\nconst Root = ({\n file,\n status,\n progress,\n error,\n announce = true,\n disabled = false,\n thumbnails = true,\n icons,\n translations,\n asChild,\n children,\n className,\n testId,\n ...rest\n}: FileItemRootProps) => {\n const locale = useLocale()\n const timeZone = useTimeZone()\n const nameId = useId()\n const t = { ...DEFAULT_TRANSLATIONS, ...translations }\n const { type, ...facts } = readFile(file)\n const kind = fileKind(type, facts.name)\n\n // Only a change of status is announced, never the first one (a stored document mounting as\n // \"done\" is not news) and never a progress tick. State adjusted during render, React's own\n // pattern for \"remember the previous prop\", so the region's text lands in the same commit.\n const [seen, setSeen] = useState(status)\n const [announced, setAnnounced] = useState<FileItemAnnouncedStatus | null>(null)\n if (seen !== status) {\n setSeen(status)\n setAnnounced(isAnnounced(status) ? status : null)\n }\n\n const shared: Shared = {\n ...facts,\n kind,\n status,\n progress,\n error,\n disabled,\n thumbnails,\n nameId,\n locale,\n timeZone,\n t,\n icons: mergeIcons(DEFAULT_ICONS, icons),\n }\n\n const region = announce && status !== undefined && (\n // A sibling of the busy Body rather than inside it: assistive tech may hold back a live\n // region's changes while it sits in an `aria-busy` subtree.\n <span role=\"status\" className=\"sr-only\">\n {announced && t.announcement(announced, facts.name)}\n {announced === \"error\" && error != null && <> {error}</>}\n </span>\n )\n\n return (\n <SharedContext.Provider value={shared}>\n <ark.div\n data-kind={kind}\n {...props({ \"data-status\": status, \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\n // `relative` contains the status region's sr-only box.\n \"relative flex items-center gap-1 rounded-input border p-2\",\n // The kit's hairline, the same as FileUpload's dropzone above its list.\n \"border-brand-900/20 dark:border-white/15\",\n // Figma's file-upload item: `Border/border-error-secondary`, Error/500 at 30%.\n \"data-[status=error]:border-red-500/30\",\n className,\n )}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => (\n <>\n {own}\n {region}\n </>\n ))}\n </ark.div>\n </SharedContext.Provider>\n )\n}\n\nexport type FileItemPreviewProps = NoAsChild<HTMLArkProps<\"div\">> & WithTestId\n\n/** The kind icon, or the thumbnail: `src`, or an image `File` through an object URL. Lazy, and\n * decorative (the name sits next to it), so it is hidden from assistive tech. */\nconst Preview = ({ className, testId, asChild: _asChild, ...rest }: FileItemPreviewProps) => {\n const { kind, src, blob, thumbnails, icons } = useShared()\n const pictured = thumbnails && (src !== undefined || (blob !== undefined && kind === \"image\"))\n // `null` when no thumbnail is wanted, so a list with thumbnails off makes no object URLs.\n const objectUrl = useObjectUrl(pictured && src === undefined ? blob : null)\n return (\n <ark.div\n aria-hidden\n data-part=\"preview\"\n {...props({ \"data-testid\": testId })}\n className={cn(\"flex size-9 shrink-0 items-center justify-center [&>svg]:size-6\", className)}\n {...rest}\n >\n {pictured ? (\n <Image src={src ?? objectUrl} alt=\"\" fallback={icons[kind]} className=\"size-9\" />\n ) : (\n icons[kind]\n )}\n </ark.div>\n )\n}\n\nexport type FileItemBodyProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** The name, meta and progress column. Busy while the file uploads or is processed. */\nconst Body = ({ className, testId, ...rest }: FileItemBodyProps) => {\n const { status } = useShared()\n return (\n <ark.div\n {...props({\n \"aria-busy\": status === \"uploading\" || status === \"processing\",\n \"data-testid\": testId,\n })}\n // `relative` anchors the progress bar, which sits in the row's bottom padding.\n className={cn(\"relative min-w-0 flex-1\", className)}\n {...rest}\n />\n )\n}\n\nexport type FileItemNameProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** The file name, on one line. The full name stays in the text (truncation is CSS only) and in\n * a `title`. `asChild` turns it into your link: `<FileItem.Name asChild><a href={url}>{name}</a></…>`\n * (an empty link would fall back to the name, but linters rightly flag one). */\nconst Name = ({ asChild, children, className, testId, ...rest }: FileItemNameProps) => {\n const { name, nameId } = useShared()\n return (\n <ark.div\n title={name}\n {...props({ \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\"block truncate text-sm\", className)}\n {...rest}\n // Last, so a composing part's own id (Ark's item name) can't detach the bar and buttons\n // that are named and described by it.\n id={nameId}\n >\n {composeChildren(asChild, children, (own) => own ?? name)}\n </ark.div>\n )\n}\n\nexport type FileItemMetaProps = NoAsChild<HTMLArkProps<\"div\">> & WithTestId\n\n/** The dot is hidden, the spaces aren't: screen readers get \"248 kB Queued\", not \"248 kBQueued\". */\nconst Separator = () => (\n <>\n {\" \"}\n <span aria-hidden>·</span>{\" \"}\n </>\n)\n\n/**\n * The size and date, then the status. `children` replace the size and date and keep the\n * status; an error replaces the whole line with its message.\n */\nconst Meta = ({ children, className, testId, asChild: _asChild, ...rest }: FileItemMetaProps) => {\n const { size, date, status, progress, error, locale, timeZone, t, icons } = useShared()\n const details =\n children === undefined\n ? [\n size === undefined ? null : formatFileSize(size, locale),\n date === undefined\n ? null\n : new Intl.DateTimeFormat(locale, { dateStyle: \"medium\", timeZone }).format(date),\n ]\n : [children]\n const state = match(status)\n .with(\"queued\", () => t.queued)\n .with(\"uploading\", () =>\n progress === undefined\n ? null\n : new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }).format(\n Math.min(Math.max(progress, 0), 1),\n ),\n )\n .with(\"processing\", () => t.processing)\n .with(\"done\", () => (\n <span\n data-color=\"green\"\n className=\"inline-flex items-center gap-1 align-bottom text-(--c-text) [&_svg]:size-3.5\"\n >\n {icons.done}\n {t.done}\n </span>\n ))\n .otherwise(() => null)\n const segments = [...details, state].filter((segment) => segment != null && segment !== \"\")\n\n return (\n <ark.div\n data-part=\"meta\"\n {...props({ \"data-testid\": testId })}\n className={cn(\"truncate text-xs\", TYPOGRAPHY_SHADE_CLASSES.muted, className)}\n {...rest}\n >\n {status === \"error\" ? (\n <span className={TEXT_COLOR_CLASSES.error}>{error ?? t.failed}</span>\n ) : (\n segments.map((segment, index) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: a fixed sequence, rebuilt per render\n <Fragment key={index}>\n {index > 0 && <Separator />}\n <span>{segment}</span>\n </Fragment>\n ))\n )}\n </ark.div>\n )\n}\n\nexport type FileItemProgressProps = Omit<ProgressProps, \"value\" | \"defaultValue\" | \"onChange\">\n\n/** The upload bar: determinate while uploading with a `progress`, indeterminate otherwise and\n * while processing, absent in every other status. Named after the file. It sits under the\n * name and meta, out of flow, so the row doesn't change height. */\nconst ProgressBar = ({ className, ...rest }: FileItemProgressProps) => {\n const { status, progress, nameId, t } = useShared()\n if (status !== \"uploading\" && status !== \"processing\") return null\n const determinate = status === \"uploading\" && progress !== undefined\n return (\n <Progress\n size=\"xs\"\n value={determinate ? Math.min(Math.max(progress, 0), 1) * 100 : null}\n aria-labelledby={nameId}\n aria-valuetext={status === \"processing\" ? t.processing : undefined}\n // Out of flow, in the row's bottom padding under the text: a row keeps its height as its\n // upload starts and ends, so a list of uploads doesn't jump.\n className={cn(\"absolute inset-x-0 -bottom-1\", className)}\n {...rest}\n />\n )\n}\n\nexport type FileItemActionsProps = HTMLArkProps<\"div\"> & WithTestId\n\n/** Your buttons for the file: download, view, open in a tab. */\nconst Actions = ({ className, testId, ...rest }: FileItemActionsProps) => (\n <ark.div\n {...props({ \"data-testid\": testId })}\n className={cn(\"ms-1 flex shrink-0 items-center gap-2\", className)}\n {...rest}\n />\n)\n\nexport type FileItemRemoveProps = HTMLArkProps<\"button\"> & WithTestId\n\n/** The × button, named \"Remove {name}\", or \"Cancel upload of {name}\" while the file is queued\n * or in flight. Wire `onClick`; a composing trigger's own name (Ark's) wins over the default. */\nconst Remove = ({\n asChild,\n children,\n className,\n testId,\n disabled,\n ...rest\n}: FileItemRemoveProps) => {\n const { name, status, disabled: rowDisabled, t, icons } = useShared()\n const label = isInFlight(status) ? t.cancel(name) : t.remove(name)\n return (\n <ark.button\n type=\"button\"\n aria-label={label}\n disabled={disabled ?? rowDisabled}\n {...props({ \"data-testid\": testId })}\n asChild={asChild}\n className={cn(\n \"inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-sm me-1\",\n // The neutral washes rows and options use for hover (`popoverOption`, Table):\n // translucent, so the button reads on whatever the row sits on.\n TYPOGRAPHY_SHADE_CLASSES.muted,\n \"transition-colors hover:bg-black/5 hover:text-black dark:hover:bg-white/8 dark:hover:text-white\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n focusStyles(),\n \"[&_svg]:size-3.5\",\n className,\n )}\n {...rest}\n >\n {composeChildren(asChild, children, (own) => own ?? icons.remove)}\n </ark.button>\n )\n}\n\nexport type FileItemRetryProps = ButtonProps\n\n/** A small \"Retry\" button, described by the file name (\"Retry, cv.pdf\"). Wire `onClick`. */\nconst Retry = ({ children, disabled, ...rest }: FileItemRetryProps) => {\n const { nameId, disabled: rowDisabled, t, icons } = useShared()\n return (\n <Button\n type=\"button\"\n size=\"xs\"\n variant=\"subtle\"\n color=\"neutral\"\n startSlot={icons.retry}\n aria-describedby={nameId}\n disabled={disabled ?? rowDisabled}\n {...rest}\n >\n {children ?? t.retry}\n </Button>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Convenience\n// ---------------------------------------------------------------------------\n\ntype FileItemClassNames = {\n root?: string\n preview?: string\n body?: string\n name?: string\n meta?: string\n progress?: string\n actions?: string\n retry?: string\n remove?: string\n}\n\nexport type FileItemProps = FileItemRootProps & {\n /** Replaces the size and date on the meta line; the status still follows. */\n meta?: ReactNode\n /** Your buttons (download, view…), before the retry and remove buttons. */\n actions?: ReactNode\n /** Renders the × button. While the file is queued or in flight it is named as a cancel, and\n * calls `onCancel` when there is one. */\n onRemove?: () => void\n /** What the × does while the file is queued or in flight: stop the upload. Falls back to\n * `onRemove`; on its own, the × shows only while there is an upload to stop. */\n onCancel?: () => void\n /** Renders a Retry button while `status` is `\"error\"`. */\n onRetry?: () => void\n classNames?: FileItemClassNames\n}\n\nfunction FileItemComponent({\n meta,\n actions,\n onRemove,\n onCancel,\n onRetry,\n classNames,\n className,\n asChild,\n children,\n ...root\n}: FileItemProps) {\n const dismiss = isInFlight(root.status) ? (onCancel ?? onRemove) : onRemove\n const row = (\n <>\n <Preview className={classNames?.preview} />\n <Body className={classNames?.body}>\n <Name className={classNames?.name} />\n <Meta className={classNames?.meta}>{meta}</Meta>\n <ProgressBar className={classNames?.progress} />\n </Body>\n {actions != null && <Actions className={classNames?.actions}>{actions}</Actions>}\n {onRetry && root.status === \"error\" && (\n <Retry onClick={onRetry} className={classNames?.retry} />\n )}\n {dismiss && <Remove onClick={dismiss} className={classNames?.remove} />}\n </>\n )\n return (\n // Under `asChild` the row becomes your element (an `<li>` in your list), with the row\n // folded in ahead of that element's own content.\n <Root {...root} asChild={asChild} className={cn(className, classNames?.root)}>\n {asChild ? (\n withAsChildContent(children, (own) => (\n <>\n {row}\n {own}\n </>\n ))\n ) : (\n <>\n {row}\n {children}\n </>\n )}\n </Root>\n )\n}\n\n/**\n * `FileItem` — the ready-made row, with the parts attached for your own layout:\n * `Root` (the file, status and context), `Preview`, `Body`, `Name`, `Meta`, `Progress`,\n * `Actions`, `Retry` and `Remove`.\n */\nexport const FileItem = Object.assign(FileItemComponent, {\n Root,\n Preview,\n Body,\n Name,\n Meta,\n Progress: ProgressBar,\n Actions,\n Retry,\n Remove,\n})\n"]}
@@ -1,5 +1,5 @@
1
- import { TimeRow, resolveHourCycle, timeRowMinWidth, toDisplayHour, fromDisplayHour, is12Hour, dayPeriodLabels } from './chunk-ULF5LOBS.js';
2
- import { CalendarBody, CalendarZoneSync, calendarGridWidth, hashArkValues, resolveCalendarTranslations } from './chunk-7BY5I2RB.js';
1
+ import { TimeRow, resolveHourCycle, timeRowMinWidth, toDisplayHour, fromDisplayHour, is12Hour, dayPeriodLabels } from './chunk-HMNXNKDA.js';
2
+ import { CalendarBody, CalendarZoneSync, calendarGridWidth, hashArkValues, resolveCalendarTranslations } from './chunk-S5CQRCTF.js';
3
3
  import { calendarValueToDate, dateToArkValue, fromArkValues, toArkValues } from './chunk-ZB5VMGKB.js';
4
4
  import { controlOpenProps } from './chunk-5FDOOG4J.js';
5
5
  import { inputSlot, inputControlClasses, shellGap, placeholderColor, inputShell } from './chunk-I4B3N3UX.js';
@@ -7,7 +7,7 @@ import { FieldShell, fieldA11yProps } from './chunk-X6DESK37.js';
7
7
  import { capitalize } from './chunk-DHM4IG2O.js';
8
8
  import { Button } from './chunk-SP6LCCTZ.js';
9
9
  import { useMergedRefs } from './chunk-HBWV5EPU.js';
10
- import { useTimeZone, useLocale } from './chunk-IUK7OJXZ.js';
10
+ import { useTimeZone, useLocale } from './chunk-OBSZ4NE2.js';
11
11
  import { Popover, popoverClearTrigger, popoverPanel } from './chunk-RKCUXOU2.js';
12
12
  import { NestedLayer } from './chunk-HWBFRDX7.js';
13
13
  import { useOverlayContainer } from './chunk-SLUOF7XW.js';
@@ -684,5 +684,5 @@ var DatePicker = Object.assign(DatePickerImpl, {
684
684
  });
685
685
 
686
686
  export { DatePicker, serializeDateValue };
687
- //# sourceMappingURL=chunk-GJFCIG34.js.map
688
- //# sourceMappingURL=chunk-GJFCIG34.js.map
687
+ //# sourceMappingURL=chunk-GEZYGBXY.js.map
688
+ //# sourceMappingURL=chunk-GEZYGBXY.js.map