x-next 1.9.0 → 1.10.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.
Files changed (51) hide show
  1. package/AI_USAGE.md +69 -7
  2. package/CHANGELOG.md +36 -0
  3. package/dist/_utils/chart/scale.d.ts +1 -1
  4. package/dist/components/_components/chart/axis-labels.d.ts +8 -0
  5. package/dist/components/_components/select-view/select-view.d.ts +9 -0
  6. package/dist/components/form-select/Select.d.ts +18 -5
  7. package/dist/components/form-select/SelectOptionGroup.vue.d.ts +1 -0
  8. package/dist/components/form-select/hooks/use-options.d.ts +1 -1
  9. package/dist/components/form-select/hooks/use-select.d.ts +1 -1
  10. package/dist/components/form-select/index.d.ts +42 -11
  11. package/dist/components/form-select/interface.d.ts +8 -0
  12. package/dist/components/link/Link.vue.d.ts +1 -1
  13. package/dist/components/link/index.d.ts +3 -3
  14. package/dist/components/pagination/page-options.vue.d.ts +60 -32
  15. package/dist/components/trigger/interface.d.ts +2 -0
  16. package/dist/components/virtual-list-v2/interface.d.ts +3 -0
  17. package/dist/components/virtual-list-v2/virtual-list.vue.d.ts +336 -1
  18. package/dist/es/_hooks/use-component-ref.js +9 -9
  19. package/dist/es/_utils/chart/scale.js +44 -39
  20. package/dist/es/components/_components/chart/ChartAxis.js +61 -36
  21. package/dist/es/components/_components/chart/axis-labels.js +26 -0
  22. package/dist/es/components/_components/select-view/select-view.js +89 -78
  23. package/dist/es/components/button/Button.js +23 -23
  24. package/dist/es/components/form-input-tag/InputTag.js +1 -1
  25. package/dist/es/components/form-select/Select.js +367 -318
  26. package/dist/es/components/form-select/SelectOption.vue.js +5 -3
  27. package/dist/es/components/form-select/SelectOption.vue2.js +54 -49
  28. package/dist/es/components/form-select/SelectOptionGroup.vue.js +17 -13
  29. package/dist/es/components/form-select/SelectOptionGroup.vue2.js +8 -5
  30. package/dist/es/components/form-select/hooks/use-options.js +40 -40
  31. package/dist/es/components/form-select/hooks/use-select.js +76 -71
  32. package/dist/es/components/trigger/Trigger.js +174 -183
  33. package/dist/es/components/virtual-list-v2/virtual-list.vue.js +22 -23
  34. package/dist/es/components/virtual-list-v2/virtual-list.vue2.js +67 -53
  35. package/dist/es/icons/icon.js +37 -36
  36. package/dist/es/icons/index.js +6 -8
  37. package/dist/es/icons/public/lucide-names.js +167 -0
  38. package/dist/es/icons/public/lucide.js +75 -188
  39. package/dist/es/index.js +152 -148
  40. package/dist/es/style.css +1 -1
  41. package/dist/icons/index.d.ts +3 -3
  42. package/dist/icons/names.d.ts +2 -2
  43. package/dist/icons/public/lucide-names.d.ts +32 -0
  44. package/dist/icons/public/lucide.d.ts +2 -2
  45. package/dist/index.cjs +3 -62
  46. package/dist/index.umd.js +3 -62
  47. package/dist/style/base.css +1 -1
  48. package/dist/style/button.css +1 -1
  49. package/dist/style/form-select.css +1 -1
  50. package/dist/style.css +1 -1
  51. package/package.json +3 -2
@@ -1,5 +1,6 @@
1
1
  import { PropType } from 'vue';
2
2
  import { ScrollOptions } from './interface';
3
+ import { ScrollbarProps } from '../scrollbar-v2';
3
4
  declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
4
5
  height: {
5
6
  type: (StringConstructor | NumberConstructor)[];
@@ -43,6 +44,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
43
44
  type: StringConstructor;
44
45
  default: string;
45
46
  };
