cotomy 0.3.13 → 0.3.14
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/README.md +1 -0
- package/dist/browser/cotomy.js +10 -3
- package/dist/browser/cotomy.js.map +1 -1
- package/dist/browser/cotomy.min.js +1 -1
- package/dist/browser/cotomy.min.js.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/api.js +10 -3
- package/dist/esm/api.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -243,6 +243,7 @@ The Form layer builds on `CotomyElement` for common form flows.
|
|
|
243
243
|
|
|
244
244
|
- `mail`, `tel`, `url` — Wrap the value in a corresponding anchor tag.
|
|
245
245
|
- `number` — Uses `Intl.NumberFormat` with `data-cotomy-locale`/`data-cotomy-currency` inheritance.
|
|
246
|
+
- `data-cotomy-fraction-digits="2"` — Forces fixed fraction digits (sets both `minimumFractionDigits` and `maximumFractionDigits`). Works with or without `data-cotomy-currency` (e.g. `0` → `0.00`).
|
|
246
247
|
- `utc` — Treats the value as UTC (or appends `Z` when missing) and formats with `data-cotomy-format` (default `YYYY/MM/DD HH:mm`).
|
|
247
248
|
- `date` — Renders local dates with `data-cotomy-format` (default `YYYY/MM/DD`) when the input is a valid `Date` value.
|
|
248
249
|
|
package/dist/browser/cotomy.js
CHANGED
|
@@ -2276,9 +2276,16 @@ class CotomyViewRenderer {
|
|
|
2276
2276
|
if (value !== undefined && value !== null) {
|
|
2277
2277
|
const currency = element.attribute("data-cotomy-currency")
|
|
2278
2278
|
|| element.closest("[data-cotomy-currency]")?.attribute("data-cotomy-currency");
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2279
|
+
const fractionDigitsAttribute = element.attribute("data-cotomy-fraction-digits")
|
|
2280
|
+
|| element.closest("[data-cotomy-fraction-digits]")?.attribute("data-cotomy-fraction-digits");
|
|
2281
|
+
const fractionDigits = fractionDigitsAttribute ? Number.parseInt(fractionDigitsAttribute, 10) : undefined;
|
|
2282
|
+
const hasFractionDigits = Number.isFinite(fractionDigits)
|
|
2283
|
+
&& fractionDigits && fractionDigits >= 0 && fractionDigits <= 20;
|
|
2284
|
+
const options = {
|
|
2285
|
+
...(currency ? { style: "currency", currency } : {}),
|
|
2286
|
+
...(hasFractionDigits ? { minimumFractionDigits: fractionDigits, maximumFractionDigits: fractionDigits } : {}),
|
|
2287
|
+
};
|
|
2288
|
+
element.text = new Intl.NumberFormat(this.locale, options).format(value);
|
|
2282
2289
|
}
|
|
2283
2290
|
});
|
|
2284
2291
|
this.renderer("utc", (element, value) => {
|