feat: Add Draft Order plugin (#13291)

* feat: Add draft order plugin

* version draft order plugin

* update readme

* chore: Update scripts

* Create purple-dolls-cheer.md

* port over latest changes

* chore: Make package public
This commit is contained in:
Oli Juhl
2025-08-27 10:14:17 +02:00
committed by GitHub
parent 7c96bc4376
commit a0fca16570
93 changed files with 14526 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
export const getLocaleAmount = (amount: number, currencyCode: string) => {
const formatter = new Intl.NumberFormat([], {
style: "currency",
currencyDisplay: "narrowSymbol",
currency: currencyCode,
})
return formatter.format(amount)
}
export const getNativeSymbol = (currencyCode: string) => {
const formatted = new Intl.NumberFormat([], {
style: "currency",
currency: currencyCode,
currencyDisplay: "narrowSymbol",
}).format(0)
return formatted.replace(/\d/g, "").replace(/[.,]/g, "").trim()
}
export const getDecimalDigits = (currencyCode: string) => {
const formatter = new Intl.NumberFormat(undefined, {
style: "currency",
currency: currencyCode,
})
return formatter.resolvedOptions().maximumFractionDigits
}
export const getStylizedAmount = (amount: number, currencyCode: string) => {
const symbol = getNativeSymbol(currencyCode)
const decimalDigits = getDecimalDigits(currencyCode)
const total = amount.toLocaleString(undefined, {
minimumFractionDigits: decimalDigits,
maximumFractionDigits: decimalDigits,
})
return `${symbol} ${total} ${currencyCode.toUpperCase()}`
}