@carbon/vue 3.0.11 → 3.0.13
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/README.md +4 -4
- package/dist/carbon-vue-3.common.js +197 -99
- package/dist/carbon-vue-3.common.js.map +1 -1
- package/dist/carbon-vue-3.umd.js +197 -99
- package/dist/carbon-vue-3.umd.js.map +1 -1
- package/dist/carbon-vue-3.umd.min.js +2 -2
- package/dist/carbon-vue-3.umd.min.js.map +1 -1
- package/dist/web-types.json +5505 -0
- package/package.json +2 -2
- package/src/components/CvAccordion/CvAccordion.stories.mdx +153 -0
- package/src/components/CvAccordion/CvAccordion.vue +18 -5
- package/src/components/CvAccordion/CvAccordionItem.vue +18 -6
- package/src/components/CvAccordion/consts.js +8 -9
- package/src/components/CvCheckbox/CvCheckbox.vue +6 -2
- package/src/components/CvDataTable/CvDataTable.stories.mdx +39 -14
- package/src/components/CvDataTable/CvDataTableHeading.vue +3 -5
- package/src/components/CvDatePicker/CvDatePicker.stories.js +165 -14
- package/src/components/CvDatePicker/CvDatePicker.vue +31 -17
- package/src/components/CvModal/CvModal.vue +35 -13
- package/src/components/CvModal/index.js +29 -1
- package/src/components/CvMultiSelect/CvMultiSelect.vue +2 -2
- package/src/components/CvNotification/CvInlineNotification.stories.js +58 -1
- package/src/components/CvNotification/CvInlineNotification.vue +13 -3
- package/src/components/CvNotification/CvInlineNotificationTemplate.mdx +16 -0
- package/src/components/CvRadioButton/CvRadioButton.stories.js +20 -1
- package/src/components/CvRadioButton/CvRadioButton.vue +7 -5
- package/src/components/CvRadioButton/CvRadioGroup.vue +18 -2
- package/src/components/CvRadioButton/__tests__/__snapshots__/CvRadioButton.spec.js.snap +6 -4
- package/src/components/CvSearch/CvSearch.vue +1 -1
- package/src/components/CvTabs/CvTabs.vue +2 -2
- package/src/components/CvAccordion/CvAccordion.stories.js +0 -55
|
@@ -15,7 +15,9 @@ const initArgs = {
|
|
|
15
15
|
|
|
16
16
|
const now = new Date();
|
|
17
17
|
const tomorrow = new Date();
|
|
18
|
+
const nextWeek = new Date();
|
|
18
19
|
tomorrow.setDate(now.getDate() + 1);
|
|
20
|
+
nextWeek.setDate(now.getDate() + 7);
|
|
19
21
|
|
|
20
22
|
export default {
|
|
21
23
|
title: `${sbCompPrefix}/CvDatePicker`,
|
|
@@ -29,11 +31,12 @@ export default {
|
|
|
29
31
|
},
|
|
30
32
|
},
|
|
31
33
|
argTypes: {
|
|
32
|
-
|
|
33
|
-
invalidMessage: {
|
|
34
|
+
kind: {
|
|
34
35
|
type: String,
|
|
35
|
-
|
|
36
|
+
options: ['short', 'simple', 'single', 'range'],
|
|
37
|
+
control: { type: 'select' },
|
|
36
38
|
},
|
|
39
|
+
calOptions: { type: Object },
|
|
37
40
|
},
|
|
38
41
|
};
|
|
39
42
|
|
|
@@ -41,7 +44,7 @@ export default {
|
|
|
41
44
|
|
|
42
45
|
const template = `
|
|
43
46
|
<div>
|
|
44
|
-
<cv-date-picker v-bind=
|
|
47
|
+
<cv-date-picker v-bind="args" @change="onChange" :value="now">
|
|
45
48
|
</cv-date-picker>
|
|
46
49
|
</div>
|
|
47
50
|
`;
|
|
@@ -50,6 +53,7 @@ const Template = args => {
|
|
|
50
53
|
components: { CvDatePicker },
|
|
51
54
|
setup: () => ({
|
|
52
55
|
args,
|
|
56
|
+
now,
|
|
53
57
|
onChange: action('change'),
|
|
54
58
|
}),
|
|
55
59
|
template,
|
|
@@ -58,6 +62,11 @@ const Template = args => {
|
|
|
58
62
|
|
|
59
63
|
export const Default = Template.bind({});
|
|
60
64
|
Default.args = initArgs;
|
|
65
|
+
Default.parameters = {
|
|
66
|
+
controls: {
|
|
67
|
+
exclude: ['update:modelValue', 'invalid-message', 'modelValue'],
|
|
68
|
+
},
|
|
69
|
+
};
|
|
61
70
|
Default.parameters = storyParametersObject(
|
|
62
71
|
Default.parameters,
|
|
63
72
|
template,
|
|
@@ -66,13 +75,13 @@ Default.parameters = storyParametersObject(
|
|
|
66
75
|
|
|
67
76
|
/* V-MODEL STORY */
|
|
68
77
|
|
|
69
|
-
const modelValue = ref(
|
|
78
|
+
const modelValue = ref(now);
|
|
70
79
|
const templateVModel = `
|
|
71
80
|
<div>
|
|
72
|
-
<cv-date-picker v-bind=
|
|
81
|
+
<cv-date-picker v-bind="args" @change="onChange" v-model="modelValue">
|
|
73
82
|
</cv-date-picker>
|
|
74
83
|
</div>
|
|
75
|
-
<div style="margin:
|
|
84
|
+
<div style="margin-top:2rem; background-color: #888888; padding:1rem">
|
|
76
85
|
<div style="font-size: 150%;">Sample interaction</div>
|
|
77
86
|
<label for="date-model" style='margin-right: 0.5rem'>V-model:</label>
|
|
78
87
|
<input id="date-model" type="text" :value="modelValue.startDate || modelValue" @change="ev => { if (args.kind === 'range') { modelValue.startDate = ev.currentTarget.value } else { modelValue = ev.currentTarget.value } }"/>
|
|
@@ -95,6 +104,11 @@ const TemplateVModel = args => {
|
|
|
95
104
|
|
|
96
105
|
export const vModel = TemplateVModel.bind({});
|
|
97
106
|
vModel.args = initArgs;
|
|
107
|
+
vModel.parameters = {
|
|
108
|
+
controls: {
|
|
109
|
+
exclude: ['update:modelValue', 'invalid-message', 'modelValue'],
|
|
110
|
+
},
|
|
111
|
+
};
|
|
98
112
|
vModel.parameters = storyParametersObject(
|
|
99
113
|
vModel.parameters,
|
|
100
114
|
templateVModel,
|
|
@@ -105,7 +119,7 @@ vModel.parameters = storyParametersObject(
|
|
|
105
119
|
|
|
106
120
|
const templateInvalidMessage = `
|
|
107
121
|
<div>
|
|
108
|
-
<cv-date-picker v-bind=
|
|
122
|
+
<cv-date-picker v-bind="args" @change="onChange" :value="now">
|
|
109
123
|
</cv-date-picker>
|
|
110
124
|
</div>
|
|
111
125
|
`;
|
|
@@ -115,6 +129,7 @@ const TemplateInvalidMessage = args => {
|
|
|
115
129
|
components: { CvDatePicker },
|
|
116
130
|
setup: () => ({
|
|
117
131
|
args,
|
|
132
|
+
now,
|
|
118
133
|
onChange: action('change'),
|
|
119
134
|
}),
|
|
120
135
|
template: templateInvalidMessage,
|
|
@@ -123,12 +138,22 @@ const TemplateInvalidMessage = args => {
|
|
|
123
138
|
|
|
124
139
|
export const InvalidMessage = TemplateInvalidMessage.bind({});
|
|
125
140
|
InvalidMessage.args = { ...initArgs, invalidMessage: 'Invalid date' };
|
|
141
|
+
InvalidMessage.parameters = {
|
|
142
|
+
controls: {
|
|
143
|
+
include: ['invalidMessage'],
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
InvalidMessage.parameters = storyParametersObject(
|
|
147
|
+
InvalidMessage.parameters,
|
|
148
|
+
templateInvalidMessage,
|
|
149
|
+
InvalidMessage.args
|
|
150
|
+
);
|
|
126
151
|
|
|
127
152
|
/* INVALID MESSAGE SLOT STORY */
|
|
128
153
|
|
|
129
154
|
const templateInvalidMessageSlot = `
|
|
130
155
|
<div>
|
|
131
|
-
<cv-date-picker v-bind=
|
|
156
|
+
<cv-date-picker v-bind="args" @change="onChange" :value="now">
|
|
132
157
|
<template #invalid-message>Invalid date slot</template>
|
|
133
158
|
</cv-date-picker>
|
|
134
159
|
</div>
|
|
@@ -139,6 +164,7 @@ const TemplateInvalidMessageSlot = args => {
|
|
|
139
164
|
components: { CvDatePicker },
|
|
140
165
|
setup: () => ({
|
|
141
166
|
args,
|
|
167
|
+
now,
|
|
142
168
|
onChange: action('change'),
|
|
143
169
|
}),
|
|
144
170
|
template: templateInvalidMessageSlot,
|
|
@@ -147,13 +173,35 @@ const TemplateInvalidMessageSlot = args => {
|
|
|
147
173
|
|
|
148
174
|
export const InvalidMessageSlot = TemplateInvalidMessageSlot.bind({});
|
|
149
175
|
InvalidMessageSlot.args = initArgs;
|
|
176
|
+
InvalidMessageSlot.parameters = {
|
|
177
|
+
controls: {
|
|
178
|
+
include: [],
|
|
179
|
+
},
|
|
180
|
+
docs: {
|
|
181
|
+
description: {
|
|
182
|
+
story: `Use slot to set invalid message \`<template #invalid-message>Invalid date slot</template>\``,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
InvalidMessageSlot.parameters = storyParametersObject(
|
|
187
|
+
InvalidMessageSlot.parameters,
|
|
188
|
+
templateInvalidMessageSlot,
|
|
189
|
+
InvalidMessageSlot.args
|
|
190
|
+
);
|
|
150
191
|
|
|
151
192
|
/* SINGLE USING DATE STORY */
|
|
152
193
|
|
|
194
|
+
const singleValue = ref(now);
|
|
153
195
|
const templateSingleUsingDate = `
|
|
154
196
|
<div>
|
|
155
|
-
<cv-date-picker v-bind=
|
|
197
|
+
<cv-date-picker v-bind="args" @change="onChange" kind="single" v-model="singleValue">
|
|
156
198
|
</cv-date-picker>
|
|
199
|
+
</div>`;
|
|
200
|
+
const templateSingleUsingDateVModel = `
|
|
201
|
+
<div style="margin-top:2rem; background-color: #888888; padding:1rem">
|
|
202
|
+
<div style="font-size: 150%;">Sample interaction</div>
|
|
203
|
+
<label for="date-model" style='margin-right: 0.5rem'>V-model:</label>
|
|
204
|
+
<input id="date-model" type="text" :value="singleValue" @change="ev => { singleValue = ev.currentTarget.value }"/>
|
|
157
205
|
</div>
|
|
158
206
|
`;
|
|
159
207
|
|
|
@@ -163,20 +211,90 @@ const TemplateSingleUsingDate = args => {
|
|
|
163
211
|
setup: () => ({
|
|
164
212
|
args,
|
|
165
213
|
now,
|
|
214
|
+
singleValue,
|
|
166
215
|
onChange: action('change'),
|
|
167
216
|
}),
|
|
168
|
-
template: templateSingleUsingDate,
|
|
217
|
+
template: templateSingleUsingDate + templateSingleUsingDateVModel,
|
|
169
218
|
};
|
|
170
219
|
};
|
|
171
220
|
|
|
172
221
|
export const SingleUsingDate = TemplateSingleUsingDate.bind({});
|
|
173
222
|
SingleUsingDate.args = initArgs;
|
|
223
|
+
SingleUsingDate.parameters = {
|
|
224
|
+
controls: {
|
|
225
|
+
include: ['dateLabel', 'disabled', 'invalidMessage', 'placeholder'],
|
|
226
|
+
},
|
|
227
|
+
docs: {
|
|
228
|
+
description: {
|
|
229
|
+
story: `Example of single date input with v-model`,
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
SingleUsingDate.parameters = storyParametersObject(
|
|
234
|
+
SingleUsingDate.parameters,
|
|
235
|
+
templateSingleUsingDate,
|
|
236
|
+
SingleUsingDate.args
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
/* SINGLE USING MIN MAX PARAMS STORY */
|
|
240
|
+
|
|
241
|
+
const templateSingleUsingMinMax = `
|
|
242
|
+
<div>
|
|
243
|
+
<cv-date-picker v-bind='args' @change="onChange" kind="single" :value="now" :cal-options="calOptions">
|
|
244
|
+
</cv-date-picker>
|
|
245
|
+
</div>
|
|
246
|
+
`;
|
|
247
|
+
|
|
248
|
+
const TemplateSingleUsingMinMax = args => {
|
|
249
|
+
return {
|
|
250
|
+
components: { CvDatePicker },
|
|
251
|
+
setup: () => ({
|
|
252
|
+
args,
|
|
253
|
+
now,
|
|
254
|
+
calOptions: {
|
|
255
|
+
minDate: now,
|
|
256
|
+
maxDate: nextWeek,
|
|
257
|
+
dateFormat: 'm/d/Y',
|
|
258
|
+
},
|
|
259
|
+
onChange: action('change'),
|
|
260
|
+
}),
|
|
261
|
+
template: templateSingleUsingMinMax,
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
const codeMinMax = `
|
|
266
|
+
const now = new Date();
|
|
267
|
+
const nextWeek = new Date();
|
|
268
|
+
nextWeek.setDate(now.getDate() + 7);
|
|
269
|
+
const calOptions = ref({
|
|
270
|
+
minDate: now,
|
|
271
|
+
maxDate: nextWeek,
|
|
272
|
+
dateFormat: 'm/d/Y'
|
|
273
|
+
})
|
|
274
|
+
${templateSingleUsingMinMax}
|
|
275
|
+
`;
|
|
276
|
+
const docMinMax = `Example showing how "calOptions" prop can be used to control the min/max date.`;
|
|
277
|
+
export const SingleUsingMinMax = TemplateSingleUsingMinMax.bind({});
|
|
278
|
+
SingleUsingMinMax.args = initArgs;
|
|
279
|
+
|
|
280
|
+
SingleUsingMinMax.parameters = {
|
|
281
|
+
controls: {
|
|
282
|
+
exclude: ['update:modelValue', 'invalid-message', 'modelValue', 'kind'],
|
|
283
|
+
},
|
|
284
|
+
docs: {
|
|
285
|
+
source: { code: codeMinMax },
|
|
286
|
+
description: {
|
|
287
|
+
story: docMinMax,
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
};
|
|
174
291
|
|
|
175
292
|
/* RANGE USING DATE STORY */
|
|
176
293
|
|
|
177
294
|
const templateRangeUsingDate = `
|
|
178
295
|
<div>
|
|
179
|
-
<cv-date-picker v-bind=
|
|
296
|
+
<cv-date-picker v-bind="args" @change="onChange" kind="range"
|
|
297
|
+
:value="{startDate: now.toLocaleDateString(), endDate: tomorrow.toLocaleDateString()}">
|
|
180
298
|
</cv-date-picker>
|
|
181
299
|
</div>
|
|
182
300
|
`;
|
|
@@ -196,12 +314,22 @@ const TemplateRangeUsingDate = args => {
|
|
|
196
314
|
|
|
197
315
|
export const RangeUsingDate = TemplateRangeUsingDate.bind({});
|
|
198
316
|
RangeUsingDate.args = initArgs;
|
|
317
|
+
RangeUsingDate.parameters = {
|
|
318
|
+
controls: {
|
|
319
|
+
exclude: ['update:modelValue', 'invalid-message', 'kind', 'modelValue'],
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
RangeUsingDate.parameters = storyParametersObject(
|
|
323
|
+
RangeUsingDate.parameters,
|
|
324
|
+
templateRangeUsingDate,
|
|
325
|
+
RangeUsingDate.args
|
|
326
|
+
);
|
|
199
327
|
|
|
200
328
|
/* MINIMAL STORY */
|
|
201
329
|
|
|
202
330
|
const templateMinimal = `
|
|
203
331
|
<div>
|
|
204
|
-
<cv-date-picker v-bind=
|
|
332
|
+
<cv-date-picker v-bind="args" @change="onChange" :value="now">
|
|
205
333
|
</cv-date-picker>
|
|
206
334
|
</div>
|
|
207
335
|
`;
|
|
@@ -211,6 +339,7 @@ const TemplateMinimal = args => {
|
|
|
211
339
|
components: { CvDatePicker },
|
|
212
340
|
setup: () => ({
|
|
213
341
|
args,
|
|
342
|
+
now,
|
|
214
343
|
onChange: action('change'),
|
|
215
344
|
}),
|
|
216
345
|
template: templateMinimal,
|
|
@@ -218,12 +347,22 @@ const TemplateMinimal = args => {
|
|
|
218
347
|
};
|
|
219
348
|
|
|
220
349
|
export const Minimal = TemplateMinimal.bind({});
|
|
350
|
+
Minimal.parameters = {
|
|
351
|
+
controls: {
|
|
352
|
+
exclude: ['update:modelValue', 'invalid-message', 'modelValue'],
|
|
353
|
+
},
|
|
354
|
+
};
|
|
355
|
+
Minimal.parameters = storyParametersObject(
|
|
356
|
+
Minimal.parameters,
|
|
357
|
+
templateMinimal,
|
|
358
|
+
Minimal.args
|
|
359
|
+
);
|
|
221
360
|
|
|
222
361
|
/* SKELETON STORY */
|
|
223
362
|
|
|
224
363
|
const templateSkeleton = `
|
|
225
364
|
<div>
|
|
226
|
-
<cv-date-picker-skeleton v-bind=
|
|
365
|
+
<cv-date-picker-skeleton v-bind="args"></cv-date-picker-skeleton>
|
|
227
366
|
</div>
|
|
228
367
|
`;
|
|
229
368
|
|
|
@@ -239,3 +378,15 @@ const TemplateSkeleton = args => {
|
|
|
239
378
|
};
|
|
240
379
|
|
|
241
380
|
export const Skeleton = TemplateSkeleton.bind({});
|
|
381
|
+
Skeleton.args = initArgs;
|
|
382
|
+
Skeleton.args = initArgs;
|
|
383
|
+
Skeleton.parameters = {
|
|
384
|
+
controls: {
|
|
385
|
+
include: [],
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
Skeleton.parameters = storyParametersObject(
|
|
389
|
+
Skeleton.parameters,
|
|
390
|
+
templateSkeleton,
|
|
391
|
+
Skeleton.args
|
|
392
|
+
);
|
|
@@ -42,13 +42,12 @@
|
|
|
42
42
|
data-date-picker-input
|
|
43
43
|
role="datepicker"
|
|
44
44
|
:data-invalid="isInvalid || null"
|
|
45
|
-
:disabled="disabled"
|
|
46
|
-
:data-date-picker-input-from="getKind === 'range'"
|
|
45
|
+
:disabled="disabled || null"
|
|
46
|
+
:data-date-picker-input-from="`${getKind === 'range'}`"
|
|
47
47
|
:class="`${carbonPrefix}--date-picker__input`"
|
|
48
48
|
:pattern="pattern"
|
|
49
49
|
:placeholder="placeholder"
|
|
50
50
|
@change="handleUpdateEvent"
|
|
51
|
-
@click="handleClick"
|
|
52
51
|
/>
|
|
53
52
|
<Calendar16
|
|
54
53
|
v-if="['single', 'range'].includes(getKind)"
|
|
@@ -87,9 +86,9 @@
|
|
|
87
86
|
type="text"
|
|
88
87
|
data-date-picker-input
|
|
89
88
|
role="todatepicker"
|
|
90
|
-
:data-date-picker-input-to="kind === 'range'"
|
|
89
|
+
:data-date-picker-input-to="`${kind === 'range'}`"
|
|
91
90
|
:data-invalid="isInvalid || null"
|
|
92
|
-
:disabled="disabled"
|
|
91
|
+
:disabled="disabled || null"
|
|
93
92
|
:class="`${carbonPrefix}--date-picker__input`"
|
|
94
93
|
:pattern="pattern"
|
|
95
94
|
:placeholder="placeholder"
|
|
@@ -136,20 +135,26 @@ const dateWrapper = ref(null);
|
|
|
136
135
|
const date = ref(null);
|
|
137
136
|
const todate = ref(null);
|
|
138
137
|
|
|
139
|
-
const cvId = useCvId(props, true, 'date-picker-');
|
|
140
|
-
const isLight = useIsLight(props);
|
|
141
|
-
|
|
142
138
|
let calendar;
|
|
143
139
|
|
|
144
140
|
const props = defineProps({
|
|
145
141
|
modelValue: { type: [String, Object, Array, Date], default: undefined },
|
|
142
|
+
/** Date picker label */
|
|
146
143
|
dateLabel: { type: String, default: undefined },
|
|
144
|
+
/** Date picker end label (when using kind="range") */
|
|
147
145
|
dateEndLabel: { type: String, default: 'End date' },
|
|
148
|
-
|
|
146
|
+
/** If true, the date picker will be disabled */
|
|
149
147
|
disabled: { type: Boolean, default: false },
|
|
148
|
+
/** Date picker text on invalid value */
|
|
150
149
|
invalidMessage: { type: String, default: undefined },
|
|
150
|
+
/** Regex pattern used for form validation, default \d{1,2}/\d{1,2}/\d{4} */
|
|
151
151
|
pattern: { type: String, default: '\\d{1,2}/\\d{1,2}/\\d{4}' },
|
|
152
|
+
/** Date picker input placeholder, shown when date picker is empty. Default 'mm/dd/yyyy' */
|
|
152
153
|
placeholder: { type: String, default: 'mm/dd/yyyy' },
|
|
154
|
+
/** You can pass flatpickr options through this prop.
|
|
155
|
+
See https://flatpickr.js.org/options/ for more details.
|
|
156
|
+
Some of the options is not supported (for example, onChange, onReady, mode, nextArrow, prevArrow).
|
|
157
|
+
Also, you have to pass dateFormat field in calOptions object if you use it. */
|
|
153
158
|
calOptions: {
|
|
154
159
|
type: Object,
|
|
155
160
|
default() {
|
|
@@ -159,6 +164,8 @@ const props = defineProps({
|
|
|
159
164
|
},
|
|
160
165
|
},
|
|
161
166
|
formItem: { type: Boolean, default: true },
|
|
167
|
+
/** Date picker kind (also known as mode in flatpickr options).
|
|
168
|
+
Possible values: 'short', 'simple', 'single', 'range' */
|
|
162
169
|
kind: {
|
|
163
170
|
type: String,
|
|
164
171
|
default: 'simple',
|
|
@@ -169,6 +176,9 @@ const props = defineProps({
|
|
|
169
176
|
...propsCvTheme,
|
|
170
177
|
});
|
|
171
178
|
|
|
179
|
+
const cvId = useCvId(props, true, 'date-picker-');
|
|
180
|
+
const isLight = useIsLight(props);
|
|
181
|
+
|
|
172
182
|
const emit = defineEmits(['update:modelValue']);
|
|
173
183
|
|
|
174
184
|
const getKind = computed({
|
|
@@ -301,6 +311,7 @@ const initFlatpickr = () => {
|
|
|
301
311
|
};
|
|
302
312
|
|
|
303
313
|
let dateToString = val => {
|
|
314
|
+
if (!val) return '';
|
|
304
315
|
return calendar.formatDate(val, props.calOptions.dateFormat);
|
|
305
316
|
};
|
|
306
317
|
|
|
@@ -337,14 +348,17 @@ const handleUpdateEvent = event => {
|
|
|
337
348
|
};
|
|
338
349
|
|
|
339
350
|
const setDate = value => {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
351
|
+
try {
|
|
352
|
+
if (value === undefined) return;
|
|
353
|
+
if (isSingle.value) {
|
|
354
|
+
calendar.setDate(value, true);
|
|
355
|
+
} else if (isRange.value) {
|
|
356
|
+
calendar.setDate([value.startDate, value.endDate], true);
|
|
357
|
+
} else {
|
|
358
|
+
date.value.value = value;
|
|
359
|
+
}
|
|
360
|
+
} catch (e) {
|
|
361
|
+
console.error('setDate', e);
|
|
348
362
|
}
|
|
349
363
|
};
|
|
350
364
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
`cv-modal ${carbonPrefix}--modal`,
|
|
9
9
|
{
|
|
10
10
|
'is-visible': dataVisible,
|
|
11
|
-
[`${carbonPrefix}--modal--danger`]: kind ===
|
|
11
|
+
[`${carbonPrefix}--modal--danger`]: kind === MODAL_KIND_DANGER,
|
|
12
12
|
},
|
|
13
13
|
]"
|
|
14
14
|
tabindex="-1"
|
|
@@ -119,6 +119,15 @@
|
|
|
119
119
|
</template>
|
|
120
120
|
|
|
121
121
|
<script setup>
|
|
122
|
+
import {
|
|
123
|
+
MODAL_KIND_DANGER,
|
|
124
|
+
MODAL_KIND_PRIMARY,
|
|
125
|
+
MODAL_KINDS,
|
|
126
|
+
MODAL_SIZE_EXTRA_SMALL,
|
|
127
|
+
MODAL_SIZE_LARGE,
|
|
128
|
+
MODAL_SIZE_SMALL,
|
|
129
|
+
MODAL_SIZES,
|
|
130
|
+
} from './index';
|
|
122
131
|
import CvButton from '../CvButton/CvButton.vue';
|
|
123
132
|
import { carbonPrefix } from '../../global/settings';
|
|
124
133
|
import { props as propsCvId, useCvId } from '../../use/cvId';
|
|
@@ -155,7 +164,11 @@ const props = defineProps({
|
|
|
155
164
|
kind: {
|
|
156
165
|
type: String,
|
|
157
166
|
default: '',
|
|
158
|
-
validator: val =>
|
|
167
|
+
validator: val => {
|
|
168
|
+
const valid = MODAL_KINDS.includes(val);
|
|
169
|
+
if (!valid) console.warn('valid kinds:', MODAL_KINDS);
|
|
170
|
+
return valid;
|
|
171
|
+
},
|
|
159
172
|
},
|
|
160
173
|
/**
|
|
161
174
|
* boolean value if true the component user is expected to close the modal via visible property.
|
|
@@ -187,8 +200,11 @@ const props = defineProps({
|
|
|
187
200
|
*/
|
|
188
201
|
size: {
|
|
189
202
|
type: String,
|
|
190
|
-
validator: val =>
|
|
191
|
-
|
|
203
|
+
validator: val => {
|
|
204
|
+
const valid = MODAL_SIZES.includes(val);
|
|
205
|
+
if (!valid) console.warn('valid sizes:', MODAL_SIZES);
|
|
206
|
+
return valid;
|
|
207
|
+
},
|
|
192
208
|
default: '',
|
|
193
209
|
},
|
|
194
210
|
/**
|
|
@@ -333,22 +349,22 @@ const dialogAttrs = computed(() => {
|
|
|
333
349
|
return attrs;
|
|
334
350
|
});
|
|
335
351
|
const primaryKind = computed(() => {
|
|
336
|
-
if (props.kind ===
|
|
337
|
-
return
|
|
352
|
+
if (props.kind === MODAL_KIND_DANGER) {
|
|
353
|
+
return MODAL_KIND_DANGER;
|
|
338
354
|
} else {
|
|
339
|
-
return
|
|
355
|
+
return MODAL_KIND_PRIMARY;
|
|
340
356
|
}
|
|
341
357
|
});
|
|
342
358
|
const internalSize = computed(() => {
|
|
343
359
|
switch (props.size) {
|
|
344
|
-
case
|
|
345
|
-
return
|
|
346
|
-
case
|
|
360
|
+
case MODAL_SIZE_EXTRA_SMALL:
|
|
361
|
+
return MODAL_SIZE_EXTRA_SMALL;
|
|
362
|
+
case MODAL_SIZE_SMALL:
|
|
347
363
|
case 'small':
|
|
348
|
-
return
|
|
349
|
-
case
|
|
364
|
+
return MODAL_SIZE_SMALL;
|
|
365
|
+
case MODAL_SIZE_LARGE:
|
|
350
366
|
case 'large':
|
|
351
|
-
return
|
|
367
|
+
return MODAL_SIZE_LARGE;
|
|
352
368
|
default:
|
|
353
369
|
return '';
|
|
354
370
|
}
|
|
@@ -398,4 +414,10 @@ function onOtherBtnClick(ev) {
|
|
|
398
414
|
onBeforeUnmount(() => {
|
|
399
415
|
if (dataVisible.value) hide();
|
|
400
416
|
});
|
|
417
|
+
|
|
418
|
+
// exposing methods
|
|
419
|
+
defineExpose({
|
|
420
|
+
show,
|
|
421
|
+
hide,
|
|
422
|
+
});
|
|
401
423
|
</script>
|
|
@@ -1,3 +1,31 @@
|
|
|
1
1
|
import CvModal from './CvModal.vue';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
const MODAL_SIZE_EXTRA_SMALL = 'xs';
|
|
4
|
+
const MODAL_SIZE_SMALL = 'sm';
|
|
5
|
+
const MODAL_SIZE_MEDIUM = 'md';
|
|
6
|
+
const MODAL_SIZE_LARGE = 'lg';
|
|
7
|
+
const MODAL_SIZES = [
|
|
8
|
+
'',
|
|
9
|
+
MODAL_SIZE_EXTRA_SMALL,
|
|
10
|
+
MODAL_SIZE_SMALL,
|
|
11
|
+
'small',
|
|
12
|
+
MODAL_SIZE_MEDIUM,
|
|
13
|
+
'medium',
|
|
14
|
+
'large',
|
|
15
|
+
MODAL_SIZE_LARGE,
|
|
16
|
+
];
|
|
17
|
+
const MODAL_KIND_PRIMARY = 'primary';
|
|
18
|
+
const MODAL_KIND_DANGER = 'danger';
|
|
19
|
+
const MODAL_KINDS = ['', MODAL_KIND_PRIMARY, MODAL_KIND_DANGER];
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
CvModal,
|
|
23
|
+
MODAL_SIZES,
|
|
24
|
+
MODAL_SIZE_EXTRA_SMALL,
|
|
25
|
+
MODAL_SIZE_SMALL,
|
|
26
|
+
MODAL_SIZE_LARGE,
|
|
27
|
+
MODAL_KINDS,
|
|
28
|
+
MODAL_KIND_PRIMARY,
|
|
29
|
+
MODAL_KIND_DANGER,
|
|
30
|
+
};
|
|
3
31
|
export default CvModal;
|
|
@@ -426,8 +426,8 @@ onUpdated(checkSlots);
|
|
|
426
426
|
onMounted(updateOptions);
|
|
427
427
|
onMounted(updateSelectedItems);
|
|
428
428
|
|
|
429
|
-
watch(() => props.modelValue, updateSelectedItems);
|
|
430
|
-
watch(() => props.options, updateOptions);
|
|
429
|
+
watch(() => props.modelValue, updateSelectedItems, { deep: true });
|
|
430
|
+
watch(() => props.options, updateOptions, { deep: true });
|
|
431
431
|
watch(() => props.selectionFeedback, updateOptions);
|
|
432
432
|
|
|
433
433
|
const highlighted = computed({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { action } from '@storybook/addon-actions';
|
|
2
|
-
import { sbCompPrefix } from '../../global/storybook-utils';
|
|
2
|
+
import { sbCompPrefix, storySourceCode } from '../../global/storybook-utils';
|
|
3
3
|
|
|
4
4
|
import { CvInlineNotification, CvNotificationConsts } from '.';
|
|
5
|
+
import DocumentationTemplate from './CvInlineNotificationTemplate.mdx';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: `${sbCompPrefix}/CvInlineNotification`,
|
|
@@ -59,6 +60,11 @@ export default {
|
|
|
59
60
|
control: { type: 'boolean' },
|
|
60
61
|
},
|
|
61
62
|
},
|
|
63
|
+
parameters: {
|
|
64
|
+
docs: {
|
|
65
|
+
page: DocumentationTemplate,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
62
68
|
};
|
|
63
69
|
|
|
64
70
|
const template = `<cv-inline-notification v-bind="args" @action="onAction" @close="onClose" />`;
|
|
@@ -79,6 +85,10 @@ const Template = args => {
|
|
|
79
85
|
export const Info = Template.bind({});
|
|
80
86
|
Info.args = {
|
|
81
87
|
kind: CvNotificationConsts.notificationKinds[0],
|
|
88
|
+
primary: true,
|
|
89
|
+
};
|
|
90
|
+
Info.parameters = {
|
|
91
|
+
docs: { source: { code: storySourceCode(template, Info.args) } },
|
|
82
92
|
};
|
|
83
93
|
|
|
84
94
|
export const InfoSquare = Template.bind({});
|
|
@@ -86,24 +96,71 @@ InfoSquare.storyName = 'Info square';
|
|
|
86
96
|
InfoSquare.args = {
|
|
87
97
|
kind: CvNotificationConsts.notificationKinds[1],
|
|
88
98
|
};
|
|
99
|
+
InfoSquare.parameters = {
|
|
100
|
+
docs: { source: { code: storySourceCode(template, InfoSquare.args) } },
|
|
101
|
+
};
|
|
89
102
|
|
|
90
103
|
export const Success = Template.bind({});
|
|
91
104
|
Success.args = {
|
|
92
105
|
kind: CvNotificationConsts.notificationKinds[2],
|
|
93
106
|
};
|
|
107
|
+
Success.parameters = {
|
|
108
|
+
docs: { source: { code: storySourceCode(template, Success.args) } },
|
|
109
|
+
};
|
|
94
110
|
|
|
95
111
|
export const Warning = Template.bind({});
|
|
96
112
|
Warning.args = {
|
|
97
113
|
kind: CvNotificationConsts.notificationKinds[3],
|
|
98
114
|
};
|
|
115
|
+
Warning.parameters = {
|
|
116
|
+
docs: { source: { code: storySourceCode(template, Warning.args) } },
|
|
117
|
+
};
|
|
99
118
|
|
|
100
119
|
export const WarningAlt = Template.bind({});
|
|
101
120
|
WarningAlt.storyName = 'Warning (alt)';
|
|
102
121
|
WarningAlt.args = {
|
|
103
122
|
kind: CvNotificationConsts.notificationKinds[4],
|
|
104
123
|
};
|
|
124
|
+
WarningAlt.parameters = {
|
|
125
|
+
docs: { source: { code: storySourceCode(template, WarningAlt.args) } },
|
|
126
|
+
};
|
|
105
127
|
|
|
106
128
|
export const Error = Template.bind({});
|
|
107
129
|
Error.args = {
|
|
108
130
|
kind: CvNotificationConsts.notificationKinds[5],
|
|
109
131
|
};
|
|
132
|
+
Error.parameters = {
|
|
133
|
+
docs: { source: { code: storySourceCode(template, Error.args) } },
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const templateSlots = `
|
|
137
|
+
<cv-inline-notification v-bind="args">
|
|
138
|
+
<template #title>
|
|
139
|
+
<h2>Big title</h2>
|
|
140
|
+
</template>
|
|
141
|
+
<template #subtitle>
|
|
142
|
+
Lorem ipsum dolor sit amet, <a href="#">consectetur adipisicing elit</a>, seed do eiusmod tempor <strong>incididunt ut labore</strong> et dolore magna aliqua.
|
|
143
|
+
</template>
|
|
144
|
+
</cv-inline-notification>`;
|
|
145
|
+
const SlotTemplate = args => {
|
|
146
|
+
return {
|
|
147
|
+
components: { CvInlineNotification },
|
|
148
|
+
template: templateSlots,
|
|
149
|
+
setup() {
|
|
150
|
+
return {
|
|
151
|
+
onAction: action('action'),
|
|
152
|
+
onClose: action('close'),
|
|
153
|
+
args,
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
export const Slots = SlotTemplate.bind({});
|
|
159
|
+
Slots.args = {
|
|
160
|
+
kind: CvNotificationConsts.notificationKinds[0],
|
|
161
|
+
actionLabel: '',
|
|
162
|
+
hideCloseButton: true,
|
|
163
|
+
};
|
|
164
|
+
Slots.parameters = {
|
|
165
|
+
docs: { source: { code: storySourceCode(templateSlots, Slots.args) } },
|
|
166
|
+
};
|