@plexui/ui 0.57.0 → 0.58.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.
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import clsx from "clsx";
3
3
  import s from "@plexui/styles/components/Kbd/Kbd.module.css";
4
+ import { KbdModifier } from "./KbdModifier.js";
4
5
  /** A key or a shortcut, such as ⌘K, in a tooltip, a menu item or a sentence. */
5
6
  export const Kbd = ({ size = "sm", variant = "soft", className, ...restProps }) => {
6
7
  return _jsx("kbd", { className: clsx(s.Kbd, className), "data-size": size, "data-variant": variant, ...restProps });
@@ -10,4 +11,6 @@ const Group = ({ className, ...restProps }) => {
10
11
  return _jsx("span", { className: clsx(s.Group, className), ...restProps });
11
12
  };
12
13
  Kbd.Group = Group;
14
+ /** A modifier key as the reader's keyboard prints it: ⌘ on a Mac, Ctrl elsewhere (`name` picks ⌘, ⌃, ⌥ or ⇧). */
15
+ Kbd.Modifier = KbdModifier;
13
16
  //# sourceMappingURL=Kbd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Kbd.js","sourceRoot":"","sources":["../../../../src/components/Kbd/Kbd.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,CAAC,MAAM,8CAA8C,CAAA;AAgB5D,gFAAgF;AAChF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,EAAY,EAAE,EAAE;IAC1F,OAAO,cAAK,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,eAAa,IAAI,kBAAgB,OAAO,KAAM,SAAS,GAAI,CAAA;AAC1G,CAAC,CAAA;AAID,6CAA6C;AAC7C,MAAM,KAAK,GAAG,CAAC,EAAE,SAAS,EAAE,GAAG,SAAS,EAAiB,EAAE,EAAE;IAC3D,OAAO,eAAM,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,KAAM,SAAS,GAAI,CAAA;AACrE,CAAC,CAAA;AAED,GAAG,CAAC,KAAK,GAAG,KAAK,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport type { ComponentProps } from \"react\"\nimport s from \"@plexui/styles/components/Kbd/Kbd.module.css\"\n\nexport type KbdProps = ComponentProps<\"kbd\"> & {\n /**\n * Height and text size: `xs` 16px, `sm` 20px, `md` 24px\n * @default sm\n */\n size?: \"xs\" | \"sm\" | \"md\"\n /**\n * `soft` fills the key, `outline` draws its edge. Both mix the text color,\n * so the key reads on any surface.\n * @default soft\n */\n variant?: \"soft\" | \"outline\"\n}\n\n/** A key or a shortcut, such as ⌘K, in a tooltip, a menu item or a sentence. */\nexport const Kbd = ({ size = \"sm\", variant = \"soft\", className, ...restProps }: KbdProps) => {\n return <kbd className={clsx(s.Kbd, className)} data-size={size} data-variant={variant} {...restProps} />\n}\n\nexport type KbdGroupProps = ComponentProps<\"span\">\n\n/** Keys pressed together: a row of `Kbd`. */\nconst Group = ({ className, ...restProps }: KbdGroupProps) => {\n return <span className={clsx(s.Group, className)} {...restProps} />\n}\n\nKbd.Group = Group\n"]}
1
+ {"version":3,"file":"Kbd.js","sourceRoot":"","sources":["../../../../src/components/Kbd/Kbd.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,CAAC,MAAM,8CAA8C,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAgB3C,gFAAgF;AAChF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,EAAY,EAAE,EAAE;IAC1F,OAAO,cAAK,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,eAAa,IAAI,kBAAgB,OAAO,KAAM,SAAS,GAAI,CAAA;AAC1G,CAAC,CAAA;AAID,6CAA6C;AAC7C,MAAM,KAAK,GAAG,CAAC,EAAE,SAAS,EAAE,GAAG,SAAS,EAAiB,EAAE,EAAE;IAC3D,OAAO,eAAM,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,KAAM,SAAS,GAAI,CAAA;AACrE,CAAC,CAAA;AAED,GAAG,CAAC,KAAK,GAAG,KAAK,CAAA;AACjB,iHAAiH;AACjH,GAAG,CAAC,QAAQ,GAAG,WAAW,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport type { ComponentProps } from \"react\"\nimport s from \"@plexui/styles/components/Kbd/Kbd.module.css\"\nimport { KbdModifier } from \"./KbdModifier\"\n\nexport type KbdProps = ComponentProps<\"kbd\"> & {\n /**\n * Height and text size: `xs` 16px, `sm` 20px, `md` 24px\n * @default sm\n */\n size?: \"xs\" | \"sm\" | \"md\"\n /**\n * `soft` fills the key, `outline` draws its edge. Both mix the text color,\n * so the key reads on any surface.\n * @default soft\n */\n variant?: \"soft\" | \"outline\"\n}\n\n/** A key or a shortcut, such as ⌘K, in a tooltip, a menu item or a sentence. */\nexport const Kbd = ({ size = \"sm\", variant = \"soft\", className, ...restProps }: KbdProps) => {\n return <kbd className={clsx(s.Kbd, className)} data-size={size} data-variant={variant} {...restProps} />\n}\n\nexport type KbdGroupProps = ComponentProps<\"span\">\n\n/** Keys pressed together: a row of `Kbd`. */\nconst Group = ({ className, ...restProps }: KbdGroupProps) => {\n return <span className={clsx(s.Group, className)} {...restProps} />\n}\n\nKbd.Group = Group\n/** A modifier key as the reader's keyboard prints it: ⌘ on a Mac, Ctrl elsewhere (`name` picks ⌘, ⌃, ⌥ or ⇧). */\nKbd.Modifier = KbdModifier\n"]}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import clsx from "clsx";
4
+ import { useSyncExternalStore } from "react";
5
+ import s from "@plexui/styles/components/Kbd/Kbd.module.css";
6
+ /** Each modifier on an Apple keyboard (a symbol and its name) and on another one. `mod` is ⌘ there and Ctrl here. */
7
+ export const KBD_MODIFIERS = {
8
+ mod: { apple: { symbol: "⌘", name: "Command" }, other: { symbol: "Ctrl", name: "Ctrl" } },
9
+ ctrl: { apple: { symbol: "⌃", name: "Control" }, other: { symbol: "Ctrl", name: "Ctrl" } },
10
+ alt: { apple: { symbol: "⌥", name: "Option" }, other: { symbol: "Alt", name: "Alt" } },
11
+ shift: { apple: { symbol: "⇧", name: "Shift" }, other: { symbol: "Shift", name: "Shift" } },
12
+ };
13
+ /** Whether the browser runs on a Mac, an iPhone or an iPad, whose keyboards print ⌘ and ⌥. */
14
+ export const isApplePlatform = () => {
15
+ if (typeof navigator === "undefined")
16
+ return true;
17
+ const platform = navigator.userAgentData?.platform || navigator.platform || navigator.userAgent;
18
+ return /mac|iphone|ipad|ipod/i.test(platform);
19
+ };
20
+ const subscribe = () => () => { };
21
+ /** A modifier key printed as the reader's keyboard prints it: ⌘ on a Mac, Ctrl elsewhere; its name is read out. */
22
+ export const KbdModifier = ({ name = "mod", platform, size = "sm", variant = "soft", className, ...restProps }) => {
23
+ const apple = useSyncExternalStore(subscribe, isApplePlatform, () => true);
24
+ const key = KBD_MODIFIERS[name][platform ?? (apple ? "apple" : "other")];
25
+ return (_jsx("kbd", { className: clsx(s.Kbd, className), "data-size": size, "data-variant": variant, "data-modifier": name, ...restProps, children: key.symbol === key.name ? (key.symbol) : (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", children: key.symbol }), _jsx("span", { className: s.Name, children: key.name })] })) }));
26
+ };
27
+ //# sourceMappingURL=KbdModifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KbdModifier.js","sourceRoot":"","sources":["../../../../src/components/Kbd/KbdModifier.tsx"],"names":[],"mappings":"AAAA,YAAY,CA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AAG,EAAE,GAAE,CAAC,CAAA;AAShC,mHAAmH;AACnH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,EAAoB,EAAE,EAAE;IAClI,MAAM,KAAK,GAAG,oBAAoB,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;IAC1E,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;IACxE,OAAO,CACL,cAAK,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,eAAa,IAAI,kBAAgB,OAAO,mBAAiB,IAAI,KAAM,SAAS,YAC/G,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CACzB,GAAG,CAAC,MAAM,CACX,CAAC,CAAC,CAAC,CACF,8BACE,8BAAkB,MAAM,YAAE,GAAG,CAAC,MAAM,GAAQ,EAC5C,eAAM,SAAS,EAAE,CAAC,CAAC,IAAI,YAAG,GAAG,CAAC,IAAI,GAAQ,IACzC,CACJ,GACG,CACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { useSyncExternalStore } from \"react\"\nimport s from \"@plexui/styles/components/Kbd/Kbd.module.css\"\nimport type { KbdProps } from \"./Kbd\"\n\nexport type KbdModifierName = \"mod\" | \"ctrl\" | \"alt\" | \"shift\"\nexport type KbdPlatform = \"apple\" | \"other\"\n\n/** Each modifier on an Apple keyboard (a symbol and its name) and on another one. `mod` is ⌘ there and Ctrl here. */\nexport const KBD_MODIFIERS: Record<KbdModifierName, Record<KbdPlatform, { symbol: string; name: string }>> = {\n mod: { apple: { symbol: \"⌘\", name: \"Command\" }, other: { symbol: \"Ctrl\", name: \"Ctrl\" } },\n ctrl: { apple: { symbol: \"⌃\", name: \"Control\" }, other: { symbol: \"Ctrl\", name: \"Ctrl\" } },\n alt: { apple: { symbol: \"⌥\", name: \"Option\" }, other: { symbol: \"Alt\", name: \"Alt\" } },\n shift: { apple: { symbol: \"⇧\", name: \"Shift\" }, other: { symbol: \"Shift\", name: \"Shift\" } },\n}\n\n/** Whether the browser runs on a Mac, an iPhone or an iPad, whose keyboards print ⌘ and ⌥. */\nexport const isApplePlatform = () => {\n if (typeof navigator === \"undefined\") return true\n const platform = (navigator as Navigator & { userAgentData?: { platform?: string } }).userAgentData?.platform || navigator.platform || navigator.userAgent\n return /mac|iphone|ipad|ipod/i.test(platform)\n}\n\nconst subscribe = () => () => {}\n\nexport type KbdModifierProps = Omit<KbdProps, \"children\"> & {\n /** The modifier: `mod` is ⌘ on an Apple keyboard and Ctrl on another, as an app's shortcuts are. @default \"mod\" */\n name?: KbdModifierName\n /** The keyboard to print for; by default the one the browser runs on (Apple on the server). */\n platform?: KbdPlatform\n}\n\n/** A modifier key printed as the reader's keyboard prints it: ⌘ on a Mac, Ctrl elsewhere; its name is read out. */\nexport const KbdModifier = ({ name = \"mod\", platform, size = \"sm\", variant = \"soft\", className, ...restProps }: KbdModifierProps) => {\n const apple = useSyncExternalStore(subscribe, isApplePlatform, () => true)\n const key = KBD_MODIFIERS[name][platform ?? (apple ? \"apple\" : \"other\")]\n return (\n <kbd className={clsx(s.Kbd, className)} data-size={size} data-variant={variant} data-modifier={name} {...restProps}>\n {key.symbol === key.name ? (\n key.symbol\n ) : (\n <>\n <span aria-hidden=\"true\">{key.symbol}</span>\n <span className={s.Name}>{key.name}</span>\n </>\n )}\n </kbd>\n )\n}\n"]}
@@ -1,2 +1,3 @@
1
1
  export { Kbd } from "./Kbd.js";
2
+ export { KBD_MODIFIERS, KbdModifier, isApplePlatform } from "./KbdModifier.js";
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Kbd/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAqC,MAAM,OAAO,CAAA","sourcesContent":["export { Kbd, type KbdGroupProps, type KbdProps } from \"./Kbd\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Kbd/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAqC,MAAM,OAAO,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAiE,MAAM,eAAe,CAAA","sourcesContent":["export { Kbd, type KbdGroupProps, type KbdProps } from \"./Kbd\"\nexport { KBD_MODIFIERS, KbdModifier, isApplePlatform, type KbdModifierName, type KbdModifierProps, type KbdPlatform } from \"./KbdModifier\"\n"]}
@@ -4,7 +4,24 @@ import clsx from "clsx";
4
4
  import {} from "react";
5
5
  import { Progress as RadixProgress } from "radix-ui";
6
6
  import s from "@plexui/styles/components/Progress/Progress.module.css";
7
- export const Progress = ({ value = null, max = 100, className, ...restProps }) => {
7
+ /** The parts of a segmented bar, each clamped so their sum stays within `max`, and their sum. */
8
+ export const progressSegments = (segments, max) => {
9
+ let total = 0;
10
+ const parts = segments.map((segment) => {
11
+ const value = Math.max(0, Math.min(max - total, segment.value || 0));
12
+ total += value;
13
+ return { ...segment, value };
14
+ });
15
+ return { parts, total };
16
+ };
17
+ const segmentsLabel = (parts, max) => parts.map((part) => `${part.label ? `${part.label} ` : ""}${Math.round((part.value / max) * 100)}%`).join(", ");
18
+ export const Progress = ({ value = null, max = 100, segments, className, ...restProps }) => {
19
+ if (segments) {
20
+ // Radix falls back to 100 for a max that is not a positive number; the parts are measured against the same
21
+ const rootMax = typeof max === "number" && max > 0 && !Number.isNaN(max) ? max : 100;
22
+ const { parts, total } = progressSegments(segments, rootMax);
23
+ return (_jsx(RadixProgress.Root, { value: total, max: rootMax, getValueLabel: () => segmentsLabel(parts, rootMax), className: clsx(s.Root, className), "data-segmented": "", ...restProps, children: parts.map((part, index) => part.value > 0 ? (_jsx("div", { className: s.Segment, "data-color": part.color ?? "primary", style: { width: `${(part.value / rootMax) * 100}%` } }, index)) : null) }));
24
+ }
8
25
  const resolved = value == null ? null : Math.max(0, Math.min(max, value));
9
26
  const percentage = resolved == null ? null : (resolved / max) * 100;
10
27
  return (_jsx(RadixProgress.Root, { value: resolved, max: max, className: clsx(s.Root, className), ...restProps, children: _jsx(RadixProgress.Indicator, { className: s.Indicator, style: {
@@ -1 +1 @@
1
- {"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAuB,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,CAAC,MAAM,wDAAwD,CAAA;AAmBtE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,KAAK,GAAG,IAAI,EACZ,GAAG,GAAG,GAAG,EACT,SAAS,EACT,GAAG,SAAS,EACE,EAAE,EAAE;IAClB,MAAM,QAAQ,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;IACzE,MAAM,UAAU,GAAG,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;IAEnE,OAAO,CACL,KAAC,aAAa,CAAC,IAAI,IACjB,KAAK,EAAE,QAAQ,EACf,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,KAC9B,SAAS,YAEb,KAAC,aAAa,CAAC,SAAS,IACtB,SAAS,EAAE,CAAC,CAAC,SAAS,EACtB,KAAK,EAAE;gBACL,SAAS,EACP,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,GAAG,GAAG,UAAU,IAAI;aACvE,wBACmB,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,GACvD,GACiB,CACtB,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { type ComponentProps } from \"react\"\nimport { Progress as RadixProgress } from \"radix-ui\"\nimport s from \"@plexui/styles/components/Progress/Progress.module.css\"\n\nexport type ProgressProps = Omit<\n ComponentProps<typeof RadixProgress.Root>,\n \"children\"\n> & {\n /**\n * Current progress value, between `0` and `max`.\n * Omit (or pass `null`) for an indeterminate state.\n */\n value?: number | null\n /**\n * Maximum value.\n * @default 100\n */\n max?: number\n className?: string\n}\n\nexport const Progress = ({\n value = null,\n max = 100,\n className,\n ...restProps\n}: ProgressProps) => {\n const resolved = value == null ? null : Math.max(0, Math.min(max, value))\n const percentage = resolved == null ? null : (resolved / max) * 100\n\n return (\n <RadixProgress.Root\n value={resolved}\n max={max}\n className={clsx(s.Root, className)}\n {...restProps}\n >\n <RadixProgress.Indicator\n className={s.Indicator}\n style={{\n transform:\n percentage == null ? undefined : `translateX(-${100 - percentage}%)`,\n }}\n data-indeterminate={percentage == null ? \"\" : undefined}\n />\n </RadixProgress.Root>\n )\n}\n"]}
1
+ {"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAuB,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,UAAU,CA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AAI,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,KAC9B,SAAS,YAEb,KAAC,aAAa,CAAC,SAAS,IACtB,SAAS,EAAE,CAAC,CAAC,SAAS,EACtB,KAAK,EAAE;gBACL,SAAS,EACP,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,GAAG,GAAG,UAAU,IAAI;aACvE,wBACmB,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,GACvD,GACiB,CACtB,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { type ComponentProps } from \"react\"\nimport { Progress as RadixProgress } from \"radix-ui\"\nimport s from \"@plexui/styles/components/Progress/Progress.module.css\"\n\nexport type ProgressColor = \"primary\" | \"secondary\" | \"success\" | \"warning\" | \"caution\" | \"danger\" | \"info\" | \"discovery\"\n\n/** A part of a segmented bar: its share of `max`, its color, and the name it is read with. */\nexport type ProgressSegment = {\n value: number\n /** @default \"primary\" */\n color?: ProgressColor\n /** Read out with its share, such as \"Paid 60%\" */\n label?: string\n}\n\nexport type ProgressProps = Omit<\n ComponentProps<typeof RadixProgress.Root>,\n \"children\"\n> & {\n /**\n * Current progress value, between `0` and `max`.\n * Omit (or pass `null`) for an indeterminate state.\n */\n value?: number | null\n /**\n * Maximum value.\n * @default 100\n */\n max?: number\n /**\n * Parts of one bar, side by side in their colors, such as paid, pending and due. The value is their sum; they\n * take `value`'s place. A part's share is clamped so the bar never passes `max`.\n */\n segments?: ProgressSegment[]\n className?: string\n}\n\n/** The parts of a segmented bar, each clamped so their sum stays within `max`, and their sum. */\nexport const progressSegments = (segments: ProgressSegment[], max: number) => {\n let total = 0\n const parts = segments.map((segment) => {\n const value = Math.max(0, Math.min(max - total, segment.value || 0))\n total += value\n return { ...segment, value }\n })\n return { parts, total }\n}\n\nconst segmentsLabel = (parts: ProgressSegment[], max: number) =>\n parts.map((part) => `${part.label ? `${part.label} ` : \"\"}${Math.round((part.value / max) * 100)}%`).join(\", \")\n\nexport const Progress = ({\n value = null,\n max = 100,\n segments,\n className,\n ...restProps\n}: ProgressProps) => {\n if (segments) {\n // Radix falls back to 100 for a max that is not a positive number; the parts are measured against the same\n const rootMax = typeof max === \"number\" && max > 0 && !Number.isNaN(max) ? max : 100\n const { parts, total } = progressSegments(segments, rootMax)\n return (\n <RadixProgress.Root\n value={total}\n max={rootMax}\n getValueLabel={() => segmentsLabel(parts, rootMax)}\n className={clsx(s.Root, className)}\n data-segmented=\"\"\n {...restProps}\n >\n {parts.map((part, index) =>\n part.value > 0 ? (\n <div key={index} className={s.Segment} data-color={part.color ?? \"primary\"} style={{ width: `${(part.value / rootMax) * 100}%` }} />\n ) : null,\n )}\n </RadixProgress.Root>\n )\n }\n\n const resolved = value == null ? null : Math.max(0, Math.min(max, value))\n const percentage = resolved == null ? null : (resolved / max) * 100\n\n return (\n <RadixProgress.Root\n value={resolved}\n max={max}\n className={clsx(s.Root, className)}\n {...restProps}\n >\n <RadixProgress.Indicator\n className={s.Indicator}\n style={{\n transform:\n percentage == null ? undefined : `translateX(-${100 - percentage}%)`,\n }}\n data-indeterminate={percentage == null ? \"\" : undefined}\n />\n </RadixProgress.Root>\n )\n}\n"]}
@@ -1,2 +1,2 @@
1
- export { Progress } from "./Progress.js";
1
+ export { Progress, progressSegments } from "./Progress.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Progress/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,YAAY,CAAA","sourcesContent":["export { Progress, type ProgressProps } from \"./Progress\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Progress/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAgE,MAAM,YAAY,CAAA","sourcesContent":["export { Progress, progressSegments, type ProgressColor, type ProgressProps, type ProgressSegment } from \"./Progress\"\n"]}
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import clsx from "clsx";
3
+ import s from "@plexui/styles/components/RollingNumber/RollingNumber.module.css";
4
+ /** A written number's characters, each keyed by its place around the decimal separator, so a digit keeps its reel
5
+ * when the number grows or its fraction gets longer; digits are the locale's own (Arabic-Indic, Bengali…). */
6
+ export const rollingNumberParts = (value, locales = "en-US", format) => {
7
+ const formatter = new Intl.NumberFormat(locales, format);
8
+ const { locale, numberingSystem } = formatter.resolvedOptions();
9
+ const digitFormatter = new Intl.NumberFormat(locale, { numberingSystem, useGrouping: false });
10
+ const glyphs = Array.from({ length: 10 }, (_, digit) => digitFormatter.format(digit));
11
+ const parts = formatter.formatToParts(value);
12
+ let integers = parts.reduce((count, part) => count + (part.type === "integer" ? Array.from(part.value).length : 0), 0);
13
+ let fractions = 0;
14
+ const seen = {};
15
+ const characters = parts.flatMap((part) => Array.from(part.value).map((character) => {
16
+ const glyph = glyphs.indexOf(character);
17
+ const digit = (part.type === "integer" || part.type === "fraction") && glyph >= 0 ? glyph : null;
18
+ let key;
19
+ if (part.type === "integer")
20
+ key = `i${integers--}`;
21
+ else if (part.type === "fraction")
22
+ key = `f${++fractions}`;
23
+ else if (part.type === "group")
24
+ key = `g${integers}`;
25
+ else {
26
+ seen[part.type] = (seen[part.type] ?? 0) + 1;
27
+ key = `${part.type}${seen[part.type]}-${character}`;
28
+ }
29
+ return { character, digit, key };
30
+ }));
31
+ return { text: parts.map((part) => part.value).join(""), glyphs, characters };
32
+ };
33
+ /**
34
+ * A number whose digits roll to a new value, as an odometer: for a total, a balance, a count or a KPI that changes
35
+ * while it is watched. It reads as the written number; its reels are hidden from a screen reader.
36
+ */
37
+ export const RollingNumber = ({ value, locales, format, className, ...restProps }) => {
38
+ const { text, glyphs, characters } = rollingNumberParts(value, locales, format);
39
+ return (_jsxs("span", { className: clsx(s.RollingNumber, className), ...restProps, children: [_jsx("span", { className: s.Text, children: text }), _jsx("span", { className: s.Visual, "aria-hidden": "true", children: characters.map(({ character, digit, key }) => digit === null ? (_jsx("span", { children: character }, key)) : (_jsxs("span", { className: s.Digit, "data-digit": digit, children: [_jsx("span", { className: s.Ghost, children: character }), _jsx("span", { className: s.Reel, style: { "--rolling-number-digit": digit }, children: glyphs.map((reelDigit) => (_jsx("span", { children: reelDigit }, reelDigit))) })] }, key))) })] }));
40
+ };
41
+ //# sourceMappingURL=RollingNumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RollingNumber.js","sourceRoot":"","sources":["../../../../src/components/RollingNumber/RollingNumber.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,CAAC,MAAM,kEAAkE,CAAA;AAWhF;8GAC8G;AAC9G,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,UAAgC,OAAO,EAAE,MAAiC,EAAE,EAAE;IAC9H,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACxD,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC,eAAe,EAAE,CAAA;IAC/D,MAAM,cAAc,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAA;IAC7F,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IACrF,MAAM,KAAK,GAAG,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAC5C,IAAI,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAA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CAAC,CACzB,yBAAuB,SAAS,IAArB,SAAS,CAAoB,CACzC,CAAC,GACG,KANE,GAAG,CAOP,CACR,CACF,GACI,IACF,CACR,CAAA;AACH,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport type { ComponentProps, CSSProperties } from \"react\"\nimport s from \"@plexui/styles/components/RollingNumber/RollingNumber.module.css\"\n\nexport type RollingNumberProps = Omit<ComponentProps<\"span\">, \"children\"> & {\n /** The number shown. A new value rolls each changed digit to it. */\n value: number\n /** The locale the number is written in, as `Intl.NumberFormat` takes it; fixed, so the server writes it as the browser does. @default \"en-US\" */\n locales?: Intl.LocalesArgument\n /** How the number is written: currency, percent, fraction digits, grouping, as `Intl.NumberFormat` takes it. */\n format?: Intl.NumberFormatOptions\n}\n\n/** A written number's characters, each keyed by its place around the decimal separator, so a digit keeps its reel\n * when the number grows or its fraction gets longer; digits are the locale's own (Arabic-Indic, Bengali…). */\nexport const rollingNumberParts = (value: number, locales: Intl.LocalesArgument = \"en-US\", format?: Intl.NumberFormatOptions) => {\n const formatter = new Intl.NumberFormat(locales, format)\n const { locale, numberingSystem } = formatter.resolvedOptions()\n const digitFormatter = new Intl.NumberFormat(locale, { numberingSystem, useGrouping: false })\n const glyphs = Array.from({ length: 10 }, (_, digit) => digitFormatter.format(digit))\n const parts = formatter.formatToParts(value)\n let integers = parts.reduce((count, part) => count + (part.type === \"integer\" ? Array.from(part.value).length : 0), 0)\n let fractions = 0\n const seen: Record<string, number> = {}\n const characters = parts.flatMap((part) =>\n Array.from(part.value).map((character) => {\n const glyph = glyphs.indexOf(character)\n const digit = (part.type === \"integer\" || part.type === \"fraction\") && glyph >= 0 ? glyph : null\n let key: string\n if (part.type === \"integer\") key = `i${integers--}`\n else if (part.type === \"fraction\") key = `f${++fractions}`\n else if (part.type === \"group\") key = `g${integers}`\n else {\n seen[part.type] = (seen[part.type] ?? 0) + 1\n key = `${part.type}${seen[part.type]}-${character}`\n }\n return { character, digit, key }\n }),\n )\n return { text: parts.map((part) => part.value).join(\"\"), glyphs, characters }\n}\n\n/**\n * A number whose digits roll to a new value, as an odometer: for a total, a balance, a count or a KPI that changes\n * while it is watched. It reads as the written number; its reels are hidden from a screen reader.\n */\nexport const RollingNumber = ({ value, locales, format, className, ...restProps }: RollingNumberProps) => {\n const { text, glyphs, characters } = rollingNumberParts(value, locales, format)\n return (\n <span className={clsx(s.RollingNumber, className)} {...restProps}>\n <span className={s.Text}>{text}</span>\n <span className={s.Visual} aria-hidden=\"true\">\n {characters.map(({ character, digit, key }) =>\n digit === null ? (\n <span key={key}>{character}</span>\n ) : (\n <span key={key} className={s.Digit} data-digit={digit}>\n <span className={s.Ghost}>{character}</span>\n <span className={s.Reel} style={{ \"--rolling-number-digit\": digit } as CSSProperties}>\n {glyphs.map((reelDigit) => (\n <span key={reelDigit}>{reelDigit}</span>\n ))}\n </span>\n </span>\n ),\n )}\n </span>\n </span>\n )\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { RollingNumber, rollingNumberParts } from "./RollingNumber.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/RollingNumber/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAA2B,MAAM,iBAAiB,CAAA","sourcesContent":["export { RollingNumber, rollingNumberParts, type RollingNumberProps } from \"./RollingNumber\"\n"]}
@@ -16,5 +16,7 @@ export type KbdProps = ComponentProps<"kbd"> & {
16
16
  export declare const Kbd: {
17
17
  ({ size, variant, className, ...restProps }: KbdProps): import("react/jsx-runtime").JSX.Element;
18
18
  Group: ({ className, ...restProps }: KbdGroupProps) => import("react/jsx-runtime").JSX.Element;
19
+ /** A modifier key as the reader's keyboard prints it: ⌘ on a Mac, Ctrl elsewhere (`name` picks ⌘, ⌃, ⌥ or ⇧). */
20
+ Modifier: ({ name, platform, size, variant, className, ...restProps }: import("./KbdModifier.js").KbdModifierProps) => import("react/jsx-runtime").JSX.Element;
19
21
  };
20
22
  export type KbdGroupProps = ComponentProps<"span">;
@@ -0,0 +1,18 @@
1
+ import type { KbdProps } from "./Kbd.js";
2
+ export type KbdModifierName = "mod" | "ctrl" | "alt" | "shift";
3
+ export type KbdPlatform = "apple" | "other";
4
+ /** Each modifier on an Apple keyboard (a symbol and its name) and on another one. `mod` is ⌘ there and Ctrl here. */
5
+ export declare const KBD_MODIFIERS: Record<KbdModifierName, Record<KbdPlatform, {
6
+ symbol: string;
7
+ name: string;
8
+ }>>;
9
+ /** Whether the browser runs on a Mac, an iPhone or an iPad, whose keyboards print ⌘ and ⌥. */
10
+ export declare const isApplePlatform: () => boolean;
11
+ export type KbdModifierProps = Omit<KbdProps, "children"> & {
12
+ /** The modifier: `mod` is ⌘ on an Apple keyboard and Ctrl on another, as an app's shortcuts are. @default "mod" */
13
+ name?: KbdModifierName;
14
+ /** The keyboard to print for; by default the one the browser runs on (Apple on the server). */
15
+ platform?: KbdPlatform;
16
+ };
17
+ /** A modifier key printed as the reader's keyboard prints it: ⌘ on a Mac, Ctrl elsewhere; its name is read out. */
18
+ export declare const KbdModifier: ({ name, platform, size, variant, className, ...restProps }: KbdModifierProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1,2 @@
1
1
  export { Kbd, type KbdGroupProps, type KbdProps } from "./Kbd.js";
2
+ export { KBD_MODIFIERS, KbdModifier, isApplePlatform, type KbdModifierName, type KbdModifierProps, type KbdPlatform } from "./KbdModifier.js";
@@ -1,5 +1,14 @@
1
1
  import { type ComponentProps } from "react";
2
2
  import { Progress as RadixProgress } from "radix-ui";
3
+ export type ProgressColor = "primary" | "secondary" | "success" | "warning" | "caution" | "danger" | "info" | "discovery";
4
+ /** A part of a segmented bar: its share of `max`, its color, and the name it is read with. */
5
+ export type ProgressSegment = {
6
+ value: number;
7
+ /** @default "primary" */
8
+ color?: ProgressColor;
9
+ /** Read out with its share, such as "Paid 60%" */
10
+ label?: string;
11
+ };
3
12
  export type ProgressProps = Omit<ComponentProps<typeof RadixProgress.Root>, "children"> & {
4
13
  /**
5
14
  * Current progress value, between `0` and `max`.
@@ -11,6 +20,22 @@ export type ProgressProps = Omit<ComponentProps<typeof RadixProgress.Root>, "chi
11
20
  * @default 100
12
21
  */
13
22
  max?: number;
23
+ /**
24
+ * Parts of one bar, side by side in their colors, such as paid, pending and due. The value is their sum; they
25
+ * take `value`'s place. A part's share is clamped so the bar never passes `max`.
26
+ */
27
+ segments?: ProgressSegment[];
14
28
  className?: string;
15
29
  };
16
- export declare const Progress: ({ value, max, className, ...restProps }: ProgressProps) => import("react/jsx-runtime").JSX.Element;
30
+ /** The parts of a segmented bar, each clamped so their sum stays within `max`, and their sum. */
31
+ export declare const progressSegments: (segments: ProgressSegment[], max: number) => {
32
+ parts: {
33
+ value: number;
34
+ /** @default "primary" */
35
+ color?: ProgressColor;
36
+ /** Read out with its share, such as "Paid 60%" */
37
+ label?: string;
38
+ }[];
39
+ total: number;
40
+ };
41
+ export declare const Progress: ({ value, max, segments, className, ...restProps }: ProgressProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- export { Progress, type ProgressProps } from "./Progress.js";
1
+ export { Progress, progressSegments, type ProgressColor, type ProgressProps, type ProgressSegment } from "./Progress.js";
@@ -0,0 +1,25 @@
1
+ import type { ComponentProps } from "react";
2
+ export type RollingNumberProps = Omit<ComponentProps<"span">, "children"> & {
3
+ /** The number shown. A new value rolls each changed digit to it. */
4
+ value: number;
5
+ /** The locale the number is written in, as `Intl.NumberFormat` takes it; fixed, so the server writes it as the browser does. @default "en-US" */
6
+ locales?: Intl.LocalesArgument;
7
+ /** How the number is written: currency, percent, fraction digits, grouping, as `Intl.NumberFormat` takes it. */
8
+ format?: Intl.NumberFormatOptions;
9
+ };
10
+ /** A written number's characters, each keyed by its place around the decimal separator, so a digit keeps its reel
11
+ * when the number grows or its fraction gets longer; digits are the locale's own (Arabic-Indic, Bengali…). */
12
+ export declare const rollingNumberParts: (value: number, locales?: Intl.LocalesArgument, format?: Intl.NumberFormatOptions) => {
13
+ text: string;
14
+ glyphs: string[];
15
+ characters: {
16
+ character: string;
17
+ digit: number | null;
18
+ key: string;
19
+ }[];
20
+ };
21
+ /**
22
+ * A number whose digits roll to a new value, as an odometer: for a total, a balance, a count or a KPI that changes
23
+ * while it is watched. It reads as the written number; its reels are hidden from a screen reader.
24
+ */
25
+ export declare const RollingNumber: ({ value, locales, format, className, ...restProps }: RollingNumberProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { RollingNumber, rollingNumberParts, type RollingNumberProps } from "./RollingNumber.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexui/ui",
3
- "version": "0.57.0",
3
+ "version": "0.58.0",
4
4
  "description": "Modern design system for building high-quality applications",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -99,7 +99,7 @@
99
99
  "@maskito/core": "^5.2.2",
100
100
  "@maskito/kit": "^5.2.2",
101
101
  "@maskito/react": "^5.2.2",
102
- "@plexui/styles": "^0.15.0",
102
+ "@plexui/styles": "^0.16.0",
103
103
  "@radix-ui/react-dismissable-layer": "1.2.1",
104
104
  "@radix-ui/react-focus-guards": "1.2.0",
105
105
  "@radix-ui/react-focus-scope": "1.3.1",