@quazardous/qdadm 2.51.0 → 2.53.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.
Files changed (129) hide show
  1. package/dist/node/cards/tools/cardsTool.d.ts +32 -0
  2. package/dist/node/cards/tools/cardsTool.js +151 -0
  3. package/dist/node/cards/tools/cli.d.ts +2 -0
  4. package/dist/node/cards/tools/cli.js +38 -0
  5. package/dist/node/cards/validate.d.ts +35 -0
  6. package/dist/node/cards/validate.js +94 -0
  7. package/dist/styles/qdadm.css +1 -1
  8. package/package.json +7 -2
  9. package/src/board/QdBoardBlock.vue +67 -0
  10. package/src/board/QdDomainBoard.vue +64 -0
  11. package/src/board/blocks/BreakdownBlock.vue +44 -0
  12. package/src/board/blocks/KpiBlock.vue +31 -0
  13. package/src/board/blocks/TimelineBlock.vue +63 -0
  14. package/src/board/blocks/TopBlock.vue +57 -0
  15. package/src/board/blocks/schemas.ts +107 -0
  16. package/src/board/index.ts +31 -0
  17. package/src/board/registry.ts +33 -0
  18. package/src/board/types.ts +32 -0
  19. package/src/cards/QdCard.vue +175 -0
  20. package/src/cards/QdCardView.vue +53 -0
  21. package/src/cards/QdCardsGallery.vue +103 -0
  22. package/src/cards/QdFavoritesCard.vue +50 -0
  23. package/src/cards/QdRecentCard.vue +44 -0
  24. package/src/cards/builtin/agenda/AgendaCard.vue +37 -0
  25. package/src/cards/builtin/agenda/meta.json +60 -0
  26. package/src/cards/builtin/agenda/schema.json +48 -0
  27. package/src/cards/builtin/bullet/BulletCard.vue +76 -0
  28. package/src/cards/builtin/bullet/meta.json +38 -0
  29. package/src/cards/builtin/bullet/schema.json +18 -0
  30. package/src/cards/builtin/cards-index.json +1694 -0
  31. package/src/cards/builtin/compare/CompareCard.vue +47 -0
  32. package/src/cards/builtin/compare/meta.json +79 -0
  33. package/src/cards/builtin/compare/schema.json +40 -0
  34. package/src/cards/builtin/favorites/FavoritesCard.vue +50 -0
  35. package/src/cards/builtin/favorites/meta.json +33 -0
  36. package/src/cards/builtin/favorites/schema.json +20 -0
  37. package/src/cards/builtin/feed/FeedCard.vue +39 -0
  38. package/src/cards/builtin/feed/meta.json +64 -0
  39. package/src/cards/builtin/feed/schema.json +54 -0
  40. package/src/cards/builtin/funnel/FunnelCard.vue +44 -0
  41. package/src/cards/builtin/funnel/meta.json +53 -0
  42. package/src/cards/builtin/funnel/schema.json +37 -0
  43. package/src/cards/builtin/goal/GoalCard.vue +73 -0
  44. package/src/cards/builtin/goal/meta.json +43 -0
  45. package/src/cards/builtin/goal/schema.json +12 -0
  46. package/src/cards/builtin/heat/HeatCard.vue +46 -0
  47. package/src/cards/builtin/heat/meta.json +101 -0
  48. package/src/cards/builtin/heat/schema.json +39 -0
  49. package/src/cards/builtin/index.ts +71 -0
  50. package/src/cards/builtin/metric/MetricCard.vue +82 -0
  51. package/src/cards/builtin/metric/meta.json +109 -0
  52. package/src/cards/builtin/metric/schema.json +35 -0
  53. package/src/cards/builtin/pills.ts +36 -0
  54. package/src/cards/builtin/queue/QueueCard.vue +65 -0
  55. package/src/cards/builtin/queue/meta.json +47 -0
  56. package/src/cards/builtin/queue/schema.json +32 -0
  57. package/src/cards/builtin/ranking/RankingCard.vue +37 -0
  58. package/src/cards/builtin/ranking/meta.json +71 -0
  59. package/src/cards/builtin/ranking/schema.json +35 -0
  60. package/src/cards/builtin/recent/RecentCard.vue +41 -0
  61. package/src/cards/builtin/recent/meta.json +32 -0
  62. package/src/cards/builtin/recent/schema.json +21 -0
  63. package/src/cards/builtin/shared.ts +83 -0
  64. package/src/cards/builtin/split/SplitCard.vue +52 -0
  65. package/src/cards/builtin/split/meta.json +72 -0
  66. package/src/cards/builtin/split/schema.json +40 -0
  67. package/src/cards/builtin/trend/TrendCard.vue +75 -0
  68. package/src/cards/builtin/trend/meta.json +81 -0
  69. package/src/cards/builtin/trend/schema.json +58 -0
  70. package/src/cards/index.ts +29 -0
  71. package/src/cards/registry.ts +57 -0
  72. package/src/cards/tools/cardsTool.ts +181 -0
  73. package/src/cards/tools/cli.ts +35 -0
  74. package/src/cards/types.ts +111 -0
  75. package/src/cards/validate.ts +111 -0
  76. package/src/components/edit/FormActions.vue +9 -5
  77. package/src/components/edit/FormPage.vue +17 -2
  78. package/src/components/layout/AppLayout.vue +4 -0
  79. package/src/components/layout/BaseLayout.vue +4 -0
  80. package/src/components/layout/CardParamsForm.vue +157 -0
  81. package/src/components/layout/CardsDashboard.vue +276 -57
  82. package/src/components/layout/PageHeader.vue +22 -1
  83. package/src/components/layout/QdFavoriteStar.vue +71 -0
  84. package/src/components/layout/Zone.vue +2 -1
  85. package/src/components/lists/ListPage.vue +9 -1
  86. package/src/components/lists/QdSaveSearch.vue +79 -0
  87. package/src/components/pages/NotFoundPage.vue +5 -2
  88. package/src/components/run/QdRunBar.vue +99 -0
  89. package/src/components/show/ShowPage.vue +10 -1
  90. package/src/composables/useBreadcrumb.ts +1 -1
  91. package/src/composables/useCardsArrangement.ts +297 -27
  92. package/src/composables/useEntityItemFormPage.ts +39 -3
  93. package/src/composables/useEntityItemFormPage.types.ts +8 -0
  94. package/src/composables/useEntityItemShowPage.ts +22 -0
  95. package/src/composables/useListPage.ts +71 -0
  96. package/src/composables/useListPage.types.ts +6 -0
  97. package/src/composables/useUnsavedChangesGuard.ts +17 -1
  98. package/src/domain/QdBadge.vue +36 -0
  99. package/src/domain/QdDomainBar.vue +213 -0
  100. package/src/domain/QdDomainBarZone.vue +19 -0
  101. package/src/domain/index.ts +6 -0
  102. package/src/domain/registry.ts +122 -0
  103. package/src/favorites/index.ts +7 -0
  104. package/src/favorites/store.ts +172 -0
  105. package/src/favorites/useFavorites.ts +217 -0
  106. package/src/i18n/defaults/core.en.generated.ts +132 -0
  107. package/src/i18n/defaults/core.en.yml +132 -0
  108. package/src/i18n/defaults/core.fr.generated.ts +132 -0
  109. package/src/i18n/defaults/core.fr.yml +132 -0
  110. package/src/index.ts +23 -0
  111. package/src/kernel/Kernel.routing.ts +4 -15
  112. package/src/kernel/Kernel.types.ts +5 -1
  113. package/src/kernel/Kernel.vue.ts +2 -2
  114. package/src/kernel/KernelContext.routing.ts +10 -1
  115. package/src/kernel/KernelContext.ts +7 -0
  116. package/src/kernel/KernelContext.types.ts +2 -0
  117. package/src/kernel/homeRoute.ts +45 -0
  118. package/src/module/moduleRegistry.ts +4 -0
  119. package/src/run/index.ts +6 -0
  120. package/src/run/run.ts +162 -0
  121. package/src/run/useRun.ts +207 -0
  122. package/src/styles/_cards-dashboard.scss +190 -0
  123. package/src/styles/_qd-board.scss +359 -0
  124. package/src/styles/_qd-cards.scss +1197 -0
  125. package/src/styles/_qd-domain-bar.scss +159 -0
  126. package/src/styles/_qd-run.scss +135 -0
  127. package/src/styles/index.scss +4 -0
  128. package/src/zones/ZoneRegistry.ts +16 -0
  129. package/src/zones/index.ts +1 -0
