mood-ui 0.14.1 → 0.15.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 (171) hide show
  1. package/README.md +1 -1
  2. package/dist/components/data-display/table/Table.cjs +1 -1
  3. package/dist/components/data-display/table/Table.cjs.map +1 -1
  4. package/dist/components/data-display/table/Table.mjs +1 -1
  5. package/dist/components/data-display/table/Table.mjs.map +1 -1
  6. package/dist/components/data-display/table/Table.vue_vue_type_script_setup_true_lang.cjs +37 -1
  7. package/dist/components/data-display/table/Table.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  8. package/dist/components/data-display/table/Table.vue_vue_type_script_setup_true_lang.mjs +38 -2
  9. package/dist/components/data-display/table/Table.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  10. package/dist/components/data-display/table/TablePagination.cjs.map +1 -1
  11. package/dist/components/data-display/table/TablePagination.mjs.map +1 -1
  12. package/dist/components/data-display/table/TablePagination.vue_vue_type_script_setup_true_lang.cjs +24 -16
  13. package/dist/components/data-display/table/TablePagination.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  14. package/dist/components/data-display/table/TablePagination.vue_vue_type_script_setup_true_lang.mjs +24 -16
  15. package/dist/components/data-display/table/TablePagination.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  16. package/dist/components/feedback/EmptyState.cjs.map +1 -1
  17. package/dist/components/feedback/EmptyState.mjs.map +1 -1
  18. package/dist/components/feedback/EmptyState.vue_vue_type_script_setup_true_lang.cjs +1 -1
  19. package/dist/components/feedback/EmptyState.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  20. package/dist/components/feedback/EmptyState.vue_vue_type_script_setup_true_lang.mjs +1 -1
  21. package/dist/components/feedback/EmptyState.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  22. package/dist/components/feedback/tour/Tour.vue_vue_type_script_setup_true_lang.cjs +369 -0
  23. package/dist/components/feedback/tour/Tour.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  24. package/dist/components/feedback/tour/Tour.vue_vue_type_script_setup_true_lang.mjs +368 -0
  25. package/dist/components/feedback/tour/Tour.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
  26. package/dist/components/feedback/tour/Tour2.cjs +6 -0
  27. package/dist/components/feedback/tour/Tour2.cjs.map +1 -0
  28. package/dist/components/feedback/tour/Tour2.mjs +7 -0
  29. package/dist/components/feedback/tour/Tour2.mjs.map +1 -0
  30. package/dist/components/feedback/tour/TourCard.cjs +6 -0
  31. package/dist/components/feedback/tour/TourCard.cjs.map +1 -0
  32. package/dist/components/feedback/tour/TourCard.mjs +7 -0
  33. package/dist/components/feedback/tour/TourCard.mjs.map +1 -0
  34. package/dist/components/feedback/tour/TourCard.vue_vue_type_script_setup_true_lang.cjs +102 -0
  35. package/dist/components/feedback/tour/TourCard.vue_vue_type_script_setup_true_lang.cjs.map +1 -0
  36. package/dist/components/feedback/tour/TourCard.vue_vue_type_script_setup_true_lang.mjs +101 -0
  37. package/dist/components/feedback/tour/TourCard.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
  38. package/dist/components/feedback/tour/tourAnchor.cjs +75 -0
  39. package/dist/components/feedback/tour/tourAnchor.cjs.map +1 -0
  40. package/dist/components/feedback/tour/tourAnchor.mjs +72 -0
  41. package/dist/components/feedback/tour/tourAnchor.mjs.map +1 -0
  42. package/dist/components/feedback/tour/tourPlace.cjs +108 -0
  43. package/dist/components/feedback/tour/tourPlace.cjs.map +1 -0
  44. package/dist/components/feedback/tour/tourPlace.mjs +107 -0
  45. package/dist/components/feedback/tour/tourPlace.mjs.map +1 -0
  46. package/dist/components/feedback/tour/tourShape.cjs +121 -0
  47. package/dist/components/feedback/tour/tourShape.cjs.map +1 -0
  48. package/dist/components/feedback/tour/tourShape.mjs +118 -0
  49. package/dist/components/feedback/tour/tourShape.mjs.map +1 -0
  50. package/dist/components/feedback/tour/useTourSpotlight.cjs +60 -0
  51. package/dist/components/feedback/tour/useTourSpotlight.cjs.map +1 -0
  52. package/dist/components/feedback/tour/useTourSpotlight.mjs +59 -0
  53. package/dist/components/feedback/tour/useTourSpotlight.mjs.map +1 -0
  54. package/dist/components/feedback/tour/useTourSteps.cjs +108 -0
  55. package/dist/components/feedback/tour/useTourSteps.cjs.map +1 -0
  56. package/dist/components/feedback/tour/useTourSteps.mjs +107 -0
  57. package/dist/components/feedback/tour/useTourSteps.mjs.map +1 -0
  58. package/dist/components/forms/Button.cjs +1 -1
  59. package/dist/components/forms/Button.cjs.map +1 -1
  60. package/dist/components/forms/Button.mjs +1 -1
  61. package/dist/components/forms/Button.mjs.map +1 -1
  62. package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.cjs +1 -1
  63. package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  64. package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.mjs +1 -1
  65. package/dist/components/forms/Button.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  66. package/dist/components/forms/FileInput.cjs +1 -1
  67. package/dist/components/forms/FileInput.cjs.map +1 -1
  68. package/dist/components/forms/FileInput.mjs +1 -1
  69. package/dist/components/forms/FileInput.mjs.map +1 -1
  70. package/dist/components/forms/FileInput.vue_vue_type_script_setup_true_lang.cjs +34 -17
  71. package/dist/components/forms/FileInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  72. package/dist/components/forms/FileInput.vue_vue_type_script_setup_true_lang.mjs +34 -17
  73. package/dist/components/forms/FileInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  74. package/dist/components/forms/MultiSelect.cjs +1 -1
  75. package/dist/components/forms/MultiSelect.cjs.map +1 -1
  76. package/dist/components/forms/MultiSelect.mjs +1 -1
  77. package/dist/components/forms/MultiSelect.mjs.map +1 -1
  78. package/dist/components/forms/MultiSelect.vue_vue_type_script_setup_true_lang.cjs +2 -1
  79. package/dist/components/forms/MultiSelect.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  80. package/dist/components/forms/MultiSelect.vue_vue_type_script_setup_true_lang.mjs +2 -1
  81. package/dist/components/forms/MultiSelect.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  82. package/dist/components/forms/TagInput.cjs.map +1 -1
  83. package/dist/components/forms/TagInput.mjs.map +1 -1
  84. package/dist/components/forms/TagInput.vue_vue_type_script_setup_true_lang.cjs +1 -0
  85. package/dist/components/forms/TagInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  86. package/dist/components/forms/TagInput.vue_vue_type_script_setup_true_lang.mjs +1 -0
  87. package/dist/components/forms/TagInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  88. package/dist/components/forms/Textarea.cjs.map +1 -1
  89. package/dist/components/forms/Textarea.mjs.map +1 -1
  90. package/dist/components/forms/Textarea.vue_vue_type_script_setup_true_lang.cjs +1 -1
  91. package/dist/components/forms/Textarea.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  92. package/dist/components/forms/Textarea.vue_vue_type_script_setup_true_lang.mjs +1 -1
  93. package/dist/components/forms/Textarea.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  94. package/dist/components/layout/Canvas.cjs +1 -1
  95. package/dist/components/layout/Canvas.cjs.map +1 -1
  96. package/dist/components/layout/Canvas.mjs +1 -1
  97. package/dist/components/layout/Canvas.mjs.map +1 -1
  98. package/dist/components/layout/Canvas.vue_vue_type_script_setup_true_lang.cjs +1 -1
  99. package/dist/components/layout/Canvas.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  100. package/dist/components/layout/Canvas.vue_vue_type_script_setup_true_lang.mjs +1 -1
  101. package/dist/components/layout/Canvas.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  102. package/dist/components/layout/PopoverPanel.cjs +1 -1
  103. package/dist/components/layout/PopoverPanel.cjs.map +1 -1
  104. package/dist/components/layout/PopoverPanel.mjs +1 -1
  105. package/dist/components/layout/PopoverPanel.mjs.map +1 -1
  106. package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.cjs +1 -1
  107. package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  108. package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.mjs +1 -1
  109. package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  110. package/dist/components/layout/popover/PopoverTrigger.cjs.map +1 -1
  111. package/dist/components/layout/popover/PopoverTrigger.mjs.map +1 -1
  112. package/dist/components/layout/popover/PopoverTrigger.vue_vue_type_script_setup_true_lang.cjs +1 -1
  113. package/dist/components/layout/popover/PopoverTrigger.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  114. package/dist/components/layout/popover/PopoverTrigger.vue_vue_type_script_setup_true_lang.mjs +1 -1
  115. package/dist/components/layout/popover/PopoverTrigger.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  116. package/dist/components/navigation/DropdownMenu.cjs +1 -1
  117. package/dist/components/navigation/DropdownMenu.cjs.map +1 -1
  118. package/dist/components/navigation/DropdownMenu.mjs +1 -1
  119. package/dist/components/navigation/DropdownMenu.mjs.map +1 -1
  120. package/dist/components/navigation/DropdownMenu.vue_vue_type_script_setup_true_lang.cjs +1 -1
  121. package/dist/components/navigation/DropdownMenu.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  122. package/dist/components/navigation/DropdownMenu.vue_vue_type_script_setup_true_lang.mjs +1 -1
  123. package/dist/components/navigation/DropdownMenu.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  124. package/dist/components/navigation/Switcher.cjs.map +1 -1
  125. package/dist/components/navigation/Switcher.mjs.map +1 -1
  126. package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs +77 -45
  127. package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  128. package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs +77 -45
  129. package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  130. package/dist/components/navigation/menu/MenuTrigger.cjs.map +1 -1
  131. package/dist/components/navigation/menu/MenuTrigger.mjs.map +1 -1
  132. package/dist/components/navigation/menu/MenuTrigger.vue_vue_type_script_setup_true_lang.cjs +1 -1
  133. package/dist/components/navigation/menu/MenuTrigger.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  134. package/dist/components/navigation/menu/MenuTrigger.vue_vue_type_script_setup_true_lang.mjs +1 -1
  135. package/dist/components/navigation/menu/MenuTrigger.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
  136. package/dist/composables/useField.cjs +28 -8
  137. package/dist/composables/useField.cjs.map +1 -1
  138. package/dist/composables/useField.mjs +28 -8
  139. package/dist/composables/useField.mjs.map +1 -1
  140. package/dist/config/ModoLocale.cjs +10 -1
  141. package/dist/config/ModoLocale.cjs.map +1 -1
  142. package/dist/config/ModoLocale.mjs +10 -1
  143. package/dist/config/ModoLocale.mjs.map +1 -1
  144. package/dist/config/locales/es.cjs +10 -1
  145. package/dist/config/locales/es.cjs.map +1 -1
  146. package/dist/config/locales/es.mjs +10 -1
  147. package/dist/config/locales/es.mjs.map +1 -1
  148. package/dist/index.cjs +4 -0
  149. package/dist/index.mjs +3 -1
  150. package/dist/mood-ui.css +289 -103
  151. package/dist/types/components/data-display/surface-card/SurfaceCardBody.vue.d.ts +1 -1
  152. package/dist/types/components/data-display/surface-card/SurfaceCardFooter.vue.d.ts +1 -1
  153. package/dist/types/components/data-display/surface-card/SurfaceCardHeader.vue.d.ts +1 -1
  154. package/dist/types/components/feedback/dialog/DialogContent.vue.d.ts +1 -1
  155. package/dist/types/components/feedback/tour/Tour.vue.d.ts +31 -0
  156. package/dist/types/components/feedback/tour/TourCard.vue.d.ts +25 -0
  157. package/dist/types/components/feedback/tour/index.d.ts +2 -0
  158. package/dist/types/components/feedback/tour/tourAnchor.d.ts +12 -0
  159. package/dist/types/components/feedback/tour/tourPlace.d.ts +60 -0
  160. package/dist/types/components/feedback/tour/tourShape.d.ts +36 -0
  161. package/dist/types/components/feedback/tour/useTourSpotlight.d.ts +14 -0
  162. package/dist/types/components/feedback/tour/useTourSteps.d.ts +31 -0
  163. package/dist/types/components/layout/Canvas.vue.d.ts +1 -1
  164. package/dist/types/components/layout/popover/PopoverContent.vue.d.ts +1 -1
  165. package/dist/types/components/navigation/menu/MenuContent.vue.d.ts +1 -1
  166. package/dist/types/composables/useField.d.ts +23 -0
  167. package/dist/types/config/ModoLocale.d.ts +14 -0
  168. package/dist/types/index.d.ts +2 -0
  169. package/dist/types/interfaces/feedback/Tour.interface.d.ts +73 -0
  170. package/dist/types/interfaces/navigation/Switcher.interface.d.ts +5 -0
  171. package/package.json +1 -1
@@ -0,0 +1,101 @@
1
+ import { interpolate } from "../../../config/ModoLocale.mjs";
2
+ import Button_default from "../../forms/Button.mjs";
3
+ import Typography_default from "../../data-display/Typography.mjs";
4
+ import Tooltip_default from "../Tooltip.mjs";
5
+ import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, toDisplayString, unref, withCtx } from "vue";
6
+ import { XMarkIcon } from "@heroicons/vue/24/outline";
7
+ //#region src/components/feedback/tour/TourCard.vue?vue&type=script&setup=true&lang.ts
8
+ var _hoisted_1 = { class: "flex flex-col gap-3 p-4" };
9
+ var _hoisted_2 = { class: "flex items-center justify-between gap-3" };
10
+ var _hoisted_3 = { class: "flex items-center justify-between gap-3" };
11
+ var _hoisted_4 = { class: "flex items-center gap-2" };
12
+ /**
13
+ * The default card of a Tour: the title (which names the dialog), the body, "2 of 5", and two actions, Back (from the second step) and
14
+ * Next ("Done" on the last), as a dialog has at most; skipping is the close icon.
15
+ */
16
+ var TourCard_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
17
+ __name: "TourCard",
18
+ props: {
19
+ titleId: {},
20
+ title: {},
21
+ body: {},
22
+ current: {},
23
+ total: {},
24
+ last: { type: Boolean },
25
+ labels: {}
26
+ },
27
+ emits: [
28
+ "back",
29
+ "next",
30
+ "skip"
31
+ ],
32
+ setup(__props, { emit: __emit }) {
33
+ const props = __props;
34
+ const emit = __emit;
35
+ const progress = computed(() => interpolate(props.labels.progress, {
36
+ current: props.current,
37
+ total: props.total
38
+ }));
39
+ return (_ctx, _cache) => {
40
+ return openBlock(), createElementBlock("div", _hoisted_1, [
41
+ createElementVNode("div", _hoisted_2, [createVNode(Typography_default, {
42
+ id: __props.titleId,
43
+ as: "h2",
44
+ variant: "title",
45
+ size: "small",
46
+ weight: "semibold"
47
+ }, {
48
+ default: withCtx(() => [createTextVNode(toDisplayString(__props.title), 1)]),
49
+ _: 1
50
+ }, 8, ["id"]), createVNode(Tooltip_default, {
51
+ content: __props.labels.skip,
52
+ placement: "top-end"
53
+ }, {
54
+ default: withCtx(() => [createVNode(Button_default, {
55
+ variant: "text",
56
+ size: "small",
57
+ icon: unref(XMarkIcon),
58
+ "aria-label": __props.labels.skip,
59
+ "data-tour-part": "skip",
60
+ onClick: _cache[0] || (_cache[0] = ($event) => emit("skip"))
61
+ }, null, 8, ["icon", "aria-label"])]),
62
+ _: 1
63
+ }, 8, ["content"])]),
64
+ createVNode(Typography_default, {
65
+ variant: "body",
66
+ size: "small",
67
+ color: "muted"
68
+ }, {
69
+ default: withCtx(() => [createTextVNode(toDisplayString(__props.body), 1)]),
70
+ _: 1
71
+ }),
72
+ createElementVNode("div", _hoisted_3, [createVNode(Typography_default, {
73
+ as: "span",
74
+ variant: "caption",
75
+ color: "muted",
76
+ "data-tour-part": "progress"
77
+ }, {
78
+ default: withCtx(() => [createTextVNode(toDisplayString(progress.value), 1)]),
79
+ _: 1
80
+ }), createElementVNode("div", _hoisted_4, [__props.current > 1 ? (openBlock(), createBlock(Button_default, {
81
+ key: 0,
82
+ label: __props.labels.back,
83
+ variant: "outline",
84
+ size: "small",
85
+ "data-tour-part": "back",
86
+ onClick: _cache[1] || (_cache[1] = ($event) => emit("back"))
87
+ }, null, 8, ["label"])) : createCommentVNode("", true), createVNode(Button_default, {
88
+ label: __props.last ? __props.labels.done : __props.labels.next,
89
+ color: "primary",
90
+ size: "small",
91
+ "data-tour-part": "next",
92
+ onClick: _cache[2] || (_cache[2] = ($event) => emit("next"))
93
+ }, null, 8, ["label"])])])
94
+ ]);
95
+ };
96
+ }
97
+ });
98
+ //#endregion
99
+ export { TourCard_vue_vue_type_script_setup_true_lang_default as default };
100
+
101
+ //# sourceMappingURL=TourCard.vue_vue_type_script_setup_true_lang.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TourCard.vue_vue_type_script_setup_true_lang.mjs","names":[],"sources":["../../../../src/components/feedback/tour/TourCard.vue"],"sourcesContent":["<template>\n <div class=\"flex flex-col gap-3 p-4\">\n <div class=\"flex items-center justify-between gap-3\">\n <Typography :id=\"titleId\" as=\"h2\" variant=\"title\" size=\"small\" weight=\"semibold\">{{ title }}</Typography>\n <Tooltip :content=\"labels.skip\" placement=\"top-end\">\n <Button\n variant=\"text\"\n size=\"small\"\n :icon=\"XMarkIcon\"\n :aria-label=\"labels.skip\"\n data-tour-part=\"skip\"\n @click=\"emit('skip')\"\n />\n </Tooltip>\n </div>\n <Typography variant=\"body\" size=\"small\" color=\"muted\">{{ body }}</Typography>\n <div class=\"flex items-center justify-between gap-3\">\n <Typography as=\"span\" variant=\"caption\" color=\"muted\" data-tour-part=\"progress\">{{ progress }}</Typography>\n <div class=\"flex items-center gap-2\">\n <Button\n v-if=\"current > 1\"\n :label=\"labels.back\"\n variant=\"outline\"\n size=\"small\"\n data-tour-part=\"back\"\n @click=\"emit('back')\"\n />\n <Button\n :label=\"last ? labels.done : labels.next\"\n color=\"primary\"\n size=\"small\"\n data-tour-part=\"next\"\n @click=\"emit('next')\"\n />\n </div>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { XMarkIcon } from \"@heroicons/vue/24/outline\";\nimport { interpolate } from \"../../../config/ModoLocale\";\nimport type { TourLabels } from \"../../../interfaces/feedback/Tour.interface\";\nimport Button from \"../../forms/Button.vue\";\nimport Typography from \"../../data-display/Typography.vue\";\nimport Tooltip from \"../Tooltip.vue\";\n\n/**\n * The default card of a Tour: the title (which names the dialog), the body, \"2 of 5\", and two actions, Back (from the second step) and\n * Next (\"Done\" on the last), as a dialog has at most; skipping is the close icon.\n */\nconst props = defineProps<{\n titleId: string;\n title: string;\n body: string;\n current: number;\n total: number;\n last: boolean;\n labels: TourLabels;\n}>();\nconst emit = defineEmits<{ back: []; next: []; skip: [] }>();\nconst progress = computed(() => interpolate(props.labels.progress, { current: props.current, total: props.total }));\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDA,MAAM,QAAQ;EASd,MAAM,OAAO;EACb,MAAM,WAAW,eAAe,YAAY,MAAM,OAAO,UAAU;GAAE,SAAS,MAAM;GAAS,OAAO,MAAM;GAAO,CAAC,CAAC;;uBA7DjH,mBAmCM,OAnCN,YAmCM;IAlCJ,mBAYM,OAZN,YAYM,CAXJ,YAAyG,oBAAA;KAA5F,IAAI,QAAA;KAAS,IAAG;KAAK,SAAQ;KAAQ,MAAK;KAAQ,QAAO;;4BAAsB,CAAA,gBAAA,gBAAR,QAAA,MAAK,EAAA,EAAA,CAAA,CAAA;;mBACzF,YASU,iBAAA;KATA,SAAS,QAAA,OAAO;KAAM,WAAU;;4BAQtC,CAPF,YAOE,gBAAA;MANA,SAAQ;MACR,MAAK;MACJ,MAAM,MAAA,UAAS;MACf,cAAY,QAAA,OAAO;MACpB,kBAAe;MACd,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,OAAA;;;;IAIlB,YAA6E,oBAAA;KAAjE,SAAQ;KAAO,MAAK;KAAQ,OAAM;;4BAAkB,CAAA,gBAAA,gBAAP,QAAA,KAAI,EAAA,EAAA,CAAA,CAAA;;;IAC7D,mBAmBM,OAnBN,YAmBM,CAlBJ,YAA2G,oBAAA;KAA/F,IAAG;KAAO,SAAQ;KAAU,OAAM;KAAQ,kBAAe;;4BAAyB,CAAA,gBAAA,gBAAX,SAAA,MAAQ,EAAA,EAAA,CAAA,CAAA;;QAC3F,mBAgBM,OAhBN,YAgBM,CAdI,QAAA,UAAO,KAAA,WAAA,EADf,YAOE,gBAAA;;KALC,OAAO,QAAA,OAAO;KACf,SAAQ;KACR,MAAK;KACL,kBAAe;KACd,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,OAAA;4DAEd,YAME,gBAAA;KALC,OAAO,QAAA,OAAO,QAAA,OAAO,OAAO,QAAA,OAAO;KACpC,OAAM;KACN,MAAK;KACL,kBAAe;KACd,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,OAAA"}
@@ -0,0 +1,75 @@
1
+ //#region src/components/feedback/tour/tourAnchor.ts
2
+ /** How long a step waits for its target (the page's data, a tab its `before` opened) before it is left out. */
3
+ var TOUR_ANCHOR_TIMEOUT = 1500;
4
+ /**
5
+ * The element that draws a target: itself, or for a wrapper with `display: contents` its first child that has a box; for one marked
6
+ * `data-tour-frame="tablist"` (a Tabs root, which holds the panels too) only its line of tabs. Null for one that is hidden, inert or has no size.
7
+ */
8
+ function tourAnchorBox(element) {
9
+ if (element.dataset.tourFrame === "tablist") {
10
+ const tabs = element.querySelector("[role='tablist']");
11
+ if (tabs) return tourAnchorBox(tabs);
12
+ }
13
+ const style = getComputedStyle(element);
14
+ if (style.display === "contents") {
15
+ for (const child of Array.from(element.children)) {
16
+ const box = child instanceof HTMLElement ? tourAnchorBox(child) : null;
17
+ if (box) return box;
18
+ }
19
+ return null;
20
+ }
21
+ if (style.visibility === "hidden" || element.closest("[hidden], [inert]")) return null;
22
+ const rect = element.getBoundingClientRect();
23
+ return rect.width > 0 && rect.height > 0 ? element : null;
24
+ }
25
+ /** The element a step points at right now, as `tourAnchorBox` measures it, or null: no target, none on the page, one that does not show. */
26
+ function findTourTarget(step, resolve) {
27
+ const { target } = step;
28
+ if (target === void 0) return null;
29
+ try {
30
+ if (typeof target === "string") {
31
+ if (resolve) {
32
+ const found = resolve(target, step);
33
+ return found ? tourAnchorBox(found) : null;
34
+ }
35
+ for (const element of Array.from(document.querySelectorAll(target))) {
36
+ const box = tourAnchorBox(element);
37
+ if (box) return box;
38
+ }
39
+ return null;
40
+ }
41
+ const element = typeof target === "function" ? target() : target;
42
+ return element ? tourAnchorBox(element) : null;
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+ /** The target once `find` gives it, or null after `timeout`: the page may still be loading what it points at. */
48
+ function waitForTourTarget(find, timeout = TOUR_ANCHOR_TIMEOUT) {
49
+ const now = find();
50
+ if (now || timeout <= 0) return Promise.resolve(now);
51
+ return new Promise((resolve) => {
52
+ const observer = new MutationObserver(() => {
53
+ const found = find();
54
+ if (found) finish(found);
55
+ });
56
+ function finish(found) {
57
+ observer.disconnect();
58
+ clearTimeout(timer);
59
+ resolve(found);
60
+ }
61
+ const timer = setTimeout(() => finish(find()), timeout);
62
+ observer.observe(document.body, {
63
+ childList: true,
64
+ subtree: true,
65
+ attributes: true
66
+ });
67
+ });
68
+ }
69
+ //#endregion
70
+ exports.TOUR_ANCHOR_TIMEOUT = TOUR_ANCHOR_TIMEOUT;
71
+ exports.findTourTarget = findTourTarget;
72
+ exports.tourAnchorBox = tourAnchorBox;
73
+ exports.waitForTourTarget = waitForTourTarget;
74
+
75
+ //# sourceMappingURL=tourAnchor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tourAnchor.cjs","names":[],"sources":["../../../../src/components/feedback/tour/tourAnchor.ts"],"sourcesContent":["import type { TourItem, TourTargetResolver } from \"../../../interfaces/feedback/Tour.interface\";\n\n/** How long a step waits for its target (the page's data, a tab its `before` opened) before it is left out. */\nexport const TOUR_ANCHOR_TIMEOUT = 1500;\n\n/**\n * The element that draws a target: itself, or for a wrapper with `display: contents` its first child that has a box; for one marked\n * `data-tour-frame=\"tablist\"` (a Tabs root, which holds the panels too) only its line of tabs. Null for one that is hidden, inert or has no size.\n */\nexport function tourAnchorBox(element: HTMLElement): HTMLElement | null {\n if (element.dataset.tourFrame === \"tablist\") {\n const tabs = element.querySelector<HTMLElement>(\"[role='tablist']\");\n if (tabs) return tourAnchorBox(tabs);\n }\n const style = getComputedStyle(element);\n if (style.display === \"contents\") {\n for (const child of Array.from(element.children)) {\n const box = child instanceof HTMLElement ? tourAnchorBox(child) : null;\n if (box) return box;\n }\n return null;\n }\n if (style.visibility === \"hidden\" || element.closest(\"[hidden], [inert]\")) return null;\n const rect = element.getBoundingClientRect();\n return rect.width > 0 && rect.height > 0 ? element : null;\n}\n\n/** The element a step points at right now, as `tourAnchorBox` measures it, or null: no target, none on the page, one that does not show. */\nexport function findTourTarget(step: TourItem, resolve?: TourTargetResolver): HTMLElement | null {\n const { target } = step;\n if (target === undefined) return null;\n try {\n if (typeof target === \"string\") {\n if (resolve) {\n const found = resolve(target, step);\n return found ? tourAnchorBox(found) : null;\n }\n for (const element of Array.from(document.querySelectorAll<HTMLElement>(target))) {\n const box = tourAnchorBox(element);\n if (box) return box;\n }\n return null;\n }\n const element = typeof target === \"function\" ? target() : target;\n return element ? tourAnchorBox(element) : null;\n } catch {\n return null;\n }\n}\n\n/** The target once `find` gives it, or null after `timeout`: the page may still be loading what it points at. */\nexport function waitForTourTarget(find: () => HTMLElement | null, timeout = TOUR_ANCHOR_TIMEOUT): Promise<HTMLElement | null> {\n const now = find();\n if (now || timeout <= 0) return Promise.resolve(now);\n return new Promise((resolve) => {\n const observer = new MutationObserver(() => {\n const found = find();\n if (found) finish(found);\n });\n function finish(found: HTMLElement | null): void {\n observer.disconnect();\n clearTimeout(timer);\n resolve(found);\n }\n const timer = setTimeout(() => finish(find()), timeout);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true });\n });\n}\n"],"mappings":";;AAGA,IAAa,sBAAsB;;;;;AAMnC,SAAgB,cAAc,SAA0C;CACtE,IAAI,QAAQ,QAAQ,cAAc,WAAW;EAC3C,MAAM,OAAO,QAAQ,cAA2B,mBAAmB;EACnE,IAAI,MAAM,OAAO,cAAc,KA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AAE,QAAQ;EACvD,SAAS,QAAQ,SAAS,MAAM;GAAE,WAAW;GAAM,SAAS;GAAM,YAAY;GAAM,CAAC;GACrF"}
@@ -0,0 +1,72 @@
1
+ //#region src/components/feedback/tour/tourAnchor.ts
2
+ /** How long a step waits for its target (the page's data, a tab its `before` opened) before it is left out. */
3
+ var TOUR_ANCHOR_TIMEOUT = 1500;
4
+ /**
5
+ * The element that draws a target: itself, or for a wrapper with `display: contents` its first child that has a box; for one marked
6
+ * `data-tour-frame="tablist"` (a Tabs root, which holds the panels too) only its line of tabs. Null for one that is hidden, inert or has no size.
7
+ */
8
+ function tourAnchorBox(element) {
9
+ if (element.dataset.tourFrame === "tablist") {
10
+ const tabs = element.querySelector("[role='tablist']");
11
+ if (tabs) return tourAnchorBox(tabs);
12
+ }
13
+ const style = getComputedStyle(element);
14
+ if (style.display === "contents") {
15
+ for (const child of Array.from(element.children)) {
16
+ const box = child instanceof HTMLElement ? tourAnchorBox(child) : null;
17
+ if (box) return box;
18
+ }
19
+ return null;
20
+ }
21
+ if (style.visibility === "hidden" || element.closest("[hidden], [inert]")) return null;
22
+ const rect = element.getBoundingClientRect();
23
+ return rect.width > 0 && rect.height > 0 ? element : null;
24
+ }
25
+ /** The element a step points at right now, as `tourAnchorBox` measures it, or null: no target, none on the page, one that does not show. */
26
+ function findTourTarget(step, resolve) {
27
+ const { target } = step;
28
+ if (target === void 0) return null;
29
+ try {
30
+ if (typeof target === "string") {
31
+ if (resolve) {
32
+ const found = resolve(target, step);
33
+ return found ? tourAnchorBox(found) : null;
34
+ }
35
+ for (const element of Array.from(document.querySelectorAll(target))) {
36
+ const box = tourAnchorBox(element);
37
+ if (box) return box;
38
+ }
39
+ return null;
40
+ }
41
+ const element = typeof target === "function" ? target() : target;
42
+ return element ? tourAnchorBox(element) : null;
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+ /** The target once `find` gives it, or null after `timeout`: the page may still be loading what it points at. */
48
+ function waitForTourTarget(find, timeout = TOUR_ANCHOR_TIMEOUT) {
49
+ const now = find();
50
+ if (now || timeout <= 0) return Promise.resolve(now);
51
+ return new Promise((resolve) => {
52
+ const observer = new MutationObserver(() => {
53
+ const found = find();
54
+ if (found) finish(found);
55
+ });
56
+ function finish(found) {
57
+ observer.disconnect();
58
+ clearTimeout(timer);
59
+ resolve(found);
60
+ }
61
+ const timer = setTimeout(() => finish(find()), timeout);
62
+ observer.observe(document.body, {
63
+ childList: true,
64
+ subtree: true,
65
+ attributes: true
66
+ });
67
+ });
68
+ }
69
+ //#endregion
70
+ export { TOUR_ANCHOR_TIMEOUT, findTourTarget, tourAnchorBox, waitForTourTarget };
71
+
72
+ //# sourceMappingURL=tourAnchor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tourAnchor.mjs","names":[],"sources":["../../../../src/components/feedback/tour/tourAnchor.ts"],"sourcesContent":["import type { TourItem, TourTargetResolver } from \"../../../interfaces/feedback/Tour.interface\";\n\n/** How long a step waits for its target (the page's data, a tab its `before` opened) before it is left out. */\nexport const TOUR_ANCHOR_TIMEOUT = 1500;\n\n/**\n * The element that draws a target: itself, or for a wrapper with `display: contents` its first child that has a box; for one marked\n * `data-tour-frame=\"tablist\"` (a Tabs root, which holds the panels too) only its line of tabs. Null for one that is hidden, inert or has no size.\n */\nexport function tourAnchorBox(element: HTMLElement): HTMLElement | null {\n if (element.dataset.tourFrame === \"tablist\") {\n const tabs = element.querySelector<HTMLElement>(\"[role='tablist']\");\n if (tabs) return tourAnchorBox(tabs);\n }\n const style = getComputedStyle(element);\n if (style.display === \"contents\") {\n for (const child of Array.from(element.children)) {\n const box = child instanceof HTMLElement ? tourAnchorBox(child) : null;\n if (box) return box;\n }\n return null;\n }\n if (style.visibility === \"hidden\" || element.closest(\"[hidden], [inert]\")) return null;\n const rect = element.getBoundingClientRect();\n return rect.width > 0 && rect.height > 0 ? element : null;\n}\n\n/** The element a step points at right now, as `tourAnchorBox` measures it, or null: no target, none on the page, one that does not show. */\nexport function findTourTarget(step: TourItem, resolve?: TourTargetResolver): HTMLElement | null {\n const { target } = step;\n if (target === undefined) return null;\n try {\n if (typeof target === \"string\") {\n if (resolve) {\n const found = resolve(target, step);\n return found ? tourAnchorBox(found) : null;\n }\n for (const element of Array.from(document.querySelectorAll<HTMLElement>(target))) {\n const box = tourAnchorBox(element);\n if (box) return box;\n }\n return null;\n }\n const element = typeof target === \"function\" ? target() : target;\n return element ? tourAnchorBox(element) : null;\n } catch {\n return null;\n }\n}\n\n/** The target once `find` gives it, or null after `timeout`: the page may still be loading what it points at. */\nexport function waitForTourTarget(find: () => HTMLElement | null, timeout = TOUR_ANCHOR_TIMEOUT): Promise<HTMLElement | null> {\n const now = find();\n if (now || timeout <= 0) return Promise.resolve(now);\n return new Promise((resolve) => {\n const observer = new MutationObserver(() => {\n const found = find();\n if (found) finish(found);\n });\n function finish(found: HTMLElement | null): void {\n observer.disconnect();\n clearTimeout(timer);\n resolve(found);\n }\n const timer = setTimeout(() => finish(find()), timeout);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true });\n });\n}\n"],"mappings":";;AAGA,IAAa,sBAAsB;;;;;AAMnC,SAAgB,cAAc,SAA0C;CACtE,IAAI,QAAQ,QAAQ,cAAc,WAAW;EAC3C,MAAM,OAAO,QAAQ,cAA2B,mBAAmB;EACnE,IAAI,MAAM,OAAO,cAAc,KAAK;;CAEtC,MAAM,QAAQ,iBAAiB,QAAQ;CACvC,IAAI,MAAM,YAAY,YAAY;EAChC,KAAK,MAAM,SAAS,MAAM,KAAK,QAAQ,SAAS,EAAE;GAChD,MAAM,MAAM,iBAAiB,cAAc,cAAc,MAAM,GAAG;GAClE,IAAI,KAAK,OAAO;;EAElB,OAAO;;CAET,IAAI,MAAM,eAAe,YAAY,QAAQ,QAAQ,oBAAoB,EAAE,OAAO;CAClF,MAAM,OAAO,QAAQ,uBAAuB;CAC5C,OAAO,KAAK,QAAQ,KAAK,KAAK,SAAS,IAAI,UAAU;;;AAIvD,SAAgB,eAAe,MAAgB,SAAkD;CAC/F,MAAM,EAAE,WAAW;CACnB,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,IAAI;EACF,IAAI,OAAO,WAAW,UAAU;GAC9B,IAAI,SAAS;IACX,MAAM,QAAQ,QAAQ,QAAQ,KAAK;IACnC,OAAO,QAAQ,cAAc,MAAM,GAAG;;GAExC,KAAK,MAAM,WAAW,MAAM,KAAK,SAAS,iBAA8B,OAAO,CAAC,EAAE;IAChF,MAAM,MAAM,cAAc,QAAQ;IAClC,IAAI,KAAK,OAAO;;GAElB,OAAO;;EAET,MAAM,UAAU,OAAO,WAAW,aAAa,QAAQ,GAAG;EAC1D,OAAO,UAAU,cAAc,QAAQ,GAAG;SACpC;EACN,OAAO;;;;AAKX,SAAgB,kBAAkB,MAAgC,UAAU,qBAAkD;CAC5H,MAAM,MAAM,MAAM;CAClB,IAAI,OAAO,WAAW,GAAG,OAAO,QAAQ,QAAQ,IAAI;CACpD,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,WAAW,IAAI,uBAAuB;GAC1C,MAAM,QAAQ,MAAM;GACpB,IAAI,OAAO,OAAO,MAAM;IACxB;EACF,SAAS,OAAO,OAAiC;GAC/C,SAAS,YAAY;GACrB,aAAa,MAAM;GACnB,QAAQ,MAAM;;EAEhB,MAAM,QAAQ,iBAAiB,OAAO,MAAM,CAAC,EAAE,QAAQ;EACvD,SAAS,QAAQ,SAAS,MAAM;GAAE,WAAW;GAAM,SAAS;GAAM,YAAY;GAAM,CAAC;GACrF"}
@@ -0,0 +1,108 @@
1
+ //#region src/components/feedback/tour/tourPlace.ts
2
+ /** The air between a target and its card, and between the card and the screen's edge. */
3
+ var GAP = 12;
4
+ var MARGIN = 16;
5
+ /**
6
+ * Where a step's card goes: below the target when it fits, else beside it (right, then left, level with its top) inside the content,
7
+ * else above when the target sits in the lower half (never over the top bar or the page's head), else the page scrolls so the
8
+ * target's top sits under the top bar and the card fits below it. A target too tall for that, or one the page cannot scroll enough,
9
+ * gets the card pinned to the bottom (right corner, the whole width on a phone) and only what the card covers cut away. A target in
10
+ * the top bar needs no scroll; one scrolled out of sight is brought back.
11
+ */
12
+ function placeStep({ box, viewport, card, inset, chrome, phone, scrolled }) {
13
+ const height = box.bottom - box.top;
14
+ const room = viewport.height - MARGIN - card.height - GAP;
15
+ const pin = (scroll) => {
16
+ const x = phone ? MARGIN : viewport.width - MARGIN - card.width;
17
+ const covered = phone || box.right > x && box.left < viewport.width - MARGIN;
18
+ return {
19
+ mode: "pinned",
20
+ scroll: scrolled ? 0 : Math.round(scroll),
21
+ cover: covered ? {
22
+ left: phone ? 0 : x - GAP,
23
+ top: room
24
+ } : null
25
+ };
26
+ };
27
+ if (chrome) return phone ? pin(0) : {
28
+ mode: "below",
29
+ scroll: 0,
30
+ cover: null
31
+ };
32
+ if (phone) return pin(height > room - inset.top ? box.top - inset.top : box.top < inset.top ? box.top - inset.top : Math.max(0, box.bottom - room));
33
+ if (box.top >= inset.top && box.bottom + GAP + card.height <= viewport.height - MARGIN) return {
34
+ mode: "below",
35
+ scroll: 0,
36
+ cover: null
37
+ };
38
+ const top = Math.min(box.top, viewport.height - MARGIN - card.height);
39
+ if (box.top >= inset.top && box.top <= viewport.height - MARGIN && top >= inset.top) {
40
+ const rightAt = box.right + GAP;
41
+ if (rightAt + card.width <= viewport.width - MARGIN) return {
42
+ mode: "right",
43
+ scroll: 0,
44
+ at: {
45
+ top,
46
+ left: rightAt
47
+ },
48
+ cover: null
49
+ };
50
+ const leftAt = box.left - GAP - card.width;
51
+ if (leftAt >= Math.max(MARGIN, inset.left)) return {
52
+ mode: "left",
53
+ scroll: 0,
54
+ at: {
55
+ top,
56
+ left: leftAt
57
+ },
58
+ cover: null
59
+ };
60
+ }
61
+ if (height + GAP + card.height > viewport.height - inset.top - MARGIN) return pin(box.top - inset.top);
62
+ if (box.top >= viewport.height / 2 && box.top - GAP - card.height >= inset.top && box.bottom <= viewport.height) return {
63
+ mode: "above",
64
+ scroll: 0,
65
+ cover: null
66
+ };
67
+ return scrolled ? pin(0) : {
68
+ mode: "below",
69
+ scroll: Math.floor(box.top - inset.top),
70
+ cover: null
71
+ };
72
+ }
73
+ /** The scrollable ancestor of an element (the page's own panel, or the document). */
74
+ function scrollerOf(element) {
75
+ for (let parent = element.parentElement; parent; parent = parent.parentElement) {
76
+ const { overflowY } = getComputedStyle(parent);
77
+ if ((overflowY === "auto" || overflowY === "scroll") && parent.scrollHeight > parent.clientHeight) return parent;
78
+ }
79
+ return document.scrollingElement ?? document.documentElement;
80
+ }
81
+ /** Scrolls the target's page by `delta` pixels and resolves when it has stopped (or after a moment, where scrollend is missing). */
82
+ function scrollPageBy(element, delta) {
83
+ if (delta === 0) return Promise.resolve();
84
+ const scroller = scrollerOf(element);
85
+ const smooth = !window.matchMedia("(prefers-reduced-motion: reduce)").matches;
86
+ const before = scroller.scrollTop;
87
+ scroller.scrollBy({
88
+ top: delta,
89
+ behavior: smooth ? "smooth" : "auto"
90
+ });
91
+ if (!smooth) return Promise.resolve();
92
+ return new Promise((resolve) => {
93
+ const target = scroller === document.scrollingElement ? document : scroller;
94
+ const finish = () => {
95
+ target.removeEventListener("scrollend", finish);
96
+ clearTimeout(timer);
97
+ resolve();
98
+ };
99
+ const timer = setTimeout(finish, 700);
100
+ if (scroller.scrollTop === before && delta < 0 && before === 0) return finish();
101
+ target.addEventListener("scrollend", finish);
102
+ });
103
+ }
104
+ //#endregion
105
+ exports.placeStep = placeStep;
106
+ exports.scrollPageBy = scrollPageBy;
107
+
108
+ //# sourceMappingURL=tourPlace.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tourPlace.cjs","names":[],"sources":["../../../../src/components/feedback/tour/tourPlace.ts"],"sourcesContent":["/** The air between a target and its card, and between the card and the screen's edge. */\nconst GAP = 12;\nconst MARGIN = 16;\n\nexport interface PlaceInput {\n /** The target's box, against the viewport. */\n box: { top: number; bottom: number; left: number; right: number };\n /** The viewport's size. */\n viewport: { width: number; height: number };\n /** The card's size. */\n card: { width: number; height: number };\n /** Where the page's content starts: the bottom of the top bar and the right edge of the menu, which the card must not cover. */\n inset: { top: number; left: number };\n /** The target sits in the top bar itself (fixed or sticky): it needs no scroll and the card goes below it. */\n chrome: boolean;\n /** On a phone the card is always pinned to the bottom. */\n phone: boolean;\n /** The page has already been scrolled for this step, so it has nothing more to give. */\n scrolled: boolean;\n}\n\n/**\n * `below` or `above` the target, `right` or `left` of it (then `at` is the card's corner), or `pinned` to the bottom of the viewport.\n * `cover` is the corner of the screen the pinned card holds, with its air: whatever of the target lies at or right of `left` and at or\n * below `top` is not cut. Set only when the card really sits over the target, so a target the card does not cover is cut whole.\n */\nexport interface Place {\n mode: \"below\" | \"above\" | \"right\" | \"left\" | \"pinned\";\n /** How far to scroll the page, positive down, before the card is placed (0: none). */\n scroll: number;\n at?: { top: number; left: number };\n cover: { left: number; top: number } | null;\n}\n\n/**\n * Where a step's card goes: below the target when it fits, else beside it (right, then left, level with its top) inside the content,\n * else above when the target sits in the lower half (never over the top bar or the page's head), else the page scrolls so the\n * target's top sits under the top bar and the card fits below it. A target too tall for that, or one the page cannot scroll enough,\n * gets the card pinned to the bottom (right corner, the whole width on a phone) and only what the card covers cut away. A target in\n * the top bar needs no scroll; one scrolled out of sight is brought back.\n */\nexport function placeStep({ box, viewport, card, inset, chrome, phone, scrolled }: PlaceInput): Place {\n const height = box.bottom - box.top;\n const room = viewport.height - MARGIN - card.height - GAP;\n const pin = (scroll: number): Place => {\n const x = phone ? MARGIN : viewport.width - MARGIN - card.width;\n const covered = phone || (box.right > x && box.left < viewport.width - MARGIN);\n return { mode: \"pinned\", scroll: scrolled ? 0 : Math.round(scroll), cover: covered ? { left: phone ? 0 : x - GAP, top: room } : null };\n };\n if (chrome) return phone ? pin(0) : { mode: \"below\", scroll: 0, cover: null };\n if (phone) {\n const tall = height > room - inset.top;\n return pin(tall ? box.top - inset.top : box.top < inset.top ? box.top - inset.top : Math.max(0, box.bottom - room));\n }\n if (box.top >= inset.top && box.bottom + GAP + card.height <= viewport.height - MARGIN) return { mode: \"below\", scroll: 0, cover: null };\n const top = Math.min(box.top, viewport.height - MARGIN - card.height);\n // A target below the fold gets no card beside it: the page scrolls to it first (below).\n if (box.top >= inset.top && box.top <= viewport.height - MARGIN && top >= inset.top) {\n const rightAt = box.right + GAP;\n if (rightAt + card.width <= viewport.width - MARGIN) return { mode: \"right\", scroll: 0, at: { top, left: rightAt }, cover: null };\n const leftAt = box.left - GAP - card.width;\n if (leftAt >= Math.max(MARGIN, inset.left)) return { mode: \"left\", scroll: 0, at: { top, left: leftAt }, cover: null };\n }\n if (height + GAP + card.height > viewport.height - inset.top - MARGIN) return pin(box.top - inset.top);\n if (box.top >= viewport.height / 2 && box.top - GAP - card.height >= inset.top && box.bottom <= viewport.height) return { mode: \"above\", scroll: 0, cover: null };\n return scrolled ? pin(0) : { mode: \"below\", scroll: Math.floor(box.top - inset.top), cover: null };\n}\n\n/** The scrollable ancestor of an element (the page's own panel, or the document). */\nexport function scrollerOf(element: HTMLElement): HTMLElement | Element {\n for (let parent = element.parentElement; parent; parent = parent.parentElement) {\n const { overflowY } = getComputedStyle(parent);\n if ((overflowY === \"auto\" || overflowY === \"scroll\") && parent.scrollHeight > parent.clientHeight) return parent;\n }\n return document.scrollingElement ?? document.documentElement;\n}\n\n/** Scrolls the target's page by `delta` pixels and resolves when it has stopped (or after a moment, where scrollend is missing). */\nexport function scrollPageBy(element: HTMLElement, delta: number): Promise<void> {\n if (delta === 0) return Promise.resolve();\n const scroller = scrollerOf(element);\n const smooth = !window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n const before = scroller.scrollTop;\n scroller.scrollBy({ top: delta, behavior: smooth ? \"smooth\" : \"auto\" });\n if (!smooth) return Promise.resolve();\n return new Promise((resolve) => {\n const target = scroller === document.scrollingElement ? document : scroller;\n const finish = () => {\n target.removeEventListener(\"scrollend\", finish);\n clearTimeout(timer);\n resolve();\n };\n const timer = setTimeout(finish, 700);\n if (scroller.scrollTop === before && delta < 0 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eAAe;GACnB,OAAO,oBAAoB,aAAa,OAAO;GAC/C,aAAa,MAAM;GACnB,SAAS;;EAEX,MAAM,QAAQ,WAAW,QAAQ,IAAI;EACrC,IAAI,SAAS,cAAc,UAAU,QAAQ,KAAK,WAAW,GAAG,OAAO,QAAQ;EAC/E,OAAO,iBAAiB,aAAa,OAAO;GAC5C"}
@@ -0,0 +1,107 @@
1
+ //#region src/components/feedback/tour/tourPlace.ts
2
+ /** The air between a target and its card, and between the card and the screen's edge. */
3
+ var GAP = 12;
4
+ var MARGIN = 16;
5
+ /**
6
+ * Where a step's card goes: below the target when it fits, else beside it (right, then left, level with its top) inside the content,
7
+ * else above when the target sits in the lower half (never over the top bar or the page's head), else the page scrolls so the
8
+ * target's top sits under the top bar and the card fits below it. A target too tall for that, or one the page cannot scroll enough,
9
+ * gets the card pinned to the bottom (right corner, the whole width on a phone) and only what the card covers cut away. A target in
10
+ * the top bar needs no scroll; one scrolled out of sight is brought back.
11
+ */
12
+ function placeStep({ box, viewport, card, inset, chrome, phone, scrolled }) {
13
+ const height = box.bottom - box.top;
14
+ const room = viewport.height - MARGIN - card.height - GAP;
15
+ const pin = (scroll) => {
16
+ const x = phone ? MARGIN : viewport.width - MARGIN - card.width;
17
+ const covered = phone || box.right > x && box.left < viewport.width - MARGIN;
18
+ return {
19
+ mode: "pinned",
20
+ scroll: scrolled ? 0 : Math.round(scroll),
21
+ cover: covered ? {
22
+ left: phone ? 0 : x - GAP,
23
+ top: room
24
+ } : null
25
+ };
26
+ };
27
+ if (chrome) return phone ? pin(0) : {
28
+ mode: "below",
29
+ scroll: 0,
30
+ cover: null
31
+ };
32
+ if (phone) return pin(height > room - inset.top ? box.top - inset.top : box.top < inset.top ? box.top - inset.top : Math.max(0, box.bottom - room));
33
+ if (box.top >= inset.top && box.bottom + GAP + card.height <= viewport.height - MARGIN) return {
34
+ mode: "below",
35
+ scroll: 0,
36
+ cover: null
37
+ };
38
+ const top = Math.min(box.top, viewport.height - MARGIN - card.height);
39
+ if (box.top >= inset.top && box.top <= viewport.height - MARGIN && top >= inset.top) {
40
+ const rightAt = box.right + GAP;
41
+ if (rightAt + card.width <= viewport.width - MARGIN) return {
42
+ mode: "right",
43
+ scroll: 0,
44
+ at: {
45
+ top,
46
+ left: rightAt
47
+ },
48
+ cover: null
49
+ };
50
+ const leftAt = box.left - GAP - card.width;
51
+ if (leftAt >= Math.max(MARGIN, inset.left)) return {
52
+ mode: "left",
53
+ scroll: 0,
54
+ at: {
55
+ top,
56
+ left: leftAt
57
+ },
58
+ cover: null
59
+ };
60
+ }
61
+ if (height + GAP + card.height > viewport.height - inset.top - MARGIN) return pin(box.top - inset.top);
62
+ if (box.top >= viewport.height / 2 && box.top - GAP - card.height >= inset.top && box.bottom <= viewport.height) return {
63
+ mode: "above",
64
+ scroll: 0,
65
+ cover: null
66
+ };
67
+ return scrolled ? pin(0) : {
68
+ mode: "below",
69
+ scroll: Math.floor(box.top - inset.top),
70
+ cover: null
71
+ };
72
+ }
73
+ /** The scrollable ancestor of an element (the page's own panel, or the document). */
74
+ function scrollerOf(element) {
75
+ for (let parent = element.parentElement; parent; parent = parent.parentElement) {
76
+ const { overflowY } = getComputedStyle(parent);
77
+ if ((overflowY === "auto" || overflowY === "scroll") && parent.scrollHeight > parent.clientHeight) return parent;
78
+ }
79
+ return document.scrollingElement ?? document.documentElement;
80
+ }
81
+ /** Scrolls the target's page by `delta` pixels and resolves when it has stopped (or after a moment, where scrollend is missing). */
82
+ function scrollPageBy(element, delta) {
83
+ if (delta === 0) return Promise.resolve();
84
+ const scroller = scrollerOf(element);
85
+ const smooth = !window.matchMedia("(prefers-reduced-motion: reduce)").matches;
86
+ const before = scroller.scrollTop;
87
+ scroller.scrollBy({
88
+ top: delta,
89
+ behavior: smooth ? "smooth" : "auto"
90
+ });
91
+ if (!smooth) return Promise.resolve();
92
+ return new Promise((resolve) => {
93
+ const target = scroller === document.scrollingElement ? document : scroller;
94
+ const finish = () => {
95
+ target.removeEventListener("scrollend", finish);
96
+ clearTimeout(timer);
97
+ resolve();
98
+ };
99
+ const timer = setTimeout(finish, 700);
100
+ if (scroller.scrollTop === before && delta < 0 && before === 0) return finish();
101
+ target.addEventListener("scrollend", finish);
102
+ });
103
+ }
104
+ //#endregion
105
+ export { placeStep, scrollPageBy };
106
+
107
+ //# sourceMappingURL=tourPlace.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tourPlace.mjs","names":[],"sources":["../../../../src/components/feedback/tour/tourPlace.ts"],"sourcesContent":["/** The air between a target and its card, and between the card and the screen's edge. */\nconst GAP = 12;\nconst MARGIN = 16;\n\nexport interface PlaceInput {\n /** The target's box, against the viewport. */\n box: { top: number; bottom: number; left: number; right: number };\n /** The viewport's size. */\n viewport: { width: number; height: number };\n /** The card's size. */\n card: { width: number; height: number };\n /** Where the page's content starts: the bottom of the top bar and the right edge of the menu, which the card must not cover. */\n inset: { top: number; left: number };\n /** The target sits in the top bar itself (fixed or sticky): it needs no scroll and the card goes below it. */\n chrome: boolean;\n /** On a phone the card is always pinned to the bottom. */\n phone: boolean;\n /** The page has already been scrolled for this step, so it has nothing more to give. */\n scrolled: boolean;\n}\n\n/**\n * `below` or `above` the target, `right` or `left` of it (then `at` is the card's corner), or `pinned` to the bottom of the viewport.\n * `cover` is the corner of the screen the pinned card holds, with its air: whatever of the target lies at or right of `left` and at or\n * below `top` is not cut. Set only when the card really sits over the target, so a target the card does not cover is cut whole.\n */\nexport interface Place {\n mode: \"below\" | \"above\" | \"right\" | \"left\" | \"pinned\";\n /** How far to scroll the page, positive down, before the card is placed (0: none). */\n scroll: number;\n at?: { top: number; left: number };\n cover: { left: number; top: number } | null;\n}\n\n/**\n * Where a step's card goes: below the target when it fits, else beside it (right, then left, level with its top) inside the content,\n * else above when the target sits in the lower half (never over the top bar or the page's head), else the page scrolls so the\n * target's top sits under the top bar and the card fits below it. A target too tall for that, or one the page cannot scroll enough,\n * gets the card pinned to the bottom (right corner, the whole width on a phone) and only what the card covers cut away. A target in\n * the top bar needs no scroll; one scrolled out of sight is brought back.\n */\nexport function placeStep({ box, viewport, card, inset, chrome, phone, scrolled }: PlaceInput): Place {\n const height = box.bottom - box.top;\n const room = viewport.height - MARGIN - card.height - GAP;\n const pin = (scroll: number): Place => {\n const x = phone ? MARGIN : viewport.width - MARGIN - card.width;\n const covered = phone || (box.right > x && box.left < viewport.width - MARGIN);\n return { mode: \"pinned\", scroll: scrolled ? 0 : Math.round(scroll), cover: covered ? { left: phone ? 0 : x - GAP, top: room } : null };\n };\n if (chrome) return phone ? pin(0) : { mode: \"below\", scroll: 0, cover: null };\n if (phone) {\n const tall = height > room - inset.top;\n return pin(tall ? box.top - inset.top : box.top < inset.top ? box.top - inset.top : Math.max(0, box.bottom - room));\n }\n if (box.top >= inset.top && box.bottom + GAP + card.height <= viewport.height - MARGIN) return { mode: \"below\", scroll: 0, cover: null };\n const top = Math.min(box.top, viewport.height - MARGIN - card.height);\n // A target below the fold gets no card beside it: the page scrolls to it first (below).\n if (box.top >= inset.top && box.top <= viewport.height - MARGIN && top >= inset.top) {\n const rightAt = box.right + GAP;\n if (rightAt + card.width <= viewport.width - MARGIN) return { mode: \"right\", scroll: 0, at: { top, left: rightAt }, cover: null };\n const leftAt = box.left - GAP - card.width;\n if (leftAt >= Math.max(MARGIN, inset.left)) return { mode: \"left\", scroll: 0, at: { top, left: leftAt }, cover: null };\n }\n if (height + GAP + card.height > viewport.height - inset.top - MARGIN) return pin(box.top - inset.top);\n if (box.top >= viewport.height / 2 && box.top - GAP - card.height >= inset.top && box.bottom <= viewport.height) return { mode: \"above\", scroll: 0, cover: null };\n return scrolled ? pin(0) : { mode: \"below\", scroll: Math.floor(box.top - inset.top), cover: null };\n}\n\n/** The scrollable ancestor of an element (the page's own panel, or the document). */\nexport function scrollerOf(element: HTMLElement): HTMLElement | Element {\n for (let parent = element.parentElement; parent; parent = parent.parentElement) {\n const { overflowY } = getComputedStyle(parent);\n if ((overflowY === \"auto\" || overflowY === \"scroll\") && parent.scrollHeight > parent.clientHeight) return parent;\n }\n return document.scrollingElement ?? document.documentElement;\n}\n\n/** Scrolls the target's page by `delta` pixels and resolves when it has stopped (or after a moment, where scrollend is missing). */\nexport function scrollPageBy(element: HTMLElement, delta: number): Promise<void> {\n if (delta === 0) return Promise.resolve();\n const scroller = scrollerOf(element);\n const smooth = !window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n const before = scroller.scrollTop;\n scroller.scrollBy({ top: delta, behavior: smooth ? \"smooth\" : \"auto\" });\n if (!smooth) return Promise.resolve();\n return new Promise((resolve) => {\n const target = scroller === document.scrollingElement ? document : scroller;\n const finish = () => {\n target.removeEventListener(\"scrollend\", finish);\n clearTimeout(timer);\n resolve();\n };\n const timer = setTimeout(finish, 700);\n if (scroller.scrollTop === before && delta < 0 && before === 0) return finish();\n target.addEventListener(\"scrollend\", finish);\n });\n}\n"],"mappings":";;AACA,IAAM,MAAM;AACZ,IAAM,SAAS;;;;;;;;AAuCf,SAAgB,UAAU,EAAE,KAAK,UAAU,MAAM,OAAO,QAAQ,OAAO,YAA+B;CACpG,MAAM,SAAS,IAAI,SAAS,IAAI;CAChC,MAAM,OAAO,SAAS,SAAS,SAAS,KAAK,SAAS;CACtD,MAAM,OAAO,WAA0B;EACrC,MAAM,IAAI,QAAQ,SAAS,SAAS,QAAQ,SAAS,KAAK;EAC1D,MAAM,UAAU,SAAU,IAAI,QAAQ,KAAK,IAAI,OAAO,SAAS,QAAQ;EACvE,OAAO;GAAE,MAAM;GAAU,QAAQ,WAAW,IAAI,KAAK,MAAM,OAAO;GAAE,OAAO,UAAU;IAAE,MAAM,QAAQ,IAAI,IAAI;IAAK,KAAK;IAAM,GAAG;GAAM;;CAExI,IAAI,QAAQ,OAAO,QAAQ,IAAI,EAAE,GAAG;EAAE,MAAM;EAAS,QAAQ;EAAG,OAAO;EAAM;CAC7E,IAAI,OAEF,OAAO,IADM,SAAS,OAAO,MAAM,MACjB,IAAI,MAAM,MAAM,MAAM,IAAI,MAAM,M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;EAC9C,KAAK,cAAc,UAAU,cAAc,aAAa,OAAO,eAAe,OAAO,cAAc,OAAO;;CAE5G,OAAO,SAAS,oBAAoB,SAAS;;;AAI/C,SAAgB,aAAa,SAAsB,OAA8B;CAC/E,IAAI,UAAU,GAAG,OAAO,QAAQ,SAAS;CACzC,MAAM,WAAW,WAAW,QAAQ;CACpC,MAAM,SAAS,CAAC,OAAO,WAAW,mCAAmC,CAAC;CACtE,MAAM,SAAS,SAAS;CACxB,SAAS,SAAS;EAAE,KAAK;EAAO,UAAU,SAAS,WAAW;EAAQ,CAAC;CACvE,IAAI,CAAC,QAAQ,OAAO,QAAQ,SAAS;CACrC,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,SAAS,aAAa,SAAS,mBAAmB,WAAW;EACnE,MAAM,eAAe;GACnB,OAAO,oBAAoB,aAAa,OAAO;GAC/C,aAAa,MAAM;GACnB,SAAS;;EAEX,MAAM,QAAQ,WAAW,QAAQ,IAAI;EACrC,IAAI,SAAS,cAAc,UAAU,QAAQ,KAAK,WAAW,GAAG,OAAO,QAAQ;EAC/E,OAAO,iBAAiB,aAAa,OAAO;GAC5C"}
@@ -0,0 +1,121 @@
1
+ //#region src/components/feedback/tour/tourShape.ts
2
+ /** The room around a target inside the spotlight's cut. */
3
+ var PADDING = 8;
4
+ /** mood-ui's corners (PopoverPanel's rounded-sm, -md, -xl and -2xl) in pixels, so the cut wears the person's radius. */
5
+ var RADII = {
6
+ none: 0,
7
+ small: 4,
8
+ medium: 6,
9
+ large: 12,
10
+ full: 16
11
+ };
12
+ /** The corner's radius in pixels of mood-ui's radius name; medium when there is none. */
13
+ function radiusOf(radius) {
14
+ return RADII[radius ?? "medium"] ?? 6;
15
+ }
16
+ /**
17
+ * The cut around a target's box: padded, kept inside the screen, its corners never rounder than half its side. `cover` is the corner of
18
+ * the screen a card holds: the cut loses only what lies there (a step down for a card under the target's right part, a plain trim when
19
+ * the card spans the target's whole width or height), so the rest of a wide target stays lit.
20
+ */
21
+ function holeAround(box, radius, viewport, cover = null) {
22
+ const x = Math.max(0, box.left - PADDING);
23
+ const y = Math.max(0, box.top - PADDING);
24
+ let width = Math.max(0, Math.min(viewport.width, box.left + box.width + PADDING) - x);
25
+ let height = Math.max(0, Math.min(viewport.height, box.top + box.height + PADDING) - y);
26
+ let notch;
27
+ if (cover && cover.left < x + width && cover.top < y + height) if (cover.left <= x) height = Math.max(0, cover.top - y);
28
+ else if (cover.top <= y) width = Math.max(0, cover.left - x);
29
+ else notch = {
30
+ x: cover.left,
31
+ y: cover.top
32
+ };
33
+ const hole = {
34
+ x,
35
+ y,
36
+ width,
37
+ height,
38
+ radius: Math.min(radius, width / 2, height / 2)
39
+ };
40
+ return notch ? {
41
+ ...hole,
42
+ notch
43
+ } : hole;
44
+ }
45
+ /** The cut's corners, clockwise: a rectangle, or an L when a card takes its bottom right corner. */
46
+ function corners({ x, y, width: w, height: h, notch }) {
47
+ if (!notch) return [
48
+ [x, y],
49
+ [x + w, y],
50
+ [x + w, y + h],
51
+ [x, y + h]
52
+ ];
53
+ return [
54
+ [x, y],
55
+ [x + w, y],
56
+ [x + w, notch.y],
57
+ [notch.x, notch.y],
58
+ [notch.x, y + h],
59
+ [x, y + h]
60
+ ];
61
+ }
62
+ /** The closed outline of the cut, every corner rounded by the hole's radius (less where an edge is short), the arcs turning with the corner. */
63
+ function outline(hole) {
64
+ const points = corners(hole);
65
+ const r = Math.max(0, hole.radius);
66
+ const bends = points.map((at, i) => {
67
+ const before = points[(i + points.length - 1) % points.length];
68
+ const after = points[(i + 1) % points.length];
69
+ const lengthIn = Math.abs(at[0] - before[0]) + Math.abs(at[1] - before[1]);
70
+ const lengthOut = Math.abs(after[0] - at[0]) + Math.abs(after[1] - at[1]);
71
+ const radius = Math.min(r, lengthIn / 2, lengthOut / 2);
72
+ const inward = [Math.sign(at[0] - before[0]), Math.sign(at[1] - before[1])];
73
+ const outward = [Math.sign(after[0] - at[0]), Math.sign(after[1] - at[1])];
74
+ return {
75
+ radius,
76
+ from: [at[0] - inward[0] * radius, at[1] - inward[1] * radius],
77
+ to: [at[0] + outward[0] * radius, at[1] + outward[1] * radius],
78
+ sweep: inward[0] * outward[1] - inward[1] * outward[0] > 0 ? 1 : 0
79
+ };
80
+ });
81
+ const first = bends[0];
82
+ let path = `M${first.to[0]} ${first.to[1]}`;
83
+ let at = first.to;
84
+ for (const bend of [...bends.slice(1), first]) {
85
+ path += `${at[1] === bend.from[1] ? "H" : "V"}${at[1] === bend.from[1] ? bend.from[0] : bend.from[1]}`;
86
+ path += `A${bend.radius} ${bend.radius} 0 0 ${bend.sweep} ${bend.to[0]} ${bend.to[1]}`;
87
+ at = bend.to;
88
+ }
89
+ return `${path}Z`;
90
+ }
91
+ /** The shade over the screen with the hole cut out (drawn after it, for `fill-rule="evenodd"`), or the whole screen without one. */
92
+ function spotlightPath(viewport, hole) {
93
+ const screen = `M0 0H${viewport.width}V${viewport.height}H0Z`;
94
+ if (!hole || hole.width <= 0 || hole.height <= 0) return screen;
95
+ return `${screen}${outline(hole)}`;
96
+ }
97
+ /** The line round the cut, `inset` pixels inside it (half the stroke's width keeps a stroke wholly inside the cut), or null with no cut. */
98
+ function ringPath(hole, inset) {
99
+ if (!hole || hole.width <= 2 * inset || hole.height <= 2 * inset) return null;
100
+ const inner = {
101
+ x: hole.x + inset,
102
+ y: hole.y + inset,
103
+ width: hole.width - 2 * inset,
104
+ height: hole.height - 2 * inset,
105
+ radius: Math.max(0, hole.radius - inset)
106
+ };
107
+ return outline(hole.notch ? {
108
+ ...inner,
109
+ notch: {
110
+ x: hole.notch.x - inset,
111
+ y: hole.notch.y - inset
112
+ }
113
+ } : inner);
114
+ }
115
+ //#endregion
116
+ exports.holeAround = holeAround;
117
+ exports.radiusOf = radiusOf;
118
+ exports.ringPath = ringPath;
119
+ exports.spotlightPath = spotlightPath;
120
+
121
+ //# sourceMappingURL=tourShape.cjs.map