wini-web-components 0.1.0

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.
Files changed (62) hide show
  1. package/README.md +70 -0
  2. package/package.json +62 -0
  3. package/public/favicon.ico +0 -0
  4. package/public/index.html +43 -0
  5. package/public/logo192.png +0 -0
  6. package/public/logo512.png +0 -0
  7. package/public/manifest.json +25 -0
  8. package/public/robots.txt +3 -0
  9. package/src/App.css +38 -0
  10. package/src/App.js +25 -0
  11. package/src/App.test.js +8 -0
  12. package/src/component/calendar/calendar.css +133 -0
  13. package/src/component/calendar/calendar.tsx +448 -0
  14. package/src/component/checkbox/checkbox.css +46 -0
  15. package/src/component/checkbox/checkbox.tsx +59 -0
  16. package/src/component/component-status.tsx +53 -0
  17. package/src/component/date-picker/date-picker.css +114 -0
  18. package/src/component/date-picker/date-picker.tsx +363 -0
  19. package/src/component/dialog/dialog.css +125 -0
  20. package/src/component/dialog/dialog.tsx +91 -0
  21. package/src/component/export-component.js +48 -0
  22. package/src/component/import-file/import-file.css +86 -0
  23. package/src/component/import-file/import-file.tsx +154 -0
  24. package/src/component/infinite-scroll/infinite-scroll.css +37 -0
  25. package/src/component/infinite-scroll/infinite-scroll.tsx +33 -0
  26. package/src/component/input-multi-select/input-multi-select.css +127 -0
  27. package/src/component/input-multi-select/input-multi-select.tsx +261 -0
  28. package/src/component/pagination/pagination.css +69 -0
  29. package/src/component/pagination/pagination.tsx +65 -0
  30. package/src/component/popup/popup.css +90 -0
  31. package/src/component/popup/popup.tsx +105 -0
  32. package/src/component/progress-bar/progress-bar.css +47 -0
  33. package/src/component/progress-bar/progress-bar.tsx +34 -0
  34. package/src/component/progress-circle/progress-circle.css +47 -0
  35. package/src/component/progress-circle/progress-circle.tsx +24 -0
  36. package/src/component/radio-button/radio-button.css +49 -0
  37. package/src/component/radio-button/radio-button.tsx +59 -0
  38. package/src/component/rating/rating.css +11 -0
  39. package/src/component/rating/rating.tsx +65 -0
  40. package/src/component/select1/select1.css +155 -0
  41. package/src/component/select1/select1.tsx +241 -0
  42. package/src/component/slider/slider.css +16 -0
  43. package/src/component/slider/slider.tsx +87 -0
  44. package/src/component/switch/switch.css +53 -0
  45. package/src/component/switch/switch.tsx +67 -0
  46. package/src/component/table/table.css +74 -0
  47. package/src/component/table/table.tsx +99 -0
  48. package/src/component/text/text.css +16 -0
  49. package/src/component/text/text.tsx +21 -0
  50. package/src/component/text-area/text-area.css +63 -0
  51. package/src/component/text-area/text-area.tsx +55 -0
  52. package/src/component/text-field/text-field.css +64 -0
  53. package/src/component/text-field/text-field.tsx +63 -0
  54. package/src/component/toast-noti/toast-noti.css +0 -0
  55. package/src/component/toast-noti/toast-noti.tsx +21 -0
  56. package/src/index.css +13 -0
  57. package/src/index.js +17 -0
  58. package/src/logo.svg +1 -0
  59. package/src/reportWebVitals.js +13 -0
  60. package/src/setupTests.js +5 -0
  61. package/src/skin/color.css +17 -0
  62. package/src/skin/typography.css +378 -0