47
+ scrollbar: {
48
+ type: PropType<boolean | ScrollbarProps>;
49
+ default: boolean;
50
+ };
46
51
  }>, {
47
52
  className: {
48
53
  block: string;
@@ -50,7 +55,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
50
55
  modifier: (className: string) => string;
51
56
  is: (className: string) => string;
52
57
  };
53
- containerRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
58
+ containerRef: import('vue').Ref<any, any>;
59
+ wrapperComRef: import('vue').Ref<HTMLElement | import('vue').ComponentPublicInstance | undefined, HTMLElement | import('vue').ComponentPublicInstance | undefined>;
60
+ displayScrollbar: import('vue').ComputedRef<boolean>;
61
+ scrollbarProps: import('vue').ComputedRef<ScrollbarProps | undefined>;
54
62
  contentRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
55
63
  frontPadding: import('vue').ComputedRef<number>;
56
64
  currentList: import('vue').ComputedRef<Record<string, any>[]>;
@@ -115,6 +123,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
115
123
  type: StringConstructor;
116
124
  default: string;
117
125
  };
126
+ scrollbar: {
127
+ type: PropType<boolean | ScrollbarProps>;
128
+ default: boolean;
129
+ };
118
130
  }>> & Readonly<{
119
131
  onScroll?: ((ev: Event) => any) | undefined;
120
132
  onReachBottom?: ((ev: Event) => any) | undefined;
@@ -122,6 +134,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
122
134
  data: Record<string, any>[];
123
135
  component: string | Record<string, any>;
124
136
  height: string | number;
137
+ scrollbar: boolean | ScrollbarProps;
125
138
  fixedSize: boolean;
126
139
  estimatedSize: number;
127
140
  buffer: number;
@@ -150,5 +163,327 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
150
163
  required: true;
151
164
  };
152
165
  }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
