@graphiql/plugin-collections 1.0.0-beta.1 → 1.0.0-beta.3

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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -6
  3. package/dist/components/collection-item-row.js +212 -282
  4. package/dist/components/collection-item-row.js.map +1 -1
  5. package/dist/components/collection-row.js +139 -159
  6. package/dist/components/collection-row.js.map +1 -1
  7. package/dist/components/collections-panel.js +408 -496
  8. package/dist/components/collections-panel.js.map +1 -1
  9. package/dist/components/conflict-dialog.js +148 -164
  10. package/dist/components/conflict-dialog.js.map +1 -1
  11. package/dist/components/export-dialog.js +52 -52
  12. package/dist/components/export-dialog.js.map +1 -1
  13. package/dist/components/import-dialog.js +100 -112
  14. package/dist/components/import-dialog.js.map +1 -1
  15. package/dist/components/save-dialog.js +116 -124
  16. package/dist/components/save-dialog.js.map +1 -1
  17. package/dist/components/session-actions.js +23 -31
  18. package/dist/components/session-actions.js.map +1 -1
  19. package/dist/icons/check.js +18 -9
  20. package/dist/icons/check.js.map +1 -1
  21. package/dist/icons/collections.js +16 -9
  22. package/dist/icons/collections.js.map +1 -1
  23. package/dist/icons/download.js +16 -9
  24. package/dist/icons/download.js.map +1 -1
  25. package/dist/icons/upload.js +16 -9
  26. package/dist/icons/upload.js.map +1 -1
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.js +32 -41
  29. package/dist/index.js.map +1 -1
  30. package/dist/operation-method.js +24 -24
  31. package/dist/operation-method.js.map +1 -1
  32. package/dist/storage/local-storage.js +32 -37
  33. package/dist/storage/local-storage.js.map +1 -1
  34. package/dist/storage/tab-links.js +27 -30
  35. package/dist/storage/tab-links.js.map +1 -1
  36. package/dist/store.js +365 -402
  37. package/dist/store.js.map +1 -1
  38. package/dist/style.css +6 -27
  39. package/dist/types.js +9 -8
  40. package/dist/types.js.map +1 -1
  41. package/dist/utility/uuid.js +11 -9
  42. package/dist/utility/uuid.js.map +1 -1
  43. package/package.json +19 -15
