tide-design-system 2.1.4 → 2.1.6
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/dist/css/dynamic-utilities.css +0 -10
- package/dist/css/fonts.css +36 -0
- package/dist/css/main.css +1 -0
- package/dist/css/utilities.css +28 -6
- package/dist/css/variables.css +13 -23
- package/dist/style.css +1 -1
- package/dist/tide-design-system.cjs +2 -2
- package/dist/tide-design-system.esm.d.ts +30 -12
- package/dist/tide-design-system.esm.js +363 -334
- package/dist/utilities/storybook.ts +25 -0
- package/dist/utilities/validation.ts +3 -3
- package/package.json +3 -3
- package/src/assets/css/dynamic-utilities.css +0 -10
- package/src/assets/css/fonts.css +36 -0
- package/src/assets/css/main.css +1 -0
- package/src/assets/css/utilities.css +28 -6
- package/src/assets/css/variables.css +13 -23
- package/src/components/TideAlert.vue +8 -8
- package/src/components/TideImage.vue +11 -12
- package/src/components/TideInputSelect.vue +3 -1
- package/src/components/TideInputText.vue +14 -5
- package/src/components/TideInputTextarea.vue +3 -1
- package/src/stories/FoundationsColor.stories.ts +156 -0
- package/src/stories/TideInputSelect.stories.ts +8 -0
- package/src/types/Styles.ts +26 -8
- package/src/utilities/storybook.ts +25 -0
- package/src/utilities/validation.ts +3 -3
- package/tests/utilities-format.spec.ts +2 -2
- package/tests/utilities-storybook.spec.ts +99 -0
- package/dist/css/animation.css +0 -14
- package/src/assets/css/animation.css +0 -14
|
@@ -5,6 +5,8 @@ import { formatKebabCase } from '@/utilities/format';
|
|
|
5
5
|
|
|
6
6
|
import type { ArgTypes, StoryContext } from '@storybook/vue3';
|
|
7
7
|
|
|
8
|
+
type KeyString = { [key: string]: string };
|
|
9
|
+
|
|
8
10
|
// Extensible object of key/value pairs
|
|
9
11
|
type KeyValue = { [key: string]: any };
|
|
10
12
|
|
|
@@ -13,6 +15,10 @@ type KeyValueNamed = {
|
|
|
13
15
|
[key: string]: KeyValue;
|
|
14
16
|
};
|
|
15
17
|
|
|
18
|
+
type Nested = {
|
|
19
|
+
[key: string]: string | Nested;
|
|
20
|
+
};
|
|
21
|
+
|
|
16
22
|
export const lineBreak = '\r';
|
|
17
23
|
export const tab = ' ';
|
|
18
24
|
|
|
@@ -89,6 +95,25 @@ export const doSomething = () => {
|
|
|
89
95
|
alert('Did something.');
|
|
90
96
|
};
|
|
91
97
|
|
|
98
|
+
// Flatten a nested constant into a simple constant.
|
|
99
|
+
export const flatten = (input: Nested): KeyString => {
|
|
100
|
+
const output: KeyString = {};
|
|
101
|
+
|
|
102
|
+
Object.entries(input).forEach(([key, value]) => {
|
|
103
|
+
if (typeof value === 'string') {
|
|
104
|
+
output[key] = value;
|
|
105
|
+
} else {
|
|
106
|
+
const flattened = flatten(value);
|
|
107
|
+
|
|
108
|
+
Object.entries(flattened).forEach(([key2, value2]) => {
|
|
109
|
+
output[`${key}.${key2}`] = value2;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return output;
|
|
115
|
+
};
|
|
116
|
+
|
|
92
117
|
// Accept a KeyValue as the value of an object with a retrievable key as a Storybook argType.
|
|
93
118
|
export const formatArgType = (collection: KeyValueNamed) => {
|
|
94
119
|
const constant = getKey(collection);
|
|
@@ -114,14 +114,14 @@ export const handleFieldValidation = ({
|
|
|
114
114
|
minlength?: number;
|
|
115
115
|
required?: boolean;
|
|
116
116
|
validators?: Validator[];
|
|
117
|
-
value
|
|
117
|
+
value?: Ref<string | undefined>;
|
|
118
118
|
}) => {
|
|
119
119
|
// error in props takes precedence over validation error
|
|
120
120
|
|
|
121
121
|
error.value = errorFromProps ? errorFromProps : false;
|
|
122
122
|
|
|
123
123
|
if (!error.value && validators) {
|
|
124
|
-
const validation = validateProperty(value
|
|
124
|
+
const validation = validateProperty(value?.value || '', validators);
|
|
125
125
|
|
|
126
126
|
if (!validation.valid) {
|
|
127
127
|
error.value = validation.message;
|
|
@@ -133,7 +133,7 @@ export const handleFieldValidation = ({
|
|
|
133
133
|
maxlength,
|
|
134
134
|
minlength,
|
|
135
135
|
required,
|
|
136
|
-
value: value
|
|
136
|
+
value: value?.value || '',
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
if (!lengthValidation.valid) {
|
package/package.json
CHANGED
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"build-vite": "vite build && cp -r src/assets/css/ dist/css/ && cp -r src/utilities/ dist/utilities/",
|
|
49
49
|
"coverage": "vitest run --coverage",
|
|
50
50
|
"dev": "vite",
|
|
51
|
-
"enforce": "npm run lint && npm run type-check",
|
|
51
|
+
"enforce": "npm run lint && npm run type-check && npm run test",
|
|
52
52
|
"lint": "eslint . --ext .js,.ts,.vue --ignore-path .gitignore",
|
|
53
53
|
"lint:fix": "eslint . --ext .js,.ts,.vue --ignore-path .gitignore --fix",
|
|
54
|
-
"precommit": "npm run lint:fix && npm run type-check",
|
|
54
|
+
"precommit": "npm run lint:fix && npm run type-check && npm run test",
|
|
55
55
|
"preview": "npm run build-storybook && npx http-server -a localhost storybook-static/",
|
|
56
56
|
"storybook": "storybook dev -p 6006",
|
|
57
57
|
"test": "vitest run",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"main": "dist/tide-design-system.cjs",
|
|
62
62
|
"module": "dist/tide-design-system.esm.js",
|
|
63
63
|
"types": "dist/tide-design-system.esm.d.ts",
|
|
64
|
-
"version": "2.1.
|
|
64
|
+
"version": "2.1.6"
|
|
65
65
|
}
|
|
@@ -9,16 +9,6 @@
|
|
|
9
9
|
.tide-bg-surface-gradient {background: var(--tide-surface-gradient);}
|
|
10
10
|
.tide-bg-surface-floating {background: var(--tide-surface-floating);}
|
|
11
11
|
|
|
12
|
-
.tide-bg-surface-error {background-color: var(--tide-error-surface);}
|
|
13
|
-
.tide-bg-surface-info {background-color: var(--tide-info-surface);}
|
|
14
|
-
.tide-bg-surface-success {background-color: var(--tide-success-surface);}
|
|
15
|
-
.tide-bg-surface-warning {background-color: var(--tide-warning-surface);}
|
|
16
|
-
|
|
17
|
-
.tide-bg-error {background-color: var(--tide-error-primary);}
|
|
18
|
-
.tide-bg-info {background-color: var(--tide-info-primary);}
|
|
19
|
-
.tide-bg-success {background-color: var(--tide-success-primary);}
|
|
20
|
-
.tide-bg-warning {background-color: var(--tide-warning-primary);}
|
|
21
|
-
|
|
22
12
|
/* Border */
|
|
23
13
|
.tide-border-primary {border-color: var(--tide-primary);}
|
|
24
14
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* latin */
|
|
2
|
+
@font-face {
|
|
3
|
+
font-family: 'Montserrat';
|
|
4
|
+
font-style: normal;
|
|
5
|
+
font-weight: 400;
|
|
6
|
+
font-display: block;
|
|
7
|
+
src: url(https://fonts.gstatic.com/s/montserrat/v25/JTUSjIg1_i6t8kCHKm459Wlhyw.woff2) format('woff2');
|
|
8
|
+
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
|
9
|
+
}
|
|
10
|
+
/* latin */
|
|
11
|
+
@font-face {
|
|
12
|
+
font-family: 'Montserrat';
|
|
13
|
+
font-style: normal;
|
|
14
|
+
font-weight: 500;
|
|
15
|
+
font-display: block;
|
|
16
|
+
src: url(https://fonts.gstatic.com/s/montserrat/v25/JTUSjIg1_i6t8kCHKm459Wlhyw.woff2) format('woff2');
|
|
17
|
+
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
|
18
|
+
}
|
|
19
|
+
/* latin */
|
|
20
|
+
@font-face {
|
|
21
|
+
font-family: 'Montserrat';
|
|
22
|
+
font-style: normal;
|
|
23
|
+
font-weight: 600;
|
|
24
|
+
font-display: block;
|
|
25
|
+
src: url(https://fonts.gstatic.com/s/montserrat/v25/JTUSjIg1_i6t8kCHKm459Wlhyw.woff2) format('woff2');
|
|
26
|
+
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
|
27
|
+
}
|
|
28
|
+
/* latin */
|
|
29
|
+
@font-face {
|
|
30
|
+
font-family: 'Montserrat';
|
|
31
|
+
font-style: normal;
|
|
32
|
+
font-weight: 700;
|
|
33
|
+
font-display: block;
|
|
34
|
+
src: url(https://fonts.gstatic.com/s/montserrat/v25/JTUSjIg1_i6t8kCHKm459Wlhyw.woff2) format('woff2');
|
|
35
|
+
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
|
36
|
+
}
|
package/src/assets/css/main.css
CHANGED
|
@@ -117,9 +117,15 @@
|
|
|
117
117
|
.tide-margin-left-4 {margin-left: var(--tide-spacing-4);}
|
|
118
118
|
.tide-margin-left-auto {margin-left: auto;}
|
|
119
119
|
|
|
120
|
-
/* Border */
|
|
120
|
+
/* Border Color */
|
|
121
121
|
.tide-border-color-initial {border-color: initial;}
|
|
122
122
|
|
|
123
|
+
.tide-border-error {border-color: var(--tide-error-border);}
|
|
124
|
+
.tide-border-info {border-color: var(--tide-info-border);}
|
|
125
|
+
.tide-border-success {border-color: var(--tide-success-border);}
|
|
126
|
+
.tide-border-warning {border-color: var(--tide-warning-border);}
|
|
127
|
+
|
|
128
|
+
/* Border Width */
|
|
123
129
|
.tide-border-1,
|
|
124
130
|
.tide-border-2,
|
|
125
131
|
.tide-border-bottom-1,
|
|
@@ -225,9 +231,19 @@
|
|
|
225
231
|
.tide-height-0 {height: 0;}
|
|
226
232
|
.tide-height-full {height: 100%;}
|
|
227
233
|
|
|
228
|
-
/*
|
|
234
|
+
/* Background */
|
|
229
235
|
.tide-bg-initial {background-color: initial;}
|
|
230
236
|
|
|
237
|
+
.tide-bg-primary-error {background-color: var(--tide-error-primary);}
|
|
238
|
+
.tide-bg-primary-info {background-color: var(--tide-info-primary);}
|
|
239
|
+
.tide-bg-primary-success {background-color: var(--tide-success-primary);}
|
|
240
|
+
.tide-bg-primary-warning {background-color: var(--tide-warning-primary);}
|
|
241
|
+
|
|
242
|
+
.tide-bg-surface-error {background-color: var(--tide-error-surface);}
|
|
243
|
+
.tide-bg-surface-info {background-color: var(--tide-info-surface);}
|
|
244
|
+
.tide-bg-surface-success {background-color: var(--tide-success-surface);}
|
|
245
|
+
.tide-bg-surface-warning {background-color: var(--tide-warning-surface);}
|
|
246
|
+
|
|
231
247
|
.tide-transparent-100 {background-color: var(--tide-transparent-100);}
|
|
232
248
|
.tide-transparent-200 {background-color: var(--tide-transparent-200);}
|
|
233
249
|
.tide-transparent-300 {background-color: var(--tide-transparent-300);}
|
|
@@ -253,6 +269,12 @@
|
|
|
253
269
|
.tide-typography-button-1 {font-size: var(--tide-font-16); font-weight: 600;}
|
|
254
270
|
.tide-typography-button-2 {font-size: var(--tide-font-14); font-weight: 600;}
|
|
255
271
|
|
|
272
|
+
/* Font Color */
|
|
273
|
+
.tide-font-error {color: var(--tide-error-primary);}
|
|
274
|
+
.tide-font-info {color: var(--tide-info-primary);}
|
|
275
|
+
.tide-font-success {color: var(--tide-success-primary);}
|
|
276
|
+
.tide-font-warning {color: var(--tide-warning-primary);}
|
|
277
|
+
|
|
256
278
|
/* Font Size */
|
|
257
279
|
.tide-font-10 {font-size: var(--tide-font-10);}
|
|
258
280
|
.tide-font-12 {font-size: var(--tide-font-12);}
|
|
@@ -485,7 +507,7 @@
|
|
|
485
507
|
|
|
486
508
|
/* Border */
|
|
487
509
|
.sm-tide-border-color-initial {border-color: initial;}
|
|
488
|
-
|
|
510
|
+
|
|
489
511
|
.sm-tide-border-1,
|
|
490
512
|
.sm-tide-border-2,
|
|
491
513
|
.sm-tide-border-bottom-1,
|
|
@@ -852,7 +874,7 @@
|
|
|
852
874
|
|
|
853
875
|
/* Border */
|
|
854
876
|
.md-tide-border-color-initial {border-color: initial;}
|
|
855
|
-
|
|
877
|
+
|
|
856
878
|
.md-tide-border-1,
|
|
857
879
|
.md-tide-border-2,
|
|
858
880
|
.md-tide-border-bottom-1,
|
|
@@ -1219,7 +1241,7 @@
|
|
|
1219
1241
|
|
|
1220
1242
|
/* Border */
|
|
1221
1243
|
.lg-tide-border-color-initial {border-color: initial;}
|
|
1222
|
-
|
|
1244
|
+
|
|
1223
1245
|
.lg-tide-border-1,
|
|
1224
1246
|
.lg-tide-border-2,
|
|
1225
1247
|
.lg-tide-border-bottom-1,
|
|
@@ -1586,7 +1608,7 @@
|
|
|
1586
1608
|
|
|
1587
1609
|
/* Border */
|
|
1588
1610
|
.xl-tide-border-color-initial {border-color: initial;}
|
|
1589
|
-
|
|
1611
|
+
|
|
1590
1612
|
.xl-tide-border-1,
|
|
1591
1613
|
.xl-tide-border-2,
|
|
1592
1614
|
.xl-tide-border-bottom-1,
|
|
@@ -85,31 +85,21 @@
|
|
|
85
85
|
--tide-yellow-400: #FACA33;
|
|
86
86
|
|
|
87
87
|
/* Global color roles */
|
|
88
|
-
--tide-error-primary:
|
|
89
|
-
--tide-error-
|
|
90
|
-
--tide-error-
|
|
88
|
+
--tide-error-primary: var(--tide-red-400);
|
|
89
|
+
--tide-error-surface: var(--tide-red-100);
|
|
90
|
+
--tide-error-border: var(--tide-red-400);
|
|
91
91
|
|
|
92
|
-
--tide-
|
|
93
|
-
--tide-
|
|
94
|
-
--tide-
|
|
92
|
+
--tide-info-primary: var(--tide-blue-400);
|
|
93
|
+
--tide-info-surface: var(--tide-blue-100);
|
|
94
|
+
--tide-info-border: var(--tide-blue-400);
|
|
95
95
|
|
|
96
|
-
--tide-
|
|
97
|
-
--tide-
|
|
96
|
+
--tide-success-primary: var(--tide-green-400);
|
|
97
|
+
--tide-success-surface: var(--tide-green-100);
|
|
98
|
+
--tide-success-border: var(--tide-green-400);
|
|
98
99
|
|
|
99
|
-
--tide-
|
|
100
|
-
--tide-
|
|
101
|
-
--tide-
|
|
102
|
-
--tide-info-border: var(--tide-blue-200);
|
|
103
|
-
|
|
104
|
-
--tide-success-primary: var(--tide-green-400);
|
|
105
|
-
--tide-success-primary-border: var(--tide-green-300);
|
|
106
|
-
--tide-success-surface: var(--tide-green-100);
|
|
107
|
-
--tide-success-border: var(--tide-green-200);
|
|
108
|
-
|
|
109
|
-
--tide-warning-primary: var(--tide-yellow-400);
|
|
110
|
-
--tide-warning-primary-border: var(--tide-yellow-300);
|
|
111
|
-
--tide-warning-surface: var(--tide-yellow-100);
|
|
112
|
-
--tide-warning-border: var(--tide-yellow-200);
|
|
100
|
+
--tide-warning-primary: var(--tide-yellow-400);
|
|
101
|
+
--tide-warning-surface: var(--tide-yellow-100);
|
|
102
|
+
--tide-warning-border: var(--tide-yellow-400);
|
|
113
103
|
|
|
114
104
|
/* Global color roles (defined in realm tonal palettes in Figma) */
|
|
115
105
|
--tide-secondary: var(--tide-gray-900);
|
|
@@ -118,7 +108,7 @@
|
|
|
118
108
|
--tide-surface: var(--tide-gray-100);
|
|
119
109
|
--tide-surface-variant: var(--tide-gray-200);
|
|
120
110
|
--tide-surface-floating: var(--tide-transparent-100);
|
|
121
|
-
|
|
111
|
+
|
|
122
112
|
--tide-on-surface: var(--tide-gray-900);
|
|
123
113
|
--tide-on-surface-variant: var(--tide-gray-700);
|
|
124
114
|
--tide-on-surface-inverse: var(--tide-gray-100);
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
CSS.AXIS2.CENTER,
|
|
56
56
|
CSS.BORDER.RADIUS.HALF,
|
|
57
57
|
CSS.PADDING.FULL.ONE,
|
|
58
|
-
props.type === ALERT.ERROR && CSS.BG.SURFACE.ERROR,
|
|
59
|
-
props.type === ALERT.INFO && CSS.BG.SURFACE.INFO,
|
|
60
|
-
props.type === ALERT.SUCCESS && CSS.BG.SURFACE.SUCCESS,
|
|
61
|
-
props.type === ALERT.WARNING && CSS.BG.SURFACE.WARNING,
|
|
58
|
+
props.type === ALERT.ERROR && CSS.BG.GLOBAL.SURFACE.ERROR,
|
|
59
|
+
props.type === ALERT.INFO && CSS.BG.GLOBAL.SURFACE.INFO,
|
|
60
|
+
props.type === ALERT.SUCCESS && CSS.BG.GLOBAL.SURFACE.SUCCESS,
|
|
61
|
+
props.type === ALERT.WARNING && CSS.BG.GLOBAL.SURFACE.WARNING,
|
|
62
62
|
props.isToast ? CSS.SHADOW.BOTTOM : '',
|
|
63
63
|
]"
|
|
64
64
|
>
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
CSS.PADDING.FULL.HALF,
|
|
69
69
|
CSS.BORDER.RADIUS.FULL,
|
|
70
70
|
CSS.FONT.COLOR.SURFACE.INVERSE,
|
|
71
|
-
props.type === ALERT.ERROR && CSS.BG.ERROR,
|
|
72
|
-
props.type === ALERT.INFO && CSS.BG.INFO,
|
|
73
|
-
props.type === ALERT.SUCCESS && CSS.BG.SUCCESS,
|
|
74
|
-
props.type === ALERT.WARNING && CSS.BG.WARNING,
|
|
71
|
+
props.type === ALERT.ERROR && CSS.BG.GLOBAL.PRIMARY.ERROR,
|
|
72
|
+
props.type === ALERT.INFO && CSS.BG.GLOBAL.PRIMARY.INFO,
|
|
73
|
+
props.type === ALERT.SUCCESS && CSS.BG.GLOBAL.PRIMARY.SUCCESS,
|
|
74
|
+
props.type === ALERT.WARNING && CSS.BG.GLOBAL.PRIMARY.WARNING,
|
|
75
75
|
]"
|
|
76
76
|
>
|
|
77
77
|
<TideIcon :icon="icon" />
|
|
@@ -23,26 +23,27 @@
|
|
|
23
23
|
width: undefined,
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const picture = ref();
|
|
27
|
+
const img = ref();
|
|
28
|
+
|
|
27
29
|
const imageDefault = 'https://cdn-static-rec.tilabs.io/image-coming-soon-512.png';
|
|
28
30
|
|
|
29
31
|
const setImageFromDefault = () => {
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
+
const currentSrc = img.value?.currentSrc;
|
|
33
|
+
const pictureSource = picture.value?.querySelector(`source[srcset="${currentSrc}"]`);
|
|
32
34
|
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
} else {
|
|
36
|
-
|
|
35
|
+
if (currentSrc && pictureSource) {
|
|
36
|
+
pictureSource.srcset = imageDefault;
|
|
37
|
+
} else if (img.value) {
|
|
38
|
+
img.value.src = imageDefault;
|
|
37
39
|
}
|
|
38
40
|
};
|
|
39
|
-
|
|
40
|
-
defineExpose(tideImage.value);
|
|
41
41
|
</script>
|
|
42
42
|
|
|
43
43
|
<template>
|
|
44
44
|
<picture
|
|
45
45
|
:class="['tide-image', CSS.DISPLAY.BLOCK]"
|
|
46
|
+
ref="picture"
|
|
46
47
|
:style="
|
|
47
48
|
width || height
|
|
48
49
|
? {
|
|
@@ -64,11 +65,9 @@
|
|
|
64
65
|
:class="[CSS.WIDTH.FULL, CSS.HEIGHT.FULL, CSS.OBJECT.CENTER, CSS.OBJECT.COVER]"
|
|
65
66
|
:fetchpriority="isLazy ? undefined : 'high'"
|
|
66
67
|
:loading="props.isLazy ? 'lazy' : 'eager'"
|
|
67
|
-
ref="
|
|
68
|
+
ref="img"
|
|
68
69
|
:src="src ?? imageDefault"
|
|
69
70
|
@error="setImageFromDefault"
|
|
70
71
|
/>
|
|
71
72
|
</picture>
|
|
72
73
|
</template>
|
|
73
|
-
|
|
74
|
-
<style scoped></style>
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
CSS.AXIS2.CENTER,
|
|
82
82
|
CSS.GAP.HALF,
|
|
83
83
|
CSS.BORDER.RADIUS.HALF,
|
|
84
|
+
CSS.BG.SURFACE.DEFAULT,
|
|
84
85
|
props.disabled ? CSS.CURSOR.NOT_ALLOWED : '',
|
|
85
86
|
CSS.OVERFLOW.XY.HIDDEN,
|
|
86
87
|
]"
|
|
@@ -96,6 +97,7 @@
|
|
|
96
97
|
CSS.MARGIN.LEFT.ONE,
|
|
97
98
|
!hasError && CSS.FONT.COLOR.SURFACE.VARIANT,
|
|
98
99
|
CSS.FONT.WEIGHT.FIVE_HUNDRED,
|
|
100
|
+
CSS.POINTER_EVENTS.OFF,
|
|
99
101
|
]"
|
|
100
102
|
:for="props.inputId"
|
|
101
103
|
v-if="label"
|
|
@@ -218,7 +220,7 @@
|
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
.tide-input-select.error {
|
|
221
|
-
color: var(--tide-error-
|
|
223
|
+
color: var(--tide-error-primary);
|
|
222
224
|
}
|
|
223
225
|
|
|
224
226
|
.tide-input-select.error option {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
transformValue: undefined,
|
|
54
54
|
type: TEXT_INPUT_TYPE.TEXT,
|
|
55
55
|
validators: undefined,
|
|
56
|
-
value:
|
|
56
|
+
value: undefined,
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
const error = ref(props.error);
|
|
@@ -65,9 +65,11 @@
|
|
|
65
65
|
const errorMessage = computed(() => getErrorMessage(props.error, error.value));
|
|
66
66
|
const formattedLabel = computed(() => (props.required && props.label ? `${props.label} *` : props.label));
|
|
67
67
|
const hasClear = computed(() => props.hasClear && value.value);
|
|
68
|
-
const hasError = computed(
|
|
68
|
+
const hasError = computed(
|
|
69
|
+
() => (props.required && value.value !== undefined && !value.value) || getFieldHasError(error.value, props.error)
|
|
70
|
+
);
|
|
69
71
|
const hasMinilabel = computed(() => hasFocus.value || !isEmpty.value);
|
|
70
|
-
const isEmpty = computed(() => value.value === '');
|
|
72
|
+
const isEmpty = computed(() => value.value === '' || value.value === undefined);
|
|
71
73
|
const type = computed(() =>
|
|
72
74
|
props.type === TEXT_INPUT_TYPE.PASSWORD && showPassword.value === true ? TEXT_INPUT_TYPE.TEXT : props.type
|
|
73
75
|
);
|
|
@@ -83,12 +85,17 @@
|
|
|
83
85
|
|
|
84
86
|
const handleFocusOut = () => {
|
|
85
87
|
hasFocus.value = false;
|
|
88
|
+
|
|
89
|
+
if (!value.value) {
|
|
90
|
+
value.value = '';
|
|
91
|
+
}
|
|
92
|
+
|
|
86
93
|
handleValidation();
|
|
87
94
|
};
|
|
88
95
|
|
|
89
96
|
const handleInput = () => {
|
|
90
97
|
if (props.transformValue) {
|
|
91
|
-
const digits = value.value
|
|
98
|
+
const digits = value.value?.match(/\d/g)?.join('') || undefined;
|
|
92
99
|
|
|
93
100
|
value.value = digits ? props.transformValue(digits) : '';
|
|
94
101
|
}
|
|
@@ -141,6 +148,7 @@
|
|
|
141
148
|
CSS.GAP.HALF,
|
|
142
149
|
CSS.POSITION.RELATIVE,
|
|
143
150
|
CSS.BORDER.RADIUS.HALF,
|
|
151
|
+
CSS.BG.SURFACE.DEFAULT,
|
|
144
152
|
hasClear ? [CSS.PADDING.RIGHT.HALF, CSS.PADDING.LEFT.ONE] : [CSS.PADDING.X.ONE],
|
|
145
153
|
CSS.PADDING.Y.HALF,
|
|
146
154
|
props.disabled ? CSS.CURSOR.NOT_ALLOWED : CSS.CURSOR.TEXT,
|
|
@@ -170,6 +178,7 @@
|
|
|
170
178
|
!hasError && CSS.FONT.COLOR.SURFACE.VARIANT,
|
|
171
179
|
CSS.FONT.WEIGHT.FIVE_HUNDRED,
|
|
172
180
|
CSS.CURSOR.TEXT,
|
|
181
|
+
CSS.POINTER_EVENTS.OFF,
|
|
173
182
|
]"
|
|
174
183
|
:for="props.inputId"
|
|
175
184
|
v-if="label"
|
|
@@ -262,7 +271,7 @@
|
|
|
262
271
|
}
|
|
263
272
|
|
|
264
273
|
.tide-input-text.error {
|
|
265
|
-
color: var(--tide-error-
|
|
274
|
+
color: var(--tide-error-primary);
|
|
266
275
|
}
|
|
267
276
|
|
|
268
277
|
.tide-input-text.error .tide-input-border {
|
|
@@ -91,6 +91,7 @@
|
|
|
91
91
|
CSS.PADDING.LEFT.ONE,
|
|
92
92
|
CSS.PADDING.TOP.HALF,
|
|
93
93
|
CSS.OVERFLOW.XY.HIDDEN,
|
|
94
|
+
CSS.BG.SURFACE.DEFAULT,
|
|
94
95
|
]"
|
|
95
96
|
>
|
|
96
97
|
<label
|
|
@@ -99,6 +100,7 @@
|
|
|
99
100
|
!hasError && CSS.FONT.COLOR.SURFACE.VARIANT,
|
|
100
101
|
CSS.FONT.WEIGHT.FIVE_HUNDRED,
|
|
101
102
|
CSS.CURSOR.TEXT,
|
|
103
|
+
CSS.POINTER_EVENTS.OFF,
|
|
102
104
|
]"
|
|
103
105
|
:for="props.inputId"
|
|
104
106
|
ref="label"
|
|
@@ -165,7 +167,7 @@
|
|
|
165
167
|
}
|
|
166
168
|
|
|
167
169
|
.tide-input-textarea.error {
|
|
168
|
-
color: var(--tide-error-
|
|
170
|
+
color: var(--tide-error-primary);
|
|
169
171
|
}
|
|
170
172
|
|
|
171
173
|
.tide-input-textarea.error .tide-input-textarea-field {
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { CSS } from '@/types/Styles';
|
|
2
|
+
import { flatten, formatArgType, getConstantsByValues, prependNoneAsEmpty } from '@/utilities/storybook';
|
|
3
|
+
|
|
4
|
+
import type { StoryContext } from '@storybook/vue3';
|
|
5
|
+
|
|
6
|
+
const COLOR_BACKGROUND = prependNoneAsEmpty(flatten(CSS.BG));
|
|
7
|
+
const COLOR_BORDER = prependNoneAsEmpty(flatten(CSS.BORDER.COLOR));
|
|
8
|
+
const COLOR_FONT = prependNoneAsEmpty(flatten(CSS.FONT.COLOR));
|
|
9
|
+
|
|
10
|
+
const formatArgs = (args: any) => {
|
|
11
|
+
args.class = formatClassNames(args).join(' ');
|
|
12
|
+
|
|
13
|
+
return { args };
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const formatClassNames = (args: any) => {
|
|
17
|
+
const classNames = [];
|
|
18
|
+
|
|
19
|
+
if (args.backgroundColor) classNames.push(args.backgroundColor);
|
|
20
|
+
if (args.borderColor) classNames.push(...['tide-border-1', args.borderColor]);
|
|
21
|
+
if (args.fontColor) classNames.push(args.fontColor);
|
|
22
|
+
|
|
23
|
+
return classNames;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const formatClassNamesSnippet = (args: any) => {
|
|
27
|
+
const classNames = formatClassNames(args);
|
|
28
|
+
|
|
29
|
+
return getConstantsByValues(classNames);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const formatSnippet = (code: string, context: StoryContext) => {
|
|
33
|
+
const { args } = context;
|
|
34
|
+
const classNames = formatClassNamesSnippet(args);
|
|
35
|
+
|
|
36
|
+
return classNames.length ? `<div :class="[${classNames.join(', ')}]">Demo</div>` : '<div>Demo</div>';
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const parameters = {
|
|
40
|
+
docs: {
|
|
41
|
+
source: {
|
|
42
|
+
format: false,
|
|
43
|
+
language: 'html',
|
|
44
|
+
transform: formatSnippet,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const render = (args: any) => ({
|
|
50
|
+
setup() {
|
|
51
|
+
return formatArgs(args);
|
|
52
|
+
},
|
|
53
|
+
template: '<div class="tide-display-inline-block tide-padding-1" v-bind="args">Demo</div>',
|
|
54
|
+
updated() {
|
|
55
|
+
return formatArgs(args);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export default {
|
|
60
|
+
argTypes: {
|
|
61
|
+
backgroundColor: {
|
|
62
|
+
...formatArgType({ COLOR_BACKGROUND }),
|
|
63
|
+
description: 'Applies a background color',
|
|
64
|
+
name: 'Background Color',
|
|
65
|
+
table: {
|
|
66
|
+
defaultValue: { summary: 'None' },
|
|
67
|
+
type: { summary: 'CSS.BG' },
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
borderColor: {
|
|
71
|
+
...formatArgType({ COLOR_BORDER }),
|
|
72
|
+
description: 'Applies a border color',
|
|
73
|
+
name: 'Border Color',
|
|
74
|
+
table: {
|
|
75
|
+
defaultValue: { summary: 'None' },
|
|
76
|
+
type: { summary: 'CSS.BORDER.COLOR' },
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
fontColor: {
|
|
80
|
+
...formatArgType({ COLOR_FONT }),
|
|
81
|
+
description: 'Applies a font color',
|
|
82
|
+
name: 'Font Color',
|
|
83
|
+
table: {
|
|
84
|
+
defaultValue: { summary: 'None' },
|
|
85
|
+
type: { summary: 'CSS.FONT.COLOR' },
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
args: {
|
|
90
|
+
backgroundColor: COLOR_BACKGROUND.None,
|
|
91
|
+
borderColor: COLOR_BORDER.None,
|
|
92
|
+
fontColor: COLOR_FONT.None,
|
|
93
|
+
},
|
|
94
|
+
parameters,
|
|
95
|
+
render,
|
|
96
|
+
tags: ['autodocs'],
|
|
97
|
+
title: 'Foundations/Color',
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const Default = {};
|
|
101
|
+
|
|
102
|
+
export const SurfaceAccent = {
|
|
103
|
+
args: {
|
|
104
|
+
backgroundColor: COLOR_BACKGROUND['SURFACE.ACCENT'],
|
|
105
|
+
fontColor: COLOR_FONT['SURFACE.DEFAULT'],
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const SurfaceBrand = {
|
|
110
|
+
args: {
|
|
111
|
+
backgroundColor: COLOR_BACKGROUND['SURFACE.BRAND'],
|
|
112
|
+
fontColor: COLOR_FONT['SURFACE.INVERSE'],
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const SurfaceGradient = {
|
|
117
|
+
args: {
|
|
118
|
+
backgroundColor: COLOR_BACKGROUND['SURFACE.GRADIENT'],
|
|
119
|
+
fontColor: COLOR_FONT['SURFACE.DEFAULT'],
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const SurfaceVariant = {
|
|
124
|
+
args: {
|
|
125
|
+
backgroundColor: COLOR_BACKGROUND['SURFACE.VARIANT'],
|
|
126
|
+
fontColor: COLOR_FONT['SURFACE.DEFAULT'],
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const GlobalSurfaceError = {
|
|
131
|
+
args: {
|
|
132
|
+
backgroundColor: COLOR_BACKGROUND['GLOBAL.SURFACE.ERROR'],
|
|
133
|
+
fontColor: COLOR_FONT['SURFACE.DEFAULT'],
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const GlobalSurfaceInfo = {
|
|
138
|
+
args: {
|
|
139
|
+
backgroundColor: COLOR_BACKGROUND['GLOBAL.SURFACE.INFO'],
|
|
140
|
+
fontColor: COLOR_FONT['SURFACE.DEFAULT'],
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export const GlobalSurfaceSuccess = {
|
|
145
|
+
args: {
|
|
146
|
+
backgroundColor: COLOR_BACKGROUND['GLOBAL.SURFACE.SUCCESS'],
|
|
147
|
+
fontColor: COLOR_FONT['SURFACE.DEFAULT'],
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const GlobalSurfaceWarning = {
|
|
152
|
+
args: {
|
|
153
|
+
backgroundColor: COLOR_BACKGROUND['GLOBAL.SURFACE.WARNING'],
|
|
154
|
+
fontColor: COLOR_FONT['SURFACE.DEFAULT'],
|
|
155
|
+
},
|
|
156
|
+
};
|
|
@@ -135,6 +135,14 @@ export default {
|
|
|
135
135
|
type: { summary: 'string' },
|
|
136
136
|
},
|
|
137
137
|
},
|
|
138
|
+
name: {
|
|
139
|
+
control: 'text',
|
|
140
|
+
description: 'Name attribute',
|
|
141
|
+
table: {
|
|
142
|
+
defaultValue: { summary: 'None' },
|
|
143
|
+
type: { summary: 'string' },
|
|
144
|
+
},
|
|
145
|
+
},
|
|
138
146
|
optgroups: {
|
|
139
147
|
...formatArgType({ selectOptionGroups }),
|
|
140
148
|
control: 'object',
|