@carbon/vue 2.45.0 → 3.0.4-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 +34 -264
- package/dist/carbon-vue-3.common.js +27392 -0
- package/dist/carbon-vue-3.common.js.map +1 -0
- package/dist/carbon-vue-3.umd.js +27403 -0
- package/dist/carbon-vue-3.umd.js.map +1 -0
- package/dist/carbon-vue-3.umd.min.js +17 -0
- package/dist/carbon-vue-3.umd.min.js.map +1 -0
- package/dist/demo.html +1 -34
- package/package.json +185 -62
- package/src/components/CvAccordion/CvAccordion.stories.js +54 -0
- package/src/components/CvAccordion/CvAccordion.vue +95 -0
- package/src/components/CvAccordion/CvAccordionItem.vue +101 -0
- package/src/components/{cv-accordion/cv-accordion-skeleton.vue → CvAccordion/CvAccordionSkeleton.vue} +14 -18
- package/src/components/CvAccordion/_CvAccordionItemSkeleton.vue +30 -0
- package/src/components/CvAccordion/consts.js +17 -0
- package/src/components/CvAccordion/index.js +6 -0
- package/src/components/CvAspectRatio/CvAspectRatio.stories.js +56 -0
- package/src/components/CvAspectRatio/CvAspectRatio.stories.scss +4 -0
- package/src/components/CvAspectRatio/CvAspectRatio.vue +33 -0
- package/src/components/CvAspectRatio/consts.js +2 -0
- package/src/components/CvAspectRatio/index.js +4 -0
- package/src/components/CvBreadcrumb/CvBreadcrumb.stories.js +75 -0
- package/src/components/CvBreadcrumb/CvBreadcrumb.vue +37 -0
- package/src/components/CvBreadcrumb/CvBreadcrumbItem.vue +28 -0
- package/src/components/CvBreadcrumb/CvBreadcrumbSkeleton.vue +29 -0
- package/src/components/CvBreadcrumb/CvBreadcrumbSkeletonItem.vue +14 -0
- package/src/components/CvBreadcrumb/index.js +11 -0
- package/src/components/CvButton/CvButton.stories.js +119 -0
- package/src/components/CvButton/CvButton.vue +68 -0
- package/src/components/CvButton/CvButtonCommon.js +75 -0
- package/src/components/CvButton/CvButtonSet.stories.js +36 -0
- package/src/components/CvButton/CvButtonSet.vue +30 -0
- package/src/components/CvButton/CvIconButton.stories.js +139 -0
- package/src/components/CvButton/CvIconButton.vue +88 -0
- package/src/components/CvButton/index.js +7 -0
- package/src/components/CvButton/sbBtnPrefix.js +2 -0
- package/src/components/CvCheckbox/CvCheckbox.stories.js +111 -0
- package/src/components/CvCheckbox/CvCheckbox.vue +73 -0
- package/src/components/CvCheckbox/index.js +3 -0
- package/src/components/CvCodeSnippet/CvCodeSnippet.stories.js +181 -0
- package/src/components/CvCodeSnippet/CvCodeSnippet.stories.scss +4 -0
- package/src/components/CvCodeSnippet/CvCodeSnippet.vue +125 -0
- package/src/components/CvCodeSnippet/CvCodeSnippetSkeleton.vue +43 -0
- package/src/components/CvCodeSnippet/_CviCodeSnippetInline.vue +72 -0
- package/src/components/CvCodeSnippet/_CviCodeSnippetMultiline.vue +199 -0
- package/src/components/CvCodeSnippet/_CviCodeSnippetOneline.vue +106 -0
- package/src/components/CvCodeSnippet/consts.js +2 -0
- package/src/components/CvCodeSnippet/index.js +4 -0
- package/src/components/CvComboBox/CvComboBox.stories.js +174 -0
- package/src/components/CvComboBox/CvComboBox.vue +460 -0
- package/src/components/CvComboBox/index.js +3 -0
- package/src/components/CvContentSwitcher/CvContentSwitcher.stories.mdx +196 -0
- package/src/components/CvContentSwitcher/CvContentSwitcher.vue +64 -0
- package/src/components/CvContentSwitcher/CvContentSwitcherButton.vue +117 -0
- package/src/components/CvContentSwitcher/CvContentSwitcherContent.vue +21 -0
- package/src/components/CvContentSwitcher/cvContentSwitcherStore.js +30 -0
- package/src/components/CvContentSwitcher/index.js +3 -0
- package/src/components/CvCopyButton/CvCopyButton.stories.js +28 -0
- package/src/components/CvCopyButton/CvCopyButton.vue +45 -0
- package/src/components/CvCopyButton/_CviCopyButton.vue +71 -0
- package/src/components/CvCopyButton/index.js +3 -0
- package/src/components/CvDataTable/CvDataTable.stories.mdx +304 -0
- package/src/components/CvDataTable/CvDataTable.vue +648 -0
- package/src/components/CvDataTable/CvDataTableAction.vue +22 -0
- package/src/components/CvDataTable/CvDataTableCell.vue +11 -0
- package/src/components/CvDataTable/CvDataTableHeading.vue +143 -0
- package/src/components/CvDataTable/CvDataTableRow.vue +139 -0
- package/src/components/CvDataTable/CvDataTableSkeleton.vue +48 -0
- package/src/components/CvDataTable/_CvDataTableRowInner.vue +169 -0
- package/src/components/CvDataTable/cvDataTableStore.js +340 -0
- package/src/components/CvDataTable/index.js +3 -0
- package/src/components/CvEmpty/_CvEmpty.vue +22 -0
- package/src/components/CvGrid/CvColumn.vue +85 -0
- package/src/components/CvGrid/CvGrid.vue +42 -0
- package/src/components/{cv-grid/cv-row.vue → CvGrid/CvRow.vue} +8 -12
- package/src/components/CvGrid/GvGrid.stories.mdx +217 -0
- package/src/components/CvGrid/_SbContainer.vue +22 -0
- package/src/components/CvGrid/_cvColumnValidation.js +48 -0
- package/src/components/CvLink/CvLink.stories.js +169 -0
- package/src/components/CvLink/CvLink.vue +38 -0
- package/src/components/CvLink/index.js +4 -0
- package/src/components/CvList/CvList.stories.js +88 -0
- package/src/components/CvList/CvList.vue +50 -0
- package/src/components/CvList/CvListItem.vue +12 -0
- package/src/components/CvList/index.js +4 -0
- package/src/components/CvLoading/CvLoading.stories.js +78 -0
- package/src/components/CvLoading/CvLoading.stories.scss +4 -0
- package/src/components/CvLoading/CvLoading.vue +106 -0
- package/src/components/CvLoading/index.js +4 -0
- package/src/components/CvNotification/CvInlineNotification.stories.js +109 -0
- package/src/components/CvNotification/CvInlineNotification.vue +102 -0
- package/src/components/CvNotification/CvToastNotification.stories.js +108 -0
- package/src/components/CvNotification/CvToastNotification.vue +88 -0
- package/src/components/CvNotification/consts.js +31 -0
- package/src/components/CvNotification/index.js +5 -0
- package/src/components/CvOverflowMenu/CvOverflowMenu.stories.mdx +119 -0
- package/src/components/CvOverflowMenu/CvOverflowMenu.vue +283 -0
- package/src/components/{cv-overflow-menu/cv-overflow-menu-item.vue → CvOverflowMenu/CvOverflowMenuItem.vue} +26 -20
- package/src/components/CvOverflowMenu/index.js +3 -0
- package/src/components/CvPagination/CvPagination.stories.mdx +160 -0
- package/src/components/CvPagination/CvPagination.vue +246 -0
- package/src/components/CvPagination/index.js +3 -0
- package/src/components/CvSelect/CvSelect.stories.mdx +227 -0
- package/src/components/CvSelect/CvSelect.vue +224 -0
- package/src/components/CvSelect/CvSelectOptgroup.vue +9 -0
- package/src/components/CvSelect/CvSelectOption.vue +22 -0
- package/src/components/CvSelect/index.js +3 -0
- package/src/components/CvSkeletonText/CvSkeletonText.stories.js +56 -0
- package/src/components/CvSkeletonText/CvSkeletonText.vue +63 -0
- package/src/components/CvSkeletonText/index.js +3 -0
- package/src/components/CvSvg/_CvSvg.vue +48 -0
- package/src/components/CvSvg/__tests__/_TestIcon.vue +19 -0
- package/src/components/CvSvg/__tests__/test-svg.svg +5 -0
- package/src/components/CvTag/CvTag.stories.js +64 -0
- package/src/components/CvTag/CvTag.vue +105 -0
- package/src/components/CvTag/consts.js +15 -0
- package/src/components/CvTag/index.js +5 -0
- package/src/components/CvUIShell/CvHeader.vue +203 -0
- package/src/components/CvUIShell/CvHeaderGlobalAction.vue +105 -0
- package/src/components/{cv-ui-shell/cv-header-menu.vue → CvUIShell/CvHeaderMenu.vue} +41 -37
- package/src/components/CvUIShell/CvHeaderMenuButton.vue +103 -0
- package/src/components/CvUIShell/CvHeaderMenuItem.vue +38 -0
- package/src/components/CvUIShell/CvHeaderName.vue +25 -0
- package/src/components/CvUIShell/CvHeaderNav.vue +18 -0
- package/src/components/CvUIShell/CvHeaderPanel.vue +106 -0
- package/src/components/CvUIShell/CvSideNav.vue +131 -0
- package/src/components/CvUIShell/CvSideNavIcon.vue +17 -0
- package/src/components/CvUIShell/CvSideNavItems.vue +22 -0
- package/src/components/CvUIShell/CvSideNavLink.vue +47 -0
- package/src/components/CvUIShell/CvSideNavMenu.vue +85 -0
- package/src/components/CvUIShell/CvSideNavMenuDivider.vue +7 -0
- package/src/components/CvUIShell/CvSideNavMenuItem.vue +31 -0
- package/src/components/CvUIShell/CvSkipToContent.vue +20 -0
- package/src/components/CvUIShell/CvSwitcher.vue +9 -0
- package/src/components/CvUIShell/CvSwitcherItem.vue +9 -0
- package/src/components/CvUIShell/CvSwitcherItemLink.vue +26 -0
- package/src/components/CvUIShell/CvUIShell.stories.mdx +454 -0
- package/src/components/{cv-ui-shell/_cv-side-nav-footer.vue → CvUIShell/_CvSideNavFooter.vue} +11 -15
- package/src/components/CvUIShell/_CvSideNavLinkText.vue +9 -0
- package/src/components/CvWrapper/CvWrapper.js +23 -0
- package/src/global/component-utils/event-bus.js +23 -0
- package/src/global/component-utils/validators.js +14 -0
- package/src/global/settings.js +5 -0
- package/src/global/storybook-utils/__tests__/story-source-code.js +162 -0
- package/src/global/storybook-utils/controls-from-props.js +72 -0
- package/src/global/storybook-utils/index.js +5 -0
- package/src/global/storybook-utils/sbCompPrefix.js +1 -0
- package/src/global/storybook-utils/split-slot-args.js +14 -0
- package/src/global/storybook-utils/story-source-code.js +52 -0
- package/src/index.js +13 -83
- package/src/use/components.js +24 -0
- package/src/use/cvCheck.js +94 -0
- package/src/use/cvId.js +57 -0
- package/src/use/cvLink.js +42 -0
- package/src/use/cvTheme.js +30 -0
- package/src/use/index.js +1 -0
- package/src/use/overflow.js +37 -0
- package/dist/carbon-vue.common.js +0 -23411
- package/dist/carbon-vue.common.js.map +0 -1
- package/dist/carbon-vue.umd.js +0 -23421
- package/dist/carbon-vue.umd.js.map +0 -1
- package/dist/carbon-vue.umd.min.js +0 -30
- package/dist/carbon-vue.umd.min.js.map +0 -1
- package/src/assets/images/component-icons.svg +0 -57
- package/src/assets/images/example-icon-svg.js +0 -10
- package/src/assets/images/example-icon.svg +0 -6
- package/src/assets/images/example-icons.svg +0 -6
- package/src/carbon.yml +0 -442
- package/src/components/cv-accordion/_cv-accordion-item-skeleton.vue +0 -29
- package/src/components/cv-accordion/cv-accordion-item.vue +0 -87
- package/src/components/cv-accordion/cv-accordion.vue +0 -59
- package/src/components/cv-accordion/index.js +0 -5
- package/src/components/cv-aspect-ratio/cv-aspect-ratio.vue +0 -28
- package/src/components/cv-aspect-ratio/index.js +0 -2
- package/src/components/cv-breadcrumb/_cv-breadcrumb-item-skeleton.vue +0 -13
- package/src/components/cv-breadcrumb/cv-breadcrumb-item.vue +0 -28
- package/src/components/cv-breadcrumb/cv-breadcrumb-skeleton.vue +0 -30
- package/src/components/cv-breadcrumb/cv-breadcrumb.vue +0 -21
- package/src/components/cv-breadcrumb/index.js +0 -5
- package/src/components/cv-button/button-mixin.js +0 -91
- package/src/components/cv-button/cv-button-set.vue +0 -17
- package/src/components/cv-button/cv-button-skeleton.vue +0 -12
- package/src/components/cv-button/cv-button.vue +0 -19
- package/src/components/cv-button/cv-icon-button.vue +0 -42
- package/src/components/cv-button/index.js +0 -6
- package/src/components/cv-checkbox/cv-checkbox-skeleton.vue +0 -15
- package/src/components/cv-checkbox/cv-checkbox.vue +0 -70
- package/src/components/cv-checkbox/index.js +0 -3
- package/src/components/cv-code-snippet/_cv-code-snippet-inline.vue +0 -39
- package/src/components/cv-code-snippet/_cv-code-snippet-multiline.vue +0 -79
- package/src/components/cv-code-snippet/_cv-code-snippet-oneline.vue +0 -47
- package/src/components/cv-code-snippet/cv-code-snippet-skeleton.vue +0 -30
- package/src/components/cv-code-snippet/cv-code-snippet.vue +0 -83
- package/src/components/cv-code-snippet/index.js +0 -3
- package/src/components/cv-combo-box/cv-combo-box.vue +0 -386
- package/src/components/cv-combo-box/index.js +0 -3
- package/src/components/cv-content-switcher/cv-content-switcher-button.vue +0 -104
- package/src/components/cv-content-switcher/cv-content-switcher-content.vue +0 -26
- package/src/components/cv-content-switcher/cv-content-switcher-store.js +0 -22
- package/src/components/cv-content-switcher/cv-content-switcher.vue +0 -117
- package/src/components/cv-content-switcher/index.js +0 -4
- package/src/components/cv-data-table/_cv-data-table-row-inner.vue +0 -139
- package/src/components/cv-data-table/cv-data-table-action.vue +0 -25
- package/src/components/cv-data-table/cv-data-table-cell.vue +0 -14
- package/src/components/cv-data-table/cv-data-table-heading.vue +0 -109
- package/src/components/cv-data-table/cv-data-table-row.vue +0 -113
- package/src/components/cv-data-table/cv-data-table-skeleton.vue +0 -64
- package/src/components/cv-data-table/cv-data-table.vue +0 -525
- package/src/components/cv-data-table/index.js +0 -8
- package/src/components/cv-date-picker/cv-date-picker.vue +0 -362
- package/src/components/cv-date-picker/index.js +0 -3
- package/src/components/cv-date-picker/plugins/appendToPlugin.js +0 -52
- package/src/components/cv-date-picker/plugins/fixEventsPlugin.js +0 -75
- package/src/components/cv-date-picker/plugins/monthSelectPlugin.js +0 -66
- package/src/components/cv-date-picker/plugins/rangePlugin.js +0 -45
- package/src/components/cv-dropdown/cv-dropdown-item.vue +0 -84
- package/src/components/cv-dropdown/cv-dropdown-skeleton.vue +0 -20
- package/src/components/cv-dropdown/cv-dropdown.vue +0 -373
- package/src/components/cv-dropdown/index.js +0 -5
- package/src/components/cv-feedback-button/_cv-feedback-button.vue +0 -74
- package/src/components/cv-file-uploader/consts.js +0 -12
- package/src/components/cv-file-uploader/cv-file-uploader-skeleton.vue +0 -22
- package/src/components/cv-file-uploader/cv-file-uploader.vue +0 -348
- package/src/components/cv-file-uploader/index.js +0 -5
- package/src/components/cv-form/cv-form-group.vue +0 -32
- package/src/components/cv-form/cv-form-item.vue +0 -13
- package/src/components/cv-form/cv-form.vue +0 -13
- package/src/components/cv-form/index.js +0 -5
- package/src/components/cv-grid/cv-column.vue +0 -77
- package/src/components/cv-grid/cv-grid.vue +0 -32
- package/src/components/cv-grid/index.js +0 -5
- package/src/components/cv-icon/_cv-icon.vue +0 -30
- package/src/components/cv-inline-loading/consts.js +0 -8
- package/src/components/cv-inline-loading/cv-inline-loading.vue +0 -91
- package/src/components/cv-inline-loading/index.js +0 -4
- package/src/components/cv-inline-notification/cv-inline-notification.vue +0 -89
- package/src/components/cv-inline-notification/index.js +0 -3
- package/src/components/cv-link/cv-link.vue +0 -30
- package/src/components/cv-link/index.js +0 -3
- package/src/components/cv-list/cv-list-item.vue +0 -13
- package/src/components/cv-list/cv-list.vue +0 -42
- package/src/components/cv-list/index.js +0 -4
- package/src/components/cv-loading/cv-loading.vue +0 -86
- package/src/components/cv-loading/index.js +0 -3
- package/src/components/cv-modal/cv-modal.vue +0 -295
- package/src/components/cv-modal/index.js +0 -2
- package/src/components/cv-multi-select/cv-multi-select.vue +0 -484
- package/src/components/cv-multi-select/index.js +0 -3
- package/src/components/cv-number-input/cv-number-input-skeleton.vue +0 -14
- package/src/components/cv-number-input/cv-number-input.vue +0 -215
- package/src/components/cv-number-input/index.js +0 -3
- package/src/components/cv-overflow-menu/cv-overflow-menu.vue +0 -253
- package/src/components/cv-overflow-menu/index.js +0 -4
- package/src/components/cv-pagination/cv-pagination.vue +0 -268
- package/src/components/cv-pagination/index.js +0 -2
- package/src/components/cv-progress/cv-progress-step.vue +0 -135
- package/src/components/cv-progress/cv-progress.vue +0 -82
- package/src/components/cv-progress/index.js +0 -4
- package/src/components/cv-radio-button/cv-radio-button.vue +0 -40
- package/src/components/cv-radio-button/cv-radio-group.vue +0 -24
- package/src/components/cv-radio-button/index.js +0 -4
- package/src/components/cv-search/cv-search.vue +0 -194
- package/src/components/cv-search/index.js +0 -2
- package/src/components/cv-select/cv-select-optgroup.vue +0 -14
- package/src/components/cv-select/cv-select-option.vue +0 -14
- package/src/components/cv-select/cv-select.vue +0 -158
- package/src/components/cv-select/index.js +0 -4
- package/src/components/cv-skeleton-text/cv-skeleton-text.vue +0 -64
- package/src/components/cv-skeleton-text/index.js +0 -2
- package/src/components/cv-slider/cv-slider-skeleton.vue +0 -22
- package/src/components/cv-slider/cv-slider.vue +0 -247
- package/src/components/cv-slider/index.js +0 -4
- package/src/components/cv-structured-list/_cv-structured-list-item-selectable.vue +0 -37
- package/src/components/cv-structured-list/_cv-structured-list-item-standard.vue +0 -13
- package/src/components/cv-structured-list/cv-structured-list-data.vue +0 -23
- package/src/components/cv-structured-list/cv-structured-list-heading.vue +0 -13
- package/src/components/cv-structured-list/cv-structured-list-item.vue +0 -46
- package/src/components/cv-structured-list/cv-structured-list.vue +0 -38
- package/src/components/cv-structured-list/index.js +0 -5
- package/src/components/cv-svg/_cv-svg.vue +0 -38
- package/src/components/cv-tabs/cv-tab.vue +0 -68
- package/src/components/cv-tabs/cv-tabs-skeleton.vue +0 -20
- package/src/components/cv-tabs/cv-tabs.vue +0 -410
- package/src/components/cv-tabs/index.js +0 -5
- package/src/components/cv-tag/cv-tag-skeleton.vue +0 -19
- package/src/components/cv-tag/cv-tag.vue +0 -121
- package/src/components/cv-tag/index.js +0 -4
- package/src/components/cv-text-area/cv-text-area.vue +0 -98
- package/src/components/cv-text-area/index.js +0 -2
- package/src/components/cv-text-input/cv-text-input.vue +0 -173
- package/src/components/cv-text-input/index.js +0 -2
- package/src/components/cv-tile/_cv-tile-clickable.vue +0 -22
- package/src/components/cv-tile/_cv-tile-expandable.vue +0 -92
- package/src/components/cv-tile/_cv-tile-selectable.vue +0 -48
- package/src/components/cv-tile/_cv-tile-standard.vue +0 -11
- package/src/components/cv-tile/cv-tile.vue +0 -83
- package/src/components/cv-tile/index.js +0 -2
- package/src/components/cv-time-picker/cv-time-picker.vue +0 -138
- package/src/components/cv-time-picker/index.js +0 -2
- package/src/components/cv-toast-notification/cv-toast-notification.vue +0 -72
- package/src/components/cv-toast-notification/index.js +0 -2
- package/src/components/cv-toggle/cv-toggle-skeleton.vue +0 -25
- package/src/components/cv-toggle/cv-toggle.vue +0 -52
- package/src/components/cv-toggle/index.js +0 -3
- package/src/components/cv-toolbar/cv-toolbar-divider.vue +0 -11
- package/src/components/cv-toolbar/cv-toolbar-option.vue +0 -16
- package/src/components/cv-toolbar/cv-toolbar-search.vue +0 -40
- package/src/components/cv-toolbar/cv-toolbar-title.vue +0 -14
- package/src/components/cv-toolbar/cv-toolbar.vue +0 -13
- package/src/components/cv-toolbar/index.js +0 -6
- package/src/components/cv-tooltip/consts.js +0 -2
- package/src/components/cv-tooltip/cv-definition-tooltip.vue +0 -44
- package/src/components/cv-tooltip/cv-interactive-tooltip.vue +0 -241
- package/src/components/cv-tooltip/cv-tooltip.vue +0 -44
- package/src/components/cv-tooltip/index.js +0 -6
- package/src/components/cv-ui-shell/_cv-side-nav-link-text.vue +0 -13
- package/src/components/cv-ui-shell/cv-content.vue +0 -16
- package/src/components/cv-ui-shell/cv-header-global-action.vue +0 -84
- package/src/components/cv-ui-shell/cv-header-menu-button.vue +0 -80
- package/src/components/cv-ui-shell/cv-header-menu-item.vue +0 -36
- package/src/components/cv-ui-shell/cv-header-name.vue +0 -18
- package/src/components/cv-ui-shell/cv-header-nav.vue +0 -18
- package/src/components/cv-ui-shell/cv-header-panel.vue +0 -72
- package/src/components/cv-ui-shell/cv-header-side-nav-items.vue +0 -21
- package/src/components/cv-ui-shell/cv-header.vue +0 -119
- package/src/components/cv-ui-shell/cv-side-nav-divider.vue +0 -12
- package/src/components/cv-ui-shell/cv-side-nav-icon.vue +0 -16
- package/src/components/cv-ui-shell/cv-side-nav-items.vue +0 -21
- package/src/components/cv-ui-shell/cv-side-nav-link.vue +0 -54
- package/src/components/cv-ui-shell/cv-side-nav-menu-item.vue +0 -30
- package/src/components/cv-ui-shell/cv-side-nav-menu.vue +0 -84
- package/src/components/cv-ui-shell/cv-side-nav.vue +0 -97
- package/src/components/cv-ui-shell/cv-skip-to-content.vue +0 -19
- package/src/components/cv-ui-shell/cv-switcher-item-link.vue +0 -26
- package/src/components/cv-ui-shell/cv-switcher-item.vue +0 -13
- package/src/components/cv-ui-shell/cv-switcher.vue +0 -13
- package/src/components/cv-ui-shell/index.js +0 -45
- package/src/components/cv-wrapper/_cv-wrapper.js +0 -33
- package/src/directives/clickout.js +0 -29
- package/src/index-components-vue.js +0 -5
- package/src/internal/feature-flags.js +0 -22
- package/src/mixins/carbon-prefix-mixin.js +0 -7
- package/src/mixins/check-mixin.js +0 -106
- package/src/mixins/index.js +0 -12
- package/src/mixins/link-mixin.js +0 -23
- package/src/mixins/methods-mixin.js +0 -18
- package/src/mixins/notification-mixin.js +0 -18
- package/src/mixins/radio-mixin.js +0 -36
- package/src/mixins/theme-mixin.js +0 -23
- package/src/mixins/uid-mixin.js +0 -23
- package/src/thumbnails/inline-notification.svg +0 -23
- package/src/thumbnails/skeleton-text.svg +0 -15
- package/src/thumbnails/toast-notification.svg +0 -34
- /package/src/components/{cv-button → CvButton}/consts.js +0 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
|
+
import { CvContentSwitcher } from '.';
|
|
3
|
+
import CvContentSwitcherButton from './CvContentSwitcherButton.vue';
|
|
4
|
+
import CvContentSwitcherContent from './CvContentSwitcherContent.vue';
|
|
5
|
+
import { IbmSecurity20 } from '@carbon/icons-vue';
|
|
6
|
+
import { action } from '@storybook/addon-actions';
|
|
7
|
+
import { sbCompPrefix, storyParametersObject } from '../../global/storybook-utils';
|
|
8
|
+
|
|
9
|
+
<Meta title={`${sbCompPrefix}/CvContentSwitcher`} component={CvContentSwitcher} />
|
|
10
|
+
|
|
11
|
+
export const Template = args => ({
|
|
12
|
+
// Components used in your story `template` are defined in the `components` object
|
|
13
|
+
components: {
|
|
14
|
+
CvContentSwitcher,
|
|
15
|
+
CvContentSwitcherButton,
|
|
16
|
+
CvContentSwitcherContent,
|
|
17
|
+
},
|
|
18
|
+
// The story's `args` need to be mapped into the template through the `setup()` method
|
|
19
|
+
setup() {
|
|
20
|
+
return {
|
|
21
|
+
args: { ...args.data },
|
|
22
|
+
iconSample: IbmSecurity20,
|
|
23
|
+
selectedIndex: args.selectedIndex,
|
|
24
|
+
onSelected: action('selected'),
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
// And then the `args` are bound to your component with `v-bind="args"`
|
|
28
|
+
template: args.template,
|
|
29
|
+
});
|
|
30
|
+
const defaultTemplate = `
|
|
31
|
+
<div>
|
|
32
|
+
<cv-content-switcher aria-label='Choose content' v-bind='args' @selected="onSelected">
|
|
33
|
+
<cv-content-switcher-button owner-id="csb-1" :selected="selectedIndex === 0">Button Name 1</cv-content-switcher-button>
|
|
34
|
+
<cv-content-switcher-button owner-id="csb-2" :selected="selectedIndex === 1">Button Name 2</cv-content-switcher-button>
|
|
35
|
+
<cv-content-switcher-button :icon="iconSample" owner-id="csb-3" :selected="selectedIndex === 2">Button Name 3</cv-content-switcher-button>
|
|
36
|
+
</cv-content-switcher>
|
|
37
|
+
<section style="margin: 10px 0;">
|
|
38
|
+
<cv-content-switcher-content owner-id="csb-1">
|
|
39
|
+
<p>This is the content for option 1</p>
|
|
40
|
+
</cv-content-switcher-content>
|
|
41
|
+
<cv-content-switcher-content owner-id="csb-2">
|
|
42
|
+
<p>This is the content for option 2</p>
|
|
43
|
+
</cv-content-switcher-content>
|
|
44
|
+
<cv-content-switcher-content owner-id="csb-2" >
|
|
45
|
+
<p>This is more content for option 2</p>
|
|
46
|
+
</cv-content-switcher-content>
|
|
47
|
+
<cv-content-switcher-content owner-id="csb-3">
|
|
48
|
+
<p>This is the content for option 3</p>
|
|
49
|
+
</cv-content-switcher-content>
|
|
50
|
+
</section>
|
|
51
|
+
</div>
|
|
52
|
+
`;
|
|
53
|
+
const defaultCode = defaultTemplate.replace("v-bind='args'", '');
|
|
54
|
+
const domTemplate = `
|
|
55
|
+
<div>
|
|
56
|
+
<cv-content-switcher aria-label='Choose content' v-bind='args' @selected="onSelected">
|
|
57
|
+
<cv-content-switcher-button content-selector=".content-1" :selected="selectedIndex === 0">Button Name 1</cv-content-switcher-button>
|
|
58
|
+
<cv-content-switcher-button content-selector=".content-2" :selected="selectedIndex === 1">Button Name 2</cv-content-switcher-button>
|
|
59
|
+
<cv-content-switcher-button :icon="iconSample" content-selector=".content-3" :selected="selectedIndex === 2">Button Name 3</cv-content-switcher-button>
|
|
60
|
+
</cv-content-switcher>
|
|
61
|
+
<section style="margin: 10px 0;">
|
|
62
|
+
<div class="content-1">
|
|
63
|
+
<p>This is the DOM content for option 1</p>
|
|
64
|
+
</div>
|
|
65
|
+
<div class="content-2">
|
|
66
|
+
<p>This is the DOM content for option 2</p>
|
|
67
|
+
</div>
|
|
68
|
+
<div class="content-2" >
|
|
69
|
+
<p>This is more DOM content for option 2</p>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="content-3">
|
|
72
|
+
<p>This is the DOM content for option 3</p>
|
|
73
|
+
</div>
|
|
74
|
+
</section>
|
|
75
|
+
</div>
|
|
76
|
+
`;
|
|
77
|
+
const domCode = domTemplate.replace("v-bind='args'", '');
|
|
78
|
+
const multipleTemplate = `
|
|
79
|
+
<div>
|
|
80
|
+
<cv-content-switcher aria-label='Choose content' v-bind='args' @selected="onSelected" id="star-wars">
|
|
81
|
+
<cv-content-switcher-button parent-switcher="star-wars" owner-id="episode-1" :selected="selectedIndex === 0">Episode 1</cv-content-switcher-button>
|
|
82
|
+
<cv-content-switcher-button parent-switcher="star-wars" owner-id="episode-2" :selected="selectedIndex === 1">Episode 2</cv-content-switcher-button>
|
|
83
|
+
<cv-content-switcher-button parent-switcher="star-wars" :icon="iconSample" owner-id="episode-3" :selected="selectedIndex === 2">Episode 3</cv-content-switcher-button>
|
|
84
|
+
</cv-content-switcher>
|
|
85
|
+
<section style="margin: 10px 0;">
|
|
86
|
+
<cv-content-switcher-content parent-switcher="star-wars" owner-id="episode-1">
|
|
87
|
+
<p>Padme</p>
|
|
88
|
+
</cv-content-switcher-content>
|
|
89
|
+
<cv-content-switcher-content parent-switcher="star-wars" owner-id="episode-2">
|
|
90
|
+
<p>Anakin</p>
|
|
91
|
+
</cv-content-switcher-content>
|
|
92
|
+
<cv-content-switcher-content parent-switcher="star-wars" owner-id="episode-2" >
|
|
93
|
+
<p>Zam</p>
|
|
94
|
+
</cv-content-switcher-content>
|
|
95
|
+
<cv-content-switcher-content parent-switcher="star-wars" owner-id="episode-3">
|
|
96
|
+
<p>Yoda</p>
|
|
97
|
+
</cv-content-switcher-content>
|
|
98
|
+
</section>
|
|
99
|
+
<cv-content-switcher aria-label='Choose content' v-bind='args' @selected="onSelected" id="LotR">
|
|
100
|
+
<cv-content-switcher-button parent-switcher="LotR" owner-id="book-1" :selected="selectedIndex === 0">Book 1</cv-content-switcher-button>
|
|
101
|
+
<cv-content-switcher-button parent-switcher="LotR" owner-id="book-2" :selected="selectedIndex === 1">Book 2</cv-content-switcher-button>
|
|
102
|
+
<cv-content-switcher-button parent-switcher="LotR" :icon="iconSample" owner-id="book-3" :selected="selectedIndex === 2">Book 3</cv-content-switcher-button>
|
|
103
|
+
</cv-content-switcher>
|
|
104
|
+
<section style="margin: 10px 0;">
|
|
105
|
+
<cv-content-switcher-content parent-switcher="LotR" owner-id="book-1">
|
|
106
|
+
<p>Bilbo</p>
|
|
107
|
+
</cv-content-switcher-content>
|
|
108
|
+
<cv-content-switcher-content parent-switcher="LotR" owner-id="book-2">
|
|
109
|
+
<p>Frodo</p>
|
|
110
|
+
</cv-content-switcher-content>
|
|
111
|
+
<cv-content-switcher-content parent-switcher="LotR" owner-id="book-2" >
|
|
112
|
+
<p>Sauron</p>
|
|
113
|
+
</cv-content-switcher-content>
|
|
114
|
+
<cv-content-switcher-content parent-switcher="LotR" owner-id="book-3">
|
|
115
|
+
<p>Gandalf</p>
|
|
116
|
+
</cv-content-switcher-content>
|
|
117
|
+
</section>
|
|
118
|
+
</div>
|
|
119
|
+
`;
|
|
120
|
+
const multipleCode = multipleTemplate.replace("v-bind='args'", '');
|
|
121
|
+
|
|
122
|
+
# CvContentSwitcher
|
|
123
|
+
|
|
124
|
+
**Migration notes:**
|
|
125
|
+
|
|
126
|
+
- The `light` and '`theme` options continue to be supported but neither seem to have any effect with Carbon 10.
|
|
127
|
+
The React component does not have these properties listed at all. Even so the `--content-switcher--light` is still
|
|
128
|
+
applied if `light` is set to true.
|
|
129
|
+
- In the Vue 2 component `cv-content-switcher-content` is set to visible if the controlling `cv-content-switcher` is
|
|
130
|
+
removed from the DOM. This is no longer supported. If you need this behaviour you can probably achieve the same effect
|
|
131
|
+
with the direct DOM version of the component plus some visibility logic.
|
|
132
|
+
|
|
133
|
+
<Canvas>
|
|
134
|
+
<Story
|
|
135
|
+
name="Default"
|
|
136
|
+
parameters={{
|
|
137
|
+
controls: { exclude: ['default', 'selected', 'template', 'data'] },
|
|
138
|
+
docs: { source: { code: defaultCode } },
|
|
139
|
+
}}
|
|
140
|
+
args={{
|
|
141
|
+
data: {
|
|
142
|
+
light: true
|
|
143
|
+
},
|
|
144
|
+
selectedIndex: 0,
|
|
145
|
+
template: defaultTemplate,
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
{Template.bind({})}
|
|
149
|
+
</Story>
|
|
150
|
+
</Canvas>
|
|
151
|
+
|
|
152
|
+
Manipulate DOM elements directly. For this mode define `content-selector`. The selector will be passed to
|
|
153
|
+
`document.querySelectorAll()` to find and show or hide elements by setting or removing the `hidden` attribute.
|
|
154
|
+
|
|
155
|
+
<Canvas>
|
|
156
|
+
<Story
|
|
157
|
+
name="Direct DOM"
|
|
158
|
+
parameters={{
|
|
159
|
+
controls: { exclude: ['default', 'selected', 'template', 'data'] },
|
|
160
|
+
docs: { source: { code: domCode } },
|
|
161
|
+
}}
|
|
162
|
+
args={{
|
|
163
|
+
data: {
|
|
164
|
+
light: true,
|
|
165
|
+
},
|
|
166
|
+
selectedIndex: 0,
|
|
167
|
+
template: domTemplate,
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
{Template.bind({})}
|
|
171
|
+
</Story>
|
|
172
|
+
</Canvas>
|
|
173
|
+
|
|
174
|
+
Does it seem like a good idea to have multiple content switchers on the page? Who am I to judge.
|
|
175
|
+
|
|
176
|
+
If you want to do this you need to define an `id` for the `cv-content-switcher` and share that with the
|
|
177
|
+
`cv-content-switcher-button` and `cv-content-switcher-content` components via the `parent-switcher` property.
|
|
178
|
+
|
|
179
|
+
<Canvas>
|
|
180
|
+
<Story
|
|
181
|
+
name="Multiple Switchers"
|
|
182
|
+
parameters={{
|
|
183
|
+
controls: { exclude: ['default', 'selected', 'template', 'data'] },
|
|
184
|
+
docs: { source: { code: multipleCode } },
|
|
185
|
+
}}
|
|
186
|
+
args={{
|
|
187
|
+
data: {
|
|
188
|
+
light: true,
|
|
189
|
+
},
|
|
190
|
+
selectedIndex: 0,
|
|
191
|
+
template: multipleTemplate,
|
|
192
|
+
}}
|
|
193
|
+
>
|
|
194
|
+
{Template.bind({})}
|
|
195
|
+
</Story>
|
|
196
|
+
</Canvas>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="[
|
|
4
|
+
`cv-content-switcher ${carbonPrefix}--content-switcher`,
|
|
5
|
+
{
|
|
6
|
+
[`${carbonPrefix}--content-switcher--light`]: isLight,
|
|
7
|
+
[`${carbonPrefix}--content-switcher--${size || 'md'}`]: size || 'md',
|
|
8
|
+
},
|
|
9
|
+
]"
|
|
10
|
+
role="tablist"
|
|
11
|
+
:id="cvId"
|
|
12
|
+
>
|
|
13
|
+
<slot></slot>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup>
|
|
18
|
+
import { carbonPrefix } from '../../global/settings';
|
|
19
|
+
import { props as propsCvId, useCvId } from '../../use/cvId';
|
|
20
|
+
import { useIsLight, props as propsTheme } from '../../use/cvTheme';
|
|
21
|
+
import { onUnmounted, watch } from 'vue';
|
|
22
|
+
import store from './cvContentSwitcherStore';
|
|
23
|
+
|
|
24
|
+
const emit = defineEmits(['selected']);
|
|
25
|
+
|
|
26
|
+
const props = defineProps({
|
|
27
|
+
size: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: undefined,
|
|
30
|
+
validator: val => ['', 'md', 'sm', 'xl'].includes(val),
|
|
31
|
+
},
|
|
32
|
+
...propsTheme,
|
|
33
|
+
...propsCvId,
|
|
34
|
+
});
|
|
35
|
+
const cvId = useCvId(props, true);
|
|
36
|
+
const isLight = useIsLight(props);
|
|
37
|
+
store.addParent(cvId.value);
|
|
38
|
+
store.setContentSelected('global', undefined);
|
|
39
|
+
onUnmounted(() => {
|
|
40
|
+
store.removeParent(cvId.value);
|
|
41
|
+
});
|
|
42
|
+
watch(
|
|
43
|
+
() => store.state.global.latest,
|
|
44
|
+
(val, prev) => {
|
|
45
|
+
// if previous is not set, do not emit. This mimics the current v2 behaviour where the initial content does not generate an event
|
|
46
|
+
if (prev) emit('selected', val);
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
let ourLatest = undefined;
|
|
51
|
+
watch(
|
|
52
|
+
() => store.state[cvId.value],
|
|
53
|
+
val => {
|
|
54
|
+
if (ourLatest !== val?.latest) {
|
|
55
|
+
// if ourLatest is not set, do not emit. This mimics the current v2 behaviour where the initial content does not generate an event
|
|
56
|
+
if (ourLatest) emit('selected', val?.latest);
|
|
57
|
+
ourLatest = val?.latest;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{ deep: true }
|
|
61
|
+
);
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<style lang="scss"></style>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Carbon content switcher button.
|
|
3
|
+
|
|
4
|
+
Attributes:
|
|
5
|
+
content-selector: A CSS selector for the content to be shown when the button is selected.
|
|
6
|
+
selected: If true the button is initially selected (only valid on one button per content switcher).
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
See content-switcher.vue
|
|
10
|
+
|
|
11
|
+
-->
|
|
12
|
+
<template>
|
|
13
|
+
<button
|
|
14
|
+
type="button"
|
|
15
|
+
role="tab"
|
|
16
|
+
class="cv-content-switcher-button"
|
|
17
|
+
:class="[
|
|
18
|
+
`${carbonPrefix}--content-switcher-btn`,
|
|
19
|
+
{
|
|
20
|
+
[`${carbonPrefix}--content-switcher--selected`]: isSelected,
|
|
21
|
+
},
|
|
22
|
+
]"
|
|
23
|
+
:data-target="contentSelector"
|
|
24
|
+
:aria-selected="isSelected ? 'true' : 'false'"
|
|
25
|
+
:id="cvId"
|
|
26
|
+
@click="open"
|
|
27
|
+
>
|
|
28
|
+
<CvSvg
|
|
29
|
+
v-if="icon"
|
|
30
|
+
:svg="icon"
|
|
31
|
+
:class="`${carbonPrefix}--content-switcher__icon`"
|
|
32
|
+
height="16"
|
|
33
|
+
width="16"
|
|
34
|
+
/>
|
|
35
|
+
<span :class="`${carbonPrefix}--content-switcher__label`">
|
|
36
|
+
<slot></slot>
|
|
37
|
+
</span>
|
|
38
|
+
</button>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script setup>
|
|
42
|
+
import { carbonPrefix } from '../../global/settings';
|
|
43
|
+
import CvSvg from '../CvSvg/_CvSvg.vue';
|
|
44
|
+
import { computed, onMounted, watch } from 'vue';
|
|
45
|
+
import { props as propsCvId, useCvId } from '../../use/cvId';
|
|
46
|
+
import store from './cvContentSwitcherStore';
|
|
47
|
+
|
|
48
|
+
const props = defineProps({
|
|
49
|
+
contentSelector: { type: String, default: undefined },
|
|
50
|
+
icon: {
|
|
51
|
+
type: [String, Object],
|
|
52
|
+
default: undefined,
|
|
53
|
+
validator(val) {
|
|
54
|
+
if (!val || typeof val === 'string') {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return val.render !== null;
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
ownerId: { type: String, default: undefined },
|
|
61
|
+
parentSwitcher: { type: String, default: 'global' },
|
|
62
|
+
selected: Boolean,
|
|
63
|
+
...propsCvId,
|
|
64
|
+
});
|
|
65
|
+
const cvId = useCvId(props, true);
|
|
66
|
+
|
|
67
|
+
function toggleContent(on) {
|
|
68
|
+
if (!props.contentSelector) {
|
|
69
|
+
console.error(
|
|
70
|
+
'CvContentSwitcherButton: Either ownerId or content-selector property must not be defined.'
|
|
71
|
+
);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// show/hide content
|
|
76
|
+
const content = document.querySelectorAll(props.contentSelector);
|
|
77
|
+
for (const element of content) {
|
|
78
|
+
// element.style.visibility = on;
|
|
79
|
+
if (!on) {
|
|
80
|
+
element.setAttribute('hidden', 'hidden');
|
|
81
|
+
} else {
|
|
82
|
+
element.removeAttribute('hidden');
|
|
83
|
+
}
|
|
84
|
+
element.setAttribute('aria-hidden', `${!on}`);
|
|
85
|
+
}
|
|
86
|
+
if (on) store.setContentSelected(props.parentSwitcher, props.contentSelector);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function open() {
|
|
90
|
+
store.setSelected(props.parentSwitcher, cvId.value);
|
|
91
|
+
if (props.ownerId) store.setOwnerContent(props.parentSwitcher, props.ownerId);
|
|
92
|
+
else toggleContent(true);
|
|
93
|
+
}
|
|
94
|
+
function close() {
|
|
95
|
+
if (!props.ownerId) toggleContent(false);
|
|
96
|
+
}
|
|
97
|
+
const isSelected = computed(() => {
|
|
98
|
+
return store.getSelected(props.parentSwitcher, cvId.value);
|
|
99
|
+
});
|
|
100
|
+
watch(isSelected, val => {
|
|
101
|
+
if (val) open();
|
|
102
|
+
else close();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// life cycle
|
|
106
|
+
onMounted(() => {
|
|
107
|
+
if (props.contentSelector === '' && props.ownerId === '') {
|
|
108
|
+
console.error(
|
|
109
|
+
'CvContentSwitcherButton: ownerId or content-selector properties must not be empty strings.'
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
if (props.selected) open();
|
|
113
|
+
else close();
|
|
114
|
+
});
|
|
115
|
+
</script>
|
|
116
|
+
|
|
117
|
+
<style lang="scss"></style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-show="isVisible" class="cv-content-switcher-content">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
8
|
+
import { computed } from 'vue';
|
|
9
|
+
import store from './cvContentSwitcherStore';
|
|
10
|
+
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
ownerId: { type: String, required: true },
|
|
13
|
+
parentSwitcher: { type: String, default: 'global' },
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const isVisible = computed(() => {
|
|
17
|
+
return store.isOwnerContent(props.parentSwitcher, props.ownerId);
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<style lang="scss"></style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { reactive } from 'vue';
|
|
2
|
+
export default reactive({
|
|
3
|
+
state: { global: { latest: undefined, selected: '', owner: '' } },
|
|
4
|
+
addParent(parentId) {
|
|
5
|
+
this.state[parentId] = { latest: undefined, selected: '', owner: '' };
|
|
6
|
+
},
|
|
7
|
+
setSelected(parentId, childId) {
|
|
8
|
+
this.getParent(parentId).selected = childId;
|
|
9
|
+
},
|
|
10
|
+
getSelected(parentId, childId) {
|
|
11
|
+
return this.getParent(parentId).selected === childId;
|
|
12
|
+
},
|
|
13
|
+
removeParent(parentId) {
|
|
14
|
+
delete this.state[parentId];
|
|
15
|
+
},
|
|
16
|
+
getParent(parentId) {
|
|
17
|
+
if (!this.state[parentId]) this.addParent(parentId);
|
|
18
|
+
return this.state[parentId];
|
|
19
|
+
},
|
|
20
|
+
setContentSelected(parentId, selected) {
|
|
21
|
+
this.getParent(parentId).latest = selected;
|
|
22
|
+
},
|
|
23
|
+
setOwnerContent(parentId, ownerId) {
|
|
24
|
+
this.getParent(parentId).owner = ownerId;
|
|
25
|
+
this.setContentSelected(parentId, ownerId);
|
|
26
|
+
},
|
|
27
|
+
isOwnerContent(parentId, ownerId) {
|
|
28
|
+
return this.getParent(parentId).owner === ownerId;
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import CvCopyButton from '.';
|
|
2
|
+
|
|
3
|
+
import { action } from '@storybook/addon-actions';
|
|
4
|
+
import {
|
|
5
|
+
sbCompPrefix,
|
|
6
|
+
storyParametersObject,
|
|
7
|
+
} from '../../global/storybook-utils';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: `${sbCompPrefix}/CvCopyButton`,
|
|
11
|
+
component: CvCopyButton,
|
|
12
|
+
argTypes: {},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const template = `<cv-copy-button v-bind="args" @copy="copy" />`;
|
|
16
|
+
const Template = args => ({
|
|
17
|
+
components: { CvCopyButton },
|
|
18
|
+
setup: () => ({ args, copy: action('copy') }),
|
|
19
|
+
template,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const Default = Template.bind({});
|
|
23
|
+
Default.args = {};
|
|
24
|
+
Default.parameters = storyParametersObject(
|
|
25
|
+
Default.parameters,
|
|
26
|
+
template,
|
|
27
|
+
Default.args
|
|
28
|
+
);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<cvi-copy-button
|
|
3
|
+
:class="`${carbonPrefix}--copy-btn`"
|
|
4
|
+
:aria-label="iconDescription"
|
|
5
|
+
:title="iconDescription"
|
|
6
|
+
:feedback="feedback"
|
|
7
|
+
:feedback-timeout="feedbackTimeout"
|
|
8
|
+
@copy="$emit('copy')"
|
|
9
|
+
>
|
|
10
|
+
<copy16 :class="`${carbonPrefix}--snippet__icon`" />
|
|
11
|
+
</cvi-copy-button>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import { Copy16 } from '@carbon/icons-vue';
|
|
16
|
+
import { carbonPrefix } from '../../global/settings';
|
|
17
|
+
import CviCopyButton from './_CviCopyButton.vue';
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
name: 'CvCopyButton',
|
|
21
|
+
props: {
|
|
22
|
+
/** Text shown when button is clicked */
|
|
23
|
+
feedback: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: 'Copied!',
|
|
26
|
+
},
|
|
27
|
+
/** How long the feedback text stays visible for */
|
|
28
|
+
feedbackTimeout: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: 2000,
|
|
31
|
+
},
|
|
32
|
+
/** A11y description for copy icon */
|
|
33
|
+
iconDescription: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: 'Copy to clipboard',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
emits: [
|
|
39
|
+
/** Emitted when user clicks on the button */
|
|
40
|
+
'copy',
|
|
41
|
+
],
|
|
42
|
+
components: { CviCopyButton, Copy16 },
|
|
43
|
+
setup: () => ({ carbonPrefix }),
|
|
44
|
+
};
|
|
45
|
+
</script>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button
|
|
3
|
+
type="button"
|
|
4
|
+
:class="[
|
|
5
|
+
`${carbonPrefix}--copy`,
|
|
6
|
+
{
|
|
7
|
+
[`${carbonPrefix}--copy-btn--animating`]: isAnimating,
|
|
8
|
+
[`${carbonPrefix}--copy-btn--${activeAnimation}`]: isAnimating,
|
|
9
|
+
},
|
|
10
|
+
]"
|
|
11
|
+
@click="handleClick"
|
|
12
|
+
@animationend="handleAnimationEnd"
|
|
13
|
+
aria-live="polite"
|
|
14
|
+
:aria-label="feedback"
|
|
15
|
+
>
|
|
16
|
+
<slot />
|
|
17
|
+
{{ feedback }}
|
|
18
|
+
<span
|
|
19
|
+
aria-hidden="true"
|
|
20
|
+
:class="[
|
|
21
|
+
`${carbonPrefix}--assistive-text`,
|
|
22
|
+
`${carbonPrefix}--copy-btn__feedback`,
|
|
23
|
+
]"
|
|
24
|
+
>{{ feedback }}</span
|
|
25
|
+
>
|
|
26
|
+
</button>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script>
|
|
30
|
+
import { ref, computed } from 'vue';
|
|
31
|
+
import { useDebounceFn } from '@vueuse/core';
|
|
32
|
+
import { carbonPrefix } from '../../global/settings';
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
props: {
|
|
36
|
+
feedback: { type: String, required: true },
|
|
37
|
+
feedbackTimeout: { type: Number, required: true },
|
|
38
|
+
},
|
|
39
|
+
emits: ['copy'],
|
|
40
|
+
setup(props, { emit }) {
|
|
41
|
+
const activeAnimation = ref('');
|
|
42
|
+
const isAnimating = computed(() => activeAnimation.value.length > 0);
|
|
43
|
+
|
|
44
|
+
const fadeOut = useDebounceFn(() => {
|
|
45
|
+
activeAnimation.value = 'fade-out';
|
|
46
|
+
}, props.feedbackTimeout);
|
|
47
|
+
|
|
48
|
+
const handleClick = () => {
|
|
49
|
+
emit('copy');
|
|
50
|
+
activeAnimation.value = 'fade-in';
|
|
51
|
+
fadeOut();
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const handleAnimationEnd = event => {
|
|
55
|
+
if (event.animationName !== 'hide-feedback') {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
activeAnimation.value = '';
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
carbonPrefix,
|
|
64
|
+
activeAnimation,
|
|
65
|
+
isAnimating,
|
|
66
|
+
handleClick,
|
|
67
|
+
handleAnimationEnd,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
</script>
|