tide-design-system 2.0.30 → 2.0.32
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/style.css +1 -1
- package/dist/tide-design-system.cjs +2 -2
- package/dist/tide-design-system.esm.d.ts +100 -36
- package/dist/tide-design-system.esm.js +833 -740
- package/index.ts +6 -1
- package/package.json +1 -1
- package/src/components/TideInputSelect.vue +27 -15
- package/src/stories/TideInputSelect.stories.ts +28 -17
- package/src/types/FacetRange.ts +5 -5
- package/src/types/Field.ts +1 -1
- package/src/types/Form.ts +1 -1
- package/src/types/Select.ts +3 -3
package/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ import TideDivider from '@/components/TideDivider.vue';
|
|
|
18
18
|
import TideIcon from '@/components/TideIcon.vue';
|
|
19
19
|
import TideImage from '@/components/TideImage.vue';
|
|
20
20
|
import TideIndicator from '@/components/TideIndicator.vue';
|
|
21
|
+
import TideInputCheckbox from '@/components/TideInputCheckbox.vue';
|
|
21
22
|
import TideInputRadio from '@/components/TideInputRadio.vue';
|
|
22
23
|
import TideInputSelect from '@/components/TideInputSelect.vue';
|
|
23
24
|
import TideInputText from '@/components/TideInputText.vue';
|
|
@@ -168,6 +169,10 @@ export {
|
|
|
168
169
|
SIZE,
|
|
169
170
|
TARGET,
|
|
170
171
|
TEXT_INPUT_TYPE,
|
|
172
|
+
VALIDATOR,
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export {
|
|
171
176
|
TideAccordionItem,
|
|
172
177
|
TideAlert,
|
|
173
178
|
TideBackgroundImage,
|
|
@@ -188,6 +193,7 @@ export {
|
|
|
188
193
|
TideIcon,
|
|
189
194
|
TideImage,
|
|
190
195
|
TideIndicator,
|
|
196
|
+
TideInputCheckbox,
|
|
191
197
|
TideInputRadio,
|
|
192
198
|
TideInputSelect,
|
|
193
199
|
TideInputText,
|
|
@@ -198,5 +204,4 @@ export {
|
|
|
198
204
|
TideSeoLinks,
|
|
199
205
|
TideTabs,
|
|
200
206
|
TideToggle,
|
|
201
|
-
VALIDATOR,
|
|
202
207
|
};
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { getCurrentInstance, computed, ref, watch } from 'vue';
|
|
3
3
|
|
|
4
4
|
import type { SelectField } from '@/types/Field';
|
|
5
|
+
import type { SelectOption, SelectOptionGroup } from '@/types/Select';
|
|
5
6
|
|
|
6
7
|
import TideIcon from '@/components/TideIcon.vue';
|
|
7
8
|
import { CSS } from '@/types/Styles';
|
|
@@ -21,20 +22,20 @@
|
|
|
21
22
|
label: undefined,
|
|
22
23
|
required: false,
|
|
23
24
|
supportingText: undefined,
|
|
24
|
-
value:
|
|
25
|
+
value: undefined,
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
const error = ref(props.error);
|
|
28
29
|
const hasFocus = ref(false);
|
|
29
30
|
const input = ref<HTMLSelectElement | null>(null);
|
|
30
31
|
const required = ref(props.required);
|
|
31
|
-
const value = ref(props.value);
|
|
32
|
+
const value = ref<string | undefined>(props.value);
|
|
32
33
|
|
|
33
34
|
const errorMessage = computed(() => getErrorMessage(props.error, error.value));
|
|
34
35
|
const formattedLabel = computed(() => (props.required ? `${props.label} *` : props.label));
|
|
35
36
|
const hasError = computed(() => (props.required && !value.value) || getFieldHasError(error.value, props.error));
|
|
36
37
|
const hasMinilabel = computed(() => hasFocus.value || !isEmpty.value);
|
|
37
|
-
const isEmpty = computed(() => value.value ===
|
|
38
|
+
const isEmpty = computed(() => value.value === undefined);
|
|
38
39
|
|
|
39
40
|
const uniqueId = computed(() => (props.inputId ? props.inputId : `text-input-${getCurrentInstance()?.uid || ''}`));
|
|
40
41
|
|
|
@@ -115,22 +116,33 @@
|
|
|
115
116
|
:id="uniqueId"
|
|
116
117
|
v-model="value"
|
|
117
118
|
>
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
<template v-for="optgroup in props.optgroups">
|
|
120
|
+
<optgroup
|
|
121
|
+
:class="[CSS.WIDTH.FULL, CSS.BG.SURFACE.DEFAULT]"
|
|
122
|
+
:key="(optgroup as SelectOptionGroup).label"
|
|
123
|
+
:label="(optgroup as SelectOptionGroup).label"
|
|
124
|
+
v-if="(optgroup as SelectOptionGroup).options"
|
|
125
|
+
>
|
|
126
|
+
<option
|
|
127
|
+
:class="[CSS.WIDTH.FULL, CSS.BG.SURFACE.DEFAULT]"
|
|
128
|
+
:key="option.value"
|
|
129
|
+
:value="option.value"
|
|
130
|
+
v-for="option in (optgroup as SelectOptionGroup).options"
|
|
131
|
+
>
|
|
132
|
+
{{ option.label }}
|
|
133
|
+
</option>
|
|
134
|
+
</optgroup>
|
|
135
|
+
|
|
125
136
|
<option
|
|
126
137
|
:class="[CSS.WIDTH.FULL, CSS.BG.SURFACE.DEFAULT]"
|
|
127
|
-
:key="
|
|
128
|
-
:
|
|
129
|
-
|
|
138
|
+
:key="(optgroup as SelectOption).value"
|
|
139
|
+
:selected="value === (optgroup as SelectOption).value ? true : undefined"
|
|
140
|
+
:value="(optgroup as SelectOption).value"
|
|
141
|
+
v-else
|
|
130
142
|
>
|
|
131
|
-
{{
|
|
143
|
+
{{ (optgroup as SelectOption).label }}
|
|
132
144
|
</option>
|
|
133
|
-
</
|
|
145
|
+
</template>
|
|
134
146
|
|
|
135
147
|
<option
|
|
136
148
|
:class="[CSS.WIDTH.FULL, CSS.BG.SURFACE.DEFAULT]"
|
|
@@ -14,26 +14,37 @@ import {
|
|
|
14
14
|
} from '@/utilities/storybook';
|
|
15
15
|
|
|
16
16
|
const options = {
|
|
17
|
+
'Any': '',
|
|
17
18
|
'Option 1': 1,
|
|
18
19
|
'Option 2': 2,
|
|
19
20
|
'Option 3': 3,
|
|
21
|
+
'Option A1': 'A1',
|
|
22
|
+
'Option A2': 'A2',
|
|
23
|
+
'Option A3': 'A3',
|
|
24
|
+
'Option B1': 'B1',
|
|
25
|
+
'Option B2': 'B2',
|
|
26
|
+
'Option B3': 'B3',
|
|
20
27
|
};
|
|
21
28
|
|
|
22
|
-
const selectOptionGroups: SelectOptionGroup[] = [
|
|
29
|
+
const selectOptionGroups: (SelectOption | SelectOptionGroup)[] = [
|
|
30
|
+
{
|
|
31
|
+
label: 'Any',
|
|
32
|
+
value: '',
|
|
33
|
+
},
|
|
23
34
|
{
|
|
24
35
|
label: 'Group A',
|
|
25
36
|
options: [
|
|
26
37
|
{
|
|
27
|
-
label: 'Option
|
|
28
|
-
value:
|
|
38
|
+
label: 'Option A1',
|
|
39
|
+
value: 'A1',
|
|
29
40
|
},
|
|
30
41
|
{
|
|
31
|
-
label: 'Option
|
|
32
|
-
value:
|
|
42
|
+
label: 'Option A2',
|
|
43
|
+
value: 'A2',
|
|
33
44
|
},
|
|
34
45
|
{
|
|
35
|
-
label: 'Option
|
|
36
|
-
value:
|
|
46
|
+
label: 'Option A3',
|
|
47
|
+
value: 'A3',
|
|
37
48
|
},
|
|
38
49
|
],
|
|
39
50
|
},
|
|
@@ -41,16 +52,16 @@ const selectOptionGroups: SelectOptionGroup[] = [
|
|
|
41
52
|
label: 'Group B',
|
|
42
53
|
options: [
|
|
43
54
|
{
|
|
44
|
-
label: 'Option
|
|
45
|
-
value:
|
|
55
|
+
label: 'Option B1',
|
|
56
|
+
value: 'B1',
|
|
46
57
|
},
|
|
47
58
|
{
|
|
48
|
-
label: 'Option
|
|
49
|
-
value:
|
|
59
|
+
label: 'Option B2',
|
|
60
|
+
value: 'B2',
|
|
50
61
|
},
|
|
51
62
|
{
|
|
52
|
-
label: 'Option
|
|
53
|
-
value:
|
|
63
|
+
label: 'Option B3',
|
|
64
|
+
value: 'B3',
|
|
54
65
|
},
|
|
55
66
|
],
|
|
56
67
|
},
|
|
@@ -59,15 +70,15 @@ const selectOptionGroups: SelectOptionGroup[] = [
|
|
|
59
70
|
const selectOptions: SelectOption[] = [
|
|
60
71
|
{
|
|
61
72
|
label: 'Option 1',
|
|
62
|
-
value: 1,
|
|
73
|
+
value: '1',
|
|
63
74
|
},
|
|
64
75
|
{
|
|
65
76
|
label: 'Option 2',
|
|
66
|
-
value: 2,
|
|
77
|
+
value: '2',
|
|
67
78
|
},
|
|
68
79
|
{
|
|
69
80
|
label: 'Option 3',
|
|
70
|
-
value: 3,
|
|
81
|
+
value: '3',
|
|
71
82
|
},
|
|
72
83
|
];
|
|
73
84
|
|
|
@@ -76,7 +87,7 @@ const render = (args: any, { updateArgs }: any) => ({
|
|
|
76
87
|
methods: {
|
|
77
88
|
doSomething,
|
|
78
89
|
handleChange: (event: Event) => {
|
|
79
|
-
const value =
|
|
90
|
+
const value = (event?.target as HTMLSelectElement).value;
|
|
80
91
|
|
|
81
92
|
updateArgs({ ...args, value });
|
|
82
93
|
action('TideInputSelect changed')(event);
|
package/src/types/FacetRange.ts
CHANGED
|
@@ -22,7 +22,7 @@ const GROSS_WEIGHT_MAX = 12000;
|
|
|
22
22
|
export const GROSS_WEIGHT_OPTIONS: SelectOption[] = [
|
|
23
23
|
{
|
|
24
24
|
label: 'Any',
|
|
25
|
-
value:
|
|
25
|
+
value: undefined,
|
|
26
26
|
},
|
|
27
27
|
...Array.from({ length: Math.floor((GROSS_WEIGHT_MAX - GROSS_WEIGHT_MIN) / 1000) + 1 }, (_, index) => ({
|
|
28
28
|
label: (GROSS_WEIGHT_MAX - index * 1000).toString(),
|
|
@@ -35,7 +35,7 @@ const SLEEP_CAP_MAX = 10;
|
|
|
35
35
|
export const SLEEPING_CAPACITY_OPTIONS: SelectOption[] = [
|
|
36
36
|
{
|
|
37
37
|
label: 'Any',
|
|
38
|
-
value:
|
|
38
|
+
value: undefined,
|
|
39
39
|
},
|
|
40
40
|
...Array.from({ length: SLEEP_CAP_MAX - SLEEP_CAP_MIN + 1 }, (_, index) => ({
|
|
41
41
|
label: (SLEEP_CAP_MAX - index).toString(),
|
|
@@ -48,7 +48,7 @@ const SLIDEOUT_MAX = 5;
|
|
|
48
48
|
export const SLIDEOUT_OPTIONS: SelectOption[] = [
|
|
49
49
|
{
|
|
50
50
|
label: 'Any',
|
|
51
|
-
value:
|
|
51
|
+
value: undefined,
|
|
52
52
|
},
|
|
53
53
|
...Array.from({ length: SLIDEOUT_MAX - SLIDEOUT_MIN + 1 }, (_, index) => ({
|
|
54
54
|
label: (SLIDEOUT_MAX - index).toString(),
|
|
@@ -61,7 +61,7 @@ const LENGTH_MAX = 50;
|
|
|
61
61
|
export const LENGTH_OPTIONS: SelectOption[] = [
|
|
62
62
|
{
|
|
63
63
|
label: 'Any',
|
|
64
|
-
value:
|
|
64
|
+
value: undefined,
|
|
65
65
|
},
|
|
66
66
|
...Array.from({ length: LENGTH_MAX - LENGTH_MIN + 1 }, (_, index) => ({
|
|
67
67
|
label: (LENGTH_MAX - index).toString(),
|
|
@@ -75,7 +75,7 @@ const YEAR_MAX = today.getFullYear() + 2;
|
|
|
75
75
|
export const YEAR_OPTIONS: SelectOption[] = [
|
|
76
76
|
{
|
|
77
77
|
label: 'Any',
|
|
78
|
-
value:
|
|
78
|
+
value: undefined,
|
|
79
79
|
},
|
|
80
80
|
...Array.from({ length: YEAR_MAX - YEAR_MIN + 1 }, (_, index) => ({
|
|
81
81
|
label: (YEAR_MAX - index).toString(),
|
package/src/types/Field.ts
CHANGED
package/src/types/Form.ts
CHANGED
|
@@ -24,7 +24,7 @@ export type SelectInput = GenericInput &
|
|
|
24
24
|
StringValue & {
|
|
25
25
|
options?: SelectOption[] | readonly SelectOption[];
|
|
26
26
|
placeholder?: string;
|
|
27
|
-
optgroups?: SelectOptionGroup[];
|
|
27
|
+
optgroups?: (SelectOption | SelectOptionGroup)[];
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export type TextInput = GenericInput &
|
package/src/types/Select.ts
CHANGED