-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1da0d9
commit 8e950ae
Showing
212 changed files
with
2,113 additions
and
2,081 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...it/demo/assets/DeleteOutlined-oAPYnq6c.js → ...it/demo/assets/DeleteOutlined-KSC0BHZd.js
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
ui-kit/demo/assets/EyeOutlined-B9jVFvSG.js → ui-kit/demo/assets/EyeOutlined-B_mcHe4i.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
ui-kit/demo/assets/Page05c3388fea664137be83236b516398dd-CzPw5hsZ.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import{r as i,j as o,D as s}from"./index-jRq8dFl9.js";import{P as n,C as a,h as m,d as l,a as d}from"./docco-DVswO1UK.js";import{B as p}from"./messageBox-A1wgNO27.js";import{D as c}from"./dFormModal-DuFw94ex.js";import{I as u}from"./inputField-DjpktlwZ.js";import{P as f}from"./passwordField-BcOkdDNE.js";import{F as h}from"./buttonsProps-C8-j13mC.js";import"./dForm-CmpnCynY.js";import"./index-h_fYsjXx.js";import"./modal-Bq0KGAYX.js";import"./index-CBQ57er9.js";import"./EyeOutlined-B_mcHe4i.js";import"./SearchOutlined-y0oc_54U.js";const e={},x={formId:"Test form",apiRef:e,confirmChanges:!0,fieldsProps:{field1:{component:u,label:"login",tooltip:"Login input"},field2:{component:f,label:"password",tooltip:"Password input"}},onSubmit:()=>new Promise((r,t)=>{setTimeout(()=>{Math.random()<.5?t({message:"Ошибка сохранения",code:400}):r({data:{login:"new login",password:"new password"}})},3e3)}),buttons:h(e)},F=()=>{const r=i.useCallback(()=>{e.open("create")},[]);return o.jsxs(o.Fragment,{children:[o.jsx("h1",{children:"Пример сохранения данных модальной формы"}),o.jsx("p",{children:"Для обеспечения сохранения необходимо в калбэк onSubmit передать функцию, возвращающую Promise, который при успешном ответе сервера (resolve) возвращает объект вида:"}),o.jsx("code",{children:'data:{имя_поля1: "значение", имя_поля2: "значение 2"...}'}),o.jsx("p",{children:"а при ошибке (reject)"}),o.jsx("code",{children:"error:{message: string, code: number}"}),o.jsx("p",{children:"Для примера, вероятность сбоя при сохранении 50%"}),o.jsx("p",{}),o.jsxs("div",{style:{maxWidth:500},children:[o.jsx(p,{onClick:r,children:"Open form"}),o.jsx(c,{...x})]})]})},A=r=>o.jsxs(n,{children:[o.jsx("div",{children:o.jsx(F,{})}),o.jsx(s,{}),o.jsx("div",{children:o.jsx(a,{items:[{key:1,label:"Show source",children:o.jsx(m,{language:"javascript",style:r.darkMode?l:d,showLineNumbers:!0,children:` | ||
import React, {useCallback} from 'react'; | ||
import {Button} from @krinopotam/ui-kit/button'; | ||
import {IDFormModalApi, DFormModal, IDFormModalProps} from @krinopotam/ui-kit/dFormModal'; | ||
import {InputField} from @krinopotam/ui-kit/dForm/fields/input/inputField"; | ||
import {PasswordField} from @krinopotam/ui-kit/dForm/fields/password/passwordField"; | ||
import {FormLayoutSwitch} from "../../common/buttonsProps"; | ||
const formApi = {} as IDFormModalApi; | ||
const formProps: IDFormModalProps = { | ||
formId: 'Test form', | ||
apiRef: formApi, | ||
confirmChanges: true, | ||
fieldsProps: { | ||
field1: {component: InputField, label: 'login', tooltip: 'Login input'}, | ||
field2: {component: PasswordField, label: 'password', tooltip: 'Password input'}, | ||
}, | ||
onSubmit: () => { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
if (Math.random() < 0.5) reject({message: 'Ошибка сохранения', code: 400}); | ||
else resolve({data: {login: 'new login', password: 'new password'}}); | ||
}, 3000); | ||
}); | ||
}, | ||
buttons: FormLayoutSwitch(formApi), | ||
} | ||
export const ModalFormSubmitting = (): React.JSX.Element => { | ||
const onClick = useCallback(() => { | ||
formApi.open('create'); | ||
}, []); | ||
return ( | ||
<> | ||
<div style={{maxWidth: 500}}> | ||
<Button onClick={onClick}>Open form</Button> | ||
<DFormModal {...formProps} /> | ||
</div> | ||
</> | ||
); | ||
}; | ||
`})}]})})]});export{A as Page05c3388fea664137be83236b516398dd,A as default}; |
Oops, something went wrong.