@scalar/components 0.12.0 → 0.12.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.
@@ -1,17 +1,17 @@
1
1
  import { defineComponent as a, openBlock as p, createBlock as i, unref as o, withCtx as t, createVNode as l, mergeProps as m, renderSlot as s, createElementVNode as f } from "vue";
2
2
  import { Menu as u, MenuItems as d, MenuButton as c } from "@headlessui/vue";
3
3
  import _ from "../ScalarFloating/ScalarFloating.vue.js";
4
- const h = /* @__PURE__ */ f("div", { class: "absolute inset-0 -z-1 rounded bg-b-1 shadow-lg brightness-lifted" }, null, -1), w = /* @__PURE__ */ a({
4
+ const g = /* @__PURE__ */ f("div", { class: "absolute inset-0 -z-1 rounded bg-b-1 shadow-lg brightness-lifted" }, null, -1), w = /* @__PURE__ */ a({
5
5
  inheritAttrs: !1,
6
6
  __name: "ScalarDropdown",
7
7
  props: {
8
8
  placement: {},
9
9
  resize: { type: Boolean },
10
10
  isOpen: { type: Boolean },
11
- teleport: { type: Boolean }
11
+ teleport: { type: [Boolean, String] }
12
12
  },
13
- setup(B) {
14
- return (e, b) => (p(), i(o(u), null, {
13
+ setup(h) {
14
+ return (e, B) => (p(), i(o(u), null, {
15
15
  default: t(({ open: r }) => [
16
16
  l(o(_), {
17
17
  isOpen: r ?? e.isOpen,
@@ -26,7 +26,7 @@ const h = /* @__PURE__ */ f("div", { class: "absolute inset-0 -z-1 rounded bg-b-
26
26
  }, e.$attrs), {
27
27
  default: t(() => [
28
28
  s(e.$slots, "items"),
29
- h
29
+ g
30
30
  ]),
31
31
  _: 2
32
32
  }, 1040, ["style"])
@@ -1,6 +1,6 @@
1
- import { defineComponent as w, ref as d, computed as t, openBlock as p, createElementBlock as z, Fragment as b, createElementVNode as r, normalizeClass as k, renderSlot as m, createBlock as B, Teleport as R, normalizeStyle as S, unref as c, createCommentVNode as _ } from "vue";
2
- import { getSideAxis as f } from "@floating-ui/utils";
3
- import { useFloating as C, autoUpdate as E, offset as F, flip as $, shift as A } from "@floating-ui/vue";
1
+ import { defineComponent as w, ref as d, computed as t, openBlock as p, createElementBlock as z, Fragment as S, createElementVNode as r, normalizeClass as b, renderSlot as m, createBlock as k, Teleport as B, normalizeStyle as R, unref as f, createCommentVNode as C } from "vue";
2
+ import { getSideAxis as c } from "@floating-ui/utils";
3
+ import { useFloating as E, autoUpdate as F, offset as _, flip as $, shift as A } from "@floating-ui/vue";
4
4
  import { useResizeWithTarget as N } from "./useResizeWithTarget.js";
5
5
  const O = { class: "scalar-app" }, H = /* @__PURE__ */ w({
6
6
  inheritAttrs: !1,
@@ -10,58 +10,58 @@ const O = { class: "scalar-app" }, H = /* @__PURE__ */ w({
10
10
  resize: { type: Boolean },
11
11
  middleware: {},
12
12
  isOpen: { type: Boolean },
13
- teleport: { type: Boolean }
13
+ teleport: { type: [Boolean, String] }
14
14
  },
15
15
  setup(u) {
16
- const o = u, n = d(null), a = d(null), i = t(
16
+ const o = u, n = d(null), l = d(null), i = t(
17
17
  () => {
18
- var e, l;
19
- return (((l = (e = a.value) == null ? void 0 : e.children) == null ? void 0 : l[0]) || a.value) ?? void 0;
18
+ var e, a;
19
+ return (((a = (e = l.value) == null ? void 0 : e.children) == null ? void 0 : a[0]) || l.value) ?? void 0;
20
20
  }
21
21
  ), s = N(i, {
22
22
  enabled: t(() => o.resize)
23
23
  }), g = t(
24
- () => f(o.placement || "bottom") === "y" ? s.width.value : void 0
24
+ () => c(o.placement || "bottom") === "y" ? s.width.value : void 0
25
25
  ), h = t(
26
- () => f(o.placement || "bottom") === "x" ? s.height.value : void 0
27
- ), { floatingStyles: v, middlewareData: y } = C(i, n, {
26
+ () => c(o.placement || "bottom") === "x" ? s.height.value : void 0
27
+ ), { floatingStyles: v, middlewareData: y } = E(i, n, {
28
28
  placement: t(() => o.placement),
29
- whileElementsMounted: E,
29
+ whileElementsMounted: F,
30
30
  middleware: t(() => [
31
- F(5),
31
+ _(5),
32
32
  $(),
33
33
  A(),
34
34
  ...o.middleware ?? []
35
35
  ])
36
36
  });
37
- return (e, l) => (p(), z(b, null, [
37
+ return (e, a) => (p(), z(S, null, [
38
38
  r("div", {
39
39
  ref_key: "wrapperRef",
40
- ref: a,
41
- class: k({ contents: !!e.$slots.default })
40
+ ref: l,
41
+ class: b({ contents: !!e.$slots.default })
42
42
  }, [
43
43
  m(e.$slots, "default")
44
44
  ], 2),
45
- e.isOpen ? (p(), B(R, {
45
+ e.isOpen ? (p(), k(B, {
46
46
  key: 0,
47
47
  disabled: !e.teleport,
48
- to: "body"
48
+ to: typeof e.teleport == "string" ? e.teleport : "body"
49
49
  }, [
50
50
  r("div", O, [
51
51
  r("div", {
52
52
  ref_key: "floatingRef",
53
53
  ref: n,
54
54
  class: "relative z-overlay",
55
- style: S(c(v))
55
+ style: R(f(v))
56
56
  }, [
57
57
  m(e.$slots, "floating", {
58
- data: c(y),
58
+ data: f(y),
59
59
  height: h.value,
60
60
  width: g.value
61
61
  })
62
62
  ], 4)
63
63
  ])
64
- ], 8, ["disabled"])) : _("", !0)
64
+ ], 8, ["disabled", "to"])) : C("", !0)
65
65
  ], 64));
66
66
  }
67
67
  });
@@ -1,5 +1,5 @@
1
- import { defineComponent as b, openBlock as i, createBlock as u, unref as t, normalizeClass as n, withCtx as l, createVNode as a, mergeProps as x, createElementBlock as v, Fragment as y, renderList as g, createElementVNode as o, toDisplayString as h, renderSlot as V } from "vue";
2
- import { Listbox as _, ListboxOptions as k, ListboxOption as z, ListboxButton as B } from "@headlessui/vue";
1
+ import { defineComponent as b, openBlock as i, createBlock as u, unref as t, normalizeClass as n, withCtx as l, createVNode as a, mergeProps as y, createElementBlock as g, Fragment as v, renderList as x, createElementVNode as o, toDisplayString as h, renderSlot as B } from "vue";
2
+ import { Listbox as V, ListboxOptions as k, ListboxOption as z, ListboxButton as _ } from "@headlessui/vue";
3
3
  import { cva as w, cx as L } from "../../cva.js";
4
4
  import O from "../ScalarFloating/ScalarFloating.vue.js";
5
5
  import $ from "../ScalarIcon/ScalarIcon.vue.js";
@@ -7,13 +7,14 @@ const C = { class: "inline-block min-w-0 flex-1 truncate text-c-1" }, S = /* @__
7
7
  inheritAttrs: !1,
8
8
  __name: "ScalarListbox",
9
9
  props: {
10
+ multiple: { type: Boolean, default: !1 },
10
11
  options: {},
11
12
  modelValue: {},
12
13
  fullWidth: { type: Boolean },
13
14
  placement: {},
14
15
  resize: { type: Boolean },
15
16
  isOpen: { type: Boolean },
16
- teleport: { type: Boolean }
17
+ teleport: { type: [Boolean, String] }
17
18
  },
18
19
  emits: ["update:modelValue"],
19
20
  setup(j) {
@@ -34,11 +35,12 @@ const C = { class: "inline-block min-w-0 flex-1 truncate text-c-1" }, S = /* @__
34
35
  disabled: { true: "pointer-events-none opacity-50" }
35
36
  }
36
37
  });
37
- return (e, d) => (i(), u(t(_), {
38
+ return (e, p) => (i(), u(t(V), {
38
39
  as: "div",
39
40
  class: n([{ "w-full": e.fullWidth }, "text-xs"]),
40
41
  modelValue: e.modelValue,
41
- "onUpdate:modelValue": d[0] || (d[0] = (r) => e.$emit("update:modelValue", r))
42
+ multiple: e.multiple,
43
+ "onUpdate:modelValue": p[0] || (p[0] = (r) => e.$emit("update:modelValue", r))
42
44
  }, {
43
45
  default: l(({ open: r }) => [
44
46
  a(t(O), {
@@ -48,25 +50,25 @@ const C = { class: "inline-block min-w-0 flex-1 truncate text-c-1" }, S = /* @__
48
50
  teleport: e.teleport
49
51
  }, {
50
52
  floating: l(({ width: f }) => [
51
- a(t(k), x({
53
+ a(t(k), y({
52
54
  class: "relative flex w-40 flex-col rounded border p-0.75",
53
55
  style: { width: f }
54
56
  }, e.$attrs), {
55
57
  default: l(() => [
56
- (i(!0), v(y, null, g(e.options, (s) => (i(), u(t(z), {
58
+ (i(!0), g(v, null, x(e.options, (s) => (i(), u(t(z), {
57
59
  key: s.id,
58
60
  as: "template",
59
61
  disabled: s.disabled,
60
62
  value: s
61
63
  }, {
62
- default: l(({ active: c, selected: p }) => [
64
+ default: l(({ active: c, selected: d }) => [
63
65
  o("li", {
64
66
  class: n(
65
- t(L)(t(m)({ active: c, selected: p, disabled: s.disabled }))
67
+ t(L)(t(m)({ active: c, selected: d, disabled: s.disabled }))
66
68
  )
67
69
  }, [
68
70
  o("div", {
69
- class: n(["flex size-4 items-center justify-center rounded-full p-[3px] group-hover:shadow-border", p ? "bg-blue text-b-1" : "text-transparent"])
71
+ class: n(["flex size-4 items-center justify-center rounded-full p-[3px] group-hover:shadow-border", d ? "bg-blue text-b-1" : "text-transparent"])
70
72
  }, [
71
73
  a(t($), {
72
74
  class: "relative top-[0.5px] size-2.5 stroke-[1.75]",
@@ -84,12 +86,12 @@ const C = { class: "inline-block min-w-0 flex-1 truncate text-c-1" }, S = /* @__
84
86
  }, 1040, ["style"])
85
87
  ]),
86
88
  default: l(() => [
87
- a(t(B), {
89
+ a(t(_), {
88
90
  as: "template",
89
91
  class: "justify-start"
90
92
  }, {
91
93
  default: l(() => [
92
- V(e.$slots, "default")
94
+ B(e.$slots, "default")
93
95
  ]),
94
96
  _: 3
95
97
  })
@@ -98,7 +100,7 @@ const C = { class: "inline-block min-w-0 flex-1 truncate text-c-1" }, S = /* @__
98
100
  }, 1032, ["isOpen", "placement", "resize", "teleport"])
99
101
  ]),
100
102
  _: 3
101
- }, 8, ["class", "modelValue"]));
103
+ }, 8, ["class", "modelValue", "multiple"]));
102
104
  }
103
105
  });
104
106
  export {
@@ -1,37 +1,37 @@
1
- import { defineComponent as i, openBlock as f, createBlock as d, unref as t, withCtx as o, createVNode as l, mergeProps as r, renderSlot as s, createElementVNode as u } from "vue";
1
+ import { defineComponent as i, openBlock as f, createBlock as d, unref as o, withCtx as t, createVNode as l, mergeProps as r, renderSlot as s, createElementVNode as u } from "vue";
2
2
  import { Popover as m, PopoverPanel as c, PopoverButton as _ } from "@headlessui/vue";
3
3
  import v from "../ScalarFloating/ScalarFloating.vue.js";
4
- const h = /* @__PURE__ */ u("div", { class: "absolute inset-0 -z-1 rounded bg-b-1 shadow-lg brightness-lifted" }, null, -1), b = /* @__PURE__ */ i({
4
+ const g = /* @__PURE__ */ u("div", { class: "absolute inset-0 -z-1 rounded bg-b-1 shadow-lg brightness-lifted" }, null, -1), b = /* @__PURE__ */ i({
5
5
  inheritAttrs: !1,
6
6
  __name: "ScalarPopover",
7
7
  props: {
8
8
  placement: {},
9
9
  resize: { type: Boolean },
10
10
  isOpen: { type: Boolean },
11
- teleport: { type: Boolean }
11
+ teleport: { type: [Boolean, String] }
12
12
  },
13
- setup(B) {
14
- return (e, P) => (f(), d(t(m), null, {
15
- default: o(({ open: p }) => [
16
- l(t(v), r(e.$props, {
13
+ setup(h) {
14
+ return (e, B) => (f(), d(o(m), null, {
15
+ default: t(({ open: p }) => [
16
+ l(o(v), r(e.$props, {
17
17
  isOpen: p ?? e.isOpen,
18
18
  teleport: e.teleport
19
19
  }), {
20
- floating: o(({ width: a, height: n }) => [
21
- l(t(c), r({
20
+ floating: t(({ width: n, height: a }) => [
21
+ l(o(c), r({
22
22
  class: "relative flex flex-col p-0.75",
23
- style: { width: a, height: n }
23
+ style: { width: n, height: a }
24
24
  }, e.$attrs), {
25
- default: o(() => [
25
+ default: t(() => [
26
26
  s(e.$slots, "popover"),
27
- h
27
+ g
28
28
  ]),
29
29
  _: 2
30
30
  }, 1040, ["style"])
31
31
  ]),
32
- default: o(() => [
33
- l(t(_), { as: "template" }, {
34
- default: o(() => [
32
+ default: t(() => [
33
+ l(o(_), { as: "template" }, {
34
+ default: t(() => [
35
35
  s(e.$slots, "default")
36
36
  ]),
37
37
  _: 3
package/dist/index.d.ts CHANGED
@@ -74,6 +74,10 @@ declare type __VLS_Prettify_8<T> = {
74
74
  [K in keyof T]: T[K];
75
75
  } & {};
76
76
 
77
+ declare type __VLS_Prettify_9<T> = {
78
+ [K in keyof T]: T[K];
79
+ } & {};
80
+
77
81
  declare type __VLS_TypePropsToRuntimeProps<T> = {
78
82
  [K in keyof T]-?: {} extends Pick<T, K> ? {
79
83
  type: PropType<__VLS_NonUndefinedable<T[K]>>;
@@ -275,6 +279,12 @@ declare type __VLS_WithDefaults_8<P, D> = {
275
279
  }> : P[K];
276
280
  };
277
281
 
282
+ declare type __VLS_WithDefaults_9<P, D> = {
283
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify_9<P[K] & {
284
+ default: D[K];
285
+ }> : P[K];
286
+ };
287
+
278
288
  declare type __VLS_WithTemplateSlots<T, S> = T & {
279
289
  new (): {
280
290
  $slots: S;
@@ -369,10 +379,11 @@ declare type FloatingOptions = {
369
379
  */
370
380
  isOpen?: boolean;
371
381
  /**
372
- * Whether to teleport the floating element to the end of the document body.
382
+ * Whether to teleport the floating element.
383
+ * Can be an `id` to teleport to or `true` to teleport to the `<body>`.
373
384
  * @default false
374
385
  */
375
- teleport?: boolean;
386
+ teleport?: boolean | string;
376
387
  };
377
388
 
378
389
  export declare type Icon = (typeof ICONS)[number];
@@ -592,19 +603,37 @@ size: "sm" | "md" | "xs" | "full" | "xxs";
592
603
  variant: string;
593
604
  }, {}>;
594
605
 
595
- export declare const ScalarListbox: __VLS_WithTemplateSlots_5<DefineComponent<__VLS_TypePropsToRuntimeProps_9<{
606
+ export declare const ScalarListbox: __VLS_WithTemplateSlots_5<DefineComponent<__VLS_WithDefaults_5<__VLS_TypePropsToRuntimeProps_9<{
607
+ /**
608
+ * Allow selecting multiple values
609
+ *
610
+ * @default false
611
+ */
612
+ multiple?: boolean | undefined;
596
613
  options: ScalarListboxOption[];
597
614
  modelValue?: ScalarListboxOption | undefined;
598
615
  fullWidth?: boolean | undefined;
599
- } & Omit<FloatingOptions, "middleware" | "offset">>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
616
+ } & Omit<FloatingOptions, "middleware" | "offset">>, {
617
+ multiple: boolean;
618
+ }>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
600
619
  "update:modelValue": (v: ScalarListboxOption) => void;
601
- }, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_9<{
620
+ }, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_5<__VLS_TypePropsToRuntimeProps_9<{
621
+ /**
622
+ * Allow selecting multiple values
623
+ *
624
+ * @default false
625
+ */
626
+ multiple?: boolean | undefined;
602
627
  options: ScalarListboxOption[];
603
628
  modelValue?: ScalarListboxOption | undefined;
604
629
  fullWidth?: boolean | undefined;
605
- } & Omit<FloatingOptions, "middleware" | "offset">>>> & {
630
+ } & Omit<FloatingOptions, "middleware" | "offset">>, {
631
+ multiple: boolean;
632
+ }>>> & {
606
633
  "onUpdate:modelValue"?: ((v: ScalarListboxOption) => any) | undefined;
607
- }, {}, {}>, {
634
+ }, {
635
+ multiple: boolean;
636
+ }, {}>, {
608
637
  default?(_: {}): any;
609
638
  }>;
610
639
 
@@ -615,12 +644,12 @@ export declare type ScalarListboxOption = {
615
644
  [x: string]: any;
616
645
  };
617
646
 
618
- export declare const ScalarLoading: DefineComponent<__VLS_WithDefaults_5<__VLS_TypePropsToRuntimeProps_10<{
647
+ export declare const ScalarLoading: DefineComponent<__VLS_WithDefaults_6<__VLS_TypePropsToRuntimeProps_10<{
619
648
  loadingState: LoadingState;
620
649
  size?: string | undefined;
621
650
  }>, {
622
651
  size: string;
623
- }>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_5<__VLS_TypePropsToRuntimeProps_10<{
652
+ }>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_6<__VLS_TypePropsToRuntimeProps_10<{
624
653
  loadingState: LoadingState;
625
654
  size?: string | undefined;
626
655
  }>, {
@@ -643,7 +672,7 @@ withImages: boolean;
643
672
  withImages: boolean;
644
673
  }, {}>;
645
674
 
646
- export declare const ScalarModal: __VLS_WithTemplateSlots_6<DefineComponent<__VLS_WithDefaults_6<__VLS_TypePropsToRuntimeProps_11<{
675
+ export declare const ScalarModal: __VLS_WithTemplateSlots_6<DefineComponent<__VLS_WithDefaults_7<__VLS_TypePropsToRuntimeProps_11<{
647
676
  state: ReturnType<typeof useModal>;
648
677
  title?: string | undefined;
649
678
  bodyClass?: string | undefined;
@@ -652,7 +681,7 @@ size?: "sm" | "md" | "xs" | "lg" | "full" | undefined;
652
681
  variant?: "search" | "history" | undefined;
653
682
  }>, {
654
683
  size: string;
655
- }>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_6<__VLS_TypePropsToRuntimeProps_11<{
684
+ }>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_7<__VLS_TypePropsToRuntimeProps_11<{
656
685
  state: ReturnType<typeof useModal>;
657
686
  title?: string | undefined;
658
687
  bodyClass?: string | undefined;
@@ -726,7 +755,7 @@ noResults?: boolean | undefined;
726
755
  default?(_: {}): any;
727
756
  }>;
728
757
 
729
- export declare const ScalarTextField: __VLS_WithTemplateSlots_11<DefineComponent<__VLS_WithDefaults_7<__VLS_TypePropsToRuntimeProps_16<{
758
+ export declare const ScalarTextField: __VLS_WithTemplateSlots_11<DefineComponent<__VLS_WithDefaults_8<__VLS_TypePropsToRuntimeProps_16<{
730
759
  modelValue: string;
731
760
  placeholder?: string | undefined;
732
761
  label?: string | undefined;
@@ -747,7 +776,7 @@ disableTrim: boolean;
747
776
  }>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
748
777
  submit: (v: string) => void;
749
778
  "update:modelValue": (v: string) => void;
750
- }, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_7<__VLS_TypePropsToRuntimeProps_16<{
779
+ }, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_8<__VLS_TypePropsToRuntimeProps_16<{
751
780
  modelValue: string;
752
781
  placeholder?: string | undefined;
753
782
  label?: string | undefined;
@@ -776,7 +805,7 @@ disableTrim: boolean;
776
805
  default?(_: {}): any;
777
806
  }>;
778
807
 
779
- export declare const ScalarTooltip: __VLS_WithTemplateSlots_12<DefineComponent<__VLS_WithDefaults_8<__VLS_TypePropsToRuntimeProps_17<{
808
+ export declare const ScalarTooltip: __VLS_WithTemplateSlots_12<DefineComponent<__VLS_WithDefaults_9<__VLS_TypePropsToRuntimeProps_17<{
780
809
  click?: (() => void) | undefined;
781
810
  delay?: number | undefined;
782
811
  skipDelay?: number | undefined;
@@ -788,7 +817,7 @@ skipDelay: number;
788
817
  side: string;
789
818
  }>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
790
819
  click: () => void;
791
- }, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_8<__VLS_TypePropsToRuntimeProps_17<{
820
+ }, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_9<__VLS_TypePropsToRuntimeProps_17<{
792
821
  click?: (() => void) | undefined;
793
822
  delay?: number | undefined;
794
823
  skipDelay?: number | undefined;
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/scalar/scalar.git",
11
11
  "directory": "packages/components"
12
12
  },
13
- "version": "0.12.0",
13
+ "version": "0.12.1",
14
14
  "engines": {
15
15
  "node": ">=18"
16
16
  },
@@ -39,8 +39,8 @@
39
39
  "radix-vue": "^1.8.4",
40
40
  "tailwind-merge": "^2.3.0",
41
41
  "vue": "^3.4.22",
42
- "@scalar/oas-utils": "0.2.3",
43
- "@scalar/code-highlight": "0.0.4"
42
+ "@scalar/code-highlight": "0.0.4",
43
+ "@scalar/oas-utils": "0.2.4"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@headlessui/tailwindcss": "^0.2.0",