pxd 0.0.61 → 0.0.63

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 (223) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/_internal/dismiss-container.d.vue.ts +28 -0
  3. package/dist/components/_internal/dismiss-container.vue +162 -0
  4. package/dist/components/_internal/popover-arrow.d.vue.ts +9 -0
  5. package/dist/components/_internal/popover-arrow.vue +38 -0
  6. package/dist/components/active-graph/index.vue +4 -4
  7. package/dist/components/avatar/index.vue +5 -7
  8. package/dist/components/avatar-group/index.d.vue.ts +0 -1
  9. package/dist/components/avatar-group/index.vue +1 -1
  10. package/dist/components/backtop/index.vue +1 -1
  11. package/dist/components/badge/index.d.vue.ts +5 -1
  12. package/dist/components/badge/index.vue +18 -4
  13. package/dist/components/badge/types.d.ts +5 -0
  14. package/dist/components/book/index.vue +1 -1
  15. package/dist/components/browser/index.vue +1 -1
  16. package/dist/components/bubble/index.d.vue.ts +22 -0
  17. package/dist/components/bubble/index.vue +59 -0
  18. package/dist/components/bubble/types.d.ts +6 -0
  19. package/dist/components/button/index.d.vue.ts +0 -2
  20. package/dist/components/button/index.vue +30 -21
  21. package/dist/components/button/types.d.ts +3 -2
  22. package/dist/components/button-group/index.d.vue.ts +14 -0
  23. package/dist/components/button-group/index.vue +26 -0
  24. package/dist/components/button-group/types.d.ts +9 -0
  25. package/dist/components/carousel/index.d.vue.ts +3 -3
  26. package/dist/components/carousel/index.vue +146 -113
  27. package/dist/components/carousel/types.d.ts +1 -1
  28. package/dist/components/carousel-item/index.vue +22 -17
  29. package/dist/components/checkbox/index.vue +6 -6
  30. package/dist/components/checkbox-group/index.d.vue.ts +1 -1
  31. package/dist/components/chip/index.d.vue.ts +1 -5
  32. package/dist/components/chip/index.vue +4 -4
  33. package/dist/components/color-selector/index.d.vue.ts +12 -0
  34. package/dist/components/color-selector/index.vue +64 -0
  35. package/dist/components/color-selector/types.d.ts +12 -0
  36. package/dist/components/command-menu/index.d.vue.ts +6 -6
  37. package/dist/components/command-menu/index.vue +23 -32
  38. package/dist/components/command-menu/types.d.ts +1 -1
  39. package/dist/components/command-menu-group/index.vue +15 -6
  40. package/dist/components/command-menu-group/types.d.ts +1 -1
  41. package/dist/components/countdown/index.d.vue.ts +11 -11
  42. package/dist/components/drawer/index.d.vue.ts +8 -8
  43. package/dist/components/drawer/index.vue +13 -10
  44. package/dist/components/drawer/types.d.ts +4 -3
  45. package/dist/components/ellipsis-text/index.d.vue.ts +4 -1
  46. package/dist/components/ellipsis-text/index.vue +84 -107
  47. package/dist/components/ellipsis-text/types.d.ts +2 -1
  48. package/dist/components/error/index.vue +1 -1
  49. package/dist/components/fader/index.vue +5 -9
  50. package/dist/components/gauge/index.vue +34 -29
  51. package/dist/components/grid/index.vue +1 -1
  52. package/dist/components/grid-item/index.vue +1 -1
  53. package/dist/components/hold-button/index.d.vue.ts +8 -10
  54. package/dist/components/hold-button/index.vue +20 -29
  55. package/dist/components/hold-button/types.d.ts +5 -6
  56. package/dist/components/index.d.ts +7 -0
  57. package/dist/components/index.js +7 -0
  58. package/dist/components/input/index.d.vue.ts +8 -8
  59. package/dist/components/input/index.vue +5 -4
  60. package/dist/components/intersection-observer/index.vue +4 -4
  61. package/dist/components/kbd/index.vue +1 -1
  62. package/dist/components/link-button/index.d.vue.ts +4 -4
  63. package/dist/components/link-button/index.vue +9 -8
  64. package/dist/components/link-button/types.d.ts +0 -3
  65. package/dist/components/list/index.d.vue.ts +10 -15
  66. package/dist/components/list/index.vue +58 -131
  67. package/dist/components/list/types.d.ts +4 -4
  68. package/dist/components/list-item/index.d.vue.ts +2 -2
  69. package/dist/components/list-item/index.vue +44 -39
  70. package/dist/components/loading-bar/index.vue +8 -7
  71. package/dist/components/material/index.vue +24 -46
  72. package/dist/components/menu/index.d.vue.ts +6 -8
  73. package/dist/components/menu/index.vue +18 -24
  74. package/dist/components/menu/types.d.ts +1 -2
  75. package/dist/components/message/composables/use-group-expand.d.ts +13 -0
  76. package/dist/components/message/composables/use-group-expand.js +50 -0
  77. package/dist/components/message/composables/use-message-timer.d.ts +9 -0
  78. package/dist/components/message/composables/use-message-timer.js +61 -0
  79. package/dist/components/message/composables/use-promise-message.d.ts +4 -0
  80. package/dist/components/message/composables/use-promise-message.js +49 -0
  81. package/dist/components/message/index.d.vue.ts +6 -33
  82. package/dist/components/message/index.vue +33 -185
  83. package/dist/components/message/types.d.ts +2 -2
  84. package/dist/components/message-item/index.vue +26 -2
  85. package/dist/components/modal/index.d.vue.ts +7 -7
  86. package/dist/components/modal/index.vue +7 -3
  87. package/dist/components/modal/types.d.ts +7 -3
  88. package/dist/components/note/index.vue +2 -2
  89. package/dist/components/number-input/index.d.vue.ts +5 -4
  90. package/dist/components/number-input/index.vue +3 -0
  91. package/dist/components/number-input/types.d.ts +1 -0
  92. package/dist/components/overlay/index.d.vue.ts +6 -3
  93. package/dist/components/overlay/index.vue +63 -68
  94. package/dist/components/overlay/types.d.ts +5 -4
  95. package/dist/components/pagination/index.vue +2 -2
  96. package/dist/components/pin-input/index.d.vue.ts +1 -1
  97. package/dist/components/pin-input/index.vue +7 -6
  98. package/dist/components/placeholder/index.vue +1 -1
  99. package/dist/components/popover/index.d.vue.ts +7 -8
  100. package/dist/components/popover/index.vue +149 -239
  101. package/dist/components/popover/types.d.ts +5 -5
  102. package/dist/components/progress/index.vue +1 -1
  103. package/dist/components/radio/index.vue +2 -2
  104. package/dist/components/resizable/index.vue +43 -51
  105. package/dist/components/resizable/types.d.ts +1 -1
  106. package/dist/components/resizable-handle/index.d.vue.ts +4 -1
  107. package/dist/components/resizable-handle/index.vue +29 -3
  108. package/dist/components/resizable-panel/index.vue +3 -7
  109. package/dist/components/scalable-text/index.d.vue.ts +9 -0
  110. package/dist/components/scalable-text/index.vue +147 -0
  111. package/dist/components/scalable-text/types.d.ts +12 -0
  112. package/dist/components/scrollable/index.d.vue.ts +2 -2
  113. package/dist/components/scrollable/index.vue +4 -3
  114. package/dist/components/separator/index.d.vue.ts +6 -0
  115. package/dist/components/separator/index.vue +18 -0
  116. package/dist/components/separator/types.d.ts +5 -0
  117. package/dist/components/skeleton/index.d.vue.ts +1 -1
  118. package/dist/components/slider/index.d.vue.ts +1 -1
  119. package/dist/components/slider/index.vue +39 -7
  120. package/dist/components/snippet/index.vue +16 -13
  121. package/dist/components/spinner/index.vue +3 -1
  122. package/dist/components/stack/index.d.vue.ts +1 -1
  123. package/dist/components/stack/index.vue +1 -1
  124. package/dist/components/switch/index.d.vue.ts +1 -1
  125. package/dist/components/switch/index.vue +4 -3
  126. package/dist/components/switch-item/index.vue +1 -1
  127. package/dist/components/tabs/index.d.vue.ts +12 -0
  128. package/dist/components/tabs/index.vue +270 -0
  129. package/dist/components/tabs/types.d.ts +12 -0
  130. package/dist/components/tabs-item/index.d.vue.ts +4 -0
  131. package/dist/components/tabs-item/index.vue +16 -0
  132. package/dist/components/tabs-item/types.d.ts +10 -0
  133. package/dist/components/text/index.vue +1 -1
  134. package/dist/components/textarea/index.d.vue.ts +2 -2
  135. package/dist/components/textarea/index.vue +1 -1
  136. package/dist/components/time-picker/index.d.vue.ts +3 -5
  137. package/dist/components/time-picker/index.vue +53 -45
  138. package/dist/components/time-picker/types.d.ts +1 -2
  139. package/dist/components/toggle/index.d.vue.ts +0 -2
  140. package/dist/components/toggle/index.vue +6 -6
  141. package/dist/components/toggle-button/index.vue +8 -6
  142. package/dist/components/tooltip/index.d.vue.ts +1 -1
  143. package/dist/components/tooltip/index.vue +19 -11
  144. package/dist/components/tooltip/types.d.ts +2 -2
  145. package/dist/components/virtual-list/index.d.vue.ts +8 -8
  146. package/dist/components/virtual-list/index.vue +27 -5
  147. package/dist/components/virtual-list/types.d.ts +3 -0
  148. package/dist/composables/index.d.ts +4 -1
  149. package/dist/composables/index.js +4 -1
  150. package/dist/composables/use-browser-observer.js +2 -2
  151. package/dist/composables/use-client-online.js +2 -2
  152. package/dist/composables/use-color-scheme.js +2 -2
  153. package/dist/composables/use-countdown.js +3 -2
  154. package/dist/composables/use-deferred-value.js +2 -2
  155. package/dist/composables/use-delay-destroy.js +11 -6
  156. package/dist/composables/use-document-hidden.js +2 -2
  157. package/dist/composables/use-focus-trap.js +2 -2
  158. package/dist/composables/use-list-filter.d.ts +11 -0
  159. package/dist/composables/use-list-filter.js +56 -0
  160. package/dist/composables/use-list-navigation.d.ts +27 -0
  161. package/dist/composables/use-list-navigation.js +159 -0
  162. package/dist/composables/use-lock-scroll.js +12 -12
  163. package/dist/composables/use-media-query.js +2 -2
  164. package/dist/composables/use-outside-click.d.ts +1 -1
  165. package/dist/composables/use-outside-click.js +8 -11
  166. package/dist/composables/use-overlay-manager.d.ts +18 -0
  167. package/dist/composables/use-overlay-manager.js +80 -0
  168. package/dist/composables/use-popover-responsive.d.ts +6 -8
  169. package/dist/composables/use-popover-responsive.js +9 -12
  170. package/dist/composables/use-repeat-action.js +2 -2
  171. package/dist/composables/use-swipe-gesture.d.ts +65 -0
  172. package/dist/composables/use-swipe-gesture.js +99 -0
  173. package/dist/composables/use-virtual-list.d.ts +5 -3
  174. package/dist/composables/use-virtual-list.js +25 -14
  175. package/dist/composables/use-window-size.js +2 -2
  176. package/dist/constants/size.d.ts +12 -0
  177. package/dist/constants/size.js +12 -0
  178. package/dist/contexts/button.d.ts +5 -0
  179. package/dist/contexts/button.js +5 -0
  180. package/dist/contexts/carousel.d.ts +2 -1
  181. package/dist/contexts/list.d.ts +23 -3
  182. package/dist/contexts/list.js +6 -2
  183. package/dist/contexts/resizable.d.ts +3 -11
  184. package/dist/contexts/tabs.d.ts +15 -0
  185. package/dist/contexts/tabs.js +2 -0
  186. package/dist/locales/en-us.d.ts +4 -4
  187. package/dist/locales/en-us.js +4 -4
  188. package/dist/locales/zh-cn.d.ts +4 -4
  189. package/dist/locales/zh-cn.js +4 -4
  190. package/dist/plugins/dayjs-millisecond-token.js +1 -1
  191. package/dist/styles/source.css +133 -128
  192. package/dist/styles/styles.css +2 -2
  193. package/dist/styles/tw.css +133 -128
  194. package/dist/types/shared/props.d.ts +1 -0
  195. package/dist/types/shared/utils.d.ts +1 -4
  196. package/dist/utils/date.d.ts +3 -3
  197. package/dist/utils/dom.d.ts +1 -0
  198. package/dist/utils/dom.js +4 -0
  199. package/dist/utils/event.d.ts +2 -1
  200. package/dist/utils/event.js +7 -1
  201. package/dist/utils/format.d.ts +3 -3
  202. package/dist/utils/format.js +5 -4
  203. package/dist/utils/fuzzy-search.d.ts +7 -0
  204. package/dist/utils/fuzzy-search.js +61 -0
  205. package/dist/utils/get.d.ts +2 -0
  206. package/dist/utils/get.js +15 -1
  207. package/dist/utils/index.d.ts +10 -11
  208. package/dist/utils/index.js +2 -3
  209. package/dist/utils/ref.d.ts +2 -2
  210. package/dist/utils/{throttle.d.ts → timing.d.ts} +1 -0
  211. package/dist/utils/{throttle.js → timing.js} +4 -2
  212. package/package.json +40 -37
  213. package/volar.d.ts +7 -0
  214. package/dist/components/overlay/overlay-stack.d.ts +0 -3
  215. package/dist/components/overlay/overlay-stack.js +0 -17
  216. package/dist/composables/use-pointer-gesture.d.ts +0 -180
  217. package/dist/composables/use-pointer-gesture.js +0 -406
  218. package/dist/utils/debounce.d.ts +0 -1
  219. package/dist/utils/debounce.js +0 -1
  220. package/dist/utils/regexp.d.ts +0 -8
  221. package/dist/utils/regexp.js +0 -8
  222. package/dist/utils/responsive.d.ts +0 -3
  223. package/dist/utils/responsive.js +0 -14
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed, nextTick, onMounted, ref, shallowRef } from "vue";
2
+ import { nextTick, onMounted, ref, shallowRef } from "vue";
3
3
  import { provideResizableContext } from "../../contexts/resizable";
