@graphiql/plugin-collections 1.0.0-beta.2 → 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.
package/README.md CHANGED
@@ -16,14 +16,14 @@ npm install react react-dom graphql @graphiql/react
16
16
 
17
17
  ## Usage
18
18
 
19
- The collections plugin is installed by default in GraphiQL, so an unmodified `<GraphiQL>` already shows a Collections rail icon. You only need to register it explicitly to configure it, for example to supply a custom storage backend or restrict what users can do.
19
+ The collections plugin is installed by default in GraphiQL, so an unmodified `<GraphiQL>` already shows a Collections rail icon. Use `COLLECTIONS_PLUGIN` when you pass a custom `plugins` array and want to keep the default collections configuration. Use `collectionsPlugin(options)` to supply a custom storage backend or restrict what users can do.
20
20
 
21
21
  > **Note:** passing the `plugins` prop replaces the default plugin set, so include the others you want alongside it.
22
22
 
23
23
  ```jsx
24
24
  import { GraphiQL } from 'graphiql';
25
25
  import { createTransport } from '@graphiql/toolkit';
26
- import { collectionsPlugin } from '@graphiql/plugin-collections';
26
+ import { COLLECTIONS_PLUGIN } from '@graphiql/plugin-collections';
27
27
  import 'graphiql/style.css';
28
28
  import '@graphiql/plugin-collections/style.css';
29
29
 
@@ -31,10 +31,8 @@ const transport = createTransport({
31
31
  url: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
32
32
  });
33
33
 
34
- const collections = collectionsPlugin();
35
-
36
34
  function GraphiQLWithCollections() {
37
- return <GraphiQL transport={transport} plugins={[collections]} />;
35
+ return <GraphiQL transport={transport} plugins={[COLLECTIONS_PLUGIN]} />;
38
36
  }
39
37
  ```
40
38
 
@@ -155,7 +153,8 @@ await actions.reload();
155
153
 
156
154
  ## Exports
157
155
 
158
- - `collectionsPlugin(options?)` — the plugin factory
156
+ - `COLLECTIONS_PLUGIN` — the default plugin configuration
157
+ - `collectionsPlugin(options?)` — the plugin factory for custom configuration
159
158
  - `collectionsStore`, `useCollectionsStore` — the store and its React hook
160
159
  - `createLocalStorageAdapter(key)`, `localStorageAdapter` — built-in storage
161
160
  - `CollectionsSaveDialog` — the save dialog component
package/dist/index.d.ts CHANGED
@@ -15,3 +15,4 @@ export type CollectionsPluginOptions = {
15
15
  allowReplace?: boolean;
16
16
  };
17
17
  export declare const collectionsPlugin: (options?: CollectionsPluginOptions) => GraphiQLPlugin;
18
+ export declare const COLLECTIONS_PLUGIN: GraphiQLPlugin;
package/dist/index.js CHANGED
@@ -30,7 +30,8 @@ var collectionsPlugin = (options) => {
30
30
  sessionActions: CollectionsSessionActionsWithOptions
31
31
  };
32
32
  };
33
+ var COLLECTIONS_PLUGIN = collectionsPlugin();
33
34
  //#endregion
34
- export { SaveDialog as CollectionsSaveDialog, collectionsPlugin, collectionsStore, createLocalStorageAdapter, localStorageAdapter, useCollectionsStore };
35
+ export { COLLECTIONS_PLUGIN, SaveDialog as CollectionsSaveDialog, collectionsPlugin, collectionsStore, createLocalStorageAdapter, localStorageAdapter, useCollectionsStore };
35
36
 
