@jsfour/root-ui 0.0.1
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/.stencil/.build/_README.log +8 -0
- package/.stencil/.build/optimizeCss_d508b9fc8ae8bf613c09ccb27d146e3a.log +1 -0
- package/.stencil/.build/optimizeModule_0b160af7f941adcacfa811e102b08adf.log +2 -0
- package/.stencil/.build/optimizeModule_0b246ca6c0647c40ed469a0cf4358a73.log +1 -0
- package/.stencil/.build/optimizeModule_1bed709b53ef02375e9f61a9dfa643f3.log +1 -0
- package/.stencil/.build/optimizeModule_1d7b03de1d56993f8736d0dfa953b016.log +1 -0
- package/.stencil/.build/optimizeModule_211068a08f9a2243f9b6bbc0d066ca7b.log +1 -0
- package/.stencil/.build/optimizeModule_2187d3c4a8fdf77d63b94a49e5339089.log +1 -0
- package/.stencil/.build/optimizeModule_25ac0c9c93505850d30d777a8983d6cc.log +1 -0
- package/.stencil/.build/optimizeModule_2a8347890bf34de8ebcd825e93de4eac.log +1 -0
- package/.stencil/.build/optimizeModule_310d74be43349d9cd4462216f44e3025.log +1 -0
- package/.stencil/.build/optimizeModule_35ed1b3083d56d1312b29cdc8702dde6.log +1 -0
- package/.stencil/.build/optimizeModule_3abf5364bd9f3e07cabdf31f25fdfccd.log +1 -0
- package/.stencil/.build/optimizeModule_3c694181a383d2d5d7c43959dae3fc40.log +2 -0
- package/.stencil/.build/optimizeModule_3e5a7a979ee157dee476e23a940398bf.log +1 -0
- package/.stencil/.build/optimizeModule_3f113b87a2543efdae16831cf4a13466.log +1 -0
- package/.stencil/.build/optimizeModule_4cf0a704790c64fa3e7636ba3472dff6.log +1 -0
- package/.stencil/.build/optimizeModule_5473d4453ebf4ef999ac7777394048db.log +1 -0
- package/.stencil/.build/optimizeModule_56e4598e7f285cec042c0632923a473c.log +1 -0
- package/.stencil/.build/optimizeModule_5721447e0280cf2192180b57b6ffd931.log +1 -0
- package/.stencil/.build/optimizeModule_5fe32756e8649adbca14ee76bdfbfad3.log +2 -0
- package/.stencil/.build/optimizeModule_60477845aacd02169ef3d0091bfb345f.log +1 -0
- package/.stencil/.build/optimizeModule_645cc880dd3009950a72ea147a926718.log +1 -0
- package/.stencil/.build/optimizeModule_64633d5e5c5103adb5683fc19edaa8b8.log +1 -0
- package/.stencil/.build/optimizeModule_6b615133c24ac4e6c5428eb74470b5cb.log +1 -0
- package/.stencil/.build/optimizeModule_6e9d6355a774b23f578c75f14d78e605.log +1 -0
- package/.stencil/.build/optimizeModule_8797e91e099ec89d9158d143cc9e8199.log +1 -0
- package/.stencil/.build/optimizeModule_8a9445cafc85dc657334e37e1fce6fdc.log +1 -0
- package/.stencil/.build/optimizeModule_8c399f3f088e7f1cbb87f65d8e96bfc4.log +1 -0
- package/.stencil/.build/optimizeModule_90f423b7b20b32670cb13ca6605940fa.log +1 -0
- package/.stencil/.build/optimizeModule_9d37b0c4d3ae587fe9c9f384659ac198.log +1 -0
- package/.stencil/.build/optimizeModule_9eb9260f8aec9636ffc5e00444eaa1ea.log +1 -0
- package/.stencil/.build/optimizeModule_a90d2726fdff70d788aaa8b3fbc0adc7.log +1 -0
- package/.stencil/.build/optimizeModule_ad865e38167d997d66ef7128fdb36b5e.log +1 -0
- package/.stencil/.build/optimizeModule_b1b3b2dbe6634f16e4a063d74c2df110.log +1 -0
- package/.stencil/.build/optimizeModule_b24fa4d64bacca187db7a0654705e182.log +1 -0
- package/.stencil/.build/optimizeModule_b90b0f1d4d3dd3aae106476a0cce19c0.log +1 -0
- package/.stencil/.build/optimizeModule_c0fee36e4d0c0c701c749a56eec1f7d8.log +1 -0
- package/.stencil/.build/optimizeModule_ceeae0c907ecc2a87e2ad19d79e99510.log +1 -0
- package/.stencil/.build/optimizeModule_d68f87c26c9b5557f71199e397b81fde.log +1 -0
- package/.stencil/.build/optimizeModule_d6b6b4cfa8009d54eb301d8147c45850.log +1 -0
- package/.stencil/.build/optimizeModule_d7a4dadc89824480596190cf7a033e72.log +1 -0
- package/.stencil/.build/optimizeModule_ddf02b2e19bf055fcfd20ed5dc8b956d.log +2 -0
- package/.stencil/.build/optimizeModule_eb39a27ff5ef48385b4bf233760a7d1f.log +1 -0
- package/.stencil/.build/optimizeModule_eee1991c594a387b17e535171c33abbf.log +1 -0
- package/.stencil/.build/optimizeModule_f0d6e7e6666905c8da7d7450a1b4088b.log +1 -0
- package/.stencil/.build/optimizeModule_f93c97ed92b866fd99189e5a0a44e774.log +1 -0
- package/.stencil/.build/optimizeModule_fdf66b9636906890546dde0f834d4d8e.log +1 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/index-CbJkKnHq.js +3244 -0
- package/dist/cjs/index.cjs.js +25 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/root-badge_6.cjs.entry.js +343 -0
- package/dist/cjs/stencil-library.cjs.js +25 -0
- package/dist/collection/collection-manifest.json +17 -0
- package/dist/collection/components/badge/badge-variation.enum.js +9 -0
- package/dist/collection/components/badge/badge.css +45 -0
- package/dist/collection/components/badge/badge.js +148 -0
- package/dist/collection/components/banner/banner-variation.enum.js +9 -0
- package/dist/collection/components/banner/banner.css +18 -0
- package/dist/collection/components/banner/banner.js +147 -0
- package/dist/collection/components/breadcrumbs/breadcrumbs.css +49 -0
- package/dist/collection/components/breadcrumbs/breadcrumbs.js +95 -0
- package/dist/collection/components/button/button-size.enum.js +5 -0
- package/dist/collection/components/button/button-type.enum.js +6 -0
- package/dist/collection/components/button/button-variation.enum.js +10 -0
- package/dist/collection/components/button/button.css +61 -0
- package/dist/collection/components/button/button.js +207 -0
- package/dist/collection/components/index.js +6 -0
- package/dist/collection/components/input/input-type.enum.js +18 -0
- package/dist/collection/components/input/input.css +134 -0
- package/dist/collection/components/input/input.js +415 -0
- package/dist/collection/components/list/list.css +18 -0
- package/dist/collection/components/list/list.js +50 -0
- package/dist/collection/enums.js +3 -0
- package/dist/collection/global/utils/randomIdGenerator/index.js +7 -0
- package/dist/collection/index.js +1 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/p-CIjEN4Bv.js +1 -0
- package/dist/components/p-CvhBNbMT.js +1 -0
- package/dist/components/root-badge.d.ts +11 -0
- package/dist/components/root-badge.js +1 -0
- package/dist/components/root-banner.d.ts +11 -0
- package/dist/components/root-banner.js +1 -0
- package/dist/components/root-breadcrumbs.d.ts +11 -0
- package/dist/components/root-breadcrumbs.js +1 -0
- package/dist/components/root-button.d.ts +11 -0
- package/dist/components/root-button.js +1 -0
- package/dist/components/root-input.d.ts +11 -0
- package/dist/components/root-input.js +1 -0
- package/dist/components/root-list.d.ts +11 -0
- package/dist/components/root-list.js +1 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/index-Cygc6-mN.js +3236 -0
- package/dist/esm/index.js +25 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/root-badge_6.entry.js +336 -0
- package/dist/esm/stencil-library.js +21 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil-library/index.esm.js +1 -0
- package/dist/stencil-library/p-2b062e4c.entry.js +1 -0
- package/dist/stencil-library/p-Cygc6-mN.js +2 -0
- package/dist/stencil-library/p-DQuL1Twl.js +1 -0
- package/dist/stencil-library/stencil-library.esm.js +1 -0
- package/dist/types/components/badge/badge-variation.enum.d.ts +8 -0
- package/dist/types/components/badge/badge.d.ts +11 -0
- package/dist/types/components/banner/banner-variation.enum.d.ts +8 -0
- package/dist/types/components/banner/banner.d.ts +11 -0
- package/dist/types/components/breadcrumbs/breadcrumbs.d.ts +12 -0
- package/dist/types/components/button/button-size.enum.d.ts +4 -0
- package/dist/types/components/button/button-type.enum.d.ts +5 -0
- package/dist/types/components/button/button-variation.enum.d.ts +9 -0
- package/dist/types/components/button/button.d.ts +15 -0
- package/dist/types/components/index.d.ts +6 -0
- package/dist/types/components/input/input-type.enum.d.ts +17 -0
- package/dist/types/components/input/input.d.ts +37 -0
- package/dist/types/components/list/list.d.ts +7 -0
- package/dist/types/components.d.ts +388 -0
- package/dist/types/enums.d.ts +3 -0
- package/dist/types/global/utils/randomIdGenerator/index.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/stencil-public-runtime.d.ts +1839 -0
- package/package.json +28 -0
- package/src/components/badge/badge-variation.enum.ts +9 -0
- package/src/components/badge/badge.scss +53 -0
- package/src/components/badge/badge.tsx +42 -0
- package/src/components/badge/readme.md +27 -0
- package/src/components/banner/banner-variation.enum.ts +9 -0
- package/src/components/banner/banner.scss +22 -0
- package/src/components/banner/banner.tsx +41 -0
- package/src/components/banner/readme.md +27 -0
- package/src/components/breadcrumbs/breadcrumbs.scss +57 -0
- package/src/components/breadcrumbs/breadcrumbs.tsx +74 -0
- package/src/components/breadcrumbs/readme.md +24 -0
- package/src/components/button/button-size.enum.ts +5 -0
- package/src/components/button/button-type.enum.ts +5 -0
- package/src/components/button/button-variation.enum.ts +10 -0
- package/src/components/button/button.scss +73 -0
- package/src/components/button/button.tsx +52 -0
- package/src/components/button/readme.md +29 -0
- package/src/components/index.ts +7 -0
- package/src/components/input/input-type.enum.ts +18 -0
- package/src/components/input/input.scss +156 -0
- package/src/components/input/input.tsx +264 -0
- package/src/components/input/readme.md +34 -0
- package/src/components/list/list.scss +21 -0
- package/src/components/list/list.tsx +24 -0
- package/src/components/list/readme.md +17 -0
- package/src/components.d.ts +388 -0
- package/src/enums.ts +3 -0
- package/src/global/styles/index.scss +0 -0
- package/src/global/utils/randomIdGenerator/index.ts +8 -0
- package/src/index.html +105 -0
- package/src/index.ts +2 -0
- package/stencil.config.ts +36 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
.root-input {
|
|
2
|
+
&--full-width {
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.root-input-field {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
width: 100%;
|
|
10
|
+
border-radius: 0.75rem;
|
|
11
|
+
background-color: var(--rootsdk-input);
|
|
12
|
+
border: 0.03125rem solid var(--rootsdk-highlight-normal);
|
|
13
|
+
color: var(--rootsdk-text-primary);
|
|
14
|
+
min-height: 2em;
|
|
15
|
+
outline: transparent;
|
|
16
|
+
box-shadow: none;
|
|
17
|
+
padding: 1rem;
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
cursor: text;
|
|
20
|
+
|
|
21
|
+
&.root-input-field--textarea {
|
|
22
|
+
align-items: flex-start;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&.root-input-field--file {
|
|
26
|
+
position: relative;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.root-input-field--color {
|
|
31
|
+
position: relative;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:focus-within {
|
|
36
|
+
border: 0.03125rem solid var(--rootsdk-brand-primary);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&.root-input-field--error {
|
|
40
|
+
border-color: var(--rootsdk-error, #e53935);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.root-input-icon {
|
|
45
|
+
margin-right: 0.5rem;
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
height: 1em;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
input {
|
|
53
|
+
flex: 1;
|
|
54
|
+
border: none;
|
|
55
|
+
background: transparent;
|
|
56
|
+
color: inherit;
|
|
57
|
+
font-family: inherit;
|
|
58
|
+
outline: none;
|
|
59
|
+
padding: 0;
|
|
60
|
+
margin: 0;
|
|
61
|
+
text-overflow: ellipsis;
|
|
62
|
+
cursor: text;
|
|
63
|
+
|
|
64
|
+
&[type='file'] {
|
|
65
|
+
position: absolute;
|
|
66
|
+
inset: 0;
|
|
67
|
+
opacity: 0;
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&[type='color'] {
|
|
72
|
+
position: absolute;
|
|
73
|
+
inset: 0;
|
|
74
|
+
opacity: 0;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
}
|
|
77
|
+
&::-webkit-calendar-picker-indicator {
|
|
78
|
+
display: none;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&::-webkit-outer-spin-button,
|
|
82
|
+
&::-webkit-inner-spin-button {
|
|
83
|
+
-webkit-appearance: none;
|
|
84
|
+
margin: 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
textarea {
|
|
89
|
+
flex: 1;
|
|
90
|
+
border: none;
|
|
91
|
+
background: transparent;
|
|
92
|
+
color: inherit;
|
|
93
|
+
font-family: inherit;
|
|
94
|
+
outline: none;
|
|
95
|
+
padding: 0;
|
|
96
|
+
margin: 0;
|
|
97
|
+
resize: vertical;
|
|
98
|
+
min-height: 6rem;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.root-input-number-controls {
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-direction: column;
|
|
104
|
+
gap: 0;
|
|
105
|
+
margin-left: 0;
|
|
106
|
+
margin-right: 0.5rem;
|
|
107
|
+
height: 1em;
|
|
108
|
+
line-height: 0.5;
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.root-input-file-label {
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
justify-content: space-between;
|
|
118
|
+
gap: 0.5rem;
|
|
119
|
+
width: 100%;
|
|
120
|
+
pointer-events: none;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.root-input-color-label {
|
|
124
|
+
display: flex;
|
|
125
|
+
align-items: center;
|
|
126
|
+
gap: 0.5rem;
|
|
127
|
+
width: 100%;
|
|
128
|
+
pointer-events: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.root-input-color-swatch {
|
|
132
|
+
width: 1rem;
|
|
133
|
+
height: 1rem;
|
|
134
|
+
border-radius: 4px;
|
|
135
|
+
border: 0.03125rem solid var(--rootsdk-highlight-normal);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.root-input-color-text {
|
|
139
|
+
font-family: inherit;
|
|
140
|
+
color: inherit;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
label {
|
|
144
|
+
font-size: 0.875rem;
|
|
145
|
+
color: var(--rootsdk-text-tertiary);
|
|
146
|
+
text-transform: capitalize;
|
|
147
|
+
margin-bottom: .5rem;
|
|
148
|
+
display: block;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.root-input-error {
|
|
152
|
+
margin-top: 0.35rem;
|
|
153
|
+
color: var(--rootsdk-error, #e53935);
|
|
154
|
+
font-size: 0.75rem;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { Component, h, Prop, Event, EventEmitter, Watch, State, Element } from '@stencil/core';
|
|
2
|
+
import { randomIdGenerator } from '../../global/utils/randomIdGenerator';
|
|
3
|
+
import { RootInputType } from './input-type.enum';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
tag: 'root-input',
|
|
7
|
+
styleUrl: 'input.scss',
|
|
8
|
+
shadow: true
|
|
9
|
+
})
|
|
10
|
+
export class RootInput {
|
|
11
|
+
@Element() hostElement: HTMLElement;
|
|
12
|
+
|
|
13
|
+
private inputRef?: HTMLInputElement | HTMLTextAreaElement;
|
|
14
|
+
|
|
15
|
+
@Prop() inputId: string = randomIdGenerator('root-input');
|
|
16
|
+
|
|
17
|
+
@Prop() type: RootInputType = RootInputType.TEXT;
|
|
18
|
+
|
|
19
|
+
@Prop() label!: string;
|
|
20
|
+
|
|
21
|
+
@Prop() inputName: string;
|
|
22
|
+
|
|
23
|
+
@Prop() placeholder: string = '';
|
|
24
|
+
|
|
25
|
+
@Prop({ mutable: true }) value: string = '';
|
|
26
|
+
|
|
27
|
+
@Watch('value')
|
|
28
|
+
onValueChanged(newValue: string) {
|
|
29
|
+
this.inputValue = newValue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Prop() maxlength: number;
|
|
33
|
+
|
|
34
|
+
@Prop() fullWidth: boolean = false;
|
|
35
|
+
|
|
36
|
+
@Prop() multiline: boolean = false;
|
|
37
|
+
|
|
38
|
+
@Prop() icon: boolean = true;
|
|
39
|
+
|
|
40
|
+
@State() showPassword: boolean = false;
|
|
41
|
+
|
|
42
|
+
@State() inputValue: string = '';
|
|
43
|
+
|
|
44
|
+
@State() error: string = '';
|
|
45
|
+
|
|
46
|
+
@State() touched: boolean = false;
|
|
47
|
+
|
|
48
|
+
@State() hasIcon: boolean = false;
|
|
49
|
+
|
|
50
|
+
@State() fileLabel: string = 'Select file';
|
|
51
|
+
|
|
52
|
+
@Event() rootInputChange: EventEmitter<string>;
|
|
53
|
+
|
|
54
|
+
@Event() rootInputBlur: EventEmitter<FocusEvent>;
|
|
55
|
+
|
|
56
|
+
componentWillLoad() {
|
|
57
|
+
this.setHasIcon();
|
|
58
|
+
this.inputValue = this.value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setHasIcon() {
|
|
62
|
+
const icon = !!this.hostElement.querySelector('[slot="icon"]');
|
|
63
|
+
|
|
64
|
+
if (icon) {
|
|
65
|
+
this.hasIcon = icon;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
private openPicker = () => {
|
|
72
|
+
if (!this.inputRef) return;
|
|
73
|
+
|
|
74
|
+
const el = this.inputRef;
|
|
75
|
+
if (el instanceof HTMLInputElement && (el as any).showPicker) {
|
|
76
|
+
(el as any).showPicker();
|
|
77
|
+
} else {
|
|
78
|
+
el.focus();
|
|
79
|
+
if (el instanceof HTMLInputElement) {
|
|
80
|
+
el.click();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private togglePasswordVisibility = () => {
|
|
86
|
+
this.showPassword = !this.showPassword;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private incrementNumber = () => {
|
|
90
|
+
if (this.inputRef instanceof HTMLInputElement) {
|
|
91
|
+
this.inputRef.stepUp();
|
|
92
|
+
this.inputValue = this.inputRef.value;
|
|
93
|
+
this.rootInputChange.emit(this.inputValue);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private decrementNumber = () => {
|
|
98
|
+
if (this.inputRef instanceof HTMLInputElement) {
|
|
99
|
+
this.inputRef.stepDown();
|
|
100
|
+
this.inputValue = this.inputRef.value;
|
|
101
|
+
this.rootInputChange.emit(this.inputValue);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private validate = (val: string): string => {
|
|
106
|
+
if (!val) return '';
|
|
107
|
+
|
|
108
|
+
if (this.type === RootInputType.EMAIL) {
|
|
109
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
110
|
+
return emailRegex.test(val) ? '' : 'Please enter a valid email address.';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (this.type === RootInputType.TEL) {
|
|
114
|
+
const phoneRegex = /^[+]?[- 0-9()]{7,}$/;
|
|
115
|
+
return phoneRegex.test(val) ? '' : 'Please enter a valid phone number.';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return '';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private handleBlur = (e: FocusEvent) => {
|
|
122
|
+
this.touched = true;
|
|
123
|
+
this.error = this.validate(this.inputValue);
|
|
124
|
+
this.rootInputBlur.emit(e);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private handleChange = (e: Event) => {
|
|
128
|
+
const target = e.target as HTMLInputElement | HTMLTextAreaElement;
|
|
129
|
+
const nextValue = target.value;
|
|
130
|
+
this.inputValue = nextValue;
|
|
131
|
+
this.rootInputChange.emit(nextValue);
|
|
132
|
+
|
|
133
|
+
if (this.touched) {
|
|
134
|
+
this.error = this.validate(nextValue);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private handleFileChange = (e: Event) => {
|
|
139
|
+
const target = e.target as HTMLInputElement;
|
|
140
|
+
const file = target.files?.[0];
|
|
141
|
+
|
|
142
|
+
if (file) {
|
|
143
|
+
this.fileLabel = file.name;
|
|
144
|
+
} else {
|
|
145
|
+
this.fileLabel = 'Select file';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
this.rootInputChange.emit(target.value);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private handleFieldClick = () => {
|
|
152
|
+
if (!this.inputRef) return;
|
|
153
|
+
|
|
154
|
+
if (this.multiline) {
|
|
155
|
+
this.inputRef.focus();
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (this.inputRef instanceof HTMLInputElement) {
|
|
160
|
+
if (this.inputRef.type === 'color') {
|
|
161
|
+
this.inputRef.click();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (this.inputRef.type !== 'date') {
|
|
165
|
+
this.inputRef.focus();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
render() {
|
|
171
|
+
const inputType = this.type === RootInputType.PASSWORD
|
|
172
|
+
? (this.showPassword ? 'text' : 'password')
|
|
173
|
+
: this.type;
|
|
174
|
+
|
|
175
|
+
const colorValue = this.type === RootInputType.COLOR
|
|
176
|
+
? (this.inputValue || '#000000')
|
|
177
|
+
: this.inputValue;
|
|
178
|
+
|
|
179
|
+
const classes = {
|
|
180
|
+
'root-input': true,
|
|
181
|
+
'root-input--full-width': this.fullWidth,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const fieldClasses = {
|
|
185
|
+
'root-input-field': true,
|
|
186
|
+
'root-input-field--error': !!this.error,
|
|
187
|
+
'root-input-field--file': this.type === RootInputType.FILE,
|
|
188
|
+
'root-input-field--color': this.type === RootInputType.COLOR,
|
|
189
|
+
'root-input-field--textarea': this.multiline,
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<div class={classes}>
|
|
194
|
+
<label htmlFor={this.inputId}>
|
|
195
|
+
{this.label}
|
|
196
|
+
</label>
|
|
197
|
+
<div class={fieldClasses} onClick={this.handleFieldClick}>
|
|
198
|
+
{this.hasIcon && (
|
|
199
|
+
<div class="root-input-icon" onClick={this.openPicker}>
|
|
200
|
+
<slot name="icon"></slot>
|
|
201
|
+
</div>
|
|
202
|
+
)}
|
|
203
|
+
{this.multiline ? (
|
|
204
|
+
<textarea
|
|
205
|
+
ref={(el) => this.inputRef = el}
|
|
206
|
+
placeholder={this.placeholder}
|
|
207
|
+
id={this.inputId}
|
|
208
|
+
name={this.inputName}
|
|
209
|
+
maxLength={this.maxlength}
|
|
210
|
+
value={this.inputValue}
|
|
211
|
+
onBlur={this.handleBlur}
|
|
212
|
+
onInput={this.handleChange}
|
|
213
|
+
aria-invalid={!!this.error ? 'true' : 'false'}
|
|
214
|
+
rows={3}
|
|
215
|
+
/>
|
|
216
|
+
) : (
|
|
217
|
+
<input
|
|
218
|
+
ref={(el) => this.inputRef = el}
|
|
219
|
+
placeholder={this.placeholder}
|
|
220
|
+
id={this.inputId}
|
|
221
|
+
name={this.inputName}
|
|
222
|
+
maxLength={this.maxlength}
|
|
223
|
+
type={inputType}
|
|
224
|
+
value={colorValue}
|
|
225
|
+
onBlur={this.handleBlur}
|
|
226
|
+
onInput={this.type === RootInputType.FILE ? this.handleFileChange : this.handleChange}
|
|
227
|
+
aria-invalid={!!this.error ? 'true' : 'false'}
|
|
228
|
+
/>
|
|
229
|
+
)}
|
|
230
|
+
{this.type === RootInputType.COLOR && (
|
|
231
|
+
<div class="root-input-color-label">
|
|
232
|
+
<span class="root-input-color-swatch" style={{ backgroundColor: colorValue }}></span>
|
|
233
|
+
<span class="root-input-color-text">{colorValue}</span>
|
|
234
|
+
</div>
|
|
235
|
+
)}
|
|
236
|
+
{this.type === RootInputType.FILE && !this.multiline && (
|
|
237
|
+
<div class="root-input-file-label">
|
|
238
|
+
<span>{this.fileLabel}</span>
|
|
239
|
+
<slot name="file-icon"></slot>
|
|
240
|
+
</div>
|
|
241
|
+
)}
|
|
242
|
+
{this.type === RootInputType.PASSWORD && !this.multiline && (
|
|
243
|
+
<div class="root-input-icon" onClick={this.togglePasswordVisibility}>
|
|
244
|
+
<slot name="password-icon"></slot>
|
|
245
|
+
</div>
|
|
246
|
+
)}
|
|
247
|
+
{this.type === RootInputType.NUMBER && !this.multiline && (
|
|
248
|
+
<div class="root-input-number-controls">
|
|
249
|
+
<div class="root-input-icon" onClick={this.incrementNumber}>
|
|
250
|
+
<slot name="number-up-icon"></slot>
|
|
251
|
+
</div>
|
|
252
|
+
<div class="root-input-icon" onClick={this.decrementNumber}>
|
|
253
|
+
<slot name="number-down-icon"></slot>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
)}
|
|
257
|
+
</div>
|
|
258
|
+
{this.error && this.touched && (
|
|
259
|
+
<div class="root-input-error">{this.error}</div>
|
|
260
|
+
)}
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# root-input
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
<!-- Auto Generated Below -->
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Properties
|
|
9
|
+
|
|
10
|
+
| Property | Attribute | Description | Type | Default |
|
|
11
|
+
| -------------------- | ------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
|
|
12
|
+
| `fullWidth` | `full-width` | | `boolean` | `false` |
|
|
13
|
+
| `icon` | `icon` | | `boolean` | `true` |
|
|
14
|
+
| `inputId` | `input-id` | | `string` | `randomIdGenerator('root-input')` |
|
|
15
|
+
| `inputName` | `input-name` | | `string` | `undefined` |
|
|
16
|
+
| `label` _(required)_ | `label` | | `string` | `undefined` |
|
|
17
|
+
| `maxlength` | `maxlength` | | `number` | `undefined` |
|
|
18
|
+
| `multiline` | `multiline` | | `boolean` | `false` |
|
|
19
|
+
| `placeholder` | `placeholder` | | `string` | `''` |
|
|
20
|
+
| `type` | `type` | | `RootInputType.COLOR \| RootInputType.DATE \| RootInputType.EMAIL \| RootInputType.FILE \| RootInputType.IMAGE \| RootInputType.MONTH \| RootInputType.NUMBER \| RootInputType.PASSWORD \| RootInputType.SEARCH \| RootInputType.SUBMIT \| RootInputType.TEL \| RootInputType.TEXT \| RootInputType.TIME \| RootInputType.URL \| RootInputType.WEEK` | `RootInputType.TEXT` |
|
|
21
|
+
| `value` | `value` | | `string` | `''` |
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Events
|
|
25
|
+
|
|
26
|
+
| Event | Description | Type |
|
|
27
|
+
| ----------------- | ----------- | ------------------------- |
|
|
28
|
+
| `rootInputBlur` | | `CustomEvent<FocusEvent>` |
|
|
29
|
+
| `rootInputChange` | | `CustomEvent<string>` |
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
----------------------------------------------
|
|
33
|
+
|
|
34
|
+
*Built with [StencilJS](https://stenciljs.com/)*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.root-list {
|
|
2
|
+
margin: 0;
|
|
3
|
+
padding-left: 1.5rem;
|
|
4
|
+
color: var(--rootsdk-text-primary);
|
|
5
|
+
font-size: 1rem;
|
|
6
|
+
line-height: 1.6;
|
|
7
|
+
list-style-position: inside;
|
|
8
|
+
|
|
9
|
+
&--bullet {
|
|
10
|
+
list-style-type: disc;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&--numbered {
|
|
14
|
+
list-style-type: decimal;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
li {
|
|
18
|
+
margin-bottom: 0.5rem;
|
|
19
|
+
padding-left: 0.25rem;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Component, h, Prop } from '@stencil/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
tag: 'root-list',
|
|
5
|
+
styleUrl: 'list.scss',
|
|
6
|
+
shadow: true
|
|
7
|
+
})
|
|
8
|
+
export class RootList {
|
|
9
|
+
/**
|
|
10
|
+
* The type of list: bullet or numbered
|
|
11
|
+
*/
|
|
12
|
+
@Prop() type: 'bullet' | 'numbered' = 'bullet';
|
|
13
|
+
|
|
14
|
+
render() {
|
|
15
|
+
const isNumbered = this.type === 'numbered';
|
|
16
|
+
const Tag = isNumbered ? 'ol' : 'ul';
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Tag class={{ 'root-list': true, [`root-list--${this.type}`]: true }}>
|
|
20
|
+
<slot></slot>
|
|
21
|
+
</Tag>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# root-list
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
<!-- Auto Generated Below -->
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Properties
|
|
9
|
+
|
|
10
|
+
| Property | Attribute | Description | Type | Default |
|
|
11
|
+
| -------- | --------- | ------------------------------------ | ------------------------ | ---------- |
|
|
12
|
+
| `type` | `type` | The type of list: bullet or numbered | `"bullet" \| "numbered"` | `'bullet'` |
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
----------------------------------------------
|
|
16
|
+
|
|
17
|
+
*Built with [StencilJS](https://stenciljs.com/)*
|