@carbon/vue 3.0.7-alpha.0 → 3.0.8-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.
- package/README.md +7 -0
- package/dist/carbon-vue-3.common.js +3438 -177
- package/dist/carbon-vue-3.common.js.map +1 -1
- package/dist/carbon-vue-3.umd.js +3438 -177
- package/dist/carbon-vue-3.umd.js.map +1 -1
- package/dist/carbon-vue-3.umd.min.js +4 -4
- package/dist/carbon-vue-3.umd.min.js.map +1 -1
- package/package.json +7 -4
- package/src/components/CvCheckbox/CvCheckbox.stories.js +18 -7
- package/src/components/CvCheckbox/CvCheckbox.vue +19 -3
- package/src/components/CvCheckbox/CvCheckboxSkeleton.vue +16 -0
- package/src/components/CvCheckbox/__tests__/__snapshots__/CvCheckboxSkeleton.spec.js.snap +3 -0
- package/src/components/CvCheckbox/index.js +2 -1
- package/src/components/CvDropdown/CvDropdown.vue +0 -2
- package/src/components/CvFileUploader/CvFileUploader.stories.mdx +333 -0
- package/src/components/CvFileUploader/CvFileUploader.vue +286 -0
- package/src/components/CvFileUploader/CvFileUploaderItem.vue +92 -0
- package/src/components/CvFileUploader/CvFileUploaderSkeleton.vue +16 -0
- package/src/components/CvFileUploader/const.js +10 -0
- package/src/components/CvFileUploader/index.js +5 -0
- package/src/components/CvMultiSelect/CvMultiSelect.stories.mdx +1 -1
- package/src/components/CvProgress/CvProgress.stories.mdx +202 -0
- package/src/components/CvProgress/CvProgress.vue +78 -0
- package/src/components/CvProgress/CvProgressStep.vue +124 -0
- package/src/components/CvProgress/index.js +4 -0
- package/src/components/CvRadioButton/CvRadioButton.stories.js +166 -0
- package/src/components/CvRadioButton/CvRadioButton.vue +57 -0
- package/src/components/CvRadioButton/CvRadioGroup.vue +27 -0
- package/src/components/CvRadioButton/__tests__/__snapshots__/CvRadioButton.spec.js.snap +27 -0
- package/src/components/CvRadioButton/index.js +6 -0
- package/src/components/CvSearch/CvSearch.stories.mdx +168 -0
- package/src/components/CvSearch/CvSearch.vue +250 -0
- package/src/components/CvSearch/index.js +3 -0
- package/src/components/CvSelect/CvSelect.vue +27 -6
- package/src/components/CvSlider/CvSlider.stories.js +166 -0
- package/src/components/CvSlider/CvSlider.vue +324 -0
- package/src/components/CvSlider/CvSliderSkeleton.stories.js +26 -0
- package/src/components/CvSlider/CvSliderSkeleton.vue +18 -0
- package/src/components/CvSlider/__tests__/__snapshots__/CvSlider.spec.js.snap +13 -0
- package/src/components/CvSlider/__tests__/__snapshots__/CvSliderSkeleton.spec.js.snap +13 -0
- package/src/components/CvSlider/index.js +5 -0
- package/src/components/CvSlider/sbSliderPrefix.js +2 -0
- package/src/components/CvTextArea/CvTextArea.stories.js +2 -2
- package/src/components/CvTextArea/CvTextAreaSkeleton.stories.js +29 -0
- package/src/components/CvTextArea/CvTextAreaSkeleton.vue +10 -0
- package/src/components/CvTextArea/StorybookGroupConst.js +1 -0
- package/src/components/CvTextArea/__tests__/__snapshots__/CvTextAreaSkeleton.spec.js.snap +7 -0
- package/src/components/CvTextArea/index.js +2 -1
- package/src/components/CvTimePicker/CvTimePicker.stories.mdx +325 -0
- package/src/components/CvTimePicker/CvTimePicker.vue +217 -0
- package/src/components/CvTimePicker/index.js +21 -0
- package/src/components/CvToggle/CvToggle-Skeleton.vue +27 -12
- package/src/components/CvToggle/CvToggle.stories.js +20 -3
- package/src/components/CvToggle/CvToggle.vue +22 -5
- package/src/components/CvToggle/__tests__/__snapshots__/CvToggle.spec.js.snap +3 -3
- package/src/components/CvTooltip/CvDefinitionTooltip.stories.js +80 -0
- package/src/components/CvTooltip/CvDefinitionTooltip.vue +61 -0
- package/src/components/CvTooltip/CvInteractiveTooltip.stories.js +90 -0
- package/src/components/CvTooltip/CvInteractiveTooltip.vue +267 -0
- package/src/components/CvTooltip/CvTooltip.stories.js +128 -0
- package/src/components/CvTooltip/CvTooltip.vue +44 -0
- package/src/components/CvTooltip/__tests__/__snapshots__/CvTooltip.spec.js.snap +525 -0
- package/src/components/CvTooltip/consts.js +15 -0
- package/src/components/CvTooltip/index.js +6 -0
- package/src/components/CvTooltip/sbTooltipPrefix.js +2 -0
- package/src/components/CvUIShell/CvSideNav.vue +10 -1
- package/src/components/CvUIShell/CvUIShell.stories.mdx +116 -50
- package/src/index.d.ts +6 -0
- package/src/index.js +11 -0
- package/src/use/cvCheck.js +3 -0
- package/src/use/index.js +2 -0
- package/src/use/useMethods.js +18 -0
- package/src/use/useRadio.js +25 -0
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
import { Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
2
|
import { sbCompPrefix } from '../../global/storybook-utils';
|
|
3
3
|
import { action } from '@storybook/addon-actions';
|
|
4
|
-
import CvHeader from './CvHeader.vue'
|
|
5
|
-
import CvSkipToContent from
|
|
6
|
-
import CvHeaderName from
|
|
7
|
-
import CvHeaderNav from
|
|
8
|
-
import CvHeaderMenuItem from
|
|
9
|
-
import CvHeaderMenuButton from
|
|
10
|
-
import CvHeaderMenu from
|
|
11
|
-
import CvHeaderGlobalAction from
|
|
12
|
-
import CvHeaderPanel from
|
|
13
|
-
import CvSwitcher from
|
|
14
|
-
import CvSwitcherItem from
|
|
15
|
-
import CvSwitcherItemLink from
|
|
16
|
-
import CvSideNav from
|
|
17
|
-
import CvSideNavItems from
|
|
18
|
-
import CvSideNavLink from
|
|
19
|
-
import CvSideNavMenu from
|
|
20
|
-
import CvSideNavMenuDivider from
|
|
21
|
-
import CvSideNavMenuItem from
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
import CvHeader from './CvHeader.vue';
|
|
5
|
+
import CvSkipToContent from './CvSkipToContent.vue';
|
|
6
|
+
import CvHeaderName from './CvHeaderName.vue';
|
|
7
|
+
import CvHeaderNav from './CvHeaderNav.vue';
|
|
8
|
+
import CvHeaderMenuItem from './CvHeaderMenuItem.vue';
|
|
9
|
+
import CvHeaderMenuButton from './CvHeaderMenuButton.vue';
|
|
10
|
+
import CvHeaderMenu from './CvHeaderMenu.vue';
|
|
11
|
+
import CvHeaderGlobalAction from './CvHeaderGlobalAction.vue';
|
|
12
|
+
import CvHeaderPanel from './CvHeaderPanel.vue';
|
|
13
|
+
import CvSwitcher from './CvSwitcher.vue';
|
|
14
|
+
import CvSwitcherItem from './CvSwitcherItem.vue';
|
|
15
|
+
import CvSwitcherItemLink from './CvSwitcherItemLink.vue';
|
|
16
|
+
import CvSideNav from './CvSideNav.vue';
|
|
17
|
+
import CvSideNavItems from './CvSideNavItems.vue';
|
|
18
|
+
import CvSideNavLink from './CvSideNavLink.vue';
|
|
19
|
+
import CvSideNavMenu from './CvSideNavMenu.vue';
|
|
20
|
+
import CvSideNavMenuDivider from './CvSideNavMenuDivider.vue';
|
|
21
|
+
import CvSideNavMenuItem from './CvSideNavMenuItem.vue';
|
|
22
|
+
import {
|
|
23
|
+
Notification20,
|
|
24
|
+
UserAvatar20,
|
|
25
|
+
Login20,
|
|
26
|
+
Switcher20,
|
|
27
|
+
Home16,
|
|
28
|
+
ChatBot16,
|
|
29
|
+
ConnectionTwoWay16,
|
|
30
|
+
MachineLearningModel16,
|
|
31
|
+
} from '@carbon/icons-vue';
|
|
32
|
+
import { ref } from 'vue';
|
|
33
|
+
const loggedIn = ref(false);
|
|
25
34
|
|
|
26
35
|
<Meta title={`${sbCompPrefix}/ui-select/CvHeader`} component={CvHeader} />
|
|
27
36
|
|
|
@@ -53,18 +62,20 @@ export const Template = args => ({
|
|
|
53
62
|
Home16,
|
|
54
63
|
ChatBot16,
|
|
55
64
|
ConnectionTwoWay16,
|
|
56
|
-
MachineLearningModel16
|
|
65
|
+
MachineLearningModel16,
|
|
57
66
|
},
|
|
58
67
|
// The story's `args` need to be mapped into the template through the `setup()` method
|
|
59
68
|
setup() {
|
|
60
69
|
return {
|
|
61
|
-
|
|
70
|
+
...args,
|
|
62
71
|
actionNotifications: () => {},
|
|
63
|
-
actionUserAvatar: () => {
|
|
72
|
+
actionUserAvatar: () => {
|
|
73
|
+
loggedIn.value = !loggedIn.value;
|
|
74
|
+
},
|
|
64
75
|
actionAppSwitcher: () => {},
|
|
65
76
|
onPanelResize: action('panel-resize'),
|
|
66
|
-
loggedIn
|
|
67
|
-
}
|
|
77
|
+
loggedIn,
|
|
78
|
+
};
|
|
68
79
|
},
|
|
69
80
|
// And then the `args` are bound to your component with `v-bind="args"`
|
|
70
81
|
template: args.template,
|
|
@@ -151,7 +162,7 @@ const defaultTemplate = `
|
|
|
151
162
|
</cv-header-panel>
|
|
152
163
|
</template>
|
|
153
164
|
</cv-header>
|
|
154
|
-
|
|
165
|
+
`;
|
|
155
166
|
const railTemplate = `
|
|
156
167
|
<cv-header aria-label="Carbon header">
|
|
157
168
|
<cv-header-menu-button aria-label="Header menu" aria-controls="side-nav" :active="expandedSideNav"/>
|
|
@@ -185,7 +196,7 @@ const railTemplate = `
|
|
|
185
196
|
</cv-side-nav>
|
|
186
197
|
</template>
|
|
187
198
|
</cv-header>
|
|
188
|
-
|
|
199
|
+
`;
|
|
189
200
|
const fixedSideNavTemplate = `
|
|
190
201
|
<cv-header aria-label="Carbon header">
|
|
191
202
|
<cv-skip-to-content href="#main-content">
|
|
@@ -220,21 +231,25 @@ const fixedSideNavTemplate = `
|
|
|
220
231
|
</cv-side-nav-link>
|
|
221
232
|
</cv-side-nav-items>
|
|
222
233
|
</cv-side-nav>
|
|
223
|
-
|
|
234
|
+
`;
|
|
224
235
|
|
|
225
236
|
# UI Shell components
|
|
237
|
+
|
|
226
238
|
Set of components for managing navigation and header bars.
|
|
227
239
|
|
|
228
240
|
## CvHeader
|
|
241
|
+
|
|
229
242
|
Slots:
|
|
243
|
+
|
|
230
244
|
- default - buttons links etc
|
|
231
245
|
- header-global - Global button content
|
|
232
246
|
- left-panels - Content panel on the left - side nav
|
|
233
247
|
- right-panels - Right panel content - users, languages, notifications, switcher, etc
|
|
234
248
|
|
|
235
|
-
|
|
236
249
|
## CvHeaderGlobalAction
|
|
250
|
+
|
|
237
251
|
Properties:
|
|
252
|
+
|
|
238
253
|
- active - `Boolean` - Specify whether the menu button is "active".
|
|
239
254
|
- ariaControls - `String` Specify the id of a panel that this button controls
|
|
240
255
|
- label - `String` - button label
|
|
@@ -242,23 +257,31 @@ Properties:
|
|
|
242
257
|
- tipAlignment - `String` - `start`, `center`, `end`. Default `center`
|
|
243
258
|
|
|
244
259
|
Slots:
|
|
260
|
+
|
|
245
261
|
- icon - Icon for the action
|
|
246
262
|
|
|
247
263
|
## CvHeaderMenu
|
|
264
|
+
|
|
248
265
|
Properties:
|
|
266
|
+
|
|
249
267
|
- title - `String` - Provide a label for the link text
|
|
250
268
|
- hoverToggle - `Boolean` - activate the menu on hover. Default `true`
|
|
251
269
|
|
|
252
270
|
Slots:
|
|
271
|
+
|
|
253
272
|
- default - menu content
|
|
254
273
|
|
|
255
274
|
## CvHeaderMenuButton
|
|
275
|
+
|
|
256
276
|
Properties:
|
|
277
|
+
|
|
257
278
|
- active - `Boolean` - Specify whether the menu button is "active".
|
|
258
279
|
- ariaControls - **required** `String` Specify the id of a panel that this button controls
|
|
259
280
|
|
|
260
281
|
## CvHeaderMenuItem
|
|
282
|
+
|
|
261
283
|
Properties:
|
|
284
|
+
|
|
262
285
|
- disabled - `Boolean` link is disabled
|
|
263
286
|
- to - link router path
|
|
264
287
|
- href - `String` destination. If `to` is specified this value is ignored
|
|
@@ -267,36 +290,48 @@ Properties:
|
|
|
267
290
|
- role - `String` - role value for the main component. Default `undefned`
|
|
268
291
|
|
|
269
292
|
Slots:
|
|
293
|
+
|
|
270
294
|
- default - menu content
|
|
271
295
|
|
|
272
296
|
## CvHeaderName
|
|
297
|
+
|
|
273
298
|
Properties:
|
|
299
|
+
|
|
274
300
|
- prefix - `String` - Optionally specify a prefix to your header name. Useful for companies, for example: IBM [Product Name] versus solely [Product Name]
|
|
275
301
|
- disabled - `Boolean` link is disabled
|
|
276
302
|
- to - link router path
|
|
277
303
|
- href - `String` destination. If `to` is specified this value is ignored
|
|
278
304
|
|
|
279
305
|
Slots:
|
|
306
|
+
|
|
280
307
|
- default - header content
|
|
281
308
|
|
|
282
309
|
## CvHeaderNav
|
|
310
|
+
|
|
283
311
|
Properties:
|
|
284
|
-
|
|
312
|
+
|
|
313
|
+
- ariaLabelledBy - `String` `aria-labelledby` value
|
|
285
314
|
|
|
286
315
|
Slots:
|
|
316
|
+
|
|
287
317
|
- default - nav content
|
|
288
318
|
|
|
289
319
|
## CvHeaderPanel
|
|
320
|
+
|
|
290
321
|
Properties:
|
|
322
|
+
|
|
291
323
|
- **Migration Note** - The `v-model` has changed in Vue 3. To control expanded as a `v-model` specify `v-model:expanded`
|
|
292
324
|
- expanded - `Boolean` - Specify whether the panel is expanded
|
|
293
325
|
- id - `String` - **required** this id must match the `ariaControls` value of the button that controls this panel
|
|
294
326
|
|
|
295
327
|
Slots:
|
|
328
|
+
|
|
296
329
|
- default - panel content
|
|
297
330
|
|
|
298
331
|
## CvSideNav
|
|
332
|
+
|
|
299
333
|
Properties:
|
|
334
|
+
|
|
300
335
|
- **Migration Note** - The `v-model` has changed in Vue 3. To control expanded as a `v-model` specify `v-model:expanded`
|
|
301
336
|
- expanded - `Boolean` - Specify whether the panel is expanded
|
|
302
337
|
- id - `String` - **required** this id must match the `ariaControls` value of the button that controls this side nav
|
|
@@ -305,17 +340,23 @@ Properties:
|
|
|
305
340
|
- assistiveToggleText - `String` - Assistive text for a non-rail, non-fixed, non-header controlled side nav
|
|
306
341
|
|
|
307
342
|
Slots:
|
|
343
|
+
|
|
308
344
|
- default - nav content
|
|
309
345
|
|
|
310
346
|
## CvSideNavIcon
|
|
347
|
+
|
|
311
348
|
Properties:
|
|
349
|
+
|
|
312
350
|
- small - `Boolean` - Use a smaller icon
|
|
313
351
|
|
|
314
352
|
Slots:
|
|
353
|
+
|
|
315
354
|
- default - icon
|
|
316
355
|
|
|
317
356
|
## CvSideNavLink
|
|
357
|
+
|
|
318
358
|
Properties:
|
|
359
|
+
|
|
319
360
|
- active - `Boolean` - Specify whether the menu button is "active".
|
|
320
361
|
- icon - icon object to display with the link
|
|
321
362
|
- disabled - `Boolean` link is disabled
|
|
@@ -323,96 +364,120 @@ Properties:
|
|
|
323
364
|
- href - `String` destination. If `to` is specified this value is ignored
|
|
324
365
|
|
|
325
366
|
Slots:
|
|
367
|
+
|
|
326
368
|
- default - nav content
|
|
327
369
|
|
|
328
370
|
## CvSideNavMenu
|
|
371
|
+
|
|
329
372
|
Properties:
|
|
373
|
+
|
|
330
374
|
- active - `Boolean` - Specify whether the menu is "active".
|
|
331
375
|
- title - `String` - Provide a label for the link text
|
|
332
376
|
- expanded - `Boolean` - Specify whether the menu is expanded
|
|
333
377
|
|
|
334
378
|
Slots:
|
|
379
|
+
|
|
335
380
|
- default - menu content
|
|
336
381
|
- nav-icon - icon
|
|
337
382
|
|
|
338
383
|
## CvSideNavMenuDivider
|
|
384
|
+
|
|
339
385
|
Draw a divider line. No props or slots.
|
|
340
386
|
|
|
341
387
|
## CvSideNavMenuItem
|
|
388
|
+
|
|
342
389
|
Properties:
|
|
390
|
+
|
|
343
391
|
- active - `Boolean` - Specify whether the menu is "active".
|
|
344
392
|
- disabled - `Boolean` link is disabled
|
|
345
393
|
- to - Vue router path
|
|
346
394
|
- href - `String` destination. If `to` is specified this value is ignored
|
|
347
395
|
|
|
348
396
|
Slots:
|
|
397
|
+
|
|
349
398
|
- default - menu content
|
|
350
399
|
|
|
351
400
|
## CvSkipToContent
|
|
401
|
+
|
|
352
402
|
Properties:
|
|
403
|
+
|
|
353
404
|
- disabled - `Boolean` link is disabled
|
|
354
405
|
- to - Vue router path
|
|
355
406
|
- href - `String` destination. If `to` is specified this value is ignored
|
|
356
407
|
|
|
357
408
|
Slots:
|
|
409
|
+
|
|
358
410
|
- default - default "Skip to main content"
|
|
359
411
|
|
|
360
412
|
## CvSwitcher
|
|
413
|
+
|
|
361
414
|
Slots:
|
|
415
|
+
|
|
362
416
|
- default - include switcher content
|
|
363
417
|
|
|
364
418
|
## CvSwitcherItem
|
|
419
|
+
|
|
365
420
|
Slots:
|
|
421
|
+
|
|
366
422
|
- default - include switcher item content
|
|
367
423
|
|
|
368
424
|
## CvSwitcherItemLink
|
|
425
|
+
|
|
369
426
|
Properties:
|
|
427
|
+
|
|
370
428
|
- disabled - `Boolean` link is disabled
|
|
371
429
|
- to - Vue router path
|
|
372
430
|
- href - `String` destination. If `to` is specified this value is ignored
|
|
373
431
|
- selected - `Boolean` is this item selected
|
|
374
432
|
|
|
375
433
|
Slots:
|
|
376
|
-
- default - item content
|
|
377
434
|
|
|
435
|
+
- default - item content
|
|
378
436
|
|
|
379
437
|
<Canvas>
|
|
380
438
|
<Story
|
|
381
439
|
name="Default"
|
|
382
440
|
parameters={{
|
|
383
|
-
controls: {
|
|
441
|
+
controls: {
|
|
442
|
+
exclude: [
|
|
384
443
|
'template',
|
|
385
444
|
'default',
|
|
386
445
|
'header-global',
|
|
387
446
|
'left-panels',
|
|
388
|
-
'right-panels'
|
|
389
|
-
]
|
|
447
|
+
'right-panels',
|
|
448
|
+
],
|
|
449
|
+
},
|
|
390
450
|
docs: { source: { code: defaultTemplate.replace('v-bind="args"', '') } },
|
|
391
451
|
}}
|
|
392
452
|
args={{
|
|
393
453
|
template: defaultTemplate,
|
|
394
454
|
}}
|
|
395
|
-
argTypes={{
|
|
396
|
-
}}
|
|
455
|
+
argTypes={{}}
|
|
397
456
|
>
|
|
398
457
|
{Template.bind({})}
|
|
399
458
|
</Story>
|
|
400
459
|
</Canvas>
|
|
401
460
|
|
|
402
|
-
|
|
403
461
|
# CvHeader with side rail
|
|
404
462
|
|
|
463
|
+
Migration notes:
|
|
464
|
+
|
|
465
|
+
- The `panel-resize` event is emitted anytime the rail is expanded or collapsed including for hover events. In the Vue 2
|
|
466
|
+
version this event was only emitted when the "hamburger" menu button was clicked.
|
|
467
|
+
|
|
405
468
|
<Canvas>
|
|
406
469
|
<Story
|
|
407
470
|
name="Side rail"
|
|
408
471
|
parameters={{
|
|
409
|
-
controls: {
|
|
472
|
+
controls: {
|
|
473
|
+
exclude: [
|
|
410
474
|
'template',
|
|
411
475
|
'default',
|
|
412
476
|
'header-global',
|
|
413
477
|
'left-panels',
|
|
414
|
-
'right-panels'
|
|
415
|
-
]
|
|
478
|
+
'right-panels',
|
|
479
|
+
],
|
|
480
|
+
},
|
|
416
481
|
docs: { source: { code: railTemplate.replace('v-bind="args"', '') } },
|
|
417
482
|
}}
|
|
418
483
|
args={{
|
|
@@ -420,34 +485,35 @@ Slots:
|
|
|
420
485
|
useFixed: false,
|
|
421
486
|
expandedSideNav: false,
|
|
422
487
|
}}
|
|
423
|
-
argTypes={{
|
|
424
|
-
}}
|
|
488
|
+
argTypes={{}}
|
|
425
489
|
>
|
|
426
490
|
{Template.bind({})}
|
|
427
491
|
</Story>
|
|
428
492
|
</Canvas>
|
|
429
493
|
|
|
430
|
-
|
|
431
494
|
# CvHeader with fixed side nav
|
|
432
495
|
|
|
433
496
|
<Canvas>
|
|
434
497
|
<Story
|
|
435
498
|
name="Fixed side nav"
|
|
436
499
|
parameters={{
|
|
437
|
-
controls: {
|
|
500
|
+
controls: {
|
|
501
|
+
exclude: [
|
|
438
502
|
'template',
|
|
439
503
|
'default',
|
|
440
504
|
'header-global',
|
|
441
505
|
'left-panels',
|
|
442
|
-
'right-panels'
|
|
443
|
-
]
|
|
444
|
-
|
|
506
|
+
'right-panels',
|
|
507
|
+
],
|
|
508
|
+
},
|
|
509
|
+
docs: {
|
|
510
|
+
source: { code: fixedSideNavTemplate.replace('v-bind="args"', '') },
|
|
511
|
+
},
|
|
445
512
|
}}
|
|
446
513
|
args={{
|
|
447
514
|
template: fixedSideNavTemplate,
|
|
448
515
|
}}
|
|
449
|
-
argTypes={{
|
|
450
|
-
}}
|
|
516
|
+
argTypes={{}}
|
|
451
517
|
>
|
|
452
518
|
{Template.bind({})}
|
|
453
519
|
</Story>
|
package/src/index.d.ts
ADDED
package/src/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference path="index.d.ts" />
|
|
1
2
|
const ctx = require.context(
|
|
2
3
|
'./components/',
|
|
3
4
|
true,
|
|
@@ -13,6 +14,16 @@ const components = ctx.keys().map(k => {
|
|
|
13
14
|
export default {
|
|
14
15
|
// options is an array of components to be registered
|
|
15
16
|
// e.g. ['c-button', 'c-modal']
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {import("vue").App} App
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Install plugin in Vue
|
|
24
|
+
* @param {App} Vue
|
|
25
|
+
* @param {Array<string>} options
|
|
26
|
+
*/
|
|
16
27
|
install(Vue, options) {
|
|
17
28
|
if (typeof options === 'undefined') {
|
|
18
29
|
for (let c of components) {
|
package/src/use/cvCheck.js
CHANGED
|
@@ -5,6 +5,9 @@ import { unref, ref, computed, watch, onMounted } from 'vue';
|
|
|
5
5
|
|
|
6
6
|
export const props = {
|
|
7
7
|
modelValue: { type: [Array, Boolean], default: undefined },
|
|
8
|
+
/**
|
|
9
|
+
* Specify whether the Checkbox is in an indeterminate state
|
|
10
|
+
*/
|
|
8
11
|
mixed: { type: Boolean, default: null },
|
|
9
12
|
checked: { type: Boolean, default: undefined },
|
|
10
13
|
name: String,
|
package/src/use/index.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
export const useMethods = methodDefs => {
|
|
4
|
+
const methods = ref({});
|
|
5
|
+
|
|
6
|
+
const keys = Object.keys(methodDefs);
|
|
7
|
+
for (let key of keys) {
|
|
8
|
+
for (let method of methodDefs[key]) {
|
|
9
|
+
methods.value[method] = (...args) => {
|
|
10
|
+
methods.value.$refs[key][method](...args);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
methods,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { computed, inject } from 'vue';
|
|
2
|
+
|
|
3
|
+
export const useRadio = (props, emit) => {
|
|
4
|
+
const isChecked = computed(() => {
|
|
5
|
+
if (props.modelValue === undefined) {
|
|
6
|
+
return props.checked;
|
|
7
|
+
} else {
|
|
8
|
+
return props.modelValue === props.value;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const onRadioItemChange = inject('onRadioItemChange', () => {});
|
|
13
|
+
|
|
14
|
+
const onChange = () => {
|
|
15
|
+
onRadioItemChange(props.value); // emit to parent
|
|
16
|
+
|
|
17
|
+
emit('update:modelValue', props.value); // emit for v-model
|
|
18
|
+
emit('change', props.value);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
isChecked,
|
|
23
|
+
onChange,
|
|
24
|
+
};
|
|
25
|
+
};
|