wini-web-components 2.8.2 → 2.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -2
- package/src/component/button/button.module.css +210 -0
- package/src/component/button/button.tsx +57 -0
- package/src/component/calendar/calendar.module.css +153 -0
- package/src/component/calendar/calendar.tsx +389 -0
- package/src/component/carousel/carousel.css +622 -0
- package/src/component/carousel/carousel.tsx +91 -0
- package/src/component/checkbox/checkbox.module.css +48 -0
- package/src/component/checkbox/checkbox.tsx +80 -0
- package/src/component/ck-editor/ck-editor.css +206 -0
- package/src/component/ck-editor/ckeditor.tsx +522 -0
- package/src/component/component-status.tsx +53 -0
- package/src/component/date-time-picker/date-time-picker.module.css +94 -0
- package/src/component/date-time-picker/date-time-picker.tsx +663 -0
- package/src/component/dialog/dialog.module.css +111 -0
- package/src/component/dialog/dialog.tsx +109 -0
- package/src/component/import-file/import-file.module.css +83 -0
- package/src/component/import-file/import-file.tsx +174 -0
- package/src/component/infinite-scroll/infinite-scroll.module.css +34 -0
- package/src/component/infinite-scroll/infinite-scroll.tsx +35 -0
- package/src/component/input-multi-select/input-multi-select.module.css +121 -0
- package/src/component/input-multi-select/input-multi-select.tsx +263 -0
- package/src/component/input-otp/input-otp.module.css +41 -0
- package/src/component/input-otp/input-otp.tsx +110 -0
- package/src/component/number-picker/number-picker.module.css +137 -0
- package/src/component/number-picker/number-picker.tsx +107 -0
- package/src/component/pagination/pagination.module.css +48 -0
- package/src/component/pagination/pagination.tsx +88 -0
- package/src/component/popup/popup.css +136 -0
- package/src/component/popup/popup.tsx +125 -0
- package/src/component/progress-bar/progress-bar.module.css +42 -0
- package/src/component/progress-bar/progress-bar.tsx +33 -0
- package/src/component/progress-circle/progress-circle.css +0 -0
- package/src/component/progress-circle/progress-circle.tsx +25 -0
- package/src/component/radio-button/radio-button.module.css +51 -0
- package/src/component/radio-button/radio-button.tsx +60 -0
- package/src/component/rating/rating.module.css +11 -0
- package/src/component/rating/rating.tsx +65 -0
- package/src/component/select1/select1.module.css +108 -0
- package/src/component/select1/select1.tsx +271 -0
- package/src/component/switch/switch.module.css +53 -0
- package/src/component/switch/switch.tsx +68 -0
- package/src/component/table/table.css +74 -0
- package/src/component/table/table.tsx +108 -0
- package/src/component/tag/tag.module.css +108 -0
- package/src/component/tag/tag.tsx +31 -0
- package/src/component/text/text.css +27 -0
- package/src/component/text/text.tsx +24 -0
- package/src/component/text-area/text-area.module.css +57 -0
- package/src/component/text-area/text-area.tsx +65 -0
- package/src/component/text-field/text-field.module.css +71 -0
- package/src/component/text-field/text-field.tsx +102 -0
- package/src/component/toast-noti/toast-noti.css +866 -0
- package/src/component/toast-noti/toast-noti.tsx +22 -0
- package/src/component/wini-icon/winicon.module.css +110 -0
- package/src/component/wini-icon/winicon.tsx +9424 -0
- package/src/form/login/view.module.css +80 -0
- package/src/form/login/view.tsx +138 -0
- package/src/global.d.ts +5 -0
- package/src/index.tsx +66 -0
- package/src/language/i18n.tsx +143 -0
- package/src/skin/layout.css +649 -0
- package/src/skin/root.css +294 -0
- package/src/skin/typography.css +314 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React, { CSSProperties, MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
import './table.css'
|
|
3
|
+
|
|
4
|
+
export enum CellAlignItems {
|
|
5
|
+
start = 'start',
|
|
6
|
+
center = 'center',
|
|
7
|
+
end = 'end',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type TbCellProps = {
|
|
11
|
+
id?: string,
|
|
12
|
+
fixed?: boolean,
|
|
13
|
+
children?: ReactNode,
|
|
14
|
+
className?: string,
|
|
15
|
+
style?: CSSProperties,
|
|
16
|
+
align?: CellAlignItems | string,
|
|
17
|
+
onClick?: React.MouseEventHandler<HTMLTableDataCellElement>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class TbCell extends React.Component<TbCellProps> {
|
|
21
|
+
render(): React.ReactNode {
|
|
22
|
+
return <td id={this.props.id} onClick={this.props.onClick} style={this.props.style} align-cell={this.props.align ?? CellAlignItems.start} className={`tb-cell ${this.props.className ?? ''} ${this.props.fixed ? 'tb-cell-fixed' : ''}`}>{this.props.children}</td>
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface TbRowProps {
|
|
27
|
+
id?: string,
|
|
28
|
+
children?: Array<TbCell>,
|
|
29
|
+
className?: string,
|
|
30
|
+
style?: CSSProperties,
|
|
31
|
+
onClick?: MouseEventHandler<HTMLTableRowElement>,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
export class TbRow extends React.Component<TbRowProps> {
|
|
36
|
+
render(): React.ReactNode {
|
|
37
|
+
return <tr id={this.props.id} style={this.props.style} className={`tb-row ${this.props.className ?? ""}`} onClick={this.props.onClick}>
|
|
38
|
+
{(this.props.children ?? []).map((e: TbCell, i: number) => {
|
|
39
|
+
let ox: number | string = 0
|
|
40
|
+
if (this.props.children && i > 0 && i < (this.props.children.length - 1)) {
|
|
41
|
+
ox = `calc(${this.props.children.slice(0, i).map(tb => {
|
|
42
|
+
const wValue = tb.props.style?.minWidth ?? tb.props.style?.width
|
|
43
|
+
return wValue ? typeof wValue === 'number' ? `${wValue}px` : wValue : '60px';
|
|
44
|
+
}).join(" + ")})`
|
|
45
|
+
}
|
|
46
|
+
return <TbCell
|
|
47
|
+
id={e.props.id}
|
|
48
|
+
key={`tb-cell-${i}`}
|
|
49
|
+
align={e.props.align}
|
|
50
|
+
children={e.props.children}
|
|
51
|
+
fixed={e.props.fixed}
|
|
52
|
+
onClick={e.props.onClick}
|
|
53
|
+
style={e.props.fixed ? (this.props.children && i === this.props.children.length - 1) ? { right: 0, ...(e.props.style ?? {}) } : { left: ox, ...(e.props.style ?? {}) } : e.props.style}
|
|
54
|
+
className={e.props.className} />;
|
|
55
|
+
})}
|
|
56
|
+
</tr>
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class TbHeader extends React.Component<TbRowProps> {
|
|
61
|
+
render() {
|
|
62
|
+
return <thead style={this.props.style} className={`tb-header ${this.props.className ?? ""}`}>
|
|
63
|
+
<tr>
|
|
64
|
+
{(this.props.children ?? []).map((e: TbCell, i: number) => {
|
|
65
|
+
let ox: number | string = 0
|
|
66
|
+
if (this.props.children && i > 0 && i < (this.props.children.length - 1)) {
|
|
67
|
+
ox = `calc(${this.props.children.slice(0, i).map(tb => tb.props.style?.width ? typeof tb.props.style.width === 'number' ? `${tb.props.style.width}px` : tb.props.style.width : '60px').join(" + ")})`
|
|
68
|
+
}
|
|
69
|
+
return <TbCell
|
|
70
|
+
id={e.props.id}
|
|
71
|
+
key={`tb-cell-${i}`}
|
|
72
|
+
align={e.props.align}
|
|
73
|
+
children={e.props.children}
|
|
74
|
+
onClick={e.props.onClick}
|
|
75
|
+
fixed={e.props.fixed}
|
|
76
|
+
style={e.props.fixed ? (this.props.children && i === this.props.children.length - 1) ? { right: 0, ...(e.props.style ?? {}) } : { left: ox, ...(e.props.style ?? {}) } : e.props.style}
|
|
77
|
+
className={e.props.className} />;
|
|
78
|
+
})}
|
|
79
|
+
</tr>
|
|
80
|
+
</thead>
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface TbBodyProps {
|
|
85
|
+
id?: string,
|
|
86
|
+
children?: Array<TbRow>,
|
|
87
|
+
className?: string,
|
|
88
|
+
style?: CSSProperties,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class TbBody extends React.Component<TbBodyProps> {
|
|
92
|
+
render(): React.ReactNode {
|
|
93
|
+
return <tbody id={this.props.id}>{this.props.children as ReactNode}</tbody>
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface TableProps {
|
|
98
|
+
id?: string,
|
|
99
|
+
children?: Array<TbBody | TbHeader>,
|
|
100
|
+
className?: string,
|
|
101
|
+
style?: CSSProperties,
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export class Table extends React.Component<TableProps> {
|
|
105
|
+
render(): React.ReactNode {
|
|
106
|
+
return <table id={this.props.id} className={`custom-table ${this.props.className}`} style={this.props.style}>{this.props.children as ReactNode}</table>
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
.tag-container {
|
|
2
|
+
padding: 3px 7px;
|
|
3
|
+
border-radius: 100rem;
|
|
4
|
+
gap: 6px;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
color: var(--neutral-text-subtitle-color, #61616B);
|
|
7
|
+
border: var(--neutral-bolder-border);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.tag-container[class~="dashed"] {
|
|
11
|
+
border-style: dashed;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.tag-container[class~="size32"] {
|
|
15
|
+
padding: 4px 11px;
|
|
16
|
+
gap: 8px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.tag-container.type-button {
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.tag-container>.tag-label {
|
|
24
|
+
color: inherit;
|
|
25
|
+
font: inherit;
|
|
26
|
+
font-size: inherit;
|
|
27
|
+
font-family: inherit;
|
|
28
|
+
line-height: inherit;
|
|
29
|
+
font-weight: inherit;
|
|
30
|
+
text-align: inherit;
|
|
31
|
+
letter-spacing: inherit;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.tag-container.disabled {
|
|
35
|
+
color: var(--neutral-text-disabled-color);
|
|
36
|
+
background-color: var(--neutral-disable-background-color) !important;
|
|
37
|
+
border-color: var(--neutral-disable-background-color) !important;
|
|
38
|
+
pointer-events: none !important;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.tag-container[class~="tag-primary"] {
|
|
42
|
+
background-color: var(--primary-main-color) !important;
|
|
43
|
+
border-color: var(--primary-main-color) !important;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.tag-container[class~="tag-primary"] * {
|
|
47
|
+
color: var(--neutral-text-stable-color) !important;
|
|
48
|
+
--color: var(--neutral-text-stable-color) !important;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.tag-container[class~="tag-grey"] {
|
|
52
|
+
border-color: var(--neutral-bolder-border-color) !important;
|
|
53
|
+
background-color: var(--neutral-main-background-color) !important;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.tag-container[class~="tag-grey"] * {
|
|
57
|
+
color: var(--neutral-text-subtitle-color) !important;
|
|
58
|
+
--color: var(--neutral-text-subtitle-color) !important;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.tag-container[class~="tag-neutral"] {
|
|
62
|
+
border-color: var(--neutral-bolder-border-color) !important;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.tag-container[class~="tag-neutral"] * {
|
|
66
|
+
color: var(--neutral-text-subtitle-color) !important;
|
|
67
|
+
--color: var(--neutral-text-subtitle-color) !important;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.tag-container[class~="tag-infor"] {
|
|
71
|
+
background-color: var(--infor-background);
|
|
72
|
+
border-color: var(--infor-main-color) !important;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.tag-container[class~="tag-infor"] * {
|
|
76
|
+
color: var(--infor-main-color) !important;
|
|
77
|
+
--color: var(--infor-main-color) !important;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.tag-container[class~="tag-warning"] {
|
|
81
|
+
background-color: var(--warning-background);
|
|
82
|
+
border-color: var(--warning-main-color) !important;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.tag-container[class~="tag-warning"] * {
|
|
86
|
+
color: var(--warning-main-color) !important;
|
|
87
|
+
--color: var(--warning-main-color) !important;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.tag-container[class~="tag-error"] {
|
|
91
|
+
background-color: var(--error-background);
|
|
92
|
+
border-color: var(--error-main-color) !important;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.tag-container[class~="tag-error"] * {
|
|
96
|
+
color: var(--error-main-color) !important;
|
|
97
|
+
--color: var(--error-main-color) !important;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.tag-container[class~="tag-success"] {
|
|
101
|
+
background-color: var(--success-background);
|
|
102
|
+
border-color: var(--success-main-color) !important;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.tag-container[class~="tag-success"] * {
|
|
106
|
+
color: var(--success-main-color) !important;
|
|
107
|
+
--color: var(--success-main-color) !important;
|
|
108
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { Text } from '../text/text';
|
|
3
|
+
import styles from './tag.module.css'
|
|
4
|
+
import { ComponentStatus } from '../component-status';
|
|
5
|
+
|
|
6
|
+
interface TagProps {
|
|
7
|
+
id?: string,
|
|
8
|
+
title: string,
|
|
9
|
+
prefix?: ReactNode,
|
|
10
|
+
suffix?: ReactNode,
|
|
11
|
+
disabled?: boolean,
|
|
12
|
+
style?: CSSProperties,
|
|
13
|
+
/**
|
|
14
|
+
* default: size24: button-text-6 \
|
|
15
|
+
* recommend: size24: button-text-6 | size32: button-text-4 \
|
|
16
|
+
* status tag: tag-primary | tag-infor | tag-warning | tag-error | tag-success | tag-grey | tag-neutral | tag-infor-main | tag-warning-main | tag-error-main | tag-success-main
|
|
17
|
+
* */
|
|
18
|
+
className?: string,
|
|
19
|
+
status?: ComponentStatus,
|
|
20
|
+
onClick?: React.MouseEventHandler<HTMLDivElement>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class Tag extends React.Component<TagProps> {
|
|
24
|
+
render() {
|
|
25
|
+
return <div id={this.props.id} tag-type={this.props.status ?? 'default'} className={`${styles['tag-container']} row ${this.props.onClick ? styles['type-button'] : ''} ${this.props.disabled ? styles['disabled'] : ""} ${this.props.className ?? "button-text-6"} `} style={this.props.style} onClick={this.props.onClick}>
|
|
26
|
+
{this.props.prefix}
|
|
27
|
+
<Text maxLine={1} className={styles['tag-label']}>{this.props.title}</Text>
|
|
28
|
+
{this.props.suffix}
|
|
29
|
+
</div>
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.comp-text {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
-webkit-box-orient: vertical;
|
|
4
|
+
-webkit-line-clamp: var(--max-line);
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
text-overflow: ellipsis;
|
|
7
|
+
-webkit-box-pack: center;
|
|
8
|
+
text-align: start;
|
|
9
|
+
vertical-align: middle;
|
|
10
|
+
display: -webkit-box;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.comp-text.type-button {
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.comp-text.innerhtml * {
|
|
18
|
+
-webkit-box-orient: vertical;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
text-overflow: ellipsis;
|
|
21
|
+
text-align: inherit;
|
|
22
|
+
margin: 0;
|
|
23
|
+
padding: 0;
|
|
24
|
+
font-family: inherit;
|
|
25
|
+
font-size: inherit;
|
|
26
|
+
-webkit-box-pack: inherit;
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import './text.css';
|
|
3
|
+
|
|
4
|
+
interface TextProps {
|
|
5
|
+
id?: string,
|
|
6
|
+
children?: ReactNode,
|
|
7
|
+
style?: CSSProperties,
|
|
8
|
+
className?: string,
|
|
9
|
+
maxLine?: number,
|
|
10
|
+
onClick?: React.MouseEventHandler<HTMLDivElement>,
|
|
11
|
+
onHover?: React.MouseEventHandler<HTMLDivElement>,
|
|
12
|
+
html?: string,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class Text extends React.Component<TextProps> {
|
|
16
|
+
render(): React.ReactNode {
|
|
17
|
+
let convertStyle: CSSProperties = this.props.style ?? {}
|
|
18
|
+
if (this.props.maxLine) {
|
|
19
|
+
convertStyle = { ...convertStyle, '--max-line': this.props.maxLine } as CSSProperties
|
|
20
|
+
}
|
|
21
|
+
return this.props.html ? <div dangerouslySetInnerHTML={{ __html: this.props.html }} id={this.props.id} onMouseOver={this.props.onHover} onClick={this.props.onClick} className={`comp-text innerhtml ${this.props.onClick ? 'type-button' : ''} ${this.props.className ?? ''}`} style={convertStyle} /> :
|
|
22
|
+
<div id={this.props.id} onMouseOver={this.props.onHover} onClick={this.props.onClick} className={`comp-text ${this.props.onClick ? 'type-button' : ''} ${this.props.className ?? ''}`} style={convertStyle}>{this.props.children}</div>
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
.text-area-container {
|
|
2
|
+
height: 4rem;
|
|
3
|
+
position: relative;
|
|
4
|
+
gap: 0.8rem;
|
|
5
|
+
border-radius: 0.8rem;
|
|
6
|
+
border: var(--neutral-bolder-border);
|
|
7
|
+
padding: 0.8rem 1.6rem;
|
|
8
|
+
align-items: start;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.text-area-container:has(> textarea:disabled) {
|
|
12
|
+
background-color: var(--neutral-disable-background-color) !important;
|
|
13
|
+
color: var(--neutral-text-disabled-color) !important;
|
|
14
|
+
pointer-events: none !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.text-area-container:focus-within {
|
|
18
|
+
border-color: var(--primary-main-color);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.text-area-container>textarea {
|
|
22
|
+
flex: 1;
|
|
23
|
+
padding: 0;
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: inherit;
|
|
26
|
+
max-height: 100%;
|
|
27
|
+
border: none;
|
|
28
|
+
outline: none;
|
|
29
|
+
background-color: transparent !important;
|
|
30
|
+
font: inherit;
|
|
31
|
+
color: inherit;
|
|
32
|
+
font-size: inherit;
|
|
33
|
+
font-family: inherit;
|
|
34
|
+
font-weight: inherit;
|
|
35
|
+
line-height: inherit;
|
|
36
|
+
text-align: inherit;
|
|
37
|
+
text-overflow: inherit;
|
|
38
|
+
resize: inherit;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.text-area-container.helper-text {
|
|
42
|
+
overflow: visible !important;
|
|
43
|
+
border-color: var(--helper-text-color) !important;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.text-area-container.helper-text::after {
|
|
47
|
+
content: attr(helper-text);
|
|
48
|
+
color: var(--helper-text-color);
|
|
49
|
+
position: absolute;
|
|
50
|
+
left: 0;
|
|
51
|
+
bottom: -0.4rem;
|
|
52
|
+
width: max-content;
|
|
53
|
+
font-size: 1.2rem;
|
|
54
|
+
line-height: 1.6rem;
|
|
55
|
+
font-family: inherit;
|
|
56
|
+
transform: translateY(100%);
|
|
57
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React, { createRef, CSSProperties } from "react";
|
|
2
|
+
import styles from './text-area.module.css'
|
|
3
|
+
import { UseFormRegister } from "react-hook-form";
|
|
4
|
+
|
|
5
|
+
interface TextAreaProps {
|
|
6
|
+
id?: string,
|
|
7
|
+
value?: string,
|
|
8
|
+
maxLength?: number,
|
|
9
|
+
defaultValue?: string,
|
|
10
|
+
onChange?: React.ChangeEventHandler<HTMLTextAreaElement>,
|
|
11
|
+
onBlur?: React.FocusEventHandler<HTMLTextAreaElement>,
|
|
12
|
+
onFocus?: React.FocusEventHandler<HTMLTextAreaElement>,
|
|
13
|
+
placeholder?: string,
|
|
14
|
+
disabled?: boolean,
|
|
15
|
+
readOnly?: boolean,
|
|
16
|
+
autoFocus?: boolean,
|
|
17
|
+
className?: string,
|
|
18
|
+
helperText?: string,
|
|
19
|
+
name?: string,
|
|
20
|
+
helperTextColor?: string,
|
|
21
|
+
style?: CSSProperties,
|
|
22
|
+
register?: UseFormRegister<{}>,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class TextArea extends React.Component<TextAreaProps> {
|
|
26
|
+
private containerRef = createRef<HTMLDivElement>()
|
|
27
|
+
|
|
28
|
+
getTextarea = () => {
|
|
29
|
+
return this.containerRef.current?.querySelector("textarea")
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
render(): React.ReactNode {
|
|
33
|
+
return <div
|
|
34
|
+
ref={this.containerRef}
|
|
35
|
+
id={this.props.id}
|
|
36
|
+
className={`${styles['text-area-container']} row ${this.props.className ?? 'body-3'} ${this.props.helperText?.length ? styles['helper-text'] : ""}`}
|
|
37
|
+
helper-text={this.props.helperText}
|
|
38
|
+
style={this.props.style ? { ...({ '--helper-text-color': this.props.helperTextColor ?? '#e14337' } as CSSProperties), ...this.props.style } : ({ '--helper-text-color': this.props.helperTextColor ?? '#e14337' } as CSSProperties)}
|
|
39
|
+
>
|
|
40
|
+
{this.props.register ?
|
|
41
|
+
<textarea
|
|
42
|
+
name={this.props.name}
|
|
43
|
+
autoFocus={this.props.autoFocus}
|
|
44
|
+
{...this.props.register}
|
|
45
|
+
maxLength={this.props.maxLength}
|
|
46
|
+
placeholder={this.props.placeholder}
|
|
47
|
+
readOnly={this.props.readOnly}
|
|
48
|
+
disabled={this.props.disabled}
|
|
49
|
+
onFocus={this.props.onFocus}
|
|
50
|
+
/> : <textarea
|
|
51
|
+
autoFocus={this.props.autoFocus}
|
|
52
|
+
maxLength={this.props.maxLength}
|
|
53
|
+
name={this.props.name}
|
|
54
|
+
defaultValue={this.props.defaultValue}
|
|
55
|
+
value={this.props.value}
|
|
56
|
+
placeholder={this.props.placeholder}
|
|
57
|
+
readOnly={this.props.readOnly}
|
|
58
|
+
disabled={this.props.disabled}
|
|
59
|
+
onChange={this.props.onChange}
|
|
60
|
+
onFocus={this.props.onFocus}
|
|
61
|
+
onBlur={this.props.onBlur}
|
|
62
|
+
/>}
|
|
63
|
+
</div>
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
.text-field-container {
|
|
2
|
+
position: relative;
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
padding: 0.8rem 1.5rem;
|
|
5
|
+
border: var(--neutral-main-border);
|
|
6
|
+
border-radius: 0.8rem;
|
|
7
|
+
gap: 0.8rem;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
input::-webkit-outer-spin-button,
|
|
11
|
+
input::-webkit-inner-spin-button {
|
|
12
|
+
-webkit-appearance: none;
|
|
13
|
+
margin: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.text-field-container[class~="size48"] {
|
|
17
|
+
padding: 1.2rem 1.5rem;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.text-field-container[class~="size32"] {
|
|
21
|
+
padding: 0.4rem 1.1rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.text-field-container[class~="size24"] {
|
|
25
|
+
padding: 0 0.7rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.text-field-container:has(> input:disabled) {
|
|
29
|
+
background-color: var(--neutral-disable-background-color) !important;
|
|
30
|
+
color: var(--neutral-text-disabled-color) !important;
|
|
31
|
+
pointer-events: none !important;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.text-field-container:focus-within {
|
|
35
|
+
border-color: var(--primary-main-color);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.text-field-container>input {
|
|
39
|
+
flex: 1;
|
|
40
|
+
width: 100%;
|
|
41
|
+
border: none;
|
|
42
|
+
outline: none;
|
|
43
|
+
padding: 0;
|
|
44
|
+
background-color: transparent !important;
|
|
45
|
+
font: inherit;
|
|
46
|
+
color: inherit;
|
|
47
|
+
font-size: inherit;
|
|
48
|
+
font-family: inherit;
|
|
49
|
+
font-weight: inherit;
|
|
50
|
+
line-height: inherit;
|
|
51
|
+
text-align: inherit;
|
|
52
|
+
text-overflow: inherit;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.text-field-container.helper-text {
|
|
56
|
+
overflow: visible !important;
|
|
57
|
+
border-color: var(--helper-text-color) !important;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.text-field-container.helper-text::after {
|
|
61
|
+
content: attr(helper-text);
|
|
62
|
+
color: var(--helper-text-color);
|
|
63
|
+
position: absolute;
|
|
64
|
+
left: 0;
|
|
65
|
+
bottom: -0.4rem;
|
|
66
|
+
width: max-content;
|
|
67
|
+
font-size: 1.2rem;
|
|
68
|
+
line-height: 1.6rem;
|
|
69
|
+
font-family: inherit;
|
|
70
|
+
transform: translateY(100%);
|
|
71
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React, { createRef, CSSProperties, ReactNode } from "react";
|
|
2
|
+
import styles from './text-field.module.css'
|
|
3
|
+
import { UseFormRegister } from "react-hook-form";
|
|
4
|
+
|
|
5
|
+
interface TextFieldProps {
|
|
6
|
+
id?: string,
|
|
7
|
+
value?: string,
|
|
8
|
+
maxLength?: number,
|
|
9
|
+
defaultValue?: string,
|
|
10
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>,
|
|
11
|
+
onComplete?: React.KeyboardEventHandler<HTMLInputElement>,
|
|
12
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>,
|
|
13
|
+
onFocus?: React.FocusEventHandler<HTMLInputElement>,
|
|
14
|
+
placeholder?: string,
|
|
15
|
+
disabled?: boolean,
|
|
16
|
+
readOnly?: boolean,
|
|
17
|
+
/**
|
|
18
|
+
* default: size40: body-3
|
|
19
|
+
* recommend: size48: body-3 | size32: body-3 | size24: body-3
|
|
20
|
+
* */
|
|
21
|
+
className?: string,
|
|
22
|
+
helperText?: string,
|
|
23
|
+
name?: string,
|
|
24
|
+
suffix?: ReactNode,
|
|
25
|
+
prefix?: ReactNode,
|
|
26
|
+
helperTextColor?: string,
|
|
27
|
+
style?: CSSProperties,
|
|
28
|
+
type?: React.HTMLInputTypeAttribute,
|
|
29
|
+
autoFocus?: boolean,
|
|
30
|
+
autoComplete?: React.HTMLInputAutoCompleteAttribute,
|
|
31
|
+
register?: UseFormRegister<{}>,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class TextField extends React.Component<TextFieldProps> {
|
|
35
|
+
private containerRef = createRef<HTMLDivElement>()
|
|
36
|
+
|
|
37
|
+
getInput = () => {
|
|
38
|
+
return this.containerRef.current?.querySelector("input")
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
render(): React.ReactNode {
|
|
42
|
+
return <div
|
|
43
|
+
ref={this.containerRef}
|
|
44
|
+
id={this.props.id}
|
|
45
|
+
className={`${styles['text-field-container']} row ${this.props.className ?? 'body-3'} ${this.props.helperText?.length ? styles['helper-text'] : ""}`}
|
|
46
|
+
helper-text={this.props.helperText}
|
|
47
|
+
style={this.props.style ? { ...({ '--helper-text-color': this.props.helperTextColor ?? '#e14337' } as CSSProperties), ...this.props.style } : ({ '--helper-text-color': this.props.helperTextColor ?? '#e14337' } as CSSProperties)}
|
|
48
|
+
>
|
|
49
|
+
{this.props.prefix}
|
|
50
|
+
{this.props.register ?
|
|
51
|
+
<input
|
|
52
|
+
name={this.props.name}
|
|
53
|
+
{...this.props.register}
|
|
54
|
+
autoComplete={this.props.autoComplete}
|
|
55
|
+
autoFocus={this.props.autoFocus}
|
|
56
|
+
maxLength={this.props.maxLength}
|
|
57
|
+
type={this.props.type ?? 'text'}
|
|
58
|
+
placeholder={this.props.placeholder}
|
|
59
|
+
readOnly={this.props.readOnly}
|
|
60
|
+
disabled={this.props.disabled}
|
|
61
|
+
onFocus={this.props.onFocus}
|
|
62
|
+
onKeyDown={this.props.onComplete ? (ev) => {
|
|
63
|
+
if (this.props.onComplete) {
|
|
64
|
+
switch (ev.key.toLowerCase()) {
|
|
65
|
+
case "enter":
|
|
66
|
+
this.props.onComplete(ev)
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} : undefined}
|
|
73
|
+
/> : <input
|
|
74
|
+
autoComplete={this.props.autoComplete}
|
|
75
|
+
autoFocus={this.props.autoFocus}
|
|
76
|
+
maxLength={this.props.maxLength}
|
|
77
|
+
name={this.props.name}
|
|
78
|
+
type={this.props.type ?? 'text'}
|
|
79
|
+
defaultValue={this.props.defaultValue}
|
|
80
|
+
value={this.props.value}
|
|
81
|
+
placeholder={this.props.placeholder}
|
|
82
|
+
readOnly={this.props.readOnly}
|
|
83
|
+
disabled={this.props.disabled}
|
|
84
|
+
onChange={this.props.onChange}
|
|
85
|
+
onFocus={this.props.onFocus}
|
|
86
|
+
onBlur={this.props.onBlur}
|
|
87
|
+
onKeyDown={this.props.onComplete ? (ev) => {
|
|
88
|
+
if (this.props.onComplete) {
|
|
89
|
+
switch (ev.key.toLowerCase()) {
|
|
90
|
+
case "enter":
|
|
91
|
+
this.props.onComplete(ev)
|
|
92
|
+
break;
|
|
93
|
+
default:
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} : undefined}
|
|
98
|
+
/>}
|
|
99
|
+
{this.props.suffix}
|
|
100
|
+
</div>
|
|
101
|
+
}
|
|
102
|
+
}
|