166
+ ScrollbarComponent: {
167
+ new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('vue').ExtractPropTypes<{
168
+ type: {
169
+ type: PropType<"track" | "embed">;
170
+ default: string;
171
+ };
172
+ outerClass: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
173
+ outerStyle: {
174
+ type: PropType<import('vue').StyleValue>;
175
+ };
176
+ hide: {
177
+ type: BooleanConstructor;
178
+ default: boolean;
179
+ };
180
+ disableHorizontal: {
181
+ type: BooleanConstructor;
182
+ default: boolean;
183
+ };
184
+ disableVertical: {
185
+ type: BooleanConstructor;
186
+ default: boolean;
187
+ };
188
+ horizontalWheel: {
189
+ type: BooleanConstructor;
190
+ default: boolean;
191
+ };
192
+ }>> & Readonly<{
193
+ onScroll?: ((ev: Event) => any) | undefined;
194
+ }>, {
195
+ className: {
196
+ block: string;
197
+ element: (className: string) => string;
198
+ modifier: (className: string) => string;
199
+ is: (className: string) => string;
200
+ };
201
+ cls: import('vue').ComputedRef<unknown[]>;
202
+ style: import('vue').ComputedRef<import('vue').StyleValue[]>;
203
+ rootRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
204
+ getContainerAttrs: () => {
205
+ [x: string]: unknown;
206
+ };
207
+ getContainerStyle: () => import('vue').StyleValue;
208
+ containerRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
209
+ horizontalThumbRef: import('vue').Ref<any, any>;
210
+ verticalThumbRef: import('vue').Ref<any, any>;
211
+ horizontalData: import('vue').Ref<import('../scrollbar-v2/interface').ThumbData | undefined, import('../scrollbar-v2/interface').ThumbData | undefined>;
212
+ verticalData: import('vue').Ref<import('../scrollbar-v2/interface').ThumbData | undefined, import('../scrollbar-v2/interface').ThumbData | undefined>;
213
+ isBoth: import('vue').Ref<boolean, boolean>;
214
+ hasHorizontalScrollbar: import('vue').ComputedRef<boolean>;
215
+ hasVerticalScrollbar: import('vue').ComputedRef<boolean>;
216
+ handleResize: () => void;
217
+ handleScroll: (ev: Event) => void;
218
+ handleWheel: (ev: WheelEvent) => void;
219
+ handleHorizontalScroll: (offset: number) => void;
220
+ handleVerticalScroll: (offset: number) => void;
221
+ }, {}, {}, {
222
+ scrollTo(options?: number | {
223
+ left?: number;
224
+ top?: number;
225
+ }, y?: number): void;
226
+ scrollTop(top: number): void;
227
+ scrollLeft(left: number): void;
228
+ }, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
229
+ scroll: (ev: Event) => true;
230
+ }, import('vue').PublicProps, {
231
+ type: "embed" | "track";
232
+ hide: boolean;
233
+ disableHorizontal: boolean;
234
+ disableVertical: boolean;
235
+ horizontalWheel: boolean;
236
+ }, true, {}, {}, {
237
+ ResizeObserver: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
238
+ watchOnUpdated: BooleanConstructor;
239
+ }>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
240
+ [key: string]: any;
241
+ }>[] | undefined, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "resize"[], "resize", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
242
+ watchOnUpdated: BooleanConstructor;
243
+ }>> & Readonly<{
244
+ onResize?: ((...args: any[]) => any) | undefined;
245
+ }>, {
246
+ watchOnUpdated: boolean;
247
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
248
+ Thumb: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
249
+ data: {
250
+ type: PropType<import('../scrollbar-v2/interface').ThumbData>;
251
+ };
252
+ direction: {
253
+ type: PropType<import('../../_utils/constant').Direction>;
254
+ default: string;
255
+ };
256
+ }>, {
257
+ trackRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
258
+ thumbRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
259
+ className: {
260
+ block: string;
261
+ element: (className: string) => string;
262
+ modifier: (className: string) => string;
263
+ is: (className: string) => string;
264
+ };
265
+ thumbCls: import('vue').ComputedRef<(string | {
266
+ [x: string]: boolean;
267
+ })[]>;
268
+ thumbStyle: import('vue').ComputedRef<{
269
+ [x: string]: string;
270
+ }>;
271
+ handleThumbMouseDown: (ev: MouseEvent) => void;
272
+ handleTrackClick: (ev: MouseEvent) => void;
273
+ setOffset: (_offset: number) => void;
274
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "scroll"[], "scroll", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
275
+ data: {
276
+ type: PropType<import('../scrollbar-v2/interface').ThumbData>;
277
+ };
278
+ direction: {
279
+ type: PropType<import('../../_utils/constant').Direction>;
280
+ default: string;
281
+ };
282
+ }>> & Readonly<{
283
+ onScroll?: ((...args: any[]) => any) | undefined;
284
+ }>, {
285
+ direction: "horizontal" | "vertical";
286
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
287
+ } & import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
288
+ P: {};
289
+ B: {};
290
+ D: {};
291
+ C: {};
292
+ M: {};
293
+ Defaults: {};
294
+ }, Readonly<import('vue').ExtractPropTypes<{
295
+ type: {
296
+ type: PropType<"track" | "embed">;
297
+ default: string;
298
+ };
299
+ outerClass: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
300
+ outerStyle: {
301
+ type: PropType<import('vue').StyleValue>;
302
+ };
303
+ hide: {
304
+ type: BooleanConstructor;
305
+ default: boolean;
306
+ };
307
+ disableHorizontal: {
308
+ type: BooleanConstructor;
309
+ default: boolean;
310
+ };
311
+ disableVertical: {
312
+ type: BooleanConstructor;
313
+ default: boolean;
314
+ };
315
+ horizontalWheel: {
316
+ type: BooleanConstructor;
317
+ default: boolean;
318
+ };
319
+ }>> & Readonly<{
320
+ onScroll?: ((ev: Event) => any) | undefined;
321
+ }>, {
322
+ className: {
323
+ block: string;
324
+ element: (className: string) => string;
325
+ modifier: (className: string) => string;
326
+ is: (className: string) => string;
327
+ };
328
+ cls: import('vue').ComputedRef<unknown[]>;
329
+ style: import('vue').ComputedRef<import('vue').StyleValue[]>;
330
+ rootRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
331
+ getContainerAttrs: () => {
332
+ [x: string]: unknown;
333
+ };
334
+ getContainerStyle: () => import('vue').StyleValue;
335
+ containerRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
336
+ horizontalThumbRef: import('vue').Ref<any, any>;
337
+ verticalThumbRef: import('vue').Ref<any, any>;
338
+ horizontalData: import('vue').Ref<import('../scrollbar-v2/interface').ThumbData | undefined, import('../scrollbar-v2/interface').ThumbData | undefined>;
339
+ verticalData: import('vue').Ref<import('../scrollbar-v2/interface').ThumbData | undefined, import('../scrollbar-v2/interface').ThumbData | undefined>;
340
+ isBoth: import('vue').Ref<boolean, boolean>;
341
+ hasHorizontalScrollbar: import('vue').ComputedRef<boolean>;
342
+ hasVerticalScrollbar: import('vue').ComputedRef<boolean>;
343
+ handleResize: () => void;
344
+ handleScroll: (ev: Event) => void;
345
+ handleWheel: (ev: WheelEvent) => void;
346
+ handleHorizontalScroll: (offset: number) => void;
347
+ handleVerticalScroll: (offset: number) => void;
348
+ }, {}, {}, {
349
+ scrollTo(options?: number | {
350
+ left?: number;
351
+ top?: number;
352
+ }, y?: number): void;
353
+ scrollTop(top: number): void;
354
+ scrollLeft(left: number): void;
355
+ }, {
356
+ type: "embed" | "track";
357
+ hide: boolean;
358
+ disableHorizontal: boolean;
359
+ disableVertical: boolean;
360
+ horizontalWheel: boolean;
361
+ }>;
362
+ __isFragment?: never;
363
+ __isTeleport?: never;
364
+ __isSuspense?: never;
365
+ } & import('vue').ComponentOptionsBase<Readonly<import('vue').ExtractPropTypes<{
366
+ type: {
367
+ type: PropType<"track" | "embed">;
368
+ default: string;
369
+ };
370
+ outerClass: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
371
+ outerStyle: {
372
+ type: PropType<import('vue').StyleValue>;
373
+ };
374
+ hide: {
375
+ type: BooleanConstructor;
376
+ default: boolean;
377
+ };
378
+ disableHorizontal: {
379
+ type: BooleanConstructor;
380
+ default: boolean;
381
+ };
382
+ disableVertical: {
383
+ type: BooleanConstructor;
384
+ default: boolean;
385
+ };
386
+ horizontalWheel: {
387
+ type: BooleanConstructor;
388
+ default: boolean;
389
+ };
390
+ }>> & Readonly<{
391
+ onScroll?: ((ev: Event) => any) | undefined;
392
+ }>, {
393
+ className: {
394
+ block: string;
395
+ element: (className: string) => string;
396
+ modifier: (className: string) => string;
397
+ is: (className: string) => string;
398
+ };
399
+ cls: import('vue').ComputedRef<unknown[]>;
400
+ style: import('vue').ComputedRef<import('vue').StyleValue[]>;
401
+ rootRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
402
+ getContainerAttrs: () => {
403
+ [x: string]: unknown;
404
+ };
405
+ getContainerStyle: () => import('vue').StyleValue;
406
+ containerRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
407
+ horizontalThumbRef: import('vue').Ref<any, any>;
408
+ verticalThumbRef: import('vue').Ref<any, any>;
409
+ horizontalData: import('vue').Ref<import('../scrollbar-v2/interface').ThumbData | undefined, import('../scrollbar-v2/interface').ThumbData | undefined>;
410
+ verticalData: import('vue').Ref<import('../scrollbar-v2/interface').ThumbData | undefined, import('../scrollbar-v2/interface').ThumbData | undefined>;
411
+ isBoth: import('vue').Ref<boolean, boolean>;
412
+ hasHorizontalScrollbar: import('vue').ComputedRef<boolean>;
413
+ hasVerticalScrollbar: import('vue').ComputedRef<boolean>;
414
+ handleResize: () => void;
415
+ handleScroll: (ev: Event) => void;
416
+ handleWheel: (ev: WheelEvent) => void;
417
+ handleHorizontalScroll: (offset: number) => void;
418
+ handleVerticalScroll: (offset: number) => void;
419
+ }, {}, {}, {
420
+ scrollTo(options?: number | {
421
+ left?: number;
422
+ top?: number;
423
+ }, y?: number): void;
424
+ scrollTop(top: number): void;
425
+ scrollLeft(left: number): void;
426
+ }, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
427
+ scroll: (ev: Event) => true;
428
+ }, string, {
429
+ type: "embed" | "track";
430
+ hide: boolean;
431
+ disableHorizontal: boolean;
432
+ disableVertical: boolean;
433
+ horizontalWheel: boolean;
434
+ }, {}, string, {}, {
435
+ ResizeObserver: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
436
+ watchOnUpdated: BooleanConstructor;
437
+ }>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
438
+ [key: string]: any;
439
+ }>[] | undefined, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "resize"[], "resize", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
440
+ watchOnUpdated: BooleanConstructor;
441
+ }>> & Readonly<{
442
+ onResize?: ((...args: any[]) => any) | undefined;
443
+ }>, {
444
+ watchOnUpdated: boolean;
445
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
446
+ Thumb: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
447
+ data: {
448
+ type: PropType<import('../scrollbar-v2/interface').ThumbData>;
449
+ };
450
+ direction: {
451
+ type: PropType<import('../../_utils/constant').Direction>;
452
+ default: string;
453
+ };
454
+ }>, {
455
+ trackRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
456
+ thumbRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
457
+ className: {
458
+ block: string;
459
+ element: (className: string) => string;
460
+ modifier: (className: string) => string;
461
+ is: (className: string) => string;
462
+ };
463
+ thumbCls: import('vue').ComputedRef<(string | {
464
+ [x: string]: boolean;
465
+ })[]>;
466
+ thumbStyle: import('vue').ComputedRef<{
467
+ [x: string]: string;
468
+ }>;
469
+ handleThumbMouseDown: (ev: MouseEvent) => void;
470
+ handleTrackClick: (ev: MouseEvent) => void;
471
+ setOffset: (_offset: number) => void;
472
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "scroll"[], "scroll", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
473
+ data: {
474
+ type: PropType<import('../scrollbar-v2/interface').ThumbData>;
475
+ };
476
+ direction: {
477
+ type: PropType<import('../../_utils/constant').Direction>;
478
+ default: string;
479
+ };
480
+ }>> & Readonly<{
481
+ onScroll?: ((...args: any[]) => any) | undefined;
482
+ }>, {
483
+ direction: "horizontal" | "vertical";
484
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
485
+ } & import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & {
486
+ install(app: import('vue').App): void;
487
+ };
153
488
  }, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
