@plexui/vue 0.39.4 → 0.40.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 (27) hide show
  1. package/dist/es/components/Dialog/Dialog.js +2 -1
  2. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  3. package/dist/es/components/Menu/Menu.js +8 -2
  4. package/dist/es/components/Menu/Menu.js.map +1 -1
  5. package/dist/es/components/NavigationRow/NavigationRow.js +16 -3
  6. package/dist/es/components/NavigationRow/NavigationRow.js.map +1 -1
  7. package/dist/es/components/Progress/Progress.js +19 -5
  8. package/dist/es/components/Progress/Progress.js.map +1 -1
  9. package/dist/es/components/Progress/index.js.map +1 -1
  10. package/dist/es/components/StatsCard/StatsCard.js +11 -2
  11. package/dist/es/components/StatsCard/StatsCard.js.map +1 -1
  12. package/dist/es/components/Transition/TransitionGroup.js +11 -3
  13. package/dist/es/components/Transition/TransitionGroup.js.map +1 -1
  14. package/dist/es/components/Transition/shared.js +6 -0
  15. package/dist/es/components/Transition/shared.js.map +1 -1
  16. package/dist/es/components/Transition/useTransitionChild.js +1 -1
  17. package/dist/es/components/Transition/useTransitionChild.js.map +1 -1
  18. package/dist/es/lib/fitValueScale.js +54 -0
  19. package/dist/es/lib/fitValueScale.js.map +1 -0
  20. package/dist/types/components/NavigationRow/NavigationRow.d.ts +21 -3
  21. package/dist/types/components/Progress/Progress.d.ts +37 -0
  22. package/dist/types/components/Progress/index.d.ts +1 -1
  23. package/dist/types/components/Sidebar/Sidebar.d.ts +1 -1
  24. package/dist/types/components/Transition/TransitionGroup.d.ts +14 -4
  25. package/dist/types/components/Transition/shared.d.ts +9 -0
  26. package/dist/types/lib/fitValueScale.d.ts +7 -0
  27. package/package.json +2 -2
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Scales a one-line value down until it fits the width of its parent, as iOS's `minimumScaleFactor` does: writes
3
+ * `property` on the value as a factor from `min` to 1 (removed at 1), for its CSS to multiply its font size by. It is
4
+ * measured again when the parent or the value resizes, the value's text changes, or the fonts load. Under `min` the
5
+ * value's own CSS cuts it (an ellipsis). Returns the cleanup.
6
+ */
7
+ export function fitValueScale(value, property, min = 0.5) {
8
+ let frame = 0;
9
+ const measure = () => {
10
+ frame = 0;
11
+ const row = value.parentElement;
12
+ if (!row)
13
+ return;
14
+ const current = value.style.getPropertyValue(property);
15
+ // The width the text takes at full size, measured at full size: a width read at a scaled size comes in whole
16
+ // pixels, and a factor from it can step back and forth with each resize it causes
17
+ value.style.removeProperty(property);
18
+ const natural = value.scrollWidth;
19
+ const available = row.clientWidth;
20
+ if (!natural || !available) {
21
+ if (current)
22
+ value.style.setProperty(property, current);
23
+ return;
24
+ }
25
+ // Two decimals, rounded down (1e-9 keeps a float like 98.99999 on its step)
26
+ const next = Math.max(min, Math.min(1, Math.floor((available / natural) * 100 + 1e-9) / 100));
27
+ if (next < 1)
28
+ value.style.setProperty(property, String(next));
29
+ };
30
+ const schedule = () => {
31
+ if (!frame)
32
+ frame = requestAnimationFrame(measure);
33
+ };
34
+ measure();
35
+ const resize = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(schedule);
36
+ if (value.parentElement)
37
+ resize?.observe(value.parentElement);
38
+ resize?.observe(value);
39
+ const mutation = typeof MutationObserver === "undefined" ? null : new MutationObserver(schedule);
40
+ mutation?.observe(value, { childList: true, characterData: true, subtree: true });
41
+ let live = true;
42
+ document.fonts?.ready.then(() => {
43
+ if (live)
44
+ schedule();
45
+ });
46
+ return () => {
47
+ live = false;
48
+ if (frame)
49
+ cancelAnimationFrame(frame);
50
+ resize?.disconnect();
51
+ mutation?.disconnect();
52
+ };
53
+ }
54
+ //# sourceMappingURL=fitValueScale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fitValueScale.js","sourceRoot":"","sources":["../../../src/lib/fitValueScale.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAkB,EAAE,QAAgB,EAAE,GAAG,GA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CAAC,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAA;IAC1F,IAAI,KAAK,CAAC,aAAa;QAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAC7D,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IACtB,MAAM,QAAQ,GAAG,OAAO,gBAAgB,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IAChG,QAAQ,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IACjF,IAAI,IAAI,GAAG,IAAI,CAAA;IACf,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;QAC9B,IAAI,IAAI;YAAE,QAAQ,EAAE,CAAA;IACtB,CAAC,CAAC,CAAA;IACF,OAAO,GAAG,EAAE;QACV,IAAI,GAAG,KAAK,CAAA;QACZ,IAAI,KAAK;YAAE,oBAAoB,CAAC,KAAK,CAAC,CAAA;QACtC,MAAM,EAAE,UAAU,EAAE,CAAA;QACpB,QAAQ,EAAE,UAAU,EAAE,CAAA;IACxB,CAAC,CAAA;AACH,CAAC","sourcesContent":["/**\n * Scales a one-line value down until it fits the width of its parent, as iOS's `minimumScaleFactor` does: writes\n * `property` on the value as a factor from `min` to 1 (removed at 1), for its CSS to multiply its font size by. It is\n * measured again when the parent or the value resizes, the value's text changes, or the fonts load. Under `min` the\n * value's own CSS cuts it (an ellipsis). Returns the cleanup.\n */\nexport function fitValueScale(value: HTMLElement, property: string, min = 0.5): () => void {\n let frame = 0\n const measure = () => {\n frame = 0\n const row = value.parentElement\n if (!row) return\n const current = value.style.getPropertyValue(property)\n // The width the text takes at full size, measured at full size: a width read at a scaled size comes in whole\n // pixels, and a factor from it can step back and forth with each resize it causes\n value.style.removeProperty(property)\n const natural = value.scrollWidth\n const available = row.clientWidth\n if (!natural || !available) {\n if (current) value.style.setProperty(property, current)\n return\n }\n // Two decimals, rounded down (1e-9 keeps a float like 98.99999 on its step)\n const next = Math.max(min, Math.min(1, Math.floor((available / natural) * 100 + 1e-9) / 100))\n if (next < 1) value.style.setProperty(property, String(next))\n }\n const schedule = () => {\n if (!frame) frame = requestAnimationFrame(measure)\n }\n measure()\n const resize = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(schedule)\n if (value.parentElement) resize?.observe(value.parentElement)\n resize?.observe(value)\n const mutation = typeof MutationObserver === \"undefined\" ? null : new MutationObserver(schedule)\n mutation?.observe(value, { childList: true, characterData: true, subtree: true })\n let live = true\n document.fonts?.ready.then(() => {\n if (live) schedule()\n })\n return () => {\n live = false\n if (frame) cancelAnimationFrame(frame)\n resize?.disconnect()\n mutation?.disconnect()\n }\n}\n"]}
@@ -4,14 +4,15 @@ type RouteTarget = string | Record<string, unknown>;
4
4
  /**
5
5
  * Vue port of `NavigationRow` from packages/ui/src/components/NavigationRow/NavigationRow.tsx: a FieldGroup row
6
6
  * that opens what it holds, as an iOS Settings drill-in. Attributes (id, class, ARIA, data, listeners) fall through
7
- * to the pressable. The `label`, `value` and `description` slots take the place of their props.
7
+ * to the pressable. The `label`, `value` and `description` slots take the place of their props; the `leading` slot
8
+ * (an `Avatar` or a picture) leads the row, as React's `leading`.
8
9
  */