4
4
  defineOptions({
5
5
  name: "PResizable",
@@ -8,10 +8,10 @@ defineOptions({
8
8
  const props = defineProps({
9
9
  direction: { type: String, required: false, default: "horizontal" }
10
10
  });
11
- const panelSizes = ref([]);
11
+ const panelSizes = ref({});
12
12
  const panelConfigs = ref([]);
13
13
  const handleConfigs = ref([]);
14
- const orderCounter = ref(0);
14
+ const orderCounter = shallowRef(0);
15
15
  const containerRef = shallowRef();
16
16
  function registerPanel(config) {
17
17
  const existingIndex = panelConfigs.value.findIndex((p) => p.id === config.id);
@@ -32,7 +32,8 @@ function unregisterPanel(id) {
32
32
  const index = panelConfigs.value.findIndex((p) => p.id === id);
33
33
  if (index !== -1) {
34
34
  panelConfigs.value.splice(index, 1);
35
- panelSizes.value.splice(index, 1);
35
+ const { [id]: _, ...rest } = panelSizes.value;
36
+ panelSizes.value = rest;
36
37
  }
37
38
  }
38
39
  function registerHandle(config) {
@@ -54,8 +55,7 @@ function unregisterHandle(id) {
54
55
  }
55
56
  }
56
57
  function getPanelSize(id) {
57
- const index = panelConfigs.value.findIndex((p) => p.id === id);
58
- return index !== -1 ? panelSizes.value[index] || 0 : 0;
58
+ return panelSizes.value[id] || 0;
59
59
  }
60
60
  function onHandleDrag(handleId, delta) {
61
61
  const handleOrder = handleConfigs.value.find((h) => h.id === handleId)?.order;
@@ -74,40 +74,33 @@ function calculateContainerSize() {
74
74
  }
75
75
  return props.direction === "horizontal" ? containerRef.value.offsetWidth : containerRef.value.offsetHeight;
76
76
  }
77
- function calculateInitialPanelSizes(totalSize) {
78
- const sizes = Array.from({ length: panelConfigs.value.length }, () => 0);
79
- let remainingSize = totalSize;
80
- const autoSizedPanelIndices = [];
77
+ function calculateInitialPanelSizes() {
78
+ const sizes = {};
79
+ let remainingSize = 100;
80
+ const autoSizedPanelIds = [];
81
81
  const sortedConfigs = [...panelConfigs.value].sort((a, b) => a.order - b.order);
82
- sortedConfigs.forEach((config, index) => {
82
+ sortedConfigs.forEach((config) => {
83
83
  const minSize = config.minSize || 0;
84
84
  const initialSizeNum = config.size;
85
85
  if (initialSizeNum !== null && initialSizeNum !== void 0) {
86
- const size = Math.max(initialSizeNum, minSize);
87
- sizes[index] = size;
88
- remainingSize -= size;
86
+ sizes[config.id] = Math.max(initialSizeNum, minSize);
87
+ remainingSize -= sizes[config.id];
89
88
  } else {
90
- sizes[index] = minSize;
89
+ sizes[config.id] = minSize;
91
90
  remainingSize -= minSize;
92
- autoSizedPanelIndices.push(index);
91
+ autoSizedPanelIds.push(config.id);
93
92
  }
94
93
  });
95
- return { sizes, remainingSize, autoSizedPanelIndices };
94
+ return { sizes, remainingSize, autoSizedPanelIds };
96
95
  }
97
- function distributeRemainingSpace(sizes, remainingSize, autoSizedPanelIndices) {
98
- if (autoSizedPanelIndices.length === 0 || remainingSize <= 0) {
96
+ function distributeRemainingSpace(sizes, remainingSize, autoSizedPanelIds) {
97
+ if (autoSizedPanelIds.length === 0 || remainingSize <= 0) {
99
98
  return sizes;
100
99
  }
101
- const updatedSizes = [...sizes];
102
- const avgSize = Math.floor(remainingSize / autoSizedPanelIndices.length);
103
- let remainder = remainingSize % autoSizedPanelIndices.length;
104
- autoSizedPanelIndices.forEach((index) => {
105
- let sizeToAdd = avgSize;
106
- if (remainder > 0) {
107
- sizeToAdd++;
108
- remainder--;
109
- }
110
- updatedSizes[index] += sizeToAdd;
100
+ const updatedSizes = { ...sizes };
101
+ const avgSize = remainingSize / autoSizedPanelIds.length;
102
+ autoSizedPanelIds.forEach((id) => {
103
+ updatedSizes[id] += avgSize;
111
104
  });
112
105
  return updatedSizes;
113
106
  }
@@ -116,25 +109,27 @@ async function initPanelSizes() {
116
109
  return;
117
110
  }
118
111
  await nextTick();
119
- const totalSize = calculateContainerSize();
120
- if (totalSize <= 0) {
121
- return;
122
- }
123
- const { sizes, remainingSize, autoSizedPanelIndices } = calculateInitialPanelSizes(totalSize);
124
- const finalSizes = distributeRemainingSpace(sizes, remainingSize, autoSizedPanelIndices);
125
- panelSizes.value = finalSizes;
112
+ const { sizes, remainingSize, autoSizedPanelIds } = calculateInitialPanelSizes();
113
+ panelSizes.value = distributeRemainingSpace(sizes, remainingSize, autoSizedPanelIds);
126
114
  }
127
115
  function onDrag(index, { deltaX, deltaY }) {
128
- if (index < 0 || index + 1 >= panelSizes.value.length) {
116
+ if (index < 0 || index + 1 >= panelConfigs.value.length) {
129
117
  return;
130
118
  }
119
+ const containerSize = calculateContainerSize();
120
+ if (containerSize <= 0) {
121
+ return;
122
+ }
123
+ const prevId = panelConfigs.value[index].id;
124
+ const nextId = panelConfigs.value[index + 1].id;
131
125
  const delta = props.direction === "horizontal" ? deltaX : deltaY;
132
- const prevSize = panelSizes.value[index];
133
- const nextSize = panelSizes.value[index + 1];
126
+ const deltaPercent = delta / containerSize * 100;
127
+ const prevSize = panelSizes.value[prevId] || 0;
128
+ const nextSize = panelSizes.value[nextId] || 0;
134
129
  const prevMinSize = panelConfigs.value[index]?.minSize || 0;
135
130
  const nextMinSize = panelConfigs.value[index + 1]?.minSize || 0;
136
- let newPrevSize = prevSize + delta;
137
- let newNextSize = nextSize - delta;
131
+ let newPrevSize = prevSize + deltaPercent;
132
+ let newNextSize = nextSize - deltaPercent;
138
133
  if (newPrevSize < prevMinSize) {
139
134
  const diff = prevMinSize - newPrevSize;
140
135
  newPrevSize = prevMinSize;
@@ -150,22 +145,19 @@ function onDrag(index, { deltaX, deltaY }) {
150
145
  if (newNextSize < nextMinSize) {
151
146
  newNextSize = nextMinSize;
152
147
  }
153
- const newSizes = [...panelSizes.value];
154
- newSizes[index] = newPrevSize;
155
- newSizes[index + 1] = newNextSize;
156
- panelSizes.value = newSizes;
148
+ panelSizes.value[prevId] = newPrevSize;
149
+ panelSizes.value[nextId] = newNextSize;
157
150
  }
158
151
  provideResizableContext({
152
+ props,
153
+ panelSizes,
159
154
  registerPanel,
160
155
  unregisterPanel,
161
156
  registerHandle,
162
157
  unregisterHandle,
163
158
  getPanelSize,
164
159
  onHandleDrag,
165
- resetPanels: initPanelSizes,
166
- direction: computed(() => props.direction),
167
- panelSizes,
168
- panelConfigs
160
+ resetPanels: initPanelSizes
169
161
  });
170
162
  onMounted(async () => {
171
163
  await nextTick();
@@ -176,8 +168,8 @@ onMounted(async () => {
176
168
  <template>
177
169
  <div
178
170
  ref="containerRef"
179
- :data-direction="direction"
180
- class="pxd-resizable flex size-full max-w-full flex-row overflow-hidden data-[direction=vertical]:flex-col"
171
+ :data-orientation="direction"
172
+ class="pxd-resizable flex size-full max-w-full flex-row overflow-hidden data-[orientation=vertical]:flex-col"
181
173
  v-bind="$attrs"
182
174
  >
183
175
  <slot />
@@ -3,8 +3,8 @@ import type { ComponentDirection } from '../../types/shared'
3
3
  export interface PanelConfig {
4
4
  id: string
5
5
  size?: number | null
6
- minSize?: number
7
6
  order: number
7
+ minSize?: number
8
8
  }
9
9
 
10
10
  export interface HandleConfig {
@@ -1,3 +1,6 @@
1
- declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ interface ResizableHandleProps {
2
+ withHandle?: boolean;
3
+ }
4
+ declare const __VLS_export: import("vue").DefineComponent<ResizableHandleProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ResizableHandleProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
5
  declare const _default: typeof __VLS_export;
3
6
  export default _default;
@@ -6,6 +6,9 @@ defineOptions({
6
6
  name: "PResizableHandle",
7
7
  inheritAttrs: false
8
8
  });
9
+ defineProps({
10
+ withHandle: { type: Boolean, required: false }
11
+ });
9
12
  const uniqueId = getUniqueId();
10
13
  const resizableContext = useResizableContext();
11
14
  let isDragging = false;
@@ -48,7 +51,8 @@ onBeforeUnmount(() => {
48
51
 
49
52
  <template>
50
53
  <div
51
- class="pxd-resizable-handle relative shrink-0 touch-none bg-border select-none hover:z-1 hover:after:bg-primary/20 active:after:bg-primary/30 motion-safe:transition-colors after:motion-safe:transition-colors"
54
+ class="pxd-resizable-handle relative shrink-0 touch-none bg-border select-none hover:after:bg-primary/15 active:after:bg-primary/20 motion-safe:transition-colors after:motion-safe:transition-colors"
55
+ :data-handler="withHandle"
52
56
  @pointerdown.prevent="handlePointerDown"
53
57
  @pointermove="handlePointerMove"
54
58
  @pointerup="handlePointerUp"
@@ -59,6 +63,18 @@ onBeforeUnmount(() => {
59
63
  </template>
60
64
 
61
65
  <style lang="postcss">
66
+ .pxd-resizable-handle[data-handler='true']::before {
67
+ content: '';
68
+ position: absolute;
69
+ top: 50%;
70
+ left: 50%;
71
+ border-radius: 0.5rem;
72
+ transform: translate(-50%, -50%);
73
+ background-color: var(--color-gray-300);
74
+ pointer-events: none;
75
+ z-index: 1;
76
+ }
77
+
62
78
  .pxd-resizable-handle::after {
63
79
  content: '';
64
80
  position: absolute;
@@ -68,21 +84,31 @@ onBeforeUnmount(() => {
68
84
  transform: translate(-50%, -50%);
69
85
  }
70
86
 
71
- .pxd-resizable[data-direction='horizontal'] .pxd-resizable-handle {
87
+ .pxd-resizable[data-orientation='horizontal'] .pxd-resizable-handle {
72
88
  width: 1px;
73
89
  height: 100%;
74
90
  cursor: ew-resize;
75
91
 
92
+ &::before {
93
+ width: 0.375rem;
94
+ height: 1.5rem;
95
+ }
96
+
76
97
  &::after {
77
98
  height: 100%;
78
99
  }
79
100
  }
80
101
 
81
- .pxd-resizable[data-direction='vertical'] .pxd-resizable-handle {
102
+ .pxd-resizable[data-orientation='vertical'] .pxd-resizable-handle {
82
103
  width: 100%;
83
104
  height: 1px;
84
105
  cursor: ns-resize;
85
106
 
107
+ &::before {
108
+ width: 1.5rem;
109
+ height: 0.375rem;
110
+ }
111
+
86
112
  &::after {
87
113
  width: 100%;
88
114
  }
@@ -16,15 +16,11 @@ const computedStyle = computed(() => {
16
16
  if (!resizableContext) {
17
17
  return {};
18
18
  }
19
- const panelIndex = resizableContext.panelConfigs.value.findIndex((p) => p.id === uniqueId);
20
- const size = panelIndex >= 0 ? resizableContext.panelSizes.value[panelIndex] || 0 : 0;
19
+ const size = resizableContext.panelSizes.value[uniqueId] || 0;
21
20
  return {
22
- flexBasis: size > 0 ? `${size}px` : "auto",
21
+ flexBasis: size > 0 ? `${size}%` : "auto",
23
22
  flexGrow: size > 0 ? 0 : 1,
24
- flexShrink: size > 0 ? 0 : 1,
25
- // 在 Vue 2.7 中添加显式的 width/height 以确保更新生效
26
- ...size > 0 && resizableContext.direction.value === "horizontal" ? { width: `${size}px` } : {},
27
- ...size > 0 && resizableContext.direction.value === "vertical" ? { height: `${size}px` } : {}
23
+ flexShrink: size > 0 ? 0 : 1
28
24
  };
29
25
  });
30
26
  onMounted(() => {
@@ -0,0 +1,9 @@
1
+ import type { ScalableTextProps } from './types';
2
+ declare const __VLS_export: import("vue").DefineComponent<ScalableTextProps, {
3
+ fittedFontSize: import("vue").ShallowRef<number | null, number | null>;
4
+ needsWrap: import("vue").ShallowRef<boolean, boolean>;
5
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ScalableTextProps> & Readonly<{}>, {
6
+ minFontSize: number;
7
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,147 @@
1
+ <script setup>
2
+ import { prepareWithSegments, measureNaturalWidth } from "@chenglou/pretext";
3
+ import { shallowRef, computed, watch, nextTick, onBeforeUnmount } from "vue";
4
+ import { useResizeObserver } from "../../composables/use-browser-observer";
5
+ import { getStyle } from "../../utils/dom";
6
+ import { caf, raf } from "../../utils/event";
7
+ import { isServer } from "../../utils/is";
8
+ defineOptions({
9
+ name: "PScalableText",
10
+ inheritAttrs: false
11
+ });
12
+ const props = defineProps({
13
+ text: { type: String, required: true },
14
+ minFontSize: { type: Number, required: false, default: 12 }
15
+ });
16
+ const PRECISION = 0.5;
17
+ const needsWrap = shallowRef(false);
18
+ const containerRef = shallowRef();
19
+ const fittedFontSize = shallowRef(null);
20
+ let rafId = 0;
21
+ let pendingAdjust = false;
22
+ function parseSize(value) {
23
+ return Number.parseFloat(value) || 0;
24
+ }
25
+ function buildFont(style, sizePx) {
26
+ const fontStyle = style.fontStyle || "normal";
27
+ const fontWeight = style.fontWeight || "400";
28
+ const fontFamily = style.fontFamily || "sans-serif";
29
+ return `${fontStyle} ${fontWeight} ${sizePx}px ${fontFamily}`;
30
+ }
31
+ function measureWidth(text, font) {
32
+ return measureNaturalWidth(prepareWithSegments(text, font));
33
+ }
34
+ function adjust() {
35
+ if (isServer()) {
36
+ return;
37
+ }
38
+ const el = containerRef.value;
39
+ if (!el?.isConnected) {
40
+ return;
41
+ }
42
+ const text = props.text ?? "";
43
+ if (!text) {
44
+ fittedFontSize.value = null;
45
+ needsWrap.value = false;
46
+ return;
47
+ }
48
+ const saved = el.style.fontSize;
49
+ el.style.fontSize = "";
50
+ const style = getStyle(el);
51
+ const defaultSize = parseSize(style.fontSize);
52
+ el.style.fontSize = saved;
53
+ if (defaultSize <= 0) {
54
+ return;
55
+ }
56
+ const padLeft = parseSize(style.paddingLeft);
57
+ const padRight = parseSize(style.paddingRight);
58
+ const available = el.clientWidth - padLeft - padRight;
59
+ if (available <= 0) {
60
+ return;
61
+ }
62
+ const min = Math.max(0, props.minFontSize);
63
+ const defaultWidth = measureWidth(text, buildFont(style, defaultSize));
64
+ if (defaultWidth <= available) {
65
+ fittedFontSize.value = null;
66
+ needsWrap.value = false;
67
+ return;
68
+ }
69
+ const minWidth = measureWidth(text, buildFont(style, min));
70
+ if (minWidth > available) {
71
+ fittedFontSize.value = min;
72
+ needsWrap.value = true;
73
+ return;
74
+ }
75
+ const prevFit = fittedFontSize.value;
76
+ const seed = prevFit !== null && prevFit > min && prevFit < defaultSize ? prevFit : available / defaultWidth * defaultSize;
77
+ const clampedEst = Math.max(min, Math.min(defaultSize, seed));
78
+ const estWidth = measureWidth(text, buildFont(style, clampedEst));
79
+ let best;
80
+ if (estWidth <= available) {
81
+ best = clampedEst;
82
+ let lo = clampedEst;
83
+ let hi = Math.min(defaultSize, clampedEst + PRECISION * 4);
84
+ while (hi - lo > PRECISION) {
85
+ const mid = (lo + hi) / 2;
86
+ if (measureWidth(text, buildFont(style, mid)) <= available) {
87
+ best = mid;
88
+ lo = mid;
89
+ } else {
90
+ hi = mid;
91
+ }
92
+ }
93
+ } else {
94
+ best = min;
95
+ let lo = min;
96
+ let hi = clampedEst;
97
+ while (hi - lo > PRECISION) {
98
+ const mid = (lo + hi) / 2;
99
+ if (measureWidth(text, buildFont(style, mid)) <= available) {
100
+ best = mid;
101
+ lo = mid;
102
+ } else {
103
+ hi = mid;
104
+ }
105
+ }
106
+ }
107
+ fittedFontSize.value = best;
108
+ needsWrap.value = false;
109
+ }
110
+ function scheduleAdjust() {
111
+ if (pendingAdjust) {
112
+ return;
113
+ }
114
+ pendingAdjust = true;
115
+ rafId = raf(() => {
116
+ pendingAdjust = false;
117
+ nextTick(adjust);
118
+ });
119
+ }
120
+ const computedStyle = computed(() => {
121
+ const size = fittedFontSize.value;
122
+ if (size === null) {
123
+ return void 0;
124
+ }
125
+ return { fontSize: `${size}px` };
126
+ });
127
+ watch(() => [props.text, props.minFontSize], scheduleAdjust, { flush: "post" });
128
+ useResizeObserver(containerRef, scheduleAdjust);
129
+ onBeforeUnmount(() => {
130
+ caf(rafId);
131
+ });
132
+ defineExpose({
133
+ fittedFontSize,
134
+ needsWrap
135
+ });
136
+ </script>
137
+
138
+ <template>
139
+ <div
140
+ ref="containerRef"
141
+ class="pxd-scalable-text max-w-full"
142
+ :style="computedStyle"
143
+ v-bind="$attrs"
144
+ >
145
+ {{ text }}
146
+ </div>
147
+ </template>
@@ -0,0 +1,12 @@
1
+ export interface ScalableTextProps {
2
+ /**
3
+ * Text content to measure. Required for width calculation.
4
+ */
5
+ text: string
6
+ /**
7
+ * Minimum font size in pixels. When the text still overflows at this size,
8
+ * it will be allowed to wrap naturally.
9
+ * @default 12
10
+ */
11
+ minFontSize?: number
12
+ }
@@ -9,11 +9,11 @@ declare const __VLS_base: import("vue").DefineComponent<ScrollableProps, {
9
9
  scrollTo: typeof scrollTo;
10
10
  forceUpdate: typeof forceUpdate;
11
11
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
- scroll: (args_0: Event) => any;
13
12
  bottom: (args_0: import("../../types/shared").ComponentDirection, args_1: Event) => any;
13
+ scroll: (args_0: Event) => any;
14
14
  }, string, import("vue").PublicProps, Readonly<ScrollableProps> & Readonly<{
15
- onScroll?: ((args_0: Event) => any) | undefined;
16
15
  onBottom?: ((args_0: import("../../types/shared").ComponentDirection, args_1: Event) => any) | undefined;
16
+ onScroll?: ((args_0: Event) => any) | undefined;
17
17
  }>, {
18
18
  fader: boolean;
19
19
  scrollbar: boolean;
@@ -3,8 +3,9 @@ import { computed, onBeforeUnmount, onMounted, shallowRef } from "vue";
3
3
  import { useMutationObserver, useResizeObserver } from "../../composables/use-browser-observer";
4
4
  import { getStyle } from "../../utils/dom";
5
5
  import { cachedOff, cachedOn, off, once } from "../../utils/event";
6
+ import { raf } from "../../utils/event";
6
7
  import { isServer } from "../../utils/is";
7
- import { throttleByRaf } from "../../utils/throttle";
8
+ import { throttleByRaf } from "../../utils/timing";
8
9
  import PFader from "../fader/index.vue";
9
10
  defineOptions({
10
11
  name: "PScrollable",
@@ -226,7 +227,7 @@ function onEndDrag(ev) {
226
227
  dragState.direction = null;
227
228
  cachedOff(document, "mousemove", onDragMove);
228
229
  throttledUpdate.cancel();
229
- requestAnimationFrame(updateScrollbarMetrics);
230
+ raf(updateScrollbarMetrics);
230
231
  }
231
232
  function scrollTo(top, left) {
232
233
  if (!contentRef.value) {
@@ -264,7 +265,7 @@ onMounted(async () => {
264
265
  return;
265
266
  }
266
267
  getContainerPadding();
267
- requestAnimationFrame(updateScrollbarMetrics);
268
+ raf(updateScrollbarMetrics);
268
269
  });
269
270
  onBeforeUnmount(() => {
270
271
  throttledUpdate.cancel();
@@ -0,0 +1,6 @@
1
+ import type { SeparatorProps } from './types';
2
+ declare const __VLS_export: import("vue").DefineComponent<SeparatorProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<SeparatorProps> & Readonly<{}>, {
3
+ direction: import("../../types/shared").ComponentDirection;
4
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare const _default: typeof __VLS_export;
6
+ export default _default;
@@ -0,0 +1,18 @@
1
+ <script setup>
2
+ defineOptions({
3
+ name: "PSeparator",
4
+ inheritAttrs: false
5
+ });
6
+ const props = defineProps({
7
+ direction: { type: String, required: false, default: "vertical" }
8
+ });
9
+ </script>
10
+
11
+ <template>
12
+ <div
13
+ role="separator"
14
+ :aria-orientation="direction"
15
+ class="pxd-separator aria-[orientation=vertical]:h-3 inline-block bg-gray-300 leading-inherit aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=vertical]:w-px"
16
+ v-bind="$attrs"
17
+ />
18
+ </template>
@@ -0,0 +1,5 @@
1
+ import type { ComponentDirection } from '../../types/shared'
2
+
3
+ export interface SeparatorProps {
4
+ direction?: ComponentDirection
5
+ }
@@ -4,8 +4,8 @@ type __VLS_Slots = {} & {
4
4
  default?: (props: typeof __VLS_1) => any;
5
5
  };
6
6
  declare const __VLS_base: import("vue").DefineComponent<SkeletonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<SkeletonProps> & Readonly<{}>, {
7
- loading: boolean;
8
7
  height: string | number;
8
+ loading: boolean;
9
9
  shape: import("../../types/shared").ComponentShape;
10
10
  animated: boolean;
11
11
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -6,9 +6,9 @@ declare const __VLS_export: import("vue").DefineComponent<SliderProps, {}, {}, {
6
6
  onChange?: ((args_0: NonNullable<number | number[] | null | undefined>) => any) | undefined;
7
7
  "onUpdate:modelValue"?: ((args_0: NonNullable<number | number[] | null | undefined>) => any) | undefined;
8
8
  }>, {
9
+ modelValue: number | number[] | null;
9
10
  max: number;
10
11
  variant: import("../../types/shared").ComponentVariant | "secondary";
11
- modelValue: number | number[] | null;
12
12
  min: number;
13
13
  step: number;
14
14
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -5,7 +5,7 @@ import { useConfigProvider } from "../../contexts/config-provider";
5
5
  import { cachedOff, cachedOn, once } from "../../utils/event";
6
6
  import { NOOP } from "../../utils/event";
7
7
  import { getFallbackValue } from "../../utils/get";
8
- import { throttleByRaf } from "../../utils/throttle";
8
+ import { throttleByRaf } from "../../utils/timing";
9
9
  defineOptions({
10
10
  name: "PSlider",
11
11
  inheritAttrs: false,
@@ -239,7 +239,7 @@ onBeforeUnmount(() => {
239
239
  tabindex="0"
240
240
  :data-dragging="isDragging && activeThumb === 'start'"
241
241
  :data-range-start="true"
242
- class="pxd-slider--thumb group rounded-xs absolute -translate-x-1/2 touch-none appearance-none bg-none self-focus-ring outline-none hover:z-1 active:[--slider-thumb-scale:1.3] motion-safe:before:transition-all pointer-fine:hover:[--slider-thumb-scale:1.3]"
242
+ class="pxd-slider--thumb group rounded-xs absolute -translate-x-1/2 transform-gpu touch-none appearance-none bg-none self-focus-ring outline-none hover:z-1 active:[--slider-thumb-scale:1.3] motion-safe:before:transition-appearance pointer-fine:hover:[--slider-thumb-scale:1.3]"
243
243
  :class="[{ 'pointer-events-none': disabled }, computedSize.thumb]"
244
244
  :style="{ left: `${startPercentage}%` }"
245
245
  @keydown="onThumbKeydown"
@@ -247,7 +247,7 @@ onBeforeUnmount(() => {
247
247
  @pointerdown.prevent.stop="startDragging($event, 'start')"
248
248
  >
249
249
  <span
250
- class="py-1 px-1.5 text-xs -top-8 shadow-sm pointer-events-none absolute left-1/2 -translate-x-1/2 rounded-md bg-gray-1000 whitespace-nowrap text-gray-100 opacity-0 select-none group-hover:opacity-100 group-data-[dragging=true]:opacity-100 motion-safe:transition-opacity"
250
+ class="py-1 px-1.5 text-xs -top-8 pointer-events-none absolute left-1/2 -translate-x-1/2 rounded-md bg-gray-1000 whitespace-nowrap text-gray-100 opacity-0 shadow-border-base shadow-border-tooltip select-none group-hover:opacity-100 group-data-[dragging=true]:opacity-100 motion-safe:transition-opacity"
251
251
  >
252
252
  {{ valueRange[0] }}
253
253
  </span>
@@ -257,7 +257,7 @@ onBeforeUnmount(() => {
257
257
  tabindex="0"
258
258
  :data-range-start="range ? false : true"
259
259
  :data-dragging="isDragging && activeThumb === 'end'"
260
- class="pxd-slider--thumb group rounded-xs absolute -translate-x-1/2 touch-none appearance-auto bg-none self-focus-ring outline-none hover:z-1 active:[--slider-thumb-scale:1.3] motion-safe:before:transition-all pointer-fine:hover:[--slider-thumb-scale:1.3]"
260
+ class="pxd-slider--thumb group rounded-xs absolute -translate-x-1/2 transform-gpu touch-none appearance-auto bg-none self-focus-ring outline-none hover:z-1 active:[--slider-thumb-scale:1.3] motion-safe:before:transition-appearance pointer-fine:hover:[--slider-thumb-scale:1.3]"
261
261
  :class="[{ 'pointer-events-none': disabled }, computedSize.thumb]"
262
262
  :style="{ left: `${endPercentage}%` }"
263
263
  @keydown="onThumbKeydown"
@@ -265,7 +265,7 @@ onBeforeUnmount(() => {
265
265
  @pointerdown.prevent.stop="startDragging($event, 'end')"
266
266
  >
267
267
  <span
268
- class="py-1 px-1.5 text-xs -top-8 shadow-sm pointer-events-none absolute left-1/2 -translate-x-1/2 rounded-md bg-gray-1000 whitespace-nowrap text-gray-100 opacity-0 select-none group-hover:opacity-100 group-data-[dragging=true]:opacity-100 motion-safe:transition-opacity"
268
+ class="py-1 px-1.5 text-xs -top-8 pointer-events-none absolute left-1/2 -translate-x-1/2 rounded-md bg-gray-1000 whitespace-nowrap text-gray-100 opacity-0 shadow-border-base shadow-border-tooltip select-none group-hover:opacity-100 group-data-[dragging=true]:opacity-100 motion-safe:transition-opacity"
269
269
  >
270
270
  {{ valueRange[1] }}
271
271
  </span>
@@ -273,6 +273,38 @@ onBeforeUnmount(() => {
273
273
  </div>
274
274
  </template>
275
275
 
276
- <style>
277
- .pxd-slider--thumb[data-dragging=true]{--slider-thumb-scale:1.3}.pxd-slider--thumb:after,.pxd-slider--thumb:before{border-radius:inherit;content:"";left:50%;position:absolute;top:50%;transform:translate3d(-50%,-50%,0) scale(var(--slider-thumb-scale,1))}.pxd-slider--thumb:before{background-color:#fff;box-shadow:0 0 0 1px var(--color-gray-alpha-500),0 1px 2px var(--color-gray-alpha-100);height:100%;width:100%}.dark .pxd-slider--thumb:before{box-shadow:0 0 0 1px #000,0 1px 2px #0000000a}.pxd-slider--thumb:after{height:200%;width:200%}.pxd-slider:active .pxd-slider--thumb,.pxd-slider:active .pxd-slider--track{will-change:width,left}
276
+ <style lang="postcss">
277
+ .pxd-slider--thumb {
278
+ &[data-dragging='true'] {
279
+ --slider-thumb-scale: 1.3;
280
+ }
281
+
282
+ &::before,
283
+ &::after {
284
+ content: '';
285
+ position: absolute;
286
+ top: 50%;
287
+ left: 50%;
288
+ border-radius: inherit;
289
+ transform: translate3d(-50%, -50%, 0) scale(var(--slider-thumb-scale, 1));
290
+ }
291
+
292
+ &::before {
293
+ width: 100%;
294
+ height: 100%;
295
+ background-color: #fff;
296
+ box-shadow:
297
+ 0 0 0 1px var(--color-gray-alpha-500),
298
+ 0 1px 2px var(--color-gray-alpha-100);
299
+ }
300
+
301
+ &::after {
302
+ width: 200%;
303
+ height: 200%;
304
+ }
305
+ }
306
+
307
+ .dark .pxd-slider--thumb::before {
308
+ box-shadow: 0 0 0 1px var(--color-background-200);
309
+ }
278
310
  </style>