@astryx-vue/core 0.7.29 → 0.8.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 (91) hide show
  1. package/dist/AvatarGroup/index.d.ts +1 -1
  2. package/dist/Banner/index.d.ts +1 -1
  3. package/dist/Button/index.d.ts +1 -1
  4. package/dist/ButtonGroup/index.d.ts +1 -1
  5. package/dist/Calendar/index.d.ts +1 -1
  6. package/dist/Carousel/index.d.ts +1 -1
  7. package/dist/Carousel/index.js +1 -1
  8. package/dist/{Carousel-C8kE0YJh.js → Carousel-BOlQQSju.js} +82 -5
  9. package/dist/Center/index.d.ts +1 -1
  10. package/dist/Chat/index.d.ts +1 -1
  11. package/dist/CheckboxInput/index.d.ts +1 -1
  12. package/dist/CheckboxList/index.d.ts +1 -1
  13. package/dist/ClickableCard/index.d.ts +1 -1
  14. package/dist/Collapsible/index.d.ts +1 -1
  15. package/dist/CommandPalette/index.d.ts +1 -1
  16. package/dist/ContextMenu/index.d.ts +1 -1
  17. package/dist/DateInput/index.d.ts +1 -1
  18. package/dist/DateRangeInput/index.d.ts +1 -1
  19. package/dist/DateTimeInput/index.d.ts +1 -1
  20. package/dist/Dialog/index.d.ts +1 -1
  21. package/dist/Drawer/index.d.ts +1 -1
  22. package/dist/FileInput/index.d.ts +1 -1
  23. package/dist/HoverCard/index.d.ts +1 -1
  24. package/dist/InfoTip/index.d.ts +1 -1
  25. package/dist/InputGroup/index.d.ts +1 -1
  26. package/dist/Link/index.d.ts +1 -1
  27. package/dist/List/index.d.ts +1 -1
  28. package/dist/MoreMenu/index.d.ts +1 -1
  29. package/dist/MultiSelector/index.d.ts +1 -1
  30. package/dist/NavItem/index.d.ts +1 -1
  31. package/dist/NumberInput/index.d.ts +1 -1
  32. package/dist/OverflowList/index.d.ts +1 -1
  33. package/dist/Overlay/index.d.ts +1 -1
  34. package/dist/Pagination/index.d.ts +1 -1
  35. package/dist/Popover/index.d.ts +1 -1
  36. package/dist/PowerSearch/index.d.ts +1 -1
  37. package/dist/ProgressBar/index.d.ts +1 -1
  38. package/dist/Radio/index.d.ts +1 -1
  39. package/dist/RadioList/index.d.ts +1 -1
  40. package/dist/Resizable/index.d.ts +1 -1
  41. package/dist/ScrollableArea/index.d.ts +1 -1
  42. package/dist/SelectableCard/index.d.ts +1 -1
  43. package/dist/Selector/index.d.ts +1 -1
  44. package/dist/SideNav/index.d.ts +1 -1
  45. package/dist/Stack/index.d.ts +1 -1
  46. package/dist/Stepper/index.d.ts +1 -1
  47. package/dist/Switch/index.d.ts +1 -1
  48. package/dist/TabList/index.d.ts +1 -1
  49. package/dist/Table/index.d.ts +1 -1
  50. package/dist/TextArea/index.d.ts +1 -1
  51. package/dist/TextInput/index.d.ts +1 -1
  52. package/dist/TimeInput/index.d.ts +1 -1
  53. package/dist/Timestamp/index.d.ts +1 -1
  54. package/dist/ToggleButton/index.d.ts +1 -1
  55. package/dist/Tokenizer/index.d.ts +1 -1
  56. package/dist/Toolbar/index.d.ts +1 -1
  57. package/dist/Tooltip/index.d.ts +1 -1
  58. package/dist/TopNav/index.d.ts +1 -1
  59. package/dist/composables/index.d.ts +2 -2
  60. package/dist/composables/index.js +2 -2
  61. package/dist/{composables-lCxHhZQY.js → composables-CF4EnyHW.js} +441 -1
  62. package/dist/{index-DpYJBFJj.d.ts → index--tm6L1ot.d.ts} +1 -1
  63. package/dist/{index-dRBNR7Tq.d.ts → index-9GQ1lEoF.d.ts} +137 -57
  64. package/dist/{index-D4FgX9h3.d.ts → index-9tZJgo0R.d.ts} +2 -2
  65. package/dist/{index-DCxdesMw.d.ts → index-B62UAbz4.d.ts} +5 -5
  66. package/dist/{index-BuubzuE8.d.ts → index-BDZCJ9ri.d.ts} +2 -2
  67. package/dist/{index-BR3MOBYd.d.ts → index-BgT6mH3U.d.ts} +2 -2
  68. package/dist/{index-Cz72NaF_.d.ts → index-BzZC2Y7c.d.ts} +1 -1
  69. package/dist/{index-DY8Wph-A.d.ts → index-C1zwvxPH.d.ts} +2 -2
  70. package/dist/{index-BvWBeoa8.d.ts → index-CEjvYAUZ.d.ts} +1 -1
  71. package/dist/{index-CdvmnNMH.d.ts → index-COgrQZIL.d.ts} +1 -1
  72. package/dist/{index-DKgonPjs.d.ts → index-Ccj-2j56.d.ts} +31 -1
  73. package/dist/{index-BMCjAlq6.d.ts → index-CfPGC9aW.d.ts} +1 -1
  74. package/dist/{index-CvLWh-d-.d.ts → index-CpG5Wql5.d.ts} +4 -4
  75. package/dist/{index-MOtVbTwK.d.ts → index-CuW4AQ7M.d.ts} +2 -2
  76. package/dist/{index-BPf_jmME.d.ts → index-Cy1rEWC-.d.ts} +2 -2
  77. package/dist/{index-B16Jb5mf.d.ts → index-Dbw5OTuo.d.ts} +7 -7
  78. package/dist/{index-unAZVFGz.d.ts → index-Dy746dfn.d.ts} +1 -1
  79. package/dist/{index-a1jCiQP7.d.ts → index-FzAAjCFZ.d.ts} +1 -1
  80. package/dist/{index-CxdKu7d2.d.ts → index-MEix_m1o.d.ts} +1 -1
  81. package/dist/{index-CO9GW-ik.d.ts → index-Q1oG9yIT.d.ts} +1 -1
  82. package/dist/{index-BKnyTWPM.d.ts → index-ZbNwGVkS.d.ts} +1 -1
  83. package/dist/{index-Dlq0cFK-.d.ts → index-dWlCpnua.d.ts} +3 -3
  84. package/dist/{index-Bn-v89Vt.d.ts → index-mkbGYz8f.d.ts} +3 -3
  85. package/dist/{index-DZKv1WNB.d.ts → index-qayqGnJT.d.ts} +1 -1
  86. package/dist/{index-BEZ4ezJk.d.ts → index-wY6dKz6c.d.ts} +2 -2
  87. package/dist/index.d.ts +26 -27
  88. package/dist/index.js +3 -3
  89. package/dist/snapPagingValue-B5hfph1H.js +93 -0
  90. package/package.json +1 -1
  91. package/dist/index-BNbAJV9C.d.ts +0 -81
