@scalar/components 0.35.5 → 0.36.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/components/ScalarButton/ScalarButton.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarButton/ScalarButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarCard/ScalarCardHeader.vue.d.ts.map +1 -1
- package/dist/components/ScalarCard/ScalarCardHeader.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/ScalarCard/ScalarCardHeader.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue.d.ts +8 -0
- package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue.d.ts.map +1 -1
- package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue.d.ts.map +1 -1
- package/dist/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue_vue_type_script_setup_true_lang.js +3 -4
- package/dist/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarCodeBlock/constants.d.ts +2 -1
- package/dist/components/ScalarCodeBlock/constants.d.ts.map +1 -1
- package/dist/components/ScalarCodeBlock/constants.js +2 -1
- package/dist/components/ScalarCodeBlock/constants.js.map +1 -1
- package/dist/components/ScalarColorModeToggle/ScalarColorModeToggleIcon.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarColorModeToggle/ScalarColorModeToggleIcon.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarCombobox.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/components/ScalarCombobox/ScalarCombobox.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxMultiselect.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/components/ScalarCombobox/ScalarComboboxMultiselect.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxPopover.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/components/ScalarCombobox/ScalarComboboxPopover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarDialog/ScalarDialog.vue.d.ts +50 -0
- package/dist/components/ScalarDialog/ScalarDialog.vue.d.ts.map +1 -0
- package/dist/components/ScalarDialog/ScalarDialog.vue.js +6 -0
- package/dist/components/ScalarDialog/ScalarDialog.vue.js.map +1 -0
- package/dist/components/ScalarDialog/ScalarDialog.vue_vue_type_script_setup_true_lang.js +120 -0
- package/dist/components/ScalarDialog/ScalarDialog.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/ScalarDialog/index.d.ts +4 -0
- package/dist/components/ScalarDialog/index.d.ts.map +1 -0
- package/dist/components/ScalarDialog/index.js +1 -0
- package/dist/components/ScalarDialog/types.d.ts +15 -0
- package/dist/components/ScalarDialog/types.d.ts.map +1 -0
- package/dist/components/ScalarDialog/useBackdropClick.d.ts +46 -0
- package/dist/components/ScalarDialog/useBackdropClick.d.ts.map +1 -0
- package/dist/components/ScalarDialog/useBackdropClick.js +60 -0
- package/dist/components/ScalarDialog/useBackdropClick.js.map +1 -0
- package/dist/components/ScalarDialog/useScrollLock.d.ts +16 -0
- package/dist/components/ScalarDialog/useScrollLock.d.ts.map +1 -0
- package/dist/components/ScalarDialog/useScrollLock.js +70 -0
- package/dist/components/ScalarDialog/useScrollLock.js.map +1 -0
- package/dist/components/ScalarDropdown/ScalarDropdown.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/components/ScalarDropdown/ScalarDropdown.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarDropdown/ScalarDropdownButton.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarDropdown/ScalarDropdownButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarDropdown/ScalarDropdownMenu.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/components/ScalarDropdown/ScalarDropdownMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarFloating/ScalarFloating.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/components/ScalarFloating/ScalarFloating.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarFloating/types.d.ts +3 -2
- package/dist/components/ScalarFloating/types.d.ts.map +1 -1
- package/dist/components/ScalarForm/ScalarFormError.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/ScalarForm/ScalarFormField.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarForm/ScalarFormField.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarForm/ScalarFormInput.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarForm/ScalarFormInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarForm/ScalarFormInputGroup.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarForm/ScalarFormInputGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarHeader/ScalarHeader.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarHeader/ScalarHeader.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarHeader/ScalarHeaderButton.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarHeader/ScalarHeaderButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarListbox/ScalarListbox.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/components/ScalarListbox/ScalarListbox.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuLink.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarMenu/ScalarMenuLink.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuProduct.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarMenu/ScalarMenuProduct.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarPopover/ScalarPopover.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/components/ScalarPopover/ScalarPopover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarButton.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarSidebar/ScalarSidebarButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarGroup.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarSidebar/ScalarSidebarGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarGroupToggle.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarSidebar/ScalarSidebarGroupToggle.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarItem.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/components/ScalarSidebar/ScalarSidebarItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarItems.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarSidebar/ScalarSidebarItems.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarNestedItems.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/components/ScalarSidebar/ScalarSidebarNestedItems.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarSection.vue_vue_type_script_setup_true_lang.js +8 -1
- package/dist/components/ScalarSidebar/ScalarSidebarSection.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarVirtualCodeBlock/ScalarVirtualCodeBlock.vue.d.ts +4 -0
- package/dist/components/ScalarVirtualCodeBlock/ScalarVirtualCodeBlock.vue.d.ts.map +1 -1
- package/dist/components/ScalarVirtualCodeBlock/ScalarVirtualCodeBlock.vue_vue_type_script_setup_true_lang.js +6 -2
- package/dist/components/ScalarVirtualCodeBlock/ScalarVirtualCodeBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/style.css +30 -0
- package/package.json +17 -12
|
@@ -11,7 +11,14 @@ var ScalarButton_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
11
11
|
inheritAttrs: false,
|
|
12
12
|
__name: "ScalarButton",
|
|
13
13
|
props: {
|
|
14
|
-
is: {
|
|
14
|
+
is: {
|
|
15
|
+
type: [
|
|
16
|
+
String,
|
|
17
|
+
Object,
|
|
18
|
+
Function
|
|
19
|
+
],
|
|
20
|
+
default: "button"
|
|
21
|
+
},
|
|
15
22
|
variant: { default: "solid" },
|
|
16
23
|
size: { default: "md" },
|
|
17
24
|
disabled: { type: Boolean },
|
package/dist/components/ScalarButton/ScalarButton.vue_vue_type_script_setup_true_lang.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarButton.vue_vue_type_script_setup_true_lang.js","names":["$slots","_openBlock","_createBlock","_resolveDynamicComponent","_mergeProps","_unref","_withCtx","_createElementBlock","_normalizeClass","_renderSlot","_createVNode","ScalarLoading"],"sources":["../../../src/components/ScalarButton/ScalarButton.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Button Component\n *\n * Provides a styled button, if you are looking for\n * an icon only button, use ScalarIconButton instead,\n * it's a helpful wrapper around this component\n *\n * @example\n * <ScalarButton>\n * <!-- Button label -->\n * </ScalarButton>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\n\nimport { ScalarLoading } from '../ScalarLoading'\nimport { BUTTON_VARIANT_STYLES } from './constants'\nimport type { ButtonSize, ClassList, ScalarButtonProps } from './types'\n\nconst {\n is = 'button',\n size = 'md',\n variant = 'solid',\n} = defineProps<ScalarButtonProps>()\n\n/** Variant styles for the button (wrapper) */\nconst buttonVariants = cva({\n base: 'scalar-button flex cursor-pointer items-center justify-center rounded font-medium -outline-offset-1',\n variants: {\n disabled: { true: 'bg-b-2 text-color-3 shadow-none' },\n size: {\n xs: 'px-2 py-1 text-xs/4',\n sm: 'px-3.5 py-2 text-sm/4',\n md: 'px-5 py-3 text-sm/4',\n } satisfies Record<ButtonSize, ClassList>,\n variant: BUTTON_VARIANT_STYLES,\n },\n compoundVariants: [\n {\n disabled: true,\n variant: ['solid', 'outlined', 'ghost', 'gradient', 'danger'],\n class:\n 'bg-b-2 text-c-3 shadow-none hover:bg-b-[_] cursor-not-allowed active:bg-b-[_] hover:text-c-[_] active:text-c-[_]',\n },\n {\n disabled: true,\n variant: ['gradient'],\n class:\n 'to-b-1.5 bg-linear-to-b hover:bg-linear-to-b dark:hover:bg-linear-to-t',\n },\n ],\n})\n\n/** Variant styles for the button icon */\nconst iconVariants = cva({\n base: 'shrink-0',\n variants: {\n size: {\n xs: 'size-2.75 -ml-0.25 mr-1',\n sm: 'size-3.5 -ml-0.25 mr-1',\n md: 'size-3.5 -ml-0.5 mr-1.5',\n } satisfies Record<ButtonSize, ClassList>,\n },\n})\n\n/** Variant styles for the loading icon */\nconst loadingVariants = cva({\n variants: {\n size: {\n xs: 'size-4',\n sm: 'size-5',\n md: 'size-6',\n } satisfies Record<ButtonSize, ClassList>,\n },\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <component\n :is=\"is\"\n :aria-disabled=\"disabled || undefined\"\n :type=\"is === 'button' ? 'button' : undefined\"\n v-bind=\"\n cx(buttonVariants({ disabled, size, variant }), {\n relative: loader?.isActive,\n })\n \">\n <div\n v-if=\"$slots.icon || icon\"\n :class=\"[iconVariants({ size }), { invisible: loader?.isActive }]\">\n <slot name=\"icon\">\n <component\n :is=\"icon\"\n class=\"size-full\" />\n </slot>\n </div>\n <span\n v-if=\"loader\"\n :class=\"{ invisible: loader?.isActive }\">\n <slot />\n </span>\n <slot v-else />\n <div\n v-if=\"loader?.isActive\"\n class=\"centered\">\n <ScalarLoading\n :class=\"loadingVariants({ size })\"\n :loader />\n </div>\n </component>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarButton.vue_vue_type_script_setup_true_lang.js","names":["$slots","_openBlock","_createBlock","_resolveDynamicComponent","_mergeProps","_unref","_withCtx","_createElementBlock","_normalizeClass","_renderSlot","_createVNode","ScalarLoading"],"sources":["../../../src/components/ScalarButton/ScalarButton.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Button Component\n *\n * Provides a styled button, if you are looking for\n * an icon only button, use ScalarIconButton instead,\n * it's a helpful wrapper around this component\n *\n * @example\n * <ScalarButton>\n * <!-- Button label -->\n * </ScalarButton>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\n\nimport { ScalarLoading } from '../ScalarLoading'\nimport { BUTTON_VARIANT_STYLES } from './constants'\nimport type { ButtonSize, ClassList, ScalarButtonProps } from './types'\n\nconst {\n is = 'button',\n size = 'md',\n variant = 'solid',\n} = defineProps<ScalarButtonProps>()\n\n/** Variant styles for the button (wrapper) */\nconst buttonVariants = cva({\n base: 'scalar-button flex cursor-pointer items-center justify-center rounded font-medium -outline-offset-1',\n variants: {\n disabled: { true: 'bg-b-2 text-color-3 shadow-none' },\n size: {\n xs: 'px-2 py-1 text-xs/4',\n sm: 'px-3.5 py-2 text-sm/4',\n md: 'px-5 py-3 text-sm/4',\n } satisfies Record<ButtonSize, ClassList>,\n variant: BUTTON_VARIANT_STYLES,\n },\n compoundVariants: [\n {\n disabled: true,\n variant: ['solid', 'outlined', 'ghost', 'gradient', 'danger'],\n class:\n 'bg-b-2 text-c-3 shadow-none hover:bg-b-[_] cursor-not-allowed active:bg-b-[_] hover:text-c-[_] active:text-c-[_]',\n },\n {\n disabled: true,\n variant: ['gradient'],\n class:\n 'to-b-1.5 bg-linear-to-b hover:bg-linear-to-b dark:hover:bg-linear-to-t',\n },\n ],\n})\n\n/** Variant styles for the button icon */\nconst iconVariants = cva({\n base: 'shrink-0',\n variants: {\n size: {\n xs: 'size-2.75 -ml-0.25 mr-1',\n sm: 'size-3.5 -ml-0.25 mr-1',\n md: 'size-3.5 -ml-0.5 mr-1.5',\n } satisfies Record<ButtonSize, ClassList>,\n },\n})\n\n/** Variant styles for the loading icon */\nconst loadingVariants = cva({\n variants: {\n size: {\n xs: 'size-4',\n sm: 'size-5',\n md: 'size-6',\n } satisfies Record<ButtonSize, ClassList>,\n },\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <component\n :is=\"is\"\n :aria-disabled=\"disabled || undefined\"\n :type=\"is === 'button' ? 'button' : undefined\"\n v-bind=\"\n cx(buttonVariants({ disabled, size, variant }), {\n relative: loader?.isActive,\n })\n \">\n <div\n v-if=\"$slots.icon || icon\"\n :class=\"[iconVariants({ size }), { invisible: loader?.isActive }]\">\n <slot name=\"icon\">\n <component\n :is=\"icon\"\n class=\"size-full\" />\n </slot>\n </div>\n <span\n v-if=\"loader\"\n :class=\"{ invisible: loader?.isActive }\">\n <slot />\n </span>\n <slot v-else />\n <div\n v-if=\"loader?.isActive\"\n class=\"centered\">\n <ScalarLoading\n :class=\"loadingVariants({ size })\"\n :loader />\n </div>\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BA,MAAM,iBAAiB,IAAI;GACzB,MAAM;GACN,UAAU;IACR,UAAU,EAAE,MAAM,kCAAkC;IACpD,MAAM;KACJ,IAAI;KACJ,IAAI;KACJ,IAAI;IACN;IACA,SAAS;GACX;GACA,kBAAkB,CAChB;IACE,UAAU;IACV,SAAS;KAAC;KAAS;KAAY;KAAS;KAAY;IAAQ;IAC5D,OACE;GACJ,GACA;IACE,UAAU;IACV,SAAS,CAAC,UAAU;IACpB,OACE;GACJ,CACF;EACF,CAAC;;EAGD,MAAM,eAAe,IAAI;GACvB,MAAM;GACN,UAAU,EACR,MAAM;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;GACN,EACF;EACF,CAAC;;EAGD,MAAM,kBAAkB,IAAI,EAC1B,UAAU,EACR,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN,EACF,EACF,CAAC;EAGD,MAAM,EAAE,OAAO,UAAU;;GAGvB,OAAAC,UAAA,GAAAC,YA+BYC,wBA9BL,QAAA,EAAE,GADTC,WA+BY;IA7BT,iBAAe,QAAA,YAAY,KAAA;IAC3B,MAAM,QAAA,OAAE,WAAA,WAA2B,KAAA;G,GACrBC,MAAA,EAAA,CAAE,CAACA,MAAA,cAAA,CAAc,CAAA;IAAA,UAAG,QAAA;IAAQ,MAAE,QAAA;IAAI,SAAE,QAAA;GAAO,CAAA,GAAA,EAAyB,UAAA,QAAA,QAAQ,S;IAK3F,SAAAC,cAQM;KAPEN,KAAAA,OAAO,QAAQ,QAAA,QADvBC,UAAA,GAAAM,mBAQM,OAAA;;MANH,OAAKC,eAAA,CAAGH,MAAA,YAAA,CAAY,CAAA,EAAA,MAAG,QAAA,KAAI,CAAA,GAAA,EAAA,WAAkB,QAAA,QAAQ,SAAQ,CAAA,CAAA;K,IAC9DI,WAIO,KAAA,QAAA,QAAA,CAAA,SAAA,EAHLR,UAAA,GAAAC,YAEsBC,wBADf,QAAA,IAAI,GAAA,EACT,OAAM,YAAW,CAAA,E;KAIf,QAAA,UADRF,UAAA,GAAAM,mBAIO,QAAA;;MAFJ,OAAKC,eAAA,EAAA,WAAe,QAAA,QAAQ,SAAQ,CAAA;K,IACrCC,WAAQ,KAAA,QAAA,SAAA,C,SAEVA,WAAe,KAAA,QAAA,WAAA,CAAA,GAAA,KAAA,GAAA,KAAA,GAAA,CAAA;KAEP,QAAA,QAAQ,YADhBR,UAAA,GAAAM,mBAMM,OANN,YAMM,CAHJG,YAEYL,MAAAM,qBAAA,GAAA;MADT,OAAKH,eAAEH,MAAA,eAAA,CAAe,CAAA,EAAA,MAAG,QAAA,KAAI,CAAA,CAAA;MAC7B,QAAA,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarCardHeader.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCard/ScalarCardHeader.vue"],"names":[],"mappings":"AA+DA;;;;;;;;;;GAUG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;
|
|
1
|
+
{"version":3,"file":"ScalarCardHeader.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCard/ScalarCardHeader.vue"],"names":[],"mappings":"AA+DA;;;;;;;;;;GAUG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;cAsEJ,CAAC,KAAK,IAAgB,KAAK,GAAG;;cAC9B,CAAC,KAAK,IAAiB,KAAK,GAAG;EAQzC,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { createBlock, createCommentVNode, createElementBlock, createElementVNode
|
|
|
6
6
|
var _hoisted_1 = ["id"];
|
|
7
7
|
var _hoisted_2 = {
|
|
8
8
|
key: 0,
|
|
9
|
-
class: "flex"
|
|
9
|
+
class: "flex max-w-full"
|
|
10
10
|
};
|
|
11
11
|
var ScalarCardHeader_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
12
12
|
inheritAttrs: false,
|
package/dist/components/ScalarCard/ScalarCardHeader.vue_vue_type_script_setup_true_lang.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarCardHeader.vue_vue_type_script_setup_true_lang.js","names":["$slots","_openBlock","_createBlock","ScalarCardSection","_normalizeProps","_guardReactiveProps","_unref","_withCtx","_createElementVNode","_renderSlot","_createElementBlock"],"sources":["../../../src/components/ScalarCard/ScalarCardHeader.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar card header component\n *\n * Will automatically be used as the aria-labelledby for the parent ScalarCard component\n *\n * @example\n * <ScalarCard>\n * <ScalarCardHeader>Header</ScalarCardHeader>\n * ...\n * </ScalarCard>\n */\nexport default {}\n</script>\n<script lang=\"ts\" setup>\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { useId } from 'vue'\n\nimport ScalarCardSection from './ScalarCardSection.vue'\nimport { useCardHeading } from './useCardHeading'\n\n/**\n * Scalar Card Header - Header section for cards with automatic accessibility setup\n */\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\n// Get a unique id for the heading\nconst id = useId()\n\n// Set the heading id for the card\nuseCardHeading(id)\n</script>\n<template>\n <ScalarCardSection\n v-bind=\"\n cx(\n 'scalar-card-header flex-wrap gap-y-1 leading-[22px] font-medium py-[6.75px] px-3 shrink-0',\n )\n \">\n <!-- Sized to its content so the actions only drop to their own row when the title does not fit beside them -->\n <div\n :id=\"id\"\n class=\"scalar-card-header-title min-w-0 flex-auto\">\n <slot />\n </div>\n <div\n v-if=\"$slots.actions\"\n class=\"flex\">\n <slot name=\"actions\" />\n </div>\n </ScalarCardSection>\n</template>\n"],"mappings":";;;;;;;;;;;;;;EAyBA,MAAM,EAAE,OAAO,UAAU;EAGzB,MAAM,KAAK,MAAM;EAGjB,eAAe,EAAE;;GAGf,OAAAC,UAAA,GAAAC,YAiBoBC,2BAAAC,eAAAC,mBAhBHC,MAAA,EAAA,CAAE,C;IAMjB,SAAAC,cAIM,CAJNC,mBAIM,OAAA;KAHH,IAAIF,MAAA,EAAA;KACL,OAAM;I,IACNG,WAAQ,KAAA,QAAA,SAAA,C,mBAGFT,KAAAA,OAAO,WADfC,UAAA,GAAAS,mBAIM,OAJN,YAIM,CADJD,WAAuB,KAAA,QAAA,SAAA,C"}
|
|
1
|
+
{"version":3,"file":"ScalarCardHeader.vue_vue_type_script_setup_true_lang.js","names":["$slots","_openBlock","_createBlock","ScalarCardSection","_normalizeProps","_guardReactiveProps","_unref","_withCtx","_createElementVNode","_renderSlot","_createElementBlock"],"sources":["../../../src/components/ScalarCard/ScalarCardHeader.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar card header component\n *\n * Will automatically be used as the aria-labelledby for the parent ScalarCard component\n *\n * @example\n * <ScalarCard>\n * <ScalarCardHeader>Header</ScalarCardHeader>\n * ...\n * </ScalarCard>\n */\nexport default {}\n</script>\n<script lang=\"ts\" setup>\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { useId } from 'vue'\n\nimport ScalarCardSection from './ScalarCardSection.vue'\nimport { useCardHeading } from './useCardHeading'\n\n/**\n * Scalar Card Header - Header section for cards with automatic accessibility setup\n */\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\n// Get a unique id for the heading\nconst id = useId()\n\n// Set the heading id for the card\nuseCardHeading(id)\n</script>\n<template>\n <ScalarCardSection\n v-bind=\"\n cx(\n 'scalar-card-header flex-wrap gap-y-1 leading-[22px] font-medium py-[6.75px] px-3 shrink-0',\n )\n \">\n <!-- Sized to its content so the actions only drop to their own row when the title does not fit beside them -->\n <div\n :id=\"id\"\n class=\"scalar-card-header-title min-w-0 flex-auto\">\n <slot />\n </div>\n <div\n v-if=\"$slots.actions\"\n class=\"flex max-w-full\">\n <slot name=\"actions\" />\n </div>\n </ScalarCardSection>\n</template>\n"],"mappings":";;;;;;;;;;;;;;EAyBA,MAAM,EAAE,OAAO,UAAU;EAGzB,MAAM,KAAK,MAAM;EAGjB,eAAe,EAAE;;GAGf,OAAAC,UAAA,GAAAC,YAiBoBC,2BAAAC,eAAAC,mBAhBHC,MAAA,EAAA,CAAE,C;IAMjB,SAAAC,cAIM,CAJNC,mBAIM,OAAA;KAHH,IAAIF,MAAA,EAAA;KACL,OAAM;I,IACNG,WAAQ,KAAA,QAAA,SAAA,C,mBAGFT,KAAAA,OAAO,WADfC,UAAA,GAAAS,mBAIM,OAJN,YAIM,CADJD,WAAuB,KAAA,QAAA,SAAA,C"}
|
|
@@ -18,6 +18,8 @@ declare const __VLS_export: import("vue").DefineComponent<({
|
|
|
18
18
|
lineNumbers?: boolean;
|
|
19
19
|
hideCredentials?: string | string[];
|
|
20
20
|
copy?: "always" | "hover" | false;
|
|
21
|
+
/** Show the language in the copy button for multiline code. */
|
|
22
|
+
showCopyLanguage?: boolean;
|
|
21
23
|
/** Original content to copy when the displayed content has been masked. */
|
|
22
24
|
copyContent?: string;
|
|
23
25
|
/**
|
|
@@ -41,6 +43,8 @@ declare const __VLS_export: import("vue").DefineComponent<({
|
|
|
41
43
|
lineNumbers?: boolean;
|
|
42
44
|
hideCredentials?: string | string[];
|
|
43
45
|
copy?: "always" | "hover" | false;
|
|
46
|
+
/** Show the language in the copy button for multiline code. */
|
|
47
|
+
showCopyLanguage?: boolean;
|
|
44
48
|
/** Original content to copy when the displayed content has been masked. */
|
|
45
49
|
copyContent?: string;
|
|
46
50
|
/**
|
|
@@ -68,6 +72,8 @@ declare const __VLS_export: import("vue").DefineComponent<({
|
|
|
68
72
|
lineNumbers?: boolean;
|
|
69
73
|
hideCredentials?: string | string[];
|
|
70
74
|
copy?: "always" | "hover" | false;
|
|
75
|
+
/** Show the language in the copy button for multiline code. */
|
|
76
|
+
showCopyLanguage?: boolean;
|
|
71
77
|
/** Original content to copy when the displayed content has been masked. */
|
|
72
78
|
copyContent?: string;
|
|
73
79
|
/**
|
|
@@ -91,6 +97,8 @@ declare const __VLS_export: import("vue").DefineComponent<({
|
|
|
91
97
|
lineNumbers?: boolean;
|
|
92
98
|
hideCredentials?: string | string[];
|
|
93
99
|
copy?: "always" | "hover" | false;
|
|
100
|
+
/** Show the language in the copy button for multiline code. */
|
|
101
|
+
showCopyLanguage?: boolean;
|
|
94
102
|
/** Original content to copy when the displayed content has been masked. */
|
|
95
103
|
copyContent?: string;
|
|
96
104
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarCodeBlock.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCodeBlock/ScalarCodeBlock.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarCodeBlock.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCodeBlock/ScalarCodeBlock.vue"],"names":[],"mappings":"AAmPA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAsBlD;;;;;;;;;GASG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;cAEN,MAAM,GAAG,MAAM;2BACF,MAAM;WACtB,mBAAmB,GAAG,MAAM;kBACrB,OAAO;sBACH,MAAM,GAAG,MAAM,EAAE;WAC5B,QAAQ,GAAG,OAAO,GAAG,KAAK;IACjC,+DAA+D;uBAC5C,OAAO;IAC1B,2EAA2E;kBAC7D,MAAM;IACpB;;;;OAIG;YACK,MAAM;IACd;;;OAGG;gBACS,MAAM;;IAWV,+CAA+C;aACtC,MAAM,GAAG,MAAM;;cAhCtB,MAAM,GAAG,MAAM;2BACF,MAAM;WACtB,mBAAmB,GAAG,MAAM;kBACrB,OAAO;sBACH,MAAM,GAAG,MAAM,EAAE;WAC5B,QAAQ,GAAG,OAAO,GAAG,KAAK;IACjC,+DAA+D;uBAC5C,OAAO;IAC1B,2EAA2E;kBAC7D,MAAM;IACpB;;;;OAIG;YACK,MAAM;IACd;;;OAGG;gBACS,MAAM;;IAeV;;;;OAIG;0BACmB,MAAM;;cAxC1B,MAAM,GAAG,MAAM;2BACF,MAAM;WACtB,mBAAmB,GAAG,MAAM;kBACrB,OAAO;sBACH,MAAM,GAAG,MAAM,EAAE;WAC5B,QAAQ,GAAG,OAAO,GAAG,KAAK;IACjC,+DAA+D;uBAC5C,OAAO;IAC1B,2EAA2E;kBAC7D,MAAM;IACpB;;;;OAIG;YACK,MAAM;IACd;;;OAGG;gBACS,MAAM;;IAWV,+CAA+C;aACtC,MAAM,GAAG,MAAM;;cAhCtB,MAAM,GAAG,MAAM;2BACF,MAAM;WACtB,mBAAmB,GAAG,MAAM;kBACrB,OAAO;sBACH,MAAM,GAAG,MAAM,EAAE;WAC5B,QAAQ,GAAG,OAAO,GAAG,KAAK;IACjC,+DAA+D;uBAC5C,OAAO;IAC1B,2EAA2E;kBAC7D,MAAM;IACpB;;;;OAIG;YACK,MAAM;IACd;;;OAGG;gBACS,MAAM;;IAeV;;;;OAIG;0BACmB,MAAM;kGAmMlC,CAAC"}
|
package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -45,6 +45,10 @@ var ScalarCodeBlock_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
45
45
|
type: [String, Boolean],
|
|
46
46
|
default: "hover"
|
|
47
47
|
},
|
|
48
|
+
showCopyLanguage: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: true
|
|
51
|
+
},
|
|
48
52
|
copyContent: {},
|
|
49
53
|
label: { default: "Code sample" },
|
|
50
54
|
copyLabel: {}
|
|
@@ -92,7 +96,7 @@ var ScalarCodeBlock_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
92
96
|
content: __props.copyContent ?? prettyContent.value,
|
|
93
97
|
copyLabel: __props.copyLabel,
|
|
94
98
|
lang: __props.lang,
|
|
95
|
-
showLang: !isOneLine.value
|
|
99
|
+
showLang: __props.showCopyLanguage && !isOneLine.value
|
|
96
100
|
}, {
|
|
97
101
|
backdrop: withCtx(() => [createVNode(ScalarCopyBackdrop_default, { class: normalizeClass(["scalar-code-copy-backdrop", [isOneLine.value ? "group-hocus-within/code-block:-left-0.5 -inset-y-0.75 -right-1 left-3" : "-top-1 -right-1.5"]]) }, null, 8, ["class"])]),
|
|
98
102
|
_: 1
|
package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue_vue_type_script_setup_true_lang.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarCodeBlock.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeProps","_guardReactiveProps","_unref","_createElementVNode","_normalizeClass","_createBlock","ScalarCodeBlockCopy","_withCtx","_createVNode","ScalarCopyBackdrop"],"sources":["../../../src/components/ScalarCodeBlock/ScalarCodeBlock.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { languages, registerLanguage } from '@scalar/highlight/all'\n\n/**\n * Registers every bundled grammar, once per module rather than once per block.\n *\n * `@scalar/highlight/all` already registers them when it is evaluated, so a\n * bare `import '@scalar/highlight/all'` reads like enough. It is not: that is a\n * side-effect-only import of an external package, and the library build drops\n * it from the emitted module. Storybook hid this because it compiles from\n * source, while the API reference consumes `dist` and lost highlighting\n * entirely — every block fell back to escaped, unscoped text.\n *\n * Registering from a named import keeps a binding the bundler can see used, so\n * the module survives. It lives in this block rather than in `<script setup>`\n * because setup runs for every instance, and a page of API reference renders\n * hundreds of code blocks.\n */\nregisterLanguage(...languages)\n\n/**\n * Scalar Code Block component\n *\n * Renders syntax-highlighted code using @scalar/highlight.\n * Supports line numbers, credential masking, and an optional copy button.\n * Set --scalar-code-line-height on the component or an ancestor to override its 1.4 line height.\n *\n * @example\n * <ScalarCodeBlock content=\"const x = 1\" lang=\"javascript\" />\n */\nexport default {}\n</script>\n<script lang=\"ts\" setup>\nimport { prettyPrintJson } from '@scalar/helpers/json/pretty-print-json'\nimport { syntaxHighlight } from '@scalar/highlight/compat'\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { computed, useId } from 'vue'\n\nimport ScalarCopyBackdrop from '@/components/ScalarCopy/ScalarCopyBackdrop.vue'\n\nimport { ScalarCodeBlockCopy } from '../ScalarCodeBlock'\nimport type { StandardLanguageKey } from './types'\n\ntype BaseProps = {\n content?: string | object\n prettyPrintedContent?: string\n lang?: StandardLanguageKey | string\n lineNumbers?: boolean\n hideCredentials?: string | string[]\n copy?: 'always' | 'hover' | false\n /** Original content to copy when the displayed content has been masked. */\n copyContent?: string\n /**\n * Accessible name for the code scroller. Long code scrolls inside a focusable region so\n * keyboard users can reach it, and a focusable region needs a name or screen readers announce\n * nothing when focus lands on it.\n */\n label?: string\n /**\n * Accessible name for the copy button. The visible label only reads \"Copy\" (and the language)\n * while the block is hovered, so the name has to say what is copied on its own.\n */\n copyLabel?: string\n}\n\n/**\n * Uses @scalar/highlight for syntax highlighting\n *\n * Requires at least one of content or prettyPrintedContent\n */\nconst {\n lang = 'plaintext',\n lineNumbers = false,\n copy = 'hover',\n label = 'Code sample',\n copyLabel,\n copyContent,\n content,\n prettyPrintedContent,\n hideCredentials,\n} = defineProps<\n BaseProps &\n (\n | {\n /** Raw unformatted object or string content */\n content: string | object\n }\n | {\n /**\n * Pre-pretty printed content string for better performance\n *\n * Avoids unnecessary costly re-serialization of large content\n */\n prettyPrintedContent: string\n }\n )\n>()\n\n/** Base id for the code block */\nconst id = useId()\n\n/** Formatted the content into an indented json string */\nconst prettyContent = computed(\n () => prettyPrintedContent || prettyPrintJson(content ?? ''),\n)\n\nconst highlightedCode = computed(() => {\n const html = syntaxHighlight(prettyContent.value, {\n lang: lang.trim(),\n lineNumbers: lineNumbers,\n maskCredentials: hideCredentials,\n })\n\n // Need to remove the wrapping <pre> element so we can use v-html without another wrapper\n return html.slice(5, -6)\n})\n\n/** Determine if the content is a single line */\nconst isOneLine = computed(() => !prettyContent.value.includes('\\n'))\n\nconst isContentValid = computed(() => {\n return (\n prettyContent.value !== null &&\n prettyContent.value !== 'null' &&\n prettyContent.value !== '404 Not Found'\n )\n})\n\n/** Whether the copy button is rendered on top of the code */\nconst showCopy = computed(() => copy && isContentValid.value)\n\n/**\n * A one-liner has the copy button floating over the end of the line, so the line needs room to\n * scroll clear of the button. The padding goes on the `w-fit` <pre> because browsers disagree about\n * whether trailing padding on an `overflow-x` container is scrollable.\n */\nconst reserveCopySpace = computed(() => isOneLine.value && showCopy.value)\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <div\n v-bind=\"\n cx(\n 'scalar-code-block group/code-block flex flex-col',\n 'relative bg-b-1 min-h-0 min-w-0 focus-visible:outline',\n )\n \">\n <!--\n Inherits the corners so the inset focus ring follows a rounded code block.\n Always a tab stop so code that scrolls stays reachable by keyboard (WCAG 2.1.1). A named\n group rather than a region, so every code sample does not add a landmark.\n -->\n <div\n :aria-label=\"label\"\n class=\"custom-scroll min-h-0 min-w-0 flex-1 overflow-x-auto rounded-[inherit] p-2 -outline-offset-2\"\n role=\"group\"\n tabindex=\"0\">\n <pre\n :id=\"id\"\n class=\"scalar-code-block-pre m-0 w-fit border-0 bg-transparent p-0 text-nowrap whitespace-pre\"\n :class=\"{ 'pr-6': reserveCopySpace }\"\n v-html=\"highlightedCode\" />\n </div>\n <ScalarCodeBlockCopy\n v-if=\"showCopy\"\n :aria-controls=\"id\"\n class=\"scalar-code-copy absolute\"\n :class=\"[\n isOneLine\n ? 'top-1/2 right-1 m-0 -translate-y-1/2'\n : 'top-2.5 right-2.5',\n { 'opacity-100': copy === 'always' },\n ]\"\n :content=\"copyContent ?? prettyContent\"\n :copyLabel=\"copyLabel\"\n :lang=\"lang\"\n :showLang=\"!isOneLine\">\n <template #backdrop>\n <ScalarCopyBackdrop\n class=\"scalar-code-copy-backdrop\"\n :class=\"[\n isOneLine\n ? 'group-hocus-within/code-block:-left-0.5 -inset-y-0.75 -right-1 left-3'\n : '-top-1 -right-1.5',\n ]\" />\n </template>\n </ScalarCodeBlockCopy>\n </div>\n</template>\n<style>\n@reference '../../style.css';\n@import '@scalar/highlight/compat/code.css';\n\n/** Match the pre line-box metrics to the code font so blank and highlighted lines have the same pitch. */\n.scalar-code-block-pre {\n font-family: var(--scalar-font-code);\n /* Disable ligatures so code characters remain distinct. */\n font-variant-ligatures: none;\n}\n\n/** Make the copy button label backdrop match the background */\n.scalar-code-block.bg-b-1 .scalar-code-copy-backdrop {\n @apply bg-b-1;\n}\n.scalar-code-block.bg-b-2 .scalar-code-copy-backdrop {\n @apply bg-b-2;\n}\n/**\n * A transparent block shows the surface of the card it sits in, so the label takes that color.\n * Outside a card there is nothing to match, and the label goes without a backdrop.\n */\n.scalar-code-block.bg-transparent .scalar-code-copy-backdrop {\n background: var(--scalar-card-surface, transparent);\n}\n/** Make the copy button one shade darker than the background */\n.scalar-code-block.bg-b-2 .scalar-code-copy {\n @apply bg-b-3;\n}\n/**\n * On a card's surface the button's own fill is the color of the card behind the surface, which\n * reads as a hole in a dark card. It takes the card's raised color instead, one step above the\n * surface. Outside a card the button keeps its own fill.\n */\n.scalar-code-block.bg-transparent .scalar-code-copy {\n background: var(--scalar-card-surface-raised, var(--scalar-background-2));\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,iBAAiB,GAAG,SAAS
|
|
1
|
+
{"version":3,"file":"ScalarCodeBlock.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeProps","_guardReactiveProps","_unref","_createElementVNode","_normalizeClass","_createBlock","ScalarCodeBlockCopy","_withCtx","_createVNode","ScalarCopyBackdrop"],"sources":["../../../src/components/ScalarCodeBlock/ScalarCodeBlock.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { languages, registerLanguage } from '@scalar/highlight/all'\n\n/**\n * Registers every bundled grammar, once per module rather than once per block.\n *\n * `@scalar/highlight/all` already registers them when it is evaluated, so a\n * bare `import '@scalar/highlight/all'` reads like enough. It is not: that is a\n * side-effect-only import of an external package, and the library build drops\n * it from the emitted module. Storybook hid this because it compiles from\n * source, while the API reference consumes `dist` and lost highlighting\n * entirely — every block fell back to escaped, unscoped text.\n *\n * Registering from a named import keeps a binding the bundler can see used, so\n * the module survives. It lives in this block rather than in `<script setup>`\n * because setup runs for every instance, and a page of API reference renders\n * hundreds of code blocks.\n */\nregisterLanguage(...languages)\n\n/**\n * Scalar Code Block component\n *\n * Renders syntax-highlighted code using @scalar/highlight.\n * Supports line numbers, credential masking, and an optional copy button.\n * Set --scalar-code-line-height on the component or an ancestor to override its 1.4 line height.\n *\n * @example\n * <ScalarCodeBlock content=\"const x = 1\" lang=\"javascript\" />\n */\nexport default {}\n</script>\n<script lang=\"ts\" setup>\nimport { prettyPrintJson } from '@scalar/helpers/json/pretty-print-json'\nimport { syntaxHighlight } from '@scalar/highlight/compat'\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { computed, useId } from 'vue'\n\nimport ScalarCopyBackdrop from '@/components/ScalarCopy/ScalarCopyBackdrop.vue'\n\nimport { ScalarCodeBlockCopy } from '../ScalarCodeBlock'\nimport type { StandardLanguageKey } from './types'\n\ntype BaseProps = {\n content?: string | object\n prettyPrintedContent?: string\n lang?: StandardLanguageKey | string\n lineNumbers?: boolean\n hideCredentials?: string | string[]\n copy?: 'always' | 'hover' | false\n /** Show the language in the copy button for multiline code. */\n showCopyLanguage?: boolean\n /** Original content to copy when the displayed content has been masked. */\n copyContent?: string\n /**\n * Accessible name for the code scroller. Long code scrolls inside a focusable region so\n * keyboard users can reach it, and a focusable region needs a name or screen readers announce\n * nothing when focus lands on it.\n */\n label?: string\n /**\n * Accessible name for the copy button. The visible label only reads \"Copy\" (and the language)\n * while the block is hovered, so the name has to say what is copied on its own.\n */\n copyLabel?: string\n}\n\n/**\n * Uses @scalar/highlight for syntax highlighting\n *\n * Requires at least one of content or prettyPrintedContent\n */\nconst {\n lang = 'plaintext',\n lineNumbers = false,\n copy = 'hover',\n showCopyLanguage = true,\n label = 'Code sample',\n copyLabel,\n copyContent,\n content,\n prettyPrintedContent,\n hideCredentials,\n} = defineProps<\n BaseProps &\n (\n | {\n /** Raw unformatted object or string content */\n content: string | object\n }\n | {\n /**\n * Pre-pretty printed content string for better performance\n *\n * Avoids unnecessary costly re-serialization of large content\n */\n prettyPrintedContent: string\n }\n )\n>()\n\n/** Base id for the code block */\nconst id = useId()\n\n/** Formatted the content into an indented json string */\nconst prettyContent = computed(\n () => prettyPrintedContent || prettyPrintJson(content ?? ''),\n)\n\nconst highlightedCode = computed(() => {\n const html = syntaxHighlight(prettyContent.value, {\n lang: lang.trim(),\n lineNumbers: lineNumbers,\n maskCredentials: hideCredentials,\n })\n\n // Need to remove the wrapping <pre> element so we can use v-html without another wrapper\n return html.slice(5, -6)\n})\n\n/** Determine if the content is a single line */\nconst isOneLine = computed(() => !prettyContent.value.includes('\\n'))\n\nconst isContentValid = computed(() => {\n return (\n prettyContent.value !== null &&\n prettyContent.value !== 'null' &&\n prettyContent.value !== '404 Not Found'\n )\n})\n\n/** Whether the copy button is rendered on top of the code */\nconst showCopy = computed(() => copy && isContentValid.value)\n\n/**\n * A one-liner has the copy button floating over the end of the line, so the line needs room to\n * scroll clear of the button. The padding goes on the `w-fit` <pre> because browsers disagree about\n * whether trailing padding on an `overflow-x` container is scrollable.\n */\nconst reserveCopySpace = computed(() => isOneLine.value && showCopy.value)\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <div\n v-bind=\"\n cx(\n 'scalar-code-block group/code-block flex flex-col',\n 'relative bg-b-1 min-h-0 min-w-0 focus-visible:outline',\n )\n \">\n <!--\n Inherits the corners so the inset focus ring follows a rounded code block.\n Always a tab stop so code that scrolls stays reachable by keyboard (WCAG 2.1.1). A named\n group rather than a region, so every code sample does not add a landmark.\n -->\n <div\n :aria-label=\"label\"\n class=\"custom-scroll min-h-0 min-w-0 flex-1 overflow-x-auto rounded-[inherit] p-2 -outline-offset-2\"\n role=\"group\"\n tabindex=\"0\">\n <pre\n :id=\"id\"\n class=\"scalar-code-block-pre m-0 w-fit border-0 bg-transparent p-0 text-nowrap whitespace-pre\"\n :class=\"{ 'pr-6': reserveCopySpace }\"\n v-html=\"highlightedCode\" />\n </div>\n <ScalarCodeBlockCopy\n v-if=\"showCopy\"\n :aria-controls=\"id\"\n class=\"scalar-code-copy absolute\"\n :class=\"[\n isOneLine\n ? 'top-1/2 right-1 m-0 -translate-y-1/2'\n : 'top-2.5 right-2.5',\n { 'opacity-100': copy === 'always' },\n ]\"\n :content=\"copyContent ?? prettyContent\"\n :copyLabel=\"copyLabel\"\n :lang=\"lang\"\n :showLang=\"showCopyLanguage && !isOneLine\">\n <template #backdrop>\n <ScalarCopyBackdrop\n class=\"scalar-code-copy-backdrop\"\n :class=\"[\n isOneLine\n ? 'group-hocus-within/code-block:-left-0.5 -inset-y-0.75 -right-1 left-3'\n : '-top-1 -right-1.5',\n ]\" />\n </template>\n </ScalarCodeBlockCopy>\n </div>\n</template>\n<style>\n@reference '../../style.css';\n@import '@scalar/highlight/compat/code.css';\n\n/** Match the pre line-box metrics to the code font so blank and highlighted lines have the same pitch. */\n.scalar-code-block-pre {\n font-family: var(--scalar-font-code);\n /* Disable ligatures so code characters remain distinct. */\n font-variant-ligatures: none;\n}\n\n/** Make the copy button label backdrop match the background */\n.scalar-code-block.bg-b-1 .scalar-code-copy-backdrop {\n @apply bg-b-1;\n}\n.scalar-code-block.bg-b-2 .scalar-code-copy-backdrop {\n @apply bg-b-2;\n}\n/**\n * A transparent block shows the surface of the card it sits in, so the label takes that color.\n * Outside a card there is nothing to match, and the label goes without a backdrop.\n */\n.scalar-code-block.bg-transparent .scalar-code-copy-backdrop {\n background: var(--scalar-card-surface, transparent);\n}\n/** Make the copy button one shade darker than the background */\n.scalar-code-block.bg-b-2 .scalar-code-copy {\n @apply bg-b-3;\n}\n/**\n * On a card's surface the button's own fill is the color of the card behind the surface, which\n * reads as a hole in a dark card. It takes the card's raised color instead, one step above the\n * surface. Outside a card the button keeps its own fill.\n */\n.scalar-code-block.bg-transparent .scalar-code-copy {\n background: var(--scalar-card-surface-raised, var(--scalar-background-2));\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,iBAAiB,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoF7B,MAAM,KAAK,MAAM;;EAGjB,MAAM,gBAAgB,eACd,QAAA,wBAAwB,gBAAgB,QAAA,WAAW,EAAE,CAC7D;EAEA,MAAM,kBAAkB,eAAe;GAQrC,OAPa,gBAAgB,cAAc,OAAO;IAChD,MAAM,QAAA,KAAK,KAAK;IAChB,aAAa,QAAA;IACb,iBAAiB,QAAA;GACnB,CAGO,CAAA,CAAK,MAAM,GAAG,EAAE;EACzB,CAAC;;EAGD,MAAM,YAAY,eAAe,CAAC,cAAc,MAAM,SAAS,IAAI,CAAC;EAEpE,MAAM,iBAAiB,eAAe;GACpC,OACE,cAAc,UAAU,QACxB,cAAc,UAAU,UACxB,cAAc,UAAU;EAE5B,CAAC;;EAGD,MAAM,WAAW,eAAe,QAAA,QAAQ,eAAe,KAAK;;;;;;EAO5D,MAAM,mBAAmB,eAAe,UAAU,SAAS,SAAS,KAAK;EAGzE,MAAM,EAAE,OAAO,UAAU;;GAGvB,OAAAA,UAAA,GAAAC,mBA+CM,OAAAC,eAAAC,mBA9CWC,MAAA,EAAA,CAAE,C,iHAWjBC,mBAUM,OAAA;IATH,cAAY,QAAA;IACb,OAAM;IACN,MAAK;IACL,UAAS;G,IACTA,mBAI6B,OAAA;IAH1B,IAAID,MAAA,EAAA;IACL,OAAKE,eAAA,CAAC,0FAAwF,EAAA,QAC5E,iBAAA,MAAgB,CAAA,CAAA;IAClC,WAAQ,gBAAA;G,2CAGJ,SAAA,SADRN,UAAA,GAAAO,YAuBsBH,MAAAI,2BAAA,GAAA;;IArBnB,iBAAeJ,MAAA,EAAA;IAChB,OAAKE,eAAA,CAAC,6BAA2B,CACf,UAAA,Q,8DAAuH,EAAA,eAAA,QAAA,SAAI,SAAA,C;IAM5I,SAAS,QAAA,eAAe,cAAA;IACxB,WAAW,QAAA;IACX,MAAM,QAAA;IACN,UAAU,QAAA,oBAAgB,CAAK,UAAA;;IACrB,UAAQG,cAOV,CANPC,YAMOC,4BAAA,EALL,OAAKL,eAAA,CAAC,6BAA2B,CACX,UAAA,Q"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarCodeBlockCopy.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarCodeBlockCopy.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue"],"names":[],"mappings":"AA2HA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAGlD;;;;;;;;GAQG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;IAEhB,yCAAyC;eAC9B,OAAO;IAClB,mCAAmC;aAC1B,MAAM,GAAG,MAAM;IACxB,iCAAiC;WAC1B,mBAAmB,GAAG,MAAM;IACnC;;;;;;OAMG;gBACS,MAAM;;aA+CT,OAAO;;;;IA5DhB,yCAAyC;eAC9B,OAAO;IAClB,mCAAmC;aAC1B,MAAM,GAAG,MAAM;IACxB,iCAAiC;WAC1B,mBAAmB,GAAG,MAAM;IACnC;;;;;;OAMG;gBACS,MAAM;;aA+CT,OAAO;;;;eAyGH,CAAC,KAAK,IAAiB,KAAK,GAAG;EAU1C,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
package/dist/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -26,12 +26,11 @@ var ScalarCodeBlockCopy_vue_vue_type_script_setup_true_lang_default = /*@__PURE_
|
|
|
26
26
|
const contentToCopy = computed(() => {
|
|
27
27
|
return typeof __props.content === "string" ? __props.content : JSON.stringify(__props.content, null, 2);
|
|
28
28
|
});
|
|
29
|
-
|
|
30
|
-
const isStandardLanguage = (lang) => lang in LANGUAGE_LABELS;
|
|
29
|
+
const hasLanguageLabel = (lang) => Object.hasOwn(LANGUAGE_LABELS, lang);
|
|
31
30
|
/** The human readable language name shown next to the copy label */
|
|
32
31
|
const langLabel = computed(() => {
|
|
33
32
|
if (!__props.lang) return;
|
|
34
|
-
return
|
|
33
|
+
return hasLanguageLabel(__props.lang) ? LANGUAGE_LABELS[__props.lang] : __props.lang;
|
|
35
34
|
});
|
|
36
35
|
/**
|
|
37
36
|
* Names the button in every state, including while its visible label is `display: none`.
|
|
@@ -58,7 +57,7 @@ var ScalarCodeBlockCopy_vue_vue_type_script_setup_true_lang_default = /*@__PURE_
|
|
|
58
57
|
name: "copy",
|
|
59
58
|
fn: withCtx(() => [createElementVNode("span", _hoisted_1, [__props.showLang ? (openBlock(), createElementBlock("span", {
|
|
60
59
|
key: 0,
|
|
61
|
-
class: normalizeClass(["group-hocus/copy-button:sr-only", { capitalize: !
|
|
60
|
+
class: normalizeClass(["group-hocus/copy-button:sr-only", { capitalize: !hasLanguageLabel(__props.lang) }])
|
|
62
61
|
}, toDisplayString(langLabel.value), 3)) : createCommentVNode("", true), createElementVNode("span", { class: normalizeClass({ "group-hocus/copy-button:not-sr-only sr-only": __props.showLang }) }, "Copy", 2)])]),
|
|
63
62
|
key: "0"
|
|
64
63
|
} : void 0]), 1040, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarCodeBlockCopy.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createBlock","_unref","ScalarCopy","_mergeProps","_withCtx","_renderSlot","_createElementVNode","_createElementBlock","_normalizeClass","_toDisplayString"],"sources":["../../../src/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Code Block Copy button\n *\n * Displays a copy-to-clipboard button with an optional language label.\n * Used internally by ScalarCodeBlock.\n *\n * @example\n * <ScalarCodeBlockCopy content=\"const x = 1\" lang=\"javascript\" />\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { computed } from 'vue'\n\nimport { ScalarCopy } from '@/components/ScalarCopy'\n\nimport { LANGUAGE_LABELS } from './constants'\nimport type { StandardLanguageKey } from './types'\n\nconst { content, lang, showLang, copyLabel } = defineProps<{\n /** Whether to show the language label */\n showLang?: boolean\n /** Content to copy to clipboard */\n content: string | object\n /** Language of the code block */\n lang?: StandardLanguageKey | string\n /**\n * Accessible name for the copy button.\n *\n * The visible label is hidden until the code block is hovered, so without an explicit name\n * screen readers announce an empty button (found by an accessibility audit). Defaults to\n * \"Copy <language> code\" so the name contains every word the button can show.\n */\n copyLabel?: string\n}>()\n\nconst copied = defineModel<boolean>('copied', { default: false })\n\n/** Handles the copy button click */\nconst contentToCopy = computed<string>(() => {\n return typeof content === 'string'\n ? content\n : JSON.stringify(content, null, 2)\n})\n\
|
|
1
|
+
{"version":3,"file":"ScalarCodeBlockCopy.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createBlock","_unref","ScalarCopy","_mergeProps","_withCtx","_renderSlot","_createElementVNode","_createElementBlock","_normalizeClass","_toDisplayString"],"sources":["../../../src/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Code Block Copy button\n *\n * Displays a copy-to-clipboard button with an optional language label.\n * Used internally by ScalarCodeBlock.\n *\n * @example\n * <ScalarCodeBlockCopy content=\"const x = 1\" lang=\"javascript\" />\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { computed } from 'vue'\n\nimport { ScalarCopy } from '@/components/ScalarCopy'\n\nimport { LANGUAGE_LABELS } from './constants'\nimport type { StandardLanguageKey } from './types'\n\nconst { content, lang, showLang, copyLabel } = defineProps<{\n /** Whether to show the language label */\n showLang?: boolean\n /** Content to copy to clipboard */\n content: string | object\n /** Language of the code block */\n lang?: StandardLanguageKey | string\n /**\n * Accessible name for the copy button.\n *\n * The visible label is hidden until the code block is hovered, so without an explicit name\n * screen readers announce an empty button (found by an accessibility audit). Defaults to\n * \"Copy <language> code\" so the name contains every word the button can show.\n */\n copyLabel?: string\n}>()\n\nconst copied = defineModel<boolean>('copied', { default: false })\n\n/** Handles the copy button click */\nconst contentToCopy = computed<string>(() => {\n return typeof content === 'string'\n ? content\n : JSON.stringify(content, null, 2)\n})\n\nconst hasLanguageLabel = (lang: string): lang is keyof typeof LANGUAGE_LABELS =>\n Object.hasOwn(LANGUAGE_LABELS, lang)\n\n/** The human readable language name shown next to the copy label */\nconst langLabel = computed<string | undefined>(() => {\n if (!lang) {\n return undefined\n }\n return hasLanguageLabel(lang) ? LANGUAGE_LABELS[lang] : lang\n})\n\n/**\n * Names the button in every state, including while its visible label is `display: none`.\n * The language is included only when it is shown, so the name always contains the visible text\n * (WCAG 2.5.3) and request and response buttons on one page get distinct names.\n */\nconst accessibleName = computed<string>(() => {\n if (copyLabel) {\n return copyLabel\n }\n return showLang && langLabel.value\n ? `Copy ${langLabel.value} code`\n : 'Copy code'\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n\n<template>\n <!-- The aria-label comes first so a consumer supplied aria-label attr still wins in the merge -->\n <ScalarCopy\n v-model:copied=\"copied\"\n :aria-label=\"accessibleName\"\n :content=\"contentToCopy\"\n placement=\"left\"\n showLabel\n v-bind=\"{\n ...cx(\n copied\n ? 'opacity-100'\n : 'opacity-0 group-hocus-within/code-block:opacity-100',\n ),\n }\">\n <template\n v-if=\"lang\"\n #copy>\n <span class=\"group-hocus-within/code-block:inline hidden\">\n <span\n v-if=\"showLang\"\n class=\"group-hocus/copy-button:sr-only\"\n :class=\"{ capitalize: !hasLanguageLabel(lang) }\">\n {{ langLabel }}\n </span>\n <span\n :class=\"{\n 'group-hocus/copy-button:not-sr-only sr-only': showLang,\n }\"\n >Copy</span\n >\n </span>\n </template>\n <template #backdrop>\n <slot name=\"backdrop\" />\n </template>\n </ScalarCopy>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EAsCA,MAAM,SAASA,SAAoB,SAAC,QAA4B;;EAGhE,MAAM,gBAAgB,eAAuB;GAC3C,OAAO,OAAO,QAAA,YAAY,WACtB,QAAA,UACA,KAAK,UAAU,QAAA,SAAS,MAAM,CAAC;EACrC,CAAC;EAED,MAAM,oBAAoB,SACxB,OAAO,OAAO,iBAAiB,IAAI;;EAGrC,MAAM,YAAY,eAAmC;GACnD,IAAI,CAAC,QAAA,MACH;GAEF,OAAO,iBAAiB,QAAA,IAAI,IAAI,gBAAgB,QAAA,QAAQ,QAAA;EAC1D,CAAC;;;;;;EAOD,MAAM,iBAAiB,eAAuB;GAC5C,IAAI,QAAA,WACF,OAAO,QAAA;GAET,OAAO,QAAA,YAAY,UAAU,QACzB,QAAQ,UAAU,MAAM,SACxB;EACN,CAAC;EAGD,MAAM,EAAE,OAAO,UAAU;;GAKvB,OAAAC,UAAA,GAAAC,YAkCaC,MAAAC,kBAAA,GAlCbC,WAkCa;IAjCH,QAAQ,OAAA;IAAA,mBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,OAAM,QAAA;IACrB,cAAY,eAAA;IACZ,SAAS,cAAA;IACV,WAAU;IACV,WAAA;G,KACmB,GAAAF,MAAA,EAAA,CAAE,CAAU,OAAA,Q;IAyBpB,UAAQG,cACO,CAAxBC,WAAwB,KAAA,QAAA,UAAA,C;;G,IAlBlB,QAAA,O;IACL,MAAA;IACD,IAAAD,cAaO,CAbPE,mBAaO,QAbP,YAaO,CAXG,QAAA,YADRP,UAAA,GAAAQ,mBAKO,QAAA;;KAHL,OAAKC,eAAA,CAAC,mCAAiC,EAAA,YAAA,CAChB,iBAAiB,QAAA,IAAI,EAAA,CAAA,CAAA;IACzC,GAAAC,gBAAA,UAAA,KAAS,GAAA,CAAA,K,8BAEdH,mBAKC,QAAA,EAJE,OAAKE,eAAA,EAA+D,+CAAA,QAAA,S,GAGpE,GAAA,QAAI,CAAA,C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Display labels for code block languages */
|
|
2
2
|
export declare const LANGUAGE_LABELS: {
|
|
3
3
|
readonly bash: "Bash";
|
|
4
4
|
readonly c: "C";
|
|
@@ -25,6 +25,7 @@ export declare const LANGUAGE_LABELS: {
|
|
|
25
25
|
readonly julia: "Julia";
|
|
26
26
|
readonly kotlin: "Kotlin";
|
|
27
27
|
readonly less: "Less";
|
|
28
|
+
readonly log: "Log";
|
|
28
29
|
readonly lua: "Lua";
|
|
29
30
|
readonly makefile: "Makefile";
|
|
30
31
|
readonly markdown: "Markdown";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCodeBlock/constants.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCodeBlock/constants.ts"],"names":[],"mappings":"AAEA,8CAA8C;AAC9C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDoC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/components/ScalarCodeBlock/constants.ts
|
|
2
|
-
/**
|
|
2
|
+
/** Display labels for code block languages */
|
|
3
3
|
var LANGUAGE_LABELS = {
|
|
4
4
|
bash: "Bash",
|
|
5
5
|
c: "C",
|
|
@@ -26,6 +26,7 @@ var LANGUAGE_LABELS = {
|
|
|
26
26
|
julia: "Julia",
|
|
27
27
|
kotlin: "Kotlin",
|
|
28
28
|
less: "Less",
|
|
29
|
+
log: "Log",
|
|
29
30
|
lua: "Lua",
|
|
30
31
|
makefile: "Makefile",
|
|
31
32
|
markdown: "Markdown",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../../../src/components/ScalarCodeBlock/constants.ts"],"sourcesContent":["import type { StandardLanguageKey } from './types'\n\n/**
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../src/components/ScalarCodeBlock/constants.ts"],"sourcesContent":["import type { StandardLanguageKey } from './types'\n\n/** Display labels for code block languages */\nexport const LANGUAGE_LABELS = {\n bash: 'Bash',\n c: 'C',\n clojure: 'Clojure',\n cpp: 'C++',\n csharp: 'C#',\n css: 'CSS',\n curl: 'cURL',\n dart: 'Dart',\n diff: 'Diff',\n docker: 'Docker',\n dockerfile: 'Dockerfile',\n elixir: 'Elixir',\n fsharp: 'F#',\n go: 'Go',\n graphql: 'GraphQL',\n haskell: 'Haskell',\n html: 'HTML',\n http: 'HTTP',\n ini: 'INI',\n java: 'Java',\n javascript: 'JavaScript',\n json: 'JSON',\n julia: 'Julia',\n kotlin: 'Kotlin',\n less: 'Less',\n log: 'Log',\n lua: 'Lua',\n makefile: 'Makefile',\n markdown: 'Markdown',\n matlab: 'MATLAB',\n mojo: 'Mojo',\n nginx: 'Nginx',\n objectivec: 'Objective-C',\n ocaml: 'OCaml',\n perl: 'Perl',\n php: 'PHP',\n plaintext: 'Plain Text',\n powershell: 'PowerShell',\n properties: 'Properties',\n python: 'Python',\n r: 'R',\n ruby: 'Ruby',\n rust: 'Rust',\n scala: 'Scala',\n scss: 'SCSS',\n shell: 'Shell',\n sql: 'SQL',\n swift: 'Swift',\n toml: 'TOML',\n typescript: 'TypeScript',\n xml: 'XML',\n yaml: 'YAML',\n} as const satisfies Record<StandardLanguageKey | 'log', string>\n"],"mappings":";;AAGA,IAAa,kBAAkB;CAC7B,MAAM;CACN,GAAG;CACH,SAAS;CACT,KAAK;CACL,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;CACN,MAAM;CACN,QAAQ;CACR,YAAY;CACZ,QAAQ;CACR,QAAQ;CACR,IAAI;CACJ,SAAS;CACT,SAAS;CACT,MAAM;CACN,MAAM;CACN,KAAK;CACL,MAAM;CACN,YAAY;CACZ,MAAM;CACN,OAAO;CACP,QAAQ;CACR,MAAM;CACN,KAAK;CACL,KAAK;CACL,UAAU;CACV,UAAU;CACV,QAAQ;CACR,MAAM;CACN,OAAO;CACP,YAAY;CACZ,OAAO;CACP,MAAM;CACN,KAAK;CACL,WAAW;CACX,YAAY;CACZ,YAAY;CACZ,QAAQ;CACR,GAAG;CACH,MAAM;CACN,MAAM;CACN,OAAO;CACP,MAAM;CACN,OAAO;CACP,KAAK;CACL,OAAO;CACP,MAAM;CACN,YAAY;CACZ,KAAK;CACL,MAAM;AACR"}
|
|
@@ -4,7 +4,14 @@ var ScalarColorModeToggleIcon_vue_vue_type_script_setup_true_lang_default = /*@_
|
|
|
4
4
|
inheritAttrs: false,
|
|
5
5
|
__name: "ScalarColorModeToggleIcon",
|
|
6
6
|
props: {
|
|
7
|
-
is: {
|
|
7
|
+
is: {
|
|
8
|
+
type: [
|
|
9
|
+
String,
|
|
10
|
+
Object,
|
|
11
|
+
Function
|
|
12
|
+
],
|
|
13
|
+
default: "button"
|
|
14
|
+
},
|
|
8
15
|
mode: { default: "light" }
|
|
9
16
|
},
|
|
10
17
|
setup(__props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarColorModeToggleIcon.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_resolveDynamicComponent","_mergeProps","_unref","_withCtx","_createElementVNode"],"sources":["../../../src/components/ScalarColorModeToggle/ScalarColorModeToggleIcon.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { computed, type Component } from 'vue'\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type ScalarColorModeToggle from './ScalarColorModeToggle.vue'\n\n/**\n * Scalar Color Mode Toggle Icon component\n *\n * An icon that toggles between a sun and moon.\n *\n * If you need a toggle that is aware of and sets color mode,\n * you want {@link ScalarColorModeToggle} instead.\n *\n * @example\n * <ScalarColorModeToggleIcon v-model=\"isDarkMode\" />\n */\nexport default {}\n</script>\n<script lang=\"ts\" setup>\nconst { is = 'button', mode = 'light' } = defineProps<{\n /** The element or component this component should render as. */\n is?: string | Component\n /** Whether the toggle is a sun or moon icon */\n mode?: 'light' | 'dark'\n}>()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\nconst ariaLabel = computed<string>(() =>\n mode === 'dark' ? 'Set light mode' : 'Set dark mode',\n)\n</script>\n<template>\n <!-- Icon -->\n <component\n :is=\"is\"\n :aria-label=\"ariaLabel\"\n :class=\"`toggle-icon-${mode}`\"\n :type=\"is === 'button' ? 'button' : undefined\"\n v-bind=\"cx('size-3 flex items-center justify-center text-c-1')\">\n <span class=\"toggle-icon-sun-ray\" />\n <span class=\"toggle-icon-sun-ray\" />\n <span class=\"toggle-icon-sun-ray\" />\n <span class=\"toggle-icon-sun-ray\" />\n <span class=\"toggle-icon-ellipse\">\n <span class=\"toggle-icon-moon-mask\" />\n </span>\n </component>\n</template>\n<style scoped>\n.toggle-icon-ellipse {\n width: 7px;\n height: 7px;\n border-radius: 50%;\n box-shadow: inset 0 0 0 1px currentColor;\n overflow: hidden;\n position: relative;\n background: var(--scalar-background-1);\n display: inline-block;\n transition:\n width 0.3s ease-in-out,\n height 0.3s ease-in-out;\n}\n.toggle-icon-moon-mask {\n width: 100%;\n height: 100%;\n border: 1px solid currentColor;\n display: block;\n left: 2.5px;\n bottom: 2.5px;\n position: absolute;\n border-radius: 50%;\n background: var(--scalar-background-1);\n transition: transform 0.3s ease-in-out;\n transform: translate3d(4px, -4px, 0);\n}\n.toggle-icon-sun-ray {\n width: 12px;\n height: 1px;\n border-radius: 8px;\n background: currentColor;\n position: absolute;\n transition: transform 0.3s ease-in-out;\n}\n.toggle-icon-sun-ray:nth-of-type(2) {\n transform: rotate(90deg);\n}\n.toggle-icon-sun-ray:nth-of-type(3) {\n transform: rotate(45deg);\n}\n.toggle-icon-sun-ray:nth-of-type(4) {\n transform: rotate(-45deg);\n}\n.toggle-icon-dark .toggle-icon-ellipse {\n width: 10px;\n height: 10px;\n mask-image: radial-gradient(\n circle at bottom left,\n pink 10px,\n transparent 12px\n );\n}\n.toggle-icon-dark .toggle-icon-sun-ray {\n transform: scale(0);\n}\n.toggle-icon-dark .toggle-icon-moon-mask {\n transform: translate3d(0, 0, 0);\n}\n</style>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarColorModeToggleIcon.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_resolveDynamicComponent","_mergeProps","_unref","_withCtx","_createElementVNode"],"sources":["../../../src/components/ScalarColorModeToggle/ScalarColorModeToggleIcon.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { computed, type Component } from 'vue'\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type ScalarColorModeToggle from './ScalarColorModeToggle.vue'\n\n/**\n * Scalar Color Mode Toggle Icon component\n *\n * An icon that toggles between a sun and moon.\n *\n * If you need a toggle that is aware of and sets color mode,\n * you want {@link ScalarColorModeToggle} instead.\n *\n * @example\n * <ScalarColorModeToggleIcon v-model=\"isDarkMode\" />\n */\nexport default {}\n</script>\n<script lang=\"ts\" setup>\nconst { is = 'button', mode = 'light' } = defineProps<{\n /** The element or component this component should render as. */\n is?: string | Component\n /** Whether the toggle is a sun or moon icon */\n mode?: 'light' | 'dark'\n}>()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\nconst ariaLabel = computed<string>(() =>\n mode === 'dark' ? 'Set light mode' : 'Set dark mode',\n)\n</script>\n<template>\n <!-- Icon -->\n <component\n :is=\"is\"\n :aria-label=\"ariaLabel\"\n :class=\"`toggle-icon-${mode}`\"\n :type=\"is === 'button' ? 'button' : undefined\"\n v-bind=\"cx('size-3 flex items-center justify-center text-c-1')\">\n <span class=\"toggle-icon-sun-ray\" />\n <span class=\"toggle-icon-sun-ray\" />\n <span class=\"toggle-icon-sun-ray\" />\n <span class=\"toggle-icon-sun-ray\" />\n <span class=\"toggle-icon-ellipse\">\n <span class=\"toggle-icon-moon-mask\" />\n </span>\n </component>\n</template>\n<style scoped>\n.toggle-icon-ellipse {\n width: 7px;\n height: 7px;\n border-radius: 50%;\n box-shadow: inset 0 0 0 1px currentColor;\n overflow: hidden;\n position: relative;\n background: var(--scalar-background-1);\n display: inline-block;\n transition:\n width 0.3s ease-in-out,\n height 0.3s ease-in-out;\n}\n.toggle-icon-moon-mask {\n width: 100%;\n height: 100%;\n border: 1px solid currentColor;\n display: block;\n left: 2.5px;\n bottom: 2.5px;\n position: absolute;\n border-radius: 50%;\n background: var(--scalar-background-1);\n transition: transform 0.3s ease-in-out;\n transform: translate3d(4px, -4px, 0);\n}\n.toggle-icon-sun-ray {\n width: 12px;\n height: 1px;\n border-radius: 8px;\n background: currentColor;\n position: absolute;\n transition: transform 0.3s ease-in-out;\n}\n.toggle-icon-sun-ray:nth-of-type(2) {\n transform: rotate(90deg);\n}\n.toggle-icon-sun-ray:nth-of-type(3) {\n transform: rotate(45deg);\n}\n.toggle-icon-sun-ray:nth-of-type(4) {\n transform: rotate(-45deg);\n}\n.toggle-icon-dark .toggle-icon-ellipse {\n width: 10px;\n height: 10px;\n mask-image: radial-gradient(\n circle at bottom left,\n pink 10px,\n transparent 12px\n );\n}\n.toggle-icon-dark .toggle-icon-sun-ray {\n transform: scale(0);\n}\n.toggle-icon-dark .toggle-icon-moon-mask {\n transform: translate3d(0, 0, 0);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;EA6BA,MAAM,EAAE,OAAO,UAAU;EAEzB,MAAM,YAAY,eAChB,QAAA,SAAS,SAAS,mBAAmB,eACvC;;GAIE,OAAAA,UAAA,GAAAC,YAaYC,wBAZL,QAAA,EAAE,GADTC,WAaY;IAXT,cAAY,UAAA;IACZ,OAAK,eAAiB,QAAA;IACtB,MAAM,QAAA,OAAE,WAAA,WAA2B,KAAA;GAC5B,GAAAC,MAAA,EAAA,CAAE,CAAA,kDAAA,CAAA,GAAA;IACV,SAAAC,cAAoC,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA;KAApCC,mBAAoC,QAAA,EAA9B,OAAM,sBAAqB,GAAA,MAAA,EAAA;KACjCA,mBAAoC,QAAA,EAA9B,OAAM,sBAAqB,GAAA,MAAA,EAAA;KACjCA,mBAAoC,QAAA,EAA9B,OAAM,sBAAqB,GAAA,MAAA,EAAA;KACjCA,mBAAoC,QAAA,EAA9B,OAAM,sBAAqB,GAAA,MAAA,EAAA;KACjCA,mBAEO,QAAA,EAFD,OAAM,sBAAqB,GAAA,CAC/BA,mBAAsC,QAAA,EAAhC,OAAM,wBAAuB,CAAA,C"}
|
package/dist/components/ScalarCombobox/ScalarCombobox.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -17,7 +17,11 @@ var ScalarCombobox_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
|
|
|
17
17
|
Function
|
|
18
18
|
] },
|
|
19
19
|
resize: { type: Boolean },
|
|
20
|
-
target: {
|
|
20
|
+
target: { type: [
|
|
21
|
+
String,
|
|
22
|
+
Object,
|
|
23
|
+
Function
|
|
24
|
+
] },
|
|
21
25
|
middleware: {},
|
|
22
26
|
teleport: { type: [Boolean, String] }
|
|
23
27
|
}, {
|
package/dist/components/ScalarCombobox/ScalarCombobox.vue_vue_type_script_setup_true_lang.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarCombobox.vue_vue_type_script_setup_true_lang.js","names":["$slots","_useModel","_openBlock","_createBlock","ComboboxPopover","_withCtx","_renderSlot","_createVNode","ComboboxOptions","_normalizeProps","_guardReactiveProps"],"sources":["../../../src/components/ScalarCombobox/ScalarCombobox.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Combobox component\n *\n * A searchable select input with support for filtering, option groups,\n * and custom option rendering.\n *\n * @example\n * <ScalarCombobox v-model=\"selected\" :options=\"options\">\n * <ScalarButton>{{ selected?.label ?? 'Select' }}</ScalarButton>\n * </ScalarCombobox>\n */\nexport default {}\n</script>\n\n<!-- prettier-ignore-attribute generic -->\n<script\n setup\n lang=\"ts\"\n generic=\"O extends Option = Option, G extends OptionGroup<O> = OptionGroup<O>\">\nimport type { ScalarFloatingOptions } from '../ScalarFloating'\nimport type { LoadingState } from '../ScalarLoading'\nimport ComboboxOptions from './ScalarComboboxOptions.vue'\nimport ComboboxPopover from './ScalarComboboxPopover.vue'\nimport type {\n ComboboxEmits,\n ComboboxSlots,\n FilterFunction,\n Option,\n OptionGroup,\n OptionsOrGroups,\n} from './types'\n\ndefineProps<\n {\n /** The options to display in the combobox */\n options: OptionsOrGroups<O, G>\n /** The placeholder text to display in the combobox */\n placeholder?: string\n /** An accessible label for the search input */\n inputLabel?: string\n /** The message to display when filtering returns no options */\n noResults?: string\n /** A function to filter the options based on a query,\n * if not provided, the options will be filtered by option label\n *\n * Pass `(_, options) => options` when the caller searches the options itself (e.g. on a\n * server) using the `query` model, so results the server already matched are shown as given.\n *\n * @see {@link FilterFunction} for more information\n */\n filterFn?: FilterFunction<O, G>\n /**\n * The loading state of the options, see `useLoadingState`\n *\n * Shows a spinner at the end of the search input while active, or an X when the state is\n * invalidated (e.g. a failed request).\n */\n loader?: LoadingState\n } & ScalarFloatingOptions\n>()\n\nconst emit = defineEmits<ComboboxEmits>()\n\nconst model = defineModel<O>()\n\n/** The search query, bind it to search the options yourself */\nconst query = defineModel<string>('query', { default: '' })\n\ndefineSlots<ComboboxSlots<O, G>>()\n</script>\n<template>\n <ComboboxPopover\n :middleware\n :offset\n :placement=\"placement ?? 'bottom-start'\"\n :resize\n :target\n :teleport>\n <template #default=\"{ open }\">\n <slot :open />\n </template>\n <template #popover=\"{ open, close }\">\n <ComboboxOptions\n v-model:query=\"query\"\n :close\n :filterFn\n :inputLabel\n :loader\n :modelValue=\"model ? [model] : []\"\n :noResults\n :open\n :options\n :placeholder\n @add=\"() => (close(), emit('add'))\"\n @update:modelValue=\"(v) => (close(), (model = v[0]))\">\n <!-- Pass through the combobox slots -->\n <template\n v-if=\"$slots['search-end']\"\n #search-end=\"props\">\n <slot\n name=\"search-end\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"$slots.option\"\n #option=\"props\">\n <slot\n name=\"option\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"$slots.group\"\n #group=\"props\">\n <slot\n name=\"group\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"$slots.add\"\n #add=\"props\">\n <slot\n name=\"add\"\n v-bind=\"props\" />\n </template>\n </ComboboxOptions>\n </template>\n </ComboboxPopover>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarCombobox.vue_vue_type_script_setup_true_lang.js","names":["$slots","_useModel","_openBlock","_createBlock","ComboboxPopover","_withCtx","_renderSlot","_createVNode","ComboboxOptions","_normalizeProps","_guardReactiveProps"],"sources":["../../../src/components/ScalarCombobox/ScalarCombobox.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Combobox component\n *\n * A searchable select input with support for filtering, option groups,\n * and custom option rendering.\n *\n * @example\n * <ScalarCombobox v-model=\"selected\" :options=\"options\">\n * <ScalarButton>{{ selected?.label ?? 'Select' }}</ScalarButton>\n * </ScalarCombobox>\n */\nexport default {}\n</script>\n\n<!-- prettier-ignore-attribute generic -->\n<script\n setup\n lang=\"ts\"\n generic=\"O extends Option = Option, G extends OptionGroup<O> = OptionGroup<O>\">\nimport type { ScalarFloatingOptions } from '../ScalarFloating'\nimport type { LoadingState } from '../ScalarLoading'\nimport ComboboxOptions from './ScalarComboboxOptions.vue'\nimport ComboboxPopover from './ScalarComboboxPopover.vue'\nimport type {\n ComboboxEmits,\n ComboboxSlots,\n FilterFunction,\n Option,\n OptionGroup,\n OptionsOrGroups,\n} from './types'\n\ndefineProps<\n {\n /** The options to display in the combobox */\n options: OptionsOrGroups<O, G>\n /** The placeholder text to display in the combobox */\n placeholder?: string\n /** An accessible label for the search input */\n inputLabel?: string\n /** The message to display when filtering returns no options */\n noResults?: string\n /** A function to filter the options based on a query,\n * if not provided, the options will be filtered by option label\n *\n * Pass `(_, options) => options` when the caller searches the options itself (e.g. on a\n * server) using the `query` model, so results the server already matched are shown as given.\n *\n * @see {@link FilterFunction} for more information\n */\n filterFn?: FilterFunction<O, G>\n /**\n * The loading state of the options, see `useLoadingState`\n *\n * Shows a spinner at the end of the search input while active, or an X when the state is\n * invalidated (e.g. a failed request).\n */\n loader?: LoadingState\n } & ScalarFloatingOptions\n>()\n\nconst emit = defineEmits<ComboboxEmits>()\n\nconst model = defineModel<O>()\n\n/** The search query, bind it to search the options yourself */\nconst query = defineModel<string>('query', { default: '' })\n\ndefineSlots<ComboboxSlots<O, G>>()\n</script>\n<template>\n <ComboboxPopover\n :middleware\n :offset\n :placement=\"placement ?? 'bottom-start'\"\n :resize\n :target\n :teleport>\n <template #default=\"{ open }\">\n <slot :open />\n </template>\n <template #popover=\"{ open, close }\">\n <ComboboxOptions\n v-model:query=\"query\"\n :close\n :filterFn\n :inputLabel\n :loader\n :modelValue=\"model ? [model] : []\"\n :noResults\n :open\n :options\n :placeholder\n @add=\"() => (close(), emit('add'))\"\n @update:modelValue=\"(v) => (close(), (model = v[0]))\">\n <!-- Pass through the combobox slots -->\n <template\n v-if=\"$slots['search-end']\"\n #search-end=\"props\">\n <slot\n name=\"search-end\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"$slots.option\"\n #option=\"props\">\n <slot\n name=\"option\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"$slots.group\"\n #group=\"props\">\n <slot\n name=\"group\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"$slots.add\"\n #add=\"props\">\n <slot\n name=\"add\"\n v-bind=\"props\" />\n </template>\n </ComboboxOptions>\n </template>\n </ComboboxPopover>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8DA,MAAM,OAAO;EAEb,MAAM,QAAQC,SAAc,SAAA,YAAC;;EAG7B,MAAM,QAAQA,SAAmB,SAAC,OAAwB;;GAKxD,OAAAC,UAAA,GAAAC,YAuDkBC,+BAAA;IAtDf,YAAA,QAAA;IACA,QAAA,QAAA;IACA,WAAW,QAAA,aAAS;IACpB,QAAA,QAAA;IACA,QAAA,QAAA;IACA,UAAA,QAAA;;IACU,SAAOC,SACF,EADM,WAAI,CACxBC,WAAc,KAAA,QAAA,WAAA,EAAP,KAAI,CAAA,C;IAEF,SAAOD,SA2CE,EA3CE,MAAM,YAAK,CAC/BE,YA0CkBC,+BAAA;KAzCR,OAAO,MAAA;KAAA,kBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,MAAK,QAAA;KACnB;KACA,UAAA,QAAA;KACA,YAAA,QAAA;KACA,QAAA,QAAA;KACA,YAAY,MAAA,QAAK,CAAI,MAAA,KAAK,IAAA,CAAA;KAC1B,WAAA,QAAA;KACA;KACA,SAAA,QAAA;KACA,aAAA,QAAA;KACA,cAAY,MAAK,GAAI,KAAI,KAAA;KACzB,wBAAoB,OAAO,MAAK,GAAK,MAAA,QAAQ,EAAC;;KAGvCR,KAAAA,OAAM,gB;MACX,MAAA;MACD,IAAAK,SADa,UAAK,CAClBC,WAEmB,KAAA,QAAA,cAAAG,eAAAC,mBAAT,KAAK,CAAA,CAAA,C;;;KAGTV,KAAAA,OAAO,S;MACZ,MAAA;MACD,IAAAK,SADS,UAAK,CACdC,WAEmB,KAAA,QAAA,UAAAG,eAAAC,mBAAT,KAAK,CAAA,CAAA,C;;;KAGTV,KAAAA,OAAO,Q;MACZ,MAAA;MACD,IAAAK,SADQ,UAAK,CACbC,WAEmB,KAAA,QAAA,SAAAG,eAAAC,mBAAT,KAAK,CAAA,CAAA,C;;;KAGTV,KAAAA,OAAO,M;MACZ,MAAA;MACD,IAAAK,SADM,UAAK,CACXC,WAEmB,KAAA,QAAA,OAAAG,eAAAC,mBAAT,KAAK,CAAA,CAAA,C"}
|
|
@@ -15,7 +15,11 @@ var ScalarComboboxMultiselect_vue_vue_type_script_setup_true_lang_default = /*@_
|
|
|
15
15
|
Function
|
|
16
16
|
] },
|
|
17
17
|
resize: { type: Boolean },
|
|
18
|
-
target: {
|
|
18
|
+
target: { type: [
|
|
19
|
+
String,
|
|
20
|
+
Object,
|
|
21
|
+
Function
|
|
22
|
+
] },
|
|
19
23
|
middleware: {},
|
|
20
24
|
teleport: { type: [Boolean, String] }
|
|
21
25
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarComboboxMultiselect.vue_vue_type_script_setup_true_lang.js","names":["$slots","_useModel","_openBlock","_createBlock","ComboboxPopover","_withCtx","_renderSlot","ComboboxOptions","_normalizeProps","_guardReactiveProps"],"sources":["../../../src/components/ScalarCombobox/ScalarComboboxMultiselect.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Combobox Multiselect component\n *\n * A searchable select input that supports selecting multiple options.\n *\n * @example\n * <ScalarComboboxMultiselect v-model=\"selected\" :options=\"options\">\n * <ScalarButton>Select items</ScalarButton>\n * </ScalarComboboxMultiselect>\n */\nexport default {}\n</script>\n\n<!-- prettier-ignore-attribute generic -->\n<script\n setup\n lang=\"ts\"\n generic=\" O extends Option = Option, G extends OptionGroup<O> = OptionGroup<O> \">\nimport { ref } from 'vue'\n\nimport type { ScalarFloatingOptions } from '../ScalarFloating'\nimport type { LoadingState } from '../ScalarLoading'\nimport ComboboxOptions from './ScalarComboboxOptions.vue'\nimport ComboboxPopover from './ScalarComboboxPopover.vue'\nimport type {\n ComboboxEmits,\n ComboboxSlots,\n FilterFunction,\n Option,\n OptionGroup,\n OptionsOrGroups,\n} from './types'\n\ndefineProps<\n {\n /** The options to display in the combobox */\n options: OptionsOrGroups<O, G>\n /** The placeholder text to display in the combobox */\n placeholder?: string\n /** A function to filter the options based on a query,\n * if not provided, the options will be filtered by option label\n *\n * Pass `(_, options) => options` when the caller searches the options itself (e.g. on a\n * server) using the `query` model, so results the server already matched are shown as given.\n *\n * @see {@link FilterFunction} for more information\n */\n filterFn?: FilterFunction<O, G>\n /**\n * The loading state of the options, see `useLoadingState`\n *\n * Shows a spinner at the end of the search input while active, or an X when the state is\n * invalidated (e.g. a failed request).\n */\n loader?: LoadingState\n } & ScalarFloatingOptions\n>()\n\nconst emit = defineEmits<ComboboxEmits>()\n\nconst model = defineModel<O[]>({ default: () => [] })\n\n/** The search query, bind it to search the options yourself */\nconst query = defineModel<string>('query', { default: '' })\n\ndefineSlots<ComboboxSlots<O, G>>()\n\n/** Propagate up the popover ref */\nconst comboboxPopoverRef = ref<typeof ComboboxPopover | null>(null)\n\ndefineExpose({ comboboxPopoverRef })\n</script>\n<template>\n <ComboboxPopover\n ref=\"comboboxPopoverRef\"\n :middleware=\"middleware\"\n :offset=\"offset\"\n :placement=\"placement ?? 'bottom-start'\"\n :resize=\"resize\"\n :target=\"target\"\n :teleport=\"teleport\">\n <template #default=\"{ open }\">\n <slot :open />\n </template>\n <template #popover=\"{ open }\">\n <ComboboxOptions\n v-if=\"options?.length || loader\"\n v-model=\"model\"\n v-model:query=\"query\"\n :filterFn\n :loader\n multiselect\n :open\n :options\n :placeholder\n @add=\"emit('add')\">\n <!-- Pass through the combobox slots -->\n <template\n v-if=\"$slots['search-end']\"\n #search-end=\"props\">\n <slot\n name=\"search-end\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"$slots.option\"\n #option=\"props\">\n <slot\n name=\"option\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"$slots.group\"\n #group=\"props\">\n <slot\n name=\"group\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"$slots.add\"\n #add=\"props\">\n <slot\n name=\"add\"\n v-bind=\"props\" />\n </template>\n </ComboboxOptions>\n </template>\n </ComboboxPopover>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarComboboxMultiselect.vue_vue_type_script_setup_true_lang.js","names":["$slots","_useModel","_openBlock","_createBlock","ComboboxPopover","_withCtx","_renderSlot","ComboboxOptions","_normalizeProps","_guardReactiveProps"],"sources":["../../../src/components/ScalarCombobox/ScalarComboboxMultiselect.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Combobox Multiselect component\n *\n * A searchable select input that supports selecting multiple options.\n *\n * @example\n * <ScalarComboboxMultiselect v-model=\"selected\" :options=\"options\">\n * <ScalarButton>Select items</ScalarButton>\n * </ScalarComboboxMultiselect>\n */\nexport default {}\n</script>\n\n<!-- prettier-ignore-attribute generic -->\n<script\n setup\n lang=\"ts\"\n generic=\" O extends Option = Option, G extends OptionGroup<O> = OptionGroup<O> \">\nimport { ref } from 'vue'\n\nimport type { ScalarFloatingOptions } from '../ScalarFloating'\nimport type { LoadingState } from '../ScalarLoading'\nimport ComboboxOptions from './ScalarComboboxOptions.vue'\nimport ComboboxPopover from './ScalarComboboxPopover.vue'\nimport type {\n ComboboxEmits,\n ComboboxSlots,\n FilterFunction,\n Option,\n OptionGroup,\n OptionsOrGroups,\n} from './types'\n\ndefineProps<\n {\n /** The options to display in the combobox */\n options: OptionsOrGroups<O, G>\n /** The placeholder text to display in the combobox */\n placeholder?: string\n /** A function to filter the options based on a query,\n * if not provided, the options will be filtered by option label\n *\n * Pass `(_, options) => options` when the caller searches the options itself (e.g. on a\n * server) using the `query` model, so results the server already matched are shown as given.\n *\n * @see {@link FilterFunction} for more information\n */\n filterFn?: FilterFunction<O, G>\n /**\n * The loading state of the options, see `useLoadingState`\n *\n * Shows a spinner at the end of the search input while active, or an X when the state is\n * invalidated (e.g. a failed request).\n */\n loader?: LoadingState\n } & ScalarFloatingOptions\n>()\n\nconst emit = defineEmits<ComboboxEmits>()\n\nconst model = defineModel<O[]>({ default: () => [] })\n\n/** The search query, bind it to search the options yourself */\nconst query = defineModel<string>('query', { default: '' })\n\ndefineSlots<ComboboxSlots<O, G>>()\n\n/** Propagate up the popover ref */\nconst comboboxPopoverRef = ref<typeof ComboboxPopover | null>(null)\n\ndefineExpose({ comboboxPopoverRef })\n</script>\n<template>\n <ComboboxPopover\n ref=\"comboboxPopoverRef\"\n :middleware=\"middleware\"\n :offset=\"offset\"\n :placement=\"placement ?? 'bottom-start'\"\n :resize=\"resize\"\n :target=\"target\"\n :teleport=\"teleport\">\n <template #default=\"{ open }\">\n <slot :open />\n </template>\n <template #popover=\"{ open }\">\n <ComboboxOptions\n v-if=\"options?.length || loader\"\n v-model=\"model\"\n v-model:query=\"query\"\n :filterFn\n :loader\n multiselect\n :open\n :options\n :placeholder\n @add=\"emit('add')\">\n <!-- Pass through the combobox slots -->\n <template\n v-if=\"$slots['search-end']\"\n #search-end=\"props\">\n <slot\n name=\"search-end\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"$slots.option\"\n #option=\"props\">\n <slot\n name=\"option\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"$slots.group\"\n #group=\"props\">\n <slot\n name=\"group\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"$slots.add\"\n #add=\"props\">\n <slot\n name=\"add\"\n v-bind=\"props\" />\n </template>\n </ComboboxOptions>\n </template>\n </ComboboxPopover>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2DA,MAAM,OAAO;EAEb,MAAM,QAAQC,SAAgB,SAAA,YAAsB;;EAGpD,MAAM,QAAQA,SAAmB,SAAC,OAAwB;;EAK1D,MAAM,qBAAqB,IAAmC,IAAI;EAElE,SAAa,EAAE,mBAAmB,CAAC;;GAGjC,OAAAC,UAAA,GAAAC,YAsDkBC,+BAAA;IArDZ,SAAA;IAAJ,KAAI;IACH,YAAY,QAAA;IACZ,QAAQ,QAAA;IACR,WAAW,QAAA,aAAS;IACpB,QAAQ,QAAA;IACR,QAAQ,QAAA;IACR,UAAU,QAAA;;IACA,SAAOC,SACF,EADM,WAAI,CACxBC,WAAc,KAAA,QAAA,WAAA,EAAP,KAAI,CAAA,C;IAEF,SAAOD,SAyCE,EAzCE,WAAI,CAEhB,QAAA,SAAS,UAAU,QAAA,UAD3BH,UAAA,GAAAC,YAwCkBI,+BAAA;;KAtCP,YAAA,MAAA;KAAA,uBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,MAAK,QAAA;KACN,OAAO,MAAA;KAAA,kBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,MAAK,QAAA;KACnB,UAAA,QAAA;KACA,QAAA,QAAA;KACD,aAAA;KACC;KACA,SAAA,QAAA;KACA,aAAA,QAAA;KACA,OAAG,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,KAAA;;KAGFP,KAAAA,OAAM,gB;MACX,MAAA;MACD,IAAAK,SADa,UAAK,CAClBC,WAEmB,KAAA,QAAA,cAAAE,eAAAC,mBAAT,KAAK,CAAA,CAAA,C;;;KAGTT,KAAAA,OAAO,S;MACZ,MAAA;MACD,IAAAK,SADS,UAAK,CACdC,WAEmB,KAAA,QAAA,UAAAE,eAAAC,mBAAT,KAAK,CAAA,CAAA,C;;;KAGTT,KAAAA,OAAO,Q;MACZ,MAAA;MACD,IAAAK,SADQ,UAAK,CACbC,WAEmB,KAAA,QAAA,SAAAE,eAAAC,mBAAT,KAAK,CAAA,CAAA,C;;;KAGTT,KAAAA,OAAO,M;MACZ,MAAA;MACD,IAAAK,SADM,UAAK,CACXC,WAEmB,KAAA,QAAA,OAAAE,eAAAC,mBAAT,KAAK,CAAA,CAAA,C"}
|
package/dist/components/ScalarCombobox/ScalarComboboxPopover.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -13,7 +13,11 @@ var ScalarComboboxPopover_vue_vue_type_script_setup_true_lang_default = /*@__PUR
|
|
|
13
13
|
Function
|
|
14
14
|
] },
|
|
15
15
|
resize: { type: Boolean },
|
|
16
|
-
target: {
|
|
16
|
+
target: { type: [
|
|
17
|
+
String,
|
|
18
|
+
Object,
|
|
19
|
+
Function
|
|
20
|
+
] },
|
|
17
21
|
middleware: {},
|
|
18
22
|
teleport: { type: [Boolean, String] }
|
|
19
23
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarComboboxPopover.vue_vue_type_script_setup_true_lang.js","names":["$props","_openBlock","_createBlock","_unref","_withCtx","_createVNode","ScalarFloating","_normalizeProps","_guardReactiveProps","_createSlots","_renderSlot","_mergeProps"],"sources":["../../../src/components/ScalarCombobox/ScalarComboboxPopover.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Combobox Popover component\n *\n * Wraps combobox content in a floating popover panel.\n * Handles open/close behavior and keyboard interactions.\n *\n * @example\n * <ScalarComboboxPopover>\n * <button>Toggle</button>\n * <template #popover=\"{ close }\">Content</template>\n * </ScalarComboboxPopover>\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { ref } from 'vue'\n\nimport { ScalarFloating, type ScalarFloatingOptions } from '../ScalarFloating'\nimport type { ScalarPopoverSlots } from '../ScalarPopover'\n\ndefineProps<ScalarFloatingOptions>()\n\ndefineSlots<ScalarPopoverSlots>()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\n/** Expose the popover button so we can close the popup */\nconst popoverButtonRef = ref<typeof PopoverButton | null>(null)\n\n/** Open the popover of the up or down arrows are pressed */\nconst handleKeydown = (e: KeyboardEvent) => {\n if (!['ArrowUp', 'ArrowDown'].includes(e.key)) {\n return\n }\n e.preventDefault()\n e.target?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }))\n}\n\ndefineExpose({ popoverButtonRef })\n</script>\n<template>\n <Popover\n v-slot=\"{ open }\"\n as=\"template\">\n <ScalarFloating v-bind=\"$props\">\n <PopoverButton\n ref=\"popoverButtonRef\"\n as=\"template\"\n @keydown=\"handleKeydown\">\n <slot :open />\n </PopoverButton>\n <template\n v-if=\"open\"\n #floating=\"{ width }\">\n <PopoverPanel\n v-slot=\"{ close }\"\n :style=\"{ width }\"\n v-bind=\"\n cx(\n 'relative flex flex-col max-h-[inherit] w-40 rounded-xl bg-b-1 dark:bg-b-1.5 text-sm shadow-md inset-shadow-border',\n )\n \">\n <slot\n :close\n name=\"popover\"\n :open />\n </PopoverPanel>\n </template>\n </ScalarFloating>\n </Popover>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarComboboxPopover.vue_vue_type_script_setup_true_lang.js","names":["$props","_openBlock","_createBlock","_unref","_withCtx","_createVNode","ScalarFloating","_normalizeProps","_guardReactiveProps","_createSlots","_renderSlot","_mergeProps"],"sources":["../../../src/components/ScalarCombobox/ScalarComboboxPopover.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Combobox Popover component\n *\n * Wraps combobox content in a floating popover panel.\n * Handles open/close behavior and keyboard interactions.\n *\n * @example\n * <ScalarComboboxPopover>\n * <button>Toggle</button>\n * <template #popover=\"{ close }\">Content</template>\n * </ScalarComboboxPopover>\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { ref } from 'vue'\n\nimport { ScalarFloating, type ScalarFloatingOptions } from '../ScalarFloating'\nimport type { ScalarPopoverSlots } from '../ScalarPopover'\n\ndefineProps<ScalarFloatingOptions>()\n\ndefineSlots<ScalarPopoverSlots>()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\n/** Expose the popover button so we can close the popup */\nconst popoverButtonRef = ref<typeof PopoverButton | null>(null)\n\n/** Open the popover of the up or down arrows are pressed */\nconst handleKeydown = (e: KeyboardEvent) => {\n if (!['ArrowUp', 'ArrowDown'].includes(e.key)) {\n return\n }\n e.preventDefault()\n e.target?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }))\n}\n\ndefineExpose({ popoverButtonRef })\n</script>\n<template>\n <Popover\n v-slot=\"{ open }\"\n as=\"template\">\n <ScalarFloating v-bind=\"$props\">\n <PopoverButton\n ref=\"popoverButtonRef\"\n as=\"template\"\n @keydown=\"handleKeydown\">\n <slot :open />\n </PopoverButton>\n <template\n v-if=\"open\"\n #floating=\"{ width }\">\n <PopoverPanel\n v-slot=\"{ close }\"\n :style=\"{ width }\"\n v-bind=\"\n cx(\n 'relative flex flex-col max-h-[inherit] w-40 rounded-xl bg-b-1 dark:bg-b-1.5 text-sm shadow-md inset-shadow-border',\n )\n \">\n <slot\n :close\n name=\"popover\"\n :open />\n </PopoverPanel>\n </template>\n </ScalarFloating>\n </Popover>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA6BA,MAAM,EAAE,OAAO,UAAU;;EAGzB,MAAM,mBAAmB,IAAiC,IAAI;;EAG9D,MAAM,iBAAiB,MAAqB;GAC1C,IAAI,CAAC,CAAC,WAAW,WAAW,CAAC,CAAC,SAAS,EAAE,GAAG,GAC1C;GAEF,EAAE,eAAe;GACjB,EAAE,QAAQ,cAAc,IAAI,cAAc,WAAW,EAAE,KAAK,QAAQ,CAAC,CAAC;EACxE;EAEA,SAAa,EAAE,iBAAiB,CAAC;;GAG/B,OAAAC,UAAA,GAAAC,YA4BUC,MAAA,OAAA,GAAA,EA1BR,IAAG,WAAU,GAAA;IACb,SAAAC,SAwBiB,EA1BP,WAAI,CAEdC,YAwBiBF,MAAAG,sBAAA,GAAAC,eAAAC,mBAxBOR,KAAAA,MAAM,CAAA,GAAAS,YAAA;KAC5B,SAAAL,cAKgB,CALhBC,YAKgBF,MAAA,aAAA,GAAA;MAJV,SAAA;MAAJ,KAAI;MACJ,IAAG;MACF,WAAS;;MACV,SAAAC,cAAc,CAAdM,WAAc,KAAA,QAAA,WAAA,EAAP,KAAI,CAAA,C;;;;I,IAGL,O;KACL,MAAA;KACD,IAAAN,SAYe,EAbF,YAAK,CAClBC,YAYeF,MAAA,YAAA,GAZfQ,WAYe,EAVZ,OAAK,EAAI,MAAK,E,GACMR,MAAA,EAAA,CAAE,C;MAKvB,SAAAC,SAGU,EAVA,YAAK,CAOfM,WAGU,KAAA,QAAA,WAAA;OAFP;OAEA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ScalarDialogProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Scalar Dialog
|
|
4
|
+
*
|
|
5
|
+
* A modal dialog built on the native `<dialog>` element. It calls `showModal()`
|
|
6
|
+
* under the hood, so the dialog is promoted to the browser top layer (escaping
|
|
7
|
+
* ancestor stacking, overflow, and transform contexts), traps and restores focus,
|
|
8
|
+
* makes the rest of the page inert, and closes on Escape — all natively, with no
|
|
9
|
+
* teleport. It also locks page scrolling while open, and gives popovers inside it a
|
|
10
|
+
* teleport target within the dialog so they render above it rather than under the
|
|
11
|
+
* top layer.
|
|
12
|
+
*
|
|
13
|
+
* Control it with `v-model:open` and compose the contents with the default slot.
|
|
14
|
+
* Restyle or resize it by passing your own `class`; the defaults are intentionally
|
|
15
|
+
* minimal so consumers compose rather than configure.
|
|
16
|
+
*
|
|
17
|
+
* Give the dialog an accessible name, ideally by pointing `aria-labelledby` at its
|
|
18
|
+
* visible heading so screen readers announce the same title sighted users see.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* <ScalarDialog v-model:open="open">
|
|
22
|
+
* <h2>Title</h2>
|
|
23
|
+
* <p>Some content</p>
|
|
24
|
+
* </ScalarDialog>
|
|
25
|
+
*/
|
|
26
|
+
declare const _default: typeof __VLS_export;
|
|
27
|
+
export default _default;
|
|
28
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ScalarDialogProps & {
|
|
29
|
+
/** Whether the dialog is open. Drives the native `showModal()` and `close()` calls. */
|
|
30
|
+
open?: boolean;
|
|
31
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
32
|
+
"update:open": (value: boolean) => any;
|
|
33
|
+
} & {
|
|
34
|
+
close: () => any;
|
|
35
|
+
}, string, import("vue").PublicProps, Readonly<ScalarDialogProps & {
|
|
36
|
+
/** Whether the dialog is open. Drives the native `showModal()` and `close()` calls. */
|
|
37
|
+
open?: boolean;
|
|
38
|
+
}> & Readonly<{
|
|
39
|
+
onClose?: (() => any) | undefined;
|
|
40
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
41
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
42
|
+
/** The dialog contents. Compose your own header, body, and footer here. */
|
|
43
|
+
default(): unknown;
|
|
44
|
+
}>;
|
|
45
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
46
|
+
new (): {
|
|
47
|
+
$slots: S;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=ScalarDialog.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScalarDialog.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarDialog/ScalarDialog.vue"],"names":[],"mappings":"AAuLA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAKhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;IAsIlB,uFAAuF;WAC9E,OAAO;;;;;;IADhB,uFAAuF;WAC9E,OAAO;;;;;IA3Hd,2EAA2E;eAChE,OAAO;EA8LhB,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ScalarDialog_vue_vue_type_script_setup_true_lang_default from "./ScalarDialog.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
// src/components/ScalarDialog/ScalarDialog.vue
|
|
3
|
+
var ScalarDialog_default = ScalarDialog_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
export { ScalarDialog_default as default };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=ScalarDialog.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScalarDialog.vue.js","names":[],"sources":[],"mappings":""}
|