@@ -1 +1 @@
1
- {"version":3,"file":"collection-item-row.js","sources":["../../src/components/collection-item-row.tsx"],"sourcesContent":["import { FC, useEffect, useRef, useState } from 'react';\nimport { MethodPill, PenIcon, CopyIcon, TrashIcon } from '@graphiql/react';\nimport type { CollectionItem } from '../types';\nimport { getDocumentMethod } from '../operation-method';\nimport UploadIcon from '../icons/upload.svg?react';\nimport CheckIcon from '../icons/check.svg?react';\n\ntype CollectionItemRowProps = {\n item: CollectionItem;\n collectionId: string;\n /** The item's position within its collection, used for drag reorder. */\n index: number;\n /** Hide write affordances (Move, Delete) and disable drag-reorder when true. */\n readOnly?: boolean;\n isGrabbed: boolean;\n onGrabToggle(): void;\n onGrabMove(direction: 'up' | 'down'): void;\n onGrabCancel(): void;\n onOpen(item: CollectionItem): void;\n onShare(itemId: string): Promise<void>;\n onAnnounce(message: string): void;\n onDelete(collectionId: string, itemId: string): void;\n onMove(\n fromCollectionId: string,\n fromIndex: number,\n toCollectionId: string,\n toIndex: number,\n ): void;\n onRenameItem(\n collectionId: string,\n itemId: string,\n updates: { name: string; description: string },\n ): void;\n};\n\nexport const CollectionItemRow: FC<CollectionItemRowProps> = ({\n item,\n collectionId,\n index,\n readOnly = false,\n isGrabbed,\n onGrabToggle,\n onGrabMove,\n onGrabCancel,\n onOpen,\n onShare,\n onAnnounce,\n onDelete,\n onMove,\n onRenameItem,\n}) => {\n const [isDragOver, setIsDragOver] = useState(false);\n const [isEditing, setIsEditing] = useState(false);\n const [confirmed, setConfirmed] = useState<'copy' | 'share' | null>(null);\n const [confirmToken, setConfirmToken] = useState(0);\n const editFormRef = useRef<HTMLDivElement>(null);\n const [editName, setEditName] = useState(item.name);\n const [editDescription, setEditDescription] = useState(\n item.description ?? '',\n );\n const method = getDocumentMethod(item.query);\n\n // Action buttons stop propagation so their clicks don't also trigger the\n // row's open handler.\n const startEdit = (e: React.MouseEvent) => {\n e.stopPropagation();\n setEditName(item.name);\n setEditDescription(item.description ?? '');\n setIsEditing(true);\n };\n\n useEffect(() => {\n if (!confirmed) {\n return;\n }\n const timer = setTimeout(() => setConfirmed(null), 1500);\n return () => clearTimeout(timer);\n }, [confirmed, confirmToken]);\n\n const runAction = async (\n kind: 'copy' | 'share',\n write: () => Promise<void>,\n message: string,\n failureMessage: string,\n ) => {\n try {\n await write();\n onAnnounce(message);\n setConfirmed(kind);\n setConfirmToken(t => t + 1);\n } catch {\n onAnnounce(failureMessage);\n }\n };\n\n const handleDelete = (e: React.MouseEvent) => {\n e.stopPropagation();\n onDelete(collectionId, item.id);\n };\n\n const commitEdit = () => {\n const name = editName.trim() || item.name;\n onRenameItem(collectionId, item.id, {\n name,\n description: editDescription,\n });\n setIsEditing(false);\n };\n\n // Commit only when focus leaves the whole form; moving between the name and\n // description inputs must not tear down the edit UI mid-edit.\n const handleBlur = (e: React.FocusEvent) => {\n if (editFormRef.current?.contains(e.relatedTarget as Node | null)) {\n return;\n }\n commitEdit();\n };\n\n const cancelEdit = () => {\n setEditName(item.name);\n setEditDescription(item.description ?? '');\n setIsEditing(false);\n };\n\n return (\n <div\n className={`graphiql-collection-item-row${isDragOver ? ' graphiql-collection-drop-target' : ''}`}\n data-grabbed={isGrabbed || undefined}\n draggable={!readOnly && !isEditing}\n onDragStart={\n readOnly || isEditing\n ? undefined\n : e => {\n e.dataTransfer.setData(\n 'application/x-graphiql-item',\n JSON.stringify({ collectionId, index }),\n );\n e.dataTransfer.effectAllowed = 'move';\n }\n }\n onDragOver={\n readOnly\n ? undefined\n : e => {\n e.preventDefault();\n e.dataTransfer.dropEffect = 'move';\n setIsDragOver(true);\n }\n }\n onDragLeave={readOnly ? undefined : () => setIsDragOver(false)}\n onDrop={\n readOnly\n ? undefined\n : e => {\n e.preventDefault();\n setIsDragOver(false);\n try {\n const data = JSON.parse(\n e.dataTransfer.getData('application/x-graphiql-item'),\n );\n onMove(data.collectionId, data.index, collectionId, index);\n } catch {\n // malformed drag data\n }\n }\n }\n onClick={() => {\n if (!isEditing) {\n onOpen(item);\n }\n }}\n >\n <button\n type=\"button\"\n className=\"graphiql-collection-drag-handle\"\n data-collection-drag-handle={item.id}\n aria-label={`Reorder ${item.name}. Press space to grab, arrow keys to move, escape to cancel.`}\n aria-pressed={isGrabbed}\n disabled={readOnly}\n onClick={e => e.stopPropagation()}\n onKeyDown={e => {\n if (e.key === ' ' || e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n onGrabToggle();\n } else if (isGrabbed && e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n onGrabMove('down');\n } else if (isGrabbed && e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n onGrabMove('up');\n } else if (isGrabbed && e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n onGrabCancel();\n }\n }}\n >\n ⠿\n </button>\n {method === 'mix' ? (\n <span\n className=\"graphiql-method-pill graphiql-collection-method-pill-mix\"\n aria-hidden\n >\n MIX\n </span>\n ) : (\n <MethodPill operation={method} aria-hidden />\n )}\n {isEditing ? (\n <div\n ref={editFormRef}\n className=\"graphiql-collection-item-edit-form\"\n onClick={e => e.stopPropagation()}\n >\n <input\n className=\"graphiql-collection-item-edit-input\"\n value={editName}\n autoFocus\n placeholder={item.name}\n onChange={e => setEditName(e.target.value)}\n onBlur={handleBlur}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n commitEdit();\n }\n if (e.key === 'Escape') {\n cancelEdit();\n }\n e.stopPropagation();\n }}\n />\n <input\n className=\"graphiql-collection-item-edit-input\"\n value={editDescription}\n placeholder=\"Description (optional)\"\n onChange={e => setEditDescription(e.target.value)}\n onBlur={handleBlur}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n commitEdit();\n }\n if (e.key === 'Escape') {\n cancelEdit();\n }\n e.stopPropagation();\n }}\n />\n </div>\n ) : (\n <div className=\"graphiql-collection-item-main\">\n <span className=\"graphiql-collection-item-name\" title={item.name}>\n {item.name}\n </span>\n {item.description && (\n <span\n className=\"graphiql-collection-item-description\"\n title={item.description}\n >\n {item.description}\n </span>\n )}\n </div>\n )}\n {!isEditing && (\n <div className=\"graphiql-collection-item-actions\">\n {!readOnly && (\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Rename ${item.name}`}\n title=\"Rename\"\n onClick={startEdit}\n >\n <PenIcon aria-hidden=\"true\" />\n </button>\n )}\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Copy operation ${item.name}`}\n title=\"Copy operation\"\n data-confirmed={confirmed === 'copy' || undefined}\n onClick={e => {\n e.stopPropagation();\n void runAction(\n 'copy',\n () => navigator.clipboard.writeText(item.query),\n 'Copied query to clipboard.',\n 'Could not copy to clipboard.',\n );\n }}\n >\n {confirmed === 'copy' ? (\n <CheckIcon aria-hidden=\"true\" />\n ) : (\n <CopyIcon aria-hidden=\"true\" />\n )}\n </button>\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Share ${item.name} as collection`}\n title=\"Share as collection\"\n data-confirmed={confirmed === 'share' || undefined}\n onClick={e => {\n e.stopPropagation();\n void runAction(\n 'share',\n () => onShare(item.id),\n 'Shared operation to clipboard.',\n 'Could not share to clipboard.',\n );\n }}\n >\n {confirmed === 'share' ? (\n <CheckIcon aria-hidden=\"true\" />\n ) : (\n <UploadIcon aria-hidden=\"true\" />\n )}\n </button>\n {!readOnly && (\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Delete ${item.name}`}\n title=\"Delete\"\n onClick={handleDelete}\n >\n <TrashIcon aria-hidden=\"true\" />\n </button>\n )}\n </div>\n )}\n </div>\n );\n};\n"],"names":["CheckIcon","UploadIcon"],"mappings":";;;;;;AAmCO,MAAM,oBAAgD,CAAC;AAAA,EAC5D;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAC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ACA,MAAM,UAAU,UAAU,UAAU,KAAK,KAAK;AAAA,kBAC9C;AAAA,kBACA;AAAA,gBACF;AAAA,cACF;AAAA,cAEC,UAAA,cAAc,SACb,oBAACA,UAAU,EAAA,eAAY,QAAO,IAE9B,oBAAC,UAAS,EAAA,eAAY,OAAO,CAAA;AAAA,YAAA;AAAA,UAEjC;AAAA,UACA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,WAAU;AAAA,cACV,cAAY,SAAS,KAAK,IAAI;AAAA,cAC9B,OAAM;AAAA,cACN,kBAAgB,cAAc,WAAW;AAAA,cACzC,SAAS,CAAK,MAAA;AACZ,kBAAE,gBAAgB;AACb,qBAAA;AAAA,kBACH;AAAA,kBACA,MAAM,QAAQ,KAAK,EAAE;AAAA,kBACrB;AAAA,kBACA;AAAA,gBACF;AAAA,cACF;AAAA,cAEC,UAAA,cAAc,UACb,oBAACA,UAAU,EAAA,eAAY,QAAO,IAE9B,oBAACC,WAAW,EAAA,eAAY,OAAO,CAAA;AAAA,YAAA;AAAA,UAEnC;AAAA,UACC,CAAC,YACA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,WAAU;AAAA,cACV,cAAY,UAAU,KAAK,IAAI;AAAA,cAC/B,OAAM;AAAA,cACN,SAAS;AAAA,cAET,UAAA,oBAAC,WAAU,EAAA,eAAY,OAAO,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QAChC,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAEJ;AAEJ;"}
1
+ {"version":3,"file":"collection-item-row.js","names":[],"sources":["../../src/components/collection-item-row.tsx"],"sourcesContent":["import { FC, useEffect, useRef, useState } from 'react';\nimport { MethodPill, PenIcon, CopyIcon, TrashIcon } from '@graphiql/react';\nimport type { CollectionItem } from '../types';\nimport { getDocumentMethod } from '../operation-method';\nimport UploadIcon from '../icons/upload.svg?react';\nimport CheckIcon from '../icons/check.svg?react';\n\ntype CollectionItemRowProps = {\n item: CollectionItem;\n collectionId: string;\n /** The item's position within its collection, used for drag reorder. */\n index: number;\n /** Hide write affordances (Move, Delete) and disable drag-reorder when true. */\n readOnly?: boolean;\n isGrabbed: boolean;\n onGrabToggle(): void;\n onGrabMove(direction: 'up' | 'down'): void;\n onGrabCancel(): void;\n onOpen(item: CollectionItem): void;\n onShare(itemId: string): Promise<void>;\n onAnnounce(message: string): void;\n onDelete(collectionId: string, itemId: string): void;\n onMove(\n fromCollectionId: string,\n fromIndex: number,\n toCollectionId: string,\n toIndex: number,\n ): void;\n onRenameItem(\n collectionId: string,\n itemId: string,\n updates: { name: string; description: string },\n ): void;\n};\n\nexport const CollectionItemRow: FC<CollectionItemRowProps> = ({\n item,\n collectionId,\n index,\n readOnly = false,\n isGrabbed,\n onGrabToggle,\n onGrabMove,\n onGrabCancel,\n onOpen,\n onShare,\n onAnnounce,\n onDelete,\n onMove,\n onRenameItem,\n}) => {\n const [isDragOver, setIsDragOver] = useState(false);\n const [isEditing, setIsEditing] = useState(false);\n const [confirmed, setConfirmed] = useState<'copy' | 'share' | null>(null);\n const [confirmToken, setConfirmToken] = useState(0);\n const editFormRef = useRef<HTMLDivElement>(null);\n const [editName, setEditName] = useState(item.name);\n const [editDescription, setEditDescription] = useState(\n item.description ?? '',\n );\n const method = getDocumentMethod(item.query);\n\n // Action buttons stop propagation so their clicks don't also trigger the\n // row's open handler.\n const startEdit = (e: React.MouseEvent) => {\n e.stopPropagation();\n setEditName(item.name);\n setEditDescription(item.description ?? '');\n setIsEditing(true);\n };\n\n useEffect(() => {\n if (!confirmed) {\n return;\n }\n const timer = setTimeout(() => setConfirmed(null), 1500);\n return () => clearTimeout(timer);\n }, [confirmed, confirmToken]);\n\n const runAction = async (\n kind: 'copy' | 'share',\n write: () => Promise<void>,\n message: string,\n failureMessage: string,\n ) => {\n try {\n await write();\n onAnnounce(message);\n setConfirmed(kind);\n setConfirmToken(t => t + 1);\n } catch {\n onAnnounce(failureMessage);\n }\n };\n\n const handleDelete = (e: React.MouseEvent) => {\n e.stopPropagation();\n onDelete(collectionId, item.id);\n };\n\n const commitEdit = () => {\n const name = editName.trim() || item.name;\n onRenameItem(collectionId, item.id, {\n name,\n description: editDescription,\n });\n setIsEditing(false);\n };\n\n // Commit only when focus leaves the whole form; moving between the name and\n // description inputs must not tear down the edit UI mid-edit.\n const handleBlur = (e: React.FocusEvent) => {\n if (editFormRef.current?.contains(e.relatedTarget as Node | null)) {\n return;\n }\n commitEdit();\n };\n\n const cancelEdit = () => {\n setEditName(item.name);\n setEditDescription(item.description ?? '');\n setIsEditing(false);\n };\n\n return (\n <div\n className={`graphiql-collection-item-row${isDragOver ? ' graphiql-collection-drop-target' : ''}`}\n data-grabbed={isGrabbed || undefined}\n draggable={!readOnly && !isEditing}\n onDragStart={\n readOnly || isEditing\n ? undefined\n : e => {\n e.dataTransfer.setData(\n 'application/x-graphiql-item',\n JSON.stringify({ collectionId, index }),\n );\n e.dataTransfer.effectAllowed = 'move';\n }\n }\n onDragOver={\n readOnly\n ? undefined\n : e => {\n e.preventDefault();\n e.dataTransfer.dropEffect = 'move';\n setIsDragOver(true);\n }\n }\n onDragLeave={readOnly ? undefined : () => setIsDragOver(false)}\n onDrop={\n readOnly\n ? undefined\n : e => {\n e.preventDefault();\n setIsDragOver(false);\n try {\n const data = JSON.parse(\n e.dataTransfer.getData('application/x-graphiql-item'),\n );\n onMove(data.collectionId, data.index, collectionId, index);\n } catch {\n // malformed drag data\n }\n }\n }\n onClick={() => {\n if (!isEditing) {\n onOpen(item);\n }\n }}\n >\n <button\n type=\"button\"\n className=\"graphiql-collection-drag-handle\"\n data-collection-drag-handle={item.id}\n aria-label={`Reorder ${item.name}. Press space to grab, arrow keys to move, escape to cancel.`}\n aria-pressed={isGrabbed}\n disabled={readOnly}\n onClick={e => e.stopPropagation()}\n onKeyDown={e => {\n if (e.key === ' ' || e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n onGrabToggle();\n } else if (isGrabbed && e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n onGrabMove('down');\n } else if (isGrabbed && e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n onGrabMove('up');\n } else if (isGrabbed && e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n onGrabCancel();\n }\n }}\n >\n ⠿\n </button>\n {method === 'mix' ? (\n <span\n className=\"graphiql-method-pill graphiql-collection-method-pill-mix\"\n aria-hidden\n >\n MIX\n </span>\n ) : (\n <MethodPill operation={method} aria-hidden />\n )}\n {isEditing ? (\n <div\n ref={editFormRef}\n className=\"graphiql-collection-item-edit-form\"\n onClick={e => e.stopPropagation()}\n >\n <input\n className=\"graphiql-collection-item-edit-input\"\n value={editName}\n autoFocus\n placeholder={item.name}\n onChange={e => setEditName(e.target.value)}\n onBlur={handleBlur}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n commitEdit();\n }\n if (e.key === 'Escape') {\n cancelEdit();\n }\n e.stopPropagation();\n }}\n />\n <input\n className=\"graphiql-collection-item-edit-input\"\n value={editDescription}\n placeholder=\"Description (optional)\"\n onChange={e => setEditDescription(e.target.value)}\n onBlur={handleBlur}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n commitEdit();\n }\n if (e.key === 'Escape') {\n cancelEdit();\n }\n e.stopPropagation();\n }}\n />\n </div>\n ) : (\n <div className=\"graphiql-collection-item-main\">\n <span className=\"graphiql-collection-item-name\" title={item.name}>\n {item.name}\n </span>\n {item.description && (\n <span\n className=\"graphiql-collection-item-description\"\n title={item.description}\n >\n {item.description}\n </span>\n )}\n </div>\n )}\n {!isEditing && (\n <div className=\"graphiql-collection-item-actions\">\n {!readOnly && (\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Rename ${item.name}`}\n title=\"Rename\"\n onClick={startEdit}\n >\n <PenIcon aria-hidden=\"true\" />\n </button>\n )}\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Copy operation ${item.name}`}\n title=\"Copy operation\"\n data-confirmed={confirmed === 'copy' || undefined}\n onClick={e => {\n e.stopPropagation();\n void runAction(\n 'copy',\n () => navigator.clipboard.writeText(item.query),\n 'Copied query to clipboard.',\n 'Could not copy to clipboard.',\n );\n }}\n >\n {confirmed === 'copy' ? (\n <CheckIcon aria-hidden=\"true\" />\n ) : (\n <CopyIcon aria-hidden=\"true\" />\n )}\n </button>\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Share ${item.name} as collection`}\n title=\"Share as collection\"\n data-confirmed={confirmed === 'share' || undefined}\n onClick={e => {\n e.stopPropagation();\n void runAction(\n 'share',\n () => onShare(item.id),\n 'Shared operation to clipboard.',\n 'Could not share to clipboard.',\n );\n }}\n >\n {confirmed === 'share' ? (\n <CheckIcon aria-hidden=\"true\" />\n ) : (\n <UploadIcon aria-hidden=\"true\" />\n )}\n </button>\n {!readOnly && (\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Delete ${item.name}`}\n title=\"Delete\"\n onClick={handleDelete}\n >\n <TrashIcon aria-hidden=\"true\" />\n </button>\n )}\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;AAmCA,IAAa,qBAAiD,EAC5D,MACA,cACA,OACA,WAAW,OACX,WACA,cACA,YACA,cACA,QACA,SACA,YACA,UACA,QACA,mBACI;CACJ,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,WAAW,gBAAgB,SAAkC,IAAI;CACxE,MAAM,CAAC,cAAc,mBAAmB,SAAS,CAAC;CAClD,MAAM,cAAc,OAAuB,IAAI;CAC/C,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK,IAAI;CAClD,MAAM,CAAC,iBAAiB,sBAAsB,SAC5C,KAAK,eAAe,EACtB;CACA,MAAM,SAAS,kBAAkB,KAAK,KAAK;CAI3C,MAAM,aAAa,MAAwB;EACzC,EAAE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BAAgB,cAAc,WAAW,KAAA;MACzC,UAAS,MAAK;OACZ,EAAE,gBAAgB;OAClB,UACE,eACM,QAAQ,KAAK,EAAE,GACrB,kCACA,+BACF;MACF;MAEC,UAAA,cAAc,UACb,oBAAC,UAAD,EAAW,eAAY,OAAQ,CAAA,IAE/B,oBAAC,WAAD,EAAY,eAAY,OAAQ,CAAA;KAE5B,CAAA;KACP,CAAC,YACA,oBAAC,UAAD;MACE,MAAK;MACL,WAAU;MACV,cAAY,UAAU,KAAK;MAC3B,OAAM;MACN,SAAS;MAET,UAAA,oBAAC,WAAD,EAAW,eAAY,OAAQ,CAAA;KACzB,CAAA;IAEP;;EAEJ;;AAET"}
@@ -1,162 +1,142 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useState, useEffect } from "react";
3
- import { PenIcon, TrashIcon } from "@graphiql/react";
4
- import { CollectionItemRow } from "./collection-item-row.js";
5
1
  import SvgUpload from "../icons/upload.js";
