@icij/murmur-next 4.0.0 → 4.0.3
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 +15 -19
- package/dist/lib/components/AccordionStep.vue.d.ts +79 -0
- package/dist/lib/components/AccordionWrapper.vue.d.ts +33 -0
- package/dist/lib/components/ActiveTextTruncate.vue.d.ts +101 -0
- package/dist/lib/components/AdvancedLinkForm.vue.d.ts +168 -0
- package/dist/lib/components/Brand.vue.d.ts +55 -0
- package/dist/lib/components/BrandExpansion.vue.d.ts +105 -0
- package/dist/lib/components/ConfirmButton.vue.d.ts +158 -0
- package/dist/lib/components/ContentPlaceholder.vue.d.ts +44 -0
- package/dist/lib/components/CustomPagination.vue.d.ts +130 -0
- package/dist/lib/components/DigitsInput.vue.d.ts +66 -0
- package/dist/lib/components/DonateForm.vue.d.ts +46 -0
- package/dist/lib/components/EmbedForm.vue.d.ts +121 -0
- package/dist/lib/components/EmbeddableFooter.vue.d.ts +103 -0
- package/dist/lib/components/FollowUsPopover.vue.d.ts +16 -0
- package/dist/lib/components/GenericFooter.vue.d.ts +47 -0
- package/dist/lib/components/GenericHeader.vue.d.ts +928 -0
- package/dist/lib/components/HapticCopy.vue.d.ts +156 -0
- package/dist/lib/components/ImddbHeader.vue.d.ts +960 -0
- package/dist/lib/components/OrdinalLegend.vue.d.ts +87 -0
- package/dist/lib/components/RangePicker.vue.d.ts +196 -0
- package/dist/lib/components/ResponsiveIframe.vue.d.ts +45 -0
- package/dist/lib/components/ScaleLegend.vue.d.ts +101 -0
- package/dist/lib/components/SecretInput.vue.d.ts +99 -0
- package/dist/lib/components/SelectableDropdown.vue.d.ts +210 -0
- package/dist/lib/components/SharingOptions.vue.d.ts +153 -0
- package/dist/lib/components/SharingOptionsLink.vue.d.ts +200 -0
- package/dist/lib/components/SignUpForm.vue.d.ts +141 -0
- package/dist/lib/components/SlideUpDown.vue.d.ts +74 -0
- package/dist/lib/components/TexturedDeck.vue.d.ts +89 -0
- package/dist/lib/components/TinyPagination.vue.d.ts +188 -0
- package/dist/lib/composables/chart.d.ts +48 -0
- package/dist/lib/composables/resizeObserver.d.ts +22 -0
- package/dist/lib/composables/sendEmail.d.ts +6 -0
- package/dist/lib/config.d.ts +19 -0
- package/dist/lib/config.default.d.ts +34 -0
- package/dist/lib/datavisualisations/BarChart.vue.d.ts +234 -0
- package/dist/lib/datavisualisations/ColumnChart.vue.d.ts +404 -0
- package/dist/lib/datavisualisations/LineChart.vue.d.ts +200 -0
- package/dist/lib/datavisualisations/StackedBarChart.vue.d.ts +342 -0
- package/dist/lib/datavisualisations/StackedColumnChart.vue.d.ts +412 -0
- package/dist/lib/enums.d.ts +32 -0
- package/dist/lib/i18n.d.ts +4 -0
- package/dist/lib/keys.d.ts +2 -0
- package/dist/lib/main.d.ts +52 -0
- package/dist/lib/maps/ChoroplethMap.vue.d.ts +460 -0
- package/dist/lib/maps/ChoroplethMapAnnotation.vue.d.ts +188 -0
- package/dist/lib/maps/SymbolMap.vue.d.ts +276 -0
- package/dist/lib/murmur.css +1 -0
- package/dist/lib/murmur.js +44661 -0
- package/dist/lib/murmur.js.map +1 -0
- package/dist/lib/murmur.umd.cjs +837 -0
- package/dist/lib/murmur.umd.cjs.map +1 -0
- package/dist/lib/types.d.ts +44 -0
- package/dist/lib/utils/animation.d.ts +8 -0
- package/dist/lib/utils/assets.d.ts +2 -0
- package/dist/lib/utils/clipboard.d.ts +2 -0
- package/dist/lib/utils/iframe-resizer.d.ts +10 -0
- package/dist/lib/utils/placeholder.d.ts +12 -0
- package/dist/lib/utils/placeholderTypes.d.ts +18 -0
- package/dist/lib/utils/strings.d.ts +1 -0
- package/lib/components/AccordionStep.vue +53 -42
- package/lib/components/AccordionWrapper.vue +25 -24
- package/lib/components/ActiveTextTruncate.vue +44 -22
- package/lib/components/AdvancedLinkForm.vue +96 -46
- package/lib/components/Brand.vue +30 -23
- package/lib/components/BrandExpansion.vue +12 -3
- package/lib/components/ConfirmButton.vue +30 -26
- package/lib/components/ContentPlaceholder.vue +11 -7
- package/lib/components/CustomPagination.vue +50 -32
- package/lib/components/DigitsInput.vue +64 -60
- package/lib/components/DonateForm.vue +112 -83
- package/lib/components/EmbedForm.vue +37 -21
- package/lib/components/EmbeddableFooter.vue +14 -10
- package/lib/components/FollowUsPopover.vue +42 -40
- package/lib/components/GenericFooter.vue +98 -23
- package/lib/components/GenericHeader.vue +66 -29
- package/lib/components/HapticCopy.vue +41 -29
- package/lib/components/ImddbHeader.vue +113 -92
- package/lib/components/OrdinalLegend.vue +43 -20
- package/lib/components/RangePicker.vue +63 -42
- package/lib/components/ResponsiveIframe.vue +9 -2
- package/lib/components/ScaleLegend.vue +56 -18
- package/lib/components/SecretInput.vue +7 -8
- package/lib/components/SelectableDropdown.vue +119 -74
- package/lib/components/SharingOptions.vue +93 -36
- package/lib/components/SharingOptionsLink.vue +11 -5
- package/lib/components/SignUpForm.vue +44 -23
- package/lib/components/SlideUpDown.vue +7 -2
- package/lib/components/TexturedDeck.vue +24 -14
- package/lib/components/TinyPagination.vue +35 -22
- package/lib/composables/chart.ts +174 -157
- package/lib/composables/resizeObserver.ts +29 -29
- package/lib/composables/sendEmail.ts +53 -42
- package/lib/config.default.ts +17 -10
- package/lib/config.ts +34 -27
- package/lib/datavisualisations/BarChart.vue +48 -42
- package/lib/datavisualisations/ColumnChart.vue +133 -89
- package/lib/datavisualisations/LineChart.vue +79 -57
- package/lib/datavisualisations/StackedBarChart.vue +116 -68
- package/lib/datavisualisations/StackedColumnChart.vue +196 -115
- package/lib/enums.ts +25 -15
- package/lib/i18n.ts +3 -3
- package/lib/keys.ts +2 -2
- package/lib/main.ts +14 -10
- package/lib/maps/ChoroplethMap.vue +299 -160
- package/lib/maps/ChoroplethMapAnnotation.vue +29 -18
- package/lib/maps/SymbolMap.vue +194 -123
- package/lib/shims-bootstrap-vue.d.ts +1 -1
- package/lib/shims-vue.d.ts +3 -3
- package/lib/styles/functions.scss +10 -6
- package/lib/styles/lib.scss +2 -4
- package/lib/styles/mixins.scss +8 -8
- package/lib/styles/utilities.scss +1 -1
- package/lib/styles/variables.scss +24 -18
- package/lib/types.ts +26 -10
- package/lib/utils/animation.ts +4 -4
- package/lib/utils/assets.ts +31 -28
- package/lib/utils/clipboard.ts +16 -10
- package/lib/utils/iframe-resizer.ts +18 -13
- package/lib/utils/placeholder.ts +54 -23
- package/lib/utils/placeholderTypes.ts +3 -3
- package/package.json +21 -2
- package/.github/workflows/deploy-github-pages.yaml +0 -50
- package/.storybook/app.scss +0 -14
- package/.storybook/doc_variables.scss +0 -20
- package/.storybook/main.ts +0 -35
- package/.storybook/preview-head.html +0 -2
- package/.storybook/preview.ts +0 -32
- package/deploy.js +0 -15
- package/docs/components/ApiTable.vue +0 -171
- package/docs/components/App.vue +0 -146
- package/docs/components/CollapsibleBlock.vue +0 -122
- package/docs/components/DocsHeader.vue +0 -68
- package/docs/components/DocsMenu.vue +0 -201
- package/docs/components/DocsMenuSection.vue +0 -109
- package/docs/components/EditLink.vue +0 -49
- package/docs/components/OutboundLink.vue +0 -13
- package/docs/components/PalettePresenter.vue +0 -96
- package/docs/components/RepositoryLink.vue +0 -28
- package/docs/components/SampleCard.vue +0 -119
- package/docs/main.js +0 -42
- package/docs/pages/components/accordion/doc.md +0 -96
- package/docs/pages/components/active-text-truncate/doc.md +0 -44
- package/docs/pages/components/advanced-link-form/doc.md +0 -105
- package/docs/pages/components/brand/doc.md +0 -30
- package/docs/pages/components/brand-expansion/doc.md +0 -70
- package/docs/pages/components/confirm-button/doc.md +0 -91
- package/docs/pages/components/content-placeholder/doc.md +0 -16
- package/docs/pages/components/custom-pagination/doc.md +0 -61
- package/docs/pages/components/digits-input/doc.md +0 -28
- package/docs/pages/components/donate-form/doc.md +0 -20
- package/docs/pages/components/embed-form/doc.md +0 -22
- package/docs/pages/components/embeddable-footer/doc.md +0 -60
- package/docs/pages/components/follow-us-popover/doc.md +0 -5
- package/docs/pages/components/generic-footer/doc.md +0 -21
- package/docs/pages/components/generic-header/doc.md +0 -24
- package/docs/pages/components/haptic-copy/doc.md +0 -27
- package/docs/pages/components/imddb-header/doc.md +0 -23
- package/docs/pages/components/ordinal-legend/doc.md +0 -44
- package/docs/pages/components/range-picker/doc.md +0 -86
- package/docs/pages/components/responsive-iframe/doc.md +0 -13
- package/docs/pages/components/scale-legend/doc.md +0 -65
- package/docs/pages/components/secret-input/doc.md +0 -12
- package/docs/pages/components/selectable-dropdown/doc.md +0 -156
- package/docs/pages/components/sharing-options/doc.md +0 -13
- package/docs/pages/components/sharing-options-link/doc.md +0 -36
- package/docs/pages/components/sign-up-form/doc.md +0 -13
- package/docs/pages/components/slide-up-down/doc.md +0 -28
- package/docs/pages/components/textured-deck/doc.md +0 -78
- package/docs/pages/components/tiny-pagination/doc.md +0 -92
- package/docs/pages/datavisualisation/bars/doc.md +0 -110
- package/docs/pages/datavisualisation/columns/doc.md +0 -165
- package/docs/pages/datavisualisation/lines/doc.md +0 -139
- package/docs/pages/datavisualisation/stacked-bar/doc.md +0 -160
- package/docs/pages/datavisualisation/stacked-column/doc.md +0 -191
- package/docs/pages/getting-started/about-icij/doc.md +0 -13
- package/docs/pages/getting-started/custom-bootstrap/doc.md +0 -36
- package/docs/pages/getting-started/installation-guide/doc.md +0 -59
- package/docs/pages/getting-started/internationalization/doc.md +0 -74
- package/docs/pages/maps/choropleth-map/doc.md +0 -420
- package/docs/pages/maps/choropleth-map-annotation/doc.md +0 -373
- package/docs/pages/maps/symbol-map/doc.md +0 -203
- package/docs/pages/structure/breakpoints/doc.md +0 -3
- package/docs/pages/structure/grid/doc.md +0 -3
- package/docs/pages/utilities/assets/doc.md +0 -138
- package/docs/pages/utilities/config/doc.md +0 -52
- package/docs/pages/utilities/iframes/doc.md +0 -3
- package/docs/pages/visual/colors/doc.md +0 -31
- package/docs/pages/visual/iconography/doc.md +0 -56
- package/docs/pages/visual/states/doc.md +0 -77
- package/docs/pages/visual/themes/doc.md +0 -3
- package/docs/pages/visual/typography/doc.md +0 -71
- package/docs/routes.js +0 -25
- package/docs/store/index.js +0 -21
- package/docs/styles/app.scss +0 -36
- package/docs/styles/variables.scss +0 -20
- package/loaders/highlight-loader.js +0 -13
- package/loaders/markdown-loader.js +0 -91
- package/loaders/metadata-loader.js +0 -18
- package/loaders/sass-extract-loader.js +0 -14
- package/loaders/vue-docgen-loader.js +0 -14
- package/plugins/MdPluginTypes.ts +0 -10
- package/plugins/docs.ts +0 -50
- package/plugins/front-matter.ts +0 -36
- package/plugins/highlight.ts +0 -27
- package/plugins/markdown-it/api-table.ts +0 -25
- package/plugins/markdown-it/sample-card.ts +0 -31
- package/plugins/plugin-delete.ts +0 -47
- package/plugins/plugin-docgen.ts +0 -23
- package/plugins/sass-vars.ts +0 -25
- package/plugins/vue-docgen.ts +0 -29
- package/public/android-chrome-192x192.png +0 -0
- package/public/android-chrome-512x512.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/assets/img/arrow-bottom.svg +0 -3
- package/public/assets/img/texture-brick-black.jpg +0 -0
- package/public/assets/img/texture-brick.jpg +0 -0
- package/public/assets/img/texture-carbon-black.jpg +0 -0
- package/public/assets/img/texture-carbon.jpg +0 -0
- package/public/assets/img/texture-crack-black.jpg +0 -0
- package/public/assets/img/texture-crack.jpg +0 -0
- package/public/assets/img/texture-rock-black.jpg +0 -0
- package/public/assets/img/texture-rock.jpg +0 -0
- package/public/assets/img/texture-sand-black.jpg +0 -0
- package/public/assets/img/texture-sand.jpg +0 -0
- package/public/assets/img/texture-silk-black.jpg +0 -0
- package/public/assets/img/texture-silk.jpg +0 -0
- package/public/assets/topojson/france-departments.json +0 -1
- package/public/assets/topojson/paris-arrondissements.json +0 -1
- package/public/assets/topojson/world-countries-sans-antarctica.json +0 -1
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/site.webmanifest +0 -1
- package/stories/assets/code-brackets.svg +0 -1
- package/stories/assets/colors.svg +0 -1
- package/stories/assets/comments.svg +0 -1
- package/stories/assets/direction.svg +0 -1
- package/stories/assets/flow.svg +0 -1
- package/stories/assets/plugin.svg +0 -1
- package/stories/assets/repo.svg +0 -1
- package/stories/assets/stackalt.svg +0 -1
- package/stories/getting-started/about-icij.mdx +0 -14
- package/stories/getting-started/custom-bootstrap.mdx +0 -23
- package/stories/getting-started/installation-guide.mdx +0 -62
- package/stories/getting-started/internationalization.mdx +0 -63
- package/stories/murmur/components/AccordionStep.stories.ts +0 -33
- package/stories/murmur/components/AccordionWrapper.stories.ts +0 -69
- package/stories/murmur/components/ActiveTextTruncate.stories.ts +0 -32
- package/stories/murmur/components/AdvancedLinkForm.stories.ts +0 -77
- package/stories/murmur/components/Brand.stories.ts +0 -30
- package/stories/murmur/components/BrandExpansion.stories.ts +0 -41
- package/stories/murmur/components/ConfirmButton.stories.ts +0 -40
- package/stories/murmur/components/ContentPlaceholder.stories.ts +0 -41
- package/stories/murmur/components/CustomPagination.stories.ts +0 -42
- package/stories/murmur/components/DigitsInput.stories.ts +0 -29
- package/stories/murmur/components/DonateForm.stories.ts +0 -29
- package/stories/murmur/components/EmbedForm.stories.ts +0 -35
- package/stories/murmur/components/EmbeddableFooter.stories.ts +0 -59
- package/stories/murmur/components/FollowUsPopover.stories.ts +0 -24
- package/stories/murmur/components/GenericFooter.stories.ts +0 -27
- package/stories/murmur/components/GenericHeader.stories.ts +0 -27
- package/stories/murmur/components/HapticCopy.stories.ts +0 -40
- package/stories/murmur/components/ImddbHeader.stories.ts +0 -27
- package/stories/murmur/components/OrdinalLegend.stories.ts +0 -49
- package/stories/murmur/components/RangePicker.stories.ts +0 -98
- package/stories/murmur/components/ResponsiveIframe.stories.ts +0 -24
- package/stories/murmur/components/ScaleLegend.stories.ts +0 -65
- package/stories/murmur/components/SecretInput.stories.ts +0 -60
- package/stories/murmur/components/SelectableDropdown.stories.ts +0 -143
- package/stories/murmur/components/SharingOptions.stories.ts +0 -32
- package/stories/murmur/components/SharingOptionsLink.stories.ts +0 -53
- package/stories/murmur/components/SignUpForm.stories.ts +0 -51
- package/stories/murmur/components/SlideUpDown.stories.ts +0 -32
- package/stories/murmur/components/TexturedDeck.stories.ts +0 -83
- package/stories/murmur/components/TinyPagination.stories.ts +0 -65
- package/stories/murmur/datavisualisations/BarChart.stories.ts +0 -54
- package/stories/murmur/datavisualisations/ColumnChart.stories.ts +0 -88
- package/stories/murmur/datavisualisations/LineChart.stories.ts +0 -139
- package/stories/murmur/datavisualisations/StackedBarChart.stories.ts +0 -199
- package/stories/murmur/datavisualisations/StackedColumnChart.stories.ts +0 -136
- package/stories/murmur/decorators.ts +0 -108
- package/stories/murmur/maps/ChoroplethMap.stories.ts +0 -440
- package/stories/murmur/maps/ChoroplethMapAnnotation.stories.ts +0 -26
- package/stories/murmur/maps/SymbolMap.stories.ts +0 -24
- package/stories/murmur/utils.ts +0 -7
- package/tests/unit/components/AccordionStep.spec.ts +0 -157
- package/tests/unit/components/AccordionWrapper.spec.ts +0 -57
- package/tests/unit/components/ActiveTextTruncate.spec.js +0 -30
- package/tests/unit/components/AdvancedLinkForm.spec.js +0 -124
- package/tests/unit/components/Brand.spec.js +0 -50
- package/tests/unit/components/ContentPlaceholder.spec.js +0 -29
- package/tests/unit/components/CustomPagination.spec.js +0 -72
- package/tests/unit/components/DigitsInput.spec.ts +0 -157
- package/tests/unit/components/DonateForm.spec.js +0 -149
- package/tests/unit/components/EmbedForm.spec.js +0 -108
- package/tests/unit/components/EmbeddableFooter.spec.js +0 -11
- package/tests/unit/components/Fa.spec.js +0 -18
- package/tests/unit/components/FollowUsPopover.spec.js +0 -29
- package/tests/unit/components/GenericFooter.spec.js +0 -29
- package/tests/unit/components/GenericHeader.spec.js +0 -104
- package/tests/unit/components/HapticCopy.spec.js +0 -123
- package/tests/unit/components/ImddbHeader.spec.js +0 -96
- package/tests/unit/components/OrdinalLegend.spec.js +0 -120
- package/tests/unit/components/RangePicker.spec.ts +0 -87
- package/tests/unit/components/ResponsiveIframe.spec.js +0 -20
- package/tests/unit/components/ScaleLegend.spec.js +0 -139
- package/tests/unit/components/SecretInput.spec.js +0 -81
- package/tests/unit/components/SelectableDropdown.spec.js +0 -160
- package/tests/unit/components/SharingOptions.spec.js +0 -125
- package/tests/unit/components/SharingOptionsLink.spec.js +0 -184
- package/tests/unit/components/SignUpForm.spec.js +0 -145
- package/tests/unit/components/SlideUpDown.spec.js +0 -59
- package/tests/unit/components/TinyPagination.spec.js +0 -46
- package/tests/unit/config.spec.js +0 -136
- package/tests/unit/datavisualisations/BarChart.spec.js +0 -63
- package/tests/unit/datavisualisations/ColumnChart.spec.js +0 -344
- package/tests/unit/datavisualisations/LineChart.spec.js +0 -155
- package/tests/unit/datavisualisations/StackedBarChart.spec.js +0 -294
- package/tests/unit/datavisualisations/StackedColumnChart.spec.js +0 -443
- package/tests/unit/i18n.spec.ts +0 -19
- package/tests/unit/main.spec.js +0 -82
- package/tests/unit/maps/ChoroplethMap.spec.js +0 -214
- package/tests/unit/maps/ChoroplethMapAnnotation.spec.ts +0 -186
- package/tests/unit/maps/SymbolMap.spec.js +0 -92
- package/tests/unit/require.spec.js +0 -22
- package/tests/unit/setup.js +0 -13
- package/tests/unit/utils/assets.spec.js +0 -61
- package/tests/unit/utils/clipboard.spec.js +0 -18
- package/tests/unit/utils/iframe-resizer.spec.js +0 -71
- package/tsconfig.json +0 -35
- package/vite.config.ts +0 -79
- package/vitest.config.ts +0 -19
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {isFunction, isString} from 'lodash'
|
|
2
|
+
import { isFunction, isString } from 'lodash'
|
|
3
3
|
import * as d3 from 'd3'
|
|
4
4
|
import * as scaleFunctions from 'd3-scale'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
defineComponent,
|
|
7
|
+
PropType,
|
|
8
|
+
ref,
|
|
9
|
+
computed,
|
|
10
|
+
onMounted,
|
|
11
|
+
watch,
|
|
12
|
+
nextTick,
|
|
13
|
+
toRef
|
|
14
|
+
} from 'vue'
|
|
6
15
|
|
|
7
16
|
type ClassListLegend = { 'scale-legend--has-cursor': boolean }
|
|
8
17
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -39,7 +48,9 @@ export default defineComponent({
|
|
|
39
48
|
type: [Function, String] as PropType<ColorScaleFn | string>,
|
|
40
49
|
default: 'scaleLinear',
|
|
41
50
|
validator(colorScale: ColorScale) {
|
|
42
|
-
return
|
|
51
|
+
return (
|
|
52
|
+
isFunction(colorScale) || (colorScale as string) in scaleFunctions
|
|
53
|
+
)
|
|
43
54
|
}
|
|
44
55
|
},
|
|
45
56
|
colorScaleEnd: {
|
|
@@ -76,7 +87,11 @@ export default defineComponent({
|
|
|
76
87
|
return isNaN(left) ? '0%' : `${left}%`
|
|
77
88
|
})
|
|
78
89
|
const colorScaleBaseCanvas = computed((): HTMLCanvasElement | null => {
|
|
79
|
-
return d3
|
|
90
|
+
return d3
|
|
91
|
+
.create('canvas')
|
|
92
|
+
.attr('width', props.width)
|
|
93
|
+
.attr('height', props.height)
|
|
94
|
+
.node()
|
|
80
95
|
})
|
|
81
96
|
const colorScaleContext = computed((): CanvasRenderingContext2D | null => {
|
|
82
97
|
return colorScaleBaseCanvas.value?.getContext('2d') ?? null
|
|
@@ -97,12 +112,18 @@ export default defineComponent({
|
|
|
97
112
|
if (isString(props.colorScale)) {
|
|
98
113
|
// @ts-ignore
|
|
99
114
|
const fn: () => any = scaleFunctions[props.colorScale]
|
|
100
|
-
return fn()
|
|
115
|
+
return fn()
|
|
116
|
+
.domain([props.min, props.max])
|
|
117
|
+
.range([props.colorScaleStart, props.colorScaleEnd])
|
|
101
118
|
}
|
|
102
119
|
return props.colorScale
|
|
103
120
|
})
|
|
104
121
|
const cursorLeftScale = computed((): d3.ScaleLinear<number, number> => {
|
|
105
|
-
return d3
|
|
122
|
+
return d3
|
|
123
|
+
.scaleLinear()
|
|
124
|
+
.domain([props.min, props.max])
|
|
125
|
+
.range([0, 100])
|
|
126
|
+
.interpolate(d3.interpolateRound)
|
|
106
127
|
})
|
|
107
128
|
const widthScaleColor = computed((): WidthScaleFn => {
|
|
108
129
|
return (x: number) => {
|
|
@@ -111,7 +132,10 @@ export default defineComponent({
|
|
|
111
132
|
}
|
|
112
133
|
})
|
|
113
134
|
const widthScale = computed((): d3.ScaleLinear<number, number> => {
|
|
114
|
-
return d3
|
|
135
|
+
return d3
|
|
136
|
+
.scaleLinear()
|
|
137
|
+
.domain([0, props.width])
|
|
138
|
+
.range([props.min, props.max])
|
|
115
139
|
})
|
|
116
140
|
|
|
117
141
|
const formatNumber = d3.format(',')
|
|
@@ -119,8 +143,10 @@ export default defineComponent({
|
|
|
119
143
|
function setCursorWrapperOffset(): void {
|
|
120
144
|
const cursor = el.value?.querySelector('.scale-legend__cursor')
|
|
121
145
|
if (cursor && el.value) {
|
|
122
|
-
const {x: cursorX, width: cursorWidth} =
|
|
123
|
-
|
|
146
|
+
const { x: cursorX, width: cursorWidth } =
|
|
147
|
+
cursor.getBoundingClientRect()
|
|
148
|
+
const { x: legendX, width: legendWidth } =
|
|
149
|
+
el.value.getBoundingClientRect()
|
|
124
150
|
const left = legendX - cursorX - 6
|
|
125
151
|
const right = legendX + legendWidth - (cursorX + cursorWidth) + 6
|
|
126
152
|
cursorWrapperOffset.value = Math.max(0, left) || Math.min(0, right)
|
|
@@ -139,11 +165,10 @@ export default defineComponent({
|
|
|
139
165
|
}
|
|
140
166
|
}
|
|
141
167
|
|
|
142
|
-
watch(cursorValue,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
})
|
|
168
|
+
watch(cursorValue, async () => {
|
|
169
|
+
await nextTick()
|
|
170
|
+
setCursorWrapperOffset()
|
|
171
|
+
})
|
|
147
172
|
|
|
148
173
|
return {
|
|
149
174
|
classList,
|
|
@@ -155,7 +180,7 @@ export default defineComponent({
|
|
|
155
180
|
//CD: function below are only uses in unit tests. use callable?
|
|
156
181
|
widthScale,
|
|
157
182
|
colorScaleFunction,
|
|
158
|
-
widthScaleColor
|
|
183
|
+
widthScaleColor
|
|
159
184
|
}
|
|
160
185
|
}
|
|
161
186
|
})
|
|
@@ -168,14 +193,27 @@ export default defineComponent({
|
|
|
168
193
|
{{ formatNumber(min) }}
|
|
169
194
|
</slot>
|
|
170
195
|
</div>
|
|
171
|
-
<img
|
|
196
|
+
<img
|
|
197
|
+
:height="height"
|
|
198
|
+
:src="colorScaleBase64"
|
|
199
|
+
:width="width"
|
|
200
|
+
class="scale-legend__scale"
|
|
201
|
+
alt="legend scale"
|
|
202
|
+
/>
|
|
172
203
|
<div class="scale-legend__bound scale-legend__bound--max">
|
|
173
204
|
<slot name="legend-cursor-max" v-bind="{ max }">
|
|
174
205
|
{{ formatNumber(max) }}
|
|
175
206
|
</slot>
|
|
176
207
|
</div>
|
|
177
|
-
<div
|
|
178
|
-
|
|
208
|
+
<div
|
|
209
|
+
v-if="hasCursor"
|
|
210
|
+
:style="{ left: cursorLeft }"
|
|
211
|
+
class="scale-legend__cursor"
|
|
212
|
+
>
|
|
213
|
+
<div
|
|
214
|
+
:style="{ transform: `translateX(${cursorWrapperOffset}px)` }"
|
|
215
|
+
class="scale-legend__cursor__wrapper"
|
|
216
|
+
>
|
|
179
217
|
<slot name="cursor" v-bind="{ value: cursorValue }">
|
|
180
218
|
{{ formatNumber(cursorValue) }}
|
|
181
219
|
</slot>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { faEye, faEyeSlash } from '@fortawesome/free-regular-svg-icons'
|
|
3
3
|
|
|
4
|
-
import { computed,ref,onBeforeMount, watch,defineComponent} from 'vue'
|
|
4
|
+
import { computed, ref, onBeforeMount, watch, defineComponent } from 'vue'
|
|
5
5
|
import { library, default as Fa } from './Fa'
|
|
6
6
|
import HapticCopy from './HapticCopy.vue'
|
|
7
7
|
|
|
@@ -49,12 +49,12 @@ export default defineComponent({
|
|
|
49
49
|
type: Boolean
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
|
-
emits:['update:visible'],
|
|
53
|
-
setup(props,{emit}){
|
|
54
|
-
onBeforeMount(() =>{
|
|
52
|
+
emits: ['update:visible'],
|
|
53
|
+
setup(props, { emit }) {
|
|
54
|
+
onBeforeMount(() => {
|
|
55
55
|
library.add(faEye, faEyeSlash)
|
|
56
56
|
})
|
|
57
|
-
const secretInput = ref<HTMLInputElement|null>(null)
|
|
57
|
+
const secretInput = ref<HTMLInputElement | null>(null)
|
|
58
58
|
const inputType = computed(() => {
|
|
59
59
|
return props.visible ? 'text' : 'password'
|
|
60
60
|
})
|
|
@@ -62,10 +62,9 @@ export default defineComponent({
|
|
|
62
62
|
return props.visible ? ['far', 'eye-slash'] : ['far', 'eye']
|
|
63
63
|
})
|
|
64
64
|
const hapticCopyClassList = computed(() => {
|
|
65
|
-
|
|
65
|
+
return `btn-${props.hapticCopyVariant}`
|
|
66
66
|
})
|
|
67
67
|
|
|
68
|
-
|
|
69
68
|
function toggle() {
|
|
70
69
|
/**
|
|
71
70
|
* Emitted when the visibility of the input changes.
|
|
@@ -73,7 +72,7 @@ export default defineComponent({
|
|
|
73
72
|
* @event update:visible
|
|
74
73
|
* @type {Boolean}
|
|
75
74
|
*/
|
|
76
|
-
emit(
|
|
75
|
+
emit('update:visible', !props.visible)
|
|
77
76
|
}
|
|
78
77
|
function selectInput() {
|
|
79
78
|
if (props.visible) {
|
|
@@ -10,12 +10,20 @@ import { faCheckSquare, faSquare } from '@fortawesome/free-regular-svg-icons'
|
|
|
10
10
|
import { RecycleScroller } from 'vue-virtual-scroller'
|
|
11
11
|
|
|
12
12
|
import Fa from './Fa'
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
defineComponent,
|
|
15
|
+
ref,
|
|
16
|
+
computed,
|
|
17
|
+
watch,
|
|
18
|
+
onMounted,
|
|
19
|
+
onUnmounted,
|
|
20
|
+
PropType
|
|
21
|
+
} from 'vue'
|
|
14
22
|
|
|
15
23
|
const KEY_ESC_CODE = 27
|
|
16
24
|
const KEY_UP_CODE = 38
|
|
17
25
|
const KEY_DOWN_CODE = 40
|
|
18
|
-
type Item = any
|
|
26
|
+
type Item = any
|
|
19
27
|
export default defineComponent({
|
|
20
28
|
name: 'SelectableDropdown',
|
|
21
29
|
components: {
|
|
@@ -108,74 +116,90 @@ export default defineComponent({
|
|
|
108
116
|
default: 'inherit'
|
|
109
117
|
}
|
|
110
118
|
},
|
|
111
|
-
emits:['click','update:modelValue', 'deactivate'],
|
|
112
|
-
setup(props,{emit}){
|
|
113
|
-
onMounted(()=> {
|
|
119
|
+
emits: ['click', 'update:modelValue', 'deactivate'],
|
|
120
|
+
setup(props, { emit }) {
|
|
121
|
+
onMounted(() => {
|
|
114
122
|
activateItemOrItems()
|
|
115
123
|
toggleKeys()
|
|
116
124
|
})
|
|
117
125
|
onUnmounted(() => {
|
|
118
126
|
unbindKeys()
|
|
119
127
|
})
|
|
120
|
-
const scroller=ref(null)
|
|
121
|
-
const activeItems =
|
|
122
|
-
const cssProps = computed(()=>{
|
|
128
|
+
const scroller = ref(null)
|
|
129
|
+
const activeItems = ref<Item[]>([])
|
|
130
|
+
const cssProps = computed(() => {
|
|
123
131
|
return {
|
|
124
132
|
'--scroller-height': props.scrollerHeight
|
|
125
133
|
}
|
|
126
134
|
})
|
|
127
|
-
const keyField = computed(()=>{
|
|
135
|
+
const keyField = computed(() => {
|
|
128
136
|
return typeof items_.value[0] === 'string' ? null : 'recycle_scroller_id'
|
|
129
137
|
})
|
|
130
|
-
const items_ = computed(():Item[]=>{
|
|
138
|
+
const items_ = computed((): Item[] => {
|
|
131
139
|
if (typeof props.items[0] === 'string') {
|
|
132
140
|
return props.items
|
|
133
141
|
}
|
|
134
|
-
return props.items.map((item:Item) => ({
|
|
142
|
+
return props.items.map((item: Item) => ({
|
|
143
|
+
...item,
|
|
144
|
+
recycle_scroller_id: `id-${uniqueId()}`
|
|
145
|
+
}))
|
|
135
146
|
})
|
|
136
|
-
const firstActiveItemIndex = computed(()=>{
|
|
137
|
-
return activeItems.value.length
|
|
147
|
+
const firstActiveItemIndex = computed(() => {
|
|
148
|
+
return activeItems.value.length
|
|
149
|
+
? items_.value.indexOf(activeItems.value[0])
|
|
150
|
+
: -1
|
|
138
151
|
})
|
|
139
|
-
const lastActiveItemIndex = computed(()=>{
|
|
140
|
-
return activeItems.value.length
|
|
152
|
+
const lastActiveItemIndex = computed(() => {
|
|
153
|
+
return activeItems.value.length
|
|
154
|
+
? items_.value.indexOf(activeItems.value.slice(-1))
|
|
155
|
+
: -1
|
|
141
156
|
})
|
|
142
|
-
const keysMap = computed(():{[key:string]:Function }=>{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
-
watch(()=>props.hide,()=> {
|
|
151
|
-
toggleKeys()
|
|
152
|
-
})
|
|
153
|
-
watch(()=>activeItems.value,
|
|
154
|
-
()=> {
|
|
155
|
-
/**
|
|
156
|
-
* Fired when the selected value change. It will pass a canonical value
|
|
157
|
-
* or an array of values if the property `multiple` is set to true.
|
|
158
|
-
*
|
|
159
|
-
* @event input
|
|
160
|
-
* @type {String, Object, Array, Number}
|
|
161
|
-
*/
|
|
162
|
-
emit('update:modelValue', props.multiple ? activeItems.value : activeItems.value[0])
|
|
157
|
+
const keysMap = computed((): { [key: string]: Function } => {
|
|
158
|
+
return {
|
|
159
|
+
[KEY_UP_CODE]: activatePreviousItem,
|
|
160
|
+
[KEY_DOWN_CODE]: activateNextItem,
|
|
161
|
+
[KEY_ESC_CODE]: deactivateItems
|
|
162
|
+
}
|
|
163
163
|
})
|
|
164
|
-
watch(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
watch(
|
|
165
|
+
() => props.hide,
|
|
166
|
+
() => {
|
|
167
|
+
toggleKeys()
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
watch(
|
|
171
|
+
() => activeItems.value,
|
|
172
|
+
() => {
|
|
173
|
+
/**
|
|
174
|
+
* Fired when the selected value change. It will pass a canonical value
|
|
175
|
+
* or an array of values if the property `multiple` is set to true.
|
|
176
|
+
*
|
|
177
|
+
* @event input
|
|
178
|
+
* @type {String, Object, Array, Number}
|
|
179
|
+
*/
|
|
180
|
+
emit(
|
|
181
|
+
'update:modelValue',
|
|
182
|
+
props.multiple ? activeItems.value : activeItems.value[0]
|
|
183
|
+
)
|
|
169
184
|
}
|
|
185
|
+
)
|
|
186
|
+
watch(
|
|
187
|
+
() => props.modelValue,
|
|
188
|
+
(itemOrItems) => {
|
|
189
|
+
const items = castArray(itemOrItems)
|
|
190
|
+
if (!isEqual(activeItems.value, items)) {
|
|
191
|
+
activateItemOrItems(items)
|
|
192
|
+
}
|
|
170
193
|
},
|
|
171
|
-
|
|
172
|
-
|
|
194
|
+
{ deep: true }
|
|
195
|
+
)
|
|
196
|
+
function indexIcon(item: Item) {
|
|
173
197
|
return itemActivated(item) ? faCheckSquare : faSquare
|
|
174
198
|
}
|
|
175
|
-
function itemActivated(item:Item) {
|
|
199
|
+
function itemActivated(item: Item) {
|
|
176
200
|
return findIndex(activeItems.value, (i) => props.eq(item, i)) > -1
|
|
177
201
|
}
|
|
178
|
-
function clickToSelectItem(item:Item) {
|
|
202
|
+
function clickToSelectItem(item: Item) {
|
|
179
203
|
/**
|
|
180
204
|
* Fired when user click on an item
|
|
181
205
|
*
|
|
@@ -189,7 +213,7 @@ export default defineComponent({
|
|
|
189
213
|
selectItem(item)
|
|
190
214
|
}
|
|
191
215
|
}
|
|
192
|
-
function clickToAddItem(item:Item) {
|
|
216
|
+
function clickToAddItem(item: Item) {
|
|
193
217
|
/**
|
|
194
218
|
* Fired when user click on an item
|
|
195
219
|
*
|
|
@@ -199,7 +223,7 @@ export default defineComponent({
|
|
|
199
223
|
emit('click', item)
|
|
200
224
|
addItem(item)
|
|
201
225
|
}
|
|
202
|
-
function clickToSelectRangeToItem(item:Item) {
|
|
226
|
+
function clickToSelectRangeToItem(item: Item) {
|
|
203
227
|
/**
|
|
204
228
|
* Fired when user click on an item
|
|
205
229
|
*
|
|
@@ -209,33 +233,42 @@ export default defineComponent({
|
|
|
209
233
|
emit('click', item)
|
|
210
234
|
selectRangeToItem(item)
|
|
211
235
|
}
|
|
212
|
-
function emitEventOnItem(
|
|
236
|
+
function emitEventOnItem(
|
|
237
|
+
name: 'click' | 'update:modelValue' | 'deactivate',
|
|
238
|
+
item: Item
|
|
239
|
+
) {
|
|
213
240
|
emit(name, item)
|
|
214
241
|
}
|
|
215
|
-
function selectItem(item:Item) {
|
|
242
|
+
function selectItem(item: Item) {
|
|
216
243
|
if (itemActivated(item) && activeItems.value.length === 1) {
|
|
217
244
|
activeItems.value = filter(activeItems.value, (i) => !props.eq(item, i))
|
|
218
245
|
} else {
|
|
219
246
|
activeItems.value = [item]
|
|
220
247
|
}
|
|
221
248
|
}
|
|
222
|
-
function addItem(item:Item) {
|
|
249
|
+
function addItem(item: Item) {
|
|
223
250
|
if (itemActivated(item)) {
|
|
224
251
|
activeItems.value = filter(activeItems.value, (i) => !props.eq(item, i))
|
|
225
252
|
} else {
|
|
226
253
|
activeItems.value.push(item)
|
|
227
254
|
}
|
|
228
255
|
}
|
|
229
|
-
function selectRangeToItem(item:Item) {
|
|
256
|
+
function selectRangeToItem(item: Item) {
|
|
230
257
|
// No activated items
|
|
231
258
|
if (!activeItems.value.length || !props.multiple) {
|
|
232
259
|
selectItem(item)
|
|
233
260
|
} else {
|
|
234
261
|
const index = items_.value.indexOf(item)
|
|
235
262
|
if (index > firstActiveItemIndex.value) {
|
|
236
|
-
activeItems.value = items_.value.slice(
|
|
263
|
+
activeItems.value = items_.value.slice(
|
|
264
|
+
firstActiveItemIndex.value,
|
|
265
|
+
index + 1
|
|
266
|
+
)
|
|
237
267
|
} else {
|
|
238
|
-
activeItems.value = items_.value.slice(
|
|
268
|
+
activeItems.value = items_.value.slice(
|
|
269
|
+
index,
|
|
270
|
+
firstActiveItemIndex.value + 1
|
|
271
|
+
)
|
|
239
272
|
}
|
|
240
273
|
}
|
|
241
274
|
}
|
|
@@ -244,10 +277,16 @@ export default defineComponent({
|
|
|
244
277
|
activeItems.value = [...items]
|
|
245
278
|
}
|
|
246
279
|
function activatePreviousItem() {
|
|
247
|
-
activeItems.value = [
|
|
280
|
+
activeItems.value = [
|
|
281
|
+
items_.value[Math.max(firstActiveItemIndex.value - 1, -1)]
|
|
282
|
+
]
|
|
248
283
|
}
|
|
249
284
|
function activateNextItem() {
|
|
250
|
-
activeItems.value = [
|
|
285
|
+
activeItems.value = [
|
|
286
|
+
items_.value[
|
|
287
|
+
Math.min(firstActiveItemIndex.value + 1, items_.value.length - 1)
|
|
288
|
+
]
|
|
289
|
+
]
|
|
251
290
|
}
|
|
252
291
|
function deactivateItems() {
|
|
253
292
|
activeItems.value = []
|
|
@@ -258,7 +297,7 @@ export default defineComponent({
|
|
|
258
297
|
*/
|
|
259
298
|
emit('deactivate')
|
|
260
299
|
}
|
|
261
|
-
function keyDown(event:KeyboardEvent) {
|
|
300
|
+
function keyDown(event: KeyboardEvent) {
|
|
262
301
|
const keyCode = event.keyCode || event.which
|
|
263
302
|
// The dropdown must be active
|
|
264
303
|
if (props.deactivateKeys || props.hide || !isKnownKey(keyCode)) return
|
|
@@ -270,7 +309,7 @@ export default defineComponent({
|
|
|
270
309
|
// Then call the right method
|
|
271
310
|
keysMap.value[keyCode]()
|
|
272
311
|
}
|
|
273
|
-
function isKnownKey(keycode:number) {
|
|
312
|
+
function isKnownKey(keycode: number) {
|
|
274
313
|
return Object.keys(keysMap.value).map(Number).indexOf(keycode) > -1
|
|
275
314
|
}
|
|
276
315
|
function unbindKeys() {
|
|
@@ -286,7 +325,7 @@ export default defineComponent({
|
|
|
286
325
|
bindKeys()
|
|
287
326
|
}
|
|
288
327
|
}
|
|
289
|
-
function itemId(item:Item){
|
|
328
|
+
function itemId(item: Item) {
|
|
290
329
|
return `dropdown-item-${item.recycle_scroller_id ?? item.toLowerCase()}`
|
|
291
330
|
}
|
|
292
331
|
|
|
@@ -310,32 +349,38 @@ export default defineComponent({
|
|
|
310
349
|
|
|
311
350
|
<template>
|
|
312
351
|
<div
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
352
|
+
v-if="!hide"
|
|
353
|
+
class="selectable-dropdown show"
|
|
354
|
+
:class="{ 'selectable-dropdown--multiple': multiple, [listClass]: true }"
|
|
316
355
|
>
|
|
317
356
|
<recycle-scroller
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
357
|
+
v-slot="{ item, active }"
|
|
358
|
+
:style="cssProps"
|
|
359
|
+
class="scroller"
|
|
360
|
+
:items="items_"
|
|
361
|
+
:key-field="keyField"
|
|
362
|
+
:item-size="itemSize"
|
|
324
363
|
>
|
|
325
364
|
<span
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
365
|
+
:id="itemId(item)"
|
|
366
|
+
:class="{
|
|
367
|
+
'recycle_scroller-item--active': active,
|
|
368
|
+
active: itemActivated(item),
|
|
369
|
+
[itemClass]: true
|
|
370
|
+
}"
|
|
371
|
+
class="selectable-dropdown__item px-3 d-flex"
|
|
372
|
+
@click.exact="clickToSelectItem(item)"
|
|
373
|
+
@click.ctrl="clickToAddItem(item)"
|
|
374
|
+
@click.shift="clickToSelectRangeToItem(item)"
|
|
332
375
|
>
|
|
333
376
|
<!-- @slot Item content -->
|
|
334
377
|
<slot name="item" :item="item">
|
|
335
378
|
<div v-if="multiple" class="selectable-dropdown__item__check">
|
|
336
379
|
<fa :icon="indexIcon(item)" class="me-2" />
|
|
337
380
|
</div>
|
|
338
|
-
<div
|
|
381
|
+
<div
|
|
382
|
+
class="flex-grow-1 text-truncate selectable-dropdown__item__label"
|
|
383
|
+
>
|
|
339
384
|
<!-- @slot Item's label content -->
|
|
340
385
|
<slot name="item-label" :item="item">
|
|
341
386
|
{{ serializer(item) }}
|