admins-components 9.0.42 → 9.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,39 +1,55 @@
1
- import { onBeforeUnmount as e, onMounted as t, ref as n, watch as r } from "vue";
1
+ import { nextTick as e, onBeforeUnmount as t, onMounted as n, ref as r, watch as i } from "vue";
2
2
  //#region src/composables/useDropdownAnchor.ts
3
- function i(e, t, n) {
3
+ function a(e, t, n) {
4
4
  let r = e.target, i = t?.contains(r) ?? !1, a = n?.contains(r) ?? !1;
5
5
  return !i && !a;
6
6
  }
7
- function a(a, o, s = {}) {
8
- let { extraStyle: c, isOutsideClick: l = i } = s, u = n(!1), d = n({});
9
- function f() {
10
- if (!a.value) return;
11
- let e = a.value.getBoundingClientRect();
12
- d.value = {
7
+ function o(o, s, c = {}) {
8
+ let { extraStyle: l, isOutsideClick: u = a, closeOnScroll: d = !1 } = c, f = r(!1), p = r({});
9
+ function m() {
10
+ if (!o.value) return;
11
+ let t = o.value.getBoundingClientRect();
12
+ p.value = {
13
13
  position: "fixed",
14
- top: `${e.bottom + 2}px`,
15
- left: `${e.left}px`,
14
+ top: `${t.bottom + 2}px`,
15
+ left: `${t.left}px`,
16
16
  zIndex: "10001",
17
- ...c ? c(e) : {}
18
- };
17
+ ...l ? l(t) : {}
18
+ }, e(() => {
19
+ if (!s.value || !o.value) return;
20
+ let e = s.value.getBoundingClientRect(), t = o.value.getBoundingClientRect(), n = window.innerHeight, r = window.innerWidth, i = e.bottom > n, a = e.right > r, c = i ? `${t.top - e.height - 2}px` : `${t.bottom + 2}px`, u = a ? `${t.right - e.width}px` : `${t.left}px`;
21
+ (i || a) && (p.value = {
22
+ position: "fixed",
23
+ top: c,
24
+ left: u,
25
+ zIndex: "10001",
26
+ ...l ? l(t) : {}
27
+ });
28
+ });
19
29
  }
20
- function p(e) {
21
- l(e, a.value, o.value) && (u.value = !1);
30
+ function h(e) {
31
+ u(e, o.value, s.value) && (f.value = !1);
22
32
  }
23
- function m() {
24
- u.value && f();
33
+ function g() {
34
+ if (f.value) {
35
+ if (d) {
36
+ f.value = !1;
37
+ return;
38
+ }
39
+ m();
40
+ }
25
41
  }
26
- return r(u, (e) => {
27
- e && f();
42
+ return i(f, (e) => {
43
+ e && m();
44
+ }), n(() => {
45
+ document.addEventListener("mousedown", h), window.addEventListener("scroll", g, !0), window.addEventListener("resize", g);
28
46
  }), t(() => {
29
- document.addEventListener("mousedown", p), window.addEventListener("scroll", m, !0), window.addEventListener("resize", m);
30
- }), e(() => {
31
- document.removeEventListener("mousedown", p), window.removeEventListener("scroll", m, !0), window.removeEventListener("resize", m);
47
+ document.removeEventListener("mousedown", h), window.removeEventListener("scroll", g, !0), window.removeEventListener("resize", g);
32
48
  }), {
33
- isOpen: u,
34
- dropdownStyle: d,
35
- positionDropdown: f
49
+ isOpen: f,
50
+ dropdownStyle: p,
51
+ positionDropdown: m
36
52
  };
37
53
  }
38
54
  //#endregion
39
- export { a as useDropdownAnchor };
55
+ export { o as useDropdownAnchor };
@@ -1 +1 @@
1
- {"version":3,"file":"admins-components12.js","names":[],"sources":["../src/composables/useDropdownAnchor.ts"],"sourcesContent":["import { ref, watch, onMounted, onBeforeUnmount } from 'vue'\nimport type { Ref } from 'vue'\n\nexport interface UseDropdownAnchorOptions {\n extraStyle?: (rect: DOMRect) => Record<string, string>\n isOutsideClick?: (\n e: MouseEvent,\n wrapperEl: HTMLElement | null,\n dropdownEl: HTMLElement | null,\n ) => boolean\n}\n\nexport interface UseDropdownAnchorReturn {\n isOpen: Ref<boolean>\n dropdownStyle: Ref<Record<string, string>>\n positionDropdown: () => void\n}\n\nfunction defaultIsOutsideClick(\n e: MouseEvent,\n wrapperEl: HTMLElement | null,\n dropdownEl: HTMLElement | null,\n): boolean {\n const target = e.target as Node\n const inWrapper = wrapperEl?.contains(target) ?? false\n const inDropdown = dropdownEl?.contains(target) ?? false\n return !inWrapper && !inDropdown\n}\n\nexport function useDropdownAnchor(\n wrapperRef: Ref<HTMLElement | null>,\n dropdownRef: Ref<HTMLElement | null>,\n options: UseDropdownAnchorOptions = {},\n): UseDropdownAnchorReturn {\n const { extraStyle, isOutsideClick = defaultIsOutsideClick } = options\n\n const isOpen = ref(false)\n const dropdownStyle = ref<Record<string, string>>({})\n\n function positionDropdown() {\n if (!wrapperRef.value) return\n const rect = wrapperRef.value.getBoundingClientRect()\n dropdownStyle.value = {\n position: 'fixed',\n top: `${rect.bottom + 2}px`,\n left: `${rect.left}px`,\n zIndex: '10001',\n ...(extraStyle ? extraStyle(rect) : {}),\n }\n }\n\n function onClickOutside(e: MouseEvent) {\n if (isOutsideClick(e, wrapperRef.value, dropdownRef.value)) {\n isOpen.value = false\n }\n }\n\n function onScrollOrResize() {\n if (isOpen.value) positionDropdown()\n }\n\n watch(isOpen, (open) => {\n if (open) positionDropdown()\n })\n\n onMounted(() => {\n document.addEventListener('mousedown', onClickOutside)\n\n window.addEventListener('scroll', onScrollOrResize, true)\n window.addEventListener('resize', onScrollOrResize)\n })\n\n onBeforeUnmount(() => {\n document.removeEventListener('mousedown', onClickOutside)\n\n window.removeEventListener('scroll', onScrollOrResize, true)\n window.removeEventListener('resize', onScrollOrResize)\n })\n\n return { isOpen, dropdownStyle, positionDropdown }\n}\n"],"mappings":";;AAkBA,SAAS,EACP,GACA,GACA,GACS;CACT,IAAM,IAAS,EAAE,QACX,IAAY,GAAW,SAAS,CAAM,KAAK,IAC3C,IAAa,GAAY,SAAS,CAAM,KAAK;CACnD,OAAO,CAAC,KAAa,CAAC;AACxB;AAEA,SAAgB,EACd,GACA,GACA,IAAoC,CAAC,GACZ;CACzB,IAAM,EAAE,eAAY,oBAAiB,MAA0B,GAEzD,IAAS,EAAI,EAAK,GAClB,IAAgB,EAA4B,CAAC,CAAC;CAEpD,SAAS,IAAmB;EAC1B,IAAI,CAAC,EAAW,OAAO;EACvB,IAAM,IAAO,EAAW,MAAM,sBAAsB;EACpD,EAAc,QAAQ;GACpB,UAAU;GACV,KAAK,GAAG,EAAK,SAAS,EAAE;GACxB,MAAM,GAAG,EAAK,KAAK;GACnB,QAAQ;GACR,GAAI,IAAa,EAAW,CAAI,IAAI,CAAC;EACvC;CACF;CAEA,SAAS,EAAe,GAAe;EACrC,AAAI,EAAe,GAAG,EAAW,OAAO,EAAY,KAAK,MACvD,EAAO,QAAQ;CAEnB;CAEA,SAAS,IAAmB;EAC1B,AAAI,EAAO,SAAO,EAAiB;CACrC;CAoBA,OAlBA,EAAM,IAAS,MAAS;EACtB,AAAI,KAAM,EAAiB;CAC7B,CAAC,GAED,QAAgB;EAId,AAHA,SAAS,iBAAiB,aAAa,CAAc,GAErD,OAAO,iBAAiB,UAAU,GAAkB,EAAI,GACxD,OAAO,iBAAiB,UAAU,CAAgB;CACpD,CAAC,GAED,QAAsB;EAIpB,AAHA,SAAS,oBAAoB,aAAa,CAAc,GAExD,OAAO,oBAAoB,UAAU,GAAkB,EAAI,GAC3D,OAAO,oBAAoB,UAAU,CAAgB;CACvD,CAAC,GAEM;EAAE;EAAQ;EAAe;CAAiB;AACnD"}
1
+ {"version":3,"file":"admins-components12.js","names":[],"sources":["../src/composables/useDropdownAnchor.ts"],"sourcesContent":["import { ref, watch, onMounted, onBeforeUnmount, nextTick } from 'vue'\nimport type { Ref } from 'vue'\n\nexport interface UseDropdownAnchorOptions {\n extraStyle?: (rect: DOMRect) => Record<string, string>\n isOutsideClick?: (\n e: MouseEvent,\n wrapperEl: HTMLElement | null,\n dropdownEl: HTMLElement | null,\n ) => boolean\n closeOnScroll?: boolean\n}\n\nexport interface UseDropdownAnchorReturn {\n isOpen: Ref<boolean>\n dropdownStyle: Ref<Record<string, string>>\n positionDropdown: () => void\n}\n\nfunction defaultIsOutsideClick(\n e: MouseEvent,\n wrapperEl: HTMLElement | null,\n dropdownEl: HTMLElement | null,\n): boolean {\n const target = e.target as Node\n const inWrapper = wrapperEl?.contains(target) ?? false\n const inDropdown = dropdownEl?.contains(target) ?? false\n return !inWrapper && !inDropdown\n}\n\nexport function useDropdownAnchor(\n wrapperRef: Ref<HTMLElement | null>,\n dropdownRef: Ref<HTMLElement | null>,\n options: UseDropdownAnchorOptions = {},\n): UseDropdownAnchorReturn {\n const { extraStyle, isOutsideClick = defaultIsOutsideClick, closeOnScroll = false } = options\n\n const isOpen = ref(false)\n const dropdownStyle = ref<Record<string, string>>({})\n\n function positionDropdown() {\n if (!wrapperRef.value) return\n const rect = wrapperRef.value.getBoundingClientRect()\n dropdownStyle.value = {\n position: 'fixed',\n top: `${rect.bottom + 2}px`,\n left: `${rect.left}px`,\n zIndex: '10001',\n ...(extraStyle ? extraStyle(rect) : {}),\n }\n nextTick(() => {\n if (!dropdownRef.value || !wrapperRef.value) return\n const dropdownRect = dropdownRef.value.getBoundingClientRect()\n const anchorRect = wrapperRef.value.getBoundingClientRect()\n const viewportHeight = window.innerHeight\n const viewportWidth = window.innerWidth\n\n const flipY = dropdownRect.bottom > viewportHeight\n const flipX = dropdownRect.right > viewportWidth\n\n const top = flipY\n ? `${anchorRect.top - dropdownRect.height - 2}px`\n : `${anchorRect.bottom + 2}px`\n const left = flipX\n ? `${anchorRect.right - dropdownRect.width}px`\n : `${anchorRect.left}px`\n\n if (flipY || flipX) {\n dropdownStyle.value = {\n position: 'fixed',\n top,\n left,\n zIndex: '10001',\n ...(extraStyle ? extraStyle(anchorRect) : {}),\n }\n }\n })\n }\n\n function onClickOutside(e: MouseEvent) {\n if (isOutsideClick(e, wrapperRef.value, dropdownRef.value)) {\n isOpen.value = false\n }\n }\n\n function onScrollOrResize() {\n if (!isOpen.value) return\n if (closeOnScroll) {\n isOpen.value = false\n return\n }\n positionDropdown()\n }\n\n watch(isOpen, (open) => {\n if (open) positionDropdown()\n })\n\n onMounted(() => {\n document.addEventListener('mousedown', onClickOutside)\n\n window.addEventListener('scroll', onScrollOrResize, true)\n window.addEventListener('resize', onScrollOrResize)\n })\n\n onBeforeUnmount(() => {\n document.removeEventListener('mousedown', onClickOutside)\n\n window.removeEventListener('scroll', onScrollOrResize, true)\n window.removeEventListener('resize', onScrollOrResize)\n })\n\n return { isOpen, dropdownStyle, positionDropdown }\n}\n"],"mappings":";;AAmBA,SAAS,EACP,GACA,GACA,GACS;CACT,IAAM,IAAS,EAAE,QACX,IAAY,GAAW,SAAS,CAAM,KAAK,IAC3C,IAAa,GAAY,SAAS,CAAM,KAAK;CACnD,OAAO,CAAC,KAAa,CAAC;AACxB;AAEA,SAAgB,EACd,GACA,GACA,IAAoC,CAAC,GACZ;CACzB,IAAM,EAAE,eAAY,oBAAiB,GAAuB,mBAAgB,OAAU,GAEhF,IAAS,EAAI,EAAK,GAClB,IAAgB,EAA4B,CAAC,CAAC;CAEpD,SAAS,IAAmB;EAC1B,IAAI,CAAC,EAAW,OAAO;EACvB,IAAM,IAAO,EAAW,MAAM,sBAAsB;EAQpD,AAPA,EAAc,QAAQ;GACpB,UAAU;GACV,KAAK,GAAG,EAAK,SAAS,EAAE;GACxB,MAAM,GAAG,EAAK,KAAK;GACnB,QAAQ;GACR,GAAI,IAAa,EAAW,CAAI,IAAI,CAAC;EACvC,GACA,QAAe;GACb,IAAI,CAAC,EAAY,SAAS,CAAC,EAAW,OAAO;GAC7C,IAAM,IAAe,EAAY,MAAM,sBAAsB,GACvD,IAAa,EAAW,MAAM,sBAAsB,GACpD,IAAiB,OAAO,aACxB,IAAgB,OAAO,YAEvB,IAAQ,EAAa,SAAS,GAC9B,IAAQ,EAAa,QAAQ,GAE7B,IAAM,IACR,GAAG,EAAW,MAAM,EAAa,SAAS,EAAE,MAC5C,GAAG,EAAW,SAAS,EAAE,KACvB,IAAO,IACT,GAAG,EAAW,QAAQ,EAAa,MAAM,MACzC,GAAG,EAAW,KAAK;GAEvB,CAAI,KAAS,OACX,EAAc,QAAQ;IACpB,UAAU;IACV;IACA;IACA,QAAQ;IACR,GAAI,IAAa,EAAW,CAAU,IAAI,CAAC;GAC7C;EAEJ,CAAC;CACH;CAEA,SAAS,EAAe,GAAe;EACrC,AAAI,EAAe,GAAG,EAAW,OAAO,EAAY,KAAK,MACvD,EAAO,QAAQ;CAEnB;CAEA,SAAS,IAAmB;EACrB,MAAO,OACZ;OAAI,GAAe;IACjB,EAAO,QAAQ;IACf;GACF;GACA,EAAiB;EADjB;CAEF;CAoBA,OAlBA,EAAM,IAAS,MAAS;EACtB,AAAI,KAAM,EAAiB;CAC7B,CAAC,GAED,QAAgB;EAId,AAHA,SAAS,iBAAiB,aAAa,CAAc,GAErD,OAAO,iBAAiB,UAAU,GAAkB,EAAI,GACxD,OAAO,iBAAiB,UAAU,CAAgB;CACpD,CAAC,GAED,QAAsB;EAIpB,AAHA,SAAS,oBAAoB,aAAa,CAAc,GAExD,OAAO,oBAAoB,UAAU,GAAkB,EAAI,GAC3D,OAAO,oBAAoB,UAAU,CAAgB;CACvD,CAAC,GAEM;EAAE;EAAQ;EAAe;CAAiB;AACnD"}
@@ -21,10 +21,13 @@ var g = { class: "ac-component" }, _ = ["aria-label"], v = { class: "ac-componen
21
21
  }
22
22
  },
23
23
  setup(c) {
24
- let x = c, S = f(null), C = f(null), { isOpen: w, dropdownStyle: T } = t(S, C, { extraStyle: (e) => ({
25
- minWidth: `${e.width}px`,
26
- maxWidth: `${e.width * 2}px`
27
- }) });
24
+ let x = c, S = f(null), C = f(null), { isOpen: w, dropdownStyle: T } = t(S, C, {
25
+ extraStyle: (e) => ({
26
+ minWidth: `${e.width}px`,
27
+ maxWidth: `${e.width * 2}px`
28
+ }),
29
+ closeOnScroll: !0
30
+ });
28
31
  function E() {
29
32
  w.value = !w.value;
30
33
  }
@@ -64,7 +67,8 @@ var g = { class: "ac-component" }, _ = ["aria-label"], v = { class: "ac-componen
64
67
  key: `cb-${n}`,
65
68
  class: l(["d-option dm-option c-field-size c-type-color", {
66
69
  [`c-field-size--${h(e)(t.size)}`]: t.size,
67
- [`c-type-color--${t.type}`]: t.type
70
+ [`c-type-color--${t.type}`]: t.type,
71
+ "is-disabled": t.disabled?.()
68
72
  }]),
69
73
  tabindex: "0",
70
74
  onClick: (e) => D(t),
@@ -1 +1 @@
1
- {"version":3,"file":"admins-components29.js","names":[],"sources":["../src/components/DropdownMenu.vue"],"sourcesContent":["<script lang=\"ts\">\nexport interface DropdownMenuItem {\n icon?: string\n label: string\n type?: ButtonType\n size?: ControlSize\n ariaLabel?: string\n callback: () => void\n disabled?: () => boolean\n}\n\nexport interface DropdownMenuProps {\n size?: ControlSize\n icon?: string\n label?: string\n ariaLabel?: string\n textEllipsis?: boolean\n type?: ButtonType\n items: DropdownMenuItem[]\n labelAlignmentFix?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { ref } from 'vue'\nimport type { ControlSize } from '@/types/types'\nimport type { ButtonType } from '@/components/Button.vue'\nimport { useDropdownAnchor } from '@/composables/useDropdownAnchor'\nimport { sizeToClass } from '@/utils/dom'\n\nconst props = withDefaults(defineProps<DropdownMenuProps>(), {\n size: 'normal',\n type: 'normal',\n textEllipsis: true,\n icon: undefined,\n label: undefined,\n labelAlignmentFix: false,\n})\n\nconst wrapperRef = ref<HTMLElement | null>(null)\nconst dropdownRef = ref<HTMLElement | null>(null)\nconst { isOpen, dropdownStyle } = useDropdownAnchor(wrapperRef, dropdownRef, {\n extraStyle: (rect) => ({\n minWidth: `${rect.width}px`,\n maxWidth: `${rect.width * 2}px`,\n }),\n})\n\nfunction toggleOpen() {\n isOpen.value = !isOpen.value\n}\n\nfunction selectItem(item: DropdownMenuItem) {\n item.callback?.()\n isOpen.value = false\n}\n</script>\n\n<template>\n <div class=\"ac-component\">\n <div ref=\"wrapperRef\" class=\"ds-wrapper d-inline-block\">\n <button\n type=\"button\"\n class=\"c-btn dm-trigger\"\n :class=\"[\n size === 'small' && 'c-btn-sm',\n size === 'large' && 'c-btn-lg',\n type !== 'normal' && `c-btn-${type}`,\n ]\"\n :aria-label=\"ariaLabel ?? label\"\n @click=\"toggleOpen()\"\n >\n <i v-if=\"icon\" class=\"fa-fw\" :class=\"icon\"></i>\n <span v-if=\"label\" :class=\"{ 'align-center-fix ': props.labelAlignmentFix }\">{{\n label\n }}</span>\n\n <span\n class=\"c-icon-btn c-icon-btn--chevron\"\n :class=\"{ 'c-icon-btn--chevron-open': isOpen }\"\n >\n <i class=\"fa-solid fa-fw fa-chevron-down\"></i>\n </span>\n </button>\n\n <Teleport to=\"body\">\n <div class=\"ac-component\">\n <div v-if=\"isOpen\" ref=\"dropdownRef\" class=\"c-dropdown ds-wrapper\" :style=\"dropdownStyle\">\n <ul class=\"ds-options c-scroll\">\n <li\n v-for=\"(item, idx) in items\"\n :key=\"`cb-${idx}`\"\n class=\"d-option dm-option c-field-size c-type-color\"\n :class=\"{\n [`c-field-size--${sizeToClass(item.size)}`]: item.size,\n [`c-type-color--${item.type}`]: item.type,\n }\"\n tabindex=\"0\"\n @click=\"selectItem(item)\"\n :aria-label=\"item.ariaLabel ?? item.label\"\n >\n <i v-if=\"item.icon\" class=\"fa-fw\" :class=\"item.icon\"></i>\n <span class=\"d-option__label\" :class=\"{ 'c-truncate': props.textEllipsis }\">{{\n item.label\n }}</span>\n </li>\n </ul>\n </div>\n </div>\n </Teleport>\n </div>\n </div>\n</template>\n<style lang=\"scss\" src=\"@/styles/components/dropdown-select.scss\"></style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EA8BA,IAAM,IAAQ,GASR,IAAa,EAAwB,IAAI,GACzC,IAAc,EAAwB,IAAI,GAC1C,EAAE,WAAQ,qBAAkB,EAAkB,GAAY,GAAa,EAC3E,aAAa,OAAU;GACrB,UAAU,GAAG,EAAK,MAAM;GACxB,UAAU,GAAG,EAAK,QAAQ,EAAE;EAC9B,GACF,CAAC;EAED,SAAS,IAAa;GACpB,EAAO,QAAQ,CAAC,EAAO;EACzB;EAEA,SAAS,EAAW,GAAwB;GAE1C,AADA,EAAK,WAAW,GAChB,EAAO,QAAQ;EACjB;yBAIE,EAoDM,OApDN,GAoDM,CAnDJ,EAkDM,OAAA;YAlDG;GAAJ,KAAI;GAAa,OAAM;MAC1B,EAsBS,UAAA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AArC,OAAK,EAAA,CAAC,SAAgB,EAAK,IAAI,CAAA;4BACnD,EAES,QAAA,EAFH,OAAK,EAAA,CAAC,mBAAiB,EAAA,cAAyB,EAAM,aAAY,CAAA,CAAA,EAAA,GAAA,EACtE,EAAK,KAAK,GAAA,CAAA,CAAA,GAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"admins-components29.js","names":[],"sources":["../src/components/DropdownMenu.vue"],"sourcesContent":["<script lang=\"ts\">\nexport interface DropdownMenuItem {\n icon?: string\n label: string\n type?: ButtonType\n size?: ControlSize\n ariaLabel?: string\n callback: () => void\n disabled?: () => boolean\n}\n\nexport interface DropdownMenuProps {\n size?: ControlSize\n icon?: string\n label?: string\n ariaLabel?: string\n textEllipsis?: boolean\n type?: ButtonType\n items: DropdownMenuItem[]\n labelAlignmentFix?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { ref } from 'vue'\nimport type { ControlSize } from '@/types/types'\nimport type { ButtonType } from '@/components/Button.vue'\nimport { useDropdownAnchor } from '@/composables/useDropdownAnchor'\nimport { sizeToClass } from '@/utils/dom'\n\nconst props = withDefaults(defineProps<DropdownMenuProps>(), {\n size: 'normal',\n type: 'normal',\n textEllipsis: true,\n icon: undefined,\n label: undefined,\n labelAlignmentFix: false,\n})\n\nconst wrapperRef = ref<HTMLElement | null>(null)\nconst dropdownRef = ref<HTMLElement | null>(null)\nconst { isOpen, dropdownStyle } = useDropdownAnchor(wrapperRef, dropdownRef, {\n extraStyle: (rect) => ({\n minWidth: `${rect.width}px`,\n maxWidth: `${rect.width * 2}px`,\n }),\n closeOnScroll: true,\n})\n\nfunction toggleOpen() {\n isOpen.value = !isOpen.value\n}\n\nfunction selectItem(item: DropdownMenuItem) {\n item.callback?.()\n isOpen.value = false\n}\n</script>\n\n<template>\n <div class=\"ac-component\">\n <div ref=\"wrapperRef\" class=\"ds-wrapper d-inline-block\">\n <button\n type=\"button\"\n class=\"c-btn dm-trigger\"\n :class=\"[\n size === 'small' && 'c-btn-sm',\n size === 'large' && 'c-btn-lg',\n type !== 'normal' && `c-btn-${type}`,\n ]\"\n :aria-label=\"ariaLabel ?? label\"\n @click=\"toggleOpen()\"\n >\n <i v-if=\"icon\" class=\"fa-fw\" :class=\"icon\"></i>\n <span v-if=\"label\" :class=\"{ 'align-center-fix ': props.labelAlignmentFix }\">{{\n label\n }}</span>\n\n <span\n class=\"c-icon-btn c-icon-btn--chevron\"\n :class=\"{ 'c-icon-btn--chevron-open': isOpen }\"\n >\n <i class=\"fa-solid fa-fw fa-chevron-down\"></i>\n </span>\n </button>\n\n <Teleport to=\"body\">\n <div class=\"ac-component\">\n <div v-if=\"isOpen\" ref=\"dropdownRef\" class=\"c-dropdown ds-wrapper\" :style=\"dropdownStyle\">\n <ul class=\"ds-options c-scroll\">\n <li\n v-for=\"(item, idx) in items\"\n :key=\"`cb-${idx}`\"\n class=\"d-option dm-option c-field-size c-type-color\"\n :class=\"{\n [`c-field-size--${sizeToClass(item.size)}`]: item.size,\n [`c-type-color--${item.type}`]: item.type,\n 'is-disabled': item.disabled?.(),\n }\"\n tabindex=\"0\"\n @click=\"selectItem(item)\"\n :aria-label=\"item.ariaLabel ?? item.label\"\n >\n <i v-if=\"item.icon\" class=\"fa-fw\" :class=\"item.icon\"></i>\n <span class=\"d-option__label\" :class=\"{ 'c-truncate': props.textEllipsis }\">{{\n item.label\n }}</span>\n </li>\n </ul>\n </div>\n </div>\n </Teleport>\n </div>\n </div>\n</template>\n<style lang=\"scss\" src=\"@/styles/components/dropdown-select.scss\"></style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EA8BA,IAAM,IAAQ,GASR,IAAa,EAAwB,IAAI,GACzC,IAAc,EAAwB,IAAI,GAC1C,EAAE,WAAQ,qBAAkB,EAAkB,GAAY,GAAa;GAC3E,aAAa,OAAU;IACrB,UAAU,GAAG,EAAK,MAAM;IACxB,UAAU,GAAG,EAAK,QAAQ,EAAE;GAC9B;GACA,eAAe;EACjB,CAAC;EAED,SAA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,OAAK,EAAA,CAAC,gDAA8C;sBACN,EAAA,CAAA,EAAY,EAAK,IAAI,MAAM,EAAK;sBAA0C,EAAK,SAAS,EAAK;mBAAuC,EAAK,WAAQ;;GAK/L,UAAS;GACR,UAAK,MAAE,EAAW,CAAI;GACtB,cAAY,EAAK,aAAa,EAAK;MAE3B,EAAK,QAAA,EAAA,GAAd,EAAyD,KAAA;;GAArC,OAAK,EAAA,CAAC,SAAgB,EAAK,IAAI,CAAA;4BACnD,EAES,QAAA,EAFH,OAAK,EAAA,CAAC,mBAAiB,EAAA,cAAyB,EAAM,aAAY,CAAA,CAAA,EAAA,GAAA,EACtE,EAAK,KAAK,GAAA,CAAA,CAAA,GAAA,IAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"admins-components30.js","names":[],"sources":["../src/components/DropdownMenu.vue"],"sourcesContent":["<script lang=\"ts\">\nexport interface DropdownMenuItem {\n icon?: string\n label: string\n type?: ButtonType\n size?: ControlSize\n ariaLabel?: string\n callback: () => void\n disabled?: () => boolean\n}\n\nexport interface DropdownMenuProps {\n size?: ControlSize\n icon?: string\n label?: string\n ariaLabel?: string\n textEllipsis?: boolean\n type?: ButtonType\n items: DropdownMenuItem[]\n labelAlignmentFix?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { ref } from 'vue'\nimport type { ControlSize } from '@/types/types'\nimport type { ButtonType } from '@/components/Button.vue'\nimport { useDropdownAnchor } from '@/composables/useDropdownAnchor'\nimport { sizeToClass } from '@/utils/dom'\n\nconst props = withDefaults(defineProps<DropdownMenuProps>(), {\n size: 'normal',\n type: 'normal',\n textEllipsis: true,\n icon: undefined,\n label: undefined,\n labelAlignmentFix: false,\n})\n\nconst wrapperRef = ref<HTMLElement | null>(null)\nconst dropdownRef = ref<HTMLElement | null>(null)\nconst { isOpen, dropdownStyle } = useDropdownAnchor(wrapperRef, dropdownRef, {\n extraStyle: (rect) => ({\n minWidth: `${rect.width}px`,\n maxWidth: `${rect.width * 2}px`,\n }),\n})\n\nfunction toggleOpen() {\n isOpen.value = !isOpen.value\n}\n\nfunction selectItem(item: DropdownMenuItem) {\n item.callback?.()\n isOpen.value = false\n}\n</script>\n\n<template>\n <div class=\"ac-component\">\n <div ref=\"wrapperRef\" class=\"ds-wrapper d-inline-block\">\n <button\n type=\"button\"\n class=\"c-btn dm-trigger\"\n :class=\"[\n size === 'small' && 'c-btn-sm',\n size === 'large' && 'c-btn-lg',\n type !== 'normal' && `c-btn-${type}`,\n ]\"\n :aria-label=\"ariaLabel ?? label\"\n @click=\"toggleOpen()\"\n >\n <i v-if=\"icon\" class=\"fa-fw\" :class=\"icon\"></i>\n <span v-if=\"label\" :class=\"{ 'align-center-fix ': props.labelAlignmentFix }\">{{\n label\n }}</span>\n\n <span\n class=\"c-icon-btn c-icon-btn--chevron\"\n :class=\"{ 'c-icon-btn--chevron-open': isOpen }\"\n >\n <i class=\"fa-solid fa-fw fa-chevron-down\"></i>\n </span>\n </button>\n\n <Teleport to=\"body\">\n <div class=\"ac-component\">\n <div v-if=\"isOpen\" ref=\"dropdownRef\" class=\"c-dropdown ds-wrapper\" :style=\"dropdownStyle\">\n <ul class=\"ds-options c-scroll\">\n <li\n v-for=\"(item, idx) in items\"\n :key=\"`cb-${idx}`\"\n class=\"d-option dm-option c-field-size c-type-color\"\n :class=\"{\n [`c-field-size--${sizeToClass(item.size)}`]: item.size,\n [`c-type-color--${item.type}`]: item.type,\n }\"\n tabindex=\"0\"\n @click=\"selectItem(item)\"\n :aria-label=\"item.ariaLabel ?? item.label\"\n >\n <i v-if=\"item.icon\" class=\"fa-fw\" :class=\"item.icon\"></i>\n <span class=\"d-option__label\" :class=\"{ 'c-truncate': props.textEllipsis }\">{{\n item.label\n }}</span>\n </li>\n </ul>\n </div>\n </div>\n </Teleport>\n </div>\n </div>\n</template>\n<style lang=\"scss\" src=\"@/styles/components/dropdown-select.scss\"></style>\n"],"mappings":""}
1
+ {"version":3,"file":"admins-components30.js","names":[],"sources":["../src/components/DropdownMenu.vue"],"sourcesContent":["<script lang=\"ts\">\nexport interface DropdownMenuItem {\n icon?: string\n label: string\n type?: ButtonType\n size?: ControlSize\n ariaLabel?: string\n callback: () => void\n disabled?: () => boolean\n}\n\nexport interface DropdownMenuProps {\n size?: ControlSize\n icon?: string\n label?: string\n ariaLabel?: string\n textEllipsis?: boolean\n type?: ButtonType\n items: DropdownMenuItem[]\n labelAlignmentFix?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { ref } from 'vue'\nimport type { ControlSize } from '@/types/types'\nimport type { ButtonType } from '@/components/Button.vue'\nimport { useDropdownAnchor } from '@/composables/useDropdownAnchor'\nimport { sizeToClass } from '@/utils/dom'\n\nconst props = withDefaults(defineProps<DropdownMenuProps>(), {\n size: 'normal',\n type: 'normal',\n textEllipsis: true,\n icon: undefined,\n label: undefined,\n labelAlignmentFix: false,\n})\n\nconst wrapperRef = ref<HTMLElement | null>(null)\nconst dropdownRef = ref<HTMLElement | null>(null)\nconst { isOpen, dropdownStyle } = useDropdownAnchor(wrapperRef, dropdownRef, {\n extraStyle: (rect) => ({\n minWidth: `${rect.width}px`,\n maxWidth: `${rect.width * 2}px`,\n }),\n closeOnScroll: true,\n})\n\nfunction toggleOpen() {\n isOpen.value = !isOpen.value\n}\n\nfunction selectItem(item: DropdownMenuItem) {\n item.callback?.()\n isOpen.value = false\n}\n</script>\n\n<template>\n <div class=\"ac-component\">\n <div ref=\"wrapperRef\" class=\"ds-wrapper d-inline-block\">\n <button\n type=\"button\"\n class=\"c-btn dm-trigger\"\n :class=\"[\n size === 'small' && 'c-btn-sm',\n size === 'large' && 'c-btn-lg',\n type !== 'normal' && `c-btn-${type}`,\n ]\"\n :aria-label=\"ariaLabel ?? label\"\n @click=\"toggleOpen()\"\n >\n <i v-if=\"icon\" class=\"fa-fw\" :class=\"icon\"></i>\n <span v-if=\"label\" :class=\"{ 'align-center-fix ': props.labelAlignmentFix }\">{{\n label\n }}</span>\n\n <span\n class=\"c-icon-btn c-icon-btn--chevron\"\n :class=\"{ 'c-icon-btn--chevron-open': isOpen }\"\n >\n <i class=\"fa-solid fa-fw fa-chevron-down\"></i>\n </span>\n </button>\n\n <Teleport to=\"body\">\n <div class=\"ac-component\">\n <div v-if=\"isOpen\" ref=\"dropdownRef\" class=\"c-dropdown ds-wrapper\" :style=\"dropdownStyle\">\n <ul class=\"ds-options c-scroll\">\n <li\n v-for=\"(item, idx) in items\"\n :key=\"`cb-${idx}`\"\n class=\"d-option dm-option c-field-size c-type-color\"\n :class=\"{\n [`c-field-size--${sizeToClass(item.size)}`]: item.size,\n [`c-type-color--${item.type}`]: item.type,\n 'is-disabled': item.disabled?.(),\n }\"\n tabindex=\"0\"\n @click=\"selectItem(item)\"\n :aria-label=\"item.ariaLabel ?? item.label\"\n >\n <i v-if=\"item.icon\" class=\"fa-fw\" :class=\"item.icon\"></i>\n <span class=\"d-option__label\" :class=\"{ 'c-truncate': props.textEllipsis }\">{{\n item.label\n }}</span>\n </li>\n </ul>\n </div>\n </div>\n </Teleport>\n </div>\n </div>\n</template>\n<style lang=\"scss\" src=\"@/styles/components/dropdown-select.scss\"></style>\n"],"mappings":""}
@@ -2,6 +2,7 @@ import { Ref } from 'vue';
2
2
  export interface UseDropdownAnchorOptions {
3
3
  extraStyle?: (rect: DOMRect) => Record<string, string>;
4
4
  isOutsideClick?: (e: MouseEvent, wrapperEl: HTMLElement | null, dropdownEl: HTMLElement | null) => boolean;
5
+ closeOnScroll?: boolean;
5
6
  }
6
7
  export interface UseDropdownAnchorReturn {
7
8
  isOpen: Ref<boolean>;
@@ -1 +1 @@
1
- .ac-component .ds-wrapper{--ds-field-padding:.375rem .5rem}.ac-component .ds-wrapper .ds-value{padding:var(--ac-input-padding);font-size:inherit;color:var(--neutral-900);flex:1;padding-right:.125rem}.ac-component .ds-wrapper .c-input-row--sm .ds-value{padding:var(--ac-input-padding-sm);padding-right:.125rem}.ac-component .ds-wrapper .c-input-row--lg .ds-value{padding:var(--ac-input-padding-lg);padding-right:.125rem}.ac-component .ds-wrapper .ds-dropdown{right:0}.ac-component .ds-wrapper .ds-filter{padding:var(--ac-field-padding);border-bottom:1px solid var(--neutral-100);align-items:center;gap:.5rem;display:flex;position:relative}.ac-component .ds-wrapper .ds-dropdown--multiple .ds-filter,.ac-component .ds-wrapper .ds-dropdown--multiple .ds-option{padding:var(--ds-field-padding)}.ac-component .ds-wrapper .ds-select-all-checkbox{flex-shrink:0}.ac-component .ds-wrapper .ds-filter-input{border:1px solid var(--neutral-200);width:100%;color:var(--neutral-900);border-radius:.375rem;outline:none;padding:.375rem 1.5rem .375rem .5rem;font-family:inherit;font-size:.8125rem}.ac-component .ds-wrapper .ds-filter-input::placeholder{color:var(--ac-placeholder-color)}.ac-component .ds-wrapper .ds-clear-btn{padding:0 .125rem 0 0}.ac-component .ds-wrapper .ds-filter-clear{padding:0;position:absolute;top:50%;right:1.375rem;transform:translateY(-50%)}.ac-component .ds-wrapper .ds-options{max-height:var(--ac-dropdown-max-height,18rem);margin:0;padding:.25rem 0;list-style:none;overflow-y:auto}.ac-component .ds-wrapper .ds-options .ds-option--loading{min-height:calc(var(--ac-dropdown-max-height,18rem) / 1.75);pointer-events:none;justify-content:center;align-items:center;display:flex}.ac-component .ds-wrapper .d-option{cursor:pointer;align-items:center;gap:.5rem;transition:background-color .1s;display:flex}.ac-component .ds-wrapper .d-option__label{flex:1}.ac-component .ds-wrapper .dm-option{align-items:center;gap:.375em;display:flex}.ac-component .ds-wrapper .dm-trigger .c-icon-btn--chevron{color:inherit}.ac-component .ds-wrapper .ds-option{padding:var(--ac-field-padding);color:var(--neutral-800);font-size:.875rem}.ac-component .ds-wrapper .ds-option:hover{background:var(--neutral-50)}.ac-component .ds-wrapper .ds-option__highlight{background:rgba(var(--ac-color-primary-rgb), .1);color:var(--neutral-900);border-radius:.125rem}.ac-component .ds-wrapper .ds-option--selected{background:var(--neutral-100);font-weight:500}.ac-component .ds-wrapper .ds-option--empty{color:var(--neutral-400);cursor:default;font-style:italic}.ac-component .ds-wrapper .ds-option--empty:hover{background:0 0}
1
+ .ac-component .ds-wrapper{--ds-field-padding:.375rem .5rem}.ac-component .ds-wrapper .ds-value{padding:var(--ac-input-padding);font-size:inherit;color:var(--neutral-900);flex:1;padding-right:.125rem}.ac-component .ds-wrapper .c-input-row--sm .ds-value{padding:var(--ac-input-padding-sm);padding-right:.125rem}.ac-component .ds-wrapper .c-input-row--lg .ds-value{padding:var(--ac-input-padding-lg);padding-right:.125rem}.ac-component .ds-wrapper .ds-dropdown{right:0}.ac-component .ds-wrapper .ds-filter{padding:var(--ac-field-padding);border-bottom:1px solid var(--neutral-100);align-items:center;gap:.5rem;display:flex;position:relative}.ac-component .ds-wrapper .ds-dropdown--multiple .ds-filter,.ac-component .ds-wrapper .ds-dropdown--multiple .ds-option{padding:var(--ds-field-padding)}.ac-component .ds-wrapper .ds-select-all-checkbox{flex-shrink:0}.ac-component .ds-wrapper .ds-filter-input{border:1px solid var(--neutral-200);width:100%;color:var(--neutral-900);border-radius:.375rem;outline:none;padding:.375rem 1.5rem .375rem .5rem;font-family:inherit;font-size:.8125rem}.ac-component .ds-wrapper .ds-filter-input::placeholder{color:var(--ac-placeholder-color)}.ac-component .ds-wrapper .ds-clear-btn{padding:0 .125rem 0 0}.ac-component .ds-wrapper .ds-filter-clear{padding:0;position:absolute;top:50%;right:1.375rem;transform:translateY(-50%)}.ac-component .ds-wrapper .ds-options{max-height:var(--ac-dropdown-max-height,18rem);margin:0;padding:.25rem 0;list-style:none;overflow-y:auto}.ac-component .ds-wrapper .ds-options .ds-option--loading{min-height:calc(var(--ac-dropdown-max-height,18rem) / 1.75);pointer-events:none;justify-content:center;align-items:center;display:flex}.ac-component .ds-wrapper .d-option{cursor:pointer;align-items:center;gap:.5rem;transition:background-color .1s;display:flex}.ac-component .ds-wrapper .d-option__label{flex:1}.ac-component .ds-wrapper .dm-option{align-items:center;gap:.375em;display:flex}.ac-component .ds-wrapper .dm-option.is-disabled{opacity:.7;pointer-events:none}.ac-component .ds-wrapper .dm-trigger .c-icon-btn--chevron{color:inherit}.ac-component .ds-wrapper .ds-option{padding:var(--ac-field-padding);color:var(--neutral-800);font-size:.875rem}.ac-component .ds-wrapper .ds-option:hover{background:var(--neutral-50)}.ac-component .ds-wrapper .ds-option__highlight{background:rgba(var(--ac-color-primary-rgb), .1);color:var(--neutral-900);border-radius:.125rem}.ac-component .ds-wrapper .ds-option--selected{background:var(--neutral-100);font-weight:500}.ac-component .ds-wrapper .ds-option--empty{color:var(--neutral-400);cursor:default;font-style:italic}.ac-component .ds-wrapper .ds-option--empty:hover{background:0 0}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "admins-components",
3
- "version": "9.0.42",
3
+ "version": "9.0.43",
4
4
  "type": "module",
5
5
  "module": "./dist/admins-components.js",
6
6
  "types": "./dist/index.d.ts",