@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
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<cv-wrapper :tag-type="formItem ? 'div' : ''" :class="`cv-date-picker ${carbonPrefix}--form-item`" :id="uid">
|
|
3
|
-
<div
|
|
4
|
-
:data-date-picker="['single', 'range'].includes(kind)"
|
|
5
|
-
:data-date-picker-type="kind"
|
|
6
|
-
:class="[
|
|
7
|
-
`${this.carbonPrefix}--date-picker ${this.carbonPrefix}--date-picker--${this.kind}`,
|
|
8
|
-
{
|
|
9
|
-
[`${carbonPrefix}--date-picker--simple`]: this.kind === 'short',
|
|
10
|
-
[`${carbonPrefix}--date-picker--light`]: isLight,
|
|
11
|
-
'cv-date-pciker': !formItem,
|
|
12
|
-
},
|
|
13
|
-
]"
|
|
14
|
-
ref="date-picker"
|
|
15
|
-
:id="formItem ? undefined : uid"
|
|
16
|
-
>
|
|
17
|
-
<div
|
|
18
|
-
:class="{
|
|
19
|
-
[`${carbonPrefix}--date-picker-container`]: ['single', 'range'].includes(kind),
|
|
20
|
-
[`${carbonPrefix}--date-picker--nolabel`]: getDateLabel !== undefined,
|
|
21
|
-
}"
|
|
22
|
-
@change="onChange"
|
|
23
|
-
>
|
|
24
|
-
<label v-if="getDateLabel.length > 0" :for="`${uid}-input-1`" :class="`${carbonPrefix}--label`">
|
|
25
|
-
{{ getDateLabel }}
|
|
26
|
-
</label>
|
|
27
|
-
<div :class="`${carbonPrefix}--date-picker-input__wrapper`">
|
|
28
|
-
<input
|
|
29
|
-
:data-invalid="isInvalid"
|
|
30
|
-
type="text"
|
|
31
|
-
:id="`${uid}-input-1`"
|
|
32
|
-
:class="`${carbonPrefix}--date-picker__input`"
|
|
33
|
-
:pattern="pattern"
|
|
34
|
-
:placeholder="placeholder"
|
|
35
|
-
data-date-picker-input
|
|
36
|
-
:data-date-picker-input-from="kind === 'range'"
|
|
37
|
-
ref="date"
|
|
38
|
-
/>
|
|
39
|
-
<Calendar16
|
|
40
|
-
v-if="['single', 'range'].includes(kind)"
|
|
41
|
-
:class="`${carbonPrefix}--date-picker__icon`"
|
|
42
|
-
data-date-picker-icon
|
|
43
|
-
@click="cal.open()"
|
|
44
|
-
/>
|
|
45
|
-
</div>
|
|
46
|
-
<div :class="`${carbonPrefix}--form-requirement`" v-if="isInvalid">
|
|
47
|
-
<slot name="invalid-message">{{ invalidMessage || invalidDateMessage }}</slot>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
<div :class="{ [`${carbonPrefix}--date-picker-container`]: kind === 'range' }" v-if="kind === 'range'">
|
|
51
|
-
<label v-if="getDateEndLabel.length > 0" :for="`${uid}-input-2`" :class="`${carbonPrefix}--label`">
|
|
52
|
-
{{ getDateEndLabel }}
|
|
53
|
-
</label>
|
|
54
|
-
<div :class="`${carbonPrefix}--date-picker-input__wrapper`">
|
|
55
|
-
<input
|
|
56
|
-
type="text"
|
|
57
|
-
:id="`${uid}-input-2`"
|
|
58
|
-
:class="`${carbonPrefix}--date-picker__input`"
|
|
59
|
-
:pattern="pattern"
|
|
60
|
-
:placeholder="placeholder"
|
|
61
|
-
data-date-picker-input
|
|
62
|
-
:data-date-picker-input-to="kind === 'range'"
|
|
63
|
-
ref="todate"
|
|
64
|
-
/>
|
|
65
|
-
<Calendar16 :class="`${carbonPrefix}--date-picker__icon`" data-date-picker-icon @click="openTodateCal()" />
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
</cv-wrapper>
|
|
70
|
-
</template>
|
|
71
|
-
|
|
72
|
-
<script>
|
|
73
|
-
import Flatpickr from 'flatpickr';
|
|
74
|
-
import l10n from 'flatpickr/dist/l10n/index';
|
|
75
|
-
// import carbonFlatpickrAppendToPlugin from './plugins/appendToPlugin';
|
|
76
|
-
import carbonFlatpickrFixEventsPlugin from './plugins/fixEventsPlugin';
|
|
77
|
-
import carbonFlatpickrRangePlugin from './plugins/rangePlugin';
|
|
78
|
-
import carbonFlatpickrMonthSelectPlugin from './plugins/monthSelectPlugin';
|
|
79
|
-
|
|
80
|
-
import { uidMixin, themeMixin, carbonPrefixMixin } from '../../mixins';
|
|
81
|
-
import Calendar16 from '@carbon/icons-vue/es/calendar/16';
|
|
82
|
-
import CvWrapper from '../cv-wrapper/_cv-wrapper';
|
|
83
|
-
|
|
84
|
-
export default {
|
|
85
|
-
name: 'CvDatePicker',
|
|
86
|
-
mixins: [uidMixin, themeMixin, carbonPrefixMixin],
|
|
87
|
-
components: { Calendar16, CvWrapper },
|
|
88
|
-
props: {
|
|
89
|
-
dateLabel: { type: String, default: undefined },
|
|
90
|
-
dateEndLabel: { type: String, default: undefined },
|
|
91
|
-
formItem: { type: Boolean, default: true },
|
|
92
|
-
kind: {
|
|
93
|
-
type: String,
|
|
94
|
-
default: 'simple',
|
|
95
|
-
validator: val => ['short', 'simple', 'single', 'range'].includes(val),
|
|
96
|
-
},
|
|
97
|
-
calOptions: {
|
|
98
|
-
type: Object,
|
|
99
|
-
default: () => {
|
|
100
|
-
return {
|
|
101
|
-
dateFormat: 'm/d/Y',
|
|
102
|
-
};
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
pattern: { type: String, default: '\\d{1,2}/\\d{1,2}/\\d{4}' },
|
|
106
|
-
placeholder: { type: String, default: 'mm/dd/yyyy' },
|
|
107
|
-
invalid: /* deprecate */ {
|
|
108
|
-
type: Boolean,
|
|
109
|
-
default: undefined,
|
|
110
|
-
validator(val) {
|
|
111
|
-
if (val !== undefined && process.env.NODE_ENV === 'development') {
|
|
112
|
-
console.warn('CvDatePicker: invalid prop deprecated in favour of invalidMessage');
|
|
113
|
-
}
|
|
114
|
-
return true;
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
invalidDateMessage: /* deprecate */ {
|
|
118
|
-
type: String,
|
|
119
|
-
default: undefined,
|
|
120
|
-
validator(val) {
|
|
121
|
-
if (val !== undefined && process.env.NODE_ENV === 'development') {
|
|
122
|
-
console.warn('CvDatePicker: invalidDateMessage deprecated in favour of invalidMessage');
|
|
123
|
-
}
|
|
124
|
-
return true;
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
invalidMessage: { type: String, default: undefined },
|
|
128
|
-
value: [String, Object, Array, Date],
|
|
129
|
-
},
|
|
130
|
-
model: {
|
|
131
|
-
prop: 'value',
|
|
132
|
-
event: 'change',
|
|
133
|
-
},
|
|
134
|
-
data() {
|
|
135
|
-
return {
|
|
136
|
-
dataValue: this.value,
|
|
137
|
-
dataOptions: {},
|
|
138
|
-
isInvalid: false,
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
watch: {
|
|
142
|
-
value() {
|
|
143
|
-
if (this.isSingle) {
|
|
144
|
-
this.cal.setDate(this.value, true);
|
|
145
|
-
} else if (this.isRange) {
|
|
146
|
-
this.cal.setDate([this.value.startDate, this.value.endDate], true);
|
|
147
|
-
} else {
|
|
148
|
-
this.$refs.date.value = this.value;
|
|
149
|
-
}
|
|
150
|
-
this.dataValue = this.value;
|
|
151
|
-
},
|
|
152
|
-
calOptions() {
|
|
153
|
-
this.initFlatpickr();
|
|
154
|
-
},
|
|
155
|
-
kind() {
|
|
156
|
-
this.initFlatpickr();
|
|
157
|
-
},
|
|
158
|
-
invalidMessage() {
|
|
159
|
-
this.checkSlots();
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
computed: {
|
|
163
|
-
getDateLabel() {
|
|
164
|
-
if (this.dateLabel !== undefined) {
|
|
165
|
-
return this.dateLabel;
|
|
166
|
-
} else {
|
|
167
|
-
if (this.isRange) {
|
|
168
|
-
return 'Start date';
|
|
169
|
-
} else {
|
|
170
|
-
return 'Date';
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
getDateEndLabel() {
|
|
175
|
-
if (this.dateEndLabel !== undefined) {
|
|
176
|
-
return this.dateEndLabel;
|
|
177
|
-
} else {
|
|
178
|
-
if (this.isRange) {
|
|
179
|
-
return 'End date';
|
|
180
|
-
} else {
|
|
181
|
-
return '';
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
isRange() {
|
|
186
|
-
return this.kind === 'range';
|
|
187
|
-
},
|
|
188
|
-
isSingle() {
|
|
189
|
-
return this.kind === 'single';
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
methods: {
|
|
193
|
-
checkSlots() {
|
|
194
|
-
// NOTE: this.$slots is not reactive so needs to be managed on updated
|
|
195
|
-
this.isInvalid = !!(
|
|
196
|
-
this.$slots['invalid-message'] ||
|
|
197
|
-
(this.invalidMessage && this.invalidMessage.length) ||
|
|
198
|
-
(this.invalidDateMessage && this.invalidDateMessage.length)
|
|
199
|
-
);
|
|
200
|
-
},
|
|
201
|
-
initFlatpickr() {
|
|
202
|
-
if (['single', 'range'].includes(this.kind)) {
|
|
203
|
-
// no need to call set value as it's done through getOptions
|
|
204
|
-
this.cal = new Flatpickr(this.$refs.date, this.getOptions());
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
getOptions() {
|
|
208
|
-
const _options = { ...this.calOptions };
|
|
209
|
-
|
|
210
|
-
// add events update based on parameters
|
|
211
|
-
_options.onChange = this.onChange;
|
|
212
|
-
_options.onOpen = this.onOpen;
|
|
213
|
-
_options.onReady = this.onCalReady;
|
|
214
|
-
|
|
215
|
-
// prefer value if set
|
|
216
|
-
if (this.dataValue) {
|
|
217
|
-
if (this.isRange) {
|
|
218
|
-
_options.defaultDate = [this.dataValue.startDate, this.dataValue.endDate];
|
|
219
|
-
} else {
|
|
220
|
-
_options.defaultDate = this.dataValue;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
// _options.onValueUpdate = this.onChange;
|
|
224
|
-
|
|
225
|
-
_options.plugins = [
|
|
226
|
-
this.isRange
|
|
227
|
-
? carbonFlatpickrRangePlugin({
|
|
228
|
-
input: this.$refs.todate,
|
|
229
|
-
})
|
|
230
|
-
: () => {},
|
|
231
|
-
carbonFlatpickrMonthSelectPlugin({
|
|
232
|
-
selectorFlatpickrMonthYearContainer: '.flatpickr-current-month',
|
|
233
|
-
selectorFlatpickrYearContainer: '.numInputWrapper',
|
|
234
|
-
selectorFlatpickrCurrentMonth: '.cur-month',
|
|
235
|
-
classFlatpickrCurrentMonth: 'cur-month',
|
|
236
|
-
}),
|
|
237
|
-
carbonFlatpickrFixEventsPlugin({
|
|
238
|
-
inputFrom: this.$refs.date,
|
|
239
|
-
inputTo: this.$refs.todate,
|
|
240
|
-
}),
|
|
241
|
-
];
|
|
242
|
-
_options.nextArrow = `
|
|
243
|
-
<svg width="16px" height="16px" viewBox="0 0 16 16">
|
|
244
|
-
<polygon points="11,8 6,13 5.3,12.3 9.6,8 5.3,3.7 6,3 "/>
|
|
245
|
-
<rect width="16" height="16" style="fill:none" />
|
|
246
|
-
</svg>`;
|
|
247
|
-
_options.prevArrow = `
|
|
248
|
-
<svg width="16px" height="16px" viewBox="0 0 16 16">
|
|
249
|
-
<polygon points="5,8 10,3 10.7,3.7 6.4,8 10.7,12.3 10,13 "/>
|
|
250
|
-
<rect width="16" height="16" style="fill:none" />
|
|
251
|
-
</svg>`;
|
|
252
|
-
|
|
253
|
-
return _options;
|
|
254
|
-
},
|
|
255
|
-
onChange() {
|
|
256
|
-
let firstDate, secondDate;
|
|
257
|
-
let dateToString = val => {
|
|
258
|
-
if (typeof val === 'number') {
|
|
259
|
-
return this.cal.formatDate(val, this.calOptions.dateFormat);
|
|
260
|
-
} else {
|
|
261
|
-
return val || '';
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
if (this.dataValue) {
|
|
266
|
-
if (this.isRange) {
|
|
267
|
-
firstDate = dateToString(this.dataValue.startDate);
|
|
268
|
-
secondDate = dateToString(this.dataValue.endDate);
|
|
269
|
-
} else {
|
|
270
|
-
firstDate = dateToString(this.dataValue);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (this.isRange) {
|
|
275
|
-
if (firstDate !== this.$refs.date.value || secondDate !== this.$refs.todate.value) {
|
|
276
|
-
this.dataValue = {
|
|
277
|
-
startDate: this.$refs.date.value,
|
|
278
|
-
endDate: this.$refs.todate.value,
|
|
279
|
-
};
|
|
280
|
-
this.$emit('change', this.dataValue);
|
|
281
|
-
}
|
|
282
|
-
} else {
|
|
283
|
-
if (firstDate !== this.$refs.date.value) {
|
|
284
|
-
this.dataValue = this.$refs.date.value;
|
|
285
|
-
this.$emit('change', this.dataValue);
|
|
286
|
-
|
|
287
|
-
if (this.$listeners['simpleChange'] && process.env.NODE_ENV === 'development') {
|
|
288
|
-
console.warn('CvDatePicker: simple change event deprecated in favour of change.');
|
|
289
|
-
this.$emit('simpleChange', this.dataValue);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
onCalReady(selectedDates, dateString, instance) {
|
|
295
|
-
const calendarContainer = instance.calendarContainer;
|
|
296
|
-
const options = {
|
|
297
|
-
classCalendarContainer: `${this.carbonPrefix}--date-picker__calendar`,
|
|
298
|
-
classMonth: `${this.carbonPrefix}--date-picker__month`,
|
|
299
|
-
classWeekdays: `${this.carbonPrefix}--date-picker__weekdays`,
|
|
300
|
-
classDays: `${this.carbonPrefix}--date-picker__days`,
|
|
301
|
-
classWeekday: `${this.carbonPrefix}--date-picker__weekday`,
|
|
302
|
-
classDay: `${this.carbonPrefix}--date-picker__day`,
|
|
303
|
-
classFocused: `${this.carbonPrefix}--focused`,
|
|
304
|
-
classVisuallyHidden: `${this.carbonPrefix}--visually-hidden`,
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
if (calendarContainer) {
|
|
308
|
-
calendarContainer.classList.add(options.classCalendarContainer);
|
|
309
|
-
calendarContainer.querySelector('.flatpickr-month').classList.add(options.classMonth);
|
|
310
|
-
calendarContainer.querySelector('.flatpickr-weekdays').classList.add(options.classWeekdays);
|
|
311
|
-
calendarContainer.querySelector('.flatpickr-days').classList.add(options.classDays);
|
|
312
|
-
for (const item of calendarContainer.querySelectorAll('.flatpickr-weekday')) {
|
|
313
|
-
const currentItem = item;
|
|
314
|
-
currentItem.innerHTML = currentItem.innerHTML.replace(/\s+/g, '');
|
|
315
|
-
currentItem.classList.add(options.classWeekday);
|
|
316
|
-
}
|
|
317
|
-
for (const item of calendarContainer.querySelectorAll('.flatpickr-day')) {
|
|
318
|
-
item.classList.add(options.classDay);
|
|
319
|
-
if (item.classList.contains('today') && selectedDates.length > 0) {
|
|
320
|
-
item.classList.add('no-border');
|
|
321
|
-
} else if (item.classList.contains('today') && selectedDates.length === 0) {
|
|
322
|
-
item.classList.remove('no-border');
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
openTodateCal() {
|
|
328
|
-
this.$refs.todate.click();
|
|
329
|
-
},
|
|
330
|
-
},
|
|
331
|
-
created() {
|
|
332
|
-
// Weekdays shorthand for english locale
|
|
333
|
-
l10n.en.weekdays.shorthand.forEach((day, index) => {
|
|
334
|
-
const currentDay = l10n.en.weekdays.shorthand;
|
|
335
|
-
if (currentDay[index] === 'Thu' || currentDay[index] === 'Th') {
|
|
336
|
-
currentDay[index] = 'Th';
|
|
337
|
-
} else {
|
|
338
|
-
currentDay[index] = currentDay[index].charAt(0);
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
},
|
|
342
|
-
mounted() {
|
|
343
|
-
this.initFlatpickr();
|
|
344
|
-
this.checkSlots();
|
|
345
|
-
// this.cal.setDate([Date.now(), Date.now()]);
|
|
346
|
-
// setTimeout(() => {
|
|
347
|
-
// let curDate = new Date();
|
|
348
|
-
// let anotherDate = new Date();
|
|
349
|
-
// anotherDate = anotherDate.setDate(anotherDate.getDate() + 16);
|
|
350
|
-
// this.cal.setDate([curDate, anotherDate], true);
|
|
351
|
-
// }, 2000);
|
|
352
|
-
},
|
|
353
|
-
updated() {
|
|
354
|
-
this.checkSlots();
|
|
355
|
-
},
|
|
356
|
-
beforeDestroy() {
|
|
357
|
-
if (this.cal) {
|
|
358
|
-
this.cal.destroy();
|
|
359
|
-
}
|
|
360
|
-
},
|
|
361
|
-
};
|
|
362
|
-
</script>
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
*
|
|
4
|
-
* Copyright IBM Corp. 2019
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/*
|
|
11
|
-
* COPIED FROM carbon-components-react
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param {object} config Plugin configuration.
|
|
16
|
-
* @returns {Plugin} A Flatpickr plugin to put adjust the position of calendar dropdown.
|
|
17
|
-
*/
|
|
18
|
-
export default config => fp => {
|
|
19
|
-
/**
|
|
20
|
-
* Adjusts the floating meun position after Flatpicker sets it.
|
|
21
|
-
*/
|
|
22
|
-
const handlePreCalendarPosition = () => {
|
|
23
|
-
Promise.resolve().then(() => {
|
|
24
|
-
const { calendarContainer, config: fpConfig, _positionElement: positionElement } = fp;
|
|
25
|
-
const { appendTo } = fpConfig;
|
|
26
|
-
const { left: containerLeft, top: containerTop } = appendTo.getBoundingClientRect();
|
|
27
|
-
const { left: refLeft, bottom: refBottom } = positionElement.getBoundingClientRect();
|
|
28
|
-
if (
|
|
29
|
-
(appendTo !== appendTo.ownerDocument.body || containerLeft !== 0 || containerTop !== 0) &&
|
|
30
|
-
appendTo.ownerDocument.defaultView.getComputedStyle(appendTo).getPropertyValue('position') === 'static'
|
|
31
|
-
) {
|
|
32
|
-
throw new Error('Floating menu container must not have `position:static`.');
|
|
33
|
-
}
|
|
34
|
-
// `2` for negative mergin on calendar dropdown
|
|
35
|
-
calendarContainer.style.top = `${refBottom - containerTop + 2}px`;
|
|
36
|
-
calendarContainer.style.left = `${refLeft - containerLeft}px`;
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Registers this Flatpickr plugin.
|
|
42
|
-
*/
|
|
43
|
-
const register = () => {
|
|
44
|
-
fp.loadedPlugins.push('carbonFlatpickrAppendToPlugin');
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
appendTo: config.appendTo,
|
|
49
|
-
onReady: register,
|
|
50
|
-
onPreCalendarPosition: handlePreCalendarPosition,
|
|
51
|
-
};
|
|
52
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2018
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* COPIED FROM carbon-components-react - amended to remove keyboard code dependency
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @param {object} config Plugin configuration.
|
|
14
|
-
* @returns {Plugin} A Flatpickr plugin to fix Flatpickr's behavior of certain events.
|
|
15
|
-
*/
|
|
16
|
-
export default config => fp => {
|
|
17
|
-
/**
|
|
18
|
-
* Handles `keydown` event.
|
|
19
|
-
*/
|
|
20
|
-
const handleKeydown = event => {
|
|
21
|
-
const { inputFrom, inputTo } = config;
|
|
22
|
-
const { target } = event;
|
|
23
|
-
if (inputFrom === target || inputTo === target) {
|
|
24
|
-
if (event.key === 'Enter') {
|
|
25
|
-
// Makes sure the hitting enter key picks up pending values of both `<input>`
|
|
26
|
-
// Workaround for: https://github.com/flatpickr/flatpickr/issues/1942
|
|
27
|
-
fp.setDate([inputFrom.value, inputTo && inputTo.value], true, fp.config.dateFormat);
|
|
28
|
-
event.stopPropagation();
|
|
29
|
-
} else if (event.key === 'Left' || event.key === 'Right') {
|
|
30
|
-
// Prevents Flatpickr code from canceling the event if left/right arrow keys are hit on `<input>`,
|
|
31
|
-
// so user can move the keyboard cursor for editing dates
|
|
32
|
-
// Workaround for: https://github.com/flatpickr/flatpickr/issues/1943
|
|
33
|
-
event.stopPropagation();
|
|
34
|
-
} else if (event.key === 'Down') {
|
|
35
|
-
event.preventDefault();
|
|
36
|
-
fp.open();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Releases event listeners used in this Flatpickr plugin.
|
|
43
|
-
*/
|
|
44
|
-
const release = () => {
|
|
45
|
-
const { inputFrom, inputTo } = config;
|
|
46
|
-
if (inputTo) {
|
|
47
|
-
inputTo.removeEventListener('keydown', handleKeydown, true);
|
|
48
|
-
}
|
|
49
|
-
inputFrom.removeEventListener('keydown', handleKeydown, true);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Sets up event listeners used for this Flatpickr plugin.
|
|
54
|
-
*/
|
|
55
|
-
const init = () => {
|
|
56
|
-
release();
|
|
57
|
-
const { inputFrom, inputTo } = config;
|
|
58
|
-
inputFrom.addEventListener('keydown', handleKeydown, true);
|
|
59
|
-
if (inputTo) {
|
|
60
|
-
inputTo.addEventListener('keydown', handleKeydown, true);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Registers this Flatpickr plugin.
|
|
66
|
-
*/
|
|
67
|
-
const register = () => {
|
|
68
|
-
fp.loadedPlugins.push('carbonFlatpickrFixEventsPlugin');
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
onReady: [register, init],
|
|
73
|
-
onDestroy: [release],
|
|
74
|
-
};
|
|
75
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* COPIED FROM carbon-components-react
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {number} monthNumber The month number.
|
|
7
|
-
* @param {boolean} shorthand `true` to use shorthand month.
|
|
8
|
-
* @param {Locale} locale The Flatpickr locale data.
|
|
9
|
-
* @returns {string} The month string.
|
|
10
|
-
*/
|
|
11
|
-
const monthToStr = (monthNumber, shorthand, locale) => locale.months[shorthand ? 'shorthand' : 'longhand'][monthNumber];
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @param {object} config Plugin configuration.
|
|
15
|
-
* @param {boolean} [config.shorthand] `true` to use shorthand month.
|
|
16
|
-
* @param {string} config.selectorFlatpickrMonthYearContainer The CSS selector for the container of month/year selection UI.
|
|
17
|
-
* @param {string} config.selectorFlatpickrYearContainer The CSS selector for the container of year selection UI.
|
|
18
|
-
* @param {string} config.selectorFlatpickrCurrentMonth The CSS selector for the text-based month selection UI.
|
|
19
|
-
* @param {string} config.classFlatpickrCurrentMonth The CSS class for the text-based month selection UI.
|
|
20
|
-
* @returns {Plugin} A Flatpickr plugin to use text instead of `<select>` for month picker.
|
|
21
|
-
*/
|
|
22
|
-
export default config => fp => {
|
|
23
|
-
const setupElements = () => {
|
|
24
|
-
if (!fp.monthElements || fp.monthElements.length < 1) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
fp.monthElements.forEach(elem => {
|
|
28
|
-
if (!elem.parentNode) return;
|
|
29
|
-
elem.parentNode.removeChild(elem);
|
|
30
|
-
});
|
|
31
|
-
fp.monthElements.splice(
|
|
32
|
-
0,
|
|
33
|
-
fp.monthElements.length,
|
|
34
|
-
...fp.monthElements.map(() => {
|
|
35
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
36
|
-
const monthElement = fp._createElement('span', config.classFlatpickrCurrentMonth);
|
|
37
|
-
monthElement.textContent = monthToStr(fp.currentMonth, config.shorthand === true, fp.l10n);
|
|
38
|
-
fp.yearElements[0]
|
|
39
|
-
.closest(config.selectorFlatpickrMonthYearContainer)
|
|
40
|
-
.insertBefore(monthElement, fp.yearElements[0].closest(config.selectorFlatpickrYearContainer));
|
|
41
|
-
return monthElement;
|
|
42
|
-
})
|
|
43
|
-
);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const updateCurrentMonth = () => {
|
|
47
|
-
const monthStr = monthToStr(fp.currentMonth, config.shorthand === true, fp.l10n);
|
|
48
|
-
fp.yearElements.forEach(elem => {
|
|
49
|
-
const currentMonthContainer = elem.closest(config.selectorFlatpickrMonthYearContainer);
|
|
50
|
-
Array.prototype.forEach.call(currentMonthContainer.querySelectorAll('.cur-month'), monthElement => {
|
|
51
|
-
monthElement.textContent = monthStr;
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const register = () => {
|
|
57
|
-
fp.loadedPlugins.push('carbonFlatpickrMonthSelectPlugin');
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
onMonthChange: updateCurrentMonth,
|
|
62
|
-
onValueUpdate: updateCurrentMonth,
|
|
63
|
-
onOpen: updateCurrentMonth,
|
|
64
|
-
onReady: [setupElements, updateCurrentMonth, register],
|
|
65
|
-
};
|
|
66
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import rangePlugin from 'flatpickr/dist/plugins/rangePlugin';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* COPIED FROM carbon-components-react
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @param {object} config Plugin configuration.
|
|
9
|
-
* @returns {Plugin} An extension of Flatpickr `rangePlugin` that does the following:
|
|
10
|
-
* * Better ensures the calendar dropdown is always aligned to the `<input>` for the starting date.
|
|
11
|
-
* Workaround for: https://github.com/flatpickr/flatpickr/issues/1944
|
|
12
|
-
* * A logic to ensure `fp.setDate()` call won't end up with "startDate to endDate" set to the first `<input>`
|
|
13
|
-
*/
|
|
14
|
-
export default config => {
|
|
15
|
-
const factory = rangePlugin(Object.assign({ position: 'left' }, config));
|
|
16
|
-
|
|
17
|
-
return fp => {
|
|
18
|
-
const origSetDate = fp.setDate;
|
|
19
|
-
|
|
20
|
-
const init = () => {
|
|
21
|
-
fp.setDate = function setDate(dates, triggerChange, format) {
|
|
22
|
-
origSetDate.call(this, dates, triggerChange, format);
|
|
23
|
-
// If `triggerChange` is `true`, `onValueUpdate` Flatpickr event is fired
|
|
24
|
-
// where Flatpickr's range plugin takes care of fixing the first `<input>`
|
|
25
|
-
if (!triggerChange) {
|
|
26
|
-
const { _input: inputFrom } = fp;
|
|
27
|
-
const { input: inputTo } = config;
|
|
28
|
-
[inputFrom, inputTo].forEach((input, i) => {
|
|
29
|
-
if (input) {
|
|
30
|
-
input.value = !dates[i] ? '' : fp.formatDate(new Date(dates[i]), fp.config.dateFormat);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const origRangePlugin = factory(fp);
|
|
38
|
-
const { onReady: origOnReady } = origRangePlugin;
|
|
39
|
-
|
|
40
|
-
return Object.assign(origRangePlugin, {
|
|
41
|
-
onReady: [init, origOnReady],
|
|
42
|
-
onPreCalendarPosition() {},
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
Carbon dropdown item
|
|
3
|
-
|
|
4
|
-
Attributes:
|
|
5
|
-
value: The value for the item. Optional.
|
|
6
|
-
|
|
7
|
-
Usage:
|
|
8
|
-
See dropdown.vue
|
|
9
|
-
|
|
10
|
-
-->
|
|
11
|
-
|
|
12
|
-
<template>
|
|
13
|
-
<li
|
|
14
|
-
data-option
|
|
15
|
-
:data-value="value"
|
|
16
|
-
:class="[
|
|
17
|
-
`cv-dropdown-item ${carbonPrefix}--dropdown-item`,
|
|
18
|
-
{ [`${carbonPrefix}--dropdown--selected`]: internalSelected },
|
|
19
|
-
]"
|
|
20
|
-
role="menuitem"
|
|
21
|
-
>
|
|
22
|
-
<a
|
|
23
|
-
:aria-checked="internalSelected"
|
|
24
|
-
:class="`${carbonPrefix}--dropdown-link`"
|
|
25
|
-
href="javascript:void(0)"
|
|
26
|
-
ref="link"
|
|
27
|
-
role="menuitemradio"
|
|
28
|
-
tabindex="-1"
|
|
29
|
-
>
|
|
30
|
-
<slot></slot>
|
|
31
|
-
</a>
|
|
32
|
-
</li>
|
|
33
|
-
</template>
|
|
34
|
-
|
|
35
|
-
<script>
|
|
36
|
-
import { carbonPrefixMixin } from '../../mixins';
|
|
37
|
-
export default {
|
|
38
|
-
name: 'CvDropdownItem',
|
|
39
|
-
mixins: [carbonPrefixMixin],
|
|
40
|
-
props: {
|
|
41
|
-
value: {
|
|
42
|
-
type: String,
|
|
43
|
-
required: true,
|
|
44
|
-
},
|
|
45
|
-
selected: Boolean,
|
|
46
|
-
},
|
|
47
|
-
watch: {
|
|
48
|
-
selected() {
|
|
49
|
-
this.dataSelected = this.selected;
|
|
50
|
-
this.$parent.$emit('cv:selected', this);
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
data() {
|
|
54
|
-
return {
|
|
55
|
-
dataSelected: undefined,
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
mounted() {
|
|
59
|
-
this.$_CvDropdownItem = true; // for use by parent with $children
|
|
60
|
-
this.$parent.$emit('cv:mounted', this);
|
|
61
|
-
},
|
|
62
|
-
beforeDestroy() {
|
|
63
|
-
this.$parent.$emit('cv:beforeDestroy', this);
|
|
64
|
-
},
|
|
65
|
-
computed: {
|
|
66
|
-
internalSelected: {
|
|
67
|
-
get() {
|
|
68
|
-
return this.dataSelected === undefined ? this.selected : this.dataSelected === true;
|
|
69
|
-
},
|
|
70
|
-
set(val) {
|
|
71
|
-
this.dataSelected = val;
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
internalContent() {
|
|
75
|
-
return this.$refs.link.innerHTML;
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
methods: {
|
|
79
|
-
setFocus() {
|
|
80
|
-
this.$refs.link.focus();
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
</script>
|