@automattic/launchpad 1.2.4 → 1.3.0

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 (78) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/action-components/share-site-modal/index.js +2 -2
  4. package/dist/cjs/action-components/share-site-modal/index.js.map +1 -1
  5. package/dist/cjs/checklist-item/style.scss +3 -1
  6. package/dist/cjs/index.js +4 -1
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/launchpad-internal.js +2 -2
  9. package/dist/cjs/launchpad-internal.js.map +1 -1
  10. package/dist/cjs/launchpad.js +5 -9
  11. package/dist/cjs/launchpad.js.map +1 -1
  12. package/dist/cjs/setup-actions.js +3 -3
  13. package/dist/cjs/setup-actions.js.map +1 -1
  14. package/dist/cjs/site-type.js +3 -0
  15. package/dist/cjs/site-type.js.map +1 -0
  16. package/dist/cjs/use-launchpad.js +151 -0
  17. package/dist/cjs/use-launchpad.js.map +1 -0
  18. package/dist/cjs/use-site.js +38 -0
  19. package/dist/cjs/use-site.js.map +1 -0
  20. package/dist/cjs/wpcom-request.js +24 -0
  21. package/dist/cjs/wpcom-request.js.map +1 -0
  22. package/dist/esm/action-components/share-site-modal/index.js +1 -1
  23. package/dist/esm/action-components/share-site-modal/index.js.map +1 -1
  24. package/dist/esm/checklist-item/style.scss +3 -1
  25. package/dist/esm/index.js +2 -0
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/launchpad-internal.js +1 -1
  28. package/dist/esm/launchpad-internal.js.map +1 -1
  29. package/dist/esm/launchpad.js +3 -6
  30. package/dist/esm/launchpad.js.map +1 -1
  31. package/dist/esm/setup-actions.js +1 -1
  32. package/dist/esm/setup-actions.js.map +1 -1
  33. package/dist/esm/site-type.js +2 -0
  34. package/dist/esm/site-type.js.map +1 -0
  35. package/dist/esm/use-launchpad.js +140 -0
  36. package/dist/esm/use-launchpad.js.map +1 -0
  37. package/dist/esm/use-site.js +33 -0
  38. package/dist/esm/use-site.js.map +1 -0
  39. package/dist/esm/wpcom-request.js +18 -0
  40. package/dist/esm/wpcom-request.js.map +1 -0
  41. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/dist/types/action-components/share-site-modal/index.d.ts +2 -2
  44. package/dist/types/action-components/share-site-modal/index.d.ts.map +1 -1
  45. package/dist/types/index.d.ts +2 -0
  46. package/dist/types/index.d.ts.map +1 -1
  47. package/dist/types/launchpad-internal.d.ts +3 -2
  48. package/dist/types/launchpad-internal.d.ts.map +1 -1
  49. package/dist/types/launchpad.d.ts +0 -1
  50. package/dist/types/launchpad.d.ts.map +1 -1
  51. package/dist/types/site-type.d.ts +10 -0
  52. package/dist/types/site-type.d.ts.map +1 -0
  53. package/dist/types/use-launchpad.d.ts +65 -0
  54. package/dist/types/use-launchpad.d.ts.map +1 -0
  55. package/dist/types/use-site.d.ts +8 -0
  56. package/dist/types/use-site.d.ts.map +1 -0
  57. package/dist/types/use-tracking/index.d.ts +2 -2
  58. package/dist/types/use-tracking/index.d.ts.map +1 -1
  59. package/dist/types/wpcom-request.d.ts +7 -0
  60. package/dist/types/wpcom-request.d.ts.map +1 -0
  61. package/package.json +11 -9
  62. package/src/action-components/share-site-modal/index.tsx +5 -5
  63. package/src/checklist-item/style.scss +3 -1
  64. package/src/index.ts +2 -0
  65. package/src/launchpad-internal.tsx +3 -3
  66. package/src/launchpad.tsx +3 -15
  67. package/src/setup-actions.ts +1 -1
  68. package/src/site-type.ts +9 -0
  69. package/src/test/launchpad.tsx +3 -1
  70. package/src/test/lib/fixtures.ts +1 -2
  71. package/src/test/setup-actions.ts +1 -1
  72. package/src/test/use-site.ts +60 -0
  73. package/src/use-launchpad.ts +249 -0
  74. package/src/use-site.ts +36 -0
  75. package/src/use-tracking/index.tsx +2 -2
  76. package/src/use-tracking/test/index.tsx +3 -3
  77. package/src/wpcom-request.ts +26 -0
  78. package/tsconfig.json +1 -5
@@ -1,9 +1,9 @@
1
+ import type { LaunchpadSiteDetails } from '../../site-type';
1
2
  import type { Task } from '../../types';
2
- import type { SiteDetails } from '@automattic/data-stores';
3
3
  import './style.scss';
4
4
  interface ShareSiteModalProps {
5
5
  setModalIsOpen: (isOpen: boolean) => void;
6
- site: SiteDetails | null;
6
+ site: LaunchpadSiteDetails | null;
7
7
  task: Task | null;
8
8
  }
9
9
  declare const ShareSiteModal: ({ setModalIsOpen, site, task }: ShareSiteModalProps) => import("react").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/action-components/share-site-modal/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,cAAc,CAAC;AAEtB,UAAU,mBAAmB;IAC5B,cAAc,EAAE,CAAE,MAAM,EAAE,OAAO,KAAM,IAAI,CAAC;IAC5C,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CAClB;AAkHD,QAAA,MAAM,cAAc,GAAK,gCAAgC,mBAAmB,gCAoH3E,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/action-components/share-site-modal/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,cAAc,CAAC;AAEtB,UAAU,mBAAmB;IAC5B,cAAc,EAAE,CAAE,MAAM,EAAE,OAAO,KAAM,IAAI,CAAC;IAC5C,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAClC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CAClB;AAkHD,QAAA,MAAM,cAAc,GAAK,gCAAgC,mBAAmB,gCAoH3E,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -6,4 +6,6 @@ export { default as Launchpad } from './launchpad';
6
6
  export { setUpActionsForTasks } from './setup-actions';
7
7
  export * from './action-components';
8
8
  export * from './types';
9
+ export * from './use-launchpad';
10
+ export { setRequester } from './wpcom-request';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import { type FC } from 'react';
2
+ import { type UseLaunchpadOptions } from './use-launchpad';
3
+ import type { LaunchpadSiteDetails } from './site-type';
2
4
  import type { Task } from './types';