6
2
  import SvgCheck from "../icons/check.js";
7
- const CollectionRow = ({
8
- collection,
9
- expanded,
10
- onToggleExpand,
11
- readOnly = false,
12
- grabbed,
13
- onGrabToggle,
14
- onGrabMove,
15
- onGrabCancel,
16
- onRename,
17
- onDelete,
18
- onShareCollection,
19
- onOpenItem,
20
- onShare,
21
- onAnnounce,
22
- onDeleteItem,
23
- onMoveItem,
24
- onRenameItem
25
- }) => {
26
- const [isRenaming, setIsRenaming] = useState(false);
27
- const [renameValue, setRenameValue] = useState(collection.name);
28
- const [confirmed, setConfirmed] = useState(false);
29
- const [confirmToken, setConfirmToken] = useState(0);
30
- useEffect(() => {
31
- if (!confirmed) {
32
- return;
33
- }
34
- const timer = setTimeout(() => setConfirmed(false), 1500);
35
- return () => clearTimeout(timer);
36
- }, [confirmed, confirmToken]);
37
- const runShareCollection = async () => {
38
- try {
39
- await onShareCollection(collection.id);
40
- onAnnounce("Shared collection to clipboard.");
41
- setConfirmed(true);
42
- setConfirmToken((t) => t + 1);
43
- } catch {
44
- onAnnounce("Could not share to clipboard.");
45
- }
46
- };
47
- const commitRename = () => {
48
- if (renameValue.trim()) {
49
- onRename(collection.id, renameValue.trim());
50
- }
51
- setIsRenaming(false);
52
- };
53
- return /* @__PURE__ */ jsxs("div", { className: "graphiql-collection-row", children: [
54
- /* @__PURE__ */ jsxs("div", { className: "graphiql-collection-header", children: [
55
- isRenaming ? /* @__PURE__ */ jsx(
56
- "input",
57
- {
58
- className: "graphiql-collection-rename-input",
59
- value: renameValue,
60
- autoFocus: true,
61
- onChange: (e) => setRenameValue(e.target.value),
62
- onBlur: commitRename,
63
- onKeyDown: (e) => {
64
- if (e.key === "Enter") {
65
- commitRename();
66
- }
67
- if (e.key === "Escape") {
68
- setRenameValue(collection.name);
69
- setIsRenaming(false);
70
- }
71
- e.stopPropagation();
72
- }
73
- }
74
- ) : /* @__PURE__ */ jsxs(
75
- "button",
76
- {
77
- type: "button",
78
- className: "graphiql-collection-toggle",
79
- "aria-expanded": expanded,
80
- "aria-label": `Toggle ${collection.name}`,
81
- onClick: onToggleExpand,
82
- children: [
83
- /* @__PURE__ */ jsx("span", { className: "graphiql-collection-chevron", "aria-hidden": "true", children: expanded ? "▾" : "▸" }),
84
- /* @__PURE__ */ jsx("span", { className: "graphiql-collection-name", children: collection.name })
85
- ]
86
- }
87
- ),
88
- /* @__PURE__ */ jsx("span", { className: "graphiql-collection-badge", children: collection.items.length }),
89
- /* @__PURE__ */ jsxs("div", { className: "graphiql-collection-header-actions", children: [
90
- !readOnly && /* @__PURE__ */ jsx(
91
- "button",
92
- {
93
- type: "button",
94
- className: "graphiql-collection-header-action",
95
- "aria-label": `Rename ${collection.name}`,
96
- title: "Rename",
97
- onClick: (e) => {
98
- e.stopPropagation();
99
- setRenameValue(collection.name);
100
- setIsRenaming(true);
101
- },
102
- children: /* @__PURE__ */ jsx(PenIcon, { "aria-hidden": "true" })
103
- }
104
- ),
105
- /* @__PURE__ */ jsx(
106
- "button",
107
- {
108
- type: "button",
109
- className: "graphiql-collection-header-action",
110
- "aria-label": `Share ${collection.name}`,
111
- title: "Share collection",
112
- "data-confirmed": confirmed || void 0,
113
- onClick: (e) => {
114
- e.stopPropagation();
115
- void runShareCollection();
116
- },
117
- children: confirmed ? /* @__PURE__ */ jsx(SvgCheck, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(SvgUpload, { "aria-hidden": "true" })
118
- }
119
- ),
120
- !readOnly && /* @__PURE__ */ jsx(
121
- "button",
122
- {
123
- type: "button",
124
- className: "graphiql-collection-header-action",
125
- "aria-label": `Delete ${collection.name}`,
126
- title: "Delete",
127
- onClick: (e) => {
128
- e.stopPropagation();
129
- onDelete(collection.id);
130
- },
131
- children: /* @__PURE__ */ jsx(TrashIcon, { "aria-hidden": "true" })
132
- }
133
- )
134
- ] })
135
- ] }),
136
- expanded && collection.items.length > 0 && /* @__PURE__ */ jsx("div", { className: "graphiql-collection-items", children: collection.items.map((item, i) => /* @__PURE__ */ jsx(
137
- CollectionItemRow,
138
- {
139
- item,
140
- collectionId: collection.id,
141
- index: i,
142
- readOnly,
143
- isGrabbed: (grabbed == null ? void 0 : grabbed.collectionId) === collection.id && grabbed.index === i,
144
- onGrabToggle: () => onGrabToggle(collection.id, i, item.id),
145
- onGrabMove,
146
- onGrabCancel,
147
- onOpen: onOpenItem,
148
- onShare,
149
- onAnnounce,
150
- onDelete: onDeleteItem,
151
- onMove: onMoveItem,
152
- onRenameItem
153
- },
154
- item.id
155
- )) }),
156
- expanded && collection.items.length === 0 && /* @__PURE__ */ jsx("div", { className: "graphiql-collection-empty-hint", children: readOnly ? "No operations here yet." : "No operations here yet. Save a query to add it to this collection." })
157
- ] });
158
- };
159
- export {
160
- CollectionRow
3
+ import { CollectionItemRow } from "./collection-item-row.js";
4
+ import { useEffect, useState } from "react";
5
+ import { PenIcon, TrashIcon } from "@graphiql/react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ //#region src/components/collection-row.tsx
8
+ var CollectionRow = ({ collection, expanded, onToggleExpand, readOnly = false, grabbed, onGrabToggle, onGrabMove, onGrabCancel, onRename, onDelete, onShareCollection, onOpenItem, onShare, onAnnounce, onDeleteItem, onMoveItem, onRenameItem }) => {
9
+ const [isRenaming, setIsRenaming] = useState(false);
10
+ const [renameValue, setRenameValue] = useState(collection.name);
11
+ const [confirmed, setConfirmed] = useState(false);
12
+ const [confirmToken, setConfirmToken] = useState(0);
13
+ useEffect(() => {
14
+ if (!confirmed) return;
15
+ const timer = setTimeout(() => setConfirmed(false), 1500);
16
+ return () => clearTimeout(timer);
17
+ }, [confirmed, confirmToken]);
18
+ const runShareCollection = async () => {
19
+ try {
20
+ await onShareCollection(collection.id);
21
+ onAnnounce("Shared collection to clipboard.");
22
+ setConfirmed(true);
23
+ setConfirmToken((t) => t + 1);
24
+ } catch {
25
+ onAnnounce("Could not share to clipboard.");
26
+ }
27
+ };
28
+ const commitRename = () => {
29
+ if (renameValue.trim()) onRename(collection.id, renameValue.trim());
30
+ setIsRenaming(false);
31
+ };
32
+ return /* @__PURE__ */ jsxs("div", {
33
+ className: "graphiql-collection-row",
34
+ children: [
35
+ /* @__PURE__ */ jsxs("div", {
36
+ className: "graphiql-collection-header",
37
+ children: [
38
+ isRenaming ? /* @__PURE__ */ jsx("input", {
39
+ className: "graphiql-collection-rename-input",
40
+ value: renameValue,
41
+ autoFocus: true,
42
+ onChange: (e) => setRenameValue(e.target.value),
43
+ onBlur: commitRename,
44
+ onKeyDown: (e) => {
45
+ if (e.key === "Enter") commitRename();
46
+ if (e.key === "Escape") {
47
+ setRenameValue(collection.name);
48
+ setIsRenaming(false);
49
+ }
50
+ e.stopPropagation();
51
+ }
52
+ }) : /* @__PURE__ */ jsxs("button", {
53
+ type: "button",
54
+ className: "graphiql-collection-toggle",
55
+ "aria-expanded": expanded,
56
+ "aria-label": `Toggle ${collection.name}`,
57
+ onClick: onToggleExpand,
58
+ children: [/* @__PURE__ */ jsx("span", {
59
+ className: "graphiql-collection-chevron",
60
+ "aria-hidden": "true",
61
+ children: expanded ? "▾" : "▸"
62
+ }), /* @__PURE__ */ jsx("span", {
63
+ className: "graphiql-collection-name",
64
+ children: collection.name
65
+ })]
66
+ }),
67
+ /* @__PURE__ */ jsx("span", {
68
+ className: "graphiql-collection-badge",
69
+ children: collection.items.length
70
+ }),
71
+ /* @__PURE__ */ jsxs("div", {
72
+ className: "graphiql-collection-header-actions",
73
+ children: [
74
+ !readOnly && /* @__PURE__ */ jsx("button", {
75
+ type: "button",
76
+ className: "graphiql-collection-header-action",
77
+ "aria-label": `Rename ${collection.name}`,
78
+ title: "Rename",
79
+ onClick: (e) => {
80
+ e.stopPropagation();
81
+ setRenameValue(collection.name);
82
+ setIsRenaming(true);
83
+ },
84
+ children: /* @__PURE__ */ jsx(PenIcon, { "aria-hidden": "true" })
85
+ }),
86
+ /* @__PURE__ */ jsx("button", {
87
+ type: "button",
88
+ className: "graphiql-collection-header-action",
89
+ "aria-label": `Share ${collection.name}`,
90
+ title: "Share collection",
91
+ "data-confirmed": confirmed || void 0,
92
+ onClick: (e) => {
93
+ e.stopPropagation();
94
+ runShareCollection();
95
+ },
96
+ children: confirmed ? /* @__PURE__ */ jsx(SvgCheck, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(SvgUpload, { "aria-hidden": "true" })
97
+ }),
98
+ !readOnly && /* @__PURE__ */ jsx("button", {
99
+ type: "button",
100
+ className: "graphiql-collection-header-action",
101
+ "aria-label": `Delete ${collection.name}`,
102
+ title: "Delete",
103
+ onClick: (e) => {
104
+ e.stopPropagation();
105
+ onDelete(collection.id);
106
+ },
107
+ children: /* @__PURE__ */ jsx(TrashIcon, { "aria-hidden": "true" })
108
+ })
109
+ ]
110
+ })
111
+ ]
112
+ }),
113
+ expanded && collection.items.length > 0 && /* @__PURE__ */ jsx("div", {
114
+ className: "graphiql-collection-items",
115
+ children: collection.items.map((item, i) => /* @__PURE__ */ jsx(CollectionItemRow, {
116
+ item,
117
+ collectionId: collection.id,
118
+ index: i,
119
+ readOnly,
120
+ isGrabbed: grabbed?.collectionId === collection.id && grabbed.index === i,
121
+ onGrabToggle: () => onGrabToggle(collection.id, i, item.id),
122
+ onGrabMove,
123
+ onGrabCancel,
124
+ onOpen: onOpenItem,
125
+ onShare,
126
+ onAnnounce,
127
+ onDelete: onDeleteItem,
128
+ onMove: onMoveItem,
129
+ onRenameItem
130
+ }, item.id))
131
+ }),
132
+ expanded && collection.items.length === 0 && /* @__PURE__ */ jsx("div", {
133
+ className: "graphiql-collection-empty-hint",
134
+ children: readOnly ? "No operations here yet." : "No operations here yet. Save a query to add it to this collection."
135
+ })
136
+ ]
137
+ });
161
138
  };
162
- //# sourceMappingURL=collection-row.js.map
139
+ //#endregion
140
+ export { CollectionRow };
141
+
142
+ //# sourceMappingURL=collection-row.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection-row.js","sources":["../../src/components/collection-row.tsx"],"sourcesContent":["import { FC, useEffect, useState } from 'react';\nimport { PenIcon, TrashIcon } from '@graphiql/react';\nimport type { Collection, CollectionItem } from '../types';\nimport { CollectionItemRow } from './collection-item-row';\nimport UploadIcon from '../icons/upload.svg?react';\nimport CheckIcon from '../icons/check.svg?react';\n\ntype CollectionRowProps = {\n collection: Collection;\n expanded: boolean;\n onToggleExpand(): void;\n /** Hide write affordances (Rename, Delete, add-item) when true. */\n readOnly?: boolean;\n grabbed: { collectionId: string; index: number; itemId: string } | null;\n onGrabToggle(collectionId: string, index: number, itemId: string): void;\n onGrabMove(direction: 'up' | 'down'): void;\n onGrabCancel(): void;\n onRename(id: string, name: string): void;\n onDelete(id: string): void;\n onShareCollection(id: string): Promise<void>;\n onOpenItem(item: CollectionItem): void;\n onShare(itemId: string): Promise<void>;\n onAnnounce(message: string): void;\n onDeleteItem(collectionId: string, itemId: string): void;\n onMoveItem(\n fromCollectionId: string,\n fromIndex: number,\n toCollectionId: string,\n toIndex: number,\n ): void;\n onAddItem(\n collectionId: string,\n item: Omit<CollectionItem, 'id' | 'createdAt' | 'updatedAt'>,\n ): CollectionItem;\n onRenameItem(\n collectionId: string,\n itemId: string,\n updates: { name: string; description: string },\n ): void;\n};\n\nexport const CollectionRow: FC<CollectionRowProps> = ({\n collection,\n expanded,\n onToggleExpand,\n readOnly = false,\n grabbed,\n onGrabToggle,\n onGrabMove,\n onGrabCancel,\n onRename,\n onDelete,\n onShareCollection,\n onOpenItem,\n onShare,\n onAnnounce,\n onDeleteItem,\n onMoveItem,\n onRenameItem,\n}) => {\n const [isRenaming, setIsRenaming] = useState(false);\n const [renameValue, setRenameValue] = useState(collection.name);\n const [confirmed, setConfirmed] = useState(false);\n const [confirmToken, setConfirmToken] = useState(0);\n\n useEffect(() => {\n if (!confirmed) {\n return;\n }\n const timer = setTimeout(() => setConfirmed(false), 1500);\n return () => clearTimeout(timer);\n }, [confirmed, confirmToken]);\n\n const runShareCollection = async () => {\n try {\n await onShareCollection(collection.id);\n onAnnounce('Shared collection to clipboard.');\n setConfirmed(true);\n setConfirmToken(t => t + 1);\n } catch {\n onAnnounce('Could not share to clipboard.');\n }\n };\n\n const commitRename = () => {\n if (renameValue.trim()) {\n onRename(collection.id, renameValue.trim());\n }\n setIsRenaming(false);\n };\n\n return (\n <div className=\"graphiql-collection-row\">\n <div className=\"graphiql-collection-header\">\n {isRenaming ? (\n <input\n className=\"graphiql-collection-rename-input\"\n value={renameValue}\n autoFocus\n onChange={e => setRenameValue(e.target.value)}\n onBlur={commitRename}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n commitRename();\n }\n if (e.key === 'Escape') {\n setRenameValue(collection.name);\n setIsRenaming(false);\n }\n e.stopPropagation();\n }}\n />\n ) : (\n <button\n type=\"button\"\n className=\"graphiql-collection-toggle\"\n aria-expanded={expanded}\n aria-label={`Toggle ${collection.name}`}\n onClick={onToggleExpand}\n >\n <span className=\"graphiql-collection-chevron\" aria-hidden=\"true\">\n {expanded ? '▾' : '▸'}\n </span>\n <span className=\"graphiql-collection-name\">{collection.name}</span>\n </button>\n )}\n <span className=\"graphiql-collection-badge\">\n {collection.items.length}\n </span>\n <div className=\"graphiql-collection-header-actions\">\n {!readOnly && (\n <button\n type=\"button\"\n className=\"graphiql-collection-header-action\"\n aria-label={`Rename ${collection.name}`}\n title=\"Rename\"\n onClick={e => {\n e.stopPropagation();\n setRenameValue(collection.name);\n setIsRenaming(true);\n }}\n >\n <PenIcon aria-hidden=\"true\" />\n </button>\n )}\n <button\n type=\"button\"\n className=\"graphiql-collection-header-action\"\n aria-label={`Share ${collection.name}`}\n title=\"Share collection\"\n data-confirmed={confirmed || undefined}\n onClick={e => {\n e.stopPropagation();\n void runShareCollection();\n }}\n >\n {confirmed ? (\n <CheckIcon aria-hidden=\"true\" />\n ) : (\n <UploadIcon aria-hidden=\"true\" />\n )}\n </button>\n {!readOnly && (\n <button\n type=\"button\"\n className=\"graphiql-collection-header-action\"\n aria-label={`Delete ${collection.name}`}\n title=\"Delete\"\n onClick={e => {\n e.stopPropagation();\n onDelete(collection.id);\n }}\n >\n <TrashIcon aria-hidden=\"true\" />\n </button>\n )}\n </div>\n </div>\n {expanded && collection.items.length > 0 && (\n <div className=\"graphiql-collection-items\">\n {collection.items.map((item, i) => (\n <CollectionItemRow\n key={item.id}\n item={item}\n collectionId={collection.id}\n index={i}\n readOnly={readOnly}\n isGrabbed={\n grabbed?.collectionId === collection.id && grabbed.index === i\n }\n onGrabToggle={() => onGrabToggle(collection.id, i, item.id)}\n onGrabMove={onGrabMove}\n onGrabCancel={onGrabCancel}\n onOpen={onOpenItem}\n onShare={onShare}\n onAnnounce={onAnnounce}\n onDelete={onDeleteItem}\n onMove={onMoveItem}\n onRenameItem={onRenameItem}\n />\n ))}\n </div>\n )}\n {expanded && collection.items.length === 0 && (\n <div className=\"graphiql-collection-empty-hint\">\n {readOnly\n ? 'No operations here yet.'\n : 'No operations here yet. Save a query to add it to this collection.'}\n </div>\n )}\n </div>\n );\n};\n"],"names":["CheckIcon","UploadIcon"],"mappings":";;;;;;AAyCO,MAAM,gBAAwC,CAAC;AAAA,EACpD;AAAA,EACA;A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AA,IAE9B,oBAACC,WAAW,EAAA,eAAY,OAAO,CAAA;AAAA,UAAA;AAAA,QAEnC;AAAA,QACC,CAAC,YACA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,WAAU;AAAA,YACV,cAAY,UAAU,WAAW,IAAI;AAAA,YACrC,OAAM;AAAA,YACN,SAAS,CAAK,MAAA;AACZ,gBAAE,gBAAgB;AAClB,uBAAS,WAAW,EAAE;AAAA,YACxB;AAAA,YAEA,UAAA,oBAAC,WAAU,EAAA,eAAY,OAAO,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAChC,EAEJ,CAAA;AAAA,IAAA,GACF;AAAA,IACC,YAAY,WAAW,MAAM,SAAS,KACpC,oBAAA,OAAA,EAAI,WAAU,6BACZ,UAAW,WAAA,MAAM,IAAI,CAAC,MAAM,MAC3B;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC;AAAA,QACA,cAAc,WAAW;AAAA,QACzB,OAAO;AAAA,QACP;AAAA,QACA,YACE,mCAAS,kBAAiB,WAAW,MAAM,QAAQ,UAAU;AAAA,QAE/D,cAAc,MAAM,aAAa,WAAW,IAAI,GAAG,KAAK,EAAE;AAAA,QAC1D;AAAA,QACA;AAAA,QACA,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA,UAAU;AAAA,QACV,QAAQ;AAAA,QACR;AAAA,MAAA;AAAA,MAhBK,KAAK;AAAA,IAkBb,CAAA,GACH;AAAA,IAED,YAAY,WAAW,MAAM,WAAW,KACtC,oBAAA,OAAA,EAAI,WAAU,kCACZ,UACG,WAAA,4BACA,qEACN,CAAA;AAAA,EAAA,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"collection-row.js","names":[],"sources":["../../src/components/collection-row.tsx"],"sourcesContent":["import { FC, useEffect, useState } from 'react';\nimport { PenIcon, TrashIcon } from '@graphiql/react';\nimport type { Collection, CollectionItem } from '../types';\nimport { CollectionItemRow } from './collection-item-row';\nimport UploadIcon from '../icons/upload.svg?react';\nimport CheckIcon from '../icons/check.svg?react';\n\ntype CollectionRowProps = {\n collection: Collection;\n expanded: boolean;\n onToggleExpand(): void;\n /** Hide write affordances (Rename, Delete, add-item) when true. */\n readOnly?: boolean;\n grabbed: { collectionId: string; index: number; itemId: string } | null;\n onGrabToggle(collectionId: string, index: number, itemId: string): void;\n onGrabMove(direction: 'up' | 'down'): void;\n onGrabCancel(): void;\n onRename(id: string, name: string): void;\n onDelete(id: string): void;\n onShareCollection(id: string): Promise<void>;\n onOpenItem(item: CollectionItem): void;\n onShare(itemId: string): Promise<void>;\n onAnnounce(message: string): void;\n onDeleteItem(collectionId: string, itemId: string): void;\n onMoveItem(\n fromCollectionId: string,\n fromIndex: number,\n toCollectionId: string,\n toIndex: number,\n ): void;\n onAddItem(\n collectionId: string,\n item: Omit<CollectionItem, 'id' | 'createdAt' | 'updatedAt'>,\n ): CollectionItem;\n onRenameItem(\n collectionId: string,\n itemId: string,\n updates: { name: string; description: string },\n ): void;\n};\n\nexport const CollectionRow: FC<CollectionRowProps> = ({\n collection,\n expanded,\n onToggleExpand,\n readOnly = false,\n grabbed,\n onGrabToggle,\n onGrabMove,\n onGrabCancel,\n onRename,\n onDelete,\n onShareCollection,\n onOpenItem,\n onShare,\n onAnnounce,\n onDeleteItem,\n onMoveItem,\n onRenameItem,\n}) => {\n const [isRenaming, setIsRenaming] = useState(false);\n const [renameValue, setRenameValue] = useState(collection.name);\n const [confirmed, setConfirmed] = useState(false);\n const [confirmToken, setConfirmToken] = useState(0);\n\n useEffect(() => {\n if (!confirmed) {\n return;\n }\n const timer = setTimeout(() => setConfirmed(false), 1500);\n return () => clearTimeout(timer);\n }, [confirmed, confirmToken]);\n\n const runShareCollection = async () => {\n try {\n await onShareCollection(collection.id);\n onAnnounce('Shared collection to clipboard.');\n setConfirmed(true);\n setConfirmToken(t => t + 1);\n } catch {\n onAnnounce('Could not share to clipboard.');\n }\n };\n\n const commitRename = () => {\n if (renameValue.trim()) {\n onRename(collection.id, renameValue.trim());\n }\n setIsRenaming(false);\n };\n\n return (\n <div className=\"graphiql-collection-row\">\n <div className=\"graphiql-collection-header\">\n {isRenaming ? (\n <input\n className=\"graphiql-collection-rename-input\"\n value={renameValue}\n autoFocus\n onChange={e => setRenameValue(e.target.value)}\n onBlur={commitRename}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n commitRename();\n }\n if (e.key === 'Escape') {\n setRenameValue(collection.name);\n setIsRenaming(false);\n }\n e.stopPropagation();\n }}\n />\n ) : (\n <button\n type=\"button\"\n className=\"graphiql-collection-toggle\"\n aria-expanded={expanded}\n aria-label={`Toggle ${collection.name}`}\n onClick={onToggleExpand}\n >\n <span className=\"graphiql-collection-chevron\" aria-hidden=\"true\">\n {expanded ? '▾' : '▸'}\n </span>\n <span className=\"graphiql-collection-name\">{collection.name}</span>\n </button>\n )}\n <span className=\"graphiql-collection-badge\">\n {collection.items.length}\n </span>\n <div className=\"graphiql-collection-header-actions\">\n {!readOnly && (\n <button\n type=\"button\"\n className=\"graphiql-collection-header-action\"\n aria-label={`Rename ${collection.name}`}\n title=\"Rename\"\n onClick={e => {\n e.stopPropagation();\n setRenameValue(collection.name);\n setIsRenaming(true);\n }}\n >\n <PenIcon aria-hidden=\"true\" />\n </button>\n )}\n <button\n type=\"button\"\n className=\"graphiql-collection-header-action\"\n aria-label={`Share ${collection.name}`}\n title=\"Share collection\"\n data-confirmed={confirmed || undefined}\n onClick={e => {\n e.stopPropagation();\n void runShareCollection();\n }}\n >\n {confirmed ? (\n <CheckIcon aria-hidden=\"true\" />\n ) : (\n <UploadIcon aria-hidden=\"true\" />\n )}\n </button>\n {!readOnly && (\n <button\n type=\"button\"\n className=\"graphiql-collection-header-action\"\n aria-label={`Delete ${collection.name}`}\n title=\"Delete\"\n onClick={e => {\n e.stopPropagation();\n onDelete(collection.id);\n }}\n >\n <TrashIcon aria-hidden=\"true\" />\n </button>\n )}\n </div>\n </div>\n {expanded && collection.items.length > 0 && (\n <div className=\"graphiql-collection-items\">\n {collection.items.map((item, i) => (\n <CollectionItemRow\n key={item.id}\n item={item}\n collectionId={collection.id}\n index={i}\n readOnly={readOnly}\n isGrabbed={\n grabbed?.collectionId === collection.id && grabbed.index === i\n }\n onGrabToggle={() => onGrabToggle(collection.id, i, item.id)}\n onGrabMove={onGrabMove}\n onGrabCancel={onGrabCancel}\n onOpen={onOpenItem}\n onShare={onShare}\n onAnnounce={onAnnounce}\n onDelete={onDeleteItem}\n onMove={onMoveItem}\n onRenameItem={onRenameItem}\n />\n ))}\n </div>\n )}\n {expanded && collection.items.length === 0 && (\n <div className=\"graphiql-collection-empty-hint\">\n {readOnly\n ? 'No operations here yet.'\n : 'No operations here yet. Save a query to add it to this collection.'}\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;AAyCA,IAAa,iBAAyC,EACpD,YACA,UACA,gBACA,WAAW,OACX,SACA,cACA,YACA,cACA,UACA,UACA,mBACA,YACA,SACA,YACA,cACA,YACA,mBACI;CACJ,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,CAAC,aAAa,kBAAkB,SAAS,WAAW,IAAI;CAC9D,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,cAAc,mBAAmB,SAAS,CAAC;CAElD,gBAAgB;EACd,IAAI,CAAC,WACH;EAEF,MAAM,QAAQ,iBAAiB,aAAa,KAAK,GAAG,IAAI;EACxD,aAAa,aAAa,KAAK;CACjC,GAAG,CAAC,WAAW,YAAY,CAAC;CAE5B,MAAM,qBAAqB,YAAY;EACrC,IAAI;GACF,MAAM,kBAAkB,WAAW,EAAE;GACrC,WAAW,iCAAiC;GAC5C,aAAa,IAAI;GACjB,iBAAgB,MAAK,IAAI,CAAC;EAC5B,QAAQ;GACN,WAAW,+BAA+B;EAC5C;CACF;CAEA,MAAM,qBAAqB;EACzB,IAAI,YAAY,KAAK,GACnB,SAAS,WAAW,IAAI,YAAY,KAAK,CAAC;EAE5C,cAAc,KAAK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