@carbon/vue 3.0.4-alpha.0 → 3.0.6-alpha.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 (41) hide show
  1. package/README.md +16 -0
  2. package/dist/carbon-vue-3.common.js +11782 -2709
  3. package/dist/carbon-vue-3.common.js.map +1 -1
  4. package/dist/carbon-vue-3.css +1 -0
  5. package/dist/carbon-vue-3.umd.js +11782 -2709
  6. package/dist/carbon-vue-3.umd.js.map +1 -1
  7. package/dist/carbon-vue-3.umd.min.js +30 -2
  8. package/dist/carbon-vue-3.umd.min.js.map +1 -1
  9. package/package.json +3 -2
  10. package/src/components/CvCheckbox/CvCheckbox.vue +0 -2
  11. package/src/components/CvDatePicker/CvDatePicker-notes.md +86 -0
  12. package/src/components/CvDatePicker/CvDatePicker.stories.js +241 -0
  13. package/src/components/CvDatePicker/CvDatePicker.vue +402 -0
  14. package/src/components/CvDatePicker/CvDatePickerSkeleton.vue +106 -0
  15. package/src/components/CvDatePicker/index.js +4 -0
  16. package/src/components/CvDatePicker/plugins/appendToPlugin.js +64 -0
  17. package/src/components/CvDatePicker/plugins/fixEventsPlugin.js +79 -0
  18. package/src/components/CvDatePicker/plugins/monthSelectPlugin.js +86 -0
  19. package/src/components/CvDatePicker/plugins/rangePlugin.js +47 -0
  20. package/src/components/CvForm/CvForm.stories.mdx +193 -0
  21. package/src/components/CvForm/CvForm.vue +9 -0
  22. package/src/components/CvForm/CvFormGroup.vue +27 -0
  23. package/src/components/CvForm/CvFormItem.vue +9 -0
  24. package/src/components/CvForm/index.js +5 -0
  25. package/src/components/CvModal/CvModal.stories.mdx +234 -0
  26. package/src/components/CvModal/CvModal.vue +403 -0
  27. package/src/components/CvModal/index.js +3 -0
  28. package/src/components/CvTextArea/CvTextArea.stories.js +174 -0
  29. package/src/components/CvTextArea/CvTextArea.vue +107 -0
  30. package/src/components/CvTextArea/index.js +4 -0
  31. package/src/components/CvTextInput/CvTextInput.stories.js +245 -0
  32. package/src/components/CvTextInput/CvTextInput.vue +217 -0
  33. package/src/components/CvTextInput/const.js +2 -0
  34. package/src/components/CvTextInput/index.js +4 -0
  35. package/src/components/CvTile/CvTile.stories.mdx +156 -0
  36. package/src/components/CvTile/CvTile.vue +67 -0
  37. package/src/components/CvTile/CvTileClickable.vue +23 -0
  38. package/src/components/CvTile/CvTileExpandable.vue +103 -0
  39. package/src/components/CvTile/CvTileSelectable.vue +52 -0
  40. package/src/components/CvTile/CvTileStandard.vue +7 -0
  41. package/src/components/CvTile/index.js +4 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/vue",
3
3
  "license": "Apache-2.0",
4
- "version": "3.0.4-alpha.0",
4
+ "version": "3.0.6-alpha.0",
5
5
  "description": "A collection of components for the Carbon Design System built using Vue.js",
6
6
  "packageManager": "yarn@3.2.0",
7
7
  "main": "dist/carbon-vue-3.umd.min.js",
@@ -28,6 +28,7 @@
28
28
  "@carbon/icons-vue": "^10.60.0",
29
29
  "@vueuse/core": "^4.11.2",
30
30
  "carbon-components": "^10.58.5",
31
+ "flatpickr": "^4.6.13",
31
32
  "mitt": "^3.0.0"
32
33
  },
33
34
  "devDependencies": {
@@ -202,5 +203,5 @@
202
203
  "url": "git+https://github.com/carbon-design-system/carbon-components-vue.git"
203
204
  },
204
205
  "sideEffects": true,
205
- "gitHead": "de2206c3b902917df58415daeda57ee823b126db"
206
+ "gitHead": "b428c30785a4cfc937c68a3122e0af82645fef8e"
206
207
  }
@@ -69,5 +69,3 @@ const cvId = useCvId(props);
69
69
  const emit = defineEmits(['update:modelValue', 'change']);
70
70
  const { onChange, isChecked } = useCheck(toRefs(props), emit);
71
71
  </script>
