@carbon/vue 3.0.5-alpha.0 → 3.0.7-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 (64) hide show
  1. package/README.md +16 -0
  2. package/dist/carbon-vue-3.common.js +22859 -11008
  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 +22859 -11008
  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 +5 -4
  10. package/src/components/CvAccordion/CvAccordion.stories.js +1 -0
  11. package/src/components/CvButton/CvButton.stories.js +3 -3
  12. package/src/components/CvButton/CvButtonSkeleton.stories.js +79 -0
  13. package/src/components/CvButton/CvButtonSkeleton.vue +19 -0
  14. package/src/components/CvButton/index.js +8 -1
  15. package/src/components/CvDatePicker/CvDatePicker-notes.md +86 -0
  16. package/src/components/CvDatePicker/CvDatePicker.stories.js +241 -0
  17. package/src/components/CvDatePicker/CvDatePicker.vue +402 -0
  18. package/src/components/CvDatePicker/CvDatePickerSkeleton.vue +106 -0
  19. package/src/components/CvDatePicker/index.js +4 -0
  20. package/src/components/CvDatePicker/plugins/appendToPlugin.js +64 -0
  21. package/src/components/CvDatePicker/plugins/fixEventsPlugin.js +79 -0
  22. package/src/components/CvDatePicker/plugins/monthSelectPlugin.js +86 -0
  23. package/src/components/CvDatePicker/plugins/rangePlugin.js +47 -0
  24. package/src/components/CvDropdown/CvDropdown.stories.mdx +407 -0
  25. package/src/components/CvDropdown/CvDropdown.vue +418 -0
  26. package/src/components/CvDropdown/CvDropdownItem.vue +86 -0
  27. package/src/components/CvDropdown/CvDropdownSkeleton.vue +17 -0
  28. package/src/components/CvDropdown/index.js +5 -0
  29. package/src/components/CvForm/CvForm.stories.mdx +193 -0
  30. package/src/components/CvForm/CvForm.vue +9 -0
  31. package/src/components/CvForm/CvFormGroup.vue +27 -0
  32. package/src/components/CvForm/CvFormItem.vue +9 -0
  33. package/src/components/CvForm/index.js +5 -0
  34. package/src/components/CvInlineLoading/CvInlineLoading.stories.mdx +87 -0
  35. package/src/components/CvInlineLoading/CvInlineLoading.vue +144 -0
  36. package/src/components/CvInlineLoading/consts.js +9 -0
  37. package/src/components/CvInlineLoading/index.js +4 -0
  38. package/src/components/CvModal/CvModal.stories.mdx +236 -0
  39. package/src/components/CvModal/CvModal.vue +401 -0
  40. package/src/components/CvModal/index.js +3 -0
  41. package/src/components/CvMultiSelect/CvMultiSelect.stories.mdx +333 -0
  42. package/src/components/CvMultiSelect/CvMultiSelect.vue +705 -0
  43. package/src/components/CvMultiSelect/consts.js +16 -0
  44. package/src/components/CvMultiSelect/index.js +3 -0
  45. package/src/components/CvNumberInput/CvNumberInput.stories.js +265 -0
  46. package/src/components/CvNumberInput/CvNumberInput.vue +227 -0
  47. package/src/components/CvNumberInput/CvNumberInputSkeleton.stories.js +30 -0
  48. package/src/components/CvNumberInput/CvNumberInputSkeleton.vue +10 -0
  49. package/src/components/CvNumberInput/StorybookGroupConst.js +1 -0
  50. package/src/components/CvNumberInput/__tests__/__snapshots__/CvNumberInput.spec.js.snap +21 -0
  51. package/src/components/CvNumberInput/index.js +5 -0
  52. package/src/components/CvTabs/CvTab.vue +77 -0
  53. package/src/components/CvTabs/CvTabs.stories.mdx +175 -0
  54. package/src/components/CvTabs/CvTabs.vue +406 -0
  55. package/src/components/CvTabs/CvTabsSkeleton.vue +24 -0
  56. package/src/components/CvTabs/_SbContainer.vue +22 -0
  57. package/src/components/CvTabs/index.js +5 -0
  58. package/src/components/CvToggle/CvToggle-Skeleton.vue +29 -0
  59. package/src/components/CvToggle/CvToggle.stories.js +232 -0
  60. package/src/components/CvToggle/CvToggle.vue +70 -0
  61. package/src/components/CvToggle/__tests__/__snapshots__/CvToggle.spec.js.snap +7 -0
  62. package/src/components/CvToggle/index.js +4 -0
  63. package/src/global/storybook-utils/story-source-code.js +1 -0
  64. package/src/use/cvInput.js +34 -0
