@datagouv/components-next 0.0.21 → 0.0.22

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.
@@ -1,4 +1,4 @@
1
- import { g as Ke } from "./main-CgjLq1oz.js";
1
+ import { g as Ke } from "./main-qCXX5fcf.js";
2
2
  import We from "vue";
3
3
  function Fe(I, K) {
4
4
  for (var V = 0; V < K.length; V++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datagouv/components-next",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./src/main.ts",
@@ -22,6 +22,7 @@
22
22
  "publish-stable": "npm publish --access public"
23
23
  },
24
24
  "dependencies": {
25
+ "@floating-ui/vue": "^1.1.8",
25
26
  "@headlessui/vue": "^1.7.23",
26
27
  "@remixicon/vue": "^4.5.0",
27
28
  "@vueuse/core": "^13.1.0",
@@ -42,6 +42,7 @@ import { getOrganizationType, isOrganizationCertified } from '../functions/organ
42
42
  import type { Organization } from '../types/organizations'
43
43
  import { useComponentsConfig } from '../config'
44
44
  import OwnerTypeIcon from './OwnerTypeIcon.vue'
45
+ import Tooltip from './Tooltip.vue'
45
46
 
46
47
  const config = useComponentsConfig()
47
48
 
@@ -0,0 +1,57 @@
1
+ <template>
2
+ <div
3
+ class="relative"
4
+ @focusin="show = true"
5
+ @mouseenter="show = true"
6
+ @focusout="show = false"
7
+ @mouseleave="show = false"
8
+ >
9
+ <p
10
+ ref="reference"
11
+ v-bind="$attrs"
12
+ :aria-describedby="id"
13
+ class="!mb-0"
14
+ >
15
+ <slot />
16
+ </p>
17
+
18
+ <div
19
+ v-if="show"
20
+ :id
21
+ ref="floating"
22
+ role="tooltip"
23
+ aria-hidden="true"
24
+ class="z-10 pt-2"
25
+ :class="tooltipClass"
26
+ :style="loaded ? floatingStyles : ''"
27
+ >
28
+ <div class="drop-shadow bg-white p-2 whitespace-nowrap">
29
+ <slot name="tooltip" />
30
+ </div>
31
+ </div>
32
+ </div>
33
+ </template>
34
+
35
+ <script setup lang="ts">
36
+ import { useFloating, autoUpdate, autoPlacement } from '@floating-ui/vue'
37
+ import { onMounted, ref, useId, useTemplateRef } from 'vue'
38
+
39
+ defineProps<{
40
+ tooltipClass?: string
41
+ }>()
42
+
43
+ const id = useId()
44
+ const show = ref(false)
45
+ const loaded = ref(false)
46
+
47
+ const referenceRef = useTemplateRef('reference')
48
+ const floatingRef = useTemplateRef('floating')
49
+ const { floatingStyles } = useFloating(referenceRef, floatingRef, {
50
+ middleware: [autoPlacement({
51
+ allowedPlacements: ['bottom-start', 'bottom', 'bottom-end'],
52
+ })],
53
+ whileElementsMounted: autoUpdate,
54
+ })
55
+
56
+ onMounted(() => loaded.value = true)
57
+ </script>
package/src/main.ts CHANGED
@@ -43,6 +43,7 @@ import Swagger from './components/ResourceAccordion/Swagger.client.vue'
43
43
  import ReuseCard from './components/ReuseCard.vue'
44
44
  import SimpleBanner from './components/SimpleBanner.vue'
45
45
  import StatBox from './components/StatBox.vue'
46
+ import Tooltip from './components/Tooltip.vue'
46
47
  import type { UseFetchFunction } from './functions/api.types'
47
48
  import { configKey, useComponentsConfig, type PluginConfig } from './config.js'
48
49
 
@@ -147,4 +148,5 @@ export {
147
148
  SimpleBanner,
148
149
  StatBox,
149
150
  Swagger,
151
+ Tooltip,
150
152
  }
@@ -1,4 +0,0 @@
1
- import { _ as f } from "./main-CgjLq1oz.js";
2
- export {
3
- f as default
4
- };