@simpleapps-com/augur-web 0.2.15 → 0.2.17
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-PTAWV5SA.js +29 -0
- package/dist/chunk-PTAWV5SA.js.map +1 -0
- package/dist/chunk-VT4JLAIE.cjs +29 -0
- package/dist/chunk-VT4JLAIE.cjs.map +1 -0
- package/dist/form-textarea.cjs +2 -2
- package/dist/form-textarea.js +3 -3
- package/dist/price-format.cjs +8 -0
- package/dist/price-format.cjs.map +1 -0
- package/dist/price-format.d.cts +17 -0
- package/dist/price-format.d.ts +17 -0
- package/dist/price-format.js +8 -0
- package/dist/price-format.js.map +1 -0
- package/dist/price.cjs +40 -22
- package/dist/price.cjs.map +1 -1
- package/dist/price.d.cts +23 -4
- package/dist/price.d.ts +23 -4
- package/dist/price.js +40 -22
- package/dist/price.js.map +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/price-format.ts
|
|
4
|
+
var formatDefaults = {
|
|
5
|
+
currency: "USD",
|
|
6
|
+
locale: "en-US",
|
|
7
|
+
precision: 2
|
|
8
|
+
};
|
|
9
|
+
function createFormatPrice(config = {}) {
|
|
10
|
+
const { currency, locale, precision: defaultPrecision } = {
|
|
11
|
+
...formatDefaults,
|
|
12
|
+
...config
|
|
13
|
+
};
|
|
14
|
+
return function formatPrice(value, options) {
|
|
15
|
+
const p = options?.precision ?? defaultPrecision;
|
|
16
|
+
const displayValue = options?.quantity !== void 0 ? value * options.quantity : value;
|
|
17
|
+
return new Intl.NumberFormat(locale, {
|
|
18
|
+
style: "currency",
|
|
19
|
+
currency,
|
|
20
|
+
minimumFractionDigits: p,
|
|
21
|
+
maximumFractionDigits: p
|
|
22
|
+
}).format(displayValue);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
createFormatPrice
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=chunk-PTAWV5SA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/price-format.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// Pure formatting logic — no React, no \"use client\".\n// Safe to import in server components.\n// ---------------------------------------------------------------------------\n\nexport interface PriceFormatConfig {\n /** ISO 4217 currency code. Default: `\"USD\"`. */\n currency?: string;\n /** BCP 47 locale. Default: `\"en-US\"`. */\n locale?: string;\n /** Decimal places. Default: `2`. */\n precision?: number;\n}\n\nexport interface FormatPriceOptions {\n /** Override precision for this call. */\n precision?: number;\n /** Multiply value by quantity before formatting. */\n quantity?: number;\n}\n\nconst formatDefaults: Required<PriceFormatConfig> = {\n currency: \"USD\",\n locale: \"en-US\",\n precision: 2,\n};\n\nexport function createFormatPrice(\n config: PriceFormatConfig = {},\n): (value: number, options?: FormatPriceOptions) => string {\n const { currency, locale, precision: defaultPrecision } = {\n ...formatDefaults,\n ...config,\n };\n\n return function formatPrice(\n value: number,\n options?: FormatPriceOptions,\n ): string {\n const p = options?.precision ?? defaultPrecision;\n const displayValue =\n options?.quantity !== undefined ? value * options.quantity : value;\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n minimumFractionDigits: p,\n maximumFractionDigits: p,\n }).format(displayValue);\n };\n}\n"],"mappings":";;;AAqBA,IAAM,iBAA8C;AAAA,EAClD,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW;AACb;AAEO,SAAS,kBACd,SAA4B,CAAC,GAC4B;AACzD,QAAM,EAAE,UAAU,QAAQ,WAAW,iBAAiB,IAAI;AAAA,IACxD,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AAEA,SAAO,SAAS,YACd,OACA,SACQ;AACR,UAAM,IAAI,SAAS,aAAa;AAChC,UAAM,eACJ,SAAS,aAAa,SAAY,QAAQ,QAAQ,WAAW;AAC/D,WAAO,IAAI,KAAK,aAAa,QAAQ;AAAA,MACnC,OAAO;AAAA,MACP;AAAA,MACA,uBAAuB;AAAA,MACvB,uBAAuB;AAAA,IACzB,CAAC,EAAE,OAAO,YAAY;AAAA,EACxB;AACF;","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
2
|
+
|
|
3
|
+
// src/price-format.ts
|
|
4
|
+
var formatDefaults = {
|
|
5
|
+
currency: "USD",
|
|
6
|
+
locale: "en-US",
|
|
7
|
+
precision: 2
|
|
8
|
+
};
|
|
9
|
+
function createFormatPrice(config = {}) {
|
|
10
|
+
const { currency, locale, precision: defaultPrecision } = {
|
|
11
|
+
...formatDefaults,
|
|
12
|
+
...config
|
|
13
|
+
};
|
|
14
|
+
return function formatPrice(value, options) {
|
|
15
|
+
const p = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.precision]), () => ( defaultPrecision));
|
|
16
|
+
const displayValue = _optionalChain([options, 'optionalAccess', _2 => _2.quantity]) !== void 0 ? value * options.quantity : value;
|
|
17
|
+
return new Intl.NumberFormat(locale, {
|
|
18
|
+
style: "currency",
|
|
19
|
+
currency,
|
|
20
|
+
minimumFractionDigits: p,
|
|
21
|
+
maximumFractionDigits: p
|
|
22
|
+
}).format(displayValue);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
exports.createFormatPrice = createFormatPrice;
|
|
29
|
+
//# sourceMappingURL=chunk-VT4JLAIE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/chunk-VT4JLAIE.cjs","../src/price-format.ts"],"names":[],"mappings":"AAAA,6rBAAY;AACZ;AACA;ACmBA,IAAM,eAAA,EAA8C;AAAA,EAClD,QAAA,EAAU,KAAA;AAAA,EACV,MAAA,EAAQ,OAAA;AAAA,EACR,SAAA,EAAW;AACb,CAAA;AAEO,SAAS,iBAAA,CACd,OAAA,EAA4B,CAAC,CAAA,EAC4B;AACzD,EAAA,MAAM,EAAE,QAAA,EAAU,MAAA,EAAQ,SAAA,EAAW,iBAAiB,EAAA,EAAI;AAAA,IACxD,GAAG,cAAA;AAAA,IACH,GAAG;AAAA,EACL,CAAA;AAEA,EAAA,OAAO,SAAS,WAAA,CACd,KAAA,EACA,OAAA,EACQ;AACR,IAAA,MAAM,EAAA,mCAAI,OAAA,2BAAS,WAAA,UAAa,kBAAA;AAChC,IAAA,MAAM,aAAA,kBACJ,OAAA,6BAAS,WAAA,IAAa,KAAA,EAAA,EAAY,MAAA,EAAQ,OAAA,CAAQ,SAAA,EAAW,KAAA;AAC/D,IAAA,OAAO,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ;AAAA,MACnC,KAAA,EAAO,UAAA;AAAA,MACP,QAAA;AAAA,MACA,qBAAA,EAAuB,CAAA;AAAA,MACvB,qBAAA,EAAuB;AAAA,IACzB,CAAC,CAAA,CAAE,MAAA,CAAO,YAAY,CAAA;AAAA,EACxB,CAAA;AACF;ADzBA;AACA;AACE;AACF,8CAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/chunk-VT4JLAIE.cjs","sourcesContent":[null,"// ---------------------------------------------------------------------------\n// Pure formatting logic — no React, no \"use client\".\n// Safe to import in server components.\n// ---------------------------------------------------------------------------\n\nexport interface PriceFormatConfig {\n /** ISO 4217 currency code. Default: `\"USD\"`. */\n currency?: string;\n /** BCP 47 locale. Default: `\"en-US\"`. */\n locale?: string;\n /** Decimal places. Default: `2`. */\n precision?: number;\n}\n\nexport interface FormatPriceOptions {\n /** Override precision for this call. */\n precision?: number;\n /** Multiply value by quantity before formatting. */\n quantity?: number;\n}\n\nconst formatDefaults: Required<PriceFormatConfig> = {\n currency: \"USD\",\n locale: \"en-US\",\n precision: 2,\n};\n\nexport function createFormatPrice(\n config: PriceFormatConfig = {},\n): (value: number, options?: FormatPriceOptions) => string {\n const { currency, locale, precision: defaultPrecision } = {\n ...formatDefaults,\n ...config,\n };\n\n return function formatPrice(\n value: number,\n options?: FormatPriceOptions,\n ): string {\n const p = options?.precision ?? defaultPrecision;\n const displayValue =\n options?.quantity !== undefined ? value * options.quantity : value;\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n minimumFractionDigits: p,\n maximumFractionDigits: p,\n }).format(displayValue);\n };\n}\n"]}
|
package/dist/form-textarea.cjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunk3RVGVJDIcjs = require('./chunk-3RVGVJDI.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkVMOQCPK5cjs = require('./chunk-VMOQCPK5.cjs');
|
|
9
9
|
require('./chunk-CK53LO3J.cjs');
|
|
10
10
|
|
|
11
11
|
// src/form-textarea.tsx
|
package/dist/form-textarea.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import {
|
|
4
|
-
FormField
|
|
5
|
-
} from "./chunk-GPDD67CJ.js";
|
|
6
3
|
import {
|
|
7
4
|
Textarea
|
|
8
5
|
} from "./chunk-DZ6HBEMA.js";
|
|
6
|
+
import {
|
|
7
|
+
FormField
|
|
8
|
+
} from "./chunk-GPDD67CJ.js";
|
|
9
9
|
import "./chunk-FHS7SJEQ.js";
|
|
10
10
|
|
|
11
11
|
// src/form-textarea.tsx
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/price-format.cjs"],"names":[],"mappings":"AAAA,qFAAY;AACZ;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,gEAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/price-format.cjs"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface PriceFormatConfig {
|
|
2
|
+
/** ISO 4217 currency code. Default: `"USD"`. */
|
|
3
|
+
currency?: string;
|
|
4
|
+
/** BCP 47 locale. Default: `"en-US"`. */
|
|
5
|
+
locale?: string;
|
|
6
|
+
/** Decimal places. Default: `2`. */
|
|
7
|
+
precision?: number;
|
|
8
|
+
}
|
|
9
|
+
interface FormatPriceOptions {
|
|
10
|
+
/** Override precision for this call. */
|
|
11
|
+
precision?: number;
|
|
12
|
+
/** Multiply value by quantity before formatting. */
|
|
13
|
+
quantity?: number;
|
|
14
|
+
}
|
|
15
|
+
declare function createFormatPrice(config?: PriceFormatConfig): (value: number, options?: FormatPriceOptions) => string;
|
|
16
|
+
|
|
17
|
+
export { type FormatPriceOptions, type PriceFormatConfig, createFormatPrice };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface PriceFormatConfig {
|
|
2
|
+
/** ISO 4217 currency code. Default: `"USD"`. */
|
|
3
|
+
currency?: string;
|
|
4
|
+
/** BCP 47 locale. Default: `"en-US"`. */
|
|
5
|
+
locale?: string;
|
|
6
|
+
/** Decimal places. Default: `2`. */
|
|
7
|
+
precision?: number;
|
|
8
|
+
}
|
|
9
|
+
interface FormatPriceOptions {
|
|
10
|
+
/** Override precision for this call. */
|
|
11
|
+
precision?: number;
|
|
12
|
+
/** Multiply value by quantity before formatting. */
|
|
13
|
+
quantity?: number;
|
|
14
|
+
}
|
|
15
|
+
declare function createFormatPrice(config?: PriceFormatConfig): (value: number, options?: FormatPriceOptions) => string;
|
|
16
|
+
|
|
17
|
+
export { type FormatPriceOptions, type PriceFormatConfig, createFormatPrice };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/price.cjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
2
2
|
"use client";
|
|
3
3
|
|
|
4
|
+
|
|
5
|
+
var _chunkVT4JLAIEcjs = require('./chunk-VT4JLAIE.cjs');
|
|
6
|
+
|
|
4
7
|
// src/price.tsx
|
|
5
8
|
var _web = require('@simpleapps-com/augur-utils/web');
|
|
6
9
|
var _jsxruntime = require('react/jsx-runtime');
|
|
@@ -15,26 +18,38 @@ function createPrice(config = {}) {
|
|
|
15
18
|
const {
|
|
16
19
|
currency,
|
|
17
20
|
locale,
|
|
18
|
-
precision
|
|
21
|
+
precision,
|
|
19
22
|
zeroLabel,
|
|
20
|
-
uomSeparator
|
|
23
|
+
uomSeparator,
|
|
24
|
+
classNames: factoryClassNames
|
|
21
25
|
} = { ...defaults, ...config };
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const formatPrice = _chunkVT4JLAIEcjs.createFormatPrice.call(void 0, { currency, locale, precision });
|
|
27
|
+
const slotKeys = [
|
|
28
|
+
"amount",
|
|
29
|
+
"uom",
|
|
30
|
+
"separator",
|
|
31
|
+
"zero",
|
|
32
|
+
"skeleton",
|
|
33
|
+
"original"
|
|
34
|
+
];
|
|
35
|
+
function mergeClassNames(instance) {
|
|
36
|
+
if (!factoryClassNames && !instance) return {};
|
|
37
|
+
const result = {};
|
|
38
|
+
for (const key of slotKeys) {
|
|
39
|
+
const merged = _web.cn.call(void 0, _optionalChain([factoryClassNames, 'optionalAccess', _ => _[key]]), _optionalChain([instance, 'optionalAccess', _2 => _2[key]]));
|
|
40
|
+
if (merged) result[key] = merged;
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
30
43
|
}
|
|
31
44
|
function Price(props) {
|
|
32
45
|
if ("loading" in props && props.loading) {
|
|
46
|
+
const slots2 = mergeClassNames(props.classNames);
|
|
33
47
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
34
48
|
"span",
|
|
35
49
|
{
|
|
36
50
|
className: _web.cn.call(void 0,
|
|
37
51
|
"inline-block h-4 w-16 animate-pulse rounded bg-muted",
|
|
52
|
+
slots2.skeleton,
|
|
38
53
|
props.className
|
|
39
54
|
)
|
|
40
55
|
}
|
|
@@ -44,22 +59,25 @@ function createPrice(config = {}) {
|
|
|
44
59
|
value = 0,
|
|
45
60
|
quantity,
|
|
46
61
|
uom,
|
|
47
|
-
precision,
|
|
62
|
+
precision: instancePrecision,
|
|
48
63
|
originalValue,
|
|
49
|
-
className
|
|
64
|
+
className,
|
|
65
|
+
classNames: instanceClassNames
|
|
50
66
|
} = props;
|
|
67
|
+
const slots = mergeClassNames(instanceClassNames);
|
|
51
68
|
if (value === 0 && originalValue === void 0) {
|
|
52
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: _web.cn.call(void 0, "text-muted-foreground", className), children: zeroLabel });
|
|
69
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: _web.cn.call(void 0, "text-muted-foreground", slots.zero, className), children: zeroLabel });
|
|
53
70
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
71
|
+
const formatted = formatPrice(value, {
|
|
72
|
+
precision: instancePrecision,
|
|
73
|
+
quantity
|
|
74
|
+
});
|
|
56
75
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className, children: [
|
|
57
|
-
originalValue !== void 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "s", { className: "mr-1 text-muted-foreground", children: formatPrice(originalValue, { precision }) }),
|
|
58
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: formatted }),
|
|
59
|
-
uom && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
60
|
-
uomSeparator,
|
|
61
|
-
" ",
|
|
62
|
-
uom
|
|
76
|
+
originalValue !== void 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "s", { className: _web.cn.call(void 0, "mr-1 text-muted-foreground", slots.original), children: formatPrice(originalValue, { precision: instancePrecision }) }),
|
|
77
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: slots.amount, children: formatted }),
|
|
78
|
+
uom && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
79
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: _web.cn.call(void 0, "ml-1", slots.separator), children: uomSeparator }),
|
|
80
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: _web.cn.call(void 0, "ml-1 text-muted-foreground", slots.uom), children: uom })
|
|
63
81
|
] })
|
|
64
82
|
] });
|
|
65
83
|
}
|
package/dist/price.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/price.cjs","../src/price.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/price.cjs","../src/price.tsx"],"names":["slots"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AA,WAAA,CAAY,aAAA,EAAe,EAAE,SAAA,EAAW,kBAAkB,CAAC,EAAA,CAC9D,CAAA;AAAA,sBAEF,6BAAA,MAAC,EAAA,EAAK,SAAA,EAAW,KAAA,CAAM,MAAA,EAAS,QAAA,EAAA,UAAA,CAAU,CAAA;AAAA,MACzC,IAAA,mBACC,8BAAA,oBAAA,EAAA,EACE,QAAA,EAAA;AAAA,wBAAA,6BAAA,MAAC,EAAA,EAAK,SAAA,EAAW,qBAAA,MAAG,EAAQ,KAAA,CAAM,SAAS,CAAA,EACxC,QAAA,EAAA,aAAA,CACH,CAAA;AAAA,wBACA,6BAAA,MAAC,EAAA,EAAK,SAAA,EAAW,qBAAA,4BAAG,EAA8B,KAAA,CAAM,GAAG,CAAA,EACxD,QAAA,EAAA,IAAA,CACH;AAAA,MAAA,EAAA,CACF;AAAA,IAAA,EAAA,CAEJ,CAAA;AAAA,EAEJ;AAEA,EAAA,KAAA,CAAM,YAAA,EAAc,OAAA;AAEpB,EAAA,OAAO,EAAE,KAAA,EAAO,YAAY,CAAA;AAC9B;ADvFA;AACE;AACF,kCAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/price.cjs","sourcesContent":[null,"\"use client\";\n\nimport { cn } from \"@simpleapps-com/augur-utils/web\";\nimport { createFormatPrice } from \"./price-format\";\nimport type { FormatPriceOptions } from \"./price-format\";\n\n// Re-export server-safe types so client consumers get everything from one path\nexport type { PriceFormatConfig, FormatPriceOptions } from \"./price-format\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface PriceClassNames {\n /** The formatted amount text. */\n amount?: string;\n /** The UOM label (e.g. \"EACH\"). */\n uom?: string;\n /** The separator between price and UOM (e.g. \"/\"). */\n separator?: string;\n /** The zero-price label (e.g. \"Call for Price\"). */\n zero?: string;\n /** The loading skeleton. */\n skeleton?: string;\n /** The strikethrough original price. */\n original?: string;\n}\n\nexport interface PriceConfig {\n /** ISO 4217 currency code. Default: `\"USD\"`. */\n currency?: string;\n /** BCP 47 locale. Default: `\"en-US\"`. */\n locale?: string;\n /** Decimal places. Default: `2`. */\n precision?: number;\n /** Label shown when value is 0. Default: `\"Call for Price\"`. */\n zeroLabel?: string;\n /** Separator between price and UOM. Default: `\"/\"`. */\n uomSeparator?: string;\n /** Default class names for sub-elements. */\n classNames?: PriceClassNames;\n}\n\ntype PricePropsBase = {\n /** Unit price. */\n value?: number;\n /** Quantity — multiplied by value for extended price. */\n quantity?: number;\n /** Unit of measure label (e.g. \"EACH\", \"FT\"). */\n uom?: string;\n /** Override precision for this instance. */\n precision?: number;\n /** Original price shown as strikethrough for sale display. */\n originalValue?: number;\n /** Additional class names for the root element. */\n className?: string;\n /** Class names for sub-elements, merged with factory defaults. */\n classNames?: PriceClassNames;\n};\n\nexport type PriceProps =\n | (PricePropsBase & { loading?: false })\n | { loading: true; className?: string; classNames?: PriceClassNames };\n\nexport interface CreatePriceResult {\n Price: React.FC<PriceProps>;\n formatPrice: (value: number, options?: FormatPriceOptions) => string;\n}\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nconst defaults = {\n currency: \"USD\",\n locale: \"en-US\",\n precision: 2,\n zeroLabel: \"Call for Price\",\n uomSeparator: \"/\",\n} as const;\n\nexport function createPrice(config: PriceConfig = {}): CreatePriceResult {\n const {\n currency,\n locale,\n precision,\n zeroLabel,\n uomSeparator,\n classNames: factoryClassNames,\n } = { ...defaults, ...config };\n\n const formatPrice = createFormatPrice({ currency, locale, precision });\n\n const slotKeys: (keyof PriceClassNames)[] = [\n \"amount\", \"uom\", \"separator\", \"zero\", \"skeleton\", \"original\",\n ];\n\n function mergeClassNames(\n instance?: PriceClassNames,\n ): PriceClassNames {\n if (!factoryClassNames && !instance) return {};\n const result: PriceClassNames = {};\n for (const key of slotKeys) {\n const merged = cn(factoryClassNames?.[key], instance?.[key]);\n if (merged) result[key] = merged;\n }\n return result;\n }\n\n function Price(props: PriceProps) {\n if (\"loading\" in props && props.loading) {\n const slots = mergeClassNames(props.classNames);\n return (\n <span\n className={cn(\n \"inline-block h-4 w-16 animate-pulse rounded bg-muted\",\n slots.skeleton,\n props.className,\n )}\n />\n );\n }\n\n const {\n value = 0,\n quantity,\n uom,\n precision: instancePrecision,\n originalValue,\n className,\n classNames: instanceClassNames,\n } = props as PricePropsBase;\n\n const slots = mergeClassNames(instanceClassNames);\n\n if (value === 0 && originalValue === undefined) {\n return (\n <span className={cn(\"text-muted-foreground\", slots.zero, className)}>\n {zeroLabel}\n </span>\n );\n }\n\n const formatted = formatPrice(value, {\n precision: instancePrecision,\n quantity,\n });\n\n return (\n <span className={className}>\n {originalValue !== undefined && (\n <s className={cn(\"mr-1 text-muted-foreground\", slots.original)}>\n {formatPrice(originalValue, { precision: instancePrecision })}\n </s>\n )}\n <span className={slots.amount}>{formatted}</span>\n {uom && (\n <>\n <span className={cn(\"ml-1\", slots.separator)}>\n {uomSeparator}\n </span>\n <span className={cn(\"ml-1 text-muted-foreground\", slots.uom)}>\n {uom}\n </span>\n </>\n )}\n </span>\n );\n }\n\n Price.displayName = \"Price\";\n\n return { Price, formatPrice };\n}\n"]}
|
package/dist/price.d.cts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
import { FormatPriceOptions } from './price-format.cjs';
|
|
2
|
+
export { PriceFormatConfig } from './price-format.cjs';
|
|
3
|
+
|
|
4
|
+
interface PriceClassNames {
|
|
5
|
+
/** The formatted amount text. */
|
|
6
|
+
amount?: string;
|
|
7
|
+
/** The UOM label (e.g. "EACH"). */
|
|
8
|
+
uom?: string;
|
|
9
|
+
/** The separator between price and UOM (e.g. "/"). */
|
|
10
|
+
separator?: string;
|
|
11
|
+
/** The zero-price label (e.g. "Call for Price"). */
|
|
12
|
+
zero?: string;
|
|
13
|
+
/** The loading skeleton. */
|
|
14
|
+
skeleton?: string;
|
|
15
|
+
/** The strikethrough original price. */
|
|
16
|
+
original?: string;
|
|
17
|
+
}
|
|
1
18
|
interface PriceConfig {
|
|
2
19
|
/** ISO 4217 currency code. Default: `"USD"`. */
|
|
3
20
|
currency?: string;
|
|
@@ -9,6 +26,8 @@ interface PriceConfig {
|
|
|
9
26
|
zeroLabel?: string;
|
|
10
27
|
/** Separator between price and UOM. Default: `"/"`. */
|
|
11
28
|
uomSeparator?: string;
|
|
29
|
+
/** Default class names for sub-elements. */
|
|
30
|
+
classNames?: PriceClassNames;
|
|
12
31
|
}
|
|
13
32
|
type PricePropsBase = {
|
|
14
33
|
/** Unit price. */
|
|
@@ -23,20 +42,20 @@ type PricePropsBase = {
|
|
|
23
42
|
originalValue?: number;
|
|
24
43
|
/** Additional class names for the root element. */
|
|
25
44
|
className?: string;
|
|
45
|
+
/** Class names for sub-elements, merged with factory defaults. */
|
|
46
|
+
classNames?: PriceClassNames;
|
|
26
47
|
};
|
|
27
48
|
type PriceProps = (PricePropsBase & {
|
|
28
49
|
loading?: false;
|
|
29
50
|
}) | {
|
|
30
51
|
loading: true;
|
|
31
52
|
className?: string;
|
|
53
|
+
classNames?: PriceClassNames;
|
|
32
54
|
};
|
|
33
|
-
interface FormatPriceOptions {
|
|
34
|
-
precision?: number;
|
|
35
|
-
}
|
|
36
55
|
interface CreatePriceResult {
|
|
37
56
|
Price: React.FC<PriceProps>;
|
|
38
57
|
formatPrice: (value: number, options?: FormatPriceOptions) => string;
|
|
39
58
|
}
|
|
40
59
|
declare function createPrice(config?: PriceConfig): CreatePriceResult;
|
|
41
60
|
|
|
42
|
-
export { type CreatePriceResult, type
|
|
61
|
+
export { type CreatePriceResult, FormatPriceOptions, type PriceClassNames, type PriceConfig, type PriceProps, createPrice };
|
package/dist/price.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
import { FormatPriceOptions } from './price-format.js';
|
|
2
|
+
export { PriceFormatConfig } from './price-format.js';
|
|
3
|
+
|
|
4
|
+
interface PriceClassNames {
|
|
5
|
+
/** The formatted amount text. */
|
|
6
|
+
amount?: string;
|
|
7
|
+
/** The UOM label (e.g. "EACH"). */
|
|
8
|
+
uom?: string;
|
|
9
|
+
/** The separator between price and UOM (e.g. "/"). */
|
|
10
|
+
separator?: string;
|
|
11
|
+
/** The zero-price label (e.g. "Call for Price"). */
|
|
12
|
+
zero?: string;
|
|
13
|
+
/** The loading skeleton. */
|
|
14
|
+
skeleton?: string;
|
|
15
|
+
/** The strikethrough original price. */
|
|
16
|
+
original?: string;
|
|
17
|
+
}
|
|
1
18
|
interface PriceConfig {
|
|
2
19
|
/** ISO 4217 currency code. Default: `"USD"`. */
|
|
3
20
|
currency?: string;
|
|
@@ -9,6 +26,8 @@ interface PriceConfig {
|
|
|
9
26
|
zeroLabel?: string;
|
|
10
27
|
/** Separator between price and UOM. Default: `"/"`. */
|
|
11
28
|
uomSeparator?: string;
|
|
29
|
+
/** Default class names for sub-elements. */
|
|
30
|
+
classNames?: PriceClassNames;
|
|
12
31
|
}
|
|
13
32
|
type PricePropsBase = {
|
|
14
33
|
/** Unit price. */
|
|
@@ -23,20 +42,20 @@ type PricePropsBase = {
|
|
|
23
42
|
originalValue?: number;
|
|
24
43
|
/** Additional class names for the root element. */
|
|
25
44
|
className?: string;
|
|
45
|
+
/** Class names for sub-elements, merged with factory defaults. */
|
|
46
|
+
classNames?: PriceClassNames;
|
|
26
47
|
};
|
|
27
48
|
type PriceProps = (PricePropsBase & {
|
|
28
49
|
loading?: false;
|
|
29
50
|
}) | {
|
|
30
51
|
loading: true;
|
|
31
52
|
className?: string;
|
|
53
|
+
classNames?: PriceClassNames;
|
|
32
54
|
};
|
|
33
|
-
interface FormatPriceOptions {
|
|
34
|
-
precision?: number;
|
|
35
|
-
}
|
|
36
55
|
interface CreatePriceResult {
|
|
37
56
|
Price: React.FC<PriceProps>;
|
|
38
57
|
formatPrice: (value: number, options?: FormatPriceOptions) => string;
|
|
39
58
|
}
|
|
40
59
|
declare function createPrice(config?: PriceConfig): CreatePriceResult;
|
|
41
60
|
|
|
42
|
-
export { type CreatePriceResult, type
|
|
61
|
+
export { type CreatePriceResult, FormatPriceOptions, type PriceClassNames, type PriceConfig, type PriceProps, createPrice };
|
package/dist/price.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
+
import {
|
|
4
|
+
createFormatPrice
|
|
5
|
+
} from "./chunk-PTAWV5SA.js";
|
|
3
6
|
|
|
4
7
|
// src/price.tsx
|
|
5
8
|
import { cn } from "@simpleapps-com/augur-utils/web";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
10
|
var defaults = {
|
|
8
11
|
currency: "USD",
|
|
9
12
|
locale: "en-US",
|
|
@@ -15,26 +18,38 @@ function createPrice(config = {}) {
|
|
|
15
18
|
const {
|
|
16
19
|
currency,
|
|
17
20
|
locale,
|
|
18
|
-
precision
|
|
21
|
+
precision,
|
|
19
22
|
zeroLabel,
|
|
20
|
-
uomSeparator
|
|
23
|
+
uomSeparator,
|
|
24
|
+
classNames: factoryClassNames
|
|
21
25
|
} = { ...defaults, ...config };
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const formatPrice = createFormatPrice({ currency, locale, precision });
|
|
27
|
+
const slotKeys = [
|
|
28
|
+
"amount",
|
|
29
|
+
"uom",
|
|
30
|
+
"separator",
|
|
31
|
+
"zero",
|
|
32
|
+
"skeleton",
|
|
33
|
+
"original"
|
|
34
|
+
];
|
|
35
|
+
function mergeClassNames(instance) {
|
|
36
|
+
if (!factoryClassNames && !instance) return {};
|
|
37
|
+
const result = {};
|
|
38
|
+
for (const key of slotKeys) {
|
|
39
|
+
const merged = cn(factoryClassNames?.[key], instance?.[key]);
|
|
40
|
+
if (merged) result[key] = merged;
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
30
43
|
}
|
|
31
44
|
function Price(props) {
|
|
32
45
|
if ("loading" in props && props.loading) {
|
|
46
|
+
const slots2 = mergeClassNames(props.classNames);
|
|
33
47
|
return /* @__PURE__ */ jsx(
|
|
34
48
|
"span",
|
|
35
49
|
{
|
|
36
50
|
className: cn(
|
|
37
51
|
"inline-block h-4 w-16 animate-pulse rounded bg-muted",
|
|
52
|
+
slots2.skeleton,
|
|
38
53
|
props.className
|
|
39
54
|
)
|
|
40
55
|
}
|
|
@@ -44,22 +59,25 @@ function createPrice(config = {}) {
|
|
|
44
59
|
value = 0,
|
|
45
60
|
quantity,
|
|
46
61
|
uom,
|
|
47
|
-
precision,
|
|
62
|
+
precision: instancePrecision,
|
|
48
63
|
originalValue,
|
|
49
|
-
className
|
|
64
|
+
className,
|
|
65
|
+
classNames: instanceClassNames
|
|
50
66
|
} = props;
|
|
67
|
+
const slots = mergeClassNames(instanceClassNames);
|
|
51
68
|
if (value === 0 && originalValue === void 0) {
|
|
52
|
-
return /* @__PURE__ */ jsx("span", { className: cn("text-muted-foreground", className), children: zeroLabel });
|
|
69
|
+
return /* @__PURE__ */ jsx("span", { className: cn("text-muted-foreground", slots.zero, className), children: zeroLabel });
|
|
53
70
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
71
|
+
const formatted = formatPrice(value, {
|
|
72
|
+
precision: instancePrecision,
|
|
73
|
+
quantity
|
|
74
|
+
});
|
|
56
75
|
return /* @__PURE__ */ jsxs("span", { className, children: [
|
|
57
|
-
originalValue !== void 0 && /* @__PURE__ */ jsx("s", { className: "mr-1 text-muted-foreground", children: formatPrice(originalValue, { precision }) }),
|
|
58
|
-
/* @__PURE__ */ jsx("span", { children: formatted }),
|
|
59
|
-
uom && /* @__PURE__ */ jsxs(
|
|
60
|
-
uomSeparator,
|
|
61
|
-
" ",
|
|
62
|
-
uom
|
|
76
|
+
originalValue !== void 0 && /* @__PURE__ */ jsx("s", { className: cn("mr-1 text-muted-foreground", slots.original), children: formatPrice(originalValue, { precision: instancePrecision }) }),
|
|
77
|
+
/* @__PURE__ */ jsx("span", { className: slots.amount, children: formatted }),
|
|
78
|
+
uom && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
79
|
+
/* @__PURE__ */ jsx("span", { className: cn("ml-1", slots.separator), children: uomSeparator }),
|
|
80
|
+
/* @__PURE__ */ jsx("span", { className: cn("ml-1 text-muted-foreground", slots.uom), children: uom })
|
|
63
81
|
] })
|
|
64
82
|
] });
|
|
65
83
|
}
|
package/dist/price.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/price.tsx"],"sourcesContent":["\"use client\";\n\nimport { cn } from \"@simpleapps-com/augur-utils/web\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface PriceConfig {\n /** ISO 4217 currency code. Default: `\"USD\"`. */\n currency?: string;\n /** BCP 47 locale. Default: `\"en-US\"`. */\n locale?: string;\n /** Decimal places. Default: `2`. */\n precision?: number;\n /** Label shown when value is 0. Default: `\"Call for Price\"`. */\n zeroLabel?: string;\n /** Separator between price and UOM. Default: `\"/\"`. */\n uomSeparator?: string;\n}\n\ntype PricePropsBase = {\n /** Unit price. */\n value?: number;\n /** Quantity — multiplied by value for extended price. */\n quantity?: number;\n /** Unit of measure label (e.g. \"EACH\", \"FT\"). */\n uom?: string;\n /** Override precision for this instance. */\n precision?: number;\n /** Original price shown as strikethrough for sale display. */\n originalValue?: number;\n /** Additional class names for the root element. */\n className?: string;\n};\n\nexport type PriceProps =\n | (PricePropsBase & { loading?: false })\n | { loading: true; className?: string
|
|
1
|
+
{"version":3,"sources":["../src/price.tsx"],"sourcesContent":["\"use client\";\n\nimport { cn } from \"@simpleapps-com/augur-utils/web\";\nimport { createFormatPrice } from \"./price-format\";\nimport type { FormatPriceOptions } from \"./price-format\";\n\n// Re-export server-safe types so client consumers get everything from one path\nexport type { PriceFormatConfig, FormatPriceOptions } from \"./price-format\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface PriceClassNames {\n /** The formatted amount text. */\n amount?: string;\n /** The UOM label (e.g. \"EACH\"). */\n uom?: string;\n /** The separator between price and UOM (e.g. \"/\"). */\n separator?: string;\n /** The zero-price label (e.g. \"Call for Price\"). */\n zero?: string;\n /** The loading skeleton. */\n skeleton?: string;\n /** The strikethrough original price. */\n original?: string;\n}\n\nexport interface PriceConfig {\n /** ISO 4217 currency code. Default: `\"USD\"`. */\n currency?: string;\n /** BCP 47 locale. Default: `\"en-US\"`. */\n locale?: string;\n /** Decimal places. Default: `2`. */\n precision?: number;\n /** Label shown when value is 0. Default: `\"Call for Price\"`. */\n zeroLabel?: string;\n /** Separator between price and UOM. Default: `\"/\"`. */\n uomSeparator?: string;\n /** Default class names for sub-elements. */\n classNames?: PriceClassNames;\n}\n\ntype PricePropsBase = {\n /** Unit price. */\n value?: number;\n /** Quantity — multiplied by value for extended price. */\n quantity?: number;\n /** Unit of measure label (e.g. \"EACH\", \"FT\"). */\n uom?: string;\n /** Override precision for this instance. */\n precision?: number;\n /** Original price shown as strikethrough for sale display. */\n originalValue?: number;\n /** Additional class names for the root element. */\n className?: string;\n /** Class names for sub-elements, merged with factory defaults. */\n classNames?: PriceClassNames;\n};\n\nexport type PriceProps =\n | (PricePropsBase & { loading?: false })\n | { loading: true; className?: string; classNames?: PriceClassNames };\n\nexport interface CreatePriceResult {\n Price: React.FC<PriceProps>;\n formatPrice: (value: number, options?: FormatPriceOptions) => string;\n}\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nconst defaults = {\n currency: \"USD\",\n locale: \"en-US\",\n precision: 2,\n zeroLabel: \"Call for Price\",\n uomSeparator: \"/\",\n} as const;\n\nexport function createPrice(config: PriceConfig = {}): CreatePriceResult {\n const {\n currency,\n locale,\n precision,\n zeroLabel,\n uomSeparator,\n classNames: factoryClassNames,\n } = { ...defaults, ...config };\n\n const formatPrice = createFormatPrice({ currency, locale, precision });\n\n const slotKeys: (keyof PriceClassNames)[] = [\n \"amount\", \"uom\", \"separator\", \"zero\", \"skeleton\", \"original\",\n ];\n\n function mergeClassNames(\n instance?: PriceClassNames,\n ): PriceClassNames {\n if (!factoryClassNames && !instance) return {};\n const result: PriceClassNames = {};\n for (const key of slotKeys) {\n const merged = cn(factoryClassNames?.[key], instance?.[key]);\n if (merged) result[key] = merged;\n }\n return result;\n }\n\n function Price(props: PriceProps) {\n if (\"loading\" in props && props.loading) {\n const slots = mergeClassNames(props.classNames);\n return (\n <span\n className={cn(\n \"inline-block h-4 w-16 animate-pulse rounded bg-muted\",\n slots.skeleton,\n props.className,\n )}\n />\n );\n }\n\n const {\n value = 0,\n quantity,\n uom,\n precision: instancePrecision,\n originalValue,\n className,\n classNames: instanceClassNames,\n } = props as PricePropsBase;\n\n const slots = mergeClassNames(instanceClassNames);\n\n if (value === 0 && originalValue === undefined) {\n return (\n <span className={cn(\"text-muted-foreground\", slots.zero, className)}>\n {zeroLabel}\n </span>\n );\n }\n\n const formatted = formatPrice(value, {\n precision: instancePrecision,\n quantity,\n });\n\n return (\n <span className={className}>\n {originalValue !== undefined && (\n <s className={cn(\"mr-1 text-muted-foreground\", slots.original)}>\n {formatPrice(originalValue, { precision: instancePrecision })}\n </s>\n )}\n <span className={slots.amount}>{formatted}</span>\n {uom && (\n <>\n <span className={cn(\"ml-1\", slots.separator)}>\n {uomSeparator}\n </span>\n <span className={cn(\"ml-1 text-muted-foreground\", slots.uom)}>\n {uom}\n </span>\n </>\n )}\n </span>\n );\n }\n\n Price.displayName = \"Price\";\n\n return { Price, formatPrice };\n}\n"],"mappings":";;;;;;;AAEA,SAAS,UAAU;AA+GX,SA4CE,UA5CF,KA4CE,YA5CF;AAxCR,IAAM,WAAW;AAAA,EACf,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AAAA,EACX,cAAc;AAChB;AAEO,SAAS,YAAY,SAAsB,CAAC,GAAsB;AACvE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,I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Ae,EAAE,WAAW,kBAAkB,CAAC,GAC9D;AAAA,MAEF,oBAAC,UAAK,WAAW,MAAM,QAAS,qBAAU;AAAA,MACzC,OACC,iCACE;AAAA,4BAAC,UAAK,WAAW,GAAG,QAAQ,MAAM,SAAS,GACxC,wBACH;AAAA,QACA,oBAAC,UAAK,WAAW,GAAG,8BAA8B,MAAM,GAAG,GACxD,eACH;AAAA,SACF;AAAA,OAEJ;AAAA,EAEJ;AAEA,QAAM,cAAc;AAEpB,SAAO,EAAE,OAAO,YAAY;AAC9B;","names":["slots"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleapps-com/augur-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "Shared React UI components for Augur ecommerce sites (Radix + Tailwind)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -65,6 +65,11 @@
|
|
|
65
65
|
"import": "./dist/price.js",
|
|
66
66
|
"require": "./dist/price.cjs"
|
|
67
67
|
},
|
|
68
|
+
"./price-format": {
|
|
69
|
+
"types": "./dist/price-format.d.ts",
|
|
70
|
+
"import": "./dist/price-format.js",
|
|
71
|
+
"require": "./dist/price-format.cjs"
|
|
72
|
+
},
|
|
68
73
|
"./radio-group": {
|
|
69
74
|
"types": "./dist/radio-group.d.ts",
|
|
70
75
|
"import": "./dist/radio-group.js",
|
|
@@ -176,7 +181,7 @@
|
|
|
176
181
|
"dist"
|
|
177
182
|
],
|
|
178
183
|
"dependencies": {
|
|
179
|
-
"@simpleapps-com/augur-utils": "0.2.
|
|
184
|
+
"@simpleapps-com/augur-utils": "0.2.17"
|
|
180
185
|
},
|
|
181
186
|
"peerDependencies": {
|
|
182
187
|
"@radix-ui/react-accordion": "^1.2.0",
|