36
37
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.tsx"],"sourcesContent":["import type { GraphiQLPlugin } from '@graphiql/react';\nimport { CollectionsPanel } from './components/collections-panel';\nimport { CollectionsSessionActions } from './components/session-actions';\nimport CollectionsIcon from './icons/collections.svg?react';\nimport type { CollectionsStorage } from './types';\nimport './index.css';\n\nexport type {\n CollectionsStorage,\n CollectionsConfig,\n Collection,\n CollectionItem,\n} from './types';\nexport {\n collectionsStore,\n useCollectionsStore,\n type ActiveOperation,\n} from './store';\nexport {\n createLocalStorageAdapter,\n localStorageAdapter,\n} from './storage/local-storage';\nexport { SaveDialog as CollectionsSaveDialog } from './components/save-dialog';\n\nexport type CollectionsPluginOptions = {\n /** Custom storage adapter. Defaults to localStorage with key 'graphiql:collections'. */\n storage?: CollectionsStorage;\n /** Disable all write operations (export & copy still allowed). Default false. */\n readOnly?: boolean;\n /** Master switch for the import/export feature. Default true. */\n allowImportExport?: boolean;\n /** Allow the destructive \"Replace\" import option. Default true. */\n allowReplace?: boolean;\n};\n\nexport const collectionsPlugin = (\n options?: CollectionsPluginOptions,\n): GraphiQLPlugin => {\n function CollectionsPanelWithOptions() {\n return (\n <CollectionsPanel\n readOnly={options?.readOnly}\n allowImportExport={options?.allowImportExport}\n allowReplace={options?.allowReplace}\n />\n );\n }\n function CollectionsSessionActionsWithOptions() {\n return (\n <CollectionsSessionActions\n storage={options?.storage}\n readOnly={options?.readOnly}\n allowImportExport={options?.allowImportExport}\n allowReplace={options?.allowReplace}\n />\n );\n }\n return {\n title: 'Collections',\n icon: CollectionsIcon,\n content: CollectionsPanelWithOptions,\n sessionActions: CollectionsSessionActionsWithOptions,\n };\n};\n"],"mappings":";;;;;;;;;AAmCA,IAAa,qBACX,YACmB;CACnB,SAAS,8BAA8B;EACrC,OACE,oBAAC,kBAAD;GACE,UAAU,SAAS;GACnB,mBAAmB,SAAS;GAC5B,cAAc,SAAS;EACxB,CAAA;CAEL;CACA,SAAS,uCAAuC;EAC9C,OACE,oBAAC,2BAAD;GACE,SAAS,SAAS;GAClB,UAAU,SAAS;GACnB,mBAAmB,SAAS;GAC5B,cAAc,SAAS;EACxB,CAAA;CAEL;CACA,OAAO;EACL,OAAO;EACP,MAAM;EACN,SAAS;EACT,gBAAgB;CAClB;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.tsx"],"sourcesContent":["import type { GraphiQLPlugin } from '@graphiql/react';\nimport { CollectionsPanel } from './components/collections-panel';\nimport { CollectionsSessionActions } from './components/session-actions';\nimport CollectionsIcon from './icons/collections.svg?react';\nimport type { CollectionsStorage } from './types';\nimport './index.css';\n\nexport type {\n CollectionsStorage,\n CollectionsConfig,\n Collection,\n CollectionItem,\n} from './types';\nexport {\n collectionsStore,\n useCollectionsStore,\n type ActiveOperation,\n} from './store';\nexport {\n createLocalStorageAdapter,\n localStorageAdapter,\n} from './storage/local-storage';\nexport { SaveDialog as CollectionsSaveDialog } from './components/save-dialog';\n\nexport type CollectionsPluginOptions = {\n /** Custom storage adapter. Defaults to localStorage with key 'graphiql:collections'. */\n storage?: CollectionsStorage;\n /** Disable all write operations (export & copy still allowed). Default false. */\n readOnly?: boolean;\n /** Master switch for the import/export feature. Default true. */\n allowImportExport?: boolean;\n /** Allow the destructive \"Replace\" import option. Default true. */\n allowReplace?: boolean;\n};\n\nexport const collectionsPlugin = (\n options?: CollectionsPluginOptions,\n): GraphiQLPlugin => {\n function CollectionsPanelWithOptions() {\n return (\n <CollectionsPanel\n readOnly={options?.readOnly}\n allowImportExport={options?.allowImportExport}\n allowReplace={options?.allowReplace}\n />\n );\n }\n function CollectionsSessionActionsWithOptions() {\n return (\n <CollectionsSessionActions\n storage={options?.storage}\n readOnly={options?.readOnly}\n allowImportExport={options?.allowImportExport}\n allowReplace={options?.allowReplace}\n />\n );\n }\n return {\n title: 'Collections',\n icon: CollectionsIcon,\n content: CollectionsPanelWithOptions,\n sessionActions: CollectionsSessionActionsWithOptions,\n };\n};\n\nexport const COLLECTIONS_PLUGIN = collectionsPlugin();\n"],"mappings":";;;;;;;;;AAmCA,IAAa,qBACX,YACmB;CACnB,SAAS,8BAA8B;EACrC,OACE,oBAAC,kBAAD;GACE,UAAU,SAAS;GACnB,mBAAmB,SAAS;GAC5B,cAAc,SAAS;EACxB,CAAA;CAEL;CACA,SAAS,uCAAuC;EAC9C,OACE,oBAAC,2BAAD;GACE,SAAS,SAAS;GAClB,UAAU,SAAS;GACnB,mBAAmB,SAAS;GAC5B,cAAc,SAAS;EACxB,CAAA;CAEL;CACA,OAAO;EACL,OAAO;EACP,MAAM;EACN,SAAS;EACT,gBAAgB;CAClB;AACF;AAEA,IAAa,qBAAqB,kBAAkB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphiql/plugin-collections",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -36,13 +36,13 @@
36
36
  "zustand": "^5"
37
37
  },
38
38
  "peerDependencies": {
39
- "@graphiql/react": "1.0.0-beta.2",
39
+ "@graphiql/react": "1.0.0-beta.3",
40
40
  "graphql": "^16.11.0 || ^17.0.0",
41
41
  "react": "^18 || ^19",
42
42
  "react-dom": "^18 || ^19"
43
43
  },
44
44
  "devDependencies": {
45
- "@graphiql/react": "1.0.0-beta.2",
45
+ "@graphiql/react": "1.0.0-beta.3",
46
46
  "@storybook/react-vite": "^10.3.6",
47
47
  "@testing-library/dom": "^10.4.0",
48
48
  "@testing-library/jest-dom": "^7.0.1",