@vizejs/fresco 0.712.0 → 0.713.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.
Files changed (36) hide show
  1. package/dist/accessibility-D1R9HiTE.d.mts +40 -0
  2. package/dist/accessibility-D1R9HiTE.d.mts.map +1 -0
  3. package/dist/{app-D1EmYPR5.mjs → app-DoXcF_Dn.mjs} +23 -8
  4. package/dist/app-DoXcF_Dn.mjs.map +1 -0
  5. package/dist/{app-BnHjO4sM.d.mts → app-adHHi99c.d.mts} +2 -2
  6. package/dist/{app-BnHjO4sM.d.mts.map → app-adHHi99c.d.mts.map} +1 -1
  7. package/dist/components/index.d.mts +2 -2
  8. package/dist/components/index.mjs +2 -2
  9. package/dist/{components-CqGU-NNE.mjs → components-DWIDBGTL.mjs} +299 -4
  10. package/dist/components-DWIDBGTL.mjs.map +1 -0
  11. package/dist/composables/index.d.mts +3 -2
  12. package/dist/composables/index.mjs +4 -4
  13. package/dist/{composables-CZLZwicA.mjs → composables-b_R5s4QQ.mjs} +3 -3
  14. package/dist/{composables-CZLZwicA.mjs.map → composables-b_R5s4QQ.mjs.map} +1 -1
  15. package/dist/{index-DqiuvriA.d.mts → index-B-asCcvK.d.mts} +20 -2
  16. package/dist/index-B-asCcvK.d.mts.map +1 -0
  17. package/dist/{index-DHSs5acI.d.mts → index-Cs1Pyrqk.d.mts} +97 -28
  18. package/dist/index-Cs1Pyrqk.d.mts.map +1 -0
  19. package/dist/index.d.mts +7 -5
  20. package/dist/index.mjs +5 -5
  21. package/dist/{accessibility-CsJ09kle.d.mts → protocol--xy80nuC.d.mts} +5 -25
  22. package/dist/protocol--xy80nuC.d.mts.map +1 -0
  23. package/dist/testing/index.d.mts +2 -1
  24. package/dist/testing/index.d.mts.map +1 -1
  25. package/dist/testing/index.mjs +1 -1
  26. package/dist/{useInput-BmjmkjZ9.mjs → useVirtualViewport-CcJuIc7U.mjs} +113 -4
  27. package/dist/useVirtualViewport-CcJuIc7U.mjs.map +1 -0
  28. package/dist/useVirtualViewport-TxTapifg.d.mts +49 -0
  29. package/dist/useVirtualViewport-TxTapifg.d.mts.map +1 -0
  30. package/package.json +11 -6
  31. package/dist/accessibility-CsJ09kle.d.mts.map +0 -1
  32. package/dist/app-D1EmYPR5.mjs.map +0 -1
  33. package/dist/components-CqGU-NNE.mjs.map +0 -1
  34. package/dist/index-DHSs5acI.d.mts.map +0 -1
  35. package/dist/index-DqiuvriA.d.mts.map +0 -1
  36. package/dist/useInput-BmjmkjZ9.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { i as useIsScreenReaderEnabled, t as useInput } from "./useInput-BmjmkjZ9.mjs";
2
- import { computed, defineComponent, h, onMounted, onUnmounted, ref, watch } from "vue";
1
+ import { i as useInput, r as useMouse, s as useIsScreenReaderEnabled, t as createVirtualViewport } from "./useVirtualViewport-CcJuIc7U.mjs";
2
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, h, mergeProps, onMounted, onUnmounted, openBlock, ref, renderList, renderSlot, unref, watch, withCtx } from "vue";
3
3
  //#region src/components/Box.ts
