@ethisyscore/core-utils 1.94.1 → 1.95.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2F5FENXB.js +84 -0
- package/dist/chunk-2F5FENXB.js.map +1 -0
- package/dist/chunk-3LIIUXBE.js +14 -0
- package/dist/chunk-3LIIUXBE.js.map +1 -0
- package/dist/chunk-G2XGZH7P.cjs +16 -0
- package/dist/chunk-G2XGZH7P.cjs.map +1 -0
- package/dist/chunk-GAZLFZEL.js +105 -0
- package/dist/chunk-GAZLFZEL.js.map +1 -0
- package/dist/chunk-LT7I4JVK.cjs +121 -0
- package/dist/chunk-LT7I4JVK.cjs.map +1 -0
- package/dist/chunk-OEDAX6WN.js +121 -0
- package/dist/chunk-OEDAX6WN.js.map +1 -0
- package/dist/chunk-P5FSVRZO.cjs +127 -0
- package/dist/chunk-P5FSVRZO.cjs.map +1 -0
- package/dist/chunk-RLPXYKSM.cjs +23 -0
- package/dist/chunk-RLPXYKSM.cjs.map +1 -0
- package/dist/chunk-TN6DXBVD.js +252 -0
- package/dist/chunk-TN6DXBVD.js.map +1 -0
- package/dist/chunk-YNBKRMK3.cjs +290 -0
- package/dist/chunk-YNBKRMK3.cjs.map +1 -0
- package/dist/chunk-ZQCGDT7D.js +19 -0
- package/dist/chunk-ZQCGDT7D.js.map +1 -0
- package/dist/chunk-ZR7TABGT.cjs +94 -0
- package/dist/chunk-ZR7TABGT.cjs.map +1 -0
- package/dist/date/index.cjs +210 -397
- package/dist/date/index.cjs.map +1 -1
- package/dist/date/index.js +2 -349
- package/dist/date/index.js.map +1 -1
- package/dist/date/org-format.cjs +13 -151
- package/dist/date/org-format.cjs.map +1 -1
- package/dist/date/org-format.js +3 -141
- package/dist/date/org-format.js.map +1 -1
- package/dist/index.cjs +286 -600
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -539
- package/dist/index.js.map +1 -1
- package/dist/list/index.cjs +7 -11
- package/dist/list/index.cjs.map +1 -1
- package/dist/list/index.js +1 -12
- package/dist/list/index.js.map +1 -1
- package/dist/money/index.cjs +39 -51
- package/dist/money/index.cjs.map +1 -1
- package/dist/money/index.d.cts +129 -8
- package/dist/money/index.d.ts +129 -8
- package/dist/money/index.js +1 -49
- package/dist/money/index.js.map +1 -1
- package/dist/number/index.cjs +15 -18
- package/dist/number/index.cjs.map +1 -1
- package/dist/number/index.js +1 -17
- package/dist/number/index.js.map +1 -1
- package/dist/patch/index.cjs +22 -121
- package/dist/patch/index.cjs.map +1 -1
- package/dist/patch/index.js +1 -119
- package/dist/patch/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/date/constants.ts","../src/date/iso.ts","../src/date/format.ts","../src/date/formatValidation.ts","../src/date/duration.ts","../src/date/wire.ts","../src/date/range.ts","../src/patch/index.ts","../src/list/index.ts","../src/money/format.ts","../src/number/format.ts"],"names":["format","isValid","year","month","day"],"mappings":";;;;AASO,IAAM,WAAA,GAAc;AAGpB,IAAM,iBAAA,GAAoB;AAG1B,IAAM,mBAAA,GAAsB;AAG5B,IAAM,eAAA,GAAkB;AAGxB,IAAM,gBAAA,GAAmB;AAGzB,IAAM,qBAAA,GAAwB;AAG9B,IAAM,WAAA,GAAc;AAGpB,IAAM,qBAAA,GAAwB;AAG9B,IAAM,UAAA,GAAa;AAGnB,IAAM,WAAA,GAAc;AAGpB,IAAM,aAAA,GAAgB;AAGtB,IAAM,yBAAA,GAA4B;AAGlC,IAAM,6BAAA,GAAgC;AAGtC,IAAM,yBAAA,GAA4B;AC3ClC,IAAM,gBAAA,GAAmB,CAAC,KAAA,KAAoC;AACnE,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,qBAAA,CAAsB,KAAK,KAAK,CAAA;AACtE;AAYO,IAAM,UAAA,GAAa,CAAC,IAAA,EAAY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AAS,UAAU,sBAAA,EAAwB;AAAA,IACtE,qBAAA,EAAuB,EAAA;AAAA,IACvB,qBAAA,EAAuB;AAAA,GACxB,CAAA,CAAE,MAAA,CAAO,KAAK,CAAA;AACjB;AAWO,SAAS,aAAA,CAAc,OAAe,OAAA,EAA8C;AACzF,EAAA,OAAO,IAAI,KAAA,GAAQ,GAAA,EAAK,QAAQ,OAAA,EAAS,aAAA,IAAiB,CAAC,CAAC,CAAA,CAAA,CAAA;AAC9D","file":"index.js","sourcesContent":["/**\n * Shared date/time format tokens (date-fns syntax).\n *\n * These are the canonical formats used across the EthisysCore monolith and\n * plugins. Change a value here for a global locale requirement rather than\n * hardcoding a format string at a call site.\n */\n\n/** ISO wire format `yyyy-MM-dd` — the standard date-only format throughout the app. */\nexport const DATE_FORMAT = \"yyyy-MM-dd\";\n\n/** Audit-log timestamp, e.g. `5 March 2026, 14:30`. */\nexport const AUDIT_DATE_FORMAT = \"d MMMM yyyy, HH:mm\";\n\n/** User-facing date display, e.g. `5 Mar 2026`. */\nexport const DISPLAY_DATE_FORMAT = \"d MMM yyyy\";\n\n/** Weekday + day + month, e.g. `Monday, 5 March`. */\nexport const DAY_DATE_FORMAT = \"EEEE, d MMMM\";\n\n/** Abbreviated day + month, e.g. `Mar 5`. */\nexport const DAY_MONTH_FORMAT = \"MMM d\";\n\n/** Abbreviated day + month + year, e.g. `Mar 5, 2026`. */\nexport const DAY_MONTH_YEAR_FORMAT = \"MMM d, yyyy\";\n\n/** 12-hour time, e.g. `2:30 PM`. */\nexport const TIME_FORMAT = \"h:mm a\";\n\n/** Short datetime, e.g. `Mar 5, 2:30 PM`. */\nexport const SHORT_DATETIME_FORMAT = \"MMM d, h:mm a\";\n\n/** Milliseconds in a day — whole-day duration / diff math (`daysBetweenIso`, axis geometry). */\nexport const MS_PER_DAY = 86_400_000;\n\n/** Milliseconds in an hour — duration math without inline `1000 * 60 * 60`. */\nexport const MS_PER_HOUR = 3_600_000;\n\n/** Milliseconds in a minute — duration / relative-time math without inline `1000 * 60`. */\nexport const MS_PER_MINUTE = 60_000;\n\n/** Fixed numeric UK date, e.g. `05/03/2026`. Deliberately NOT org-driven — form-field / compact contexts. */\nexport const DISPLAY_DATE_SLASH_FORMAT = \"dd/MM/yyyy\";\n\n/** Fixed numeric UK datetime, e.g. `05/03/2026 14:30`. Deliberately NOT org-driven. */\nexport const DISPLAY_DATETIME_SLASH_FORMAT = \"dd/MM/yyyy HH:mm\";\n\n/** Weekday + day + abbreviated month, e.g. `Wed 5 Mar`. */\nexport const DISPLAY_SHORT_DATE_FORMAT = \"EEE d MMM\";\n","import { format, isValid } from \"date-fns\";\n\nimport { DATE_FORMAT, MS_PER_DAY } from \"./constants\";\n\n/** Type guard: is `value` a bare `yyyy-MM-dd` date-only string? */\nexport const isDateOnlyString = (value: unknown): value is string => {\n return typeof value === \"string\" && /^\\d{4}-\\d{2}-\\d{2}$/.test(value);\n};\n\n/**\n * Formats a `Date`, defaulting to the standard application ISO date format\n * (`yyyy-MM-dd`). Pass `dateFormat` to override.\n *\n * Name note: this `formatDate` takes a `Date`. The org-aware `formatDate` on the\n * `@ethisyscore/core-utils/date/org-format` sub-path takes an ISO STRING and\n * returns org-configured display text — a different contract that never collides\n * because it lives on a different entry point. For the common Date→`yyyy-MM-dd`\n * case prefer {@link toIsoDate}, whose name sidesteps the overload.\n */\nexport const formatDate = (date: Date, dateFormat: string = DATE_FORMAT): string => {\n return format(date, dateFormat);\n};\n\n/** Today's date as a `yyyy-MM-dd` ISO string (local calendar day). */\nexport const getTodayIsoDate = (): string => {\n return formatDate(new Date());\n};\n\n/**\n * Formats a `Date` as a `yyyy-MM-dd` ISO date-only string in local time — the\n * inverse of {@link parseIsoDateLocal}. Equivalent to `formatDate(date)`, exposed\n * under the clearer name for the date-only round-trip.\n */\nexport const toIsoDate = (date: Date): string => formatDate(date);\n\n/**\n * Returns a new local `Date` at the first day of `date`'s month, offset by `months`\n * (may be negative), normalising the day-of-month to 1 — e.g. offsetting 15 Mar 2026\n * by -1 gives 1 Feb 2026, not 15 Feb. Returns an `Invalid Date` for a null/invalid\n * input so month-axis arithmetic propagates NaN rather than throwing. Used for\n * month-granular axis/range building (e.g. a Gantt chart).\n */\nexport const startOfMonthOffset = (date: Date | null | undefined, months: number): Date => {\n if (!date || !isValid(date)) {\n return new Date(NaN);\n }\n return new Date(date.getFullYear(), date.getMonth() + months, 1);\n};\n\n/**\n * Whole-day difference between two `yyyy-MM-dd` date-only strings (`toIso - fromIso`),\n * rounded to guard against DST half-day drift when the range crosses a clock-change\n * boundary. Parses both bounds as LOCAL dates (via {@link parseIsoDateLocal}); returns\n * `NaN` when either is not a valid date-only string.\n */\nexport const daysBetweenIso = (fromIso: string, toIso: string): number => {\n const from = parseIsoDateLocal(fromIso);\n const to = parseIsoDateLocal(toIso);\n if (!from || !to) return NaN;\n return Math.round((to.getTime() - from.getTime()) / MS_PER_DAY);\n};\n\n/** First day of the given date's month, as a `yyyy-MM-dd` ISO string. */\nexport const getMonthStartIso = (date: Date): string =>\n formatDate(new Date(date.getFullYear(), date.getMonth(), 1));\n\n/** Last day of the given date's month, as a `yyyy-MM-dd` ISO string. */\nexport const getMonthEndIso = (date: Date): string =>\n formatDate(new Date(date.getFullYear(), date.getMonth() + 1, 0));\n\n/**\n * Parses a date-only `yyyy-MM-dd` string as a LOCAL date. Returns `null` when\n * the value is not a date-only string or is not a valid calendar date. Avoids\n * the `new Date(\"yyyy-MM-dd\")` UTC parse, which shifts the day in non-UTC zones.\n */\nexport const parseIsoDateLocal = (value: string | null | undefined): Date | null => {\n if (!value || !isDateOnlyString(value)) return null;\n const [year, month, day] = value.split(\"-\").map(Number);\n const d = new Date(year, month - 1, day);\n return isValid(d) ? d : null;\n};\n\n/**\n * Adds `days` to an ISO `yyyy-MM-dd` date and returns the result as a `yyyy-MM-dd`\n * string. Parses and formats in local time (via `parseIsoDateLocal` / `formatDate`)\n * so the arithmetic can't drift across a day boundary in non-UTC timezones/DST.\n * Returns the input unchanged when it is not a valid date-only string.\n */\nexport const addDaysToIsoDate = (isoDate: string, days: number): string => {\n const base = parseIsoDateLocal(isoDate);\n if (!base) return isoDate;\n base.setDate(base.getDate() + days);\n return formatDate(base);\n};\n\n/**\n * Adds `years` to an ISO `yyyy-MM-dd` date and returns the result as a `yyyy-MM-dd`\n * string. Parses and formats in local time (like {@link addDaysToIsoDate}) so the\n * arithmetic can't drift across a day boundary in non-UTC timezones/DST. Used to seed\n * default expiry / end-of-term dates (insurance cover, licences, fixed-term contracts).\n * A 29 Feb base in a non-leap target year rolls to 1 Mar, matching `Date.setFullYear`.\n * Returns the input unchanged when it is not a valid date-only string.\n */\nexport const addYearsToIsoDate = (isoDate: string, years: number): string => {\n const base = parseIsoDateLocal(isoDate);\n if (!base) return isoDate;\n base.setFullYear(base.getFullYear() + years);\n return formatDate(base);\n};\n\n/**\n * Extracts a date-only string (`yyyy-MM-dd`) from a date string.\n * - Date-only strings (`2024-05-15`) are returned as-is.\n * - ISO datetime strings (`2024-05-15T00:00:00+05:30`) have the date portion\n * extracted directly from the string to preserve the original calendar date\n * without timezone conversion.\n * - Returns empty string for null, undefined, or unparseable values.\n */\nexport const toDateOnlyString = (value: string | null | undefined): string => {\n if (!value) return \"\";\n // Extract the yyyy-MM-dd portion before the \"T\" separator to avoid timezone\n // conversion that can shift the date by a day.\n const datepart = value.split(\"T\")[0];\n return isDateOnlyString(datepart) ? datepart : \"\";\n};\n","import { format, isValid, parseISO } from \"date-fns\";\n\nimport {\n DATE_FORMAT,\n DAY_MONTH_FORMAT,\n DISPLAY_DATE_SLASH_FORMAT,\n DISPLAY_DATETIME_SLASH_FORMAT,\n DISPLAY_SHORT_DATE_FORMAT,\n MS_PER_MINUTE,\n} from \"./constants\";\nimport { formatDate, isDateOnlyString, parseIsoDateLocal } from \"./iso\";\n\n/**\n * FALLBACK CONVENTION: a display formatter given falsy/unparseable input returns\n * the em-dash placeholder {@link EM_DASH} so callers can render unconditionally.\n * (Wire/parse helpers in `iso.ts` / `wire.ts` return `\"\"`/`undefined` instead so\n * the value is omitted rather than shown; `formatDuration` likewise uses the\n * em-dash for missing/invalid input, but `0m` for a real zero.) The one exception\n * is {@link formatDateWithOrdinal}, whose \"Not specified\" / \"Invalid date\" are\n * deliberate, richer domain messages.\n */\nexport const EM_DASH = \"—\";\n\n/**\n * Shared body for the fixed (not org-driven) datetime formatters below: parse an\n * ISO string with the native `Date`, and render it with `fmt` or the em-dash for\n * falsy/invalid input. Not exported — the named formatters are the public surface.\n */\nconst formatFixedDateTime = (value: string | null | undefined, fmt: string): string => {\n if (!value) return EM_DASH;\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? EM_DASH : format(date, fmt);\n};\n\n/**\n * Shared relative-time ladder: maps a whole-minute age to a short phrase\n * (\"Just now\", \"5m ago\", \"3h ago\", \"2d ago\"), or `null` for anything a week or\n * older so the caller can substitute an absolute date. Backs both\n * {@link formatTimeAgo} here and `formatRelativeTime` in the org-format module.\n */\nexport const relativeTimePhrase = (diffMinutes: number): string | null => {\n if (diffMinutes < 1) return \"Just now\";\n if (diffMinutes < 60) return `${diffMinutes}m ago`;\n const hours = Math.floor(diffMinutes / 60);\n if (hours < 24) return `${hours}h ago`;\n const days = Math.floor(hours / 24);\n if (days < 7) return `${days}d ago`;\n return null;\n};\n\n/**\n * Formats a date-only `yyyy-MM-dd` string in the user's LOCAL timezone as the fixed\n * numeric UK date `dd/MM/yyyy`. Parses via {@link parseIsoDateLocal} to avoid the\n * `new Date(\"yyyy-MM-dd\")` UTC-midnight parse that renders as the previous day west\n * of UTC. Returns the original string when it is not a valid date-only value.\n * Deliberately fixed (not org-driven) — for form-field / compact contexts.\n */\nexport const formatSlashDate = (dateString: string): string => {\n const parsed = parseIsoDateLocal(dateString);\n return parsed ? format(parsed, DISPLAY_DATE_SLASH_FORMAT) : dateString;\n};\n\n/**\n * Formats an ISO datetime string as the fixed numeric UK datetime `dd/MM/yyyy HH:mm`\n * for compact display contexts such as table columns. Returns em-dash for missing or\n * invalid values. Deliberately fixed (not org-driven) — distinct from the org-aware\n * `formatDateTime` in `@ethisyscore/core-utils/date/org-format`.\n */\nexport const formatCompactDateTime = (value?: string | null): string =>\n formatFixedDateTime(value, DISPLAY_DATETIME_SLASH_FORMAT);\n\n/**\n * Formats an ISO date/datetime string as a short weekday date `EEE d MMM` (e.g. `Wed 5 Mar`).\n * Returns em-dash for missing or invalid values. Deliberately fixed (not org-driven).\n */\nexport const formatShortDate = (value?: string | null): string =>\n formatFixedDateTime(value, DISPLAY_SHORT_DATE_FORMAT);\n\n/**\n * Formats an ISO date/datetime string as an abbreviated month-day `MMM d` (e.g. `Mar 5`).\n * Intended for chart axis ticks where vertical space is limited. Returns em-dash for\n * missing or invalid values. Deliberately fixed (not org-driven).\n */\nexport const formatMonthDay = (value?: string | null): string =>\n formatFixedDateTime(value, DAY_MONTH_FORMAT);\n\n/**\n * Safely formats a date string or `Date`. Handles null, undefined, and invalid\n * dates by returning a fallback string.\n * @param date - The date to format (string, Date, null, or undefined)\n * @param formatStr - The desired output format (defaults to `DATE_FORMAT`)\n * @param fallback - Returned when the date is invalid or missing (defaults to `\"—\"`)\n */\nexport const formatDateSafe = (\n date: string | Date | null | undefined,\n formatStr: string = DATE_FORMAT,\n fallback: string = \"—\",\n): string => {\n if (!date) return fallback;\n try {\n const dateObj = typeof date === \"string\" ? parseISO(date) : date;\n if (!isValid(dateObj)) return fallback;\n return format(dateObj, formatStr);\n } catch {\n return fallback;\n }\n};\n\n/** Returns the ordinal suffix for a day of month (`st`, `nd`, `rd`, `th`). */\nconst getOrdinalSuffix = (day: number): string => {\n if (day > 3 && day < 21) return \"th\";\n switch (day % 10) {\n case 1:\n return \"st\";\n case 2:\n return \"nd\";\n case 3:\n return \"rd\";\n default:\n return \"th\";\n }\n};\n\n/**\n * Formats a date string or `Date` to a format like `31st Aug 2025`.\n * Handles date-only strings (`yyyy-MM-dd`) as local dates to avoid timezone shifts.\n * @param date - Date string (`yyyy-MM-dd`) or `Date`\n * @returns Formatted date string with ordinal suffix\n */\nexport const formatDateWithOrdinal = (date: string | Date | null | undefined): string => {\n if (!date) return \"Not specified\";\n\n let dateObj: Date;\n if (typeof date === \"string\") {\n if (isDateOnlyString(date)) {\n const [year, month, day] = date.split(\"-\").map(Number);\n dateObj = new Date(year, month - 1, day);\n } else {\n dateObj = parseISO(date);\n }\n } else {\n dateObj = date;\n }\n\n if (!isValid(dateObj)) return \"Invalid date\";\n\n const day = dateObj.getDate();\n const month = format(dateObj, \"MMM\");\n const year = dateObj.getFullYear();\n return `${day}${getOrdinalSuffix(day)} ${month} ${year}`;\n};\n\n/**\n * Formats a date as a relative time string (e.g. `2h ago`, `Just now`).\n * Optimised for short labels in dropdowns; anything older than a week falls\n * back to the standard date format.\n * @param date - ISO string or `Date`\n */\nexport const formatTimeAgo = (date: string | Date | null | undefined): string => {\n if (!date) return \"\";\n\n const dateObj = typeof date === \"string\" ? parseISO(date) : date;\n if (!isValid(dateObj)) return \"\";\n\n const diffMinutes = Math.floor((new Date().getTime() - dateObj.getTime()) / MS_PER_MINUTE);\n // A week or older falls back to the plain ISO date (this helper's fixed contract);\n // the org-aware sibling `formatRelativeTime` falls back to the org datetime instead.\n return relativeTimePhrase(diffMinutes) ?? formatDate(dateObj);\n};\n","/**\n * Structural (token-grammar) validator for date/time format strings — a framework-agnostic\n * mirror of the CoreConnect API's `DateFnsFormatValidator` (CoreConnect.Application.Common).\n * Accepts any combination of the supported date-fns tokens (a deliberate subset — see the token\n * sets below), separators and quoted literals (so users can define custom formats), while unknown\n * tokens — incl. .NET-style DD/YYYY/tt, which date-fns either throws on or silently renders as\n * garbage — are rejected with a targeted hint.\n *\n * PARITY CONTRACT: the canonical test vectors in `__tests__/formatValidation.test.ts` are\n * duplicated verbatim in the API's `DateFnsFormatValidatorTests.cs`. Error message strings are\n * part of the contract — change them in lockstep across both repos.\n */\n\nexport interface FormatValidationResult {\n valid: boolean;\n error?: string;\n}\n\nconst SEPARATOR_CHARS = \" ,./-:()\";\n\nconst DAY_TOKENS = new Set([\"d\", \"dd\", \"do\"]);\nconst WEEKDAY_TOKENS = new Set([\"EEE\", \"EEEE\"]);\nconst MONTH_TOKENS = new Set([\"M\", \"MM\", \"MMM\", \"MMMM\"]);\nconst YEAR_TOKENS = new Set([\"yy\", \"yyyy\"]);\nconst HOUR12_TOKENS = new Set([\"h\", \"hh\"]);\nconst HOUR24_TOKENS = new Set([\"H\", \"HH\"]);\nconst MINUTE_TOKENS = new Set([\"m\", \"mm\"]);\nconst SECOND_TOKENS = new Set([\"s\", \"ss\"]);\nconst MERIDIEM_TOKEN = \"a\";\n\n/** Common wrong-token → right-token hints for DATE formats (.NET / minute-vs-month mixups). */\nconst DATE_HINTS: Record<string, string> = {\n D: \"d\",\n DD: \"dd\",\n Y: \"yyyy\",\n YY: \"yy\",\n YYYY: \"yyyy\",\n E: \"EEE\",\n EE: \"EEE\",\n m: \"M\",\n mm: \"MM\",\n};\n\n/** Common wrong-token → right-token hints for TIME formats (.NET meridiem / month-vs-minute mixups). */\nconst TIME_HINTS: Record<string, string> = {\n t: \"a\",\n tt: \"a\",\n A: \"a\",\n M: \"m\",\n MM: \"mm\",\n};\n\nconst invalid = (error: string): FormatValidationResult => ({ valid: false, error });\n\nconst isLetter = (c: string): boolean => /[a-zA-Z]/.test(c);\n\n/**\n * Walks the format string collecting letter-run tokens. Quoted literals ('...', with '' as the\n * escaped apostrophe) and separator characters are skipped; any other character, or a letter run\n * not in `isKnownToken`, fails with the canonical error (with a hint when the mixup is known).\n */\nfunction tokenize(\n value: string,\n isKnownToken: (token: string) => boolean,\n hints: Record<string, string>,\n): { result: FormatValidationResult; tokens: string[] } {\n const tokens: string[] = [];\n let i = 0;\n\n while (i < value.length) {\n const c = value[i];\n\n if (c === \"'\") {\n i++;\n let closed = false;\n while (i < value.length) {\n if (value[i] === \"'\") {\n if (i + 1 < value.length && value[i + 1] === \"'\") {\n i += 2; // '' inside a literal = escaped apostrophe\n continue;\n }\n closed = true;\n i++;\n break;\n }\n i++;\n }\n if (!closed) return { result: invalid(\"Unterminated quoted literal.\"), tokens };\n continue;\n }\n\n if (isLetter(c)) {\n const start = i;\n while (i < value.length && value[i] === c) i++;\n let run = value.slice(start, i);\n\n // date-fns ordinal day-of-month is the two-letter token 'do' — the only\n // mixed-letter token the grammar supports.\n if (run === \"d\" && value[i] === \"o\") {\n run = \"do\";\n i++;\n }\n\n if (!isKnownToken(run)) {\n const hint = hints[run];\n return {\n result: invalid(hint ? `Unknown token '${run}' — use '${hint}' instead.` : `Unknown token '${run}'.`),\n tokens,\n };\n }\n\n tokens.push(run);\n continue;\n }\n\n if (SEPARATOR_CHARS.includes(c)) {\n i++;\n continue;\n }\n\n return { result: invalid(`Unsupported character '${c}'.`), tokens };\n }\n\n return { result: { valid: true }, tokens };\n}\n\n/**\n * Validates a DATE format string: only supported date-fns date tokens, separators and quoted\n * literals; must contain a day, a month and a year token. Nullish or empty input is valid\n * (means \"unset / use the caller's default\"), mirroring the API's `string?` overload — a\n * non-empty whitespace-only string is NOT treated as empty and fails the day-token check, matching\n * the server's `string.IsNullOrEmpty` semantics.\n */\nexport function validateDateFormat(value: string | null | undefined): FormatValidationResult {\n if (!value) return { valid: true };\n\n const { result, tokens } = tokenize(\n value,\n (t) => DAY_TOKENS.has(t) || WEEKDAY_TOKENS.has(t) || MONTH_TOKENS.has(t) || YEAR_TOKENS.has(t),\n DATE_HINTS,\n );\n if (!result.valid) return result;\n\n if (!tokens.some((t) => DAY_TOKENS.has(t))) return invalid(\"Date format must include a day token (d, dd or do).\");\n if (!tokens.some((t) => MONTH_TOKENS.has(t))) {\n return invalid(\"Date format must include a month token (M, MM, MMM or MMMM).\");\n }\n if (!tokens.some((t) => YEAR_TOKENS.has(t))) return invalid(\"Date format must include a year token (yy or yyyy).\");\n\n return { valid: true };\n}\n\n/**\n * Validates a TIME format string: only supported date-fns time tokens, separators and quoted\n * literals; must contain an hour and a minute token; 12-hour tokens require the meridiem token\n * 'a' (and vice versa) so an ambiguous 12h-without-AM/PM can never be stored. Nullish or empty\n * input is valid (means \"unset / use the caller's default\"), mirroring the API's `string?`\n * overload; a non-empty whitespace-only string is NOT treated as empty and fails the hour-token check.\n */\nexport function validateTimeFormat(value: string | null | undefined): FormatValidationResult {\n if (!value) return { valid: true };\n\n const { result, tokens } = tokenize(\n value,\n (t) =>\n HOUR12_TOKENS.has(t) ||\n HOUR24_TOKENS.has(t) ||\n MINUTE_TOKENS.has(t) ||\n SECOND_TOKENS.has(t) ||\n t === MERIDIEM_TOKEN,\n TIME_HINTS,\n );\n if (!result.valid) return result;\n\n const hasHour12 = tokens.some((t) => HOUR12_TOKENS.has(t));\n const hasHour24 = tokens.some((t) => HOUR24_TOKENS.has(t));\n\n if (!hasHour12 && !hasHour24) return invalid(\"Time format must include an hour token (h, hh, H or HH).\");\n if (!tokens.some((t) => MINUTE_TOKENS.has(t))) return invalid(\"Time format must include a minute token (m or mm).\");\n\n const hasMeridiem = tokens.includes(MERIDIEM_TOKEN);\n if (hasHour12 && !hasMeridiem) return invalid(\"12-hour time format requires the meridiem token 'a'.\");\n if (hasMeridiem && !hasHour12) return invalid(\"Meridiem token 'a' requires a 12-hour hour token (h or hh).\");\n\n return { valid: true };\n}\n","/**\n * Pure duration / timespan helpers — no external dependencies.\n *\n * Cover the two duration shapes that flow across the EthisysCore wire: a\n * `\"HH:mm:ss\"` timespan string (.NET `TimeSpan`) and a millisecond count.\n */\nimport { MS_PER_DAY, MS_PER_HOUR, MS_PER_MINUTE } from \"./constants\";\n\n/** Converts a `\"HH:mm:ss\"` timespan string to milliseconds. */\nexport const timespanToMilliseconds = (timespan: string): number => {\n if (!timespan) return 0;\n\n const [h = \"0\", m = \"0\", s = \"0\"] = timespan.split(\":\");\n const hours = parseInt(h || \"0\", 10);\n const minutes = parseInt(m || \"0\", 10);\n const seconds = parseInt(s || \"0\", 10);\n\n return (\n (isNaN(hours) ? 0 : hours) * 60 * 60 * 1000 +\n (isNaN(minutes) ? 0 : minutes) * 60 * 1000 +\n (isNaN(seconds) ? 0 : seconds) * 1000\n );\n};\n\n/** Converts milliseconds to hours (as a float). */\nexport const millisecondsToHours = (ms: number): number => ms / MS_PER_HOUR;\n\n/** Converts hours to milliseconds. */\nexport const hoursToMilliseconds = (hours: number): number => hours * MS_PER_HOUR;\n\n/**\n * The one human-readable duration formatter. Takes a MILLISECOND count and renders\n * the largest non-zero units as `Xd Xh Xm` (e.g. `4h 15m`, `2d 3h`, `45m`). Zero is\n * a real value (`0m`); a nullish/NaN/negative input is missing data and returns the\n * em-dash. Minute granularity — seconds are not shown.\n *\n * Feed non-millisecond inputs through the converters in this module:\n * `formatDuration(timespanToMilliseconds(\"04:15:00\"))` // \"HH:mm:ss\" TimeSpan\n * `formatDuration(hoursToMilliseconds(2.5))` // fractional hours\n */\nexport const formatDuration = (ms: number | null | undefined): string => {\n if (ms == null || Number.isNaN(ms) || ms < 0) return \"—\";\n if (ms < MS_PER_MINUTE) return \"0m\";\n\n const days = Math.floor(ms / MS_PER_DAY);\n const hours = Math.floor((ms % MS_PER_DAY) / MS_PER_HOUR);\n const minutes = Math.floor((ms % MS_PER_HOUR) / MS_PER_MINUTE);\n\n const parts: string[] = [];\n if (days) parts.push(`${days}d`);\n if (hours) parts.push(`${hours}h`);\n if (minutes) parts.push(`${minutes}m`);\n return parts.join(\" \");\n};\n\n/**\n * Trims an API-supplied `\"HH:mm:ss\"` down to the `\"HH:mm\"` string used by\n * MUI `TimePicker`-backed forms. Returns the supplied fallback when the value\n * is missing or shorter than five characters.\n */\nexport function toHHmm(value: string | null | undefined, fallback: string): string {\n if (!value || value.length < 5) return fallback;\n return value.slice(0, 5);\n}\n\n/**\n * Serialises a non-empty `\"HH:mm\"` / `\"HH:mm:ss\"` value back to the canonical\n * `\"HH:mm:ss\"` API format. Returns `null` for empty input so callers can block\n * the save rather than silently persisting midnight — an empty TimePicker\n * (cleared via keyboard) is an unsaved edit, not a legitimate `00:00:00` value.\n */\nexport function toHHmmss(value: string): string | null {\n const trimmed = value.trim();\n if (!trimmed) return null;\n return trimmed.length === 5 ? `${trimmed}:00` : trimmed;\n}\n","import { format, isValid } from \"date-fns\";\n\n// ---------------------------------------------------------------------------\n// Wire-boundary helpers\n// ---------------------------------------------------------------------------\n//\n// HTML's `<input type=\"date\">` and `<input type=\"datetime-local\">` emit naive\n// local strings with NO timezone suffix. Sending those raw to a .NET backend\n// that deserialises into `DateTimeOffset` parses them using the BE process's\n// local offset (UTC on most container hosts), silently misinterpreting the\n// user's wall-clock as UTC and shifting the stored timestamp by the user's\n// offset (e.g. losing the first hour of the local day during BST). These\n// helpers bridge cleanly between the input shapes and full ISO-8601 UTC.\n//\n// All are pure and timezone-aware via the runtime `Date` object.\n\n/**\n * Normalises a date-only value from `<input type=\"date\">` (`yyyy-MM-dd`) into a\n * canonical UTC ISO-8601 timestamp at midnight UTC, e.g.\n * `2026-07-14` → `2026-07-14T00:00:00.000Z`. Use at the API-payload boundary\n * for fields the BE types as `DateTimeOffset` — a bare date-only string risks\n * ambiguous/failed deserialisation. A value that is already a full ISO\n * timestamp is passed through unchanged. Empty/invalid → `undefined` so callers\n * omit the field (BE clears it).\n */\nexport function dateOnlyToIsoUtc(value: string | null | undefined): string | undefined {\n if (!value) return undefined;\n const parsed = value.includes(\"T\") ? new Date(value) : new Date(`${value}T00:00:00Z`);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed.toISOString();\n}\n\n/**\n * Returns the current local wall-clock as a `yyyy-MM-ddTHH:mm` string — the\n * format an `<input type=\"datetime-local\">` element expects. Minute precision;\n * seconds and timezone deliberately omitted.\n */\nexport function nowLocalDateTimeInputValue(): string {\n return format(new Date(), \"yyyy-MM-dd'T'HH:mm\");\n}\n\n/**\n * Converts a naive local-time string from `<input type=\"datetime-local\">`\n * (shape `yyyy-MM-ddTHH:mm` or `yyyy-MM-ddTHH:mm:ss`) into a full ISO-8601 UTC\n * string with `Z` suffix that .NET `DateTimeOffset` cannot ambiguously\n * interpret. Empty / undefined inputs pass through as `undefined`.\n */\nexport function localDateTimeInputToIsoUtc(value: string | null | undefined): string | undefined {\n if (!value) return undefined;\n const parsed = new Date(value);\n if (!isValid(parsed)) return undefined;\n return parsed.toISOString();\n}\n\n/**\n * Ensures an ISO-8601 string is treated as UTC by appending a `Z` suffix when\n * no explicit offset or UTC indicator is present. The backend may emit\n * timestamps like `2026-05-26T06:21:00` (no Z), which JS would otherwise parse\n * as local time.\n */\nexport function ensureUtcIso(value: string): string {\n return /[Zz]|[+-]\\d{2}:?\\d{2}$/.test(value) ? value : value + \"Z\";\n}\n\n/**\n * Converts an ISO-8601 string (with or without explicit offset) into the naive\n * local-time shape `yyyy-MM-ddTHH:mm` expected by `<input type=\"datetime-local\">`.\n * Returns the supplied fallback (default empty string) when the input is\n * missing or unparseable. When `value` carries no offset or `Z` suffix it is\n * treated as UTC before converting to local time, so the edit form displays the\n * correct time regardless of the user's timezone.\n */\nexport function isoUtcToLocalDateTimeInput(value: string | null | undefined, fallback = \"\"): string {\n if (!value) return fallback;\n const parsed = new Date(ensureUtcIso(value));\n if (!isValid(parsed)) return fallback;\n return format(parsed, \"yyyy-MM-dd'T'HH:mm\");\n}\n","import { format, subDays, subMonths, subYears } from \"date-fns\";\n\nimport { DATE_FORMAT } from \"./constants\";\n\nexport interface DateRange {\n startDate: string;\n endDate: string;\n}\n\n/**\n * Returns a `{ startDate, endDate }` date range for a named relative period,\n * formatted with `dateFormat` (defaults to the ISO date-only format). Unknown\n * periods fall back to the last week.\n * @param timePeriod - one of `week` | `month` | `quarter` | `year`\n * @param dateFormat - output format for both bounds (defaults to `DATE_FORMAT`)\n */\nexport const getDateRange = (timePeriod: string, dateFormat: string = DATE_FORMAT): DateRange => {\n const today = new Date();\n switch (timePeriod) {\n case \"month\":\n return { startDate: format(subMonths(today, 1), dateFormat), endDate: format(today, dateFormat) };\n case \"quarter\":\n return { startDate: format(subMonths(today, 3), dateFormat), endDate: format(today, dateFormat) };\n case \"year\":\n return { startDate: format(subYears(today, 1), dateFormat), endDate: format(today, dateFormat) };\n case \"week\":\n default:\n return { startDate: format(subDays(today, 7), dateFormat), endDate: format(today, dateFormat) };\n }\n};\n\n/** Computes an ISO timestamp range from a number of days back to now. */\nexport function computeDateRange(days: number): { from: string; to: string } {\n const to = new Date().toISOString();\n const from = new Date(Date.now() - days * 86_400_000).toISOString();\n return { from, to };\n}\n\n/**\n * Returns the current calendar month as a half-open UTC range `[fromUtc, beforeUtc)`,\n * suitable for \"this month\" count filters. `fromUtc` is the first instant of the\n * month; `beforeUtc` is the first instant of the next month (exclusive).\n */\nexport function currentMonthRangeUtc(today: Date = new Date()): { fromUtc: string; beforeUtc: string } {\n const year = today.getUTCFullYear();\n const month = today.getUTCMonth();\n return {\n fromUtc: new Date(Date.UTC(year, month, 1)).toISOString(),\n beforeUtc: new Date(Date.UTC(year, month + 1, 1)).toISOString(),\n };\n}\n\n/**\n * Computes the current UTC-offset minutes for a given IANA zone name using the\n * runtime's `Intl` implementation. Returns `null` when the zone is unknown.\n *\n * Used by timezone auto-populate fallbacks so a browser reporting an IANA zone\n * that isn't in the backend seed (e.g. `Europe/London` during BST) can still\n * match against a seeded zone sharing the same current offset.\n */\nexport function getCurrentOffsetMinutes(iana: string): number | null {\n try {\n const parts = new Intl.DateTimeFormat(\"en\", {\n timeZone: iana,\n timeZoneName: \"longOffset\",\n }).formatToParts(new Date());\n const label = parts.find((p) => p.type === \"timeZoneName\")?.value ?? \"\";\n if (label === \"GMT\" || label === \"UTC\") return 0;\n const m = label.match(/GMT([+-])(\\d{2}):(\\d{2})/);\n if (!m) return null;\n const sign = m[1] === \"+\" ? 1 : -1;\n return sign * (parseInt(m[2], 10) * 60 + parseInt(m[3], 10));\n } catch {\n return null;\n }\n}\n","/**\n * RFC 6902 JSON Patch helpers shared by the EthisysCore monolith and plugins.\n *\n * The wire shape (`JsonPatchOperation`) matches the backend SDK's\n * `EthisysCore.Plugin.Sdk.JsonPatchOperation` record, so a patch produced here by\n * {@link generateJsonPatch} is applied by `IEntityPatchService` on the server.\n */\nimport { apply, create } from \"mutative\";\n\n/** JSON Patch operation type. */\nexport type PatchOperation = \"add\" | \"remove\" | \"replace\";\n\n/**\n * A single JSON Patch operation (RFC 6902 compatible; mutative's format with a string path).\n */\nexport interface JsonPatchOperation {\n /** The operation to be performed. */\n op: PatchOperation;\n /** JSON Pointer path (RFC 6902 format). */\n path: string;\n /** The value for add/replace operations. */\n value?: unknown;\n /** Source pointer for move/copy operations (backend `From`); unused by the generate/apply helpers. */\n from?: string;\n}\n\n/** Array of JSON Patch operations. */\nexport type JsonPatch = JsonPatchOperation[];\n\n/**\n * Generates JSON Patch operations (RFC 6902).\n * Strictly typed, handles Date objects, and ignores key order.\n */\nexport function generateJsonPatch<T>(original: T, modified: T): JsonPatch {\n // If types are completely different (e.g. Array vs Object), strict replacement.\n if (!isSameType(original, modified)) {\n // If both are strictly equal (e.g. both null), returns empty\n if (original === modified) return [];\n // If different, replace root\n return [{ op: \"replace\", path: \"\", value: modified }];\n }\n\n const [, patches] = create(\n original,\n (draft) => {\n // We can safely cast draft to unknown here because we control the recursion\n applyChanges(draft, modified);\n },\n {\n enablePatches: {\n pathAsArray: false,\n },\n },\n );\n\n return patches.map(\n (patch): JsonPatchOperation => ({\n op: patch.op as \"add\" | \"remove\" | \"replace\",\n path: patch.path as string,\n // explicitly check for value existence to satisfy strict null checks if needed\n ...(patch.op !== \"remove\" ? { value: patch.value } : {}),\n }),\n );\n}\n\n/**\n * Recursively applies changes to the Mutative draft.\n * Uses 'unknown' and Type Guards instead of 'any'.\n */\nfunction applyChanges(draft: unknown, modified: unknown): void {\n // This handles Primitives, Dates, and identical References early\n if (isDeepEqual(draft, modified)) {\n return;\n }\n\n // We explicitly check isArray to safely access .length and .push\n if (Array.isArray(draft) && Array.isArray(modified)) {\n const draftArray = draft as Array<unknown>;\n // Clear and Replace approach (safer for DTOs than diffing indices)\n draftArray.length = 0;\n draftArray.push(...modified);\n return;\n }\n\n // We use type guards to ensure we can treat them as dictionaries\n if (isPlainObject(draft) && isPlainObject(modified)) {\n const draftObj = draft;\n const modifiedObj = modified;\n\n // A. Remove keys that don't exist in modified\n for (const key of Object.keys(draftObj)) {\n if (!Object.prototype.hasOwnProperty.call(modifiedObj, key)) {\n delete draftObj[key];\n }\n }\n\n // B. Add or update top-level keys. We deliberately do NOT recurse into nested objects: the backend\n // patch applier (IEntityPatchService) supports only top-level property operations, so a changed\n // nested object is replaced wholesale (path \"/key\"), never diffed into \"/key/child\" paths that the\n // server would reject.\n for (const key of Object.keys(modifiedObj)) {\n if (!isDeepEqual(draftObj[key], modifiedObj[key])) {\n draftObj[key] = modifiedObj[key];\n }\n }\n return;\n }\n}\n\n/**\n * Handles: Primitives, Arrays, Dates, Objects (order-independent), null/undefined\n */\nfunction isDeepEqual(a: unknown, b: unknown): boolean {\n // Strict Reference & Primitive Check\n if (a === b) return true;\n\n // Null/Undefined Checks\n if (a === null || a === undefined || b === null || b === undefined) {\n return a === b;\n }\n\n // Type Mismatch\n if (typeof a !== typeof b) return false;\n\n // Date Objects\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // Arrays\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!isDeepEqual(a[i], b[i])) return false;\n }\n return true;\n }\n\n // Objects\n if (typeof a === \"object\" && typeof b === \"object\") {\n // Treat as Record<string, unknown> safely\n const objA = a as Record<string, unknown>;\n const objB = b as Record<string, unknown>;\n\n const keysA = Object.keys(objA);\n const keysB = Object.keys(objB);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (!Object.prototype.hasOwnProperty.call(objB, key)) return false;\n if (!isDeepEqual(objA[key], objB[key])) return false;\n }\n return true;\n }\n\n return false;\n}\n\n/**\n * Type Guard: Checks if value is a plain object (not null, array, or Date)\n * Allows safe casting to Record<string, unknown>\n */\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n !(value instanceof Date)\n );\n}\n\n/**\n * Helper: Checks if two values share a high-level type category\n */\nfunction isSameType(a: unknown, b: unknown): boolean {\n if (Array.isArray(a)) return Array.isArray(b);\n if (Array.isArray(b)) return false;\n if (a instanceof Date) return b instanceof Date;\n if (a && typeof a === \"object\" && b && typeof b === \"object\") return true;\n return typeof a === typeof b;\n}\n\n/**\n * Applies JSON Patch operations to an object using Mutative.\n * @param original - The original object\n * @param patches - Array of JSON Patch operations to apply\n * @returns The patched object (immutable)\n */\nexport function applyJsonPatch<T>(original: T, patches: JsonPatch): T {\n // Check for root replacement first - if found, it should be the only operation\n const rootReplacement = patches.find((patch) => patch.path === \"\" && patch.op === \"replace\");\n if (rootReplacement) {\n return rootReplacement.value as T;\n }\n\n // Filter out any root operations that might interfere and apply the rest\n const nonRootPatches = patches.filter((patch) => patch.path !== \"\");\n if (nonRootPatches.length === 0) {\n return original;\n }\n\n // Mutative's apply function expects patches in RFC 6902 format, which is what we have\n return apply(original as Record<string, unknown>, nonRootPatches) as T;\n}\n\n/**\n * Checks if a patch array is empty (null, undefined, or empty array).\n * @param patches - Array of patch operations or null/undefined\n * @returns True if patches is null, undefined, or empty array\n */\nexport function isNullOrEmpty(patches: JsonPatch | null | undefined): boolean {\n return !patches || patches.length === 0;\n}\n\n/**\n * Checks if a patch array has any operations.\n * @param patches - Array of patch operations\n * @returns True if patches array has operations, false if empty\n */\nexport function hasPatches(patches: JsonPatch): boolean {\n return patches.length > 0;\n}\n\n/**\n * Creates a deep clone of an object.\n * Useful for creating the \"modified\" version before generating patches.\n * @param obj - Object to clone\n * @returns Deep cloned object\n */\nexport function deepClone<T>(obj: T): T {\n // structuredClone preserves Dates (and undefined); fall back to JSON clone on legacy runtimes.\n if (typeof structuredClone === \"function\") {\n return structuredClone(obj);\n }\n return JSON.parse(JSON.stringify(obj));\n}\n","/**\n * List-response helpers shared by the EthisysCore monolith and plugins.\n *\n * List-returning tools (MCP tools, REST endpoints) return their rows either as a\n * bare array or wrapped in an `{ items }` / `{ rows }` envelope. {@link unwrapList}\n * normalises either shape to a flat array so callers never branch on it.\n */\n\n/** A list response: a bare array or an `{ items }` / `{ rows }` envelope. */\nexport type ListEnvelope<T> = T[] | { items?: T[]; rows?: T[] };\n\n/** Normalise a list response (bare array or `{ items }` / `{ rows }`) to a flat array. */\nexport function unwrapList<T>(response: ListEnvelope<T> | null | undefined): T[] {\n if (response == null) {\n return [];\n }\n if (Array.isArray(response)) {\n return response;\n }\n return response.items ?? response.rows ?? [];\n}\n","/**\n * Framework-agnostic money DISPLAY formatting.\n *\n * The platform stores amounts as a plain number plus a currency (an ISO 4217 code,\n * optionally a symbol and a decimal-places override from the host `Currency` row).\n * This module turns that into a localized string via `Intl.NumberFormat`, with a\n * deterministic fallback so output is machine-stable regardless of the host OS\n * locale - the same principle as the date org-format seam.\n *\n * It is pure - no React, no host access - so it lives in core-utils behind the\n * `@ethisyscore/core-utils/money` sub-path. Resolving WHICH currency to render in\n * (the amount's own currency, or the org's reporting currency) and CONVERTING\n * between currencies are host-aware concerns handled by the plugin-ui `useCurrency`\n * hook, which formats through this module.\n */\n\n/**\n * Deterministic fallback locale. Matches the date seam's UK fallback so money and\n * dates render consistently when no explicit locale is supplied, and so output does\n * not drift with the OS locale of whatever host renders it.\n */\nexport const MONEY_FALLBACK_LOCALE = \"en-GB\";\n\n/** Options for {@link formatMoney}. */\nexport interface FormatMoneyOptions {\n /** ISO 4217 code (e.g. `\"GBP\"`, `\"EUR\"`) - drives `Intl` currency formatting. */\n currencyCode: string;\n /**\n * Fraction digits to show. When null/undefined, `Intl`'s per-currency default is\n * used (GBP -> 2, JPY -> 0). Pass a number to force a currency's decimal-places\n * override from the host `Currency` row.\n */\n decimalPlaces?: number | null;\n /** BCP-47 locale; defaults to {@link MONEY_FALLBACK_LOCALE} for stable output. */\n locale?: string;\n /**\n * Symbol to use only in the fallback path when `Intl` cannot format the currency\n * code (e.g. a non-ISO custom code). Ignored on the happy path, where `Intl`\n * supplies the symbol.\n */\n symbol?: string | null;\n}\n\n/**\n * Formats a monetary amount in the given currency. On an unknown/invalid currency\n * code (which makes `Intl.NumberFormat` throw) it falls back to a symbol/code prefix\n * plus the fixed-decimal amount, so a bad code degrades to a readable string rather\n * than throwing on a render path.\n */\nexport function formatMoney(amount: number, options: FormatMoneyOptions): string {\n const { currencyCode, decimalPlaces, locale = MONEY_FALLBACK_LOCALE, symbol } = options;\n\n // Intl.NumberFormat requires a well-formed (uppercase) ISO 4217 code; a lowercase\n // code (e.g. \"usd\") throws and forces the fallback, so normalise up front.\n const normalizedCode = currencyCode.toUpperCase();\n\n try {\n const formatter = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: normalizedCode,\n // Narrow symbol so a clear currency context renders \"$100\", not \"US$100\".\n currencyDisplay: \"narrowSymbol\",\n ...(decimalPlaces != null\n ? { minimumFractionDigits: decimalPlaces, maximumFractionDigits: decimalPlaces }\n : {}),\n });\n return formatter.format(amount);\n } catch {\n const fractionDigits = decimalPlaces ?? 2;\n const prefix = symbol ?? normalizedCode;\n // Keep the minus sign before the symbol/code prefix (\"-£10.00\", not \"£-10.00\").\n const sign = amount < 0 ? \"-\" : \"\";\n return `${sign}${prefix}${Math.abs(amount).toFixed(fractionDigits)}`;\n }\n}\n\n/** Options for {@link formatCompactMoney}. */\nexport interface FormatCompactMoneyOptions {\n /** ISO 4217 code (e.g. `\"GBP\"`, `\"EUR\"`) - resolves the leading symbol. */\n currencyCode: string;\n /**\n * Fallback symbol used ONLY when `Intl` cannot resolve `currencyCode` (a non-ISO\n * custom code). For a valid ISO code `Intl`'s own symbol always wins - this option\n * does not override it. Mirrors {@link FormatMoneyOptions.symbol} and the\n * {@link getCurrencySymbol} fallback contract.\n */\n symbol?: string | null;\n /** BCP-47 locale used only to resolve the symbol; defaults to {@link MONEY_FALLBACK_LOCALE}. */\n locale?: string;\n}\n\n/**\n * Formats an amount as an abbreviated currency string for compact display, such\n * as chart axis ticks where space is tight - e.g. `\"£1.3m\"`, `\"£500k\"`, `\"£99\"`.\n *\n * Thresholds on the absolute value: >= 1,000,000 renders in millions with a\n * lowercase `m` and one decimal place; >= 1,000 renders in thousands with a\n * lowercase `k` and no decimals; otherwise the whole amount with no decimals.\n * A leading minus is kept before the symbol (e.g. `\"-£1.3m\"`).\n *\n * Unlike {@link formatMoney} this is NOT org-locale driven beyond resolving the\n * leading symbol via {@link getCurrencySymbol}; the number itself is formatted\n * with fixed abbreviations so axis labels stay short and machine-stable.\n */\nexport function formatCompactMoney(amount: number, options: FormatCompactMoneyOptions): string {\n const { currencyCode, symbol, locale = MONEY_FALLBACK_LOCALE } = options;\n\n const sym = getCurrencySymbol(currencyCode, locale, symbol);\n const sign = amount < 0 ? \"-\" : \"\";\n const abs = Math.abs(amount);\n\n if (abs >= 1_000_000) {\n return `${sign}${sym}${(abs / 1_000_000).toFixed(1)}m`;\n }\n if (abs >= 1_000) {\n return `${sign}${sym}${(abs / 1_000).toFixed(0)}k`;\n }\n return `${sign}${sym}${abs.toFixed(0)}`;\n}\n\n/**\n * Resolves the currency symbol for a code in a locale (e.g. `\"GBP\"` -> `\"£\"`),\n * for use in input adornments and labels. Falls back to the supplied `symbol`, then\n * the code itself, when `Intl` cannot resolve it.\n */\nexport function getCurrencySymbol(\n currencyCode: string,\n locale: string = MONEY_FALLBACK_LOCALE,\n symbol?: string | null,\n): string {\n // Intl needs an uppercase ISO code; a lowercase one throws (see formatMoney).\n const normalizedCode = currencyCode.toUpperCase();\n\n try {\n const parts = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: normalizedCode,\n currencyDisplay: \"narrowSymbol\",\n }).formatToParts(0);\n\n return parts.find((part) => part.type === \"currency\")?.value ?? symbol ?? normalizedCode;\n } catch {\n return symbol ?? normalizedCode;\n }\n}\n","/**\n * Framework-agnostic number DISPLAY formatting.\n *\n * Pure helpers for rendering plain numeric values and ratios as strings, with a\n * deterministic `en-GB` fallback locale so output is machine-stable regardless\n * of the host OS locale - the same principle as the money and date seams.\n *\n * It is pure - no React, no host access - so it lives in core-utils behind the\n * `@ethisyscore/core-utils/number` sub-path.\n */\n\n/**\n * Deterministic fallback locale. Matches the money/date seams so numbers render\n * consistently when no explicit locale is supplied, and so output does not drift\n * with the OS locale of whatever host renders it.\n */\nexport const NUMBER_FALLBACK_LOCALE = \"en-GB\";\n\n/**\n * Formats a numeric value with grouping and a fixed number of decimal places via\n * `Intl.NumberFormat`. Returns an em-dash (`\"—\"`) for null/undefined so an\n * absent value renders as a readable placeholder rather than `\"NaN\"` or `\"null\"`.\n *\n * Defaults to two decimal places in {@link NUMBER_FALLBACK_LOCALE}.\n */\nexport function formatNumber(\n value: number | null | undefined,\n options?: { decimalPlaces?: number; locale?: string },\n): string {\n if (value == null) {\n return \"—\";\n }\n\n const dp = options?.decimalPlaces ?? 2;\n return new Intl.NumberFormat(options?.locale ?? NUMBER_FALLBACK_LOCALE, {\n minimumFractionDigits: dp,\n maximumFractionDigits: dp,\n }).format(value);\n}\n\n/**\n * Formats a RATIO as a percentage string with a fixed number of decimal places -\n * e.g. `0.1234` -> `\"12.34%\"`. The input is a ratio, not an already-scaled\n * percentage.\n *\n * Uses `toFixed` (no grouping) rather than `Intl` percent style so output is a\n * plain fixed-decimal percentage, matching what callers expect on compact labels.\n * Defaults to two decimal places.\n */\nexport function formatPercent(ratio: number, options?: { decimalPlaces?: number }): string {\n return `${(ratio * 100).toFixed(options?.decimalPlaces ?? 2)}%`;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/dist/list/index.cjs
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
function unwrapList(response) {
|
|
5
|
-
if (response == null) {
|
|
6
|
-
return [];
|
|
7
|
-
}
|
|
8
|
-
if (Array.isArray(response)) {
|
|
9
|
-
return response;
|
|
10
|
-
}
|
|
11
|
-
return response.items ?? response.rows ?? [];
|
|
12
|
-
}
|
|
3
|
+
var chunkG2XGZH7P_cjs = require('../chunk-G2XGZH7P.cjs');
|
|
13
4
|
|
|
14
|
-
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "unwrapList", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkG2XGZH7P_cjs.unwrapList; }
|
|
10
|
+
});
|
|
15
11
|
//# sourceMappingURL=index.cjs.map
|
|
16
12
|
//# sourceMappingURL=index.cjs.map
|
package/dist/list/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/list/index.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
function unwrapList(response) {
|
|
3
|
-
if (response == null) {
|
|
4
|
-
return [];
|
|
5
|
-
}
|
|
6
|
-
if (Array.isArray(response)) {
|
|
7
|
-
return response;
|
|
8
|
-
}
|
|
9
|
-
return response.items ?? response.rows ?? [];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { unwrapList };
|
|
1
|
+
export { unwrapList } from '../chunk-3LIIUXBE.js';
|
|
13
2
|
//# sourceMappingURL=index.js.map
|
|
14
3
|
//# sourceMappingURL=index.js.map
|
package/dist/list/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/dist/money/index.cjs
CHANGED
|
@@ -1,56 +1,44 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var MONEY_FALLBACK_LOCALE = "en-GB";
|
|
5
|
-
function formatMoney(amount, options) {
|
|
6
|
-
const { currencyCode, decimalPlaces, locale = MONEY_FALLBACK_LOCALE, symbol } = options;
|
|
7
|
-
const normalizedCode = currencyCode.toUpperCase();
|
|
8
|
-
try {
|
|
9
|
-
const formatter = new Intl.NumberFormat(locale, {
|
|
10
|
-
style: "currency",
|
|
11
|
-
currency: normalizedCode,
|
|
12
|
-
// Narrow symbol so a clear currency context renders "$100", not "US$100".
|
|
13
|
-
currencyDisplay: "narrowSymbol",
|
|
14
|
-
...decimalPlaces != null ? { minimumFractionDigits: decimalPlaces, maximumFractionDigits: decimalPlaces } : {}
|
|
15
|
-
});
|
|
16
|
-
return formatter.format(amount);
|
|
17
|
-
} catch {
|
|
18
|
-
const fractionDigits = decimalPlaces ?? 2;
|
|
19
|
-
const prefix = symbol ?? normalizedCode;
|
|
20
|
-
const sign = amount < 0 ? "-" : "";
|
|
21
|
-
return `${sign}${prefix}${Math.abs(amount).toFixed(fractionDigits)}`;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function formatCompactMoney(amount, options) {
|
|
25
|
-
const { currencyCode, symbol, locale = MONEY_FALLBACK_LOCALE } = options;
|
|
26
|
-
const sym = getCurrencySymbol(currencyCode, locale, symbol);
|
|
27
|
-
const sign = amount < 0 ? "-" : "";
|
|
28
|
-
const abs = Math.abs(amount);
|
|
29
|
-
if (abs >= 1e6) {
|
|
30
|
-
return `${sign}${sym}${(abs / 1e6).toFixed(1)}m`;
|
|
31
|
-
}
|
|
32
|
-
if (abs >= 1e3) {
|
|
33
|
-
return `${sign}${sym}${(abs / 1e3).toFixed(0)}k`;
|
|
34
|
-
}
|
|
35
|
-
return `${sign}${sym}${abs.toFixed(0)}`;
|
|
36
|
-
}
|
|
37
|
-
function getCurrencySymbol(currencyCode, locale = MONEY_FALLBACK_LOCALE, symbol) {
|
|
38
|
-
const normalizedCode = currencyCode.toUpperCase();
|
|
39
|
-
try {
|
|
40
|
-
const parts = new Intl.NumberFormat(locale, {
|
|
41
|
-
style: "currency",
|
|
42
|
-
currency: normalizedCode,
|
|
43
|
-
currencyDisplay: "narrowSymbol"
|
|
44
|
-
}).formatToParts(0);
|
|
45
|
-
return parts.find((part) => part.type === "currency")?.value ?? symbol ?? normalizedCode;
|
|
46
|
-
} catch {
|
|
47
|
-
return symbol ?? normalizedCode;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
3
|
+
var chunkZR7TABGT_cjs = require('../chunk-ZR7TABGT.cjs');
|
|
50
4
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
exports
|
|
54
|
-
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "MONEY_FALLBACK_CURRENCY", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkZR7TABGT_cjs.MONEY_FALLBACK_CURRENCY; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "MONEY_FALLBACK_LOCALE", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkZR7TABGT_cjs.MONEY_FALLBACK_LOCALE; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "formatCompactMoney", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkZR7TABGT_cjs.formatCompactMoney; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "formatMoney", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkZR7TABGT_cjs.formatMoney; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "getCurrencySymbol", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkZR7TABGT_cjs.getCurrencySymbol; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "getOrgReportingCurrency", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkZR7TABGT_cjs.getOrgReportingCurrency; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "parseMoney", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunkZR7TABGT_cjs.parseMoney; }
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "resolveOrgReportingCurrencyCode", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return chunkZR7TABGT_cjs.resolveOrgReportingCurrencyCode; }
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "setOrgReportingCurrency", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return chunkZR7TABGT_cjs.setOrgReportingCurrency; }
|
|
42
|
+
});
|
|
55
43
|
//# sourceMappingURL=index.cjs.map
|
|
56
44
|
//# sourceMappingURL=index.cjs.map
|
package/dist/money/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/money/index.d.cts
CHANGED
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
* (the amount's own currency, or the org's reporting currency) and CONVERTING
|
|
13
13
|
* between currencies are host-aware concerns handled by the plugin-ui `useCurrency`
|
|
14
14
|
* hook, which formats through this module.
|
|
15
|
+
*
|
|
16
|
+
* When no currency is given, `formatMoney` falls back to the organisation's
|
|
17
|
+
* reporting currency via the {@link ./orgCurrency} seam (the same module-ref +
|
|
18
|
+
* fail-open-to-`GBP` mechanism as the date org-format seam), so a plugin can render
|
|
19
|
+
* reporting-currency amounts without threading a code or hardcoding one.
|
|
15
20
|
*/
|
|
16
21
|
/**
|
|
17
22
|
* Deterministic fallback locale. Matches the date seam's UK fallback so money and
|
|
@@ -21,8 +26,12 @@
|
|
|
21
26
|
declare const MONEY_FALLBACK_LOCALE = "en-GB";
|
|
22
27
|
/** Options for {@link formatMoney}. */
|
|
23
28
|
interface FormatMoneyOptions {
|
|
24
|
-
/**
|
|
25
|
-
|
|
29
|
+
/**
|
|
30
|
+
* ISO 4217 code (e.g. `"GBP"`, `"EUR"`) - drives `Intl` currency formatting.
|
|
31
|
+
* Optional: when omitted, `formatMoney` resolves the organisation's reporting
|
|
32
|
+
* currency (see {@link ./orgCurrency}), falling back to `GBP` when none is stamped.
|
|
33
|
+
*/
|
|
34
|
+
currencyCode?: string;
|
|
26
35
|
/**
|
|
27
36
|
* Fraction digits to show. When null/undefined, `Intl`'s per-currency default is
|
|
28
37
|
* used (GBP -> 2, JPY -> 0). Pass a number to force a currency's decimal-places
|
|
@@ -39,12 +48,23 @@ interface FormatMoneyOptions {
|
|
|
39
48
|
symbol?: string | null;
|
|
40
49
|
}
|
|
41
50
|
/**
|
|
42
|
-
* Formats a monetary amount
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
51
|
+
* Formats a monetary amount. The currency is resolved in this order:
|
|
52
|
+
*
|
|
53
|
+
* - `formatMoney(amount, "EUR")` — a positional ISO code, with the currency's
|
|
54
|
+
* natural decimals.
|
|
55
|
+
* - `formatMoney(amount, { currencyCode, decimalPlaces, locale, symbol })` — the
|
|
56
|
+
* options form; any of `currencyCode`/`decimalPlaces` may be omitted.
|
|
57
|
+
* - `formatMoney(amount)` (or an options object without `currencyCode`) — the
|
|
58
|
+
* organisation's reporting currency stamped via the {@link ./orgCurrency} seam,
|
|
59
|
+
* including that currency's decimal-places override when the caller gave none.
|
|
60
|
+
* When no org currency is stamped it falls back to {@link MONEY_FALLBACK_CURRENCY}
|
|
61
|
+
* (`GBP`), the same deterministic fail-open as the date org-format seam.
|
|
62
|
+
*
|
|
63
|
+
* On an unknown/invalid currency code (which makes `Intl.NumberFormat` throw) it
|
|
64
|
+
* falls back to a symbol/code prefix plus the fixed-decimal amount, so a bad code
|
|
65
|
+
* degrades to a readable string rather than throwing on a render path.
|
|
46
66
|
*/
|
|
47
|
-
declare function formatMoney(amount: number,
|
|
67
|
+
declare function formatMoney(amount: number, currency?: string | FormatMoneyOptions): string;
|
|
48
68
|
/** Options for {@link formatCompactMoney}. */
|
|
49
69
|
interface FormatCompactMoneyOptions {
|
|
50
70
|
/** ISO 4217 code (e.g. `"GBP"`, `"EUR"`) - resolves the leading symbol. */
|
|
@@ -80,4 +100,105 @@ declare function formatCompactMoney(amount: number, options: FormatCompactMoneyO
|
|
|
80
100
|
*/
|
|
81
101
|
declare function getCurrencySymbol(currencyCode: string, locale?: string, symbol?: string | null): string;
|
|
82
102
|
|
|
83
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Organisation-driven reporting-currency resolution.
|
|
105
|
+
*
|
|
106
|
+
* Plugin (and host) surfaces render reporting-currency amounts in whatever the
|
|
107
|
+
* organisation has configured as its reporting currency, without threading a
|
|
108
|
+
* currency code through every call site. This module holds the module-level
|
|
109
|
+
* reporting-currency ref, its setter, and the readers with a deterministic
|
|
110
|
+
* fallback constant. It is pure — no React, no host access — so it lives in
|
|
111
|
+
* core-utils behind the `@ethisyscore/core-utils/money` sub-path, mirroring the
|
|
112
|
+
* date org-format seam (`@ethisyscore/core-utils/date/org-format`).
|
|
113
|
+
*
|
|
114
|
+
* The ref is stamped by the surface sync hook — the SDK
|
|
115
|
+
* `useReportingCurrencySync` reads the host
|
|
116
|
+
* `settings:get-organisation-reporting-currency` tool and calls
|
|
117
|
+
* `setOrgReportingCurrency`. When no reporting currency is stamped (a
|
|
118
|
+
* standalone/mock run, an old host, or a failed fetch) resolution falls back to
|
|
119
|
+
* the deterministic UK default `GBP`, NOT the OS locale, so output is
|
|
120
|
+
* machine-stable regardless of the host. This is the exact fail-open contract of
|
|
121
|
+
* the date seam's UK `dd/MM/yyyy` fallback.
|
|
122
|
+
*
|
|
123
|
+
* Deciding WHICH currency an amount is in (its own currency vs the org's
|
|
124
|
+
* reporting currency) and CONVERTING between currencies stay host-aware concerns
|
|
125
|
+
* of the plugin-ui `useCurrency` hook. This seam only answers "what is the org's
|
|
126
|
+
* reporting currency" for the pure {@link formatMoney} default path.
|
|
127
|
+
*/
|
|
128
|
+
/**
|
|
129
|
+
* Deterministic fallback reporting currency when no org currency is stamped.
|
|
130
|
+
* Matches the date seam's UK fallback (`ORG_DATE_FALLBACK_FORMAT`) so money and
|
|
131
|
+
* dates degrade consistently, and so output does not drift with the OS locale of
|
|
132
|
+
* whatever host renders it.
|
|
133
|
+
*/
|
|
134
|
+
declare const MONEY_FALLBACK_CURRENCY = "GBP";
|
|
135
|
+
/** The organisation's reporting currency as stamped by the surface sync hook. */
|
|
136
|
+
interface OrgReportingCurrency {
|
|
137
|
+
/** ISO 4217 code (e.g. `"GBP"`, `"EUR"`) drives `Intl` currency formatting. */
|
|
138
|
+
code: string;
|
|
139
|
+
/**
|
|
140
|
+
* Host decimal-places override for the currency, or null to use the currency's
|
|
141
|
+
* ISO default (GBP -> 2, JPY -> 0). Applied by {@link formatMoney} only when the
|
|
142
|
+
* caller supplies no explicit decimalPlaces.
|
|
143
|
+
*/
|
|
144
|
+
decimalPlaces: number | null;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Stamps the module-level reporting-currency ref. Called by the surface sync hook
|
|
148
|
+
* each time the organisation's reporting currency resolves. Pass `null` to clear
|
|
149
|
+
* it and fall back to the deterministic {@link MONEY_FALLBACK_CURRENCY}.
|
|
150
|
+
*/
|
|
151
|
+
declare function setOrgReportingCurrency(currency: OrgReportingCurrency | null): void;
|
|
152
|
+
/** The org's stamped reporting currency, or null to fall back to the UK default. */
|
|
153
|
+
declare function getOrgReportingCurrency(): OrgReportingCurrency | null;
|
|
154
|
+
/**
|
|
155
|
+
* The org's effective reporting-currency code: the stamped code when present, else
|
|
156
|
+
* the deterministic {@link MONEY_FALLBACK_CURRENCY} (`GBP`). Never null, so callers
|
|
157
|
+
* always have a well-formed code to format with.
|
|
158
|
+
*/
|
|
159
|
+
declare function resolveOrgReportingCurrencyCode(): string;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Framework-agnostic money PARSING — the inverse of {@link formatMoney} for form
|
|
163
|
+
* inputs and editable amount fields.
|
|
164
|
+
*
|
|
165
|
+
* A user (or a round-tripped display value) types an amount in the en-GB /
|
|
166
|
+
* dot-decimal display shape — a currency symbol or ISO code prefix, comma grouping
|
|
167
|
+
* separators, stray whitespace, and a dot decimal point ("£1,234.56", "GBP 1,234.56").
|
|
168
|
+
* This turns that back into a plain number, or null when there is no meaningful value
|
|
169
|
+
* to parse.
|
|
170
|
+
*
|
|
171
|
+
* It is deliberately lenient about the symbol, currency-code prefix and grouping so
|
|
172
|
+
* it tolerates the display forms {@link formatMoney} produces in the en-GB fallback
|
|
173
|
+
* locale, but it is NOT a locale-universal inverse of {@link formatMoney}. Only the
|
|
174
|
+
* dot-decimal shape is understood: a comma is always treated as a grouping separator
|
|
175
|
+
* and dropped, so comma-decimal locales (de-DE `1.234,56`) are OUT OF SCOPE and would
|
|
176
|
+
* mis-parse. The platform stores and edits amounts in the dot-decimal numeric form.
|
|
177
|
+
*
|
|
178
|
+
* Ported from the per-plugin `parseCurrency` helper so consuming plugins drop the
|
|
179
|
+
* local copy.
|
|
180
|
+
*/
|
|
181
|
+
/**
|
|
182
|
+
* Parses a formatted currency string back to a number. Returns null for
|
|
183
|
+
* null/undefined, an empty/whitespace-only string, or the literal `"N/A"`
|
|
184
|
+
* placeholder; normalises the Unicode minus, strips every non-numeric character
|
|
185
|
+
* (currency symbols, alpha currency-code prefixes, grouping commas and whitespace),
|
|
186
|
+
* then `parseFloat`s the remainder, returning null when the result is not a number.
|
|
187
|
+
*
|
|
188
|
+
* Parses only the en-GB / dot-decimal display shape (comma thousands, dot decimal);
|
|
189
|
+
* see the module docs — it is NOT a locale-universal inverse of {@link formatMoney}.
|
|
190
|
+
* A leading minus is preserved, so `"-£10.00"` parses to `-10`. Garbage that contains
|
|
191
|
+
* no leading number (`"abc"`) yields null.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* parseMoney("£1,234.56") // 1234.56
|
|
195
|
+
* parseMoney("GBP 1,234.56") // 1234.56
|
|
196
|
+
* parseMoney("−£10.00") // -10 (Unicode minus U+2212)
|
|
197
|
+
* parseMoney("ZZZZ10.00") // 10 (invalid-code fallback prefix)
|
|
198
|
+
* parseMoney("N/A") // null
|
|
199
|
+
* parseMoney("") // null
|
|
200
|
+
* parseMoney(null) // null
|
|
201
|
+
*/
|
|
202
|
+
declare function parseMoney(value: string | null | undefined): number | null;
|
|
203
|
+
|
|
204
|
+
export { type FormatCompactMoneyOptions, type FormatMoneyOptions, MONEY_FALLBACK_CURRENCY, MONEY_FALLBACK_LOCALE, type OrgReportingCurrency, formatCompactMoney, formatMoney, getCurrencySymbol, getOrgReportingCurrency, parseMoney, resolveOrgReportingCurrencyCode, setOrgReportingCurrency };
|