154
489
  export default _default;
@@ -1,16 +1,16 @@
1
- import { ref as o, onMounted as u, watch as m } from "vue";
2
- import { isComponentInstance as f } from "../_utils/is.js";
3
- const c = (r) => {
4
- const e = o(), t = () => f(e.value) ? e.value.$refs[r] : e.value, n = o();
1
+ import { ref as r, onMounted as u, watch as f } from "vue";
2
+ import { isComponentInstance as l } from "../_utils/is.js";
3
+ const s = (n) => {
4
+ const e = r(), o = () => l(e.value) ? e.value.$refs[n] ?? Reflect.get(e.value, n) : e.value, t = r();
5
5
  return u(() => {
6
- n.value = t();
7
- }), m([e], () => {
8
- n.value = t();
6
+ t.value = o();
7
+ }), f([e], () => {
8
+ t.value = o();
9
9
  }), {
10
10
  componentRef: e,
11
- elementRef: n
11
+ elementRef: t
12
12
  };
13
13
  };
14
14
  export {
15
- c as useComponentRef
15
+ s as useComponentRef
16
16
  };
@@ -1,77 +1,82 @@
1
- const h = (t) => Number(t.toPrecision(12)), g = (t) => Number(t.toFixed(4)), f = (t) => Math.max(2, Math.floor(t)), p = (t) => {
1
+ const a = (t) => Number(t.toPrecision(12)), g = (t) => Number(t.toFixed(4)), f = (t) => Math.max(2, Math.floor(t)), F = (t) => {
2
2
  if (!Number.isFinite(t) || t <= 0) return 0;
3
- const e = 10 ** Math.floor(Math.log10(t)), i = t / e;
4
- return e * (i <= 1 ? 1 : i <= 2 ? 2 : i <= 5 ? 5 : 10);
5
- }, x = (t, e = 4) => {
3
+ const n = 10 ** Math.floor(Math.log10(t)), e = t / n;
4
+ return n * (e <= 1 ? 1 : e <= 2 ? 2 : e <= 5 ? 5 : 10);
5
+ }, x = (t, n = 4) => {
6
6
  if (!Number.isFinite(t) || t <= 0)
7
7
  return { max: 0, ticks: [0] };
8
- const i = f(e) - 1, s = p(t / i), r = h(Math.ceil(t / s) * s), n = Math.round(r / s);
8
+ const e = f(n) - 1, s = F(t / e), r = a(Math.ceil(t / s) * s), i = Math.round(r / s);
9
9
  return {
10
10
  max: r,
11
- ticks: Array.from({ length: n + 1 }, (o, c) => h(s * c))
11
+ ticks: Array.from({ length: i + 1 }, (o, c) => a(s * c))
12
12
  };
13
- }, M = (t, e = 4, i) => {
14
- const s = f(e);
15
- if (Number.isFinite(i) && i > 0) {
16
- const r = i, n = s - 1;
13
+ }, d = (t, n = 4, e) => {
14
+ const s = f(n);
15
+ if (Number.isFinite(e) && e > 0) {
16
+ const r = e, i = s - 1;
17
17
  return {
18
18
  max: r,
19
19
  ticks: Array.from(
20
- { length: n + 1 },
21
- (o, c) => g(r / n * c)
20
+ { length: i + 1 },
21
+ (o, c) => g(r / i * c)
22
22
  )
23
23
  };
24
24
  }
25
25
  return x(t, s);
26
- }, d = (t, e, i = 4) => {
27
- const s = Number.isFinite(t) ? t : 0, r = Number.isFinite(e) ? e : 0, n = Math.min(0, s), o = Math.max(0, r);
28
- if (n === 0 && o === 0)
26
+ }, M = (t, n, e = 4) => {
27
+ const s = Number.isFinite(t) ? t : 0, r = Number.isFinite(n) ? n : 0, i = Math.min(0, s), o = Math.max(0, r);
28
+ if (i === 0 && o === 0)
29
29
  return { min: 0, max: 0, ticks: [0] };
30
- const c = f(i) - 1, u = p((o - n) / c), l = h(Math.floor(n / u) * u), m = h(Math.ceil(o / u) * u), a = Math.round((m - l) / u);
30
+ const c = f(e) - 1, u = F((o - i) / c), h = a(Math.floor(i / u) * u), m = a(Math.ceil(o / u) * u), l = Math.round((m - h) / u);
31
31
  return {
32
- min: l,
32
+ min: h,
33
33
  max: m,
34
- ticks: Array.from({ length: a + 1 }, (N, b) => h(l + u * b))
34
+ ticks: Array.from({ length: l + 1 }, (N, b) => a(h + u * b))
35
35
  };
36
- }, A = (t, e, i = 4, s, r) => {
37
- const n = f(i), o = Number.isFinite(s), c = Number.isFinite(r);
36
+ }, A = (t, n, e = 4, s, r) => {
37
+ const i = f(e), o = Number.isFinite(s), c = Number.isFinite(r);
38
38
  if (!o && !c)
39
- return d(t, e, n);
40
- const u = Math.min(0, Number.isFinite(t) ? t : 0), l = Math.max(0, Number.isFinite(e) ? e : 0);
41
- let m = o ? s : u, a = c ? r : l;
42
- m > a && ([m, a] = [a, m]);
43
- const N = n - 1;
39
+ return M(t, n, i);
40
+ const u = Math.min(0, Number.isFinite(t) ? t : 0), h = Math.max(0, Number.isFinite(n) ? n : 0);
41
+ let m = o ? s : u, l = c ? r : h;
42
+ m > l && ([m, l] = [l, m]);
43
+ const N = i - 1;
44
44
  return {
45
45
  min: m,
46
- max: a,
46
+ max: l,
47
47
  ticks: Array.from(
48
48
  { length: N + 1 },
49
- (b, F) => g(m + (a - m) / N * F)
49
+ (b, p) => g(m + (l - m) / N * p)
50
50
  )
51
51
  };
52
52
  }, k = (t) => {
53
53
  if (!Number.isFinite(t)) return "";
54
- const e = Number(Number(t.toPrecision(12)).toFixed(4)), [i, s] = String(Math.abs(e)).split("."), r = i.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
55
- return `${e < 0 ? "-" : ""}${r}${s ? `.${s}` : ""}`;
56
- }, y = (t, e) => {
57
- let i = 0;
54
+ const n = Number(Number(t.toPrecision(12)).toFixed(4)), [e, s] = String(Math.abs(n)).split("."), r = e.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
55
+ return `${n < 0 ? "-" : ""}${r}${s ? `.${s}` : ""}`;
56
+ }, y = (t, n) => {
57
+ let e = 0;
58
58
  for (const s of t)
59
- i += s.charCodeAt(0) > 255 ? 1 : 0.6;
60
- return i * e;
61
- }, S = (t, e, i, s = 8) => {
59
+ e += s.charCodeAt(0) > 255 ? 1 : 0.6;
60
+ return e * n;
61
+ }, S = (t, n, e, s = 8) => {
62
62
  if (t <= 0) return [];
63
- const r = Math.max(1, Math.ceil((i + s) / Math.max(e, 1))), n = [];
63
+ const r = Math.max(1, Math.ceil((e + s) / Math.max(n, 1))), i = [];
64
64
  for (let c = 0; c < t; c += r)
65
- n.push(c);
65
+ i.push(c);
66
66
  const o = t - 1;
67
- return n[n.length - 1] !== o && (n.length > 1 && o - n[n.length - 1] < r * 0.6 && n.pop(), n.push(o)), n;
67
+ if (i[i.length - 1] !== o) {
68
+ for (; i.length && (o - i[i.length - 1]) * n < e + s; )
69
+ i.pop();
70
+ i.push(o);
71
+ }
72
+ return i;
68
73
  };
69
74
  export {
70
75
  k as defaultValueFormatter,
71
76
  y as estimateTextWidth,
72
77
  A as getDomain,
73
- d as getNiceDomain,
78
+ M as getNiceDomain,
74
79
  x as getNiceScale,
75
- M as getScale,
80
+ d as getScale,
76
81
  S as pickLabelIndices
77
82
  };
@@ -1,6 +1,8 @@
1
- import { defineComponent as s, createVNode as a } from "vue";
2
- import { getClassNameMixin as i } from "../../../_utils/config.js";
3
- const y = 6, x = 8, c = /* @__PURE__ */ s({
1
+ import { defineComponent as x, ref as u, computed as h, onMounted as b, watchPostEffect as g, onBeforeUnmount as L, createVNode as n } from "vue";
2
+ import { getClassNameMixin as S } from "../../../_utils/config.js";
3
+ import { layoutAxisLabels as v } from "./axis-labels.js";
4
+ import { estimateTextWidth as z } from "../../../_utils/chart/scale.js";
5
+ const A = 6, w = 8, N = /* @__PURE__ */ x({
4
6
  name: "ChartAxis",
5
7
  props: {
6
8
  plot: {
@@ -36,44 +38,67 @@ const y = 6, x = 8, c = /* @__PURE__ */ s({
36
38
  default: !0
37
39
  }
38
40
  },
39
- setup(e) {
40
- const l = i("chart"), o = () => ({
41
- fontSize: `${e.fontSize}px`,
42
- fill: e.color
43
- });
44
- return () => a("g", null, [e.showHorizontalLines && a("g", {
45
- class: l.element("grid")
46
- }, [e.ticks.map((t, n) => a("line", {
47
- key: n,
48
- class: [l.element("grid-line"), {
49
- [l.is("baseline")]: t.isBaseline
41
+ setup(t) {
42
+ const o = S("chart"), f = () => ({
43
+ fontSize: `${t.fontSize}px`,
44
+ fill: t.color
45
+ }), s = u(), d = u(), m = (e) => v(t.xLabels, t.plot.left, t.plot.right, t.fontSize * 0.6, e), y = h(() => d.value ?? m((e) => z(e, t.fontSize)));
46
+ let i = null, c = !0;
47
+ const a = () => {
48
+ if (!c || !s.value) return;
49
+ const e = getComputedStyle(s.value);
50
+ if (i) {
51
+ i.font = `${e.fontStyle} ${e.fontWeight} ${t.fontSize}px ${e.fontFamily}`;
52
+ const l = Number.parseFloat(e.letterSpacing) || 0;
53
+ d.value = m((r) => i.measureText(r).width + Math.max(0, Array.from(r).length - 1) * l);
54
+ }
55
+ };
56
+ return b(() => {
57
+ var e, l;
58
+ i = document.createElement("canvas").getContext("2d"), a(), (e = document.fonts) == null || e.addEventListener("loadingdone", a), (l = document.fonts) == null || l.ready.then(a);
59
+ }), g(() => {
60
+ t.xLabels, t.plot, t.fontSize, a();
61
+ }), L(() => {
62
+ var e;
63
+ c = !1, (e = document.fonts) == null || e.removeEventListener("loadingdone", a);
64
+ }), () => n("g", {
65
+ ref: s,
66
+ style: {
67
+ fontSize: `${t.fontSize}px`
68
+ }
69
+ }, [t.showHorizontalLines && n("g", {
70
+ class: o.element("grid")
71
+ }, [t.ticks.map((e, l) => n("line", {
72
+ key: l,
73
+ class: [o.element("grid-line"), {
74
+ [o.is("baseline")]: e.isBaseline
50
75
  }],
51
- x1: e.plot.left,
52
- x2: e.plot.left + e.plot.width,
53
- y1: t.y,
54
- y2: t.y
55
- }, null))]), e.showY && a("g", {
56
- class: l.element("y-labels")
57
- }, [e.ticks.map((t, n) => a("text", {
58
- key: n,
59
- class: l.element("axis-label"),
60
- x: e.plot.left - y,
61
- y: t.y,
76
+ x1: t.plot.left,
77
+ x2: t.plot.left + t.plot.width,
78
+ y1: e.y,
79
+ y2: e.y
80
+ }, null))]), t.showY && n("g", {
81
+ class: o.element("y-labels")
82
+ }, [t.ticks.map((e, l) => n("text", {
83
+ key: l,
84
+ class: o.element("axis-label"),
85
+ x: t.plot.left - A,
86
+ y: e.y,
62
87
  "text-anchor": "end",
63
88
  "dominant-baseline": "middle",
64
- style: o()
65
- }, [t.label]))]), e.showX && a("g", {
66
- class: l.element("x-labels")
67
- }, [e.xLabels.map((t, n) => a("text", {
68
- key: n,
69
- class: l.element("axis-label"),
70
- x: t.x,
71
- y: e.plot.bottom + x + e.fontSize * 0.9,
89
+ style: f()
90
+ }, [e.label]))]), t.showX && n("g", {
91
+ class: o.element("x-labels")
92
+ }, [y.value.map((e, l) => n("text", {
93
+ key: l,
94
+ class: o.element("axis-label"),
95
+ x: e.x,
96
+ y: t.plot.bottom + w + t.fontSize * 0.9,
72
97
  "text-anchor": "middle",
73
- style: o()
74
- }, [t.text]))])]);
98
+ style: f()
99
+ }, [e.text, e.title && n("title", null, [e.title])]))])]);
75
100
  }
76
101
  });
77
102
  export {
78
- c as default
103
+ N as default
79
104
  };
@@ -0,0 +1,26 @@
1
+ const M = (h, f, d, u, i) => {
2
+ const n = Math.max(0, d - f);
3
+ if (n <= 0) return [];
4
+ const m = [];
5
+ let I = Number.POSITIVE_INFINITY;
6
+ for (let c = h.length - 1; c >= 0; c--) {
7
+ const l = h[c];
8
+ let e = l.text, t = i(e);
9
+ if (t > n) {
10
+ if (i("…") > n) continue;
11
+ const a = Array.from(e);
12
+ let o = 0, s = a.length;
13
+ for (; o < s; ) {
14
+ const r = Math.ceil((o + s) / 2);
15
+ i(`${a.slice(0, r).join("")}…`) <= n ? o = r : s = r - 1;
16
+ }
17
+ e = `${a.slice(0, o).join("")}…`, t = i(e);
18
+ }
19
+ const x = Math.max(f + t / 2, Math.min(l.x, d - t / 2));
20
+ x + t / 2 + u > I || (m.push({ x, text: e, width: t, ...e !== l.text ? { title: l.text } : {} }), I = x - t / 2);
21
+ }
22
+ return m.reverse();
23
+ };
24
+ export {
25
+ M as layoutAxisLabels
26
+ };