4
4
  /**
5
5
  * Box Component - Container with flexbox layout
@@ -550,6 +550,301 @@ defineComponent({
550
550
  }
551
551
  });
552
552
  //#endregion
553
+ //#region src/components/ScrollBar.vue
554
+ var ScrollBar_default = /* @__PURE__ */ defineComponent({
555
+ __name: "ScrollBar",
556
+ props: {
557
+ itemCount: {
558
+ type: Number,
559
+ required: true
560
+ },
561
+ viewportSize: {
562
+ type: Number,
563
+ required: true
564
+ },
565
+ offset: {
566
+ type: Number,
567
+ required: true
568
+ },
569
+ length: {
570
+ type: Number,
571
+ required: false
572
+ },
573
+ orientation: {
574
+ type: String,
575
+ required: false,
576
+ default: "vertical"
577
+ },
578
+ track: {
579
+ type: String,
580
+ required: false,
581
+ default: "│"
582
+ },
583
+ thumb: {
584
+ type: String,
585
+ required: false,
586
+ default: "█"
587
+ },
588
+ fg: {
589
+ type: String,
590
+ required: false
591
+ },
592
+ thumbFg: {
593
+ type: String,
594
+ required: false
595
+ }
596
+ },
597
+ setup(__props) {
598
+ function nonNegativeInteger(value) {
599
+ const floored = Math.floor(value);
600
+ return Number.isSafeInteger(floored) && floored >= 0 ? floored : 0;
601
+ }
602
+ const metrics = computed(() => {
603
+ const trackLength = nonNegativeInteger(__props.length ?? __props.viewportSize);
604
+ const boundedViewportSize = nonNegativeInteger(__props.viewportSize);
605
+ const boundedItemCount = nonNegativeInteger(__props.itemCount);
606
+ const maxOffset = Math.max(0, boundedItemCount - boundedViewportSize);
607
+ return {
608
+ trackLength,
609
+ boundedViewportSize,
610
+ boundedItemCount,
611
+ maxOffset,
612
+ boundedOffset: Number.isFinite(__props.offset) ? Math.min(maxOffset, Math.max(0, __props.offset)) : 0
613
+ };
614
+ });
615
+ const cells = computed(() => {
616
+ const { trackLength, boundedViewportSize, boundedItemCount, maxOffset, boundedOffset } = metrics.value;
617
+ if (trackLength === 0) return [];
618
+ const thumbSize = maxOffset === 0 ? trackLength : Math.max(1, Math.min(trackLength, Math.floor(trackLength * boundedViewportSize / boundedItemCount)));
619
+ const travel = trackLength - thumbSize;
620
+ const thumbStart = maxOffset === 0 ? 0 : Math.round(boundedOffset / maxOffset * travel);
621
+ return Array.from({ length: trackLength }, (_, position) => ({
622
+ position,
623
+ symbol: position >= thumbStart && position < thumbStart + thumbSize ? __props.thumb : __props.track,
624
+ thumb: position >= thumbStart && position < thumbStart + thumbSize
625
+ }));
626
+ });
627
+ const ariaState = computed(() => ({
628
+ orientation: __props.orientation,
629
+ valueMin: 0,
630
+ valueMax: metrics.value.maxOffset,
631
+ valueNow: metrics.value.boundedOffset
632
+ }));
633
+ const accessibilityProps = computed(() => ({
634
+ ariaRole: "scrollbar",
635
+ ariaState: ariaState.value
636
+ }));
637
+ const cellAccessibilityProps = { ariaHidden: true };
638
+ return (_ctx, _cache) => {
639
+ return openBlock(), createBlock(unref(Box), mergeProps({ "flex-direction": __props.orientation === "vertical" ? "column" : "row" }, accessibilityProps.value), {
640
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(cells.value, (cell) => {
641
+ return openBlock(), createBlock(unref(Text), mergeProps({
642
+ key: cell.position,
643
+ content: cell.symbol,
644
+ fg: cell.thumb ? __props.thumbFg ?? __props.fg : __props.fg
645
+ }, { ref_for: true }, cellAccessibilityProps), null, 16, ["content", "fg"]);
646
+ }), 128))]),
647
+ _: 1
648
+ }, 16, ["flex-direction"]);
649
+ };
650
+ }
651
+ });
652
+ //#endregion
653
+ //#region src/components/ScrollBox.vue
654
+ var ScrollBox_default = /* @__PURE__ */ defineComponent({
655
+ __name: "ScrollBox",
656
+ props: {
657
+ itemCount: {
658
+ type: Number,
659
+ required: true
660
+ },
661
+ viewportSize: {
662
+ type: Number,
663
+ required: true
664
+ },
665
+ modelValue: {
666
+ type: Number,
667
+ required: false
668
+ },
669
+ overscan: {
670
+ type: Number,
671
+ required: false,
672
+ default: 2
673
+ },
674
+ focused: {
675
+ type: Boolean,
676
+ required: false,
677
+ default: false
678
+ },
679
+ disabled: {
680
+ type: Boolean,
681
+ required: false,
682
+ default: false
683
+ },
684
+ wheelStep: {
685
+ type: Number,
686
+ required: false,
687
+ default: 3
688
+ },
689
+ showScrollbar: {
690
+ type: Boolean,
691
+ required: false,
692
+ default: true
693
+ },
694
+ followOutput: {
695
+ type: Boolean,
696
+ required: false,
697
+ default: false
698
+ },
699
+ scrollbarTrack: {
700
+ type: String,
701
+ required: false,
702
+ default: "│"
703
+ },
704
+ scrollbarThumb: {
705
+ type: String,
706
+ required: false,
707
+ default: "█"
708
+ }
709
+ },
710
+ emits: ["update:modelValue", "scroll"],
711
+ setup(__props, { expose: __expose, emit: __emit }) {
712
+ const emit = __emit;
713
+ const viewport = createVirtualViewport({
714
+ itemCount: __props.itemCount,
715
+ viewportSize: __props.viewportSize,
716
+ overscan: __props.overscan,
717
+ initialOffset: __props.modelValue ?? 0
718
+ });
719
+ const isActive = computed(() => __props.focused && !__props.disabled);
720
+ const normalizedWheelStep = computed(() => {
721
+ const truncated = Math.trunc(__props.wheelStep);
722
+ return Number.isSafeInteger(truncated) && truncated > 0 ? truncated : 1;
723
+ });
724
+ const retainedIndexes = computed(() => {
725
+ const range = viewport.range.value;
726
+ return Array.from({ length: range.overscanEnd - range.overscanStart }, (_, index) => range.overscanStart + index);
727
+ });
728
+ const rootAriaState = computed(() => ({ disabled: __props.disabled }));
729
+ const rootAccessibilityProps = computed(() => ({
730
+ ariaRole: "list",
731
+ ariaState: rootAriaState.value
732
+ }));
733
+ function publish(changed) {
734
+ if (!changed) return false;
735
+ emit("update:modelValue", viewport.offset.value);
736
+ emit("scroll", viewport.range.value);
737
+ return true;
738
+ }
739
+ function scrollTo(offset) {
740
+ return publish(viewport.scrollTo(offset));
741
+ }
742
+ function scrollBy(delta) {
743
+ return publish(viewport.scrollBy(delta));
744
+ }
745
+ function scrollIntoView(index, alignment = "nearest") {
746
+ return publish(viewport.scrollIntoView(index, alignment));
747
+ }
748
+ function isVisible(index) {
749
+ const range = viewport.range.value;
750
+ return index >= range.visibleStart && index < range.visibleEnd;
751
+ }
752
+ function itemSlot(index) {
753
+ return {
754
+ ...viewport.range.value,
755
+ index,
756
+ visible: isVisible(index)
757
+ };
758
+ }
759
+ watch([
760
+ () => __props.itemCount,
761
+ () => __props.viewportSize,
762
+ () => __props.modelValue
763
+ ], ([itemCount, viewportSize, modelValue], [previousItemCount, previousViewportSize, previousModelValue]) => {
764
+ const itemCountChanged = itemCount !== previousItemCount;
765
+ const viewportSizeChanged = viewportSize !== previousViewportSize;
766
+ const modelValueChanged = modelValue !== previousModelValue;
767
+ const followedEnd = itemCountChanged && __props.followOutput && viewport.atEnd.value;
768
+ const previousOffset = viewport.offset.value;
769
+ if (itemCountChanged) viewport.setItemCount(itemCount);
770
+ if (viewportSizeChanged) viewport.setViewportSize(viewportSize);
771
+ if (followedEnd && !modelValueChanged) viewport.scrollTo(viewport.maxOffset.value);
772
+ if (modelValue !== void 0 && (modelValueChanged || (itemCountChanged || viewportSizeChanged) && !followedEnd)) viewport.scrollTo(modelValue);
773
+ const offsetChanged = previousOffset !== viewport.offset.value;
774
+ const requestedOffsetWasClamped = modelValue !== void 0 && modelValue !== viewport.offset.value;
775
+ if (requestedOffsetWasClamped || offsetChanged && !modelValueChanged) emit("update:modelValue", viewport.offset.value);
776
+ if (offsetChanged && (itemCountChanged || viewportSizeChanged || requestedOffsetWasClamped)) emit("scroll", viewport.range.value);
777
+ });
778
+ watch(() => __props.overscan, (value) => viewport.setOverscan(value));
779
+ useInput((_input, key) => {
780
+ if (key.eventType === "release") return;
781
+ if (key.upArrow) scrollBy(-1);
782
+ else if (key.downArrow) scrollBy(1);
783
+ else if (key.pageUp) scrollBy(-Math.max(1, __props.viewportSize - 1));
784
+ else if (key.pageDown) scrollBy(Math.max(1, __props.viewportSize - 1));
785
+ else if (key.home) scrollTo(0);
786
+ else if (key.end) scrollTo(viewport.maxOffset.value);
787
+ }, { isActive });
788
+ useMouse((event) => {
789
+ if (event.kind === "scroll-up") scrollBy(-normalizedWheelStep.value);
790
+ else if (event.kind === "scroll-down") scrollBy(normalizedWheelStep.value);
791
+ }, { isActive });
792
+ __expose({
793
+ scrollTo,
794
+ scrollBy,
795
+ scrollIntoView,
796
+ range: () => viewport.range.value
797
+ });
798
+ return (_ctx, _cache) => {
799
+ return openBlock(), createBlock(unref(Box), mergeProps({ "flex-direction": "column" }, rootAccessibilityProps.value), {
800
+ default: withCtx(() => [
801
+ renderSlot(_ctx.$slots, "start"),
802
+ createVNode(unref(Box), { "flex-direction": __props.showScrollbar ? "row" : "column" }, {
803
+ default: withCtx(() => [createVNode(unref(Box), {
804
+ "flex-direction": "column",
805
+ height: __props.viewportSize,
806
+ overflow: "hidden"
807
+ }, {
808
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(retainedIndexes.value, (index) => {
809
+ return openBlock(), createBlock(unref(Box), {
810
+ key: index,
811
+ display: isVisible(index) ? "flex" : "none",
812
+ "aria-hidden": !isVisible(index),
813
+ "data-scroll-index": index
814
+ }, {
815
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default", mergeProps({ ref_for: true }, itemSlot(index)))]),
816
+ _: 2
817
+ }, 1032, [
818
+ "display",
819
+ "aria-hidden",
820
+ "data-scroll-index"
821
+ ]);
822
+ }), 128))]),
823
+ _: 3
824
+ }, 8, ["height"]), __props.showScrollbar && __props.itemCount > __props.viewportSize ? (openBlock(), createBlock(ScrollBar_default, {
825
+ key: 0,
826
+ "item-count": __props.itemCount,
827
+ "viewport-size": __props.viewportSize,
828
+ offset: unref(viewport).offset.value,
829
+ track: __props.scrollbarTrack,
830
+ thumb: __props.scrollbarThumb
831
+ }, null, 8, [
832
+ "item-count",
833
+ "viewport-size",
834
+ "offset",
835
+ "track",
836
+ "thumb"
837
+ ])) : createCommentVNode("v-if", true)]),
838
+ _: 3
839
+ }, 8, ["flex-direction"]),
840
+ renderSlot(_ctx.$slots, "end")
841
+ ]),
842
+ _: 3
843
+ }, 16);
844
+ };
845
+ }
846
+ });
847
+ //#endregion
553
848
  //#region src/components/Newline.ts