@@ -0,0 +1,193 @@
1
+ import { Canvas, Meta, Story } from '@storybook/addon-docs';
2
+ import { action } from '@storybook/addon-actions';
3
+ import { sbCompPrefix } from '../../global/storybook-utils';
4
+ import CvButton from '../CvButton';
5
+ import CvTextInput from '../CvTextInput';
6
+ import CvTextArea from '../CvTextArea';
7
+ import { CvForm, CvFormGroup, CvFormItem } from '.';
8
+
9
+ <Meta title={`${sbCompPrefix}/CvForm`} component={CvForm} />
10
+
11
+ export const Template = args => ({
12
+ components: {
13
+ CvForm,
14
+ CvFormGroup,
15
+ CvFormItem,
16
+ CvButton,
17
+ CvTextInput,
18
+ CvTextArea,
19
+ },
20
+ setup: () => {
21
+ const doSubmit = action('cv-form -submit event');
22
+ return {
23
+ args: { ...args, template: undefined },
24
+ onSubmit(ev) {
25
+ console.dir([].slice.call(ev.target, [0, ev.target.length]));
26
+ doSubmit(ev);
27
+ },
28
+ }
29
+ },
30
+ template: args.template,
31
+ });
32
+
33
+ export const defaultTemplate = `
34
+ <cv-form @submit.prevent="onSubmit">
35
+ <cv-text-input
36
+ label="Text input label"
37
+ placeholder="Optional placeholder text"
38
+ helperText="Optional helper text here; if message is more than one line text should wrap (~100 character count maximum)"
39
+ />
40
+ <cv-text-area
41
+ label="Text area label"
42
+ placeholder="Optional placeholder text"
43
+ helperText="Optional helper text here; if message is more than one line text should wrap (~100 character count maximum)"
44
+ />
45
+ <cv-button>Submit</cv-button>
46
+ </cv-form>
47
+ `;
48
+
49
+ export const formGroupTemplate = `
50
+ <cv-form-group v-bind="args">
51
+ <template #label>
52
+ FormGroup label-legend
53
+ </template>
54
+ <template #content>
55
+ <cv-text-input label="First name" />
56
+ <cv-text-input label="Last name" />
57
+ </template>
58
+ </cv-form-group>
59
+ `;
60
+
61
+ export const formItemTemplate = `
62
+ <cv-form-item>
63
+ <label for="text-input-3" class="bx--label">Text Input label</label>
64
+ <input id="text-input-3" type="text" class="bx--text-input" placeholder="Optional placeholder text" />
65
+ </cv-form-item>
66
+ `;
67
+
68
+ # CvForm
69
+
70
+ These components are purely wrapper elements for use in creating forms.
71
+
72
+ ## Usage CvForm
73
+
74
+ CvForm has no properties and a single default slot
75
+
76
+ <Canvas>
77
+ <Story
78
+ name="Default"
79
+ parameters={{
80
+ controls: {
81
+ exclude: ['template']
82
+ },
83
+ docs: { source: { code: defaultTemplate } },
84
+ }}
85
+ args={{
86
+ template: defaultTemplate,
87
+ }}
88
+ argTypes={{
89
+ default: {
90
+ control: 'none',
91
+ table: {
92
+ type: { summary: 'text | html | Component' },
93
+ category: 'slots',
94
+ }
95
+ },
96
+ }}
97
+ >
98
+ {Template.bind({})}
99
+ </Story>
100
+ </Canvas>
101
+
102
+
103
+ ## CvFormGroup
104
+
105
+ Used inside a form to group components such as checkboxes and radio buttons.
106
+
107
+ <Canvas>
108
+ <Story
109
+ name="FormGroup-Default"
110
+ parameters={{
111
+ controls: {
112
+ exclude: ['template', 'default']
113
+ },
114
+ docs: { source: { code: formGroupTemplate.replace('v-bind="args"', '') } },
115
+ }}
116
+ args={{
117
+ template: formGroupTemplate,
118
+ }}
119
+ argTypes={{
120
+ content: {
121
+ control: 'none',
122
+ table: {
123
+ type: { summary: 'text | html | Component' },
124
+ category: 'slots',
125
+ },
126
+ },
127
+ label: {
128
+ control: 'none',
129
+ table: {
130
+ type: { summary: 'text | html | Component' },
131
+ category: 'slots',
132
+ },
133
+ description: 'Legend element content',
134
+ },
135
+ invalid: {
136
+ type: 'boolean',
137
+ table: {
138
+ type: { summary: 'boolean' },
139
+ category: 'props',
140
+ },
141
+ description: 'Specify whether the `FormGroup` is invalid',
142
+ },
143
+ message: {
144
+ type: 'string',
145
+ table: {
146
+ type: { summary: 'string' },
147
+ category: 'props',
148
+ },
149
+ description: 'Specify a message to be placed at the end of the `FormGroup`',
150
+ },
151
+ noMargin: {
152
+ type: 'boolean',
153
+ table: {
154
+ type: { summary: 'boolean' },
155
+ category: 'props',
156
+ },
157
+ description: 'Remove default margins set on `FormGroup`',
158
+ },
159
+ }}
160
+ >
161
+ {Template.bind({})}
162
+ </Story>
163
+ </Canvas>
164
+
165
+ ## CvFormItem
166
+
167
+ Used inside a form to provide positional styling.
168
+
169
+ <Canvas>
170
+ <Story
171
+ name="FormItem-Default"
172
+ parameters={{
173
+ controls: {
174
+ exclude: ['template']
175
+ },
176
+ docs: { source: { code: formItemTemplate } },
177
+ }}
178
+ args={{
179
+ template: formItemTemplate,
180
+ }}
181
+ argTypes={{
182
+ default: {
183
+ control: 'none',
184
+ table: {
185
+ type: { summary: 'text | html | Component' },
186
+ category: 'slots',
187
+ }
188
+ },
189
+ }}
190
+ >
191
+ {Template.bind({})}
192
+ </Story>
193
+ </Canvas>
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <form :class="`cv-form ${carbonPrefix}--form`">
3
+ <slot></slot>
4
+ </form>
5
+ </template>
6
+
7
+ <script setup>
8
+ import { carbonPrefix } from '../../global/settings';
9
+ </script>
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <fieldset
3
+ :class="[
4
+ `cv-form-group ${carbonPrefix}--fieldset`,
5
+ { [`${carbonPrefix}--fieldset--no-margin`]: noMargin },
6
+ ]"
7
+ :data-invalid="invalid"
8
+ >
9
+ <legend :class="`${carbonPrefix}--label`">
10
+ <slot name="label"></slot>
11
+ </legend>
12
+ <slot name="content"></slot>
13
+ <div v-if="message" :class="`${carbonPrefix}--form__requirements`">
14
+ {{ message }}
15
+ </div>
16
+ </fieldset>
17
+ </template>
18
+
19
+ <script setup>
20
+ import { carbonPrefix } from '../../global/settings';
21
+
22
+ defineProps({
23
+ invalid: Boolean,
24
+ message: String,
25
+ noMargin: Boolean,
26
+ });
27
+ </script>
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <div :class="`cv-form-item ${carbonPrefix}--form-item`">
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <script setup>
8
+ import { carbonPrefix } from '../../global/settings';
9
+ </script>
@@ -0,0 +1,5 @@
1
+ import CvForm from './CvForm';
2
+ import CvFormGroup from './CvFormGroup';
3
+ import CvFormItem from './CvFormItem';
4
+
5
+ export { CvForm, CvFormGroup, CvFormItem };
@@ -0,0 +1,87 @@
1
+ import { Canvas, Meta, Story } from '@storybook/addon-docs';
2
+ import CvInlineLoading from './CvInlineLoading.vue';
3
+ import { sbCompPrefix } from '../../global/storybook-utils';
4
+
5
+ <Meta title={`${sbCompPrefix}/CvInlineLoading`} component={CvInlineLoading} />
6
+
7
+ export const Template = args => ({
8
+ // Components used in your story `template` are defined in the `components` object
9
+ components: {
10
+ CvInlineLoading,
11
+ },
12
+ // The story's `args` need to be mapped into the template through the `setup()` method
13
+ setup() {
14
+ return {
15
+ description: args.description,
16
+ errorText: args.errorText,
17
+ endingText: args.endingText,
18
+ loadingText: args.loadingText,
19
+ loadedText: args.loadedText,
20
+ state: args.state,
21
+ };
22
+ },
23
+ template: args.template,
24
+ });
25
+ const defaultTemplate = `
26
+ <cv-inline-loading
27
+ :description="description"
28
+ :ending-text="endingText"
29
+ :error-text="errorText"
30
+ :loading-text="loadingText"
31
+ :loaded-text="loadedText"
32
+ :state="state" />
33
+ `;
34
+
35
+ # CvInlineLoading
36
+
37
+ Migration notes:
38
+
39
+ - The `active` property is still available but does not actually work. Please use the `state` property instead.
40
+ - The state has two new values to make it easier to transition form `loading` to either `loaded` or `error`.
41
+ Setting `state` to "ending:loaded" or "ending:error" will first set the `ending` state and then, when
42
+ the ending animation completes, the `loaded` or `error` state.
43
+ - The states can be imported like `import { STATES } from "@/components/CvInlineLoading";` and used
44
+ as:
45
+ - `STATES.LOADING`
46
+ - `STATES.ENDING`
47
+ - `STATES.LOADED`
48
+ - `STATES.ERROR`
49
+ - `STATES.ENDING_LOADED`
50
+ - `STATES.ENDING_ERROR`
51
+
52
+ <Canvas>
53
+ <Story
54
+ name="Default"
55
+ parameters={{
56
+ controls: {
57
+ exclude: ['template'],
58
+ },
59
+ docs: { source: { code: defaultTemplate } },
60
+ }}
61
+ args={{
62
+ template: defaultTemplate,
63
+ endingText: 'Jumping to warp 9',
64
+ description: 'Warp engine status',
65
+ errorText: 'Warp drive is damaged',
66
+ loadingText: 'Warp drive coming online...',
67
+ loadedText: 'Warp drive engaged',
68
+ state: 'loading',
69
+ }}
70
+ argTypes={{
71
+ state: {
72
+ control: 'select',
73
+ default: 'loading',
74
+ options: [
75
+ 'loading',
76
+ 'ending',
77
+ 'loaded',
78
+ 'error',
79
+ 'ending:loaded',
80
+ 'ending:error',
81
+ ],
82
+ },
83
+ }}
84
+ >
85
+ {Template.bind({})}
86
+ </Story>
87
+ </Canvas>
@@ -0,0 +1,144 @@
1
+ <template>
2
+ <div
3
+ data-inline-loading
4
+ :class="`${carbonPrefix}--inline-loading`"
5
+ role="alert"
6
+ aria-live="assertive"
7
+ >
8
+ <div
9
+ :class="[
10
+ `${carbonPrefix}--inline-loading__animation`,
11
+ { [`${carbonPrefix}--loading--stop`]: internalState === STATES.ENDING },
12
+ ]"
13
+ @animationend="onLoadingEnd"
14
+ >
15
+ <div
16
+ v-show="internalActive"
17
+ :class="`${carbonPrefix}--loading ${carbonPrefix}--loading--small`"
18
+ >
19
+ <cv-loading
20
+ :class="`${carbonPrefix}--inline-loading__animation`"
21
+ :description="description"
22
+ :active="undefined"
23
+ :small="true"
24
+ />
25
+ </div>
26
+ <checkmark-filled16
27
+ v-if="internalState === STATES.LOADED"
28
+ :class="`${carbonPrefix}--inline-loading__checkmark-container`"
29
+ />
30
+ <error-filled16
31
+ v-if="internalState === STATES.ERROR"
32
+ :class="`${carbonPrefix}--inline-loading--error`"
33
+ />
34
+ </div>
35
+ <p :class="`${carbonPrefix}--inline-loading__text`">{{ stateText }}</p>
36
+ </div>
37
+ </template>
38
+
39
+ <script setup>
40
+ import { STATES } from './consts';
41
+ import ErrorFilled16 from '@carbon/icons-vue/lib/error--filled/16';
42
+ import CheckmarkFilled16 from '@carbon/icons-vue/lib/checkmark--filled/16';
43
+ import { carbonPrefix } from '../../global/settings';
44
+ import CvLoading from '../CvLoading/CvLoading.vue';
45
+ import { computed, ref, watch } from 'vue';
46
+
47
+ const props = defineProps({
48
+ /**
49
+ * Deprecated: Please use state property
50
+ * @deprecated
51
+ */
52
+ active: {
53
+ type: Boolean,
54
+ default: undefined,
55
+ deprecated: true,
56
+ validator: val => {
57
+ if (val !== undefined && process.env.NODE_ENV === 'development') {
58
+ console.warn(
59
+ 'CvInlineLoading: active prop deprecated in favour of state prop'
60
+ );
61
+ }
62
+ return true;
63
+ },
64
+ },
65
+ /**
66
+ * Specify the description for the inline loading text
67
+ */
68
+ description: { type: String, default: 'Loading' },
69
+ /**
70
+ * Specify the text to show while the loading is ending (state: 'ending')
71
+ */
72
+ endingText: { type: String, default: 'Load ending...' },
73
+ /**
74
+ * Specify the text to show for the error state (state: 'error')
75
+ */
76
+ errorText: { type: String, default: 'Loading data failed.' },
77
+ /**
78
+ * Specify the text to show while loading (state: 'loading')
79
+ */
80
+ loadingText: { type: String, default: 'Loading data...' },
81
+ /**
82
+ * Specify the text to show while loading (state: 'loaded')
83
+ */
84
+ loadedText: { type: String, default: 'Data loaded.' },
85
+ /**
86
+ * Specify the loading status
87
+ * @values ['loading','ending','loaded','error']
88
+ */
89
+ state: {
90
+ type: String,
91
+ default: STATES.LOADING,
92
+ required: true,
93
+ validator: val => {
94
+ if (Object.values(STATES).includes(val)) {
95
+ return true;
96
+ } else {
97
+ console.error(
98
+ `CvInlineLoading: Valid states are ${Object.values(STATES)}`
99
+ );
100
+ return false;
101
+ }
102
+ },
103
+ },
104
+ });
105
+ const internalState = ref(stateFromProps());
106
+ function stateFromProps() {
107
+ if (props.state.includes(':')) {
108
+ return props.state.split(':')[0];
109
+ } else {
110
+ return props.state;
111
+ }
112
+ }
113
+ watch(
114
+ () => props.state,
115
+ () => {
116
+ internalState.value = stateFromProps();
117
+ }
118
+ );
119
+ function onLoadingEnd(ev) {
120
+ if (ev.animationName === 'rotate-end-p2' && props.state.includes(':')) {
121
+ internalState.value = props.state.split(':')[1];
122
+ }
123
+ }
124
+ const internalActive = computed(() => {
125
+ if (props.active !== undefined) {
126
+ return props.active;
127
+ } else {
128
+ return [STATES.LOADING, STATES.ENDING].includes(internalState.value);
129
+ }
130
+ });
131
+
132
+ const stateText = computed(() => {
133
+ switch (internalState.value) {
134
+ case STATES.LOADED:
135
+ return props.loadedText;
136
+ case STATES.ERROR:
137
+ return props.errorText;
138
+ case STATES.ENDING:
139
+ return props.endingText;
140
+ default:
141
+ return props.loadingText;
142
+ }
143
+ });
144
+ </script>
@@ -0,0 +1,9 @@
1
+ const STATES = {
2
+ LOADED: 'loaded',
3
+ ERROR: 'error',
4
+ LOADING: 'loading',
5
+ ENDING: 'ending',
6
+ ENDING_LOADED: 'ending:loaded',
7
+ ENDING_ERROR: 'ending:error',
8
+ };
9
+ export { STATES };
@@ -0,0 +1,4 @@
1
+ import CvInlineLoading from './CvInlineLoading.vue';
2
+ import { STATES } from './consts';
3
+
4
+ export { CvInlineLoading, STATES };