Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
npm
common
Commits
bb02c978
Commit
bb02c978
authored
Nov 23, 2018
by
Vladislav Lagunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Переименование bindZoom -> createZoom
parent
36769d46
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
10 deletions
+12
-10
create-form/index.ts
+10
-9
fields/TextField.tsx
+1
-1
functions/find-map.ts
+1
-0
No files found.
create-form/index.ts
View file @
bb02c978
...
@@ -43,7 +43,7 @@ export type CardProps<T> = {
...
@@ -43,7 +43,7 @@ export type CardProps<T> = {
// Опции для `createForm`
// Опции для `createForm`
export
type
CreateFormOptions
<
T
>
=
{
export
type
CreateFormOptions
<
T
>
=
{
validate
?(
value
:
T
):
any
;
validate
?(
value
:
T
,
instance
):
any
;
disabled
?(
value
:
T
,
instance
):
any
;
disabled
?(
value
:
T
,
instance
):
any
;
};
};
...
@@ -51,14 +51,15 @@ export type CreateFormOptions<T> = {
...
@@ -51,14 +51,15 @@ export type CreateFormOptions<T> = {
export
default
function
createForm
<
O
extends
CreateFormOptions
<
any
>>
(
options
:
O
)
{
export
default
function
createForm
<
O
extends
CreateFormOptions
<
any
>>
(
options
:
O
)
{
type
T
=
O
extends
CreateFormOptions
<
infer
T
>
?
T
:
never
;
type
T
=
O
extends
CreateFormOptions
<
infer
T
>
?
T
:
never
;
function
bindZoom
(
self
:
React
.
Component
<
CardProps
<
T
>>
)
{
function
createZoom
(
self
:
React
.
Component
<
CardProps
<
T
>>
)
{
function
Zoom
<
K1
extends
keyof
T
,
C
extends
Any
<
T
[
K1
]
>>
(...
keys
:
[
K1
]):
FieldProps
<
T
[
K1
]
>
;
function
zoom
():
FieldProps
<
T
>
;
function
Zoom
<
K1
extends
keyof
T
,
K2
extends
keyof
T
[
K1
],
C
extends
Any
<
T
[
K1
][
K2
]
>>
(...
keys
:
[
K1
,
K2
]):
FieldProps
<
T
[
K1
][
K2
]
>
;
function
zoom
<
K1
extends
keyof
T
>
(...
keys
:
[
K1
]):
FieldProps
<
T
[
K1
]
>
;
function
Zoom
<
K1
extends
keyof
T
,
K2
extends
keyof
T
[
K1
],
K3
extends
keyof
T
[
K1
][
K2
],
C
extends
Any
<
T
[
K1
][
K2
][
K3
]
>>
(...
keys
:
[
K1
,
K2
,
K3
]):
FieldProps
<
T
[
K1
][
K2
][
K3
]
>
;
function
zoom
<
K1
extends
keyof
T
,
K2
extends
keyof
T
[
K1
]
>
(...
keys
:
[
K1
,
K2
]):
FieldProps
<
T
[
K1
][
K2
]
>
;
function
Zoom
(...
keys
)
{
function
zoom
<
K1
extends
keyof
T
,
K2
extends
keyof
T
[
K1
],
K3
extends
keyof
T
[
K1
][
K2
]
>
(...
keys
:
[
K1
,
K2
,
K3
]):
FieldProps
<
T
[
K1
][
K2
][
K3
]
>
;
function
zoom
(...
keys
)
{
const
{
dispatch
,
ctx
}
=
self
.
props
;
const
{
dispatch
,
ctx
}
=
self
.
props
;
const
value
=
self
.
props
.
model
.
modified
||
self
.
props
.
model
.
initial
;
const
value
=
self
.
props
.
model
.
modified
||
self
.
props
.
model
.
initial
;
const
error
=
options
.
validate
?
options
.
validate
(
value
)
:
{};
const
error
=
options
.
validate
?
options
.
validate
(
value
,
self
)
:
{};
const
disabled
=
options
.
disabled
?
options
.
disabled
(
value
,
self
)
:
{};
const
disabled
=
options
.
disabled
?
options
.
disabled
(
value
,
self
)
:
{};
const
onValueChange
=
(
value
,
at
:
ObjectPath
=
[])
=>
dispatch
({
tag
:
'Change'
,
value
,
at
});
const
onValueChange
=
(
value
,
at
:
ObjectPath
=
[])
=>
dispatch
({
tag
:
'Change'
,
value
,
at
});
...
@@ -70,7 +71,7 @@ export default function createForm<O extends CreateFormOptions<any>>(options: O)
...
@@ -70,7 +71,7 @@ export default function createForm<O extends CreateFormOptions<any>>(options: O)
onValueChange
:
zoomOnChange
(
keys
,
onValueChange
),
onValueChange
:
zoomOnChange
(
keys
,
onValueChange
),
};
};
}
}
return
Z
oom
;
return
z
oom
;
}
}
function
set
<
M
extends
CardProps
<
T
>
[
'model'
]
>
(
model
:
M
,
form
:
T
):
M
{
function
set
<
M
extends
CardProps
<
T
>
[
'model'
]
>
(
model
:
M
,
form
:
T
):
M
{
...
@@ -88,7 +89,7 @@ export default function createForm<O extends CreateFormOptions<any>>(options: O)
...
@@ -88,7 +89,7 @@ export default function createForm<O extends CreateFormOptions<any>>(options: O)
}
}
// @ts-ignore
// @ts-ignore
return
{
...
options
,
bindZoom
,
set
,
get
,
modify
}
as
{
bindZoom
:
typeof
bind
Zoom
,
set
:
typeof
set
,
get
:
typeof
get
,
modify
:
typeof
modify
}
&
O
;
return
{
...
options
,
createZoom
,
set
,
get
,
modify
}
as
{
createZoom
:
typeof
create
Zoom
,
set
:
typeof
set
,
get
:
typeof
get
,
modify
:
typeof
modify
}
&
O
;
}
}
...
...
fields/TextField.tsx
View file @
bb02c978
...
@@ -10,7 +10,7 @@ const eyeSlash = require('./eye-slash.svg');
...
@@ -10,7 +10,7 @@ const eyeSlash = require('./eye-slash.svg');
// Props
// Props
export
type
Props
=
StandardProps
<
React
.
HTMLProps
<
HTMLInputElement
>
,
ClassKey
,
'ref'
|
'disabled'
>
&
FieldProps
<
string
>
&
{
export
type
Props
=
StandardProps
<
React
.
HTMLProps
<
HTMLInputElement
>
,
ClassKey
,
'ref'
|
'disabled'
|
'value'
>
&
FieldProps
<
string
>
&
{
__
:
Gettext
;
__
:
Gettext
;
ctx
?:
LocaleCtx
;
ctx
?:
LocaleCtx
;
type
?:
React
.
HTMLProps
<
HTMLInputElement
>
[
'type'
];
type
?:
React
.
HTMLProps
<
HTMLInputElement
>
[
'type'
];
...
...
functions/find-map.ts
View file @
bb02c978
...
@@ -7,4 +7,5 @@ export default function findMap<A, B>(xs: A[], f: (a: A) => B|undefined): B|unde
...
@@ -7,4 +7,5 @@ export default function findMap<A, B>(xs: A[], f: (a: A) => B|undefined): B|unde
const
b_or_undefined
=
f
(
x
);
const
b_or_undefined
=
f
(
x
);
if
(
b_or_undefined
!==
undefined
)
return
b_or_undefined
;
if
(
b_or_undefined
!==
undefined
)
return
b_or_undefined
;
}
}
return
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment