@leaflink/stash 41.7.0 → 42.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Card.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as w, useSlots as i, openBlock as a, createElementBlock as r, unref as s, normalizeClass as n, createElementVNode as l, renderSlot as o, createCommentVNode as f } from "vue";
2
2
  const p = {
3
- class: "stash-card tw-border tw-rounded tw-shadow tw-inline-block tw-relative tw-bg-white",
3
+ class: "stash-card tw-border tw-rounded tw-shadow-md tw-inline-block tw-relative tw-bg-white",
4
4
  "data-test": "stash-card"
5
5
  }, h = /* @__PURE__ */ w({
6
6
  __name: "Card",
package/dist/Card.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Card.js","sources":["../src/components/Card/Card.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { useSlots } from 'vue';\n\n export interface CardProps {\n /**\n * Detach the actions from the top of the card, making them absolute-positioned.\n * @default false\n */\n detachActions?: boolean;\n }\n\n const props = withDefaults(defineProps<CardProps>(), {\n detachActions: false,\n });\n\n const slots = useSlots();\n</script>\n\n<template>\n <article\n class=\"stash-card tw-border tw-rounded tw-shadow tw-inline-block tw-relative tw-bg-white\"\n data-test=\"stash-card\"\n >\n <div\n v-if=\"slots['top-left'] || slots['top-right']\"\n data-test=\"card-actions\"\n :class=\"{ 'tw-absolute tw-top-0 tw-w-full': props.detachActions }\"\n class=\"tw-flex tw-justify-between tw-items-start tw-flex-wrap tw-p-6\"\n >\n <div>\n <!-- @slot Top left actions slot, for rendering content on the card top-left -->\n <slot name=\"top-left\"></slot>\n </div>\n <div>\n <!-- @slot Top right actions slot, for rendering content on the card top-right -->\n <slot name=\"top-right\"></slot>\n </div>\n </div>\n\n <div :class=\"{ 'tw-flex tw-flex-col tw-gap-y-6 tw-h-full tw-mb-6': slots['default'] }\">\n <!-- @slot Default slot, for rendering card subcomponents -->\n <slot></slot>\n </div>\n </article>\n</template>\n"],"names":["slots","useSlots"],"mappings":";;;;;;;;;;iBAeQA,IAAQC;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Card.js","sources":["../src/components/Card/Card.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { useSlots } from 'vue';\n\n export interface CardProps {\n /**\n * Detach the actions from the top of the card, making them absolute-positioned.\n * @default false\n */\n detachActions?: boolean;\n }\n\n const props = withDefaults(defineProps<CardProps>(), {\n detachActions: false,\n });\n\n const slots = useSlots();\n</script>\n\n<template>\n <article\n class=\"stash-card tw-border tw-rounded tw-shadow-md tw-inline-block tw-relative tw-bg-white\"\n data-test=\"stash-card\"\n >\n <div\n v-if=\"slots['top-left'] || slots['top-right']\"\n data-test=\"card-actions\"\n :class=\"{ 'tw-absolute tw-top-0 tw-w-full': props.detachActions }\"\n class=\"tw-flex tw-justify-between tw-items-start tw-flex-wrap tw-p-6\"\n >\n <div>\n <!-- @slot Top left actions slot, for rendering content on the card top-left -->\n <slot name=\"top-left\"></slot>\n </div>\n <div>\n <!-- @slot Top right actions slot, for rendering content on the card top-right -->\n <slot name=\"top-right\"></slot>\n </div>\n </div>\n\n <div :class=\"{ 'tw-flex tw-flex-col tw-gap-y-6 tw-h-full tw-mb-6': slots['default'] }\">\n <!-- @slot Default slot, for rendering card subcomponents -->\n <slot></slot>\n </div>\n </article>\n</template>\n"],"names":["slots","useSlots"],"mappings":";;;;;;;;;;iBAeQA,IAAQC;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/Dropdown.js CHANGED
@@ -1,10 +1,10 @@
1
- import { defineComponent as z, ref as u, useCssModule as I, watch as C, onMounted as q, onBeforeUnmount as K, computed as U, withDirectives as _, openBlock as v, createElementBlock as k, renderSlot as x, createElementVNode as E, normalizeClass as b, createTextVNode as V, toDisplayString as W, createVNode as S, createBlock as Y, Transition as F, withCtx as j, unref as M, normalizeStyle as G, vShow as H, nextTick as A } from "vue";
1
+ import { defineComponent as R, ref as u, useCssModule as z, watch as C, onMounted as I, onBeforeUnmount as q, computed as K, withDirectives as _, openBlock as p, createElementBlock as k, renderSlot as x, createElementVNode as E, normalizeClass as b, createTextVNode as U, toDisplayString as V, createVNode as S, createBlock as W, Transition as Y, withCtx as F, unref as M, normalizeStyle as j, vShow as G, nextTick as A } from "vue";
2
2
  import { KEY_CODES as d } from "./constants.js";
3
- import J from "./clickoutside.js";
4
- import Q from "./utils/calculateElementOverflow.js";
5
- import { getMountPoint as X } from "./utils/helpers.js";
3
+ import H from "./clickoutside.js";
4
+ import J from "./utils/calculateElementOverflow.js";
5
+ import { getMountPoint as Q } from "./utils/helpers.js";
6
6
  import B from "./Icon.js";
7
- import { _ as Z } from "./_plugin-vue_export-helper-dad06003.js";
7
+ import { _ as X } from "./_plugin-vue_export-helper-dad06003.js";
8
8
  import "./capitalize-667d9f60.js";
9
9
  import "./toString-7d5bf363.js";
10
10
  import "./isObjectLike-54341556.js";
@@ -17,10 +17,10 @@ import "./_overArg-6d920d99.js";
17
17
  import "./Icon.vue_used_vue_type_style_index_0_lang.module-d2507af3.js";
18
18
  import "./uniqueId-847efe53.js";
19
19
  import "./index-79ce320f.js";
20
- const ee = ["aria-expanded"], te = {
20
+ const Z = ["aria-expanded"], ee = {
21
21
  key: 0,
22
22
  class: "tw-font-medium tw-flex tw-items-center tw-text-blue hover:tw-text-blue-700"
23
- }, oe = /* @__PURE__ */ z({
23
+ }, te = /* @__PURE__ */ R({
24
24
  name: "ll-dropdown",
25
25
  __name: "Dropdown",
26
26
  props: {
@@ -33,105 +33,105 @@ const ee = ["aria-expanded"], te = {
33
33
  fluidContent: { type: Boolean, default: !1 }
34
34
  },
35
35
  emits: ["toggle", "dismiss"],
36
- setup(D, { expose: $, emit: m }) {
37
- const n = D, t = u(null), w = u(null), f = [], a = u(f), s = u(-1), o = u(!1), g = u({}), L = I();
36
+ setup(D, { expose: $, emit: v }) {
37
+ const a = D, t = u(null), w = u(null), f = [], s = u(f), i = u(-1), o = u(!1), g = u({}), L = z();
38
38
  C(o, (e) => {
39
- e || (s.value = -1), m("toggle", e);
40
- }), C(s, (e, l) => {
41
- e in a.value && a.value[e].classList.add("is-highlighted"), l in a.value && a.value[l].classList.remove("is-highlighted");
42
- }), q(() => {
43
- var e, l, r;
44
- if (n.reattach) {
45
- const c = X();
39
+ e || (i.value = -1), v("toggle", e);
40
+ }), C(i, (e, l) => {
41
+ e in s.value && s.value[e].classList.add("is-highlighted"), l in s.value && s.value[l].classList.remove("is-highlighted");
42
+ }), I(() => {
43
+ var e, l, n;
44
+ if (a.reattach) {
45
+ const c = Q();
46
46
  t.value && c.appendChild(t.value);
47
47
  }
48
- (e = t.value) != null && e.querySelector(".stash-menu") ? a.value = ((l = t.value) == null ? void 0 : l.querySelectorAll(".stash-menu-item")) ?? f : a.value = ((r = t.value) == null ? void 0 : r.querySelectorAll(".dropdown__item")) ?? f, window.addEventListener("resize", i);
49
- }), K(() => {
48
+ (e = t.value) != null && e.querySelector(".stash-menu") ? s.value = ((l = t.value) == null ? void 0 : l.querySelectorAll(".stash-menu-item")) ?? f : s.value = ((n = t.value) == null ? void 0 : n.querySelectorAll(".dropdown__item")) ?? f, window.addEventListener("resize", r);
49
+ }), q(() => {
50
50
  var e, l;
51
- window.removeEventListener("resize", i), (l = (e = t.value) == null ? void 0 : e.parentNode) == null || l.removeChild(t.value);
51
+ window.removeEventListener("resize", r), (l = (e = t.value) == null ? void 0 : e.parentNode) == null || l.removeChild(t.value);
52
52
  });
53
- function i() {
54
- const e = o.value;
55
- o.value = !1, e && m("dismiss");
53
+ function r(e) {
54
+ var n;
55
+ if (a.closeManually && ((n = t.value) != null && n.contains(e == null ? void 0 : e.target) || t.value === (e == null ? void 0 : e.target)))
56
+ return;
57
+ const l = o.value;
58
+ o.value = !1, l && v("dismiss");
56
59
  }
57
- async function p() {
60
+ async function m() {
58
61
  var e;
59
- o.value ? o.value = !1 : (o.value = !0, await P(), (e = t.value) == null || e.focus());
62
+ o.value ? o.value = !1 : (o.value = !0, await O(), (e = t.value) == null || e.focus());
60
63
  }
61
64
  function T(e) {
62
- n.closeManually && e.stopPropagation();
63
- }
64
- function N(e) {
65
65
  if (e.keyCode === d.ESCAPE)
66
- i();
67
- else if (e.keyCode === d.DOWN && s.value < a.value.length - 1)
68
- o.value && s.value++;
69
- else if (e.keyCode === d.UP && s.value > -1)
70
- o.value && s.value--;
71
- else if (e.keyCode === d.ENTER && s.value !== -1)
72
- o.value && a[s.value].click();
66
+ r();
67
+ else if (e.keyCode === d.DOWN && i.value < s.value.length - 1)
68
+ o.value && i.value++;
69
+ else if (e.keyCode === d.UP && i.value > -1)
70
+ o.value && i.value--;
71
+ else if (e.keyCode === d.ENTER && i.value !== -1)
72
+ o.value && s[i.value].click();
73
73
  else
74
74
  return;
75
75
  e.preventDefault();
76
76
  }
77
- function O() {
77
+ function N() {
78
78
  var e;
79
79
  (e = t.value) == null || e.style.setProperty("--offset", "0");
80
80
  }
81
- async function P() {
81
+ async function O() {
82
82
  var h, y;
83
83
  await A();
84
- const e = ((h = w.value) == null ? void 0 : h.getBoundingClientRect()) || {}, l = e.top + e.height, r = {
84
+ const e = ((h = w.value) == null ? void 0 : h.getBoundingClientRect()) || {}, l = e.top + e.height, n = {
85
85
  x: 0,
86
86
  y: 0,
87
- ...n.offset
87
+ ...a.offset
88
88
  };
89
- n.reattach && (g.value = {
90
- left: n.align === "left" ? `${Math.round(e.left) + r.x}px` : void 0,
91
- right: n.align === "right" ? `${document.documentElement.clientWidth - Math.round(e.right) + r.x}px` : void 0,
92
- top: `${window.scrollY + l + r.y}px`
89
+ a.reattach && (g.value = {
90
+ left: a.align === "left" ? `${Math.round(e.left) + n.x}px` : void 0,
91
+ right: a.align === "right" ? `${document.documentElement.clientWidth - Math.round(e.right) + n.x}px` : void 0,
92
+ top: `${window.scrollY + l + n.y}px`
93
93
  }, await A());
94
- const c = Q(t == null ? void 0 : t.value);
94
+ const c = J(t == null ? void 0 : t.value);
95
95
  if (c) {
96
- const R = n.align === "left" ? "-" : "";
97
- (y = t.value) == null || y.style.setProperty("--offset", `${R}${c.value}`);
96
+ const P = a.align === "left" ? "-" : "";
97
+ (y = t.value) == null || y.style.setProperty("--offset", `${P}${c.value}`);
98
98
  }
99
99
  }
100
100
  return $({
101
- isActive: U(() => o.value),
102
- toggle: p,
103
- dismiss: i
104
- }), (e, l) => _((v(), k("div", {
101
+ isActive: K(() => o.value),
102
+ toggle: m,
103
+ dismiss: r
104
+ }), (e, l) => _((p(), k("div", {
105
105
  ref_key: "dropdownRef",
106
106
  ref: w,
107
107
  class: "tw-inline-block tw-relative",
108
108
  "data-test": "ll-dropdown",
109
- onKeydown: N
109
+ onKeydown: T
110
110
  }, [
111
111
  x(e.$slots, "toggle", {
112
112
  isActive: o.value,
113
- toggle: p
113
+ toggle: m
114
114
  }, () => [
115
115
  E("button", {
116
116
  "data-test": "button|toggle",
117
117
  "aria-expanded": o.value,
118
118
  class: b([e.label ? "button--tertiary tw-outline-none tw-min-w-auto" : "button--icon button tw-rounded"]),
119
- onClick: p
119
+ onClick: m
120
120
  }, [
121
- e.label ? (v(), k("span", te, [
122
- V(W(e.label) + " ", 1),
121
+ e.label ? (p(), k("span", ee, [
122
+ U(V(e.label) + " ", 1),
123
123
  S(B, { name: "caret-down" })
124
- ])) : (v(), Y(B, {
124
+ ])) : (p(), W(B, {
125
125
  key: 1,
126
126
  name: "ellipsis"
127
127
  }))
128
- ], 10, ee)
128
+ ], 10, Z)
129
129
  ]),
130
- S(F, {
130
+ S(Y, {
131
131
  name: "fade",
132
- onAfterLeave: O
132
+ onAfterLeave: N
133
133
  }, {
134
- default: j(() => [
134
+ default: F(() => [
135
135
  _(E("div", {
136
136
  ref_key: "contentRef",
137
137
  ref: t,
@@ -140,34 +140,33 @@ const ee = ["aria-expanded"], te = {
140
140
  M(L).content,
141
141
  e.contentClass,
142
142
  {
143
- "tw-left-0 after:tw-left-6": n.align === "left",
144
- "tw-right-0": n.align === "right",
145
- "tw-max-w-[360px]": !n.fluidContent
143
+ "tw-left-0 after:tw-left-6": a.align === "left",
144
+ "tw-right-0": a.align === "right",
145
+ "tw-max-w-[360px]": !a.fluidContent
146
146
  }
147
147
  ]),
148
- style: G(g.value),
149
- onClick: T
148
+ style: j(g.value)
150
149
  }, [
151
150
  x(e.$slots, "default", {
152
- dismiss: i,
151
+ dismiss: r,
153
152
  isActive: o.value
154
153
  })
155
154
  ], 6), [
156
- [H, o.value]
155
+ [G, o.value]
157
156
  ])
158
157
  ]),
159
158
  _: 3
160
159
  })
161
160
  ], 32)), [
162
- [M(J), i]
161
+ [M(H), r]
163
162
  ]);
164
163
  }
165
- }), le = "_content_naa5r_2", ne = {
166
- content: le
164
+ }), oe = "_content_naa5r_2", le = {
165
+ content: oe
167
166
  }, ae = {
168
- $style: ne
169
- }, be = /* @__PURE__ */ Z(oe, [["__cssModules", ae]]);
167
+ $style: le
168
+ }, Ee = /* @__PURE__ */ X(te, [["__cssModules", ae]]);
170
169
  export {
171
- be as default
170
+ Ee as default
172
171
  };
173
172
  //# sourceMappingURL=Dropdown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.js","sources":["../src/components/Dropdown/Dropdown.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, nextTick, onBeforeUnmount, onMounted, ref, useCssModule, watch } from 'vue';\n\n import { KEY_CODES } from '../../constants';\n import vClickoutside from '../../directives/clickoutside/clickoutside';\n import calculateElementOverflow from '../../utils/calculateElementOverflow';\n import { getMountPoint } from '../../utils/helpers';\n import Icon from '../Icon/Icon.vue';\n\n export type DropdownOffset = {\n x?: number;\n y?: number;\n };\n\n export interface DropdownProps {\n /**\n * Used to position the dropdown relative to target\n * Options: left, right\n */\n align?: 'left' | 'right';\n /**\n * When passed, text with caret is displayed instead of default kebab menu.\n */\n label?: string;\n /**\n * If true, dropdown will remain open when clicking on its content. Otherwise, it'll close automatically on click.\n */\n closeManually?: boolean;\n /**\n * Used to horizontally and vertically offset the dropdown in pixels\n * Keep in mind, `x` value is relative to `align` value.\n */\n offset?: DropdownOffset;\n /**\n * If `reattach` is true, the contents will be mounted in the mount point container,\n * so as to circumvent clipping issues from a parent's overflow property.\n */\n reattach?: boolean;\n /**\n * Custom class to apply to the default dropdown content element\n */\n contentClass?: string | string[];\n /**\n * Removes content container's max width\n */\n fluidContent?: boolean;\n }\n\n type DropdownStyles = {\n left?: string;\n right?: string;\n top?: string;\n };\n\n defineOptions({\n name: 'll-dropdown',\n });\n\n const props = withDefaults(defineProps<DropdownProps>(), {\n align: 'right',\n label: '',\n closeManually: false,\n offset: () => ({}),\n reattach: true,\n contentClass: '',\n fluidContent: false,\n });\n\n const emit =\n defineEmits<{\n toggle: [isActive: boolean];\n dismiss: [];\n }>();\n\n const contentRef = ref<HTMLElement | null>(null);\n const dropdownRef = ref<HTMLDivElement | null>(null);\n\n const DEFAULT_ITEMS_LIST = [] as unknown as NodeListOf<Element>;\n\n const items = ref<NodeListOf<Element>>(DEFAULT_ITEMS_LIST);\n const itemIndex = ref(-1);\n const isActive = ref(false);\n\n const styles = ref<DropdownStyles>({});\n const classes = useCssModule();\n\n watch(isActive, (val) => {\n if (!val) {\n itemIndex.value = -1;\n }\n\n emit('toggle', val);\n });\n\n watch(itemIndex, (next, prev) => {\n next in items.value && items.value[next].classList.add('is-highlighted');\n prev in items.value && items.value[prev].classList.remove('is-highlighted');\n });\n\n onMounted(() => {\n if (props.reattach) {\n const target = getMountPoint();\n\n contentRef.value && target.appendChild(contentRef.value);\n }\n\n // if stash-menu exists, use it's items\n if (contentRef.value?.querySelector('.stash-menu')) {\n items.value = contentRef.value?.querySelectorAll('.stash-menu-item') ?? DEFAULT_ITEMS_LIST;\n } else {\n items.value = contentRef.value?.querySelectorAll('.dropdown__item') ?? DEFAULT_ITEMS_LIST;\n }\n\n window.addEventListener('resize', dismiss);\n });\n\n onBeforeUnmount(() => {\n window.removeEventListener('resize', dismiss);\n contentRef.value?.parentNode?.removeChild(contentRef.value);\n });\n\n /**\n * Dismisses the Dropdown.\n */\n function dismiss() {\n const wasOpen = isActive.value;\n\n isActive.value = false;\n\n if (wasOpen) {\n emit('dismiss');\n }\n }\n\n /**\n * Opens or closes the Dropdown. If opening, positions and focuses its content.\n */\n async function toggle() {\n if (isActive.value) {\n isActive.value = false;\n } else {\n isActive.value = true;\n await calculateOffset();\n contentRef.value?.focus();\n }\n }\n\n /**\n * Prevent the dropdown from closing if a user interacts with a UI item\n * within the dropdown `content`. By default, the dropdown will close\n * after a user clicks something within.\n * @param {Event} e The click event.\n */\n function stop(e: Event) {\n props.closeManually && e.stopPropagation();\n }\n\n /**\n * Handles all user keyboard input on the Dropdown.\n * @param {KeyboardEvent} e The native keydown event.\n */\n function onKeyDown(e: KeyboardEvent) {\n if (e.keyCode === KEY_CODES.ESCAPE) {\n dismiss();\n } else if (e.keyCode === KEY_CODES.DOWN && itemIndex.value < items.value.length - 1) {\n isActive.value && itemIndex.value++;\n } else if (e.keyCode === KEY_CODES.UP && itemIndex.value > -1) {\n isActive.value && itemIndex.value--;\n } else if (e.keyCode === KEY_CODES.ENTER && itemIndex.value !== -1) {\n isActive.value && items[itemIndex.value].click();\n } else {\n return;\n }\n\n e.preventDefault(); // if keyDown did something / we didn't return\n }\n\n /**\n * Reset any page overflow offset\n */\n function resetOffset() {\n contentRef.value?.style.setProperty('--offset', '0');\n }\n\n /**\n * Calculate the position for the Dropdown content element,\n * relative to the viewport.\n * Repositions the dropdown content element (& arrow)\n * if it overflows the page (including gutter).\n */\n async function calculateOffset() {\n await nextTick();\n\n const toggleBCR = dropdownRef.value?.getBoundingClientRect() || ({} as DOMRect);\n const top = toggleBCR.top + toggleBCR.height;\n const offset = {\n x: 0,\n y: 0,\n ...props.offset,\n };\n\n if (props.reattach) {\n styles.value = {\n left: props.align === 'left' ? `${Math.round(toggleBCR.left) + offset.x}px` : undefined,\n right:\n props.align === 'right'\n ? `${document.documentElement.clientWidth - Math.round(toggleBCR.right) + offset.x}px`\n : undefined,\n top: `${window.scrollY + top + offset.y}px`,\n };\n await nextTick(); // wait for style updates to sync in the DOM\n }\n\n const overflow = calculateElementOverflow(contentRef?.value);\n\n if (overflow) {\n const direction = props.align === 'left' ? '-' : '';\n contentRef.value?.style.setProperty('--offset', `${direction}${overflow.value}`);\n }\n }\n\n defineExpose({\n isActive: computed(() => isActive.value),\n toggle,\n dismiss,\n });\n</script>\n\n<template>\n <div\n ref=\"dropdownRef\"\n v-clickoutside=\"dismiss\"\n class=\"tw-inline-block tw-relative\"\n data-test=\"ll-dropdown\"\n @keydown=\"onKeyDown\"\n >\n <!-- @slot Toggle component slot, receives `toggle` method to trigger Dropdown display -->\n <slot name=\"toggle\" :is-active=\"isActive\" :toggle=\"toggle\">\n <button\n data-test=\"button|toggle\"\n :aria-expanded=\"isActive\"\n :class=\"[label ? 'button--tertiary tw-outline-none tw-min-w-auto' : 'button--icon button tw-rounded']\"\n @click=\"toggle\"\n >\n <span v-if=\"label\" class=\"tw-font-medium tw-flex tw-items-center tw-text-blue hover:tw-text-blue-700\">\n {{ label }}\n <Icon name=\"caret-down\" />\n </span>\n <Icon v-else name=\"ellipsis\" />\n </button>\n </slot>\n\n <transition name=\"fade\" @after-leave=\"resetOffset\">\n <div\n v-show=\"isActive\"\n ref=\"contentRef\"\n data-test=\"ll-dropdown-content\"\n :class=\"[\n classes.content,\n contentClass,\n {\n 'tw-left-0 after:tw-left-6': props.align === 'left',\n 'tw-right-0': props.align === 'right',\n 'tw-max-w-[360px]': !props.fluidContent,\n },\n ]\"\n :style=\"styles\"\n @click=\"stop\"\n >\n <!-- @slot Dropdown content slot. Receives `dismiss` method, to trigger manual close. Receives `is-active` prop. -->\n <slot :dismiss=\"dismiss\" :is-active=\"isActive\"></slot>\n </div>\n </transition>\n </div>\n</template>\n\n<style module>\n .content {\n --offset: 0;\n\n @apply tw-shadow\n tw-bg-white\n tw-border\n tw-border-solid\n tw-border-blue\n tw-rounded\n tw-absolute\n tw-z-control\n tw-min-w-[200px];\n\n transform: translateX(calc(var(--offset) * 1px));\n }\n\n /**\n * TODO: these global styles should be componentized in https://leaflink.atlassian.net/browse/STASH-566\n */\n :global(.dropdown__list) {\n @apply tw-bg-white tw-list-none tw-m-1.5 tw-p-0;\n }\n\n :global(.dropdown__item) {\n @apply tw-block tw-mx-0 tw-mt-0 tw-mb-1.5 tw-w-full first:tw-mt-0 last:tw-mb-0;\n }\n\n :global(.dropdown__item) button {\n @apply tw-border-none tw-text-left tw-p-1.5;\n }\n\n :global(.dropdown__item) :where(a, button) {\n @apply tw-rounded\n tw-text-ice-700\n tw-block\n tw-py-[10px]\n tw-px-1.5\n tw-w-full\n disabled:tw-text-ice\n disabled:tw-cursor-default\n hover:tw-bg-ice-200\n hover:tw-text-ice-700\n hover:tw-no-underline\n tw-transition-all\n tw-duration-fast\n tw-ease-swing;\n }\n</style>\n"],"names":["contentRef","ref","dropdownRef","DEFAULT_ITEMS_LIST","items","itemIndex","isActive","styles","classes","useCssModule","watch","val","emit","next","prev","onMounted","props","target","getMountPoint","_a","_b","_c","dismiss","onBeforeUnmount","wasOpen","toggle","calculateOffset","stop","onKeyDown","KEY_CODES","resetOffset","nextTick","toggleBCR","top","offset","overflow","calculateElementOverflow","direction","__expose","computed"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0EQA,IAAaC,EAAwB,IAAI,GACzCC,IAAcD,EAA2B,IAAI,GAE7CE,IAAqB,CAAA,GAErBC,IAAQH,EAAyBE,CAAkB,GACnDE,IAAYJ,EAAI,EAAE,GAClBK,IAAWL,EAAI,EAAK,GAEpBM,IAASN,EAAoB,CAAA,CAAE,GAC/BO,IAAUC;AAEV,IAAAC,EAAAJ,GAAU,CAACK,MAAQ;AACvB,MAAKA,MACHN,EAAU,QAAQ,KAGpBO,EAAK,UAAUD,CAAG;AAAA,IAAA,CACnB,GAEKD,EAAAL,GAAW,CAACQ,GAAMC,MAAS;AACvB,MAAAD,KAAAT,EAAM,SAASA,EAAM,MAAMS,CAAI,EAAE,UAAU,IAAI,gBAAgB,GAC/DC,K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;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Dropdown.js","sources":["../src/components/Dropdown/Dropdown.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, nextTick, onBeforeUnmount, onMounted, ref, useCssModule, watch } from 'vue';\n\n import { KEY_CODES } from '../../constants';\n import vClickoutside from '../../directives/clickoutside/clickoutside';\n import calculateElementOverflow from '../../utils/calculateElementOverflow';\n import { getMountPoint } from '../../utils/helpers';\n import Icon from '../Icon/Icon.vue';\n\n export type DropdownOffset = {\n x?: number;\n y?: number;\n };\n\n export interface DropdownProps {\n /**\n * Used to position the dropdown relative to target\n * Options: left, right\n */\n align?: 'left' | 'right';\n /**\n * When passed, text with caret is displayed instead of default kebab menu.\n */\n label?: string;\n /**\n * If true, dropdown will remain open when clicking on its content. Otherwise, it'll close automatically on click.\n */\n closeManually?: boolean;\n /**\n * Used to horizontally and vertically offset the dropdown in pixels\n * Keep in mind, `x` value is relative to `align` value.\n */\n offset?: DropdownOffset;\n /**\n * If `reattach` is true, the contents will be mounted in the mount point container,\n * so as to circumvent clipping issues from a parent's overflow property.\n */\n reattach?: boolean;\n /**\n * Custom class to apply to the default dropdown content element\n */\n contentClass?: string | string[];\n /**\n * Removes content container's max width\n */\n fluidContent?: boolean;\n }\n\n type DropdownStyles = {\n left?: string;\n right?: string;\n top?: string;\n };\n\n defineOptions({\n name: 'll-dropdown',\n });\n\n const props = withDefaults(defineProps<DropdownProps>(), {\n align: 'right',\n label: '',\n closeManually: false,\n offset: () => ({}),\n reattach: true,\n contentClass: '',\n fluidContent: false,\n });\n\n const emit =\n defineEmits<{\n toggle: [isActive: boolean];\n dismiss: [];\n }>();\n\n const contentRef = ref<HTMLElement | null>(null);\n const dropdownRef = ref<HTMLDivElement | null>(null);\n\n const DEFAULT_ITEMS_LIST = [] as unknown as NodeListOf<Element>;\n\n const items = ref<NodeListOf<Element>>(DEFAULT_ITEMS_LIST);\n const itemIndex = ref(-1);\n const isActive = ref(false);\n\n const styles = ref<DropdownStyles>({});\n const classes = useCssModule();\n\n watch(isActive, (val) => {\n if (!val) {\n itemIndex.value = -1;\n }\n\n emit('toggle', val);\n });\n\n watch(itemIndex, (next, prev) => {\n next in items.value && items.value[next].classList.add('is-highlighted');\n prev in items.value && items.value[prev].classList.remove('is-highlighted');\n });\n\n onMounted(() => {\n if (props.reattach) {\n const target = getMountPoint();\n\n contentRef.value && target.appendChild(contentRef.value);\n }\n\n // if stash-menu exists, use it's items\n if (contentRef.value?.querySelector('.stash-menu')) {\n items.value = contentRef.value?.querySelectorAll('.stash-menu-item') ?? DEFAULT_ITEMS_LIST;\n } else {\n items.value = contentRef.value?.querySelectorAll('.dropdown__item') ?? DEFAULT_ITEMS_LIST;\n }\n\n window.addEventListener('resize', dismiss);\n });\n\n onBeforeUnmount(() => {\n window.removeEventListener('resize', dismiss);\n contentRef.value?.parentNode?.removeChild(contentRef.value);\n });\n\n /**\n * Dismisses the Dropdown.\n */\n function dismiss(event?: Event) {\n if (\n props.closeManually &&\n (contentRef.value?.contains(event?.target as HTMLElement) || contentRef.value === event?.target)\n ) {\n return;\n }\n\n const wasOpen = isActive.value;\n\n isActive.value = false;\n\n if (wasOpen) {\n emit('dismiss');\n }\n }\n\n /**\n * Opens or closes the Dropdown. If opening, positions and focuses its content.\n */\n async function toggle() {\n if (isActive.value) {\n isActive.value = false;\n } else {\n isActive.value = true;\n await calculateOffset();\n contentRef.value?.focus();\n }\n }\n\n /**\n * Handles all user keyboard input on the Dropdown.\n * @param {KeyboardEvent} e The native keydown event.\n */\n function onKeyDown(e: KeyboardEvent) {\n if (e.keyCode === KEY_CODES.ESCAPE) {\n dismiss();\n } else if (e.keyCode === KEY_CODES.DOWN && itemIndex.value < items.value.length - 1) {\n isActive.value && itemIndex.value++;\n } else if (e.keyCode === KEY_CODES.UP && itemIndex.value > -1) {\n isActive.value && itemIndex.value--;\n } else if (e.keyCode === KEY_CODES.ENTER && itemIndex.value !== -1) {\n isActive.value && items[itemIndex.value].click();\n } else {\n return;\n }\n\n e.preventDefault(); // if keyDown did something / we didn't return\n }\n\n /**\n * Reset any page overflow offset\n */\n function resetOffset() {\n contentRef.value?.style.setProperty('--offset', '0');\n }\n\n /**\n * Calculate the position for the Dropdown content element,\n * relative to the viewport.\n * Repositions the dropdown content element (& arrow)\n * if it overflows the page (including gutter).\n */\n async function calculateOffset() {\n await nextTick();\n\n const toggleBCR = dropdownRef.value?.getBoundingClientRect() || ({} as DOMRect);\n const top = toggleBCR.top + toggleBCR.height;\n const offset = {\n x: 0,\n y: 0,\n ...props.offset,\n };\n\n if (props.reattach) {\n styles.value = {\n left: props.align === 'left' ? `${Math.round(toggleBCR.left) + offset.x}px` : undefined,\n right:\n props.align === 'right'\n ? `${document.documentElement.clientWidth - Math.round(toggleBCR.right) + offset.x}px`\n : undefined,\n top: `${window.scrollY + top + offset.y}px`,\n };\n await nextTick(); // wait for style updates to sync in the DOM\n }\n\n const overflow = calculateElementOverflow(contentRef?.value);\n\n if (overflow) {\n const direction = props.align === 'left' ? '-' : '';\n contentRef.value?.style.setProperty('--offset', `${direction}${overflow.value}`);\n }\n }\n\n defineExpose({\n isActive: computed(() => isActive.value),\n toggle,\n dismiss,\n });\n</script>\n\n<template>\n <div\n ref=\"dropdownRef\"\n v-clickoutside=\"dismiss\"\n class=\"tw-inline-block tw-relative\"\n data-test=\"ll-dropdown\"\n @keydown=\"onKeyDown\"\n >\n <!-- @slot Toggle component slot, receives `toggle` method to trigger Dropdown display -->\n <slot name=\"toggle\" :is-active=\"isActive\" :toggle=\"toggle\">\n <button\n data-test=\"button|toggle\"\n :aria-expanded=\"isActive\"\n :class=\"[label ? 'button--tertiary tw-outline-none tw-min-w-auto' : 'button--icon button tw-rounded']\"\n @click=\"toggle\"\n >\n <span v-if=\"label\" class=\"tw-font-medium tw-flex tw-items-center tw-text-blue hover:tw-text-blue-700\">\n {{ label }}\n <Icon name=\"caret-down\" />\n </span>\n <Icon v-else name=\"ellipsis\" />\n </button>\n </slot>\n\n <transition name=\"fade\" @after-leave=\"resetOffset\">\n <div\n v-show=\"isActive\"\n ref=\"contentRef\"\n data-test=\"ll-dropdown-content\"\n :class=\"[\n classes.content,\n contentClass,\n {\n 'tw-left-0 after:tw-left-6': props.align === 'left',\n 'tw-right-0': props.align === 'right',\n 'tw-max-w-[360px]': !props.fluidContent,\n },\n ]\"\n :style=\"styles\"\n >\n <!-- @slot Dropdown content slot. Receives `dismiss` method, to trigger manual close. You must call dismiss with parentheses. Receives `is-active` prop. -->\n <slot :dismiss=\"dismiss\" :is-active=\"isActive\"></slot>\n </div>\n </transition>\n </div>\n</template>\n\n<style module>\n .content {\n --offset: 0;\n\n @apply tw-shadow\n tw-bg-white\n tw-border\n tw-border-solid\n tw-border-blue\n tw-rounded\n tw-absolute\n tw-z-control\n tw-min-w-[200px];\n\n transform: translateX(calc(var(--offset) * 1px));\n }\n\n /**\n * TODO: these global styles should be componentized in https://leaflink.atlassian.net/browse/STASH-566\n */\n :global(.dropdown__list) {\n @apply tw-bg-white tw-list-none tw-m-1.5 tw-p-0;\n }\n\n :global(.dropdown__item) {\n @apply tw-block tw-mx-0 tw-mt-0 tw-mb-1.5 tw-w-full first:tw-mt-0 last:tw-mb-0;\n }\n\n :global(.dropdown__item) button {\n @apply tw-border-none tw-text-left tw-p-1.5;\n }\n\n :global(.dropdown__item) :where(a, button) {\n @apply tw-rounded\n tw-text-ice-700\n tw-block\n tw-py-[10px]\n tw-px-1.5\n tw-w-full\n disabled:tw-text-ice\n disabled:tw-cursor-default\n hover:tw-bg-ice-200\n hover:tw-text-ice-700\n hover:tw-no-underline\n tw-transition-all\n tw-duration-fast\n tw-ease-swing;\n }\n</style>\n"],"names":["contentRef","ref","dropdownRef","DEFAULT_ITEMS_LIST","items","itemIndex","isActive","styles","classes","useCssModule","watch","val","emit","next","prev","onMounted","props","target","getMountPoint","_a","_b","_c","dismiss","onBeforeUnmount","event","wasOpen","toggle","calculateOffset","onKeyDown","KEY_CODES","resetOffset","nextTick","toggleBC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,CAAC,OAAO;AAAA,QAC9E,OACElB,EAAM,UAAU,UACZ,GAAG,SAAS,gBAAgB,cAAc,KAAK,MAAMgB,EAAU,KAAK,IAAIE,EAAO,CAAC,OAChF;AAAA,QACN,KAAK,GAAG,OAAO,UAAUD,IAAMC,EAAO,CAAC;AAAA,MAAA,GAEzC,MAAMH,EAAS;AAGX,YAAAI,IAAWC,EAAyBpC,KAAA,gBAAAA,EAAY,KAAK;AAE3D,UAAImC,GAAU;AACZ,cAAME,IAAYrB,EAAM,UAAU,SAAS,MAAM;AACtC,SAAAI,IAAApB,EAAA,UAAA,QAAAoB,EAAO,MAAM,YAAY,YAAY,GAAGiB,CAAS,GAAGF,EAAS,KAAK;AAAA,MAC/E;AAAA,IACF;AAEa,WAAAG,EAAA;AAAA,MACX,UAAUC,EAAS,MAAMjC,EAAS,KAAK;AAAA,MACvC,QAAAoB;AAAA,MACA,SAAAJ;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -83,7 +83,7 @@ export default _default;
83
83
  /**
84
84
  * Dismisses the Dropdown.
85
85
  */
86
- declare function dismiss(): void;
86
+ declare function dismiss(event?: Event): void;
87
87
 
88
88
  export declare type DropdownOffset = {
89
89
  x?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflink/stash",
3
- "version": "41.7.0",
3
+ "version": "42.1.0",
4
4
  "description": "LeafLink's design system.",
5
5
  "homepage": "https://stash.leaflink.com",
6
6
  "main": "./dist/index.ts",