@@ -0,0 +1,47 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * compare - better or worse than before? (#5355)
4
+ *
5
+ * The two values side by side with their labels, and the change, signed, in
6
+ * points or in percent, toned by `higherIs`. See meta.json for the sheet.
7
+ */
8
+ import { computed } from 'vue'
9
+ import { useI18n } from '../../../i18n/useI18n'
10
+ import { formatNumber, formatDelta, deltaTone } from '../shared'
11
+ import type { CardSize } from '../../types'
12
+
13
+ const props = defineProps<{
14
+ data: { now: { value: number; label?: string }; then: { value: number; label?: string } }
15
+ options: { unit?: string; decimals?: number; higherIs?: 'better' | 'worse' | 'neutral'; changeAs?: 'points' | 'percent' }
16
+ size: CardSize
17
+ }>()
18
+ const { t, locale } = useI18n()
19
+
20
+ const fmt = (v: number) => formatNumber(v, locale.value, { decimals: props.options.decimals ?? 1, unit: props.options.unit })
21
+ const change = computed(() => {
22
+ const { now, then } = props.data
23
+ const diff = now.value - then.value
24
+ const percent = props.options.changeAs === 'percent'
25
+ if (percent && then.value === 0) return null
26
+ const amount = percent ? (diff / Math.abs(then.value)) * 100 : diff
27
+ const unit = percent ? '%' : props.options.unit === '%' ? t('core.cards.compare.points') : props.options.unit
28
+ const text = formatDelta(amount, locale.value, props.options.decimals ?? 1)
29
+ return { text: unit ? `${text} ${unit}` : text, tone: deltaTone(diff, props.options.higherIs) }
30
+ })
31
+ </script>
32
+
33
+ <template>
34
+ <div class="qd-compare">
35
+ <div class="qd-compare-values">
36
+ <div class="qd-compare-now">
37
+ <span class="qd-card-value">{{ fmt(data.now.value) }}</span>
38
+ <span v-if="data.now.label" class="qd-card-unit">{{ data.now.label }}</span>
39
+ </div>
40
+ <div class="qd-compare-then">
41
+ <span class="qd-compare-then-value">{{ fmt(data.then.value) }}</span>
42
+ <span v-if="data.then.label" class="qd-card-unit">{{ data.then.label }}</span>
43
+ </div>
44
+ </div>
45
+ <span v-if="change" class="qd-card-delta" :class="`qd-tone--${change.tone}`">{{ change.text }}</span>
46
+ </div>
47
+ </template>
@@ -0,0 +1,79 @@
1
+ {
2
+ "type": "compare",
3
+ "title": "Compare",
4
+ "question": "Better or worse than before?",
5
+ "readings": [
6
+ "the two values side by side: now, and the one it is compared with, each with its label",
7
+ "the change: signed, in points or in percent, toned good or bad by higherIs"
8
+ ],
9
+ "strengths": [
10
+ "answers \"compared with what?\" without a curve",
11
+ "the change is written, not only drawn"
12
+ ],
13
+ "avoid": [
14
+ "for a level over many periods: use trend or metric",
15
+ "for more than two values: use ranking"
16
+ ],
17
+ "sizes": [
18
+ "s",
19
+ "m"
20
+ ],
21
+ "options": {
22
+ "unit": {
23
+ "type": "string",
24
+ "description": "Written after both values: \"%\", \"k€\""
25
+ },
26
+ "decimals": {
27
+ "type": "integer",
28
+ "minimum": 0,
29
+ "maximum": 4,
30
+ "default": 1,
31
+ "description": "Digits after the decimal point"
32
+ },
33
+ "higherIs": {
34
+ "type": "string",
35
+ "enum": [
36
+ "better",
37
+ "worse",
38
+ "neutral"
39
+ ],
40
+ "default": "better",
41
+ "description": "Whether a rise is good news"
42
+ },
43
+ "changeAs": {
44
+ "type": "string",
45
+ "enum": [
46
+ "points",
47
+ "percent"
48
+ ],
49
+ "default": "points",
50
+ "description": "The change as a difference (points) or as a share of the old value (percent)"
51
+ }
52
+ },
53
+ "action": "mode list: the detail behind the two values",
54
+ "example": {
55
+ "envelope": {
56
+ "title": "Average margin",
57
+ "status": "watch",
58
+ "source": "sales",
59
+ "to": "/margins",
60
+ "size": "s"
61
+ },
62
+ "data": {
63
+ "now": {
64
+ "value": 11.8,
65
+ "label": "November"
66
+ },
67
+ "then": {
68
+ "value": 13.1,
69
+ "label": "November 2025"
70
+ }
71
+ },
72
+ "options": {
73
+ "unit": "%",
74
+ "decimals": 1,
75
+ "higherIs": "better",
76
+ "changeAs": "points"
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "type": "object",
3
+ "required": [
4
+ "now",
5
+ "then"
6
+ ],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "now": {
10
+ "type": "object",
11
+ "required": [
12
+ "value"
13
+ ],
14
+ "additionalProperties": false,
15
+ "properties": {
16
+ "value": {
17
+ "type": "number"
18
+ },
19
+ "label": {
20
+ "type": "string"
21
+ }
22
+ }
23
+ },
24
+ "then": {
25
+ "type": "object",
26
+ "required": [
27
+ "value"
28
+ ],
29
+ "additionalProperties": false,
30
+ "properties": {
31
+ "value": {
32
+ "type": "number"
33
+ },
34
+ "label": {
35
+ "type": "string"
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,50 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * favorites - what do I follow? (#5349)
4
+ *
5
+ * The pages someone starred and the searches they saved, grouped by kind,
6
+ * each opening its page. QdFavoritesCard feeds it live from useFavorites.
7
+ * See meta.json for the sheet.
8
+ */
9
+ import { computed } from 'vue'
10
+ import { RouterLink, type RouteLocationRaw } from 'vue-router'
11
+ import { useI18n } from '../../../i18n/useI18n'
12
+ import type { CardSize } from '../../types'
13
+
14
+ type Kind = 'item' | 'list' | 'search' | 'board'
15
+ interface FavoritesData {
16
+ items: Array<{ label: string; to: RouteLocationRaw; kind?: Kind }>
17
+ }
18
+
19
+ const props = defineProps<{ data: FavoritesData; options: { maxItems?: number; groupByKind?: boolean }; size: CardSize }>()
20
+ const { t } = useI18n()
21
+
22
+ const KINDS: Kind[] = ['item', 'list', 'search', 'board']
23
+ const ICON: Record<Kind, string> = { item: 'pi pi-file', list: 'pi pi-list', search: 'pi pi-filter', board: 'pi pi-th-large' }
24
+
25
+ const shown = computed(() => props.data.items.slice(0, props.options.maxItems ?? 8))
26
+ const groups = computed(() => {
27
+ const byKind = KINDS.map((kind) => ({ kind, items: shown.value.filter((i) => (i.kind ?? 'item') === kind) })).filter((g) => g.items.length)
28
+ // One kind, or no grouping: one plain list
29
+ if (props.options.groupByKind === false || byKind.length < 2) return [{ kind: null as Kind | null, items: shown.value }]
30
+ return byKind
31
+ })
32
+ const more = computed(() => props.data.items.length - shown.value.length)
33
+ </script>
34
+
35
+ <template>
36
+ <div class="qd-favorites">
37
+ <section v-for="g in groups" :key="g.kind ?? 'all'" class="qd-favorites-group">
38
+ <h3 v-if="g.kind" class="qd-favorites-kind">{{ t(`core.favorites.kind.${g.kind}`) }}</h3>
39
+ <ul class="qd-favorites-list">
40
+ <li v-for="(item, i) in g.items" :key="i">
41
+ <RouterLink :to="item.to" class="qd-favorites-link">
42
+ <i :class="ICON[item.kind ?? 'item']" aria-hidden="true"></i>
43
+ <span>{{ item.label }}</span>
44
+ </RouterLink>
45
+ </li>
46
+ </ul>
47
+ </section>
48
+ <p v-if="more > 0" class="qd-favorites-more">{{ t('core.cards.moreProblems', { count: more }) }}</p>
49
+ </div>
50
+ </template>
@@ -0,0 +1,33 @@
1
+ {
2
+ "type": "favorites",
3
+ "title": "Favourites",
4
+ "question": "What do I follow?",
5
+ "readings": [
6
+ "the pages the person starred and the searches they saved, by kind",
7
+ "each line opens its page, filtered as it was for a search"
8
+ ],
9
+ "strengths": [
10
+ "one click back to what someone follows, whatever its domain",
11
+ "read live: a star clicked in a header shows at once"
12
+ ],
13
+ "avoid": [
14
+ "for what everyone must see: that is a board's own card, not a favourite"
15
+ ],
16
+ "sizes": ["s", "m"],
17
+ "options": {
18
+ "maxItems": { "type": "integer", "minimum": 1, "maximum": 20, "default": 8, "description": "How many lines to show" },
19
+ "groupByKind": { "type": "boolean", "default": true, "description": "Group the lines by kind (records, lists, searches, boards)" }
20
+ },
21
+ "action": "none: each line is its own gesture",
22
+ "example": {
23
+ "envelope": { "title": "Favourites", "status": "info", "size": "s" },
24
+ "data": {
25
+ "items": [
26
+ { "label": "Order 575806", "to": "/orders/575806", "kind": "item" },
27
+ { "label": "Returns", "to": "/returns", "kind": "list" },
28
+ { "label": "Orders to ship tonight", "to": "/orders?status=todo", "kind": "search" }
29
+ ]
30
+ },
31
+ "options": { "maxItems": 8, "groupByKind": true }
32
+ }
33
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "type": "object",
3
+ "required": ["items"],
4
+ "additionalProperties": false,
5
+ "properties": {
6
+ "items": {
7
+ "type": "array",
8
+ "items": {
9
+ "type": "object",
10
+ "required": ["label", "to"],
11
+ "additionalProperties": false,
12
+ "properties": {
13
+ "label": { "type": "string" },
14
+ "to": { "type": ["string", "object"], "description": "The page it opens" },
15
+ "kind": { "type": "string", "enum": ["item", "list", "search", "board"], "description": "What it is: a record, a list, a saved search, a board" }
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,39 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * feed - what happened? (#5355)
4
+ *
5
+ * The latest events first, with when (a time for today, else a day), each
6
+ * opening its item; a status as a side mark and a word. See meta.json for
7
+ * the sheet.
8
+ */
9
+ import { computed } from 'vue'
10
+ import { RouterLink, type RouteLocationRaw } from 'vue-router'
11
+ import { useI18n } from '../../../i18n/useI18n'
12
+ import { dayWords } from '../shared'
13
+ import type { CardSize, CardStatus } from '../../types'
14
+
15
+ const props = defineProps<{
16
+ data: { now?: string | number; items: Array<{ at: string | number; label: string; to?: RouteLocationRaw; status?: CardStatus }> }
17
+ options: { maxItems?: number }
18
+ size: CardSize
19
+ }>()
20
+ const { t, locale } = useI18n()
21
+
22
+ const lines = computed(() => {
23
+ const now = props.data.now !== undefined ? new Date(props.data.now) : new Date()
24
+ return [...props.data.items]
25
+ .sort((a, b) => new Date(b.at).getTime() - new Date(a.at).getTime())
26
+ .slice(0, props.options.maxItems ?? 4)
27
+ .map((item) => ({ ...item, ...dayWords(new Date(item.at), now, locale.value, t, true) }))
28
+ })
29
+ </script>
30
+
31
+ <template>
32
+ <ul class="qd-feed">
33
+ <li v-for="(line, i) in lines" :key="i" class="qd-feed-item" :data-status="line.status">
34
+ <time class="qd-feed-when" :datetime="line.iso" :title="line.full">{{ line.when }}</time>
35
+ <component :is="line.to ? RouterLink : 'span'" :to="line.to" class="qd-feed-label">{{ line.label }}</component>
36
+ <span v-if="line.status" class="qd-feed-status">{{ t(`core.cards.status.${line.status}`) }}</span>
37
+ </li>
38
+ </ul>
39
+ </template>
@@ -0,0 +1,64 @@
1
+ {
2
+ "type": "feed",
3
+ "title": "Feed",
4
+ "question": "What happened?",
5
+ "readings": [
6
+ "each line: when, and what happened",
7
+ "its status, when it has one: a side mark and a word"
8
+ ],
9
+ "strengths": [
10
+ "the notable events, the latest first",
11
+ "each line opens its item"
12
+ ],
13
+ "avoid": [
14
+ "for a full log: link to it",
15
+ "for what is coming: use agenda"
16
+ ],
17
+ "sizes": [
18
+ "s",
19
+ "m"
20
+ ],
21
+ "options": {
22
+ "maxItems": {
23
+ "type": "integer",
24
+ "minimum": 1,
25
+ "maximum": 10,
26
+ "default": 4,
27
+ "description": "How many lines"
28
+ }
29
+ },
30
+ "action": "mode list: all the events",
31
+ "example": {
32
+ "envelope": {
33
+ "title": "Worth knowing",
34
+ "status": "info",
35
+ "source": "all",
36
+ "to": "/events",
37
+ "size": "s"
38
+ },
39
+ "data": {
40
+ "now": "2026-11-19T11:00:00",
41
+ "items": [
42
+ {
43
+ "at": "2026-11-19T10:42:00",
44
+ "label": "€24k order (Mairie de Lyon) to approve",
45
+ "status": "watch",
46
+ "to": "/orders/575806"
47
+ },
48
+ {
49
+ "at": "2026-11-19T09:15:00",
50
+ "label": "Westcoast: 258 products back on sale",
51
+ "status": "good"
52
+ },
53
+ {
54
+ "at": "2026-11-19T08:03:00",
55
+ "label": "2/5 customer review on Amazon, order 575806",
56
+ "status": "critical"
57
+ }
58
+ ]
59
+ },
60
+ "options": {
61
+ "maxItems": 4
62
+ }
63
+ }
64
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "type": "object",
3
+ "required": [
4
+ "items"
5
+ ],
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "now": {
9
+ "type": [
10
+ "string",
11
+ "number"
12
+ ],
13
+ "description": "Now, to say \"today\"; default the clock"
14
+ },
15
+ "items": {
16
+ "type": "array",
17
+ "items": {
18
+ "type": "object",
19
+ "required": [
20
+ "at",
21
+ "label"
22
+ ],
23
+ "additionalProperties": false,
24
+ "properties": {
25
+ "at": {
26
+ "type": [
27
+ "string",
28
+ "number"
29
+ ]
30
+ },
31
+ "label": {
32
+ "type": "string"
33
+ },
34
+ "to": {
35
+ "type": [
36
+ "string",
37
+ "object"
38
+ ],
39
+ "description": "Where it opens"
40
+ },
41
+ "status": {
42
+ "type": "string",
43
+ "enum": [
44
+ "critical",
45
+ "watch",
46
+ "good",
47
+ "info"
48
+ ]
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,44 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * funnel - where is it lost? (#5355)
4
+ *
5
+ * The steps with their counts, bars scaled to the first step, and between two
6
+ * steps the loss in words ("−33 between sent and followed up"). See meta.json
7
+ * for the sheet.
8
+ */
9
+ import { computed } from 'vue'
10
+ import { RouterLink, type RouteLocationRaw } from 'vue-router'
11
+ import { useI18n } from '../../../i18n/useI18n'
12
+ import { formatNumber } from '../shared'
13
+ import type { CardSize } from '../../types'
14
+
15
+ const props = defineProps<{ data: { steps: Array<{ label: string; value: number; to?: RouteLocationRaw }> }; options: Record<string, never>; size: CardSize }>()
16
+ const { t, locale } = useI18n()
17
+
18
+ const first = computed(() => props.data.steps[0]?.value ?? 0)
19
+ const steps = computed(() =>
20
+ props.data.steps.map((s, i) => {
21
+ const prev = props.data.steps[i - 1]
22
+ const lost = prev ? prev.value - s.value : 0
23
+ return {
24
+ ...s,
25
+ share: first.value ? Math.min(100, (s.value / first.value) * 100) : 0,
26
+ text: formatNumber(s.value, locale.value),
27
+ loss: prev && lost > 0 ? t('core.cards.funnel.loss', { count: formatNumber(lost, locale.value), from: prev.label, to: s.label }) : null,
28
+ }
29
+ })
30
+ )
31
+ </script>
32
+
33
+ <template>
34
+ <ol class="qd-funnel">
35
+ <li v-for="(s, i) in steps" :key="i" class="qd-funnel-step">
36
+ <span v-if="s.loss" class="qd-funnel-loss">{{ s.loss }}</span>
37
+ <component :is="s.to ? RouterLink : 'div'" :to="s.to" class="qd-funnel-row">
38
+ <span class="qd-funnel-label">{{ s.label }}</span>
39
+ <span class="qd-funnel-track" aria-hidden="true"><span class="qd-funnel-bar" :style="{ width: `${s.share}%` }"></span></span>
40
+ <span class="qd-funnel-value">{{ s.text }}</span>
41
+ </component>
42
+ </li>
43
+ </ol>
44
+ </template>
@@ -0,0 +1,53 @@
1
+ {
2
+ "type": "funnel",
3
+ "title": "Funnel",
4
+ "question": "Where is it lost?",
5
+ "readings": [
6
+ "each step with its count",
7
+ "the bars, scaled to the first step",
8
+ "the loss between two steps, in words"
9
+ ],
10
+ "strengths": [
11
+ "shows the step that leaks",
12
+ "the losses are written, not guessed from bars"
13
+ ],
14
+ "avoid": [
15
+ "for parts that are not steps of one path: use split"
16
+ ],
17
+ "sizes": [
18
+ "s",
19
+ "m"
20
+ ],
21
+ "options": {},
22
+ "action": "mode list: the items stuck at the leaking step",
23
+ "example": {
24
+ "envelope": {
25
+ "title": "Quotes this month",
26
+ "status": "info",
27
+ "source": "sales",
28
+ "to": "/quotes",
29
+ "size": "s"
30
+ },
31
+ "data": {
32
+ "steps": [
33
+ {
34
+ "label": "sent",
35
+ "value": 84
36
+ },
37
+ {
38
+ "label": "followed up",
39
+ "value": 51
40
+ },
41
+ {
42
+ "label": "signed",
43
+ "value": 26
44
+ },
45
+ {
46
+ "label": "delivered",
47
+ "value": 20
48
+ }
49
+ ]
50
+ },
51
+ "options": {}
52
+ }
53
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "type": "object",
3
+ "required": [
4
+ "steps"
5
+ ],
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "steps": {
9
+ "type": "array",
10
+ "minItems": 1,
11
+ "items": {
12
+ "type": "object",
13
+ "required": [
14
+ "label",
15
+ "value"
16
+ ],
17
+ "additionalProperties": false,
18
+ "properties": {
19
+ "label": {
20
+ "type": "string"
21
+ },
22
+ "value": {
23
+ "type": "number",
24
+ "minimum": 0
25
+ },
26
+ "to": {
27
+ "type": [
28
+ "string",
29
+ "object"
30
+ ],
31
+ "description": "Where it opens"
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,73 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * goal - am I on time? (#5339)
4
+ *
5
+ * The value against the target, the bar's length for the share reached, a
6
+ * tick for where the expected pace says it should be today, and the words
7
+ * (share, expected share, ahead or behind), so nothing rests on colour.
8
+ * See meta.json for the sheet.
9
+ */
10
+ import { computed } from 'vue'
11
+ import { useI18n } from '../../../i18n/useI18n'
12
+ import { formatNumber } from '../shared'
13
+ import type { CardSize } from '../../types'
14
+
15
+ interface GoalData {
16
+ value: number
17
+ target: number
18
+ start?: string
19
+ due?: string
20
+ now?: string
21
+ }
22
+
23
+ const props = defineProps<{ data: GoalData; options: { unit?: string; decimals?: number }; size: CardSize }>()
24
+ const { t, locale } = useI18n()
25
+
26
+ const fmt = (v: number) => formatNumber(v, locale.value, { decimals: props.options.decimals, unit: props.options.unit })
27
+ const pct = (r: number) => new Intl.NumberFormat(locale.value, { style: 'percent', maximumFractionDigits: 0 }).format(r)
28
+
29
+ const progress = computed(() => (props.data.target > 0 ? props.data.value / props.data.target : 0))
30
+
31
+ /** The share the pace expects today, or null without a period */
32
+ const expected = computed(() => {
33
+ const { start, due, now } = props.data
34
+ if (!start || !due) return null
35
+ const s = Date.parse(start)
36
+ const d = Date.parse(due) + 86_400_000 // the last day counts whole
37
+ const n = now ? Date.parse(now) + 86_400_000 : Date.now()
38
+ if ([s, d, n].some(Number.isNaN) || d <= s) return null
39
+ return Math.min(Math.max((n - s) / (d - s), 0), 1)
40
+ })
41
+ const today = computed(() => {
42
+ const n = props.data.now ? new Date(props.data.now) : new Date()
43
+ return new Intl.DateTimeFormat(locale.value, { day: 'numeric', month: 'short' }).format(n)
44
+ })
45
+ const ahead = computed(() => (expected.value === null ? null : progress.value >= expected.value))
46
+ </script>
47
+
48
+ <template>
49
+ <div class="qd-goal">
50
+ <div class="qd-metric-line">
51
+ <span class="qd-card-value">{{ fmt(data.value) }}</span>
52
+ <span class="qd-card-unit">{{ t('core.cards.goal.of', { target: fmt(data.target) }) }}</span>
53
+ </div>
54
+ <div
55
+ class="qd-goal-bar"
56
+ role="meter"
57
+ :aria-valuenow="Math.round(progress * 100)"
58
+ aria-valuemin="0"
59
+ aria-valuemax="100"
60
+ :aria-label="t('core.cards.goal.reached', { share: pct(progress) })"
61
+ :data-pace="ahead === null ? 'none' : ahead ? 'ahead' : 'behind'"
62
+ >
63
+ <span class="qd-goal-fill" :style="{ width: `${Math.min(progress, 1) * 100}%` }"></span>
64
+ <span v-if="expected !== null" class="qd-goal-pace" :style="{ left: `${expected * 100}%` }"></span>
65
+ </div>
66
+ <p class="qd-card-note">
67
+ {{ t('core.cards.goal.reached', { share: pct(progress) }) }}<template v-if="expected !== null"
68
+ >; {{ t('core.cards.goal.pace', { date: today, share: pct(expected) }) }}
69
+ <strong class="qd-goal-verdict">{{ ahead ? t('core.cards.goal.ahead') : t('core.cards.goal.behind') }}</strong></template
70
+ >
71
+ </p>
72
+ </div>
73
+ </template>