@@ -0,0 +1,93 @@
1
+ import { markRaw, toRaw } from "vue";
2
+ //#region src/composables/internal/snapPagingValue.ts
3
+ const values = /* @__PURE__ */ new WeakSet();
4
+ const attachments = /* @__PURE__ */ new WeakMap();
5
+ /** 生成一个用 `attach` 挂载的 `SnapPaging` 值。 */
6
+ function makeSnapPaging(attach) {
7
+ const value = markRaw({ attach });
8
+ values.add(value);
9
+ return value;
10
+ }
11
+ /** `value` 是否来自 `useSnapPaging`。被 Vue 包成响应式的也认得。 */
12
+ function isSnapPaging(value) {
13
+ return typeof value === "object" && value !== null && values.has(toRaw(value));
14
+ }
15
+ /** 把分页挂到 `element` 上,返回卸载函数。`onHeld` 在分页按住这一行期间收到它的位置。 */
16
+ function attachSnapPaging(value, element, onHeld) {
17
+ const attachment = toRaw(value).attach(element, onHeld);
18
+ attachments.set(element, attachment);
19
+ return () => {
20
+ attachments.delete(element);
21
+ attachment.detach();
22
+ };
23
+ }
24
+ /** 由分页把挂着分页的这一行挪到 `target`。这一行没挂分页时返回 false。 */
25
+ function moveSnapPaging(element, target) {
26
+ const attachment = attachments.get(element);
27
+ if (attachment == null) return false;
28
+ attachment.move(target);
29
+ return true;
30
+ }
31
+ /** 分页正按住这一行时把它挪到 `target`;没按住时返回 false。 */
32
+ function moveHeldSnapPaging(element, target) {
33
+ return attachments.get(element)?.moveHeld(target) ?? false;
34
+ }
35
+ /** 离 `at` 最近的停点;一行没有停点时就是 `at`。 */
36
+ function nearestStop(stops, at) {
37
+ return stops.reduce((best, stop) => Math.abs(stop - at) < Math.abs(best - at) ? stop : best, stops[0] ?? at);
38
+ }
39
+ function isRtl(element) {
40
+ return getComputedStyle(element).direction === "rtl";
41
+ }
42
+ /** 祖先缩放会缩放矩形,但不缩放滚动偏移。 */
43
+ function rowScale(element, box) {
44
+ return element.offsetWidth > 0 && box.width > 0 ? box.width / element.offsetWidth : 1;
45
+ }
46
+ function itemStops(element, shown, end) {
47
+ const rtl = isRtl(element);
48
+ const box = element.getBoundingClientRect();
49
+ const scale = rowScale(element, box);
50
+ const border = rtl ? element.offsetWidth - element.clientWidth - element.clientLeft : element.clientLeft;
51
+ const style = getComputedStyle(element);
52
+ const padding = Number.parseFloat(rtl ? style.scrollPaddingRight : style.scrollPaddingLeft) || 0;
53
+ return Array.from(element.children, (item) => {
54
+ const rect = item.getBoundingClientRect();
55
+ const fromEdge = (rtl ? box.right - rect.right : rect.left - box.left) / scale;
56
+ return {
57
+ item,
58
+ stop: Math.min(Math.max(fromEdge - border + shown - padding, 0), end)
59
+ };
60
+ });
61
+ }
62
+ /**
63
+ * 一行的停点,每页一个,从各项的矩形读出,再加回当前显示的偏移 `shown`。
64
+ * 相距不到半像素的停点算一个。末端那一页是末端就近归属的那一页:离末端不到
65
+ * 前一步一半的停点并进末端,停在这一行真正的尽头,原生吸附也跳过它那一项(`skipped`)。
66
+ */
67
+ function snapPages(element, shown, end) {
68
+ const stops = [];
69
+ const owners = [];
70
+ for (const { item, stop } of itemStops(element, shown, end)) if (stops.length === 0 || stop > stops[stops.length - 1] + .5) {
71
+ stops.push(stop);
72
+ owners.push([item]);
73
+ } else owners[owners.length - 1].push(item);
74
+ const n = stops.length;
75
+ if (n >= 3 && stops[n - 1] >= end - .5 && stops[n - 1] - stops[n - 2] < (stops[n - 2] - stops[n - 3]) / 2) {
76
+ const skipped = owners[n - 2];
77
+ stops.splice(n - 2, 1);
78
+ return {
79
+ stops,
80
+ skipped
81
+ };
82
+ }
83
+ return {
84
+ stops: n > 0 ? stops : [0],
85
+ skipped: []
86
+ };
87
+ }
88
+ /** 一行的停点(见 `snapPages`)。 */
89
+ function snapStops(element, shown, end) {
90
+ return snapPages(element, shown, end).stops;
91
+ }
92
+ //#endregion
93
+ export { moveSnapPaging as a, snapStops as c, moveHeldSnapPaging as i, isSnapPaging as n, nearestStop as o, makeSnapPaging as r, snapPages as s, attachSnapPaging as t };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astryx-vue/core",
3
3
  "type": "module",
