@fias/arche-sdk 1.6.0 → 1.8.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/dist/cli/create-plugin.js +0 -0
- package/dist/hooks.d.ts +24 -11
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +142 -29
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.test.js +191 -0
- package/dist/hooks.test.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +92 -16
- package/dist/types.d.ts +20 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/templates/default/AGENTS.md +103 -3
- package/templates/default/CLAUDE.md +102 -2
- package/templates/multi-step/README.md +13 -0
- package/templates/multi-step/fias-plugin.json +11 -0
- package/templates/multi-step/index.html +12 -0
- package/templates/multi-step/package.json +26 -0
- package/templates/multi-step/src/App.tsx +38 -0
- package/templates/multi-step/src/context/AppContext.tsx +36 -0
- package/templates/multi-step/src/index.tsx +12 -0
- package/templates/multi-step/src/steps/step-one/StepOne.tsx +43 -0
- package/templates/multi-step/src/steps/step-two/StepTwo.tsx +40 -0
- package/templates/multi-step/tsconfig.json +17 -0
- package/templates/multi-step/vite.config.ts +18 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createContext, useContext, ReactNode } from 'react';
|
|
2
|
+
import { usePersistentState } from '@fias/arche-sdk';
|
|
3
|
+
|
|
4
|
+
interface AppContextValue {
|
|
5
|
+
currentStep: string | null;
|
|
6
|
+
setCurrentStep: (step: string | null) => void;
|
|
7
|
+
// Domain data — safe to persist with usePersistentState.
|
|
8
|
+
notes: string;
|
|
9
|
+
setNotes: (value: string) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const AppContext = createContext<AppContextValue | null>(null);
|
|
13
|
+
|
|
14
|
+
interface AppProviderProps {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
currentStep: string | null;
|
|
17
|
+
setCurrentStep: (step: string | null) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function AppProvider({ children, currentStep, setCurrentStep }: AppProviderProps) {
|
|
21
|
+
// Step navigation comes in from useStepNavigation (in App.tsx) — the single
|
|
22
|
+
// source of truth. Only domain data lives in usePersistentState here.
|
|
23
|
+
const [notes, setNotes] = usePersistentState<string>('notes', '');
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<AppContext.Provider value={{ currentStep, setCurrentStep, notes, setNotes }}>
|
|
27
|
+
{children}
|
|
28
|
+
</AppContext.Provider>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function useAppContext(): AppContextValue {
|
|
33
|
+
const ctx = useContext(AppContext);
|
|
34
|
+
if (!ctx) throw new Error('useAppContext must be used within AppProvider');
|
|
35
|
+
return ctx;
|
|
36
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
import { FiasProvider } from '@fias/arche-sdk';
|
|
4
|
+
import { App } from './App';
|
|
5
|
+
|
|
6
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
7
|
+
<React.StrictMode>
|
|
8
|
+
<FiasProvider>
|
|
9
|
+
<App />
|
|
10
|
+
</FiasProvider>
|
|
11
|
+
</React.StrictMode>,
|
|
12
|
+
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useFiasTheme } from '@fias/arche-sdk';
|
|
2
|
+
import { useAppContext } from '../../context/AppContext';
|
|
3
|
+
|
|
4
|
+
export function StepOne() {
|
|
5
|
+
const theme = useFiasTheme();
|
|
6
|
+
const { notes, setNotes, setCurrentStep } = useAppContext();
|
|
7
|
+
|
|
8
|
+
if (!theme) return null;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<div>
|
|
12
|
+
<h1 style={{ fontFamily: theme.fonts.heading }}>Step 1 — Notes</h1>
|
|
13
|
+
<textarea
|
|
14
|
+
value={notes}
|
|
15
|
+
onChange={(e) => setNotes(e.target.value)}
|
|
16
|
+
rows={6}
|
|
17
|
+
style={{
|
|
18
|
+
width: '100%',
|
|
19
|
+
padding: theme.spacing.sm,
|
|
20
|
+
backgroundColor: theme.colors.surface,
|
|
21
|
+
color: theme.colors.text,
|
|
22
|
+
border: `${theme.components.borderWidth} solid ${theme.colors.border}`,
|
|
23
|
+
borderRadius: theme.components.inputRadius,
|
|
24
|
+
}}
|
|
25
|
+
/>
|
|
26
|
+
<button
|
|
27
|
+
onClick={() => setCurrentStep('step-two')}
|
|
28
|
+
disabled={notes.trim().length === 0}
|
|
29
|
+
style={{
|
|
30
|
+
marginTop: theme.spacing.md,
|
|
31
|
+
padding: `${theme.spacing.sm} ${theme.spacing.lg}`,
|
|
32
|
+
backgroundColor: theme.colors.primary,
|
|
33
|
+
color: theme.colors.primaryText,
|
|
34
|
+
border: 'none',
|
|
35
|
+
borderRadius: theme.components.buttonRadius,
|
|
36
|
+
cursor: notes.trim().length === 0 ? 'not-allowed' : 'pointer',
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
Next
|
|
40
|
+
</button>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useFiasTheme } from '@fias/arche-sdk';
|
|
2
|
+
import { useAppContext } from '../../context/AppContext';
|
|
3
|
+
|
|
4
|
+
export function StepTwo() {
|
|
5
|
+
const theme = useFiasTheme();
|
|
6
|
+
const { notes, setCurrentStep } = useAppContext();
|
|
7
|
+
|
|
8
|
+
if (!theme) return null;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<div>
|
|
12
|
+
<h1 style={{ fontFamily: theme.fonts.heading }}>Step 2 — Review</h1>
|
|
13
|
+
<pre
|
|
14
|
+
style={{
|
|
15
|
+
padding: theme.spacing.md,
|
|
16
|
+
backgroundColor: theme.colors.surface,
|
|
17
|
+
color: theme.colors.text,
|
|
18
|
+
borderRadius: theme.components.cardRadius,
|
|
19
|
+
whiteSpace: 'pre-wrap',
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
{notes}
|
|
23
|
+
</pre>
|
|
24
|
+
<button
|
|
25
|
+
onClick={() => setCurrentStep('step-one')}
|
|
26
|
+
style={{
|
|
27
|
+
marginTop: theme.spacing.md,
|
|
28
|
+
padding: `${theme.spacing.sm} ${theme.spacing.lg}`,
|
|
29
|
+
backgroundColor: theme.colors.surface,
|
|
30
|
+
color: theme.colors.text,
|
|
31
|
+
border: `${theme.components.borderWidth} solid ${theme.colors.border}`,
|
|
32
|
+
borderRadius: theme.components.buttonRadius,
|
|
33
|
+
cursor: 'pointer',
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
Back
|
|
37
|
+
</button>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"noEmit": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src"]
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [react()],
|
|
6
|
+
build: {
|
|
7
|
+
outDir: 'dist',
|
|
8
|
+
rollupOptions: {
|
|
9
|
+
input: 'index.html',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
server: {
|
|
13
|
+
port: 3100,
|
|
14
|
+
cors: true,
|
|
15
|
+
headers: { 'Access-Control-Allow-Origin': '*' },
|
|
16
|
+
hmr: { host: 'localhost' },
|
|
17
|
+
},
|
|
18
|
+
});
|