554
849
  /**
555
850
  * Newline Component - inserts one or more newline characters inside Text.
@@ -2894,6 +3189,6 @@ const Avatar = defineComponent({
2894
3189
  }
2895
3190
  });
2896
3191
  //#endregion
2897
- export { Newline as A, Select as C, Code as D, Link as E, Stack as F, VStack as I, Divider as L, Card as M, Grid as N, Transform as O, HStack as P, Spacer as R, Checkbox as S, TextInput as T, ProgressBar as _, Modal as a, Confirm as b, Tabs as c, Table as d, List as f, Alert as g, Badge as h, StatusBar as i, Text as j, Static as k, Menu as l, Timer as m, KeyHint as n, Stepper as o, Tooltip as p, Header as r, Breadcrumb as s, Avatar as t, Tree as u, Spinner as v, TextArea as w, RadioGroup as x, Form as y, Box as z };
3192
+ export { Newline as A, Spacer as B, Select as C, Code as D, Link as E, Grid as F, HStack as I, Stack as L, ScrollBar_default as M, Text as N, Transform as O, Card as P, VStack as R, Checkbox as S, TextInput as T, Box as V, ProgressBar as _, Modal as a, Confirm as b, Tabs as c, Table as d, List as f, Alert as g, Badge as h, StatusBar as i, ScrollBox_default as j, Static as k, Menu as l, Timer as m, KeyHint as n, Stepper as o, Tooltip as p, Header as r, Breadcrumb as s, Avatar as t, Tree as u, Spinner as v, TextArea as w, RadioGroup as x, Form as y, Divider as z };
2898
3193
 
2899
- //# sourceMappingURL=components-CqGU-NNE.mjs.map
3194
+ //# sourceMappingURL=components-DWIDBGTL.mjs.map