@@ -0,0 +1,448 @@
1
+ import React, { CSSProperties, ReactNode } from "react"
2
+ import './calendar.css'
3
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
4
+ import { faAngleDoubleLeft, faAngleDoubleRight, faAngleLeft, faAngleRight } from "@fortawesome/free-solid-svg-icons"
5
+ import { differenceInCalendarDays } from "date-fns"
6
+
7
+ export const today = new Date()
8
+ export const startDate = new Date(
9
+ today.getFullYear() - 100,
10
+ today.getMonth(),
11
+ today.getDate()
12
+ )
13
+ export const endDate = new Date(
14
+ today.getFullYear() + 100,
15
+ today.getMonth(),
16
+ today.getDate()
17
+ )
18
+
19
+ export const inRangeTime = (date: Date, startDate: Date, endDate: Date) => (differenceInCalendarDays(date, startDate) > -1 && differenceInCalendarDays(endDate, date) > -1)
20
+
21
+ export const enum CalendarType {
22
+ DATE,
23
+ MONTH,
24
+ YEAR,
25
+ DATETIME,
26
+ }
27
+
28
+ interface CalendarProps {
29
+ value?: Date,
30
+ min?: Date,
31
+ max?: Date,
32
+ onSelect?: (props: Date) => void,
33
+ disabled?: boolean,
34
+ helperText?: string,
35
+ helperTextColor?: string,
36
+ placeholder?: string,
37
+ className?: string,
38
+ style?: CSSProperties,
39
+ type: CalendarType,
40
+ showSidebar?: boolean,
41
+ footer?: ReactNode
42
+ }
43
+
44
+ interface CalendarState {
45
+ value: Date,
46
+ selectDate?: Date,
47
+ selectMonth: number,
48
+ selectYear: number,
49
+ selectHours: number,
50
+ selectMinutes: number,
51
+ selectSeconds: number,
52
+ type: CalendarType,
53
+ }
54
+
55
+ export class Calendar extends React.Component<CalendarProps, CalendarState> {
56
+ state: Readonly<CalendarState> = {
57
+ value: this.props.value ?? today,
58
+ selectDate: this.props.value ?? today,
59
+ selectMonth: (this.props.value ?? today).getMonth(),
60
+ selectYear: (this.props.value ?? today).getFullYear(),
61
+ type: CalendarType.DATE,
62
+ selectHours: this.props.value?.getHours() ?? 0,
63
+ selectMinutes: this.props.value?.getMinutes() ?? 0,
64
+ selectSeconds: this.props.value?.getSeconds() ?? 0,
65
+ }
66
+
67
+ showDateInMonth() {
68
+ let firstDayOfMonth = new Date(this.state.selectYear, this.state.selectMonth, 1)
69
+ return <>
70
+ {Array.from({ length: 7 }).map((_, i) => {
71
+ switch (i) {
72
+ case 0:
73
+ var weekdayTitle = 'Su'
74
+ break
75
+ case 1:
76
+ weekdayTitle = 'Mo'
77
+ break
78
+ case 2:
79
+ weekdayTitle = 'Tu'
80
+ break
81
+ case 3:
82
+ weekdayTitle = 'We'
83
+ break
84
+ case 4:
85
+ weekdayTitle = 'Th'
86
+ break
87
+ case 5:
88
+ weekdayTitle = 'Fr'
89
+ break
90
+ case 6:
91
+ weekdayTitle = 'Sa'
92
+ break
93
+ default:
94
+ weekdayTitle = ''
95
+ break
96
+ }
97
+ return <div key={'dtwk-' + i} className='date-picker-circle label-4' style={{ color: '#00204D99' }}>
98
+ {weekdayTitle}
99
+ </div>
100
+ })}
101
+ {Array.from({ length: 42 }).map((_, i) => {
102
+ let dateNumber = (i % 7) + (Math.floor(i / 7) * 7) - firstDayOfMonth.getDay()
103
+ const timeValue = new Date(this.state.selectYear, this.state.selectMonth, dateNumber + 1, this.state.selectHours, this.state.selectMinutes, this.state.selectSeconds)
104
+ let style = {}
105
+ let additionProps = {}
106
+ let selected = false
107
+ if (dateNumber + 1 === today.getDate() && this.state.selectMonth === today.getMonth() && this.state.selectYear === today.getFullYear()) {
108
+ style = { borderColor: 'var(--infor-color)' }
109
+ }
110
+ if (!inRangeTime(timeValue, startDate, endDate)) {
111
+ additionProps = { 'in-range': 'false' }
112
+ } else if (!inRangeTime(timeValue, this.props.min ?? startDate, this.props.min ?? endDate)) {
113
+ style = {
114
+ ...style,
115
+ color: 'var(--disabled-font-color)',
116
+ pointerEvents: 'none'
117
+ }
118
+ } else if (this.state.value.valueOf() === timeValue.valueOf()) {
119
+ additionProps = { ...additionProps }
120
+ selected = true
121
+ } else if (timeValue.getMonth() !== this.state.selectMonth) {
122
+ style = { ...style, color: '#9fb0c7' }
123
+ }
124
+ return <button type="button" key={timeValue.toString()} className={`date-picker-circle body-3 ${selected ? 'selected' : ''}`} style={style} {...additionProps}
125
+ onClick={() => {
126
+ this.setState({ ...this.state, value: timeValue })
127
+ if (this.props.onSelect) this.props.onSelect(timeValue)
128
+ }} >
129
+ {timeValue.getDate()}
130
+ </button>
131
+ })}
132
+ </>
133
+ }
134
+
135
+ showMonthInYear() {
136
+ return <>
137
+ {Array.from({ length: 12 }).map((_, i) => {
138
+ let monthTitle: string = ''
139
+ switch (i) {
140
+ case 0:
141
+ monthTitle = 'Jan'
142
+ break
143
+ case 1:
144
+ monthTitle = 'Feb'
145
+ break
146
+ case 2:
147
+ monthTitle = 'Mar'
148
+ break
149
+ case 3:
150
+ monthTitle = 'Apr'
151
+ break
152
+ case 4:
153
+ monthTitle = 'May'
154
+ break
155
+ case 5:
156
+ monthTitle = 'Jun'
157
+ break
158
+ case 6:
159
+ monthTitle = 'Jul'
160
+ break
161
+ case 7:
162
+ monthTitle = 'Aug'
163
+ break
164
+ case 8:
165
+ monthTitle = 'Sep'
166
+ break
167
+ case 9:
168
+ monthTitle = 'Oct'
169
+ break
170
+ case 10:
171
+ monthTitle = 'Nov'
172
+ break
173
+ case 11:
174
+ monthTitle = 'Dec'
175
+ break
176
+ default:
177
+ break
178
+ }
179
+ const timeValue = new Date(this.state.selectYear, i, today.getDate())
180
+ let additionProps = {}
181
+ let style = {}
182
+ let selected = false
183
+ if (this.state.selectYear === today.getFullYear() && today.getMonth() === i) {
184
+ style = { borderColor: 'var(--infor-color)' }
185
+ } if (!inRangeTime(timeValue, startDate, endDate)) {
186
+ additionProps = { 'in-range': 'false' }
187
+ } else if (!inRangeTime(new Date(this.state.selectYear, this.state.selectMonth), this.props.min ?? startDate, this.props.min ?? endDate)) {
188
+ if (this.state.selectYear === this.state.selectDate?.getFullYear() && this.state.selectDate.getMonth() === i) {
189
+ style = {
190
+ color: 'var(--disabled-font-color)',
191
+ pointerEvents: 'none'
192
+ }
193
+ }
194
+ }
195
+ if (this.state.selectYear === this.state.value.getFullYear() && i === this.state.value.getMonth()) {
196
+ selected = true
197
+ }
198
+ return <button type="button" key={timeValue.toString()} className={`month-picker-circle body-3 row ${selected ? 'selected' : ''}`} style={style} {...additionProps}
199
+ onClick={() => {
200
+ if (this.props.type === CalendarType.MONTH) {
201
+ this.setState({ ...this.state, value: timeValue })
202
+ if (this.props.onSelect) this.props.onSelect(timeValue)
203
+ } else {
204
+ this.setState({ ...this.state, selectMonth: i, type: CalendarType.DATE })
205
+ }
206
+ }}
207
+ >
208
+ {monthTitle}
209
+ </button>
210
+ })}
211
+ </>
212
+ }
213
+
214
+ showYearInRange() {
215
+ return <>
216
+ {Array.from({ length: 12 }).map((_, i) => {
217
+ let firstYearInTable = this.state.selectYear - ((this.state.selectYear - startDate.getFullYear()) % 12)
218
+ let yearNumber = i + firstYearInTable
219
+ let additionProps = {}
220
+ let style = {}
221
+ let selected = false
222
+ if (yearNumber === today.getFullYear()) {
223
+ style = { borderColor: 'var(--infor-color)' }
224
+ } else if (yearNumber < ((this.props.min ?? startDate).getFullYear()) || yearNumber > ((this.props.min ?? endDate).getFullYear())) {
225
+ additionProps = { 'in-range': 'false' }
226
+ }
227
+ if (yearNumber === this.state.value.getFullYear()) {
228
+ selected = true
229
+ }
230
+ return <button type="button" key={yearNumber.toString()} className={`year-picker-circle body-3 row ${selected ? 'selected' : ''}`} style={style} {...additionProps}
231
+ onClick={() => {
232
+ if (this.props.type === CalendarType.YEAR) {
233
+ this.setState({ ...this.state, value: new Date(yearNumber) })
234
+ if (this.props.onSelect) this.props.onSelect(new Date(yearNumber))
235
+ } else {
236
+ this.setState({ ...this.state, type: CalendarType.MONTH, selectYear: yearNumber })
237
+ }
238
+ }}
239
+ >
240
+ {yearNumber}
241
+ </button>
242
+ })}
243
+ </>
244
+ }
245
+
246
+ getTitle() {
247
+ switch (this.state.type) {
248
+ case CalendarType.YEAR:
249
+ let firstYearInTable = this.state.selectYear - ((this.state.selectYear - startDate.getFullYear()) % 12)
250
+ return `${firstYearInTable}-${firstYearInTable + 11}`
251
+ case CalendarType.MONTH:
252
+ return this.state.selectYear
253
+ default:
254
+ switch (this.state.selectMonth) {
255
+ case 0:
256
+ var monthName = 'January'
257
+ break
258
+ case 1:
259
+ monthName = 'February'
260
+ break
261
+ case 2:
262
+ monthName = 'March'
263
+ break
264
+ case 3:
265
+ monthName = 'April'
266
+ break
267
+ case 4:
268
+ monthName = 'May'
269
+ break
270
+ case 5:
271
+ monthName = 'June'
272
+ break
273
+ case 6:
274
+ monthName = 'July'
275
+ break
276
+ case 7:
277
+ monthName = 'August'
278
+ break
279
+ case 8:
280
+ monthName = 'September'
281
+ break
282
+ case 9:
283
+ monthName = 'October'
284
+ break
285
+ case 10:
286
+ monthName = 'November'
287
+ break
288
+ case 11:
289
+ monthName = 'December'
290
+ break
291
+ default:
292
+ monthName = ''
293
+ break
294
+ }
295
+ return `${monthName} ${this.state.selectYear}`
296
+ }
297
+ }
298
+
299
+ render(): React.ReactNode {
300
+ return <div className={`row calendar-container ${this.props.className}`} style={this.props.style}>
301
+ {this.props.showSidebar ? <div className="calendar-sidebar-options col">
302
+ <button type="button" onClick={() => { }} className="label-4 calendar-sidebar-option-buttton">Yesterday</button>
303
+ <button type="button" className="label-4 calendar-sidebar-option-buttton">Last week</button>
304
+ <button type="button" className="label-4 calendar-sidebar-option-buttton">Last month</button>
305
+ <button type="button" className="label-4 calendar-sidebar-option-buttton">Last year</button>
306
+ </div> : null}
307
+ <div className="calendar-body col">
308
+ <div className="row" style={{ alignItems: 'start' }} >
309
+ <div className="picker-date-container col">
310
+ <div className='picker-date-header row'>
311
+ <button type='button'
312
+ onClick={() => {
313
+ switch (this.state.type) {
314
+ case CalendarType.YEAR:
315
+ if (this.state.selectYear - 20 < startDate.getFullYear()) {
316
+ this.setState({ ...this.state, selectYear: startDate.getFullYear() })
317
+ } else {
318
+ this.setState({ ...this.state, selectYear: this.state.selectYear - 20 })
319
+ }
320
+ break
321
+ case CalendarType.MONTH:
322
+ if (this.state.selectYear - 10 < startDate.getFullYear()) {
323
+ this.setState({ ...this.state, selectYear: startDate.getFullYear() })
324
+ } else {
325
+ this.setState({ ...this.state, selectYear: this.state.selectYear - 10 })
326
+ }
327
+ break
328
+ default:
329
+ this.setState({ ...this.state, selectYear: this.state.selectYear - 1 })
330
+ break
331
+ }
332
+ }}
333
+ >
334
+ <FontAwesomeIcon icon={faAngleDoubleLeft} />
335
+ </button>
336
+ <button type='button'
337
+ onClick={() => {
338
+ switch (this.state.type) {
339
+ case CalendarType.YEAR:
340
+ if (this.state.selectYear - 10 < startDate.getFullYear()) {
341
+ this.setState({ ...this.state, selectYear: startDate.getFullYear() })
342
+ } else {
343
+ this.setState({ ...this.state, selectYear: this.state.selectYear - 10 })
344
+ }
345
+ break
346
+ case CalendarType.MONTH:
347
+ if (this.state.selectYear - 1 >= startDate.getFullYear()) {
348
+ this.setState({ ...this.state, selectYear: this.state.selectYear - 1 })
349
+ }
350
+ break
351
+ default:
352
+ const newDataVl = new Date(this.state.selectYear, this.state.selectMonth - 1, 1)
353
+ this.setState({ ...this.state, selectMonth: newDataVl.getMonth(), selectYear: newDataVl.getFullYear() })
354
+ break
355
+ }
356
+ }}
357
+ >
358
+ <FontAwesomeIcon icon={faAngleLeft} />
359
+ </button>
360
+ <span className="heading-7" onClick={() => {
361
+ if (this.state.type !== CalendarType.YEAR)
362
+ this.setState({ ...this.state, type: this.state.type === CalendarType.DATE ? CalendarType.MONTH : CalendarType.YEAR })
363
+ }} >
364
+ {this.getTitle()}
365
+ </span>
366
+ <button type='button'
367
+ onClick={() => {
368
+ switch (this.state.type) {
369
+ case CalendarType.YEAR:
370
+ if (this.state.selectYear + 10 > endDate.getFullYear()) {
371
+ this.setState({ ...this.state, selectYear: endDate.getFullYear() })
372
+ } else {
373
+ this.setState({ ...this.state, selectYear: this.state.selectYear + 10 })
374
+ }
375
+ break
376
+ case CalendarType.MONTH:
377
+ if (this.state.selectYear + 1 <= endDate.getFullYear()) {
378
+ this.setState({ ...this.state, selectYear: this.state.selectYear + 1 })
379
+ }
380
+ break
381
+ default:
382
+ const newDataVl = new Date(this.state.selectYear, this.state.selectMonth + 1, 1)
383
+ this.setState({ ...this.state, selectMonth: newDataVl.getMonth(), selectYear: newDataVl.getFullYear() })
384
+ break
385
+ }
386
+ }}
387
+ >
388
+ <FontAwesomeIcon icon={faAngleRight} />
389
+ </button>
390
+ <button type='button'
391
+ onClick={() => {
392
+ switch (this.state.type) {
393
+ case CalendarType.YEAR:
394
+ if (this.state.selectYear + 20 > endDate.getFullYear()) {
395
+ this.setState({ ...this.state, selectYear: endDate.getFullYear() })
396
+ } else {
397
+ this.setState({ ...this.state, selectYear: this.state.selectYear + 20 })
398
+ }
399
+ break
400
+ case CalendarType.MONTH:
401
+ if (this.state.selectYear + 10 < endDate.getFullYear()) {
402
+ this.setState({ ...this.state, selectYear: endDate.getFullYear() })
403
+ } else {
404
+ this.setState({ ...this.state, selectYear: this.state.selectYear + 10 })
405
+ }
406
+ break
407
+ default:
408
+ this.setState({ ...this.state, selectYear: this.state.selectYear + 1 })
409
+ break
410
+ }
411
+ }}
412
+ >
413
+ <FontAwesomeIcon icon={faAngleDoubleRight} />
414
+ </button>
415
+ </div>
416
+ <div className='picker-date-body row' >
417
+ {this.state.type === CalendarType.YEAR ? this.showYearInRange() : this.state.type === CalendarType.MONTH ? this.showMonthInYear() : this.showDateInMonth()}
418
+ </div>
419
+ </div>
420
+ {this.props.type === CalendarType.DATETIME ? <div className="picker-time-container col">
421
+ <div className="heading-7">{this.state.selectHours < 10 ? `0${this.state.selectHours}` : this.state.selectHours}:{this.state.selectMinutes < 10 ? `0${this.state.selectMinutes}` : this.state.selectMinutes}:{this.state.selectSeconds < 10 ? `0${this.state.selectSeconds}` : this.state.selectSeconds}</div>
422
+ <div className="row" style={{ alignItems: 'start', flex: 1, height: '100%' }}>
423
+ <div className="scroll-picker-hours col">{Array.from({ length: 24 }).map((_, i) => <button type="button" onClick={() => {
424
+ let newValue = this.state.value
425
+ newValue.setHours(i)
426
+ this.setState({ ...this.state, selectHours: i, value: newValue })
427
+ if (this.props.onSelect) this.props.onSelect(newValue)
428
+ }} key={`hours-${i}`} className={`label-4 ${this.state.selectHours === (i) ? 'selected' : ''}`} >{i < 10 ? `0${i}` : i}</button>)}</div>
429
+ <div className="scroll-picker-minutes col">{Array.from({ length: 60 }).map((_, i) => <button type="button" onClick={() => {
430
+ let newValue = this.state.value
431
+ newValue.setMinutes(i)
432
+ this.setState({ ...this.state, selectMinutes: i, value: newValue })
433
+ if (this.props.onSelect) this.props.onSelect(newValue)
434
+ }} key={`hours-${i}`} className={`label-4 ${this.state.selectMinutes === (i) ? 'selected' : ''}`} >{i < 10 ? `0${i}` : i}</button>)}</div>
435
+ <div className="scroll-picker-seconds col">{Array.from({ length: 60 }).map((_, i) => <button type="button" onClick={() => {
436
+ let newValue = this.state.value
437
+ newValue.setSeconds(i)
438
+ this.setState({ ...this.state, selectSeconds: i, value: newValue })
439
+ if (this.props.onSelect) this.props.onSelect(newValue)
440
+ }} key={`hours-${i}`} className={`label-4 ${this.state.selectSeconds === (i) ? 'selected' : ''}`} >{i < 10 ? `0${i}` : i}</button>)}</div>
441
+ </div>
442
+ </div> : null}
443
+ </div>
444
+ {this.props.footer}
445
+ </div>
446
+ </div>
447
+ }
448
+ }
@@ -0,0 +1,46 @@
1
+ .checkbox-container {
2
+ position: relative;
3
+ border-radius: 0.4rem;
4
+ border: 1px solid #00358033;
5
+ background-color: var(--infor-color);
6
+ transition: border, background-color 0.5s;
7
+ cursor: pointer;
8
+ }
9
+
10
+ .checkbox-container:not(*:has(> input:checked)) {
11
+ background-color: transparent !important;
12
+ }
13
+
14
+ .checkbox-container>input {
15
+ position: absolute;
16
+ opacity: 0;
17
+ cursor: pointer;
18
+ height: 0;
19
+ width: 0;
20
+ }
21
+
22
+ .checkbox-container>svg {
23
+ width: 100%;
24
+ height: 100%;
25
+ visibility: hidden;
26
+ opacity: 0 !important;
27
+ transition: visibility, opacity 0.5s;
28
+ }
29
+
30
+ .checkbox-container>input:checked~svg {
31
+ visibility: visible;
32
+ opacity: 1 !important;
33
+ }
34
+
35
+ .checkbox-container:has(> input:checked) {
36
+ border: none !important;
37
+ }
38
+
39
+ .checkbox-container:has(> input:disabled) {
40
+ background-color: var(--disabled-background) !important;
41
+ border: 1px solid #00358033 !important;
42
+ }
43
+
44
+ .checkbox-container:has(> input:disabled) > svg > path {
45
+ stroke: #00204D40 !important;
46
+ }
@@ -0,0 +1,59 @@
1
+ import React, { CSSProperties } from 'react';
2
+ import './checkbox.css';
3
+
4
+ interface CheckboxProps {
5
+ onChange?: (value: boolean) => void,
6
+ value?: boolean,
7
+ checkColor?: string,
8
+ disabled?: false,
9
+ style?: CSSProperties,
10
+ /** default 2.4rem **/
11
+ size?: number | string,
12
+ }
13
+
14
+ interface CheckboxState {
15
+ value?: boolean,
16
+ }
17
+
18
+ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
19
+ state: Readonly<CheckboxState> = {
20
+ value: this.props.value ?? false
21
+ }
22
+
23
+ componentDidUpdate(prevProps: Readonly<CheckboxProps>): void {
24
+ if (prevProps.value !== this.props.value) {
25
+ this.setState({ value: this.props.value })
26
+ }
27
+ }
28
+
29
+ render() {
30
+ let convertStyle: CSSProperties = {
31
+ width: this.props.size ?? '2.4rem',
32
+ height: this.props.size ?? '2.4rem',
33
+ }
34
+ if (this.props.style) {
35
+ delete this.props.style.width
36
+ delete this.props.style.minWidth
37
+ delete this.props.style.maxWidth
38
+ delete this.props.style.height
39
+ delete this.props.style.minHeight
40
+ delete this.props.style.maxHeight
41
+ convertStyle = {
42
+ ...this.props.style,
43
+ ...convertStyle
44
+ }
45
+ }
46
+ return <label className="checkbox-container row" style={convertStyle} >
47
+ <input type="checkbox" checked={this.state.value} disabled={this.props.disabled}
48
+ onChange={() => {
49
+ const newValue = !this.state.value
50
+ this.setState({ value: newValue })
51
+ if (this.props.onChange) this.props.onChange(newValue)
52
+ }}
53
+ />
54
+ <svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" >
55
+ <path d="M6.72 11.52 L10.8 15.6 L18 7.2" fill="none" strokeLinecap="round" stroke={this.props.checkColor ?? '#ffffff'} />
56
+ </svg>
57
+ </label>
58
+ }
59
+ }
@@ -0,0 +1,53 @@
1
+ import React from "react"
2
+
3
+ export const enum ComponentStatus {
4
+ INFOR = 1,
5
+ ERROR = 2,
6
+ WARNING = 3,
7
+ SUCCSESS = 4,
8
+ }
9
+
10
+ export const getStatusIcon = (status: ComponentStatus) => {
11
+ switch (status) {
12
+ case ComponentStatus.ERROR:
13
+ return errorSvg
14
+ case ComponentStatus.WARNING:
15
+ return warningSvg
16
+ case ComponentStatus.SUCCSESS:
17
+ return successSvg
18
+ default:
19
+ return inforSvg
20
+ }
21
+ }
22
+
23
+ const inforSvg = (
24
+ <div style={{ width: '3.6rem', height: '3.6rem' }}>
25
+ <svg width='100%' height='100%' viewBox='0 0 36 36' fill='none' xmlns='http://www.w3.org/2000/svg' >
26
+ <path d='M18.0003 3.41669C15.116 3.41669 12.2965 4.27198 9.89826 5.87442C7.50005 7.47686 5.63087 9.75446 4.52709 12.4192C3.42331 15.084 3.13451 18.0162 3.69721 20.8451C4.25991 23.674 5.64884 26.2725 7.68836 28.312C9.72787 30.3515 12.3264 31.7404 15.1553 32.3031C17.9842 32.8658 20.9164 32.577 23.5811 31.4733C26.2459 30.3695 28.5235 28.5003 30.1259 26.1021C31.7284 23.7039 32.5837 20.8843 32.5837 18C32.5795 14.1336 31.0417 10.4267 28.3077 7.69266C25.5737 4.95867 21.8668 3.42087 18.0003 3.41669V3.41669ZM19.2496 26.1715H16.7401V15.5695H19.2496V26.1715ZM19.0418 12.2384C18.9034 12.3653 18.7407 12.463 18.5637 12.5256C18.3866 12.5883 18.1987 12.6146 18.0113 12.603C17.8204 12.6157 17.6289 12.5899 17.4481 12.5273C17.2673 12.4647 17.101 12.3664 16.9588 12.2384C16.8333 12.1032 16.7363 11.9441 16.6737 11.7706C16.611 11.5971 16.584 11.4127 16.5943 11.2285C16.5815 11.04 16.6073 10.8509 16.67 10.6727C16.7327 10.4945 16.8309 10.3309 16.9588 10.1919C17.1013 10.0644 17.2678 9.96649 17.4484 9.9039C17.6291 9.84131 17.8204 9.81526 18.0113 9.82728C18.1987 9.81637 18.3864 9.843 18.5633 9.90561C18.7403 9.96822 18.903 10.0655 19.0418 10.1919C19.1697 10.3309 19.268 10.4945 19.3307 10.6727C19.3934 10.8509 19.4191 11.04 19.4064 11.2285C19.4166 11.4127 19.3896 11.5971 19.327 11.7706C19.2644 11.9441 19.1674 12.1032 19.0418 12.2384Z' fill='#366AE2' />
27
+ </svg>
28
+ </div>
29
+ )
30
+
31
+ const errorSvg = (
32
+ <div style={{ width: '3.6rem', height: '3.6rem' }}>
33
+ <svg width='100%' height='100%' viewBox='0 0 36 36' fill='none' xmlns='http://www.w3.org/2000/svg' >
34
+ <path d='M18.0003 3.41669C15.116 3.41669 12.2965 4.27198 9.89826 5.87442C7.50005 7.47686 5.63087 9.75446 4.52709 12.4192C3.42331 15.084 3.13451 18.0162 3.69721 20.8451C4.25991 23.674 5.64884 26.2725 7.68836 28.312C9.72787 30.3515 12.3264 31.7404 15.1553 32.3031C17.9842 32.8658 20.9164 32.577 23.5811 31.4733C26.2459 30.3695 28.5235 28.5003 30.1259 26.1021C31.7284 23.7039 32.5837 20.8843 32.5837 18C32.5724 14.1357 31.0324 10.4329 28.2999 7.70044C25.5674 4.96797 21.8646 3.42791 18.0003 3.41669V3.41669ZM24.016 22.2972L22.2976 24.0156L18.0003 19.7184L13.7031 24.0156L11.9847 22.2972L16.2819 18L11.9847 13.7028L13.7031 11.9844L18.0003 16.2816L22.2976 11.9844L24.016 13.7028L19.7187 18L24.016 22.2972Z' fill='#E14337' />
35
+ </svg>
36
+ </div>
37
+ )
38
+
39
+ const warningSvg = (
40
+ <div style={{ width: '3.6rem', height: '3.6rem' }}>
41
+ <svg width='100%' height='100%' viewBox='0 0 36 36' fill='none' xmlns='http://www.w3.org/2000/svg' >
42
+ <path d='M32.1516 25.8877L21.3215 5.41379C21.0014 4.81074 20.5231 4.30622 19.938 3.95437C19.3529 3.60252 18.6831 3.41663 18.0003 3.41663C17.3176 3.41663 16.6477 3.60252 16.0626 3.95437C15.4775 4.30622 14.9993 4.81074 14.6792 5.41379L3.84901 25.8877C3.54781 26.459 3.39954 27.0984 3.41863 27.744C3.43771 28.3895 3.6235 29.0191 3.95793 29.5716C4.29235 30.1241 4.76404 30.5806 5.32713 30.8969C5.89022 31.2131 6.52555 31.3783 7.17136 31.3763H28.8293C29.4751 31.3783 30.1104 31.2131 30.6735 30.8969C31.2366 30.5806 31.7083 30.1241 32.0427 29.5716C32.3771 29.0191 32.5629 28.3895 32.582 27.744C32.6011 27.0984 32.4528 26.459 32.1516 25.8877ZM18.0003 27.7294C17.6397 27.7294 17.2871 27.6224 16.9873 27.4221C16.6874 27.2217 16.4537 26.9369 16.3157 26.6037C16.1776 26.2705 16.1415 25.9039 16.2119 25.5502C16.2823 25.1965 16.4559 24.8715 16.7109 24.6165C16.966 24.3615 17.2909 24.1878 17.6446 24.1175C17.9983 24.0471 18.3649 24.0832 18.6981 24.2212C19.0313 24.3593 19.3161 24.593 19.5165 24.8928C19.7168 25.1927 19.8238 25.5453 19.8238 25.9059C19.8238 26.3895 19.6317 26.8533 19.2897 27.1953C18.9477 27.5373 18.4839 27.7294 18.0003 27.7294ZM19.216 21.6512H16.7847L16.1769 11.926H19.8238L19.216 21.6512Z' fill='#FC6B03' />
43
+ </svg>
44
+ </div>
45
+ )
46
+
47
+ const successSvg = (
48
+ <div style={{ width: '3.6rem', height: '3.6rem' }}>
49
+ <svg width='100%' height='100%' viewBox='0 0 36 36' fill='none' xmlns='http://www.w3.org/2000/svg' >
50
+ <path d='M18.0003 3.41669C15.116 3.41669 12.2965 4.27198 9.89826 5.87442C7.50005 7.47686 5.63087 9.75446 4.52709 12.4192C3.42331 15.084 3.13451 18.0162 3.69721 20.8451C4.25991 23.674 5.64884 26.2725 7.68836 28.312C9.72787 30.3515 12.3264 31.7404 15.1553 32.3031C17.9842 32.8658 20.9164 32.577 23.5811 31.4733C26.2459 30.3695 28.5235 28.5003 30.1259 26.1021C31.7284 23.7039 32.5837 20.8843 32.5837 18C32.5724 14.1357 31.0324 10.4329 28.2999 7.70044C25.5674 4.96797 21.8646 3.42791 18.0003 3.41669V3.41669ZM15.5698 24.5795L8.99026 18L10.7087 16.2816L15.5698 21.1427L25.292 11.4205L27.0104 13.1389L15.5698 24.5795Z' fill='#39AC6D' />
51
+ </svg>
52
+ </div>
53
+ )