@scalar/components 0.23.0 → 0.24.1
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/components/ScalarFloating/ScalarFloating.vue.js.map +1 -1
- package/dist/components/ScalarFloating/ScalarFloating.vue.script.js +4 -4
- package/dist/components/ScalarFloating/ScalarFloating.vue.script.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarNestedItems.vue.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarNestedItems.vue.script.js +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarNestedItems.vue.script.js.map +1 -1
- package/dist/components/ScalarSidebar/useSidebarNestedItems.d.ts +4 -3
- package/dist/components/ScalarSidebar/useSidebarNestedItems.d.ts.map +1 -1
- package/dist/components/ScalarSidebar/useSidebarNestedItems.js +8 -5
- package/dist/components/ScalarSidebar/useSidebarNestedItems.js.map +1 -1
- package/dist/style.css +4 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarFloating.vue.js","names":[],"sources":["../../../src/components/ScalarFloating/ScalarFloating.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Floating component\n *\n * Positions a floating element relative to a reference element\n * using Floating UI. Handles placement, offset, flipping, and resizing.\n *\n * @example\n * <ScalarFloating placement=\"bottom\">\n * <button>Reference</button>\n * <template #floating>Floating content</template>\n * </ScalarFloating>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { getSideAxis } from '@floating-ui/utils'\nimport {\n type MiddlewareData,\n autoUpdate,\n flip,\n offset as offsetMiddleware,\n shift,\n size,\n useFloating,\n} from '@floating-ui/vue'\nimport { type Ref, computed, ref } from 'vue'\n\nimport { ScalarTeleport } from '../ScalarTeleport'\nimport type { FloatingOptions } from './types'\nimport { useResizeWithTarget } from './useResizeWithTarget'\n\nconst {\n placement,\n offset = 5,\n resize = false,\n middleware = [],\n target,\n teleport,\n} = defineProps<FloatingOptions>()\n\ndefineSlots<{\n /** The reference element for the element in the #floating slot */\n default(): unknown\n /** The floating element */\n floating?(props: {\n /** The width of the reference element if `resize` is true and placement is on the y axis */\n width?: string\n /** The height of the reference element if `resize` is true and placement is on the x axis */\n height?: string\n /** The middleware data return by Floating UI */\n data?: MiddlewareData\n }): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst floatingRef: Ref<HTMLElement | null> = ref(null)\nconst wrapperRef: Ref<HTMLElement | null> = ref(null)\n\nconst targetRef = computed<HTMLElement | undefined>(() => {\n if (typeof window !== 'undefined' && wrapperRef.value) {\n // If target is a string (id), try to find it in the document\n if (typeof target === 'string') {\n const t = document.getElementById(target)\n if (t) {\n return t\n }\n console.warn(`ScalarFloating: Target with id=\"${target}\" not found`)\n }\n // If target is an HTMLElement, return it\n else if (target instanceof HTMLElement) {\n return target\n }\n // Fallback to div wrapper if no child element is provided\n const firstChild = wrapperRef.value.children?.[0]\n if (firstChild instanceof HTMLElement) {\n return firstChild\n }\n return wrapperRef.value\n }\n // Return undefined if nothing is found\n return undefined\n})\n\nconst targetSize = useResizeWithTarget(targetRef, {\n enabled: computed(() => resize),\n})\n\nconst targetWidth = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'y'\n ? targetSize.width.value\n : undefined,\n)\n\nconst targetHeight = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'x'\n ? targetSize.height.value\n : undefined,\n)\nconst { floatingStyles, middlewareData } = useFloating(targetRef, floatingRef, {\n placement: computed(() => placement ?? 'bottom'),\n whileElementsMounted: autoUpdate,\n middleware: computed(() => [\n offsetMiddleware(offset),\n flip(),\n shift({ padding:
|
|
1
|
+
{"version":3,"file":"ScalarFloating.vue.js","names":[],"sources":["../../../src/components/ScalarFloating/ScalarFloating.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Floating component\n *\n * Positions a floating element relative to a reference element\n * using Floating UI. Handles placement, offset, flipping, and resizing.\n *\n * @example\n * <ScalarFloating placement=\"bottom\">\n * <button>Reference</button>\n * <template #floating>Floating content</template>\n * </ScalarFloating>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { getSideAxis } from '@floating-ui/utils'\nimport {\n type MiddlewareData,\n autoUpdate,\n flip,\n offset as offsetMiddleware,\n shift,\n size,\n useFloating,\n} from '@floating-ui/vue'\nimport { type Ref, computed, ref } from 'vue'\n\nimport { ScalarTeleport } from '../ScalarTeleport'\nimport type { FloatingOptions } from './types'\nimport { useResizeWithTarget } from './useResizeWithTarget'\n\nconst {\n placement,\n offset = 5,\n resize = false,\n middleware = [],\n target,\n teleport,\n} = defineProps<FloatingOptions>()\n\ndefineSlots<{\n /** The reference element for the element in the #floating slot */\n default(): unknown\n /** The floating element */\n floating?(props: {\n /** The width of the reference element if `resize` is true and placement is on the y axis */\n width?: string\n /** The height of the reference element if `resize` is true and placement is on the x axis */\n height?: string\n /** The middleware data return by Floating UI */\n data?: MiddlewareData\n }): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst floatingRef: Ref<HTMLElement | null> = ref(null)\nconst wrapperRef: Ref<HTMLElement | null> = ref(null)\n\nconst targetRef = computed<HTMLElement | undefined>(() => {\n if (typeof window !== 'undefined' && wrapperRef.value) {\n // If target is a string (id), try to find it in the document\n if (typeof target === 'string') {\n const t = document.getElementById(target)\n if (t) {\n return t\n }\n console.warn(`ScalarFloating: Target with id=\"${target}\" not found`)\n }\n // If target is an HTMLElement, return it\n else if (target instanceof HTMLElement) {\n return target\n }\n // Fallback to div wrapper if no child element is provided\n const firstChild = wrapperRef.value.children?.[0]\n if (firstChild instanceof HTMLElement) {\n return firstChild\n }\n return wrapperRef.value\n }\n // Return undefined if nothing is found\n return undefined\n})\n\nconst targetSize = useResizeWithTarget(targetRef, {\n enabled: computed(() => resize),\n})\n\nconst targetWidth = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'y'\n ? targetSize.width.value\n : undefined,\n)\n\nconst targetHeight = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'x'\n ? targetSize.height.value\n : undefined,\n)\nconst { floatingStyles, middlewareData } = useFloating(targetRef, floatingRef, {\n placement: computed(() => placement ?? 'bottom'),\n whileElementsMounted: autoUpdate,\n middleware: computed(() => [\n offsetMiddleware(offset),\n flip({ padding: 48 }),\n shift({ padding: 8 }),\n size({\n apply({ availableWidth, availableHeight, elements }) {\n // Assign the max width and height to the floating element\n // @see https://floating-ui.com/docs/size\n Object.assign(elements.floating.style, {\n maxWidth: `${Math.max(0, availableWidth) - 16}px`,\n maxHeight: `${Math.max(0, availableHeight) - 16}px`,\n })\n },\n }),\n ...middleware,\n ]),\n})\n\ndefineExpose({\n /** The resolved target element */\n targetRef,\n})\n</script>\n<template>\n <div\n ref=\"wrapperRef\"\n :class=\"{ contents: !!$slots.default }\">\n <slot />\n </div>\n <ScalarTeleport\n v-if=\"$slots.floating\"\n :disabled=\"!teleport\"\n :to=\"typeof teleport === 'string' ? teleport : undefined\">\n <div\n ref=\"floatingRef\"\n class=\"relative z-context\"\n :style=\"floatingStyles\">\n <slot\n :data=\"middlewareData\"\n :height=\"targetHeight\"\n name=\"floating\"\n :width=\"targetWidth\" />\n </div>\n </ScalarTeleport>\n</template>\n"],"mappings":""}
|
|
@@ -47,12 +47,12 @@ var ScalarFloating_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
47
47
|
whileElementsMounted: autoUpdate,
|
|
48
48
|
middleware: computed(() => [
|
|
49
49
|
offset(__props.offset),
|
|
50
|
-
flip(),
|
|
51
|
-
shift({ padding:
|
|
50
|
+
flip({ padding: 48 }),
|
|
51
|
+
shift({ padding: 8 }),
|
|
52
52
|
size({ apply({ availableWidth, availableHeight, elements }) {
|
|
53
53
|
Object.assign(elements.floating.style, {
|
|
54
|
-
maxWidth: `${Math.max(0, availableWidth) -
|
|
55
|
-
maxHeight: `${Math.max(0, availableHeight) -
|
|
54
|
+
maxWidth: `${Math.max(0, availableWidth) - 16}px`,
|
|
55
|
+
maxHeight: `${Math.max(0, availableHeight) - 16}px`
|
|
56
56
|
});
|
|
57
57
|
} }),
|
|
58
58
|
...__props.middleware
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarFloating.vue.script.js","names":["$slots"],"sources":["../../../src/components/ScalarFloating/ScalarFloating.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Floating component\n *\n * Positions a floating element relative to a reference element\n * using Floating UI. Handles placement, offset, flipping, and resizing.\n *\n * @example\n * <ScalarFloating placement=\"bottom\">\n * <button>Reference</button>\n * <template #floating>Floating content</template>\n * </ScalarFloating>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { getSideAxis } from '@floating-ui/utils'\nimport {\n type MiddlewareData,\n autoUpdate,\n flip,\n offset as offsetMiddleware,\n shift,\n size,\n useFloating,\n} from '@floating-ui/vue'\nimport { type Ref, computed, ref } from 'vue'\n\nimport { ScalarTeleport } from '../ScalarTeleport'\nimport type { FloatingOptions } from './types'\nimport { useResizeWithTarget } from './useResizeWithTarget'\n\nconst {\n placement,\n offset = 5,\n resize = false,\n middleware = [],\n target,\n teleport,\n} = defineProps<FloatingOptions>()\n\ndefineSlots<{\n /** The reference element for the element in the #floating slot */\n default(): unknown\n /** The floating element */\n floating?(props: {\n /** The width of the reference element if `resize` is true and placement is on the y axis */\n width?: string\n /** The height of the reference element if `resize` is true and placement is on the x axis */\n height?: string\n /** The middleware data return by Floating UI */\n data?: MiddlewareData\n }): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst floatingRef: Ref<HTMLElement | null> = ref(null)\nconst wrapperRef: Ref<HTMLElement | null> = ref(null)\n\nconst targetRef = computed<HTMLElement | undefined>(() => {\n if (typeof window !== 'undefined' && wrapperRef.value) {\n // If target is a string (id), try to find it in the document\n if (typeof target === 'string') {\n const t = document.getElementById(target)\n if (t) {\n return t\n }\n console.warn(`ScalarFloating: Target with id=\"${target}\" not found`)\n }\n // If target is an HTMLElement, return it\n else if (target instanceof HTMLElement) {\n return target\n }\n // Fallback to div wrapper if no child element is provided\n const firstChild = wrapperRef.value.children?.[0]\n if (firstChild instanceof HTMLElement) {\n return firstChild\n }\n return wrapperRef.value\n }\n // Return undefined if nothing is found\n return undefined\n})\n\nconst targetSize = useResizeWithTarget(targetRef, {\n enabled: computed(() => resize),\n})\n\nconst targetWidth = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'y'\n ? targetSize.width.value\n : undefined,\n)\n\nconst targetHeight = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'x'\n ? targetSize.height.value\n : undefined,\n)\nconst { floatingStyles, middlewareData } = useFloating(targetRef, floatingRef, {\n placement: computed(() => placement ?? 'bottom'),\n whileElementsMounted: autoUpdate,\n middleware: computed(() => [\n offsetMiddleware(offset),\n flip(),\n shift({ padding:
|
|
1
|
+
{"version":3,"file":"ScalarFloating.vue.script.js","names":["$slots"],"sources":["../../../src/components/ScalarFloating/ScalarFloating.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Floating component\n *\n * Positions a floating element relative to a reference element\n * using Floating UI. Handles placement, offset, flipping, and resizing.\n *\n * @example\n * <ScalarFloating placement=\"bottom\">\n * <button>Reference</button>\n * <template #floating>Floating content</template>\n * </ScalarFloating>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { getSideAxis } from '@floating-ui/utils'\nimport {\n type MiddlewareData,\n autoUpdate,\n flip,\n offset as offsetMiddleware,\n shift,\n size,\n useFloating,\n} from '@floating-ui/vue'\nimport { type Ref, computed, ref } from 'vue'\n\nimport { ScalarTeleport } from '../ScalarTeleport'\nimport type { FloatingOptions } from './types'\nimport { useResizeWithTarget } from './useResizeWithTarget'\n\nconst {\n placement,\n offset = 5,\n resize = false,\n middleware = [],\n target,\n teleport,\n} = defineProps<FloatingOptions>()\n\ndefineSlots<{\n /** The reference element for the element in the #floating slot */\n default(): unknown\n /** The floating element */\n floating?(props: {\n /** The width of the reference element if `resize` is true and placement is on the y axis */\n width?: string\n /** The height of the reference element if `resize` is true and placement is on the x axis */\n height?: string\n /** The middleware data return by Floating UI */\n data?: MiddlewareData\n }): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst floatingRef: Ref<HTMLElement | null> = ref(null)\nconst wrapperRef: Ref<HTMLElement | null> = ref(null)\n\nconst targetRef = computed<HTMLElement | undefined>(() => {\n if (typeof window !== 'undefined' && wrapperRef.value) {\n // If target is a string (id), try to find it in the document\n if (typeof target === 'string') {\n const t = document.getElementById(target)\n if (t) {\n return t\n }\n console.warn(`ScalarFloating: Target with id=\"${target}\" not found`)\n }\n // If target is an HTMLElement, return it\n else if (target instanceof HTMLElement) {\n return target\n }\n // Fallback to div wrapper if no child element is provided\n const firstChild = wrapperRef.value.children?.[0]\n if (firstChild instanceof HTMLElement) {\n return firstChild\n }\n return wrapperRef.value\n }\n // Return undefined if nothing is found\n return undefined\n})\n\nconst targetSize = useResizeWithTarget(targetRef, {\n enabled: computed(() => resize),\n})\n\nconst targetWidth = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'y'\n ? targetSize.width.value\n : undefined,\n)\n\nconst targetHeight = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'x'\n ? targetSize.height.value\n : undefined,\n)\nconst { floatingStyles, middlewareData } = useFloating(targetRef, floatingRef, {\n placement: computed(() => placement ?? 'bottom'),\n whileElementsMounted: autoUpdate,\n middleware: computed(() => [\n offsetMiddleware(offset),\n flip({ padding: 48 }),\n shift({ padding: 8 }),\n size({\n apply({ availableWidth, availableHeight, elements }) {\n // Assign the max width and height to the floating element\n // @see https://floating-ui.com/docs/size\n Object.assign(elements.floating.style, {\n maxWidth: `${Math.max(0, availableWidth) - 16}px`,\n maxHeight: `${Math.max(0, availableHeight) - 16}px`,\n })\n },\n }),\n ...middleware,\n ]),\n})\n\ndefineExpose({\n /** The resolved target element */\n targetRef,\n})\n</script>\n<template>\n <div\n ref=\"wrapperRef\"\n :class=\"{ contents: !!$slots.default }\">\n <slot />\n </div>\n <ScalarTeleport\n v-if=\"$slots.floating\"\n :disabled=\"!teleport\"\n :to=\"typeof teleport === 'string' ? teleport : undefined\">\n <div\n ref=\"floatingRef\"\n class=\"relative z-context\"\n :style=\"floatingStyles\">\n <slot\n :data=\"middlewareData\"\n :height=\"targetHeight\"\n name=\"floating\"\n :width=\"targetWidth\" />\n </div>\n </ScalarTeleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAyDA,MAAM,cAAuC,IAAI,KAAI;EACrD,MAAM,aAAsC,IAAI,KAAI;EAEpD,MAAM,YAAY,eAAwC;AACxD,OAAI,OAAO,WAAW,eAAe,WAAW,OAAO;AAErD,QAAI,OAAO,QAAA,WAAW,UAAU;KAC9B,MAAM,IAAI,SAAS,eAAe,QAAA,OAAM;AACxC,SAAI,EACF,QAAO;AAET,aAAQ,KAAK,mCAAmC,QAAA,OAAO,aAAY;eAG5D,QAAA,kBAAkB,YACzB,QAAO,QAAA;IAGT,MAAM,aAAa,WAAW,MAAM,WAAW;AAC/C,QAAI,sBAAsB,YACxB,QAAO;AAET,WAAO,WAAW;;IAIrB;EAED,MAAM,aAAa,oBAAoB,WAAW,EAChD,SAAS,eAAe,QAAA,OAAO,EAChC,CAAA;EAED,MAAM,cAAc,eAClB,YAAY,QAAA,aAAa,SAAS,KAAK,MACnC,WAAW,MAAM,QACjB,KAAA,EACN;EAEA,MAAM,eAAe,eACnB,YAAY,QAAA,aAAa,SAAS,KAAK,MACnC,WAAW,OAAO,QAClB,KAAA,EACN;EACA,MAAM,EAAE,gBAAgB,mBAAmB,YAAY,WAAW,aAAa;GAC7E,WAAW,eAAe,QAAA,aAAa,SAAS;GAChD,sBAAsB;GACtB,YAAY,eAAe;IACzB,OAAiB,QAAA,OAAO;IACxB,KAAK,EAAE,SAAS,IAAI,CAAC;IACrB,MAAM,EAAE,SAAS,GAAG,CAAC;IACrB,KAAK,EACH,MAAM,EAAE,gBAAgB,iBAAiB,YAAY;AAGnD,YAAO,OAAO,SAAS,SAAS,OAAO;MACrC,UAAU,GAAG,KAAK,IAAI,GAAG,eAAe,GAAG,GAAG;MAC9C,WAAW,GAAG,KAAK,IAAI,GAAG,gBAAgB,GAAG,GAAG;MACjD,CAAA;OAEJ,CAAC;IACF,GAAG,QAAA;IACJ,CAAC;GACH,CAAA;AAED,WAAa,EAEX,WACD,CAAA;;2DAGC,mBAIM,OAAA;aAHA;IAAJ,KAAI;IACH,OAAK,eAAA,EAAA,UAAA,CAAA,CAAgBA,KAAAA,OAAO,SAAO,CAAA;OACpC,WAAQ,KAAA,QAAA,UAAA,CAAA,EAAA,EAAA,EAGFA,KAAAA,OAAO,YAAA,WAAA,EADf,YAciB,MAAA,uBAAA,EAAA;;IAZd,UAAQ,CAAG,QAAA;IACX,IAAE,OAAS,QAAA,aAAQ,WAAgB,QAAA,WAAW,KAAA;;2BAUzC,CATN,mBASM,OAAA;cARA;KAAJ,KAAI;KACJ,OAAM;KACL,OAAK,eAAE,MAAA,eAAc,CAAA;QACtB,WAIyB,KAAA,QAAA,YAAA;KAHtB,MAAM,MAAA,eAAc;KACpB,QAAQ,aAAA;KAER,OAAO,YAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarSidebarNestedItems.vue.js","names":[],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarNestedItems.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Nested Items component\n *\n * A provides list of items thats presented over the parent list\n * Needs to be nested inside a ScalarSidebarItems component\n *\n * @example\n * <ScalarSidebarNestedItems v-model=\"open\">\n * <!-- Item text -->\n * <template #items>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * </template>\n * </ScalarSidebarNestedItems>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarIconArrowRight, ScalarIconCaretLeft } from '@scalar/icons'\nimport { nextTick, ref, useTemplateRef } from 'vue'\n\nimport ScalarSidebarButton from './ScalarSidebarButton.vue'\nimport ScalarSidebarItems from './ScalarSidebarItems.vue'\nimport ScalarSidebarLoading from './ScalarSidebarLoading.vue'\nimport ScalarSidebarSpacer from './ScalarSidebarSpacer.vue'\nimport { findScrollContainer } from './findScrollContainer'\nimport type { ScalarSidebarGroupProps } from './types'\nimport { useSidebarGroups } from './useSidebarGroups'\nimport { useSidebarNestedItem } from './useSidebarNestedItems'\n\nconst { controlled } = defineProps<ScalarSidebarGroupProps>()\n\nconst emit = defineEmits<{\n /** Emitted when the nested item button is clicked */\n (e: 'click', event: MouseEvent): void\n /** Emitted when the back button is clicked */\n (e: 'back', event: MouseEvent): void\n}>()\n\nconst open = defineModel<boolean>('open', { default: false })\nuseSidebarNestedItem(open)\n\ndefineSlots<{\n /** The text content of the button */\n 'default'?: () => unknown\n /** Override the entire button */\n 'button'?: () => unknown\n /** Override the icon */\n 'icon'?: () => unknown\n /** Override the aside slot */\n 'aside'?: () => unknown\n /** Override the back button */\n 'back'?: () => unknown\n /** Override the back button label */\n 'back-label'?: () => unknown\n /** The list of sidebar subitems */\n 'items'?: () => unknown\n}>()\n\nconst { level } = useSidebarGroups({ reset: true })\n\n/** The root element ref */\nconst el = useTemplateRef('el')\n\n/** How far down to offset the nested items by when animating them in */\nconst offset = ref(0)\n\n// Transition hooks\n\nfunction onOpen() {\n // Calculate how far down the nearest scroll container is scrolled\n // We offset the nested items by this amount when animating them\n // in so they appear in line with the parent items list.\n offset.value = findScrollContainer(el.value).scrollTop ?? 0\n\n // Focus the first button in the nested items\n nextTick(() =>\n el.value\n ?.querySelector<HTMLButtonElement>('button:not([aria-expanded=\"true\"])')\n ?.focus({ preventScroll: true }),\n )\n}\nfunction onOpened() {\n /** Reset the scroll position of the scroll container after opening */\n findScrollContainer(el.value).scrollTop = 0\n}\nfunction onClose() {\n nextTick(() => {\n el.value?.querySelector('button')?.focus({ preventScroll: true })\n findScrollContainer(el.value).scrollTop = offset.value\n })\n}\n\ndefineOptions({ inheritAttrs: false })\n\n/** Handle the click event for the nested items button */\nconst handleClick = (event: MouseEvent) => {\n // Bubble up the click event\n emit('click', event)\n if (!controlled) {\n // Only toggle the open state if the group is uncontrolled\n open.value = true\n }\n}\n\n/** Handle the back button click event */\nconst handleBack = (event: MouseEvent) => {\n // Bubble up the back event\n emit('back', event)\n if (!controlled) {\n // Only toggle the open state if the group is uncontrolled\n open.value = false\n }\n}\n</script>\n<template>\n <li\n ref=\"el\"\n class=\"group/item group/nested-items contents\"\n :class=\"{ 'group/nested-items-open': open }\"\n :style=\"{ '--nested-items-offset': `${offset}px` }\">\n <slot name=\"button\">\n <ScalarSidebarButton\n is=\"button\"\n :aria-expanded=\"open\"\n :disabled\n :icon\n :indent=\"level\"\n :selected\n v-bind=\"$attrs\"\n @click=\"handleClick\">\n <template\n v-if=\"$slots.icon\"\n #icon>\n <slot name=\"icon\" />\n </template>\n <slot />\n <template #aside>\n <slot name=\"aside\">\n <ScalarIconArrowRight class=\"size-4 text-sidebar-c-2\" />\n </slot>\n </template>\n </ScalarSidebarButton>\n </slot>\n <!-- Make sure the div is around for the entire transition -->\n <Transition\n :duration=\"300\"\n enterActiveClass=\"top-(--nested-items-offset)!\"\n leaveActiveClass=\"top-(--nested-items-offset)!\"\n @afterEnter=\"onOpened\"\n @enter=\"onOpen\"\n @leave=\"onClose\">\n <div\n v-if=\"open\"\n class=\"absolute inset-0 translate-x-full\">\n <ScalarSidebarItems v-bind=\"$attrs\">\n <div\n class=\"flex flex-col gap-px sticky top-(--scalar-sidebar-sticky-offset,0) pt-(--scalar-sidebar-padding) -mt-(--scalar-sidebar-padding) px-(--scalar-sidebar-padding) -mx-(--scalar-sidebar-padding) bg-sidebar-b-1 z-1 animate-sidebar-border-bottom border-b-sidebar-border\">\n <slot name=\"back\">\n <ScalarSidebarButton\n is=\"button\"\n class=\"text-sidebar-c-1 font-sidebar-active hover:text-sidebar-c-1\"\n @click=\"handleBack\">\n <template #icon>\n <ScalarIconCaretLeft class=\"size-4 -m-px text-sidebar-c-2\" />\n </template>\n <slot name=\"back-label\">Back</slot>\n </ScalarSidebarButton>\n </slot>\n <ScalarSidebarSpacer class=\"h-3\" />\n </div>\n <ScalarSidebarLoading v-if=\"loading\" />\n <slot\n v-else\n name=\"items\" />\n </ScalarSidebarItems>\n </div>\n </Transition>\n </li>\n</template>\n\n<style>\n@reference \"../../style.css\";\n\n.animate-sidebar-border-bottom {\n animation: border-bottom forwards;\n animation-timeline: scroll();\n animation-range-end: 1px;\n}\n\n@keyframes border-bottom {\n from {\n border-bottom-width: 0;\n }\n to {\n border-bottom-width: var(--scalar-border-width);\n }\n}\n</style>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ScalarSidebarNestedItems.vue.js","names":[],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarNestedItems.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Nested Items component\n *\n * A provides list of items thats presented over the parent list\n * Needs to be nested inside a ScalarSidebarItems component\n *\n * @example\n * <ScalarSidebarNestedItems v-model=\"open\">\n * <!-- Item text -->\n * <template #items>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * </template>\n * </ScalarSidebarNestedItems>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarIconArrowRight, ScalarIconCaretLeft } from '@scalar/icons'\nimport { nextTick, ref, useTemplateRef } from 'vue'\n\nimport ScalarSidebarButton from './ScalarSidebarButton.vue'\nimport ScalarSidebarItems from './ScalarSidebarItems.vue'\nimport ScalarSidebarLoading from './ScalarSidebarLoading.vue'\nimport ScalarSidebarSpacer from './ScalarSidebarSpacer.vue'\nimport { findScrollContainer } from './findScrollContainer'\nimport type { ScalarSidebarGroupProps } from './types'\nimport { useSidebarGroups } from './useSidebarGroups'\nimport { useSidebarNestedItem } from './useSidebarNestedItems'\n\nconst { controlled } = defineProps<ScalarSidebarGroupProps>()\n\nconst emit = defineEmits<{\n /** Emitted when the nested item button is clicked */\n (e: 'click', event: MouseEvent): void\n /** Emitted when the back button is clicked */\n (e: 'back', event: MouseEvent): void\n}>()\n\nconst open = defineModel<boolean>('open', { default: false })\nuseSidebarNestedItem(() => open.value)\n\ndefineSlots<{\n /** The text content of the button */\n 'default'?: () => unknown\n /** Override the entire button */\n 'button'?: () => unknown\n /** Override the icon */\n 'icon'?: () => unknown\n /** Override the aside slot */\n 'aside'?: () => unknown\n /** Override the back button */\n 'back'?: () => unknown\n /** Override the back button label */\n 'back-label'?: () => unknown\n /** The list of sidebar subitems */\n 'items'?: () => unknown\n}>()\n\nconst { level } = useSidebarGroups({ reset: true })\n\n/** The root element ref */\nconst el = useTemplateRef('el')\n\n/** How far down to offset the nested items by when animating them in */\nconst offset = ref(0)\n\n// Transition hooks\n\nfunction onOpen() {\n // Calculate how far down the nearest scroll container is scrolled\n // We offset the nested items by this amount when animating them\n // in so they appear in line with the parent items list.\n offset.value = findScrollContainer(el.value).scrollTop ?? 0\n\n // Focus the first button in the nested items\n nextTick(() =>\n el.value\n ?.querySelector<HTMLButtonElement>('button:not([aria-expanded=\"true\"])')\n ?.focus({ preventScroll: true }),\n )\n}\nfunction onOpened() {\n /** Reset the scroll position of the scroll container after opening */\n findScrollContainer(el.value).scrollTop = 0\n}\nfunction onClose() {\n nextTick(() => {\n el.value?.querySelector('button')?.focus({ preventScroll: true })\n findScrollContainer(el.value).scrollTop = offset.value\n })\n}\n\ndefineOptions({ inheritAttrs: false })\n\n/** Handle the click event for the nested items button */\nconst handleClick = (event: MouseEvent) => {\n // Bubble up the click event\n emit('click', event)\n if (!controlled) {\n // Only toggle the open state if the group is uncontrolled\n open.value = true\n }\n}\n\n/** Handle the back button click event */\nconst handleBack = (event: MouseEvent) => {\n // Bubble up the back event\n emit('back', event)\n if (!controlled) {\n // Only toggle the open state if the group is uncontrolled\n open.value = false\n }\n}\n</script>\n<template>\n <li\n ref=\"el\"\n class=\"group/item group/nested-items contents\"\n :class=\"{ 'group/nested-items-open': open }\"\n :style=\"{ '--nested-items-offset': `${offset}px` }\">\n <slot name=\"button\">\n <ScalarSidebarButton\n is=\"button\"\n :aria-expanded=\"open\"\n :disabled\n :icon\n :indent=\"level\"\n :selected\n v-bind=\"$attrs\"\n @click=\"handleClick\">\n <template\n v-if=\"$slots.icon\"\n #icon>\n <slot name=\"icon\" />\n </template>\n <slot />\n <template #aside>\n <slot name=\"aside\">\n <ScalarIconArrowRight class=\"size-4 text-sidebar-c-2\" />\n </slot>\n </template>\n </ScalarSidebarButton>\n </slot>\n <!-- Make sure the div is around for the entire transition -->\n <Transition\n :duration=\"300\"\n enterActiveClass=\"top-(--nested-items-offset)!\"\n leaveActiveClass=\"top-(--nested-items-offset)!\"\n @afterEnter=\"onOpened\"\n @enter=\"onOpen\"\n @leave=\"onClose\">\n <div\n v-if=\"open\"\n class=\"absolute inset-0 translate-x-full\">\n <ScalarSidebarItems v-bind=\"$attrs\">\n <div\n class=\"flex flex-col gap-px sticky top-(--scalar-sidebar-sticky-offset,0) pt-(--scalar-sidebar-padding) -mt-(--scalar-sidebar-padding) px-(--scalar-sidebar-padding) -mx-(--scalar-sidebar-padding) bg-sidebar-b-1 z-1 animate-sidebar-border-bottom border-b-sidebar-border\">\n <slot name=\"back\">\n <ScalarSidebarButton\n is=\"button\"\n class=\"text-sidebar-c-1 font-sidebar-active hover:text-sidebar-c-1\"\n @click=\"handleBack\">\n <template #icon>\n <ScalarIconCaretLeft class=\"size-4 -m-px text-sidebar-c-2\" />\n </template>\n <slot name=\"back-label\">Back</slot>\n </ScalarSidebarButton>\n </slot>\n <ScalarSidebarSpacer class=\"h-3\" />\n </div>\n <ScalarSidebarLoading v-if=\"loading\" />\n <slot\n v-else\n name=\"items\" />\n </ScalarSidebarItems>\n </div>\n </Transition>\n </li>\n</template>\n\n<style>\n@reference \"../../style.css\";\n\n.animate-sidebar-border-bottom {\n animation: border-bottom forwards;\n animation-timeline: scroll();\n animation-range-end: 1px;\n}\n\n@keyframes border-bottom {\n from {\n border-bottom-width: 0;\n }\n to {\n border-bottom-width: var(--scalar-border-width);\n }\n}\n</style>\n"],"mappings":""}
|
|
@@ -37,7 +37,7 @@ var ScalarSidebarNestedItems_vue_vue_type_script_setup_true_lang_default = /* @_
|
|
|
37
37
|
setup(__props, { emit: __emit }) {
|
|
38
38
|
const emit = __emit;
|
|
39
39
|
const open = useModel(__props, "open");
|
|
40
|
-
useSidebarNestedItem(open);
|
|
40
|
+
useSidebarNestedItem(() => open.value);
|
|
41
41
|
const { level } = useSidebarGroups({ reset: true });
|
|
42
42
|
/** The root element ref */
|
|
43
43
|
const el = useTemplateRef("el");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarSidebarNestedItems.vue.script.js","names":["$attrs","$slots"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarNestedItems.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Nested Items component\n *\n * A provides list of items thats presented over the parent list\n * Needs to be nested inside a ScalarSidebarItems component\n *\n * @example\n * <ScalarSidebarNestedItems v-model=\"open\">\n * <!-- Item text -->\n * <template #items>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * </template>\n * </ScalarSidebarNestedItems>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarIconArrowRight, ScalarIconCaretLeft } from '@scalar/icons'\nimport { nextTick, ref, useTemplateRef } from 'vue'\n\nimport ScalarSidebarButton from './ScalarSidebarButton.vue'\nimport ScalarSidebarItems from './ScalarSidebarItems.vue'\nimport ScalarSidebarLoading from './ScalarSidebarLoading.vue'\nimport ScalarSidebarSpacer from './ScalarSidebarSpacer.vue'\nimport { findScrollContainer } from './findScrollContainer'\nimport type { ScalarSidebarGroupProps } from './types'\nimport { useSidebarGroups } from './useSidebarGroups'\nimport { useSidebarNestedItem } from './useSidebarNestedItems'\n\nconst { controlled } = defineProps<ScalarSidebarGroupProps>()\n\nconst emit = defineEmits<{\n /** Emitted when the nested item button is clicked */\n (e: 'click', event: MouseEvent): void\n /** Emitted when the back button is clicked */\n (e: 'back', event: MouseEvent): void\n}>()\n\nconst open = defineModel<boolean>('open', { default: false })\nuseSidebarNestedItem(open)\n\ndefineSlots<{\n /** The text content of the button */\n 'default'?: () => unknown\n /** Override the entire button */\n 'button'?: () => unknown\n /** Override the icon */\n 'icon'?: () => unknown\n /** Override the aside slot */\n 'aside'?: () => unknown\n /** Override the back button */\n 'back'?: () => unknown\n /** Override the back button label */\n 'back-label'?: () => unknown\n /** The list of sidebar subitems */\n 'items'?: () => unknown\n}>()\n\nconst { level } = useSidebarGroups({ reset: true })\n\n/** The root element ref */\nconst el = useTemplateRef('el')\n\n/** How far down to offset the nested items by when animating them in */\nconst offset = ref(0)\n\n// Transition hooks\n\nfunction onOpen() {\n // Calculate how far down the nearest scroll container is scrolled\n // We offset the nested items by this amount when animating them\n // in so they appear in line with the parent items list.\n offset.value = findScrollContainer(el.value).scrollTop ?? 0\n\n // Focus the first button in the nested items\n nextTick(() =>\n el.value\n ?.querySelector<HTMLButtonElement>('button:not([aria-expanded=\"true\"])')\n ?.focus({ preventScroll: true }),\n )\n}\nfunction onOpened() {\n /** Reset the scroll position of the scroll container after opening */\n findScrollContainer(el.value).scrollTop = 0\n}\nfunction onClose() {\n nextTick(() => {\n el.value?.querySelector('button')?.focus({ preventScroll: true })\n findScrollContainer(el.value).scrollTop = offset.value\n })\n}\n\ndefineOptions({ inheritAttrs: false })\n\n/** Handle the click event for the nested items button */\nconst handleClick = (event: MouseEvent) => {\n // Bubble up the click event\n emit('click', event)\n if (!controlled) {\n // Only toggle the open state if the group is uncontrolled\n open.value = true\n }\n}\n\n/** Handle the back button click event */\nconst handleBack = (event: MouseEvent) => {\n // Bubble up the back event\n emit('back', event)\n if (!controlled) {\n // Only toggle the open state if the group is uncontrolled\n open.value = false\n }\n}\n</script>\n<template>\n <li\n ref=\"el\"\n class=\"group/item group/nested-items contents\"\n :class=\"{ 'group/nested-items-open': open }\"\n :style=\"{ '--nested-items-offset': `${offset}px` }\">\n <slot name=\"button\">\n <ScalarSidebarButton\n is=\"button\"\n :aria-expanded=\"open\"\n :disabled\n :icon\n :indent=\"level\"\n :selected\n v-bind=\"$attrs\"\n @click=\"handleClick\">\n <template\n v-if=\"$slots.icon\"\n #icon>\n <slot name=\"icon\" />\n </template>\n <slot />\n <template #aside>\n <slot name=\"aside\">\n <ScalarIconArrowRight class=\"size-4 text-sidebar-c-2\" />\n </slot>\n </template>\n </ScalarSidebarButton>\n </slot>\n <!-- Make sure the div is around for the entire transition -->\n <Transition\n :duration=\"300\"\n enterActiveClass=\"top-(--nested-items-offset)!\"\n leaveActiveClass=\"top-(--nested-items-offset)!\"\n @afterEnter=\"onOpened\"\n @enter=\"onOpen\"\n @leave=\"onClose\">\n <div\n v-if=\"open\"\n class=\"absolute inset-0 translate-x-full\">\n <ScalarSidebarItems v-bind=\"$attrs\">\n <div\n class=\"flex flex-col gap-px sticky top-(--scalar-sidebar-sticky-offset,0) pt-(--scalar-sidebar-padding) -mt-(--scalar-sidebar-padding) px-(--scalar-sidebar-padding) -mx-(--scalar-sidebar-padding) bg-sidebar-b-1 z-1 animate-sidebar-border-bottom border-b-sidebar-border\">\n <slot name=\"back\">\n <ScalarSidebarButton\n is=\"button\"\n class=\"text-sidebar-c-1 font-sidebar-active hover:text-sidebar-c-1\"\n @click=\"handleBack\">\n <template #icon>\n <ScalarIconCaretLeft class=\"size-4 -m-px text-sidebar-c-2\" />\n </template>\n <slot name=\"back-label\">Back</slot>\n </ScalarSidebarButton>\n </slot>\n <ScalarSidebarSpacer class=\"h-3\" />\n </div>\n <ScalarSidebarLoading v-if=\"loading\" />\n <slot\n v-else\n name=\"items\" />\n </ScalarSidebarItems>\n </div>\n </Transition>\n </li>\n</template>\n\n<style>\n@reference \"../../style.css\";\n\n.animate-sidebar-border-bottom {\n animation: border-bottom forwards;\n animation-timeline: scroll();\n animation-range-end: 1px;\n}\n\n@keyframes border-bottom {\n from {\n border-bottom-width: 0;\n }\n to {\n border-bottom-width: var(--scalar-border-width);\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCA,MAAM,OAAO;EAOb,MAAM,OAAO,SAAoB,SAAC,OAA0B;AAC5D,
|
|
1
|
+
{"version":3,"file":"ScalarSidebarNestedItems.vue.script.js","names":["$attrs","$slots"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarNestedItems.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Nested Items component\n *\n * A provides list of items thats presented over the parent list\n * Needs to be nested inside a ScalarSidebarItems component\n *\n * @example\n * <ScalarSidebarNestedItems v-model=\"open\">\n * <!-- Item text -->\n * <template #items>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * </template>\n * </ScalarSidebarNestedItems>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarIconArrowRight, ScalarIconCaretLeft } from '@scalar/icons'\nimport { nextTick, ref, useTemplateRef } from 'vue'\n\nimport ScalarSidebarButton from './ScalarSidebarButton.vue'\nimport ScalarSidebarItems from './ScalarSidebarItems.vue'\nimport ScalarSidebarLoading from './ScalarSidebarLoading.vue'\nimport ScalarSidebarSpacer from './ScalarSidebarSpacer.vue'\nimport { findScrollContainer } from './findScrollContainer'\nimport type { ScalarSidebarGroupProps } from './types'\nimport { useSidebarGroups } from './useSidebarGroups'\nimport { useSidebarNestedItem } from './useSidebarNestedItems'\n\nconst { controlled } = defineProps<ScalarSidebarGroupProps>()\n\nconst emit = defineEmits<{\n /** Emitted when the nested item button is clicked */\n (e: 'click', event: MouseEvent): void\n /** Emitted when the back button is clicked */\n (e: 'back', event: MouseEvent): void\n}>()\n\nconst open = defineModel<boolean>('open', { default: false })\nuseSidebarNestedItem(() => open.value)\n\ndefineSlots<{\n /** The text content of the button */\n 'default'?: () => unknown\n /** Override the entire button */\n 'button'?: () => unknown\n /** Override the icon */\n 'icon'?: () => unknown\n /** Override the aside slot */\n 'aside'?: () => unknown\n /** Override the back button */\n 'back'?: () => unknown\n /** Override the back button label */\n 'back-label'?: () => unknown\n /** The list of sidebar subitems */\n 'items'?: () => unknown\n}>()\n\nconst { level } = useSidebarGroups({ reset: true })\n\n/** The root element ref */\nconst el = useTemplateRef('el')\n\n/** How far down to offset the nested items by when animating them in */\nconst offset = ref(0)\n\n// Transition hooks\n\nfunction onOpen() {\n // Calculate how far down the nearest scroll container is scrolled\n // We offset the nested items by this amount when animating them\n // in so they appear in line with the parent items list.\n offset.value = findScrollContainer(el.value).scrollTop ?? 0\n\n // Focus the first button in the nested items\n nextTick(() =>\n el.value\n ?.querySelector<HTMLButtonElement>('button:not([aria-expanded=\"true\"])')\n ?.focus({ preventScroll: true }),\n )\n}\nfunction onOpened() {\n /** Reset the scroll position of the scroll container after opening */\n findScrollContainer(el.value).scrollTop = 0\n}\nfunction onClose() {\n nextTick(() => {\n el.value?.querySelector('button')?.focus({ preventScroll: true })\n findScrollContainer(el.value).scrollTop = offset.value\n })\n}\n\ndefineOptions({ inheritAttrs: false })\n\n/** Handle the click event for the nested items button */\nconst handleClick = (event: MouseEvent) => {\n // Bubble up the click event\n emit('click', event)\n if (!controlled) {\n // Only toggle the open state if the group is uncontrolled\n open.value = true\n }\n}\n\n/** Handle the back button click event */\nconst handleBack = (event: MouseEvent) => {\n // Bubble up the back event\n emit('back', event)\n if (!controlled) {\n // Only toggle the open state if the group is uncontrolled\n open.value = false\n }\n}\n</script>\n<template>\n <li\n ref=\"el\"\n class=\"group/item group/nested-items contents\"\n :class=\"{ 'group/nested-items-open': open }\"\n :style=\"{ '--nested-items-offset': `${offset}px` }\">\n <slot name=\"button\">\n <ScalarSidebarButton\n is=\"button\"\n :aria-expanded=\"open\"\n :disabled\n :icon\n :indent=\"level\"\n :selected\n v-bind=\"$attrs\"\n @click=\"handleClick\">\n <template\n v-if=\"$slots.icon\"\n #icon>\n <slot name=\"icon\" />\n </template>\n <slot />\n <template #aside>\n <slot name=\"aside\">\n <ScalarIconArrowRight class=\"size-4 text-sidebar-c-2\" />\n </slot>\n </template>\n </ScalarSidebarButton>\n </slot>\n <!-- Make sure the div is around for the entire transition -->\n <Transition\n :duration=\"300\"\n enterActiveClass=\"top-(--nested-items-offset)!\"\n leaveActiveClass=\"top-(--nested-items-offset)!\"\n @afterEnter=\"onOpened\"\n @enter=\"onOpen\"\n @leave=\"onClose\">\n <div\n v-if=\"open\"\n class=\"absolute inset-0 translate-x-full\">\n <ScalarSidebarItems v-bind=\"$attrs\">\n <div\n class=\"flex flex-col gap-px sticky top-(--scalar-sidebar-sticky-offset,0) pt-(--scalar-sidebar-padding) -mt-(--scalar-sidebar-padding) px-(--scalar-sidebar-padding) -mx-(--scalar-sidebar-padding) bg-sidebar-b-1 z-1 animate-sidebar-border-bottom border-b-sidebar-border\">\n <slot name=\"back\">\n <ScalarSidebarButton\n is=\"button\"\n class=\"text-sidebar-c-1 font-sidebar-active hover:text-sidebar-c-1\"\n @click=\"handleBack\">\n <template #icon>\n <ScalarIconCaretLeft class=\"size-4 -m-px text-sidebar-c-2\" />\n </template>\n <slot name=\"back-label\">Back</slot>\n </ScalarSidebarButton>\n </slot>\n <ScalarSidebarSpacer class=\"h-3\" />\n </div>\n <ScalarSidebarLoading v-if=\"loading\" />\n <slot\n v-else\n name=\"items\" />\n </ScalarSidebarItems>\n </div>\n </Transition>\n </li>\n</template>\n\n<style>\n@reference \"../../style.css\";\n\n.animate-sidebar-border-bottom {\n animation: border-bottom forwards;\n animation-timeline: scroll();\n animation-range-end: 1px;\n}\n\n@keyframes border-bottom {\n from {\n border-bottom-width: 0;\n }\n to {\n border-bottom-width: var(--scalar-border-width);\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCA,MAAM,OAAO;EAOb,MAAM,OAAO,SAAoB,SAAC,OAA0B;AAC5D,6BAA2B,KAAK,MAAK;EAmBrC,MAAM,EAAE,UAAU,iBAAiB,EAAE,OAAO,MAAM,CAAA;;EAGlD,MAAM,KAAK,eAAe,KAAI;;EAG9B,MAAM,SAAS,IAAI,EAAC;EAIpB,SAAS,SAAS;AAIhB,UAAO,QAAQ,oBAAoB,GAAG,MAAM,CAAC,aAAa;AAG1D,kBACE,GAAG,OACC,cAAiC,uCAAoC,EACrE,MAAM,EAAE,eAAe,MAAM,CAAC,CACpC;;EAEF,SAAS,WAAW;;AAElB,uBAAoB,GAAG,MAAM,CAAC,YAAY;;EAE5C,SAAS,UAAU;AACjB,kBAAe;AACb,OAAG,OAAO,cAAc,SAAS,EAAE,MAAM,EAAE,eAAe,MAAM,CAAA;AAChE,wBAAoB,GAAG,MAAM,CAAC,YAAY,OAAO;KAClD;;;EAMH,MAAM,eAAe,UAAsB;AAEzC,QAAK,SAAS,MAAK;AACnB,OAAI,CAAC,QAAA,WAEH,MAAK,QAAQ;;;EAKjB,MAAM,cAAc,UAAsB;AAExC,QAAK,QAAQ,MAAK;AAClB,OAAI,CAAC,QAAA,WAEH,MAAK,QAAQ;;;uBAKf,mBA8DK,MAAA;aA7DC;IAAJ,KAAI;IACJ,OAAK,eAAA,CAAC,0CAAwC,EAAA,2BACT,KAAA,OAAI,CAAA,CAAA;IACxC,OAAK,eAAA,EAAA,yBAAA,GAAgC,OAAA,MAAM,KAAA,CAAA;OAC5C,WAsBO,KAAA,QAAA,UAAA,EAAA,QAAA,CArBL,YAoBsB,6BApBtB,WAoBsB;IAnBpB,IAAG;IACF,iBAAe,KAAA;IACf,UAAA,QAAA;IACA,MAAA,QAAA;IACA,QAAQ,MAAA,MAAK;IACb,UAAA,QAAA;MACOA,KAAAA,QAAM,EACb,SAAO,aAAW,CAAA,EAAA,YAAA;IAOR,OAAK,cAGP,CAFP,WAEO,KAAA,QAAA,SAAA,EAAA,QAAA,CADL,YAAwD,MAAA,qBAAA,EAAA,EAAlC,OAAM,2BAAyB,CAAA,CAAA,CAAA,CAAA,CAAA;2BAHjD,CAAR,WAAQ,KAAA,QAAA,UAAA,CAAA,CAAA;;OAJAC,KAAAA,OAAO,OAAA;UACZ;sBACmB,CAApB,WAAoB,KAAA,QAAA,OAAA,CAAA,CAAA;;;;;;;;SAW1B,YAgCa,YAAA;IA/BV,UAAU;IACX,kBAAiB;IACjB,kBAAiB;IAChB,cAAY;IACZ,SAAO;IACP,SAAO;;2BAyBF,CAvBE,KAAA,SAAA,WAAA,EADR,mBAwBM,OAxBN,YAwBM,CArBJ,YAoBqB,4BAAA,eAAA,mBApBOD,KAAAA,OAAM,CAAA,EAAA;4BAe1B,CAdN,mBAcM,OAdN,YAcM,CAZJ,WAUO,KAAA,QAAA,QAAA,EAAA,QAAA,CATL,YAQsB,6BAAA;MAPpB,IAAG;MACH,OAAM;MACL,SAAO;;MACG,MAAI,cACgD,CAA7D,YAA6D,MAAA,oBAAA,EAAA,EAAxC,OAAM,iCAA+B,CAAA,CAAA,CAAA;6BAEzB,CAAnC,WAAmC,KAAA,QAAA,cAAA,EAAA,QAAA,CAAA,OAAA,OAAA,OAAA,KAAA,gBAAX,QAAI,GAAA,EAAA,CAAA,CAAA,CAAA;;WAGhC,YAAmC,6BAAA,EAAd,OAAM,OAAK,CAAA,CAAA,CAAA,EAEN,QAAA,WAAA,WAAA,EAA5B,YAAuC,8BAAA,EAAA,KAAA,GAAA,CAAA,IACvC,WAEiB,KAAA,QAAA,SAAA,EAAA,KAAA,GAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
type SidebarNestedItemOpenGetter = () => boolean;
|
|
2
2
|
/**
|
|
3
3
|
* Get the open / closed model for the nearest nested child items
|
|
4
4
|
*/
|
|
5
5
|
export declare const useSidebarNestedItem: (
|
|
6
|
-
/** The
|
|
7
|
-
open:
|
|
6
|
+
/** The getter for the open state of the current nested items */
|
|
7
|
+
open: SidebarNestedItemOpenGetter) => void;
|
|
8
8
|
/**
|
|
9
9
|
* Get whether or not any nested child items are open
|
|
10
10
|
*/
|
|
@@ -12,4 +12,5 @@ export declare const useSidebarNestedItems: () => {
|
|
|
12
12
|
/** Whether or not any nested child items are open */
|
|
13
13
|
open: import("vue").ComputedRef<boolean>;
|
|
14
14
|
};
|
|
15
|
+
export {};
|
|
15
16
|
//# sourceMappingURL=useSidebarNestedItems.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSidebarNestedItems.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarSidebar/useSidebarNestedItems.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSidebarNestedItems.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarSidebar/useSidebarNestedItems.ts"],"names":[],"mappings":"AAEA,KAAK,2BAA2B,GAAG,MAAM,OAAO,CAAA;AAOhD;;GAEG;AACH,eAAO,MAAM,oBAAoB;AAC/B,gEAAgE;AAChE,MAAM,2BAA2B,KAChC,IAYF,CAAA;AACD;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAkB9B,qDAAqD;;CAGxD,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, inject, onBeforeUnmount, provide,
|
|
1
|
+
import { computed, inject, onBeforeUnmount, provide, shallowReactive } from "vue";
|
|
2
2
|
//#region src/components/ScalarSidebar/useSidebarNestedItems.ts
|
|
3
3
|
/**
|
|
4
4
|
* Tracks the open state of the nearest nested child items
|
|
@@ -10,9 +10,9 @@ var SIDEBAR_NESTED_ITEMS_SYMBOL = Symbol();
|
|
|
10
10
|
var useSidebarNestedItem = (open) => {
|
|
11
11
|
const parentList = inject(SIDEBAR_NESTED_ITEMS_SYMBOL);
|
|
12
12
|
if (parentList) {
|
|
13
|
-
parentList.
|
|
13
|
+
parentList.add(open);
|
|
14
14
|
onBeforeUnmount(() => {
|
|
15
|
-
parentList.
|
|
15
|
+
parentList.delete(open);
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
};
|
|
@@ -20,8 +20,11 @@ var useSidebarNestedItem = (open) => {
|
|
|
20
20
|
* Get whether or not any nested child items are open
|
|
21
21
|
*/
|
|
22
22
|
var useSidebarNestedItems = () => {
|
|
23
|
-
const children =
|
|
24
|
-
const open = computed(() =>
|
|
23
|
+
const children = shallowReactive(/* @__PURE__ */ new Set());
|
|
24
|
+
const open = computed(() => {
|
|
25
|
+
for (const getIsChildOpen of children) if (getIsChildOpen()) return true;
|
|
26
|
+
return false;
|
|
27
|
+
});
|
|
25
28
|
provide(SIDEBAR_NESTED_ITEMS_SYMBOL, children);
|
|
26
29
|
return { open };
|
|
27
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSidebarNestedItems.js","names":[],"sources":["../../../src/components/ScalarSidebar/useSidebarNestedItems.ts"],"sourcesContent":["import { type InjectionKey,
|
|
1
|
+
{"version":3,"file":"useSidebarNestedItems.js","names":[],"sources":["../../../src/components/ScalarSidebar/useSidebarNestedItems.ts"],"sourcesContent":["import { type InjectionKey, computed, inject, onBeforeUnmount, provide, shallowReactive } from 'vue'\n\ntype SidebarNestedItemOpenGetter = () => boolean\n\n/**\n * Tracks the open state of the nearest nested child items\n */\nconst SIDEBAR_NESTED_ITEMS_SYMBOL = Symbol() as InjectionKey<Set<SidebarNestedItemOpenGetter>>\n\n/**\n * Get the open / closed model for the nearest nested child items\n */\nexport const useSidebarNestedItem = (\n /** The getter for the open state of the current nested items */\n open: SidebarNestedItemOpenGetter,\n): void => {\n const parentList = inject(SIDEBAR_NESTED_ITEMS_SYMBOL)\n\n if (parentList) {\n // Add this child to the parent list when the component is mounted\n parentList.add(open)\n\n onBeforeUnmount(() => {\n // Remove the reference to this child from the parent list when the component is unmounted\n parentList.delete(open)\n })\n }\n}\n/**\n * Get whether or not any nested child items are open\n */\nexport const useSidebarNestedItems = () => {\n // Create a reactive set with getters for each child's open state\n const children = shallowReactive(new Set<SidebarNestedItemOpenGetter>())\n\n const open = computed(() => {\n // Track the child list and each child's open state\n for (const getIsChildOpen of children) {\n if (getIsChildOpen()) {\n return true\n }\n }\n\n return false\n })\n\n provide(SIDEBAR_NESTED_ITEMS_SYMBOL, children)\n\n return {\n /** Whether or not any nested child items are open */\n open,\n }\n}\n"],"mappings":";;;;;AAOA,IAAM,8BAA8B,QAAQ;;;;AAK5C,IAAa,wBAEX,SACS;CACT,MAAM,aAAa,OAAO,4BAA4B;AAEtD,KAAI,YAAY;AAEd,aAAW,IAAI,KAAK;AAEpB,wBAAsB;AAEpB,cAAW,OAAO,KAAK;IACvB;;;;;;AAMN,IAAa,8BAA8B;CAEzC,MAAM,WAAW,gCAAgB,IAAI,KAAkC,CAAC;CAExE,MAAM,OAAO,eAAe;AAE1B,OAAK,MAAM,kBAAkB,SAC3B,KAAI,gBAAgB,CAClB,QAAO;AAIX,SAAO;GACP;AAEF,SAAQ,6BAA6B,SAAS;AAE9C,QAAO,EAEL,MACD"}
|
package/dist/style.css
CHANGED
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
11
|
"directory": "packages/components"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.
|
|
13
|
+
"version": "0.24.1",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=22"
|
|
16
16
|
},
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"vue": "^3.5.30",
|
|
41
41
|
"vue-component-type-helpers": "^3.2.6",
|
|
42
42
|
"@scalar/code-highlight": "0.3.4",
|
|
43
|
-
"@scalar/helpers": "0.5.
|
|
43
|
+
"@scalar/helpers": "0.5.5",
|
|
44
44
|
"@scalar/icons": "0.7.2",
|
|
45
45
|
"@scalar/themes": "0.15.3",
|
|
46
46
|
"@scalar/use-hooks": "0.4.3"
|