9
10
  declare const NavigationRowComponent: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
10
11
  /** The row's name, where a row's label starts */
11
12
  label: PropType<string | number>;
12
13
  /** The current value, at the end of the row in the secondary label. `0` shows; `null`, `undefined` and `""` do not. */
13
14
  value: PropType<string | number | null>;
14
- /** A line under the label; the row grows from 52 to hold it */
15
+ /** A line under the label; the row grows from 52 to hold it. A `<br />` in the slot starts a second line. */
15
16
  description: PropType<string | number>;
16
17
  /** Where the row goes. With it the row is a link (through `PlexUIProvider`'s `linkComponent`, or `as`). */
17
18
  href: StringConstructor;
@@ -37,6 +38,14 @@ declare const NavigationRowComponent: import("vue").DefineComponent<import("vue"
37
38
  type: PropType<"end" | "below" | "auto">;
38
39
  default: string;
39
40
  };
41
+ /**
42
+ * The chevron at the end. `false` drops it, for a row that opens a record rather than a page of choices (as the
43
+ * Contacts list of iOS); the row is still one press.
44
+ */
45
+ disclosure: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
40
49
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
41
50
  [key: string]: any;
42
51
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -44,7 +53,7 @@ declare const NavigationRowComponent: import("vue").DefineComponent<import("vue"
44
53
  label: PropType<string | number>;
45
54
  /** The current value, at the end of the row in the secondary label. `0` shows; `null`, `undefined` and `""` do not. */
46
55
  value: PropType<string | number | null>;
47
- /** A line under the label; the row grows from 52 to hold it */
56
+ /** A line under the label; the row grows from 52 to hold it. A `<br />` in the slot starts a second line. */
48
57
  description: PropType<string | number>;
49
58
  /** Where the row goes. With it the row is a link (through `PlexUIProvider`'s `linkComponent`, or `as`). */
50
59
  href: StringConstructor;
@@ -70,10 +79,19 @@ declare const NavigationRowComponent: import("vue").DefineComponent<import("vue"
70
79
  type: PropType<"end" | "below" | "auto">;
71
80
  default: string;
72
81
  };
82
+ /**
83
+ * The chevron at the end. `false` drops it, for a row that opens a record rather than a page of choices (as the
84
+ * Contacts list of iOS); the row is still one press.
85
+ */
86
+ disclosure: {
87
+ type: BooleanConstructor;
88
+ default: boolean;
89
+ };
73
90
  }>> & Readonly<{}>, {
74
91
  disabled: boolean;
75
92
  external: boolean;
76
93
  valuePlacement: "auto" | "end" | "below";
94
+ disclosure: boolean;
77
95
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
78
96
  type NavigationRowOwnProps = InstanceType<typeof NavigationRowComponent>["$props"];
79
97
  /** NavigationRow props plus the native button and link attributes and the click listener that fall through to the
@@ -1,4 +1,5 @@
1
1
  import { type HTMLAttributes, type PropType } from "vue";
2
+ export type ProgressSize = "sm" | "md" | "lg";
2
3
  export type ProgressColor = "primary" | "secondary" | "success" | "warning" | "caution" | "danger" | "info" | "discovery";
3
4
  /** A part of a segmented bar: its share of `max`, its color, and the name it is read with. */
4
5
  export type ProgressSegment = {
@@ -43,6 +44,23 @@ declare const ProgressComponent: import("vue").DefineComponent<import("vue").Ext
43
44
  type: PropType<ProgressSegment[]>;
44
45
  default: undefined;
45
46
  };
47
+ /**
48
+ * The bar's thickness: `sm` 4px (iOS's progress view), `md` 6px, `lg` 8px (a bar in a stats card, as Apple Fitness).
49
+ * @default "sm"
50
+ */
51
+ size: {
52
+ type: PropType<ProgressSize>;
53
+ default: string;
54
+ };
55
+ /**
56
+ * The color of the filled part, such as `secondary` (grey) for a second series beside a `primary` one. A segmented
57
+ * bar's parts take their own colors.
58
+ * @default "primary"
59
+ */
60
+ color: {
61
+ type: PropType<ProgressColor>;
62
+ default: string;
63
+ };
46
64
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
47
65
  [key: string]: any;
48
66
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -69,8 +87,27 @@ declare const ProgressComponent: import("vue").DefineComponent<import("vue").Ext
69
87
  type: PropType<ProgressSegment[]>;
70
88
  default: undefined;
71
89
  };
90
+ /**
91
+ * The bar's thickness: `sm` 4px (iOS's progress view), `md` 6px, `lg` 8px (a bar in a stats card, as Apple Fitness).
92
+ * @default "sm"
93
+ */
94
+ size: {
95
+ type: PropType<ProgressSize>;
96
+ default: string;
97
+ };
98
+ /**
99
+ * The color of the filled part, such as `secondary` (grey) for a second series beside a `primary` one. A segmented
100
+ * bar's parts take their own colors.
101
+ * @default "primary"
102
+ */
103
+ color: {
104
+ type: PropType<ProgressColor>;
105
+ default: string;
106
+ };
72
107
  }>> & Readonly<{}>, {
73
108
  value: number | null;
109
+ size: ProgressSize;
110
+ color: ProgressColor;
74
111
  max: number;
75
112
  segments: ProgressSegment[];
76
113
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -1 +1 @@
1
- export { Progress, progressSegments, type ProgressColor, type ProgressProps, type ProgressSegment } from "./Progress.js";
1
+ export { Progress, progressSegments, type ProgressColor, type ProgressProps, type ProgressSegment, type ProgressSize } from "./Progress.js";
@@ -463,8 +463,8 @@ declare const SidebarMobileComponent: DefineComponent<import("vue").ExtractPropT
463
463
  default: boolean;
464
464
  };
465
465
  }>> & Readonly<{}>, {
466
- contained: boolean;
467
466
  disclosure: boolean;
467
+ contained: boolean;
468
468
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
469
469
  export type SidebarMobileProps = InstanceType<typeof SidebarMobileComponent>["$props"] & HTMLAttributes;
470
470
  export declare const SidebarMobile: typeof SidebarMobileComponent & {
@@ -31,6 +31,11 @@ export declare const TransitionGroup: import("vue").DefineComponent<import("vue"
31
31
  type: NumberConstructor;
32
32
  default: number;
33
33
  };
34
+ /**
35
+ * The enter time with reduced motion, in place of `enterDuration`: for an overlay
36
+ * whose styles fade it in over a time of its own then (a Dialog, a Menu).
37
+ */
38
+ reducedMotionEnterDuration: NumberConstructor;
34
39
  /** Determines the amount of time that the exit state is applied before unmounting */
35
40
  exitDuration: {
36
41
  type: NumberConstructor;
@@ -50,8 +55,8 @@ export declare const TransitionGroup: import("vue").DefineComponent<import("vue"
50
55
  };
51
56
  /**
52
57
  * For overlays: an exiting child is `inert`, out of the tab order and of hit
53
- * testing, and with reduced motion it settles and leaves without waiting for
54
- * `enterDuration` or `exitDuration` (nothing moves, so nothing is held).
58
+ * testing, and with reduced motion it leaves without waiting for `exitDuration`. It
59
+ * still waits out `enterDuration`: with reduced motion an overlay fades in over it.
55
60
  */
56
61
  overlay: BooleanConstructor;
57
62
  /** Determines how new children are added to the children array */
@@ -86,6 +91,11 @@ export declare const TransitionGroup: import("vue").DefineComponent<import("vue"
86
91
  type: NumberConstructor;
87
92
  default: number;
88
93
  };
94
+ /**
95
+ * The enter time with reduced motion, in place of `enterDuration`: for an overlay
96
+ * whose styles fade it in over a time of its own then (a Dialog, a Menu).
97
+ */
98
+ reducedMotionEnterDuration: NumberConstructor;
89
99
  /** Determines the amount of time that the exit state is applied before unmounting */
90
100
  exitDuration: {
91
101
  type: NumberConstructor;
@@ -105,8 +115,8 @@ export declare const TransitionGroup: import("vue").DefineComponent<import("vue"
105
115
  };
106
116
  /**
107
117
  * For overlays: an exiting child is `inert`, out of the tab order and of hit
108
- * testing, and with reduced motion it settles and leaves without waiting for
109
- * `enterDuration` or `exitDuration` (nothing moves, so nothing is held).
118
+ * testing, and with reduced motion it leaves without waiting for `exitDuration`. It
119
+ * still waits out `enterDuration`: with reduced motion an overlay fades in over it.
110
120
  */
111
121
  overlay: BooleanConstructor;
112
122
  /** Determines how new children are added to the children array */
@@ -48,6 +48,15 @@ export declare const overlayTimingQuick: {
48
48
  enterDuration: number;
49
49
  exitDuration: number;
50
50
  };
51
+ /**
52
+ * With reduced motion a Dialog and a Menu fade in place, as on iOS with Reduce Motion (measured on the iOS 27.2
53
+ * simulator: a sheet about 350 ms, a menu about 500 ms), and stay entering, holding touches, for the whole fade. These
54
+ * match --motion-reduced-enter-dialog and --motion-reduced-enter-menu.
55
+ */
56
+ export declare const reducedMotionEnter: {
57
+ dialog: number;
58
+ menu: number;
59
+ };
51
60
  /**
52
61
  * An overlay stays a dismissable layer through its exit. A press on its trigger
53
62
  * turns it around, and the layer must not count that press as outside and
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Scales a one-line value down until it fits the width of its parent, as iOS's `minimumScaleFactor` does: writes
3
+ * `property` on the value as a factor from `min` to 1 (removed at 1), for its CSS to multiply its font size by. It is
4
+ * measured again when the parent or the value resizes, the value's text changes, or the fonts load. Under `min` the
5
+ * value's own CSS cuts it (an ellipsis). Returns the cleanup.
6
+ */
7
+ export declare function fitValueScale(value: HTMLElement, property: string, min?: number): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexui/vue",
3
- "version": "0.39.4",
3
+ "version": "0.40.0",
4
4
  "description": "Plex UI components for Vue 3, built on Reka UI and the shared @plexui/styles CSS",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -77,7 +77,7 @@
77
77
  "@maskito/core": "5.2.2",
78
78
  "@maskito/kit": "5.2.2",
79
79
  "@maskito/vue": "5.2.2",
80
- "@plexui/styles": "^0.16.2",
80
+ "@plexui/styles": "^0.16.4",
81
81
  "@tanstack/table-core": "8.21.3",
82
82
  "@tanstack/vue-table": "8.21.3",
83
83
  "@tiptap/core": "3.21.0",