Commit 9d5f882b authored by greg@1m's avatar greg@1m
Browse files

wip on doc using zod

parent d939fd83
......@@ -21,7 +21,7 @@ import { SettingsPopup } from './components/settingsView/settingsView.component'
import { useAppViewType } from './hooks/app/appView.hook';
import { Lightbox } from './components/Lightbox.component';
import { addKeyAction, getKeyModif, startListeningToKeys } from './managers/keys.manager';
import { PopupContext, usePromptPopup } from './hooks/app/usePromptPopup.hook';
import { usePromptPopup } from './hooks/app/usePromptPopup.hook';
import { useTabs } from './hooks/app/tabs.hook';
import { TabList } from './components/tabs/TabList.component';
import { WindowGrid } from './components/windowGrid/WindowGrid.component';
......@@ -282,7 +282,7 @@ export const App = () => {
{ /* API : making clientapi available everywhere */}
<ClientApiContext.Provider value={clientApi} >
<Global styles={GlobalCssApp()} />
<Global styles={GlobalCssApp()} />
<div role="dialog" className={`
main-wrapper
${api.userSettings.get('ui_sidebar') ? "with-sidebar" : "without-sidebar"}
......
......@@ -32,7 +32,7 @@ const myFunction = z
//@ts-ignore
window.myfun = myFunction
type myFunction = z.infer<typeof myFunction>;
console.log(122222333, User, myFunction, JSON.stringify(myFunction.returnType()), myFunction.returnType()._def.typeName);
// console.log(122222333, User, myFunction, JSON.stringify(myFunction.returnType()), myFunction.returnType()._def.typeName);
// en gros je peux creer des types et objets
// en deduire des types
// et je peux generer une docuentation
......@@ -51,7 +51,8 @@ const myBiggerObject = z.object({
//@ts-ignore
window.test2 = myBiggerObject
console.log(122222333, myBiggerObject, JSON.stringify(myBiggerObject));
// console.log(122222333, z.(myBiggerObject));
// console.log(122222333, typeof myBiggerObject, JSON.stringify(myBiggerObject));
......
import React, { useEffect, useRef, useState } from 'react';
import { Popup } from '../../components/Popup.component';
import { strings } from '../../managers/strings.manager';
import z, { Function, obj, fn, string, number, boolean } from "../../managers/types.manager";
const liveVars: {
onAccept: Function,
......@@ -11,15 +10,42 @@ const liveVars: {
onRefuse: () => { },
}
export type iPrompt = (p: {
text: string,
title?: string,
onAccept?: Function,
onRefuse?: Function
}) => void
// INTERFACES
const zPrompt = z.function()
.args(z.object({
text: string,
title: string.optional(),
onAccept: fn.optional(),
onRefuse: fn.optional()
}))
.returns(z.void())
const zConfirmPopup = z.function().args(z.string({ description: "woop" }), z.number({ description: "wooop2" })).returns(z.void())
// const test = z.function().args(z.string().describe("woo"))
const test = z.function().args(z.string({}))
type iTest = z.infer<typeof test>
type iPrompt = z.infer<typeof zPrompt>
type iConfirm = z.infer<typeof zConfirmPopup>
export type iConfirmPopup = (text: string, cb: Function) => void
export type iPopupApi = { confirm: iConfirmPopup, prompt: iPrompt }
export const PopupContext = React.createContext<iPopupApi | null>(null);
// old
// export type iPrompt = (p: {
// text: string,
// title?: string,
// onAccept?: Function,
// onRefuse?: Function
// }) => void
export const usePromptPopup = (p: {
}) => {
......
import { z } from "zod";
// override Function type to be compatible with zod infered ts
export const obj = z.object
export const string = z.string()
export const number = z.number()
export const boolean = z.boolean()
export const fn = z.function()
export type Function = z.infer<typeof fn>
// export const func = (args, res) => {
// return z.function()
// .args(...args)
// .returns(res)
// }
// export const getType = (T) => z.infer < typeof T >
// exporting z
export default z
{
"name": "tiro-notes",
"version": "0.30.33-dev",
"version": "0.30.34-dev",
"description": "Tiro Notes CLI to start Tiro Notes from the command line!",
"scripts": {
"dev": "ISDEV=true node cli.js",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment