Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3b592895
authored
Apr 29, 2026
by
yyhhyyyyyy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: follow required marker styling convention
parent
e0b6eb3a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
1 deletions
+43
-1
web/default/src/components/ui/label.tsx
+43
-1
No files found.
web/default/src/components/ui/label.tsx
View file @
3b592895
...
@@ -4,8 +4,48 @@ import * as React from 'react'
...
@@ -4,8 +4,48 @@ import * as React from 'react'
import
*
as
LabelPrimitive
from
'@radix-ui/react-label'
import
*
as
LabelPrimitive
from
'@radix-ui/react-label'
import
{
cn
}
from
'@/lib/utils'
import
{
cn
}
from
'@/lib/utils'
const
requiredMarkerPattern
=
/
\s\*
$/
function
renderRequiredMarker
(
text
:
string
,
key
?:
React
.
Key
)
{
if
(
!
requiredMarkerPattern
.
test
(
text
))
{
return
text
}
return
(
<
span
key=
{
key
}
>
{
text
.
slice
(
0
,
-
1
)
}
<
span
className=
'text-destructive'
>
*
</
span
>
</
span
>
)
}
function
renderLabelChildren
(
children
:
React
.
ReactNode
)
{
const
childArray
=
React
.
Children
.
toArray
(
children
)
if
(
childArray
.
length
===
0
)
{
return
children
}
if
(
childArray
.
every
(
(
child
)
=>
typeof
child
===
'string'
||
typeof
child
===
'number'
)
)
{
return
renderRequiredMarker
(
childArray
.
join
(
''
))
}
return
childArray
.
map
((
child
,
index
)
=>
{
if
(
typeof
child
===
'string'
||
typeof
child
===
'number'
)
{
return
renderRequiredMarker
(
String
(
child
),
index
)
}
return
child
})
}
function
Label
({
function
Label
({
className
,
className
,
children
,
...
props
...
props
}:
React
.
ComponentProps
<
typeof
LabelPrimitive
.
Root
>
)
{
}:
React
.
ComponentProps
<
typeof
LabelPrimitive
.
Root
>
)
{
return
(
return
(
...
@@ -16,7 +56,9 @@ function Label({
...
@@ -16,7 +56,9 @@ function Label({
className
className
)
}
)
}
{
...
props
}
{
...
props
}
/>
>
{
renderLabelChildren
(
children
)
}
</
LabelPrimitive
.
Root
>
)
)
}
}
...
...
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