3
- import type { SiteDetails, UseLaunchpadOptions } from '@automattic/data-stores';
4
5
  interface Props {
5
- site?: SiteDetails | null;
6
+ site?: LaunchpadSiteDetails | null;
6
7
  siteSlug: string | null;
7
8
  checklistSlug: string | null;
8
9
  makeLastTaskPrimaryAction?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"launchpad-internal.d.ts","sourceRoot":"","sources":["../../src/launchpad-internal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,EAAW,MAAM,OAAO,CAAC;AAIzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEhF,UAAU,KAAK;IACd,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,UAAU,CAAC,EAAE,CAAE,KAAK,EAAE,IAAI,EAAE,KAAM,IAAI,EAAE,CAAC;IACzC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,QAAA,MAAM,iBAAiB,EAAE,EAAE,CAAE,KAAK,CA+DjC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"launchpad-internal.d.ts","sourceRoot":"","sources":["../../src/launchpad-internal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAW,MAAM,OAAO,CAAC;AAGzC,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,UAAU,KAAK;IACd,IAAI,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACnC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,UAAU,CAAC,EAAE,CAAE,KAAK,EAAE,IAAI,EAAE,KAAM,IAAI,EAAE,CAAC;IACzC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,QAAA,MAAM,iBAAiB,EAAE,EAAE,CAAE,KAAK,CA+DjC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import type { EventHandlers, Task } from './types';
2
- export declare const SITE_STORE: "automattic/site";
3
2
  type LaunchpadProps = {
4
3
  siteSlug: string | null;
5
4
  checklistSlug: string;
@@ -1 +1 @@
1
- {"version":3,"file":"launchpad.d.ts","sourceRoot":"","sources":["../../src/launchpad.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEnD,eAAO,MAAM,UAAU,mBAAwD,CAAC;AAEhF,KAAK,cAAc,GAAG;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,aAAa,CAAE,aAAa,CAAE,CAAC;IAC7C,iBAAiB,CAAC,EAAE,CAAE,KAAK,EAAE,IAAI,EAAE,KAAM,IAAI,EAAE,CAAC;IAChD,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,QAAA,MAAM,SAAS,GAAK,qHAQjB,cAAc,uCAkEhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"launchpad.d.ts","sourceRoot":"","sources":["../../src/launchpad.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEnD,KAAK,cAAc,GAAG;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,aAAa,CAAE,aAAa,CAAE,CAAC;IAC7C,iBAAiB,CAAC,EAAE,CAAE,KAAK,EAAE,IAAI,EAAE,KAAM,IAAI,EAAE,CAAC;IAChD,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,QAAA,MAAM,SAAS,GAAK,qHAQjB,cAAc,uCA6DhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,10 @@
1
+ /** A full `SiteDetails` satisfies this. */
2
+ export interface LaunchpadSiteDetails {
3
+ slug?: string;
4
+ URL?: string;
5
+ options?: {
6
+ site_intent?: string;
7
+ site_goals?: string[];
8
+ };
9
+ }
10
+ //# sourceMappingURL=site-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-type.d.ts","sourceRoot":"","sources":["../../src/site-type.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,MAAM,WAAW,oBAAoB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE;QACT,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;CACF"}
@@ -0,0 +1,65 @@
1
+ interface Task {
2
+ id: string;
3
+ completed: boolean;
4
+ disabled: boolean;
5
+ title: string;
6
+ subtitle?: string;
7
+ badgeText?: string;
8
+ actionDispatch?: () => void;
9
+ isLaunchTask?: boolean;
10
+ warning?: boolean;
11
+ order?: number;
12
+ }
13
+ export interface ChecklistStatuses {
14
+ links_edited?: boolean;
15
+ site_edited?: boolean;
16
+ site_launched?: boolean;
17
+ first_post_published?: boolean;
18
+ video_uploaded?: boolean;
19
+ publish_first_course?: boolean;
20
+ plan_selected?: boolean;
21
+ plan_completed?: boolean;
22
+ domain_upsell_deferred?: boolean;
23
+ }
24
+ type LaunchpadScreen = 'full' | 'off' | 'skipped' | 'minimized';
25
+ export interface LaunchpadResponse {
26
+ site_intent?: string | null;
27
+ launchpad_screen?: LaunchpadScreen | boolean | null | undefined;
28
+ checklist?: Task[] | null;
29
+ checklist_statuses?: ChecklistStatuses;
30
+ is_enabled: boolean;
31
+ is_dismissed: boolean;
32
+ is_dismissible: boolean;
33
+ title?: string | null;
34
+ }
35
+ type LaunchpadUpdateSettings = {
36
+ checklist_statuses?: Record<string, boolean>;
37
+ is_checklist_dismissed?: {
38
+ slug: string;
39
+ is_dismissed?: boolean;
40
+ dismissed_until?: number | null;
41
+ };
42
+ launchpad_screen?: 'off' | 'minimized' | 'full' | 'skipped';
43
+ };
44
+ export type UseLaunchpadOptions = {
45
+ onSuccess?: (data: LaunchpadResponse) => LaunchpadResponse;
46
+ };
47
+ export declare const fetchLaunchpad: (siteSlug: SiteSlug, checklistSlug?: string | null, launchpadContext?: string) => Promise<LaunchpadResponse>;
48
+ export declare function sortLaunchpadTasksByCompletionStatus(response: LaunchpadResponse): LaunchpadResponse;
49
+ export declare function defaultSuccessCallback(response: LaunchpadResponse): LaunchpadResponse;
50
+ type SiteSlug = string | number | null;
51
+ export declare const useLaunchpad: (siteSlug: SiteSlug, checklistSlug?: string | null, options?: UseLaunchpadOptions, launchpad_context?: string | undefined) => import("@tanstack/react-query").DefinedUseQueryResult<LaunchpadResponse, Error>;
52
+ export declare const useSortedLaunchpadTasks: (siteSlug: SiteSlug, checklistSlug?: string | null, launchpadContext?: string) => import("@tanstack/react-query").DefinedUseQueryResult<LaunchpadResponse, Error>;
53
+ export declare const updateLaunchpadSettings: (siteSlug: SiteSlug, settings?: LaunchpadUpdateSettings) => Promise<unknown>;
54
+ export interface PermanentDismiss {
55
+ isDismissed: boolean;
56
+ }
57
+ export interface TemporaryDismiss {
58
+ dismissBy: '+ 1 day' | '+ 1 week';
59
+ }
60
+ type DismissSettings = PermanentDismiss | TemporaryDismiss;
61
+ export declare const useLaunchpadDismisser: (siteSlug: SiteSlug, checklistSlug: string, launchpadContext: string) => import("@tanstack/react-query").UseMutationResult<unknown, Error, DismissSettings, {
62
+ previous: LaunchpadResponse | undefined;
63
+ }>;
64
+ export {};
65
+ //# sourceMappingURL=use-launchpad.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-launchpad.d.ts","sourceRoot":"","sources":["../../src/use-launchpad.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,8 @@
1
+ import type { LaunchpadSiteDetails } from './site-type';
2
+ /**
3
+ * Fetches the site fields Launchpad reads. The response is the full site; only these
4
+ * fields are cached. Skipped where the proxy is unavailable, since there is no REST
5
+ * fallback, and kept for the session — both matching the site store this replaces.
6
+ */
7
+ export declare const useSite: (siteSlug: string | null) => LaunchpadSiteDetails | null;
8
+ //# sourceMappingURL=use-site.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-site.d.ts","sourceRoot":"","sources":["../../src/use-site.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAK,UAAU,MAAM,GAAG,IAAI,gCA0B/C,CAAC"}
@@ -1,10 +1,10 @@
1
+ import type { LaunchpadSiteDetails } from '../site-type';
1
2
  import type { Task } from '../types';
2
- import type { SiteDetails } from '@automattic/data-stores';
3
3
  interface Params {
4
4
  tasks: Task[];
5
5
  checklistSlug: string | null;
6
6
  context: string;
7
- site: SiteDetails | null | undefined;
7
+ site: LaunchpadSiteDetails | null | undefined;
8
8
  flow?: string;
9
9
  }
10
10
  export declare const useTracking: (params: Params) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/use-tracking/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,UAAU,MAAM;IACf,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAWD,eAAO,MAAM,WAAW,GAAK,QAAQ,MAAM;2BAoDX,IAAI;CAgBnC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/use-tracking/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,UAAU,MAAM;IACf,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,oBAAoB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAWD,eAAO,MAAM,WAAW,GAAK,QAAQ,MAAM;2BAoDX,IAAI;CAgBnC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type WpcomRequestParams } from 'wpcom-proxy-request';
2
+ type WpcomRequester = <T>(params: WpcomRequestParams) => Promise<T>;
3
+ export declare function setRequester(requester: WpcomRequester): void;
4
+ export default function wpcomRequest<T>(params: WpcomRequestParams): Promise<T>;
5
+ export declare function canAccessWpcomApis(): boolean;
6
+ export {};
7
+ //# sourceMappingURL=wpcom-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wpcom-request.d.ts","sourceRoot":"","sources":["../../src/wpcom-request.ts"],"names":[],"mappings":"AAAA,OAA0B,EACzB,KAAK,kBAAkB,EAEvB,MAAM,qBAAqB,CAAC;AAE7B,KAAK,cAAc,GAAG,CAAE,CAAC,EAAI,MAAM,EAAE,kBAAkB,KAAM,OAAO,CAAE,CAAC,CAAE,CAAC;AAI1E,wBAAgB,YAAY,CAAE,SAAS,EAAE,cAAc,GAAI,IAAI,CAE9D;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,CAAC,EAAI,MAAM,EAAE,kBAAkB,GAAI,OAAO,CAAE,CAAC,CAAE,CAKpF;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAK5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/launchpad",
3
- "version": "1.2.4",
3
+ "version": "1.3.0",
4
4
  "description": "Launchpad components.",
5
5
  "homepage": "https://github.com/Automattic/wp-calypso",
6
6
  "license": "GPL-2.0-or-later",
@@ -14,6 +14,9 @@
14
14
  "types": "./dist/types/index.d.ts",
15
15
  "import": "./dist/esm/index.js",
16
16
  "require": "./dist/cjs/index.js"
17
+ },
18
+ "./src/*": {
19
+ "calypso:src": "./src/*"
17
20
  }
18
21
  },
19
22
  "sideEffects": [
@@ -35,23 +38,25 @@
35
38
  "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets",
36
39
  "prepack": "yarn run clean && yarn run build",
37
40
  "watch": "tsc --build ./tsconfig.json --watch",
38
- "storybook:start": "storybook dev"
41
+ "storybook:start": "storybook dev -p 26837"
39
42
  },
40
43
  "dependencies": {
41
44
  "@automattic/calypso-analytics": "^1.1.5",
42
- "@automattic/data-stores": "^3.2.2",
43
45
  "@automattic/i18n-utils": "^1.3.0",
46
+ "@automattic/oauth-token": "^1.0.1",
44
47
  "@automattic/typography": "^1.0.0",
45
48
  "@automattic/viewport": "^1.1.1",
46
49
  "@tanstack/react-query": "^5.83.0",
50
+ "@wordpress/api-fetch": "^7.48.0",
47
51
  "@wordpress/base-styles": "^9.1.0",
48
- "@wordpress/components": "^35.0.0",
52
+ "@wordpress/components": "^37.0.0",
49
53
  "@wordpress/icons": "^13.3.0",
50
- "@wordpress/ui": "^0.17.0",
54
+ "@wordpress/ui": "^0.18.0",
55
+ "@wordpress/url": "^4.48.0",
51
56
  "clsx": "^2.1.1",
52
57
  "social-logos": "^3.1.18",
53
58
  "tslib": "^2.8.1",
54
- "wpcom-proxy-request": "^7.0.7"
59
+ "wpcom-proxy-request": "^7.1.0"
55
60
  },
56
61
  "devDependencies": {
57
62
  "@automattic/calypso-build": "^11.0.0",
@@ -68,10 +73,7 @@
68
73
  "webpack": "^5.99.8"
69
74
  },
70
75
  "peerDependencies": {
71
- "@wordpress/data": "^10.48.0",
72
- "@wordpress/element": "^8.0.0",
73
76
  "@wordpress/i18n": "^6.21.0",
74
- "debug": "^4.4.1",
75
77
  "react": "^18.3.1 || ^19.0.0",
76
78
  "react-dom": "^18.3.1 || ^19.0.0"
77
79
  }
@@ -1,5 +1,4 @@
1
1
  import { recordTracksEvent } from '@automattic/calypso-analytics';
2
- import { updateLaunchpadSettings } from '@automattic/data-stores';
3
2
  import { useQueryClient } from '@tanstack/react-query';
4
3
  import {
5
4
  Button,
@@ -13,13 +12,14 @@ import { __, sprintf } from '@wordpress/i18n';
13
12
  import { copy, share, check } from '@wordpress/icons';
14
13
  import { useState, useMemo, useCallback } from 'react';
15
14
  import { SocialLogo } from 'social-logos';
15
+ import { updateLaunchpadSettings } from '../../use-launchpad';
16
+ import type { LaunchpadSiteDetails } from '../../site-type';
16
17
  import type { Task } from '../../types';
17
- import type { SiteDetails } from '@automattic/data-stores';
18
18
  import './style.scss';
19
19
 
20
20
  interface ShareSiteModalProps {
21
21
  setModalIsOpen: ( isOpen: boolean ) => void;
22
- site: SiteDetails | null;
22
+ site: LaunchpadSiteDetails | null;
23
23
  task: Task | null;
24
24
  }
25
25
 
@@ -106,7 +106,7 @@ const getShareLinks = ( siteUrl: string, text: string ): ShareLink[] => {
106
106
  ];
107
107
  };
108
108
 
109
- const getSiteSlug = ( site: SiteDetails | null ) => {
109
+ const getSiteSlug = ( site: LaunchpadSiteDetails | null ) => {
110
110
  if ( ! site ) {
111
111
  return '';
112
112
  }
@@ -121,7 +121,7 @@ const getSiteSlug = ( site: SiteDetails | null ) => {
121
121
  return '';
122
122
  };
123
123
 
124
- const getShareData = ( site: SiteDetails | null ) => {
124
+ const getShareData = ( site: LaunchpadSiteDetails | null ) => {
125
125
  const siteSlug = getSiteSlug( site );
126
126
  return {
127
127
  title: siteSlug,
@@ -123,7 +123,8 @@
123
123
  // general styles
124
124
  .checklist-item__text {
125
125
  font-weight: 600;
126
- flex-grow: 1;
126
+ flex: 1 1 0%;
127
+ min-width: 0;
127
128
  text-align: left;
128
129
  }
129
130
 
@@ -236,6 +237,7 @@
236
237
  display: flex;
237
238
  line-height: 20px;
238
239
  width: 30px;
240
+ flex-shrink: 0;
239
241
  }
240
242
 
241
243
  .gridicon.checklist-item__chevron {
package/src/index.ts CHANGED
@@ -6,3 +6,5 @@ export { default as Launchpad } from './launchpad';
6
6
  export { setUpActionsForTasks } from './setup-actions';
7
7
  export * from './action-components';
8
8
  export * from './types';
9
+ export * from './use-launchpad';
10
+ export { setRequester } from './wpcom-request';
@@ -1,13 +1,13 @@
1
- import { useLaunchpad } from '@automattic/data-stores';
2
1
  import { type FC, useMemo } from 'react';
3
2
  import Checklist, { Placeholder as ChecklistPlaceHolder } from './checklist';
4
3
  import ChecklistItem from './checklist-item';
4
+ import { useLaunchpad, type UseLaunchpadOptions } from './use-launchpad';
5
5
  import { useTracking } from './use-tracking';
6
+ import type { LaunchpadSiteDetails } from './site-type';
6
7
  import type { Task } from './types';
7
- import type { SiteDetails, UseLaunchpadOptions } from '@automattic/data-stores';
8
8
 
9
9
  interface Props {
10
- site?: SiteDetails | null;
10
+ site?: LaunchpadSiteDetails | null;
11
11
  siteSlug: string | null;
12
12
  checklistSlug: string | null;
13
13
  makeLastTaskPrimaryAction?: boolean;
package/src/launchpad.tsx CHANGED
@@ -1,19 +1,12 @@
1
1
  import { recordTracksEvent } from '@automattic/calypso-analytics';
2
- import {
3
- Site,
4
- type SiteSelect,
5
- defaultSuccessCallback,
6
- useSortedLaunchpadTasks,
7
- } from '@automattic/data-stores';
8
- import { useSelect } from '@wordpress/data';
9
2
  import { useState } from 'react';
10
3
  import { ShareSiteModal } from './action-components';
11
4
  import LaunchpadInternal from './launchpad-internal';
12
5
  import { setUpActionsForTasks } from './setup-actions';
6
+ import { defaultSuccessCallback, useSortedLaunchpadTasks } from './use-launchpad';
7
+ import { useSite } from './use-site';
13
8
  import type { EventHandlers, Task } from './types';
14
9
 
15
- export const SITE_STORE = Site.register( { client_id: '', client_secret: '' } );
16
-
17
10
  type LaunchpadProps = {
18
11
  siteSlug: string | null;
19
12
  checklistSlug: string;
@@ -41,12 +34,7 @@ const Launchpad = ( {
41
34
 
42
35
  const tracksData = { recordTracksEvent, checklistSlug, tasklistCompleted, launchpadContext };
43
36
 
44
- const site = useSelect(
45
- ( select ) => {
46
- return siteSlug ? ( select( SITE_STORE ) as SiteSelect ).getSite( siteSlug ) : null;
47
- },
48
- [ siteSlug ]
49
- );
37
+ const site = useSite( siteSlug );
50
38
  const [ shareSiteModalIsOpen, setShareSiteModalIsOpen ] = useState( false );
51
39
 
52
40
  const taskFilter = ( tasks: Task[] ) => {
@@ -1,7 +1,7 @@
1
- import { updateLaunchpadSettings } from '@automattic/data-stores';
2
1
  import { localizeUrl } from '@automattic/i18n-utils';
3
2
  import { isMobile } from '@automattic/viewport';
4
3
  import wpcomRequest from 'wpcom-proxy-request';
4
+ import { updateLaunchpadSettings } from './use-launchpad';
5
5
  import type { LaunchpadTaskActionsProps, Task } from './types';
6
6
 
7
7
  const TASKS_TO_COMPLETE_ON_CLICK = [
@@ -0,0 +1,9 @@
1
+ /** A full `SiteDetails` satisfies this. */
2
+ export interface LaunchpadSiteDetails {
3
+ slug?: string;
4
+ URL?: string;
5
+ options?: {
6
+ site_intent?: string;
7
+ site_goals?: string[];
8
+ };
9
+ }
@@ -8,7 +8,9 @@ import type { Task } from '../types';
8
8
 
9
9
  jest.mock( '@automattic/calypso-analytics' );
10
10
 
11
- jest.mock( '@automattic/data-stores', () => {
11
+ jest.mock( '../use-launchpad', () => {
12
+ // jest.mock factories are hoisted above imports, so the fixture has to be required here.
13
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
12
14
  const { buildTask } = require( './lib/fixtures' );
13
15
  return {
14
16
  useLaunchpad: jest.fn( () => {
@@ -1,7 +1,6 @@
1
- import { SiteDetails } from '@automattic/data-stores/src/site';
2
1
  import { Task } from '../../types';
3
2
 
4
- export const defaultSiteDetails: SiteDetails = {
3
+ export const defaultSiteDetails = {
5
4
  ID: 211078228,
6
5
  title: 'Test Newsletter',
7
6
  name: 'testNewsletter',
@@ -5,7 +5,7 @@ import { setUpActionsForTasks } from '../setup-actions';
5
5
  import type { LaunchpadTaskActionsProps } from '../types';
6
6
 
7
7
  jest.mock( '@automattic/viewport', () => ( { isMobile: jest.fn( () => false ) } ) );
8
- jest.mock( '@automattic/data-stores', () => ( { updateLaunchpadSettings: jest.fn() } ) );
8
+ jest.mock( '../use-launchpad', () => ( { updateLaunchpadSettings: jest.fn() } ) );
9
9
 
10
10
  const runDriveTraffic = ( calypso_path: string ) => {
11
11
  const props: LaunchpadTaskActionsProps = {
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
5
+ import { renderHook, waitFor } from '@testing-library/react';
6
+ import React from 'react';
7
+ import { useSite } from '../use-site';
8
+ import wpcomRequest, { canAccessWpcomApis } from '../wpcom-request';
9
+
10
+ jest.mock( '../wpcom-request', () => ( {
11
+ __esModule: true,
12
+ default: jest.fn(),
13
+ canAccessWpcomApis: jest.fn(),
14
+ } ) );
15
+
16
+ const request = wpcomRequest as jest.Mock;
17
+ const canAccess = canAccessWpcomApis as jest.Mock;
18
+
19
+ const render = () => {
20
+ const client = new QueryClient( { defaultOptions: { queries: { retry: false } } } );
21
+ const wrapper = ( { children }: { children: React.ReactNode } ) =>
22
+ React.createElement( QueryClientProvider, { client }, children );
23
+ return renderHook( () => useSite( 'example.wordpress.com' ), { wrapper } );
24
+ };
25
+
26
+ describe( 'useSite', () => {
27
+ beforeEach( () => jest.clearAllMocks() );
28
+
29
+ it( 'keeps only the fields Launchpad reads, so the rest of the site is never cached', async () => {
30
+ canAccess.mockReturnValue( true );
31
+ request.mockResolvedValue( {
32
+ slug: 'example.wordpress.com',
33
+ URL: 'https://example.wordpress.com',
34
+ options: {
35
+ site_intent: 'build',
36
+ site_goals: [ 'sell' ],
37
+ jetpack_connection_active_plugins: [],
38
+ },
39
+ capabilities: { manage_options: true },
40
+ } );
41
+
42
+ const { result } = render();
43
+
44
+ await waitFor( () => expect( result.current ).not.toBeNull() );
45
+ expect( result.current ).toEqual( {
46
+ slug: 'example.wordpress.com',
47
+ URL: 'https://example.wordpress.com',
48
+ options: { site_intent: 'build', site_goals: [ 'sell' ] },
49
+ } );
50
+ } );
51
+
52
+ it( 'does not request where the proxy is unavailable, since there is no fallback', () => {
53
+ canAccess.mockReturnValue( false );
54
+
55
+ const { result } = render();
56
+
57
+ expect( request ).not.toHaveBeenCalled();
58
+ expect( result.current ).toBeNull();
59
+ } );
60
+ } );