72
-
73
- <style scoped></style>
@@ -0,0 +1,86 @@
1
+ # cv-date-picker
2
+
3
+ A Vue implementation of a Carbon Components date-picker.
4
+
5
+ http://www.carbondesignsystem.com/components/date-picker/code
6
+
7
+ ## Usage
8
+
9
+ ### Short
10
+
11
+ ```html
12
+ <cv-date-picker
13
+ kind="short"
14
+ pattern="\d{1,2}/\d{2}"
15
+ placeholder="mm/yy"
16
+ @onChange="actionChange"
17
+ >
18
+ </cv-date-picker>
19
+ ```
20
+
21
+ ### Simple
22
+
23
+ ```html
24
+ <cv-date-picker
25
+ kind="simple"
26
+ pattern="\d{1,2}/\d{1,2}/\d{4}"
27
+ placeholder="mm/dd/yyyy"
28
+ @onChange="actionChange"
29
+ >
30
+ </cv-date-picker>
31
+ ```
32
+
33
+ ### Single
34
+
35
+ ```html
36
+ <cv-date-picker
37
+ kind="single"
38
+ pattern="\d{1,2}/\d{1,2}/\d{4}"
39
+ placeholder="mm/dd/yyyy"
40
+ :cal-options="calOptions"
41
+ @onChange="actionChange"
42
+ >
43
+ </cv-date-picker>
44
+ ```
45
+
46
+ ### Range
47
+
48
+ ```html
49
+ <cv-date-picker
50
+ kind="range"
51
+ pattern="\d{1,2}/\d{1,2}/\d{4}"
52
+ placeholder="mm/dd/yyyy"
53
+ :cal-options="calOptions"
54
+ @onChange="actionChange"
55
+ >
56
+ </cv-date-picker>
57
+ ```
58
+
59
+ ## Attributes
60
+
61
+ - dateLabel: optional label for the date input (first in range)
62
+ - dateEndLabel: optional for the end range date input (first in range)
63
+ - kind: 'short', 'simple', 'single', 'range' as per carbon components core only single and range have a date picker
64
+ - calOptions: Options to confiure flatpickr, see flatpickr for full details.
65
+
66
+ - e.g. { dateFormat: 'd/m/Y', defaultDate: '01/01/2019' }
67
+ - NOTE: passing event handlers onChange and onValueUpdate are swallowed internally. Both produce an onChange.
68
+
69
+ - pattern: Regex pattern used for form validation '\\d{1,2}/\\d{1,2}/\\d{4}',
70
+ - placeholder: Shown when date picker is empty,
71
+ - invalidMessage: Message displayed if invalid is true
72
+
73
+ - value: can be
74
+ - Javascript Date
75
+ - String with a date matching the format based on the calendar options
76
+ - Object (kind === 'range' only): { startDate: val, endDate: val2 } where val and val2 are a javascript date or date string as per format option
77
+
78
+ ## Slots
79
+
80
+ invalid-message: Overrides the invalid message property
81
+
82
+ ###
83
+
84
+ ## Events
85
+
86
+ - change raised when single or ranged date picker value changes.
@@ -0,0 +1,241 @@
1
+ import {
2
+ sbCompPrefix,
3
+ storyParametersObject,
4
+ } from '../../global/storybook-utils';
5
+
6
+ import { CvDatePicker } from '.';
7
+ import { CvDatePickerSkeleton } from '.';
8
+ import { action } from '@storybook/addon-actions';
9
+ import { ref } from 'vue';
10
+
11
+ const initArgs = {
12
+ dateLabel: 'Date label',
13
+ invalidMessage: '',
14
+ };
15
+
16
+ const now = new Date();
17
+ const tomorrow = new Date();
18
+ tomorrow.setDate(now.getDate() + 1);
19
+
20
+ export default {
21
+ title: `${sbCompPrefix}/CvDatePicker`,
22
+ component: CvDatePicker,
23
+ parameters: {
24
+ a11y: {
25
+ config: {
26
+ rules: [],
27
+ },
28
+ manual: true,
29
+ },
30
+ },
31
+ argTypes: {
32
+ dateLabel: { type: String, description: 'Date picker label' },
33
+ invalidMessage: {
34
+ type: String,
35
+ description: 'Date picker text on invalid value',
36
+ },
37
+ },
38
+ };
39
+
40
+ /* DEFAULT STORY */
41
+
42
+ const template = `
43
+ <div>
44
+ <cv-date-picker v-bind='args' @change='onChange'>
45
+ </cv-date-picker>
46
+ </div>
47
+ `;
48
+ const Template = args => {
49
+ return {
50
+ components: { CvDatePicker },
51
+ setup: () => ({
52
+ args,
53
+ onChange: action('change'),
54
+ }),
55
+ template,
56
+ };
57
+ };
58
+
59
+ export const Default = Template.bind({});
60
+ Default.args = initArgs;
61
+ Default.parameters = storyParametersObject(
62
+ Default.parameters,
63
+ template,
64
+ Default.args
65
+ );
66
+
67
+ /* V-MODEL STORY */
68
+
69
+ const modelValue = ref('');
70
+ const templateVModel = `
71
+ <div>
72
+ <cv-date-picker v-bind='args' @change='onChange' v-model="modelValue">
73
+ </cv-date-picker>
74
+ </div>
75
+ <div style="margin: 32px 0;">
76
+ <div style="font-size: 150%;">Sample interaction</div>
77
+ <label for="date-model" style='margin-right: 0.5rem'>V-model:</label>
78
+ <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 } }"/>
79
+ <input v-if="args.kind === 'range'" id="date-model" type="text" :value="modelValue.endDate" @change="ev => modelValue.endDate = ev.currentTarget.value"/>
80
+ </div>
81
+ `;
82
+
83
+ const TemplateVModel = args => {
84
+ return {
85
+ components: { CvDatePicker },
86
+ setup: () => ({
87
+ args,
88
+ modelValue,
89
+ now,
90
+ onChange: action('change'),
91
+ }),
92
+ template: templateVModel,
93
+ };
94
+ };
95
+
96
+ export const vModel = TemplateVModel.bind({});
97
+ vModel.args = initArgs;
98
+ vModel.parameters = storyParametersObject(
99
+ vModel.parameters,
100
+ templateVModel,
101
+ vModel.args
102
+ );
103
+
104
+ /* INVALID MESSAGE STORY */
105
+
106
+ const templateInvalidMessage = `
107
+ <div>
108
+ <cv-date-picker v-bind='args' @change='onChange'>
109
+ </cv-date-picker>
110
+ </div>
111
+ `;
112
+
113
+ const TemplateInvalidMessage = args => {
114
+ return {
115
+ components: { CvDatePicker },
116
+ setup: () => ({
117
+ args,
118
+ onChange: action('change'),
119
+ }),
120
+ template: templateInvalidMessage,
121
+ };
122
+ };
123
+
124
+ export const InvalidMessage = TemplateInvalidMessage.bind({});
125
+ InvalidMessage.args = { ...initArgs, invalidMessage: 'Invalid date' };
126
+
127
+ /* INVALID MESSAGE SLOT STORY */
128
+
129
+ const templateInvalidMessageSlot = `
130
+ <div>
131
+ <cv-date-picker v-bind='args' @change='onChange'>
132
+ <template #invalid-message>Invalid date slot</template>
133
+ </cv-date-picker>
134
+ </div>
135
+ `;
136
+
137
+ const TemplateInvalidMessageSlot = args => {
138
+ return {
139
+ components: { CvDatePicker },
140
+ setup: () => ({
141
+ args,
142
+ onChange: action('change'),
143
+ }),
144
+ template: templateInvalidMessageSlot,
145
+ };
146
+ };
147
+
148
+ export const InvalidMessageSlot = TemplateInvalidMessageSlot.bind({});
149
+ InvalidMessageSlot.args = initArgs;
150
+
151
+ /* SINGLE USING DATE STORY */
152
+
153
+ const templateSingleUsingDate = `
154
+ <div>
155
+ <cv-date-picker v-bind='args' @change='onChange' kind="single" :value="now">
156
+ </cv-date-picker>
157
+ </div>
158
+ `;
159
+
160
+ const TemplateSingleUsingDate = args => {
161
+ return {
162
+ components: { CvDatePicker },
163
+ setup: () => ({
164
+ args,
165
+ now,
166
+ onChange: action('change'),
167
+ }),
168
+ template: templateSingleUsingDate,
169
+ };
170
+ };
171
+
172
+ export const SingleUsingDate = TemplateSingleUsingDate.bind({});
173
+ SingleUsingDate.args = initArgs;
174
+
175
+ /* RANGE USING DATE STORY */
176
+
177
+ const templateRangeUsingDate = `
178
+ <div>
179
+ <cv-date-picker v-bind='args' @change='onChange' kind="range" :value="{startDate: now.toLocaleDateString(), endDate: tomorrow.toLocaleDateString()}">
180
+ </cv-date-picker>
181
+ </div>
182
+ `;
183
+
184
+ const TemplateRangeUsingDate = args => {
185
+ return {
186
+ components: { CvDatePicker },
187
+ setup: () => ({
188
+ args,
189
+ now,
190
+ tomorrow,
191
+ onChange: action('change'),
192
+ }),
193
+ template: templateRangeUsingDate,
194
+ };
195
+ };
196
+
197
+ export const RangeUsingDate = TemplateRangeUsingDate.bind({});
198
+ RangeUsingDate.args = initArgs;
199
+
200
+ /* MINIMAL STORY */
201
+
202
+ const templateMinimal = `
203
+ <div>
204
+ <cv-date-picker v-bind='args' @change='onChange'>
205
+ </cv-date-picker>
206
+ </div>
207
+ `;
208
+
209
+ const TemplateMinimal = args => {
210
+ return {
211
+ components: { CvDatePicker },
212
+ setup: () => ({
213
+ args,
214
+ onChange: action('change'),
215
+ }),
216
+ template: templateMinimal,
217
+ };
218
+ };
219
+
220
+ export const Minimal = TemplateMinimal.bind({});
221
+
222
+ /* SKELETON STORY */
223
+
224
+ const templateSkeleton = `
225
+ <div>
226
+ <cv-date-picker-skeleton v-bind='args'></cv-date-picker-skeleton>
227
+ </div>
228
+ `;
229
+
230
+ const TemplateSkeleton = args => {
231
+ return {
232
+ components: { CvDatePicker, CvDatePickerSkeleton },
233
+ setup: () => ({
234
+ args,
235
+ onChange: action('change'),
236
+ }),
237
+ template: templateSkeleton,
238
+ };
239
+ };
240
+
241
+ export const Skeleton = TemplateSkeleton.bind({});