Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
UI_storybook
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Дмитрий Малюгин
UI_storybook
Commits
0d2d4116
Commit
0d2d4116
authored
1 month ago
by
Дмитрий Малюгин
Browse files
Options
Downloads
Patches
Plain Diff
feat: 'InputDiv' logic of input in process
parent
fc9098be
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
Finish "UI-library v1.0.0"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/InputDiv/InputDiv.vue
+52
-20
52 additions, 20 deletions
src/components/InputDiv/InputDiv.vue
with
52 additions
and
20 deletions
src/components/InputDiv/InputDiv.vue
+
52
−
20
View file @
0d2d4116
...
@@ -13,7 +13,8 @@ const props = withDefaults(defineProps<IInputDivProps>(), {
...
@@ -13,7 +13,8 @@ const props = withDefaults(defineProps<IInputDivProps>(), {
});
});
const
value
=
defineModel
()
as
Ref
<
string
>
;
const
value
=
defineModel
()
as
Ref
<
string
>
;
const
container
=
document
.
querySelector
(
'
#inputDiv-container
'
);
let
container
;
setTimeout
(()
=>
(
container
=
document
.
querySelector
(
'
#inputDiv-container
'
)),
0
);
const
inputPartsBy
=
computed
(()
=>
calcPartsBy
(
props
.
scheme
));
const
inputPartsBy
=
computed
(()
=>
calcPartsBy
(
props
.
scheme
));
const
inputPartsDash
=
computed
(()
=>
calcPartsDash
(
props
.
scheme
));
const
inputPartsDash
=
computed
(()
=>
calcPartsDash
(
props
.
scheme
));
...
@@ -29,33 +30,64 @@ const inputHeight = computed(() => getValueFromSize(props.size, ['30px', '36px',
...
@@ -29,33 +30,64 @@ const inputHeight = computed(() => getValueFromSize(props.size, ['30px', '36px',
const
fontSize
=
computed
(()
=>
getValueFromSize
(
props
.
size
,
[
'
12px
'
,
'
16px
'
,
'
24px
'
,
'
32px
'
]));
const
fontSize
=
computed
(()
=>
getValueFromSize
(
props
.
size
,
[
'
12px
'
,
'
16px
'
,
'
24px
'
,
'
32px
'
]));
const
borderWidth
=
computed
(()
=>
(
props
.
size
===
'
small
'
||
props
.
size
===
'
normal
'
?
'
1px
'
:
'
2px
'
));
const
borderWidth
=
computed
(()
=>
(
props
.
size
===
'
small
'
||
props
.
size
===
'
normal
'
?
'
1px
'
:
'
2px
'
));
const
toggleInput
=
()
=>
{};
const
toggleInput
=
(
itemIndex
:
number
,
inputIndex
:
number
)
=>
{
let
currentInput
;
let
currentItem
;
const
list
=
Array
(
container
?.
children
[
inputPartsBy
.
value
?
0
:
1
].
children
)[
0
];
cycle
:
for
(
let
i
=
0
;
i
<
list
.
length
;
i
++
)
{
const
item
=
list
[
i
];
if
(
!
item
.
classList
.
contains
(
itemIndex
))
continue
;
for
(
const
child
of
item
.
children
)
{
if
(
child
.
classList
.
contains
(
inputIndex
))
{
currentInput
=
child
;
currentItem
=
item
;
break
cycle
;
}
}
}
// если значение ввели
if
(
currentInput
.
value
)
{
let
nextInputInSameItem
=
null
;
for
(
const
child
of
currentItem
.
children
)
{
if
(
child
.
classList
.
contains
(
inputIndex
+
1
))
{
nextInputInSameItem
=
child
;
break
;
}
}
if
(
nextInputInSameItem
)
{
nextInputInSameItem
.
focus
();
}
else
{
// обработка следующей части, если она есть, иначе ничего не делать (или оставить старое значение, что ещё лучше)
}
}
else
{
// если значение удалили
let
prevInputInSameItem
=
null
;
for
(
const
child
of
currentItem
.
children
)
{
if
(
child
.
classList
.
contains
(
inputIndex
-
1
))
{
prevInputInSameItem
=
child
;
break
;
}
}
if
(
prevInputInSameItem
)
{
prevInputInSameItem
.
focus
();
}
else
{
// обработка предыдущей части, если она есть, иначе ничего не делать
}
}
};
</
script
>
</
script
>
<
template
>
<
template
>
<section
id=
"inputDiv-container"
>
<section
id=
"inputDiv-container"
>
<div
v-show=
"inputPartsBy"
class=
"list"
>
<div
v-show=
"inputPartsBy"
class=
"list"
>
<div
<div
v-for=
"(item, itemIndex) of inputPartsBy"
:key=
"item"
:class=
"`item $
{itemIndex}`">
v-for=
"(item, itemIndex) of inputPartsBy"
:key=
"item"
:class=
"[
'item',
{
itemIndex,
},
]"
>
<input
<input
v-for=
"(input, inputIndex) of item"
v-for=
"(input, inputIndex) of item"
:key=
"inputIndex"
:key=
"inputIndex"
@
change
=
"toggleInput(itemIndex, inputIndex)"
@
input.prevent
=
"toggleInput(itemIndex,
+
inputIndex)"
type=
"text"
type=
"text"
:class=
"[
:class=
"`input $
{inputIndex}`"
'input',
{
inputIndex,
},
]"
/>
/>
</div>
</div>
</div>
</div>
...
@@ -73,7 +105,7 @@ const toggleInput = () => {};
...
@@ -73,7 +105,7 @@ const toggleInput = () => {};
<input
<input
v-for=
"(input, inputIndex) of item"
v-for=
"(input, inputIndex) of item"
:key=
"inputIndex"
:key=
"inputIndex"
@
change
=
"toggleInput(itemIndex, inputIndex)"
@
input
=
"toggleInput(itemIndex,
+
inputIndex)"
type=
"text"
type=
"text"
:class=
"[
:class=
"[
'input',
'input',
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment