@plexui/vue 0.37.0 → 0.39.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.
- package/dist/es/components/Dialog/Dialog.js +2 -1
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Kbd/Kbd.js +41 -1
- package/dist/es/components/Kbd/Kbd.js.map +1 -1
- package/dist/es/components/Kbd/index.js +1 -1
- package/dist/es/components/Kbd/index.js.map +1 -1
- package/dist/es/components/NavigationRow/NavigationRow.js +13 -6
- package/dist/es/components/NavigationRow/NavigationRow.js.map +1 -1
- package/dist/es/components/Progress/Progress.js +32 -0
- package/dist/es/components/Progress/Progress.js.map +1 -1
- package/dist/es/components/Progress/index.js +1 -1
- package/dist/es/components/Progress/index.js.map +1 -1
- package/dist/es/components/RollingNumber/RollingNumber.js +64 -0
- package/dist/es/components/RollingNumber/RollingNumber.js.map +1 -0
- package/dist/es/components/RollingNumber/index.js +2 -0
- package/dist/es/components/RollingNumber/index.js.map +1 -0
- package/dist/es/components/Select/Select.js +9 -2
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/Textarea/Textarea.js +3 -3
- package/dist/es/components/Textarea/Textarea.js.map +1 -1
- package/dist/es/components/Toolbar/Toolbar.js +14 -5
- package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/es/lib/observeTextareaWidth.js +6 -0
- package/dist/es/lib/observeTextareaWidth.js.map +1 -1
- package/dist/types/components/Kbd/Kbd.d.ts +68 -0
- package/dist/types/components/Kbd/index.d.ts +1 -1
- package/dist/types/components/Progress/Progress.d.ts +37 -0
- package/dist/types/components/Progress/index.d.ts +1 -1
- package/dist/types/components/RollingNumber/RollingNumber.d.ts +63 -0
- package/dist/types/components/RollingNumber/index.d.ts +1 -0
- package/dist/types/components/Select/Select.d.ts +17 -0
- package/dist/types/lib/observeTextareaWidth.d.ts +6 -0
- package/package.json +2 -2
|
@@ -75,14 +75,21 @@ const NavigationRowComponent = defineComponent({
|
|
|
75
75
|
check();
|
|
76
76
|
};
|
|
77
77
|
onMounted(() => {
|
|
78
|
-
check();
|
|
79
|
-
fonts?.ready.then(onFonts);
|
|
80
78
|
fonts?.addEventListener?.("loadingdone", onFonts);
|
|
81
|
-
if (typeof ResizeObserver === "undefined" || !row.value)
|
|
79
|
+
if (typeof ResizeObserver === "undefined" || !row.value) {
|
|
80
|
+
check();
|
|
81
|
+
fonts?.ready.then(onFonts);
|
|
82
82
|
return;
|
|
83
|
-
|
|
84
|
-
observer
|
|
85
|
-
|
|
83
|
+
}
|
|
84
|
+
// The first measure waits for the observer's first report, after the frame's layout and before its paint: a
|
|
85
|
+
// measure on mount forced a layout for every row while a sheet of rows was being built. Fonts that finish
|
|
86
|
+
// loading after that report measure again; before it, the report itself measures with them.
|
|
87
|
+
fonts?.ready.then(() => {
|
|
88
|
+
if (width !== -1)
|
|
89
|
+
onFonts();
|
|
90
|
+
});
|
|
91
|
+
observer = new ResizeObserver((entries) => {
|
|
92
|
+
const next = entries?.[entries.length - 1]?.contentRect.width ?? row.value?.getBoundingClientRect().width ?? width;
|
|
86
93
|
if (next === width)
|
|
87
94
|
return;
|
|
88
95
|
width = next;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationRow.js","sourceRoot":"","sources":["../../../../src/components/NavigationRow/NavigationRow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsF,eAAe,EAAE,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAiB,GAAG,EAAmB,KAAK,EAAE,MAAM,KAAK,CAAA;AACzN,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,CAAC,MAAM,kEAAkE,CAAA;AAIhF,MAAM,KAAK,GAAG,CA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,EAAE,KAAK,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAA;YAEpF,OAAO,CAAC,CACN,KAAK,EACL;gBACE,KAAK,EAAE,GAAG;gBACV,OAAO,EAAE,CAAC,CAAC,aAAa;gBACxB,UAAU,EAAE,EAAE;gBACd,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;gBAC1C,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;gBACvC,kBAAkB,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;aACpD,EACD;gBACE,IAAI;oBACF,CAAC,CAAC,CAAC,CACC,UAAU,EACV,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,EAC9G,EAAE,OAAO,EAAE,OAAO,EAAE,CACrB;oBACH,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;aACtG,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAYF,MAAM,CAAC,MAAM,aAAa,GAAG,sBAE5B,CAAA","sourcesContent":["import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type ComponentPublicInstance, defineComponent, h, nextTick, onBeforeUnmount, onMounted, onUpdated, type PropType, ref, type VNodeChild, watch } from \"vue\"\nimport { Button, ButtonLink } from \"../Button/index.js\"\nimport { Disclosure } from \"../Icon/index.js\"\nimport { useFieldColumns } from \"../../lib/fieldRow.js\"\nimport type { LinkComponent } from \"../PlexUIProvider/index.js\"\nimport s from \"@plexui/styles/components/NavigationRow/NavigationRow.module.css\"\n\ntype RouteTarget = string | Record<string, unknown>\n\nconst shown = (value: unknown) => value !== null && value !== undefined && value !== false && value !== \"\"\n\n/** Whether the label and the value of a row fit beside each other on one line: measured in the end layout, unwrapped */\nconst valueFitsBeside = (row: HTMLElement) => {\n const content = row.querySelector<HTMLElement>(\"[data-navigation-row-content]\")\n if (!content) return true\n const below = row.hasAttribute(\"data-value-below\")\n row.removeAttribute(\"data-value-below\")\n row.setAttribute(\"data-measuring\", \"\")\n const fits = [content, ...content.querySelectorAll<HTMLElement>(\"[data-navigation-row-part]\")].every(\n (element) => element.scrollWidth <= element.clientWidth + 0.5,\n )\n row.removeAttribute(\"data-measuring\")\n if (below) row.setAttribute(\"data-value-below\", \"\")\n return fits\n}\n\n/**\n * Vue port of `NavigationRow` from packages/ui/src/components/NavigationRow/NavigationRow.tsx: a FieldGroup row\n * that opens what it holds, as an iOS Settings drill-in. Attributes (id, class, ARIA, data, listeners) fall through\n * to the pressable. The `label`, `value` and `description` slots take the place of their props.\n */\nconst NavigationRowComponent = defineComponent({\n name: \"NavigationRow\",\n inheritAttrs: false,\n props: {\n /** The row's name, where a row's label starts */\n label: [String, Number] as PropType<string | number>,\n /** The current value, at the end of the row in the secondary label. `0` shows; `null`, `undefined` and `\"\"` do not. */\n value: [String, Number] as PropType<string | number | null>,\n /** A line under the label; the row grows from 52 to hold it */\n description: [String, Number] as PropType<string | number>,\n /** Where the row goes. With it the row is a link (through `PlexUIProvider`'s `linkComponent`, or `as`). */\n href: String,\n /** A router target; with it the row is a link through the provider's link component */\n to: [String, Object] as PropType<RouteTarget>,\n /** Force external-link behavior */\n external: { type: Boolean, default: undefined },\n /** Link component override (e.g. a router link). */\n as: [String, Object, Function] as PropType<LinkComponent>,\n /** The row can't be pressed. A disabled link renders as a disabled button, so it never navigates. */\n disabled: { type: Boolean, default: undefined },\n /**\n * Where the value stands: at the `end` of the row, `below` the label at the full width, or `auto`: at the end while\n * it fits beside the label on one line, otherwise below (as Calendar sets a long value).\n */\n valuePlacement: { type: String as PropType<\"end\" | \"below\" | \"auto\">, default: \"end\" },\n },\n setup(props, { attrs, slots, expose }) {\n const pressable = ref<ComponentPublicInstance | null>(null)\n const element = () => (pressable.value?.$el ?? null) as HTMLElement | null\n // A ref reaches the pressable, as in React: its element and focus()\n expose({ focus: (options?: FocusOptions) => element()?.focus(options), get element() { return element() } })\n\n // \"auto\": measure after each render and when the row's width changes\n const row = ref<HTMLElement | null>(null)\n const fits = ref(true)\n const hasValueNow = () => !!slots.value || shown(props.value)\n const check = () => {\n if (props.valuePlacement !== \"auto\" || !hasValueNow() || !row.value) return\n const next = valueFitsBeside(row.value)\n if (next !== fits.value) fits.value = next\n }\n let observer: ResizeObserver | undefined\n let width = -1\n // A web font that arrives late (font-display: swap) changes the words' widths, not the row's\n const fonts = typeof document !== \"undefined\" ? document.fonts : undefined\n let live = true\n const onFonts = () => {\n if (live) check()\n }\n onMounted(() => {\n check()\n fonts?.ready.then(onFonts)\n fonts?.addEventListener?.(\"loadingdone\", onFonts)\n if (typeof ResizeObserver === \"undefined\" || !row.value) return\n width = row.value.getBoundingClientRect().width\n observer = new ResizeObserver(() => {\n const next = row.value?.getBoundingClientRect().width ?? width\n if (next === width) return\n width = next\n check()\n })\n observer.observe(row.value)\n })\n onUpdated(check)\n // FieldGroup columns give the label a column of its own: a change of them measures again, after the group renders\n const columns = useFieldColumns()\n watch(columns, () => nextTick(check), { flush: \"post\" })\n onBeforeUnmount(() => {\n live = false\n fonts?.removeEventListener?.(\"loadingdone\", onFonts)\n observer?.disconnect()\n })\n\n return () => {\n const label: VNodeChild = slots.label ? slots.label() : props.label\n const value: VNodeChild = slots.value ? slots.value() : shown(props.value) ? props.value : undefined\n const description: VNodeChild = slots.description ? slots.description() : props.description\n const hasValue = slots.value ? true : shown(props.value)\n const hasDescription = slots.description ? true : shown(props.description)\n const below = hasValue && (props.valuePlacement === \"below\" || (props.valuePlacement === \"auto\" && !fits.value))\n\n const content = () =>\n h(\"span\", { \"class\": s.Content, \"data-navigation-row-content\": \"\" }, [\n h(\"span\", { class: s.Text }, [\n h(\"span\", { \"class\": s.Label, \"data-navigation-row-part\": \"\" }, [label as never]),\n hasDescription ? h(\"span\", { class: s.Description }, [description as never]) : null,\n ]),\n hasValue ? h(\"span\", { \"class\": s.Value, \"data-navigation-row-part\": \"\" }, [value as never]) : null,\n h(Disclosure, { \"class\": s.Disclosure, \"aria-hidden\": \"true\", \"data-no-autosize\": \"\" }),\n ])\n\n const { class: className, ...rest } = attrs\n const shared = {\n \"class\": [s.Pressable, className],\n \"block\": true,\n \"color\": \"secondary\",\n \"variant\": \"ghost\",\n \"data-navigation-row\": \"\",\n } as const\n const link = (props.href !== undefined || props.to !== undefined) && !props.disabled\n\n return h(\n \"div\",\n {\n \"ref\": row,\n \"class\": s.NavigationRow,\n \"data-row\": \"\",\n \"data-value-below\": below ? \"\" : undefined,\n \"data-value\": hasValue ? \"\" : undefined,\n \"data-description\": hasDescription ? \"\" : undefined,\n },\n [\n link\n ? h(\n ButtonLink,\n { ...rest, ...shared, ref: pressable, href: props.href, to: props.to, external: props.external, as: props.as },\n { default: content },\n )\n : h(Button, { ...rest, ...shared, ref: pressable, disabled: props.disabled }, { default: content }),\n ],\n )\n }\n },\n})\n\ntype NavigationRowOwnProps = InstanceType<typeof NavigationRowComponent>[\"$props\"]\n\n/** NavigationRow props plus the native button and link attributes and the click listener that fall through to the\n * pressable, as in React. */\nexport type NavigationRowProps = NavigationRowOwnProps &\n Omit<ButtonHTMLAttributes, keyof NavigationRowOwnProps | \"value\" | \"type\"> &\n Pick<AnchorHTMLAttributes, \"target\" | \"rel\" | \"download\" | \"hreflang\" | \"ping\" | \"referrerpolicy\"> & {\n onClick?: (event: MouseEvent) => void\n }\n\nexport const NavigationRow = NavigationRowComponent as typeof NavigationRowComponent & {\n new (): { $props: NavigationRowProps; focus: (options?: FocusOptions) => void; element: HTMLElement | null }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NavigationRow.js","sourceRoot":"","sources":["../../../../src/components/NavigationRow/NavigationRow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsF,eAAe,EAAE,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAiB,GAAG,EAAmB,KAAK,EAAE,MAAM,KAAK,CAAA;AACzN,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,CAAC,MAAM,kEAAkE,CAAA;AAIhF,MAAM,KAAK,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,EAAE,CAAA;AAE1G,wHAAwH;AACxH,MAAM,eAAe,GAAG,CAAC,GAAgB,EAAE,EAAE;IAC3C,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAc,+BAA+B,CAAC,CAAA;IAC/E,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IACzB,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAA;IAClD,GAAG,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAA;IACvC,GAAG,CAAC,YAAY,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;IACtC,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAc,4BAA4B,CAAC,CAAC,CAAC,KAAK,CAClG,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,GAAG,GAAG,CAC9D,CAAA;IACD,GAAG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AAG,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,EAC9G,EAAE,OAAO,EAAE,OAAO,EAAE,CACrB;oBACH,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;aACtG,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAYF,MAAM,CAAC,MAAM,aAAa,GAAG,sBAE5B,CAAA","sourcesContent":["import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type ComponentPublicInstance, defineComponent, h, nextTick, onBeforeUnmount, onMounted, onUpdated, type PropType, ref, type VNodeChild, watch } from \"vue\"\nimport { Button, ButtonLink } from \"../Button/index.js\"\nimport { Disclosure } from \"../Icon/index.js\"\nimport { useFieldColumns } from \"../../lib/fieldRow.js\"\nimport type { LinkComponent } from \"../PlexUIProvider/index.js\"\nimport s from \"@plexui/styles/components/NavigationRow/NavigationRow.module.css\"\n\ntype RouteTarget = string | Record<string, unknown>\n\nconst shown = (value: unknown) => value !== null && value !== undefined && value !== false && value !== \"\"\n\n/** Whether the label and the value of a row fit beside each other on one line: measured in the end layout, unwrapped */\nconst valueFitsBeside = (row: HTMLElement) => {\n const content = row.querySelector<HTMLElement>(\"[data-navigation-row-content]\")\n if (!content) return true\n const below = row.hasAttribute(\"data-value-below\")\n row.removeAttribute(\"data-value-below\")\n row.setAttribute(\"data-measuring\", \"\")\n const fits = [content, ...content.querySelectorAll<HTMLElement>(\"[data-navigation-row-part]\")].every(\n (element) => element.scrollWidth <= element.clientWidth + 0.5,\n )\n row.removeAttribute(\"data-measuring\")\n if (below) row.setAttribute(\"data-value-below\", \"\")\n return fits\n}\n\n/**\n * Vue port of `NavigationRow` from packages/ui/src/components/NavigationRow/NavigationRow.tsx: a FieldGroup row\n * that opens what it holds, as an iOS Settings drill-in. Attributes (id, class, ARIA, data, listeners) fall through\n * to the pressable. The `label`, `value` and `description` slots take the place of their props.\n */\nconst NavigationRowComponent = defineComponent({\n name: \"NavigationRow\",\n inheritAttrs: false,\n props: {\n /** The row's name, where a row's label starts */\n label: [String, Number] as PropType<string | number>,\n /** The current value, at the end of the row in the secondary label. `0` shows; `null`, `undefined` and `\"\"` do not. */\n value: [String, Number] as PropType<string | number | null>,\n /** A line under the label; the row grows from 52 to hold it */\n description: [String, Number] as PropType<string | number>,\n /** Where the row goes. With it the row is a link (through `PlexUIProvider`'s `linkComponent`, or `as`). */\n href: String,\n /** A router target; with it the row is a link through the provider's link component */\n to: [String, Object] as PropType<RouteTarget>,\n /** Force external-link behavior */\n external: { type: Boolean, default: undefined },\n /** Link component override (e.g. a router link). */\n as: [String, Object, Function] as PropType<LinkComponent>,\n /** The row can't be pressed. A disabled link renders as a disabled button, so it never navigates. */\n disabled: { type: Boolean, default: undefined },\n /**\n * Where the value stands: at the `end` of the row, `below` the label at the full width, or `auto`: at the end while\n * it fits beside the label on one line, otherwise below (as Calendar sets a long value).\n */\n valuePlacement: { type: String as PropType<\"end\" | \"below\" | \"auto\">, default: \"end\" },\n },\n setup(props, { attrs, slots, expose }) {\n const pressable = ref<ComponentPublicInstance | null>(null)\n const element = () => (pressable.value?.$el ?? null) as HTMLElement | null\n // A ref reaches the pressable, as in React: its element and focus()\n expose({ focus: (options?: FocusOptions) => element()?.focus(options), get element() { return element() } })\n\n // \"auto\": measure after each render and when the row's width changes\n const row = ref<HTMLElement | null>(null)\n const fits = ref(true)\n const hasValueNow = () => !!slots.value || shown(props.value)\n const check = () => {\n if (props.valuePlacement !== \"auto\" || !hasValueNow() || !row.value) return\n const next = valueFitsBeside(row.value)\n if (next !== fits.value) fits.value = next\n }\n let observer: ResizeObserver | undefined\n let width = -1\n // A web font that arrives late (font-display: swap) changes the words' widths, not the row's\n const fonts = typeof document !== \"undefined\" ? document.fonts : undefined\n let live = true\n const onFonts = () => {\n if (live) check()\n }\n onMounted(() => {\n fonts?.addEventListener?.(\"loadingdone\", onFonts)\n if (typeof ResizeObserver === \"undefined\" || !row.value) {\n check()\n fonts?.ready.then(onFonts)\n return\n }\n // The first measure waits for the observer's first report, after the frame's layout and before its paint: a\n // measure on mount forced a layout for every row while a sheet of rows was being built. Fonts that finish\n // loading after that report measure again; before it, the report itself measures with them.\n fonts?.ready.then(() => {\n if (width !== -1) onFonts()\n })\n observer = new ResizeObserver((entries?: ResizeObserverEntry[]) => {\n const next = entries?.[entries.length - 1]?.contentRect.width ?? row.value?.getBoundingClientRect().width ?? width\n if (next === width) return\n width = next\n check()\n })\n observer.observe(row.value)\n })\n onUpdated(check)\n // FieldGroup columns give the label a column of its own: a change of them measures again, after the group renders\n const columns = useFieldColumns()\n watch(columns, () => nextTick(check), { flush: \"post\" })\n onBeforeUnmount(() => {\n live = false\n fonts?.removeEventListener?.(\"loadingdone\", onFonts)\n observer?.disconnect()\n })\n\n return () => {\n const label: VNodeChild = slots.label ? slots.label() : props.label\n const value: VNodeChild = slots.value ? slots.value() : shown(props.value) ? props.value : undefined\n const description: VNodeChild = slots.description ? slots.description() : props.description\n const hasValue = slots.value ? true : shown(props.value)\n const hasDescription = slots.description ? true : shown(props.description)\n const below = hasValue && (props.valuePlacement === \"below\" || (props.valuePlacement === \"auto\" && !fits.value))\n\n const content = () =>\n h(\"span\", { \"class\": s.Content, \"data-navigation-row-content\": \"\" }, [\n h(\"span\", { class: s.Text }, [\n h(\"span\", { \"class\": s.Label, \"data-navigation-row-part\": \"\" }, [label as never]),\n hasDescription ? h(\"span\", { class: s.Description }, [description as never]) : null,\n ]),\n hasValue ? h(\"span\", { \"class\": s.Value, \"data-navigation-row-part\": \"\" }, [value as never]) : null,\n h(Disclosure, { \"class\": s.Disclosure, \"aria-hidden\": \"true\", \"data-no-autosize\": \"\" }),\n ])\n\n const { class: className, ...rest } = attrs\n const shared = {\n \"class\": [s.Pressable, className],\n \"block\": true,\n \"color\": \"secondary\",\n \"variant\": \"ghost\",\n \"data-navigation-row\": \"\",\n } as const\n const link = (props.href !== undefined || props.to !== undefined) && !props.disabled\n\n return h(\n \"div\",\n {\n \"ref\": row,\n \"class\": s.NavigationRow,\n \"data-row\": \"\",\n \"data-value-below\": below ? \"\" : undefined,\n \"data-value\": hasValue ? \"\" : undefined,\n \"data-description\": hasDescription ? \"\" : undefined,\n },\n [\n link\n ? h(\n ButtonLink,\n { ...rest, ...shared, ref: pressable, href: props.href, to: props.to, external: props.external, as: props.as },\n { default: content },\n )\n : h(Button, { ...rest, ...shared, ref: pressable, disabled: props.disabled }, { default: content }),\n ],\n )\n }\n },\n})\n\ntype NavigationRowOwnProps = InstanceType<typeof NavigationRowComponent>[\"$props\"]\n\n/** NavigationRow props plus the native button and link attributes and the click listener that fall through to the\n * pressable, as in React. */\nexport type NavigationRowProps = NavigationRowOwnProps &\n Omit<ButtonHTMLAttributes, keyof NavigationRowOwnProps | \"value\" | \"type\"> &\n Pick<AnchorHTMLAttributes, \"target\" | \"rel\" | \"download\" | \"hreflang\" | \"ping\" | \"referrerpolicy\"> & {\n onClick?: (event: MouseEvent) => void\n }\n\nexport const NavigationRow = NavigationRowComponent as typeof NavigationRowComponent & {\n new (): { $props: NavigationRowProps; focus: (options?: FocusOptions) => void; element: HTMLElement | null }\n}\n"]}
|
|
@@ -14,6 +14,17 @@ const DEFAULT_MAX = 100;
|
|
|
14
14
|
const isNumber = (value) => typeof value === "number";
|
|
15
15
|
const isValidMax = (max) => isNumber(max) && !Number.isNaN(max) && max > 0;
|
|
16
16
|
const isValidValue = (value, max) => isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0;
|
|
17
|
+
/** The parts of a segmented bar, each clamped so their sum stays within `max`, and their sum. */
|
|
18
|
+
export const progressSegments = (segments, max) => {
|
|
19
|
+
let total = 0;
|
|
20
|
+
const parts = segments.map((segment) => {
|
|
21
|
+
const value = Math.max(0, Math.min(max - total, segment.value || 0));
|
|
22
|
+
total += value;
|
|
23
|
+
return { ...segment, value };
|
|
24
|
+
});
|
|
25
|
+
return { parts, total };
|
|
26
|
+
};
|
|
27
|
+
const segmentsLabel = (parts, max) => parts.map((part) => `${part.label ? `${part.label} ` : ""}${Math.round((part.value / max) * 100)}%`).join(", ");
|
|
17
28
|
const defaultGetValueLabel = (value, max) => `${Math.round((value / max) * 100)}%`;
|
|
18
29
|
const ProgressComponent = defineComponent({
|
|
19
30
|
name: "Progress",
|
|
@@ -27,10 +38,31 @@ const ProgressComponent = defineComponent({
|
|
|
27
38
|
max: { type: Number, default: DEFAULT_MAX },
|
|
28
39
|
/** Accessible value text for the current value. @default "<percentage>%" */
|
|
29
40
|
getValueLabel: Function,
|
|
41
|
+
/**
|
|
42
|
+
* Parts of one bar, side by side in their colors, such as paid, pending and due. The value is their sum; they
|
|
43
|
+
* take `value`'s place. A part's share is clamped so the bar never passes `max`.
|
|
44
|
+
*/
|
|
45
|
+
segments: { type: Array, default: undefined },
|
|
30
46
|
},
|
|
31
47
|
setup(props) {
|
|
32
48
|
const getValueText = (value, max) => isNumber(value) ? (props.getValueLabel ?? defaultGetValueLabel)(value, max) : undefined;
|
|
33
49
|
return () => {
|
|
50
|
+
if (props.segments) {
|
|
51
|
+
const rootMax = isValidMax(props.max) ? props.max : DEFAULT_MAX;
|
|
52
|
+
const { parts, total } = progressSegments(props.segments, rootMax);
|
|
53
|
+
return h(ProgressRoot, {
|
|
54
|
+
"modelValue": total,
|
|
55
|
+
"max": rootMax,
|
|
56
|
+
"getValueLabel": () => undefined,
|
|
57
|
+
"getValueText": (current, currentMax) => props.getValueLabel && isNumber(current) ? props.getValueLabel(current, currentMax) : segmentsLabel(parts, rootMax),
|
|
58
|
+
"class": s.Root,
|
|
59
|
+
"data-segmented": "",
|
|
60
|
+
}, {
|
|
61
|
+
default: () => parts.map((part, index) => part.value > 0
|
|
62
|
+
? h("div", { "key": index, "class": s.Segment, "data-color": part.color ?? "primary", "style": { width: `${(part.value / rootMax) * 100}%` } })
|
|
63
|
+
: null),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
34
66
|
const { value, max } = props;
|
|
35
67
|
const resolved = value == null ? null : Math.max(0, Math.min(max, value));
|
|
36
68
|
const percentage = resolved == null ? null : (resolved / max) * 100;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../../src/components/Progress/Progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAsC,MAAM,KAAK,CAAA;AAC5E,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,CAAC,MAAM,wDAAwD,CAAA;AAEtE,4EAA4E;AAC5E,6EAA6E;AAC7E,qBAAqB;AACrB,8EAA8E;AAC9E,6EAA6E;AAC7E,iEAAiE;AACjE,2EAA2E;AAC3E,2EAA2E;AAC3E,gFAAgF;AAEhF,MAAM,WAAW,GAAG,GAAG,CAAA;AAEvB,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAA;AAC/E,MAAM,UAAU,GAAG,CAAC,GAAY,EAAiB,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAA;AAClG,MAAM,YAAY,GAAG,CAAC,KAAc,EAAE,GAAW,EAAmB,EAAE,CACpE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC,CAAA;AAEvE,MAAM,oBAAoB,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,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA;YAEnE,OAAO,CAAC,CACN,YAAY,EACZ;gBACE,UAAU,EAAE,SAAS;gBACrB,GAAG,EAAE,OAAO;gBACZ,aAAa,EAAE,GAAG,EAAE,CAAC,SAAS;gBAC9B,YAAY;gBACZ,KAAK,EAAE,CAAC,CAAC,IAAI;aACd,EACD;gBACE,OAAO,EAAE,GAAG,EAAE,CACZ,CAAC,CAAC,iBAAiB,EAAE;oBACnB,OAAO,EAAE,CAAC,CAAC,SAAS;oBACpB,OAAO,EAAE,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,GAAG,GAAG,UAAU,IAAI,EAAE;oBAC5F,oBAAoB,EAAE,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;iBAC1D,CAAC;aACL,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAqF,CAAA","sourcesContent":["import { defineComponent, h, type HTMLAttributes, type PropType } from \"vue\"\nimport { ProgressIndicator, ProgressRoot } from \"reka-ui\"\nimport s from \"@plexui/styles/components/Progress/Progress.module.css\"\n\n// Vue port of packages/ui/src/components/Progress/Progress.tsx on Reka UI's\n// Progress. Radix and Reka differ in three places, smoothed over here so the\n// DOM matches React:\n// - Radix announces the percentage as `aria-valuetext` (via `getValueLabel`),\n// Reka as `aria-label`. Reka's label is turned off and its value text set.\n// - Radix falls back to `max = 100` for an invalid max and to an\n// indeterminate value for an invalid value. Reka keeps them and asks the\n// parent to correct them, so the same fallbacks are applied before Reka.\n// - Caller attributes still win over Reka's, as `{...restProps}` does in React.\n\nconst DEFAULT_MAX = 100\n\nconst isNumber = (value: unknown): value is number => typeof value === \"number\"\nconst isValidMax = (max: unknown): max is number => isNumber(max) && !Number.isNaN(max) && max > 0\nconst isValidValue = (value: unknown, max: number): value is number =>\n isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0\n\nconst defaultGetValueLabel = (value: number, max: number) => `${Math.round((value / max) * 100)}%`\n\nconst ProgressComponent = defineComponent({\n name: \"Progress\",\n props: {\n /**\n * Current progress value, between `0` and `max`.\n * Omit (or pass `null`) for an indeterminate state.\n */\n value: { type: Number as PropType<number | null>, default: null },\n /** Maximum value. @default 100 */\n max: { type: Number, default: DEFAULT_MAX },\n /** Accessible value text for the current value. @default \"<percentage>%\" */\n getValueLabel: Function as PropType<(value: number, max: number) => string>,\n },\n setup(props) {\n const getValueText = (value: number | null | undefined, max: number) =>\n isNumber(value) ? (props.getValueLabel ?? defaultGetValueLabel)(value, max) : undefined\n\n return () => {\n const { value, max } = props\n const resolved = value == null ? null : Math.max(0, Math.min(max, value))\n const percentage = resolved == null ? null : (resolved / max) * 100\n\n // What Radix renders for the props React hands it\n const rootMax = isValidMax(max) ? max : DEFAULT_MAX\n const rootValue = isValidValue(resolved, rootMax) ? resolved : null\n\n return h(\n ProgressRoot,\n {\n modelValue: rootValue,\n max: rootMax,\n getValueLabel: () => undefined,\n getValueText,\n class: s.Root,\n },\n {\n default: () =>\n h(ProgressIndicator, {\n \"class\": s.Indicator,\n \"style\": percentage == null ? undefined : { transform: `translateX(-${100 - percentage}%)` },\n \"data-indeterminate\": percentage == null ? \"\" : undefined,\n }),\n },\n )\n }\n },\n})\n\ntype ProgressOwnProps = InstanceType<typeof ProgressComponent>[\"$props\"]\n\n/** Progress props plus the native <div> attributes that fall through to the root, as in React. */\nexport type ProgressProps = ProgressOwnProps & Omit<HTMLAttributes, keyof ProgressOwnProps>\n\nexport const Progress = ProgressComponent as typeof ProgressComponent & { new (): { $props: ProgressProps } }\n"]}
|
|
1
|
+
{"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../../src/components/Progress/Progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe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} from \"vue\"\nimport { ProgressIndicator, ProgressRoot } from \"reka-ui\"\nimport s from \"@plexui/styles/components/Progress/Progress.module.css\"\n\n// Vue port of packages/ui/src/components/Progress/Progress.tsx on Reka UI's\n// Progress. Radix and Reka differ in three places, smoothed over here so the\n// DOM matches React:\n// - Radix announces the percentage as `aria-valuetext` (via `getValueLabel`),\n// Reka as `aria-label`. Reka's label is turned off and its value text set.\n// - Radix falls back to `max = 100` for an invalid max and to an\n// indeterminate value for an invalid value. Reka keeps them and asks the\n// parent to correct them, so the same fallbacks are applied before Reka.\n// - Caller attributes still win over Reka's, as `{...restProps}` does in React.\n\nconst DEFAULT_MAX = 100\n\nconst isNumber = (value: unknown): value is number => typeof value === \"number\"\nconst isValidMax = (max: unknown): max is number => isNumber(max) && !Number.isNaN(max) && max > 0\nconst isValidValue = (value: unknown, max: number): value is number =>\n isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0\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\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\nconst defaultGetValueLabel = (value: number, max: number) => `${Math.round((value / max) * 100)}%`\n\nconst ProgressComponent = defineComponent({\n name: \"Progress\",\n props: {\n /**\n * Current progress value, between `0` and `max`.\n * Omit (or pass `null`) for an indeterminate state.\n */\n value: { type: Number as PropType<number | null>, default: null },\n /** Maximum value. @default 100 */\n max: { type: Number, default: DEFAULT_MAX },\n /** Accessible value text for the current value. @default \"<percentage>%\" */\n getValueLabel: Function as PropType<(value: number, max: number) => string>,\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: { type: Array as PropType<ProgressSegment[]>, default: undefined },\n },\n setup(props) {\n const getValueText = (value: number | null | undefined, max: number) =>\n isNumber(value) ? (props.getValueLabel ?? defaultGetValueLabel)(value, max) : undefined\n\n return () => {\n if (props.segments) {\n const rootMax = isValidMax(props.max) ? props.max : DEFAULT_MAX\n const { parts, total } = progressSegments(props.segments, rootMax)\n return h(\n ProgressRoot,\n {\n \"modelValue\": total,\n \"max\": rootMax,\n \"getValueLabel\": () => undefined,\n \"getValueText\": (current: number | null | undefined, currentMax: number) =>\n props.getValueLabel && isNumber(current) ? props.getValueLabel(current, currentMax) : segmentsLabel(parts, rootMax),\n \"class\": s.Root,\n \"data-segmented\": \"\",\n },\n {\n default: () => parts.map((part, index) =>\n part.value > 0\n ? h(\"div\", { \"key\": index, \"class\": s.Segment, \"data-color\": part.color ?? \"primary\", \"style\": { width: `${(part.value / rootMax) * 100}%` } })\n : null),\n },\n )\n }\n const { value, max } = props\n const resolved = value == null ? null : Math.max(0, Math.min(max, value))\n const percentage = resolved == null ? null : (resolved / max) * 100\n\n // What Radix renders for the props React hands it\n const rootMax = isValidMax(max) ? max : DEFAULT_MAX\n const rootValue = isValidValue(resolved, rootMax) ? resolved : null\n\n return h(\n ProgressRoot,\n {\n modelValue: rootValue,\n max: rootMax,\n getValueLabel: () => undefined,\n getValueText,\n class: s.Root,\n },\n {\n default: () =>\n h(ProgressIndicator, {\n \"class\": s.Indicator,\n \"style\": percentage == null ? undefined : { transform: `translateX(-${100 - percentage}%)` },\n \"data-indeterminate\": percentage == null ? \"\" : undefined,\n }),\n },\n )\n }\n },\n})\n\ntype ProgressOwnProps = InstanceType<typeof ProgressComponent>[\"$props\"]\n\n/** Progress props plus the native <div> attributes that fall through to the root, as in React. */\nexport type ProgressProps = ProgressOwnProps & Omit<HTMLAttributes, keyof ProgressOwnProps>\n\nexport const Progress = ProgressComponent as typeof ProgressComponent & { new (): { $props: ProgressProps } }\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.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Progress/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAgE,MAAM,eAAe,CAAA","sourcesContent":["export { Progress, progressSegments, type ProgressColor, type ProgressProps, type ProgressSegment } from \"./Progress.js\"\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
import s from "@plexui/styles/components/RollingNumber/RollingNumber.module.css";
|
|
3
|
+
// Vue port of packages/ui/src/components/RollingNumber/RollingNumber.tsx: the same DOM, attributes fall through to
|
|
4
|
+
// the root <span>.
|
|
5
|
+
/** A written number's characters, each keyed by its place around the decimal separator, so a digit keeps its reel
|
|
6
|
+
* when the number grows or its fraction gets longer; digits are the locale's own (Arabic-Indic, Bengali…). */
|
|
7
|
+
export const rollingNumberParts = (value, locales = "en-US", format) => {
|
|
8
|
+
const formatter = new Intl.NumberFormat(locales, format);
|
|
9
|
+
const { locale, numberingSystem } = formatter.resolvedOptions();
|
|
10
|
+
const digitFormatter = new Intl.NumberFormat(locale, { numberingSystem, useGrouping: false });
|
|
11
|
+
const glyphs = Array.from({ length: 10 }, (_, digit) => digitFormatter.format(digit));
|
|
12
|
+
const parts = formatter.formatToParts(value);
|
|
13
|
+
let integers = parts.reduce((count, part) => count + (part.type === "integer" ? Array.from(part.value).length : 0), 0);
|
|
14
|
+
let fractions = 0;
|
|
15
|
+
const seen = {};
|
|
16
|
+
const characters = parts.flatMap((part) => Array.from(part.value).map((character) => {
|
|
17
|
+
const glyph = glyphs.indexOf(character);
|
|
18
|
+
const digit = (part.type === "integer" || part.type === "fraction") && glyph >= 0 ? glyph : null;
|
|
19
|
+
let key;
|
|
20
|
+
if (part.type === "integer")
|
|
21
|
+
key = `i${integers--}`;
|
|
22
|
+
else if (part.type === "fraction")
|
|
23
|
+
key = `f${++fractions}`;
|
|
24
|
+
else if (part.type === "group")
|
|
25
|
+
key = `g${integers}`;
|
|
26
|
+
else {
|
|
27
|
+
seen[part.type] = (seen[part.type] ?? 0) + 1;
|
|
28
|
+
key = `${part.type}${seen[part.type]}-${character}`;
|
|
29
|
+
}
|
|
30
|
+
return { character, digit, key };
|
|
31
|
+
}));
|
|
32
|
+
return { text: parts.map((part) => part.value).join(""), glyphs, characters };
|
|
33
|
+
};
|
|
34
|
+
const RollingNumberComponent = defineComponent({
|
|
35
|
+
name: "RollingNumber",
|
|
36
|
+
props: {
|
|
37
|
+
/** The number shown. A new value rolls each changed digit to it. */
|
|
38
|
+
value: { type: Number, required: true },
|
|
39
|
+
/** 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" */
|
|
40
|
+
locales: { type: [String, Array], default: undefined },
|
|
41
|
+
/** How the number is written: currency, percent, fraction digits, grouping, as `Intl.NumberFormat` takes it. */
|
|
42
|
+
format: { type: Object, default: undefined },
|
|
43
|
+
},
|
|
44
|
+
setup(props) {
|
|
45
|
+
return () => {
|
|
46
|
+
const { text, glyphs, characters } = rollingNumberParts(props.value, props.locales, props.format);
|
|
47
|
+
return h("span", { class: s.RollingNumber }, [
|
|
48
|
+
h("span", { class: s.Text }, text),
|
|
49
|
+
h("span", { "class": s.Visual, "aria-hidden": "true" }, characters.map(({ character, digit, key }) => digit === null
|
|
50
|
+
? h("span", { key }, character)
|
|
51
|
+
: h("span", { "key": key, "class": s.Digit, "data-digit": digit }, [
|
|
52
|
+
h("span", { class: s.Ghost }, character),
|
|
53
|
+
h("span", { class: s.Reel, style: { "--rolling-number-digit": digit } }, glyphs.map((reelDigit) => h("span", { key: reelDigit }, reelDigit))),
|
|
54
|
+
]))),
|
|
55
|
+
]);
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* A number whose digits roll to a new value, as an odometer: for a total, a balance, a count or a KPI that changes
|
|
61
|
+
* while it is watched. It reads as the written number; its reels are hidden from a screen reader.
|
|
62
|
+
*/
|
|
63
|
+
export const RollingNumber = RollingNumberComponent;
|
|
64
|
+
//# sourceMappingURL=RollingNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RollingNumber.js","sourceRoot":"","sources":["../../../../src/components/RollingNumber/RollingNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAsC,MAAM,KAAK,CAAA;AAC5E,OAAO,CAAC,MAAM,kEAAkE,CAAA;AAEhF,mHAAmH;AACnH,mBAAmB;AAEnB;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,IA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AC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC;gBAClC,CAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CACnG,KAAK,KAAK,IAAI;oBACZ,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,SAAS,CAAC;oBAC/B,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE;wBACjE,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC;wBACxC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,wBAAwB,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;qBAC9I,CAAC,CACL,CAAC;aACH,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,sBAAoG,CAAA","sourcesContent":["import { defineComponent, h, type HTMLAttributes, type PropType } from \"vue\"\nimport s from \"@plexui/styles/components/RollingNumber/RollingNumber.module.css\"\n\n// Vue port of packages/ui/src/components/RollingNumber/RollingNumber.tsx: the same DOM, attributes fall through to\n// the root <span>.\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\nconst RollingNumberComponent = defineComponent({\n name: \"RollingNumber\",\n props: {\n /** The number shown. A new value rolls each changed digit to it. */\n value: { type: Number, required: true },\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: { type: [String, Array] as PropType<Intl.LocalesArgument>, default: undefined },\n /** How the number is written: currency, percent, fraction digits, grouping, as `Intl.NumberFormat` takes it. */\n format: { type: Object as PropType<Intl.NumberFormatOptions>, default: undefined },\n },\n setup(props) {\n return () => {\n const { text, glyphs, characters } = rollingNumberParts(props.value, props.locales, props.format)\n return h(\"span\", { class: s.RollingNumber }, [\n h(\"span\", { class: s.Text }, text),\n h(\"span\", { \"class\": s.Visual, \"aria-hidden\": \"true\" }, characters.map(({ character, digit, key }) =>\n digit === null\n ? h(\"span\", { key }, character)\n : h(\"span\", { \"key\": key, \"class\": s.Digit, \"data-digit\": digit }, [\n h(\"span\", { class: s.Ghost }, character),\n h(\"span\", { class: s.Reel, style: { \"--rolling-number-digit\": digit } }, glyphs.map((reelDigit) => h(\"span\", { key: reelDigit }, reelDigit))),\n ]),\n )),\n ])\n }\n },\n})\n\ntype RollingNumberOwnProps = InstanceType<typeof RollingNumberComponent>[\"$props\"]\n\n/** RollingNumber props plus the native attributes that fall through to the root <span>. */\nexport type RollingNumberProps = RollingNumberOwnProps & Omit<HTMLAttributes, keyof RollingNumberOwnProps>\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 = RollingNumberComponent as typeof RollingNumberComponent & { new (): { $props: RollingNumberProps } }\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/RollingNumber/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAA2B,MAAM,oBAAoB,CAAA","sourcesContent":["export { RollingNumber, rollingNumberParts, type RollingNumberProps } from \"./RollingNumber.js\"\n"]}
|
|
@@ -48,6 +48,11 @@ const selectProps = {
|
|
|
48
48
|
variant: { type: String, default: "outline" },
|
|
49
49
|
/** Fully rounded pill shape for the trigger. @default false, or true at the end of a `Field row` */
|
|
50
50
|
pill: { type: Boolean, default: undefined },
|
|
51
|
+
/**
|
|
52
|
+
* The list in the rounder shape of a pill menu (as `MenuContent pill`), whatever the trigger: a `#trigger` of its own or
|
|
53
|
+
* a rounded field can open the same list as a pill one. @default the trigger's `pill`
|
|
54
|
+
*/
|
|
55
|
+
listPill: { type: Boolean, default: undefined },
|
|
51
56
|
/** Size of the trigger: `3xs` 22px up to `3xl` 48px. @default "md" */
|
|
52
57
|
size: { type: String, default: "md" },
|
|
53
58
|
/** Icon displayed in the far right of the select trigger. @default "dropdown" */
|
|
@@ -153,6 +158,7 @@ const SelectComponent = defineComponent({
|
|
|
153
158
|
setup(rawProps, { emit, slots }) {
|
|
154
159
|
const props = rawProps;
|
|
155
160
|
const pill = useFieldRowPill(() => props.pill);
|
|
161
|
+
const listPill = computed(() => props.listPill ?? pill.value);
|
|
156
162
|
// At the end of a Field row the menu opens from the row's end and fits its options: on a phone
|
|
157
163
|
// the trigger there is only as wide as its value, so a menu of the trigger's width breaks every word.
|
|
158
164
|
// In a `FieldGroup columns` the value starts at the column, and so does its menu.
|
|
@@ -239,6 +245,7 @@ const SelectComponent = defineComponent({
|
|
|
239
245
|
triggerEl: shallowRef(null),
|
|
240
246
|
block,
|
|
241
247
|
pill,
|
|
248
|
+
listPill,
|
|
242
249
|
align,
|
|
243
250
|
alignOffset,
|
|
244
251
|
listWidth,
|
|
@@ -589,7 +596,7 @@ const SelectContentElement = markRaw(defineComponent({
|
|
|
589
596
|
const SelectPopoverContent = defineComponent({
|
|
590
597
|
name: "SelectPopoverContent",
|
|
591
598
|
setup() {
|
|
592
|
-
const { props, align, alignOffset, listWidth, listMaxWidth,
|
|
599
|
+
const { props, align, alignOffset, listWidth, listMaxWidth, listPill } = useSelectContext();
|
|
593
600
|
const { handleRootOpenChange, popoverTriggerEl, open, selectContentRef } = inject(CustomSelectContextKey);
|
|
594
601
|
const floatingBoundary = useFloatingBoundary(() => open.value && props.avoidCollisions, { bottom: 30, top: 30 });
|
|
595
602
|
// On a phone the list opens over its trigger, as the pop-up menu of an iOS picker does (ref-app pickers, block 8:
|
|
@@ -622,7 +629,7 @@ const SelectPopoverContent = defineComponent({
|
|
|
622
629
|
forceMount: true,
|
|
623
630
|
as: SelectContentElement,
|
|
624
631
|
class: s.MenuList,
|
|
625
|
-
"data-pill":
|
|
632
|
+
"data-pill": listPill.value ? "" : undefined,
|
|
626
633
|
// A list that fits its options is the 250pt of an iOS menu on a phone (Select.module.css)
|
|
627
634
|
"data-list-width": listWidth.value === "auto" ? "auto" : undefined,
|
|
628
635
|
// A list given its own width keeps it on a phone too, below the 250pt
|