@krizaka/ui 3.67.0 → 3.68.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/app-header.d.ts +3 -3
- package/dist/app-shell.js +2 -2
- package/dist/app-shell.js.map +1 -1
- package/dist/chunk-PZ4FJOD5.js +44 -0
- package/dist/chunk-PZ4FJOD5.js.map +1 -0
- package/dist/{chunk-6BMKLAZ7.js → chunk-Z47KIPCT.js} +7 -2
- package/dist/{chunk-6BMKLAZ7.js.map → chunk-Z47KIPCT.js.map} +1 -1
- package/dist/copy-button.d.ts +29 -0
- package/dist/copy-button.js +56 -0
- package/dist/copy-button.js.map +1 -0
- package/dist/date-picker.js +2 -1
- package/dist/date-picker.js.map +1 -1
- package/dist/desktop-window.js.map +1 -1
- package/dist/file-upload.d.ts +2 -2
- package/dist/filter-bar.d.ts +3 -3
- package/dist/flock.js +2 -1
- package/dist/flock.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/kind-config-editor.js +106 -129
- package/dist/kind-config-editor.js.map +1 -1
- package/dist/map.d.ts +2 -2
- package/dist/map.js +3 -3
- package/dist/map.js.map +1 -1
- package/dist/money-input.d.ts +29 -0
- package/dist/money-input.js +78 -0
- package/dist/money-input.js.map +1 -0
- package/dist/native/map.d.ts +2 -2
- package/dist/native/map.js +3 -3
- package/dist/native/map.js.map +1 -1
- package/dist/nav-bar.d.ts +28 -4
- package/dist/nav-bar.js +31 -14
- package/dist/nav-bar.js.map +1 -1
- package/dist/promo-code-field.d.ts +38 -0
- package/dist/promo-code-field.js +94 -0
- package/dist/promo-code-field.js.map +1 -0
- package/dist/radio-group.js +1 -1
- package/dist/retro-tv.d.ts +39 -4
- package/dist/retro-tv.js +217 -40
- package/dist/retro-tv.js.map +1 -1
- package/dist/status-chip.js +1 -1
- package/dist/terminal-replay.js +1 -1
- package/package.json +46 -3
- package/registry/account-menu.json +1 -1
- package/registry/account-settings.json +1 -1
- package/registry/achievement.json +1 -1
- package/registry/action-bar.json +1 -1
- package/registry/activity-feed.json +1 -1
- package/registry/agenda.json +1 -1
- package/registry/alert.json +1 -1
- package/registry/analysis-report.json +1 -1
- package/registry/anatomy-plate.json +1 -1
- package/registry/app-frame.json +34 -34
- package/registry/app-header.json +1 -1
- package/registry/app-shell.json +3 -3
- package/registry/argument-card.json +1 -1
- package/registry/audio-player.json +1 -1
- package/registry/auth-layout.json +1 -1
- package/registry/avatar.json +1 -1
- package/registry/badge.json +1 -1
- package/registry/bird-plate.json +1 -1
- package/registry/button.json +1 -1
- package/registry/captcha.json +1 -1
- package/registry/card-grid.json +1 -1
- package/registry/card.json +1 -1
- package/registry/catalogue-page.json +1 -1
- package/registry/changelog-page.json +1 -1
- package/registry/chapter.json +1 -1
- package/registry/chat.json +1 -1
- package/registry/checkbox.json +1 -1
- package/registry/chip-link.json +1 -1
- package/registry/chip-row.json +1 -1
- package/registry/chip.json +1 -1
- package/registry/choice-grid.json +1 -1
- package/registry/code-block.json +1 -1
- package/registry/collection-switcher.json +1 -1
- package/registry/combobox.json +1 -1
- package/registry/command.json +1 -1
- package/registry/comparison-table.json +1 -1
- package/registry/component-page.json +1 -1
- package/registry/confirm-button.json +1 -1
- package/registry/contact-page.json +1 -1
- package/registry/continue-prompt.json +1 -1
- package/registry/copy-button.json +382 -0
- package/registry/countdown.json +1 -1
- package/registry/cover-hero.json +1 -1
- package/registry/cta-panel.json +1 -1
- package/registry/dashboard-layout.json +1 -1
- package/registry/data-table.json +1 -1
- package/registry/date-picker.json +3 -3
- package/registry/decision-list.json +1 -1
- package/registry/description-list.json +1 -1
- package/registry/desktop-window.json +1 -1
- package/registry/detail-layout.json +1 -1
- package/registry/dialog.json +1 -1
- package/registry/docs-article-page.json +1 -1
- package/registry/docs-hub-page.json +1 -1
- package/registry/docs-layout.json +1 -1
- package/registry/docs-nav.json +1 -1
- package/registry/document-viewer.json +1 -1
- package/registry/doodle.json +1 -1
- package/registry/drop-overlay.json +1 -1
- package/registry/dropdown-menu.json +1 -1
- package/registry/elephant.json +2 -2
- package/registry/embed-facade.json +1 -1
- package/registry/empty-state.json +1 -1
- package/registry/engine-flow.json +1 -1
- package/registry/entity-header.json +1 -1
- package/registry/environment-notice.json +1 -1
- package/registry/error-page.json +1 -1
- package/registry/examples/copy-button/default.d.ts +4 -0
- package/registry/examples/copy-button/default.js +11 -0
- package/registry/examples/copy-button/default.tsx +7 -0
- package/registry/examples/copy-button/icon-only.d.ts +4 -0
- package/registry/examples/copy-button/icon-only.js +11 -0
- package/registry/examples/copy-button/icon-only.tsx +7 -0
- package/registry/examples/money-input/currencies.d.ts +4 -0
- package/registry/examples/money-input/currencies.js +18 -0
- package/registry/examples/money-input/currencies.tsx +16 -0
- package/registry/examples/money-input/default.d.ts +4 -0
- package/registry/examples/money-input/default.js +18 -0
- package/registry/examples/money-input/default.tsx +16 -0
- package/registry/examples/promo-code-field/applied.d.ts +4 -0
- package/registry/examples/promo-code-field/applied.js +11 -0
- package/registry/examples/promo-code-field/applied.tsx +7 -0
- package/registry/examples/promo-code-field/default.d.ts +4 -0
- package/registry/examples/promo-code-field/default.js +19 -0
- package/registry/examples/promo-code-field/default.tsx +14 -0
- package/registry/examples/promo-code-field/expired.d.ts +4 -0
- package/registry/examples/promo-code-field/expired.js +11 -0
- package/registry/examples/promo-code-field/expired.tsx +7 -0
- package/registry/examples/retro-tv/playlist-channel.d.ts +4 -0
- package/registry/examples/retro-tv/playlist-channel.js +15 -0
- package/registry/examples/retro-tv/playlist-channel.tsx +10 -0
- package/registry/examples/retro-tv/playlist-crossfade.d.ts +4 -0
- package/registry/examples/retro-tv/playlist-crossfade.js +15 -0
- package/registry/examples/retro-tv/playlist-crossfade.tsx +10 -0
- package/registry/examples/retro-tv/playlist-slide.d.ts +4 -0
- package/registry/examples/retro-tv/playlist-slide.js +15 -0
- package/registry/examples/retro-tv/playlist-slide.tsx +10 -0
- package/registry/field.json +1 -1
- package/registry/file-upload.json +1 -1
- package/registry/filter-bar.json +1 -1
- package/registry/flock.json +2 -2
- package/registry/footnote.json +1 -1
- package/registry/force-update-screen.json +1 -1
- package/registry/form.json +1 -1
- package/registry/gallery-page.json +1 -1
- package/registry/genui.json +1 -1
- package/registry/glossary-term.json +1 -1
- package/registry/glossary.json +1 -1
- package/registry/glow-card.json +1 -1
- package/registry/goal-gauge.json +1 -1
- package/registry/grade-stamp.json +1 -1
- package/registry/how-it-works-page.json +1 -1
- package/registry/image-cropper.json +1 -1
- package/registry/index.json +108 -9
- package/registry/iso.json +1 -1
- package/registry/kanban.json +1 -1
- package/registry/kbd.json +1 -1
- package/registry/kind-config-editor.json +1 -1
- package/registry/kpi-explained.json +1 -1
- package/registry/landing-page.json +1 -1
- package/registry/landscape.json +1 -1
- package/registry/language-switch.json +1 -1
- package/registry/legal-page.json +1 -1
- package/registry/link-card.json +1 -1
- package/registry/list.json +1 -1
- package/registry/loader.json +1 -1
- package/registry/longform-page.json +1 -1
- package/registry/maintenance-screen.json +1 -1
- package/registry/map.json +95 -95
- package/registry/margin-layout.json +1 -1
- package/registry/markdown.json +1 -1
- package/registry/marketing-layout.json +1 -1
- package/registry/marquee.json +1 -1
- package/registry/mascot-quote.json +1 -1
- package/registry/mascot-state.json +1 -1
- package/registry/mascots.json +1 -1
- package/registry/match-dialog.json +1 -1
- package/registry/media-capture.json +1 -1
- package/registry/media-gallery.json +1 -1
- package/registry/media-grid.json +1 -1
- package/registry/meta-row.json +1 -1
- package/registry/meter.json +1 -1
- package/registry/money-input.json +236 -0
- package/registry/nav-bar.json +55 -41
- package/registry/next-actions.json +1 -1
- package/registry/notification-preferences.json +1 -1
- package/registry/number-ticker.json +1 -1
- package/registry/opening-hours.json +1 -1
- package/registry/page-header.json +1 -1
- package/registry/page-hero.json +1 -1
- package/registry/page-index.json +1 -1
- package/registry/page.json +1 -1
- package/registry/pagination.json +1 -1
- package/registry/photo-grid.json +1 -1
- package/registry/pointer-light.json +1 -1
- package/registry/popover.json +1 -1
- package/registry/pricing-page.json +1 -1
- package/registry/product-page.json +1 -1
- package/registry/profile-card.json +1 -1
- package/registry/progress.json +1 -1
- package/registry/promise-card.json +1 -1
- package/registry/promo-code-field.json +258 -0
- package/registry/qr-code.json +1 -1
- package/registry/quota-meter.json +1 -1
- package/registry/radio-group.json +1 -1
- package/registry/rail-nav.json +34 -34
- package/registry/recipes.json +1 -1
- package/registry/retro-tv.json +120 -8
- package/registry/reviews.json +1 -1
- package/registry/router.json +1 -1
- package/registry/scroll-stage.json +1 -1
- package/registry/search-field.json +1 -1
- package/registry/section-backdrop.json +1 -1
- package/registry/separator.json +1 -1
- package/registry/service-card.json +1 -1
- package/registry/settings-layout.json +1 -1
- package/registry/shop-composer.json +1 -1
- package/registry/shop.json +2 -2
- package/registry/showcase.json +1 -1
- package/registry/signature.json +1 -1
- package/registry/site-cahier.json +1 -1
- package/registry/site-footer.json +34 -34
- package/registry/sites.json +1 -1
- package/registry/skeleton.json +1 -1
- package/registry/skip-link.json +1 -1
- package/registry/slider.json +1 -1
- package/registry/slot-picker.json +1 -1
- package/registry/slot.json +1 -1
- package/registry/specimen-tag.json +1 -1
- package/registry/speed-lines.json +1 -1
- package/registry/spinner.json +1 -1
- package/registry/split-view.json +1 -1
- package/registry/stage-banner.json +1 -1
- package/registry/stat.json +1 -1
- package/registry/status-chip.json +1 -1
- package/registry/status-page.json +1 -1
- package/registry/step-progress.json +1 -1
- package/registry/step-showcase.json +1 -1
- package/registry/stepper.json +1 -1
- package/registry/sticky-action.json +1 -1
- package/registry/stuck.json +1 -1
- package/registry/swipe-deck.json +1 -1
- package/registry/switch.json +1 -1
- package/registry/tabs.json +1 -1
- package/registry/tag-input.json +1 -1
- package/registry/tag-selector.json +1 -1
- package/registry/taped-photo.json +1 -1
- package/registry/terminal-replay.json +1 -1
- package/registry/text-style.json +1 -1
- package/registry/theme.json +1 -1
- package/registry/toast.json +1 -1
- package/registry/toc.json +1 -1
- package/registry/tooltip.json +1 -1
- package/registry/tree-view.json +1 -1
- package/registry/update-prompt.json +1 -1
- package/registry/upload-queue.json +1 -1
- package/registry/usage.json +1 -1
- package/registry/verified-badge.json +1 -1
- package/registry/versus-card.json +1 -1
- package/registry/vertical-video.json +1 -1
- package/registry/video-player.json +1 -1
- package/registry/video-trimmer.json +1 -1
- package/registry/virtual.json +1 -1
- package/registry/wall.json +1 -1
- package/registry/waveform.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type MoneyInputProps = Omit<React.ComponentProps<"input">, "value" | "defaultValue" | "onChange" | "type" | "inputMode"> & {
|
|
4
|
+
/** The amount in minor units (cents), an integer, or `null` when empty. */
|
|
5
|
+
value: number | null;
|
|
6
|
+
/** Called with the new amount in minor units, or `null` when the field is emptied. */
|
|
7
|
+
onValueChange: (minorUnits: number | null) => void;
|
|
8
|
+
/** ISO 4217 code: `"CAD"`. */
|
|
9
|
+
currency: string;
|
|
10
|
+
/** BCP 47 locale for the separators: `"fr-CA"`, `"en-CA"`. */
|
|
11
|
+
locale: string;
|
|
12
|
+
/** The currencies to choose among (ISO codes). Omitted: the currency is fixed. */
|
|
13
|
+
currencies?: readonly string[];
|
|
14
|
+
/** Called with the chosen currency (required with `currencies`). */
|
|
15
|
+
onCurrencyChange?: (currency: string) => void;
|
|
16
|
+
/** The currency select's accessible name, passed translated: "Currency". */
|
|
17
|
+
currencyLabel?: string;
|
|
18
|
+
/** Marks the amount invalid (pair it with a `Field.Error`). */
|
|
19
|
+
invalid?: boolean;
|
|
20
|
+
};
|
|
21
|
+
/** "12,50" → 1250 without a float; `undefined` when the text is not an amount or has too many decimals. */
|
|
22
|
+
declare function parseMinorUnits(text: string, locale: string, digits: number): number | null | undefined;
|
|
23
|
+
/** Minor units → "1 234,50" in the locale, exact (BigInt), padded to the currency's decimals. */
|
|
24
|
+
declare function formatMinorUnits(minor: number, locale: string, digits: number): string;
|
|
25
|
+
/** An amount field in minor units. The caller holds an integer; the person sees their locale's decimal. */
|
|
26
|
+
declare function MoneyInput({ value, onValueChange, currency, locale, currencies, onCurrencyChange, currencyLabel, invalid, className, onBlur, disabled, ...props }: MoneyInputProps): React.JSX.Element;
|
|
27
|
+
|
|
28
|
+
export { MoneyInput, formatMinorUnits, parseMinorUnits };
|
|
29
|
+
export type { MoneyInputProps };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Input,
|
|
4
|
+
Select
|
|
5
|
+
} from "./chunk-PZ4FJOD5.js";
|
|
6
|
+
import {
|
|
7
|
+
cn
|
|
8
|
+
} from "./chunk-NSLXEDIS.js";
|
|
9
|
+
|
|
10
|
+
// src/money-input/money-input.tsx
|
|
11
|
+
import { currencyDigits } from "@krizaka/intl";
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
var separators = (locale) => {
|
|
15
|
+
const parts = new Intl.NumberFormat(locale, { useGrouping: true, minimumFractionDigits: 1 }).formatToParts(12345671e-1);
|
|
16
|
+
return { decimal: parts.find((p) => p.type === "decimal")?.value ?? ".", group: parts.find((p) => p.type === "group")?.value ?? "," };
|
|
17
|
+
};
|
|
18
|
+
function parseMinorUnits(text, locale, digits) {
|
|
19
|
+
const { decimal } = separators(locale);
|
|
20
|
+
const cleaned = text.replace(/\s/g, "");
|
|
21
|
+
if (cleaned === "") return null;
|
|
22
|
+
const marks = [...cleaned].filter((c) => c === "." || c === "," || c === decimal);
|
|
23
|
+
if (!/^[\d.,]+$/.test(cleaned.replaceAll(decimal, ""))) return void 0;
|
|
24
|
+
const last = marks.length ? Math.max(cleaned.lastIndexOf("."), cleaned.lastIndexOf(","), cleaned.lastIndexOf(decimal)) : -1;
|
|
25
|
+
const whole = (last >= 0 ? cleaned.slice(0, last) : cleaned).replace(/\D/g, "");
|
|
26
|
+
const fraction = last >= 0 ? cleaned.slice(last + 1) : "";
|
|
27
|
+
if (!/^\d*$/.test(fraction) || fraction.length > digits || digits === 0 && last >= 0) return void 0;
|
|
28
|
+
const minor = Number(`${whole || "0"}${fraction.padEnd(digits, "0")}`);
|
|
29
|
+
return Number.isSafeInteger(minor) ? minor : void 0;
|
|
30
|
+
}
|
|
31
|
+
function formatMinorUnits(minor, locale, digits) {
|
|
32
|
+
const { decimal } = separators(locale);
|
|
33
|
+
const abs = BigInt(Math.abs(minor)).toString().padStart(digits + 1, "0");
|
|
34
|
+
const whole = new Intl.NumberFormat(locale).format(BigInt(digits ? abs.slice(0, -digits) : abs));
|
|
35
|
+
return `${minor < 0 ? "-" : ""}${whole}${digits ? decimal + abs.slice(-digits) : ""}`;
|
|
36
|
+
}
|
|
37
|
+
function MoneyInput({ value, onValueChange, currency, locale, currencies, onCurrencyChange, currencyLabel, invalid, className, onBlur, disabled, ...props }) {
|
|
38
|
+
const digits = currencyDigits(currency);
|
|
39
|
+
const [text, setText] = React.useState(() => value === null ? "" : formatMinorUnits(value, locale, digits));
|
|
40
|
+
const typed = React.useRef(value);
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
if (typed.current !== value) setText(value === null ? "" : formatMinorUnits(value, locale, digits));
|
|
43
|
+
typed.current = value;
|
|
44
|
+
}, [value, locale, digits]);
|
|
45
|
+
return /* @__PURE__ */ jsxs("span", { className: cn("flex w-full items-stretch gap-2", className), children: [
|
|
46
|
+
/* @__PURE__ */ jsx(
|
|
47
|
+
Input,
|
|
48
|
+
{
|
|
49
|
+
...props,
|
|
50
|
+
type: "text",
|
|
51
|
+
inputMode: digits ? "decimal" : "numeric",
|
|
52
|
+
autoComplete: "off",
|
|
53
|
+
disabled,
|
|
54
|
+
invalid,
|
|
55
|
+
"data-currency": currency,
|
|
56
|
+
value: text,
|
|
57
|
+
onChange: (event) => {
|
|
58
|
+
const parsed = parseMinorUnits(event.target.value, locale, digits);
|
|
59
|
+
if (parsed === void 0) return;
|
|
60
|
+
setText(event.target.value);
|
|
61
|
+
typed.current = parsed;
|
|
62
|
+
onValueChange(parsed);
|
|
63
|
+
},
|
|
64
|
+
onBlur: (event) => {
|
|
65
|
+
onBlur?.(event);
|
|
66
|
+
if (value !== null) setText(formatMinorUnits(value, locale, digits));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
currencies ? /* @__PURE__ */ jsx(Select, { "aria-label": currencyLabel, disabled, value: currency, onChange: (event) => onCurrencyChange?.(event.target.value), className: "w-28", children: currencies.map((code) => /* @__PURE__ */ jsx("option", { value: code, children: code }, code)) }) : /* @__PURE__ */ jsx("span", { className: "flex items-center text-sm font-medium text-fg-secondary", children: currency })
|
|
71
|
+
] });
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
MoneyInput,
|
|
75
|
+
formatMinorUnits,
|
|
76
|
+
parseMinorUnits
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=money-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/money-input/money-input.tsx"],"sourcesContent":["// Client (the text being typed). An amount in INTEGER minor units (cents) plus a currency. The person types a\n// decimal in their locale's way; it is read as a string (never a float) into cents, refused beyond the currency's own\n// decimals, and written back grouped and padded on blur. The currency can be chosen among `currencies` (a native\n// select). Words arrive as props.\nimport { currencyDigits } from \"@krizaka/intl\";\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { Input, Select } from \"../field/field\";\n\nexport type MoneyInputProps = Omit<React.ComponentProps<\"input\">, \"value\" | \"defaultValue\" | \"onChange\" | \"type\" | \"inputMode\"> & {\n /** The amount in minor units (cents), an integer, or `null` when empty. */\n value: number | null;\n /** Called with the new amount in minor units, or `null` when the field is emptied. */\n onValueChange: (minorUnits: number | null) => void;\n /** ISO 4217 code: `\"CAD\"`. */\n currency: string;\n /** BCP 47 locale for the separators: `\"fr-CA\"`, `\"en-CA\"`. */\n locale: string;\n /** The currencies to choose among (ISO codes). Omitted: the currency is fixed. */\n currencies?: readonly string[];\n /** Called with the chosen currency (required with `currencies`). */\n onCurrencyChange?: (currency: string) => void;\n /** The currency select's accessible name, passed translated: \"Currency\". */\n currencyLabel?: string;\n /** Marks the amount invalid (pair it with a `Field.Error`). */\n invalid?: boolean;\n};\n\nconst separators = (locale: string) => {\n const parts = new Intl.NumberFormat(locale, { useGrouping: true, minimumFractionDigits: 1 }).formatToParts(1234567.1);\n return { decimal: parts.find((p) => p.type === \"decimal\")?.value ?? \".\", group: parts.find((p) => p.type === \"group\")?.value ?? \",\" };\n};\n\n/** \"12,50\" → 1250 without a float; `undefined` when the text is not an amount or has too many decimals. */\nexport function parseMinorUnits(text: string, locale: string, digits: number): number | null | undefined {\n const { decimal } = separators(locale);\n const cleaned = text.replace(/\\s/g, \"\");\n if (cleaned === \"\") return null;\n // The locale's decimal mark, and \".\" or \",\" as a typed alternative; any other mark is a thousands separator.\n const marks = [...cleaned].filter((c) => c === \".\" || c === \",\" || c === decimal);\n if (!/^[\\d.,]+$/.test(cleaned.replaceAll(decimal, \"\"))) return undefined;\n const last = marks.length ? Math.max(cleaned.lastIndexOf(\".\"), cleaned.lastIndexOf(\",\"), cleaned.lastIndexOf(decimal)) : -1;\n const whole = (last >= 0 ? cleaned.slice(0, last) : cleaned).replace(/\\D/g, \"\");\n const fraction = last >= 0 ? cleaned.slice(last + 1) : \"\";\n if (!/^\\d*$/.test(fraction) || fraction.length > digits || (digits === 0 && last >= 0)) return undefined;\n const minor = Number(`${whole || \"0\"}${fraction.padEnd(digits, \"0\")}`);\n return Number.isSafeInteger(minor) ? minor : undefined;\n}\n\n/** Minor units → \"1 234,50\" in the locale, exact (BigInt), padded to the currency's decimals. */\nexport function formatMinorUnits(minor: number, locale: string, digits: number): string {\n const { decimal } = separators(locale);\n const abs = BigInt(Math.abs(minor)).toString().padStart(digits + 1, \"0\");\n const whole = new Intl.NumberFormat(locale).format(BigInt(digits ? abs.slice(0, -digits) : abs));\n return `${minor < 0 ? \"-\" : \"\"}${whole}${digits ? decimal + abs.slice(-digits) : \"\"}`;\n}\n\n/** An amount field in minor units. The caller holds an integer; the person sees their locale's decimal. */\nexport function MoneyInput({ value, onValueChange, currency, locale, currencies, onCurrencyChange, currencyLabel, invalid, className, onBlur, disabled, ...props }: MoneyInputProps) {\n const digits = currencyDigits(currency);\n const [text, setText] = React.useState(() => (value === null ? \"\" : formatMinorUnits(value, locale, digits)));\n const typed = React.useRef<number | null>(value);\n // Follow the caller when the value changes from outside (a reset, another currency's digits).\n React.useEffect(() => {\n if (typed.current !== value) setText(value === null ? \"\" : formatMinorUnits(value, locale, digits));\n typed.current = value;\n }, [value, locale, digits]);\n return (\n <span className={cn(\"flex w-full items-stretch gap-2\", className)}>\n <Input\n {...props}\n type=\"text\"\n inputMode={digits ? \"decimal\" : \"numeric\"}\n autoComplete=\"off\"\n disabled={disabled}\n invalid={invalid}\n data-currency={currency}\n value={text}\n onChange={(event) => {\n const parsed = parseMinorUnits(event.target.value, locale, digits);\n if (parsed === undefined) return; // refused: not an amount, or more decimals than the currency has\n setText(event.target.value);\n typed.current = parsed;\n onValueChange(parsed);\n }}\n onBlur={(event) => {\n onBlur?.(event);\n if (value !== null) setText(formatMinorUnits(value, locale, digits));\n }}\n />\n {currencies ? (\n <Select aria-label={currencyLabel} disabled={disabled} value={currency} onChange={(event) => onCurrencyChange?.(event.target.value)} className=\"w-28\">\n {currencies.map((code) => (\n <option key={code} value={code}>\n {code}\n </option>\n ))}\n </Select>\n ) : (\n <span className=\"flex items-center text-sm font-medium text-fg-secondary\">{currency}</span>\n )}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;AAIA,SAAS,sBAAsB;AAC/B,YAAY,WAAW;AAgEnB,SACE,KADF;AAxCJ,IAAM,aAAa,CAAC,WAAmB;AACrC,QAAM,QAAQ,IAAI,KAAK,aAAa,QAAQ,EAAE,aAAa,MAAM,uBAAuB,EAAE,CAAC,EAAE,cAAc,WAAS;AACpH,SAAO,EAAE,SAAS,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS,GAAG,SAAS,KAAK,OAAO,MAAM,KAAK,CAAC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oBAAC,YAAkB,OAAO,MACvB,kBADU,IAEb,CACD,GACH,IAEA,oBAAC,UAAK,WAAU,2DAA2D,oBAAS;AAAA,KAExF;AAEJ;","names":[]}
|
package/dist/native/map.d.ts
CHANGED
|
@@ -112,7 +112,7 @@ type MapProps = {
|
|
|
112
112
|
style?: StyleProp<ViewStyle>;
|
|
113
113
|
};
|
|
114
114
|
/** A map: MapLibre Native over our Protomaps tiles, styled from the tokens in the app's scheme; its places in its name. */
|
|
115
|
-
declare function
|
|
115
|
+
declare function NativeMap({ label, center, zoom, brand, lang, region, world, interactive, onMoveEnd, onPress, children, style }: MapProps): React.JSX.Element;
|
|
116
116
|
type MarkerProps = {
|
|
117
117
|
/** Where it stands. */
|
|
118
118
|
position: LngLat;
|
|
@@ -197,5 +197,5 @@ type LocationPickerProps = Pick<MapProps, "brand" | "lang" | "region" | "world"
|
|
|
197
197
|
/** A position picked by moving the map under a pin; its distance from the person; "near me" asks for the location only when pressed. */
|
|
198
198
|
declare function LocationPicker({ label, value, onValueChange, locale, zoom, radius: zone, origin: originProp, labels: given, style, ...map }: LocationPickerProps): React.JSX.Element;
|
|
199
199
|
|
|
200
|
-
export { Cluster, LocationPicker, MAP_ATTRIBUTION, MAP_GLYPHS, MAP_TILES, Map, Marker, RadiusCircle, UserPosition, circlePolygon, distanceMeters, formatDistance, mapPalette, mapStyle };
|
|
200
|
+
export { Cluster, LocationPicker, MAP_ATTRIBUTION, MAP_GLYPHS, MAP_TILES, NativeMap as Map, Marker, RadiusCircle, UserPosition, circlePolygon, distanceMeters, formatDistance, mapPalette, mapStyle };
|
|
201
201
|
export type { ClusterPoint, ClusterProps, LngLat, LocationPickerLabels, LocationPickerProps, MapProps, MapRegion, MarkerProps, RadiusCircleProps, UserPositionProps };
|
package/dist/native/map.js
CHANGED
|
@@ -582,7 +582,7 @@ var useMapContext = () => {
|
|
|
582
582
|
if (!ctx) throw new Error("inside a <Map> only");
|
|
583
583
|
return ctx;
|
|
584
584
|
};
|
|
585
|
-
function
|
|
585
|
+
function NativeMap({ label, center, zoom = 12, brand, lang, region, world, interactive = true, onMoveEnd, onPress, children, style }) {
|
|
586
586
|
const { scheme, theme, radius, motion } = useTheme();
|
|
587
587
|
const reduce = motion.duration.base === 0;
|
|
588
588
|
const camera = React.useRef(null);
|
|
@@ -759,7 +759,7 @@ function LocationPicker({ label, value, onValueChange, locale, zoom = 14, radius
|
|
|
759
759
|
const message = status === "locating" ? labels.locating : status === "denied" ? labels.denied : status === "unavailable" ? labels.unavailable : null;
|
|
760
760
|
return /* @__PURE__ */ jsxs(View, { role: "group", "aria-label": label, style: [styles.picker, style], children: [
|
|
761
761
|
/* @__PURE__ */ jsxs(View, { style: styles.pickerFrame, children: [
|
|
762
|
-
/* @__PURE__ */ jsxs(
|
|
762
|
+
/* @__PURE__ */ jsxs(NativeMap, { ...map, label, center: camera, zoom, onMoveEnd: (v) => onValueChange(v.center), style: StyleSheet.absoluteFill, children: [
|
|
763
763
|
zone ? /* @__PURE__ */ jsx(RadiusCircle, { center: value, radius: zone }) : null,
|
|
764
764
|
origin ? /* @__PURE__ */ jsx(UserPosition, { position: origin, label: labels.you }) : null
|
|
765
765
|
] }),
|
|
@@ -798,7 +798,7 @@ export {
|
|
|
798
798
|
MAP_ATTRIBUTION,
|
|
799
799
|
MAP_GLYPHS,
|
|
800
800
|
MAP_TILES,
|
|
801
|
-
Map,
|
|
801
|
+
NativeMap as Map,
|
|
802
802
|
Marker,
|
|
803
803
|
RadiusCircle,
|
|
804
804
|
UserPosition,
|