@thelol3882/sapar 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +380 -2
- package/dist/adapter-Y9yB3-q3.d.ts +14 -0
- package/dist/adapter-fFZPsINL.d.ts +14 -0
- package/dist/chunk-7B66QEMY.js +536 -0
- package/dist/chunk-7B66QEMY.js.map +1 -0
- package/dist/chunk-FM64UDKJ.js +893 -0
- package/dist/chunk-FM64UDKJ.js.map +1 -0
- package/dist/chunk-VC6XLWM3.js +176 -0
- package/dist/chunk-VC6XLWM3.js.map +1 -0
- package/dist/chunk-ZBVQGMR4.js +583 -0
- package/dist/chunk-ZBVQGMR4.js.map +1 -0
- package/dist/cli/index.js +1335 -0
- package/dist/core/index.d.ts +273 -0
- package/dist/core/index.js +71 -0
- package/dist/core/index.js.map +1 -0
- package/dist/expo/index.d.ts +189 -0
- package/dist/expo/index.js +39 -0
- package/dist/expo/index.js.map +1 -0
- package/dist/expo-router/index.d.ts +18 -0
- package/dist/expo-router/index.js +46 -0
- package/dist/expo-router/index.js.map +1 -0
- package/dist/next/index.d.ts +18 -0
- package/dist/next/index.js +49 -0
- package/dist/next/index.js.map +1 -0
- package/dist/presentation-CClsPRT6.d.ts +12 -0
- package/dist/react/index.d.ts +35 -0
- package/dist/react/index.js +29 -0
- package/dist/react/index.js.map +1 -0
- package/dist/rtk/index.d.ts +751 -0
- package/dist/rtk/index.js +114 -0
- package/dist/rtk/index.js.map +1 -0
- package/dist/stepCount-CTYYFWiV.d.ts +57 -0
- package/dist/types-CHD2pB5X.d.ts +192 -0
- package/dist/web/index.d.ts +112 -0
- package/dist/web/index.js +34 -0
- package/dist/web/index.js.map +1 -0
- package/package.json +147 -3
- package/templates/expo/AnnouncementModal.tsx +102 -0
- package/templates/expo/TourCard.tsx +112 -0
- package/templates/expo/WhatsNewButton.tsx +87 -0
- package/templates/expo/WhatsNewPanel.tsx +167 -0
- package/templates/mantine/AnnouncementModal.tsx +66 -0
- package/templates/mantine/TourCard.tsx +84 -0
- package/templates/mantine/WhatsNewButton.tsx +62 -0
- package/templates/mantine/WhatsNewPanel.tsx +129 -0
- package/templates/tailwind/AnnouncementModal.tsx +100 -0
- package/templates/tailwind/TourCard.tsx +69 -0
- package/templates/tailwind/WhatsNewButton.tsx +56 -0
- package/templates/tailwind/WhatsNewPanel.tsx +174 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
createWebAdapter
|
|
4
|
+
} from "../chunk-7B66QEMY.js";
|
|
5
|
+
import {
|
|
6
|
+
SaparProvider
|
|
7
|
+
} from "../chunk-VC6XLWM3.js";
|
|
8
|
+
import "../chunk-FM64UDKJ.js";
|
|
9
|
+
|
|
10
|
+
// src/next/NextSaparProvider.tsx
|
|
11
|
+
import { usePathname as usePathname2 } from "next/navigation";
|
|
12
|
+
|
|
13
|
+
// src/next/useNextSaparAdapter.ts
|
|
14
|
+
import { usePathname, useRouter } from "next/navigation";
|
|
15
|
+
import { useEffect, useRef, useState } from "react";
|
|
16
|
+
function useNextSaparAdapter(options = {}) {
|
|
17
|
+
const router = useRouter();
|
|
18
|
+
const pathname = usePathname();
|
|
19
|
+
const latest = useRef({ router, pathname });
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
latest.current = { router, pathname };
|
|
22
|
+
});
|
|
23
|
+
const [adapter] = useState(
|
|
24
|
+
() => createWebAdapter({
|
|
25
|
+
...options,
|
|
26
|
+
navigate: (route) => latest.current.router.push(route),
|
|
27
|
+
currentRoute: () => latest.current.pathname
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
return adapter;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/next/NextSaparProvider.tsx
|
|
34
|
+
import { jsx } from "react/jsx-runtime";
|
|
35
|
+
function NextSaparProvider({
|
|
36
|
+
children,
|
|
37
|
+
disableRouteTriggers = false,
|
|
38
|
+
adapterOptions,
|
|
39
|
+
...controllerOptions
|
|
40
|
+
}) {
|
|
41
|
+
const adapter = useNextSaparAdapter(adapterOptions);
|
|
42
|
+
const pathname = usePathname2();
|
|
43
|
+
return /* @__PURE__ */ jsx(SaparProvider, { ...controllerOptions, adapter, route: disableRouteTriggers ? void 0 : pathname, children });
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
NextSaparProvider,
|
|
47
|
+
useNextSaparAdapter
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/next/NextSaparProvider.tsx","../../src/next/useNextSaparAdapter.ts"],"sourcesContent":["'use client';\n\nimport { usePathname } from 'next/navigation';\nimport type { ReactNode } from 'react';\nimport type { SaparControllerOptions } from '../core';\nimport { SaparProvider } from '../react';\nimport { useNextSaparAdapter, type NextSaparAdapterOptions } from './useNextSaparAdapter';\n\nexport interface NextSaparProviderProps extends Omit<SaparControllerOptions, 'adapter'> {\n children: ReactNode;\n /** Stop reporting route changes, so tours and announcements are never offered automatically. */\n disableRouteTriggers?: boolean;\n adapterOptions?: NextSaparAdapterOptions;\n}\n\nexport function NextSaparProvider({\n children,\n disableRouteTriggers = false,\n adapterOptions,\n ...controllerOptions\n}: NextSaparProviderProps) {\n const adapter = useNextSaparAdapter(adapterOptions);\n const pathname = usePathname();\n\n return (\n <SaparProvider {...controllerOptions} adapter={adapter} route={disableRouteTriggers ? undefined : pathname}>\n {children}\n </SaparProvider>\n );\n}\n","'use client';\n\nimport { usePathname, useRouter } from 'next/navigation';\nimport { useEffect, useRef, useState } from 'react';\nimport type { PlatformAdapter } from '../core';\nimport { createWebAdapter, type WebAdapterOptions } from '../web';\n\nexport type NextSaparAdapterOptions = Pick<WebAdapterOptions, 'compactBreakpointPx' | 'session'>;\n\n/** Identity never changes; `options` are read on first render only. */\nexport function useNextSaparAdapter(options: NextSaparAdapterOptions = {}): PlatformAdapter {\n const router = useRouter();\n const pathname = usePathname();\n const latest = useRef({ router, pathname });\n useEffect(() => {\n latest.current = { router, pathname };\n });\n\n const [adapter] = useState(() =>\n createWebAdapter({\n ...options,\n navigate: (route) => latest.current.router.push(route),\n currentRoute: () => latest.current.pathname,\n }),\n );\n return adapter;\n}\n"],"mappings":";;;;;;;;;AAEA,SAAS,eAAAA,oBAAmB;;;ACA5B,SAAS,aAAa,iBAAiB;AACvC,SAAS,WAAW,QAAQ,gBAAgB;AAOrC,SAAS,oBAAoB,UAAmC,CAAC,GAAoB;AACxF,QAAM,SAAS,UAAU;AACzB,QAAM,WAAW,YAAY;AAC7B,QAAM,SAAS,OAAO,EAAE,QAAQ,SAAS,CAAC;AAC1C,YAAU,MAAM;AACZ,WAAO,UAAU,EAAE,QAAQ,SAAS;AAAA,EACxC,CAAC;AAED,QAAM,CAAC,OAAO,IAAI;AAAA,IAAS,MACvB,iBAAiB;AAAA,MACb,GAAG;AAAA,MACH,UAAU,CAAC,UAAU,OAAO,QAAQ,OAAO,KAAK,KAAK;AAAA,MACrD,cAAc,MAAM,OAAO,QAAQ;AAAA,IACvC,CAAC;AAAA,EACL;AACA,SAAO;AACX;;;ADDQ;AAVD,SAAS,kBAAkB;AAAA,EAC9B;AAAA,EACA,uBAAuB;AAAA,EACvB;AAAA,EACA,GAAG;AACP,GAA2B;AACvB,QAAM,UAAU,oBAAoB,cAAc;AAClD,QAAM,WAAWC,aAAY;AAE7B,SACI,oBAAC,iBAAe,GAAG,mBAAmB,SAAkB,OAAO,uBAAuB,SAAY,UAC7F,UACL;AAER;","names":["usePathname","usePathname"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type Presentation = 'auto' | 'anchored' | 'sheet';
|
|
2
|
+
interface PresentationInput {
|
|
3
|
+
presentation: Presentation;
|
|
4
|
+
/** The adapter reports a window narrower than its compact breakpoint. */
|
|
5
|
+
compact: boolean;
|
|
6
|
+
/** Whether the measured card fits beside the anchor; `undefined` until the card has been measured. */
|
|
7
|
+
fits: boolean | undefined;
|
|
8
|
+
}
|
|
9
|
+
/** `'auto'` is anchored unless the window is compact or the card is known not to fit beside the anchor. */
|
|
10
|
+
declare function resolvePresentation({ presentation, compact, fits }: PresentationInput): Exclude<Presentation, 'auto'>;
|
|
11
|
+
|
|
12
|
+
export { type Presentation as P, type PresentationInput as a, resolvePresentation as r };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { a as SaparController, b as PlatformAdapter, S as SaparControllerOptions, f as Announcement, m as InboxStatus, T as Tour } from '../types-CHD2pB5X.js';
|
|
4
|
+
export { A as AnnouncementInterruption, S as StepAnnouncement, a as StepCount, T as TourStepState, U as UseSaparResult, b as UseWhatsNewResult, d as defaultAnnounceStep, c as defaultProgress, u as useAnnouncementInterruption, e as useSapar, f as useSaparSnapshot, g as useTourStep, h as useWhatsNew } from '../stepCount-CTYYFWiV.js';
|
|
5
|
+
|
|
6
|
+
interface CommonProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Forwarded to the controller on change. Leave undefined to opt out of route triggers. */
|
|
9
|
+
route?: string;
|
|
10
|
+
}
|
|
11
|
+
type SaparProviderProps = CommonProps & ({
|
|
12
|
+
controller: SaparController;
|
|
13
|
+
adapter?: PlatformAdapter;
|
|
14
|
+
} | ({
|
|
15
|
+
controller?: undefined;
|
|
16
|
+
} & SaparControllerOptions));
|
|
17
|
+
declare function SaparProvider(props: SaparProviderProps): react.JSX.Element;
|
|
18
|
+
|
|
19
|
+
declare function useSaparController(): SaparController;
|
|
20
|
+
declare function useSaparAdapter(): PlatformAdapter | undefined;
|
|
21
|
+
|
|
22
|
+
interface WhatsNewPanelItem extends Announcement {
|
|
23
|
+
/** Unread when the panel was opened; stays true until it closes. */
|
|
24
|
+
isNew: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface UseWhatsNewPanelResult {
|
|
27
|
+
items: WhatsNewPanelItem[];
|
|
28
|
+
status: InboxStatus;
|
|
29
|
+
recordClick: (key: string) => void;
|
|
30
|
+
startTour: (tourOrKey: Tour | string) => Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
/** Marks what was unread as seen once per opening, while `isNew` keeps pointing at it until the panel closes. */
|
|
33
|
+
declare function useWhatsNewPanel(open: boolean): UseWhatsNewPanelResult;
|
|
34
|
+
|
|
35
|
+
export { SaparProvider, type SaparProviderProps, type UseWhatsNewPanelResult, type WhatsNewPanelItem, useSaparAdapter, useSaparController, useWhatsNewPanel };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
SaparProvider,
|
|
4
|
+
defaultAnnounceStep,
|
|
5
|
+
defaultProgress,
|
|
6
|
+
useAnnouncementInterruption,
|
|
7
|
+
useSapar,
|
|
8
|
+
useSaparAdapter,
|
|
9
|
+
useSaparController,
|
|
10
|
+
useSaparSnapshot,
|
|
11
|
+
useTourStep,
|
|
12
|
+
useWhatsNew,
|
|
13
|
+
useWhatsNewPanel
|
|
14
|
+
} from "../chunk-VC6XLWM3.js";
|
|
15
|
+
import "../chunk-FM64UDKJ.js";
|
|
16
|
+
export {
|
|
17
|
+
SaparProvider,
|
|
18
|
+
defaultAnnounceStep,
|
|
19
|
+
defaultProgress,
|
|
20
|
+
useAnnouncementInterruption,
|
|
21
|
+
useSapar,
|
|
22
|
+
useSaparAdapter,
|
|
23
|
+
useSaparController,
|
|
24
|
+
useSaparSnapshot,
|
|
25
|
+
useTourStep,
|
|
26
|
+
useWhatsNew,
|
|
27
|
+
useWhatsNewPanel
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|