4
- "version": "0.7.29",
4
+ "version": "0.8.0",
5
5
  "description": "Vue 3 components for the unofficial astryx-vue port of Astryx. Not affiliated with Meta.",
6
6
  "author": "ShenQingchuan",
7
7
  "license": "MIT",
@@ -1,81 +0,0 @@
1
- import { n as SpacingStep } from "./types-BTk0WZ0b.js";
2
- import { VNode } from "vue";
3
- //#region src/Carousel/types.d.ts
4
- /** Gap steps the carousel actually spaces with. Padding accepts every spacing step. */
5
- type CarouselGap = 0 | 0.5 | 1 | 1.5 | 2 | 3 | 4;
6
- interface CarouselHandle {
7
- /** Scroll forward by roughly one viewport. With `hasLoop`, wraps to the start at the end. */
8
- scrollNext: () => void;
9
- /** Scroll backward by roughly one viewport. With `hasLoop`, wraps to the end at the start. */
10
- scrollPrev: () => void;
11
- /**
12
- * Scroll the item at the 0-based index to the start edge.
13
- * The index is clamped. Only the carousel scrolls.
14
- */
15
- scrollTo: (index: number) => void;
16
- /** Whether a forward scroll is available. With `hasLoop`, true whenever the content overflows. */
17
- canScrollNext: () => boolean;
18
- /** Whether a backward scroll is available. With `hasLoop`, true whenever the content overflows. */
19
- canScrollPrev: () => boolean;
20
- }
21
- interface CarouselProps {
22
- /**
23
- * Gap between items, as a spacing step.
24
- * @default 1
25
- */
26
- gap?: CarouselGap;
27
- /**
28
- * Show previous and next buttons when the content overflows.
29
- * @default true
30
- */
31
- hasButtons?: boolean;
32
- /**
33
- * Fade the edges that hide overflow, so it is obvious there is more to scroll.
34
- * @default true
35
- */
36
- hasEdgeFade?: boolean;
37
- /**
38
- * Wrap from the last item back to the first, and the other way around.
39
- * Buttons stay available at both edges. Has no effect when the content fits.
40
- * @default false
41
- */
42
- hasLoop?: boolean;
43
- /**
44
- * Snap each direct child to the start edge.
45
- * @default false
46
- */
47
- hasSnap?: boolean;
48
- /**
49
- * Inline padding inside the scrollport, with matching scroll-padding so snap
50
- * points line up with the content edge.
51
- */
52
- padding?: SpacingStep;
53
- /**
54
- * Accessible name of the carousel region.
55
- * @default 'Carousel' (localized)
56
- */
57
- label?: string;
58
- }
59
- interface CarouselSlots {
60
- /** Carousel items, rendered in a horizontal scrollport. */
61
- default?: () => VNode[];
62
- }
63
- //#endregion
64
- //#region src/Carousel/Carousel.vue.d.ts
65
- type __VLS_Slots = CarouselSlots;
66
- declare const __VLS_base: import("vue").DefineComponent<CarouselProps, CarouselHandle, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CarouselProps> & Readonly<{}>, {
67
- gap: CarouselGap;
68
- hasButtons: boolean;
69
- hasEdgeFade: boolean;
70
- hasLoop: boolean;
71
- hasSnap: boolean;
72
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
73
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
74
- declare const _default: typeof __VLS_export;
75
- type __VLS_WithSlots<T, S> = T & {
76
- new (): {
77
- $slots: S;
78
- };
79
- };
80
- //#endregion
81
- export { CarouselSlots as a, CarouselProps as i, CarouselGap as n, CarouselHandle as r, _default as t };