@azx-pbc/axiom-web 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +161 -2
- package/dist/address.d.ts +32 -0
- package/dist/address.d.ts.map +1 -0
- package/dist/address.js +146 -0
- package/dist/address.js.map +1 -0
- package/dist/capture/MediaCapture.d.ts +45 -0
- package/dist/capture/MediaCapture.d.ts.map +1 -0
- package/dist/capture/MediaCapture.js +669 -0
- package/dist/capture/MediaCapture.js.map +1 -0
- package/dist/capture/SignatureCapture.d.ts +31 -0
- package/dist/capture/SignatureCapture.d.ts.map +1 -0
- package/dist/capture/SignatureCapture.js +329 -0
- package/dist/capture/SignatureCapture.js.map +1 -0
- package/dist/capture/copy.d.ts +101 -0
- package/dist/capture/copy.d.ts.map +1 -0
- package/dist/capture/copy.js +1369 -0
- package/dist/capture/copy.js.map +1 -0
- package/dist/capture/index.d.ts +19 -0
- package/dist/capture/index.d.ts.map +1 -0
- package/dist/capture/index.js +14 -0
- package/dist/capture/index.js.map +1 -0
- package/dist/capture/media-kind.d.ts +16 -0
- package/dist/capture/media-kind.d.ts.map +1 -0
- package/dist/capture/media-kind.js +64 -0
- package/dist/capture/media-kind.js.map +1 -0
- package/dist/capture/permissions.d.ts +109 -0
- package/dist/capture/permissions.d.ts.map +1 -0
- package/dist/capture/permissions.js +172 -0
- package/dist/capture/permissions.js.map +1 -0
- package/dist/capture/refusal.d.ts +13 -0
- package/dist/capture/refusal.d.ts.map +1 -0
- package/dist/capture/refusal.js +16 -0
- package/dist/capture/refusal.js.map +1 -0
- package/dist/controls.d.ts +64 -0
- package/dist/controls.d.ts.map +1 -0
- package/dist/controls.js +2524 -0
- package/dist/controls.js.map +1 -0
- package/dist/coordinate.d.ts +38 -0
- package/dist/coordinate.d.ts.map +1 -0
- package/dist/coordinate.js +220 -0
- package/dist/coordinate.js.map +1 -0
- package/dist/copy.d.ts +313 -0
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +2602 -0
- package/dist/copy.js.map +1 -0
- package/dist/countries.d.ts +14 -0
- package/dist/countries.d.ts.map +1 -0
- package/dist/countries.js +264 -0
- package/dist/countries.js.map +1 -0
- package/dist/format/calendar-locale.d.ts +19 -0
- package/dist/format/calendar-locale.d.ts.map +1 -0
- package/dist/format/calendar-locale.js +38 -0
- package/dist/format/calendar-locale.js.map +1 -0
- package/dist/format/country-names.d.ts +21 -0
- package/dist/format/country-names.d.ts.map +1 -0
- package/dist/format/country-names.js +2277 -0
- package/dist/format/country-names.js.map +1 -0
- package/dist/format/date.d.ts +58 -0
- package/dist/format/date.d.ts.map +1 -0
- package/dist/format/date.js +155 -0
- package/dist/format/date.js.map +1 -0
- package/dist/format/digits.d.ts +23 -0
- package/dist/format/digits.d.ts.map +1 -0
- package/dist/format/digits.js +46 -0
- package/dist/format/digits.js.map +1 -0
- package/dist/format/index.d.ts +28 -0
- package/dist/format/index.d.ts.map +1 -0
- package/dist/format/index.js +24 -0
- package/dist/format/index.js.map +1 -0
- package/dist/format/invariant.d.ts +8 -0
- package/dist/format/invariant.d.ts.map +1 -0
- package/dist/format/invariant.js +10 -0
- package/dist/format/invariant.js.map +1 -0
- package/dist/format/locale.d.ts +33 -0
- package/dist/format/locale.d.ts.map +1 -0
- package/dist/format/locale.js +39 -0
- package/dist/format/locale.js.map +1 -0
- package/dist/format/media-type.d.ts +8 -0
- package/dist/format/media-type.d.ts.map +1 -0
- package/dist/format/media-type.js +302 -0
- package/dist/format/media-type.js.map +1 -0
- package/dist/format/money.d.ts +52 -0
- package/dist/format/money.d.ts.map +1 -0
- package/dist/format/money.js +36 -0
- package/dist/format/money.js.map +1 -0
- package/dist/format/number.d.ts +28 -0
- package/dist/format/number.d.ts.map +1 -0
- package/dist/format/number.js +91 -0
- package/dist/format/number.js.map +1 -0
- package/dist/host.d.ts +122 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +20 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/media.d.ts +42 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +151 -0
- package/dist/media.js.map +1 -0
- package/dist/pickers/DatePicker.d.ts +35 -0
- package/dist/pickers/DatePicker.d.ts.map +1 -0
- package/dist/pickers/DatePicker.js +212 -0
- package/dist/pickers/DatePicker.js.map +1 -0
- package/dist/pickers/TimeSegments.d.ts +27 -0
- package/dist/pickers/TimeSegments.d.ts.map +1 -0
- package/dist/pickers/TimeSegments.js +82 -0
- package/dist/pickers/TimeSegments.js.map +1 -0
- package/dist/pickers/day-picker-locale.d.ts +15 -0
- package/dist/pickers/day-picker-locale.d.ts.map +1 -0
- package/dist/pickers/day-picker-locale.js +46 -0
- package/dist/pickers/day-picker-locale.js.map +1 -0
- package/dist/render/dom.d.ts +100 -0
- package/dist/render/dom.d.ts.map +1 -0
- package/dist/render/dom.js +882 -0
- package/dist/render/dom.js.map +1 -0
- package/dist/render/layout.d.ts +45 -0
- package/dist/render/layout.d.ts.map +1 -0
- package/dist/render/layout.js +8 -0
- package/dist/render/layout.js.map +1 -0
- package/dist/schedule/SchedulePicker.d.ts +46 -0
- package/dist/schedule/SchedulePicker.d.ts.map +1 -0
- package/dist/schedule/SchedulePicker.js +160 -0
- package/dist/schedule/SchedulePicker.js.map +1 -0
- package/dist/schedule/timeslot.d.ts +52 -0
- package/dist/schedule/timeslot.d.ts.map +1 -0
- package/dist/schedule/timeslot.js +265 -0
- package/dist/schedule/timeslot.js.map +1 -0
- package/dist/styles.css +2151 -0
- package/dist/theme/index.d.ts +12 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +11 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/presets.d.ts +93 -0
- package/dist/theme/presets.d.ts.map +1 -0
- package/dist/theme/presets.js +200 -0
- package/dist/theme/presets.js.map +1 -0
- package/dist/tokens.css +234 -0
- package/dist/wizard-checkpoints.d.ts +18 -0
- package/dist/wizard-checkpoints.d.ts.map +1 -0
- package/dist/wizard-checkpoints.js +56 -0
- package/dist/wizard-checkpoints.js.map +1 -0
- package/package.json +76 -3
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CURRENCY_CODE_PATTERN } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import { DEFAULT_DIGIT_POLICY } from './digits.js';
|
|
3
|
+
import { groupCanonicalNumericText } from './number.js';
|
|
4
|
+
const CANONICAL_MONEY_TEXT_PATTERN = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]{1,6})?$/;
|
|
5
|
+
/**
|
|
6
|
+
* True when `value` is the `.`-separated money text a declared scale produces.
|
|
7
|
+
*
|
|
8
|
+
* The wire allows a scale of `0..6`, so one to six fraction digits is the bound. Negative zero
|
|
9
|
+
* is refused for the same reason the wire refuses `-0`: two spellings of zero would be two
|
|
10
|
+
* amounts to a reader and one amount to the record.
|
|
11
|
+
*/
|
|
12
|
+
export function isCanonicalMoneyText(value) {
|
|
13
|
+
if (typeof value !== 'string' || !CANONICAL_MONEY_TEXT_PATTERN.test(value))
|
|
14
|
+
return false;
|
|
15
|
+
return !value.startsWith('-') || /[1-9]/u.test(value);
|
|
16
|
+
}
|
|
17
|
+
/** True when `value` is three upper-case ASCII letters. */
|
|
18
|
+
export function isCurrencyCode(value) {
|
|
19
|
+
return typeof value === 'string' && CURRENCY_CODE_PATTERN.test(value);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The money display for one amount, locale and currency.
|
|
23
|
+
*
|
|
24
|
+
* The digits, sign and scale are the caller's canonical text unchanged; only the integer part is
|
|
25
|
+
* grouped and only the two marks are localised. CLDR's `minimumGroupingDigits` applies: Spanish
|
|
26
|
+
* prints a four-digit amount as `1234,00` and a five-digit one as `12.345,00`, while German
|
|
27
|
+
* prints `1.234,00` at four. The currency is passed through, not printed, because placement
|
|
28
|
+
* belongs to the copy layer.
|
|
29
|
+
*/
|
|
30
|
+
export function formatMoney(amount, locale, currency, policy = DEFAULT_DIGIT_POLICY) {
|
|
31
|
+
return {
|
|
32
|
+
amount: groupCanonicalNumericText(amount, locale, policy),
|
|
33
|
+
currency,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=money.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"money.js","sourceRoot":"","sources":["../../src/format/money.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAgBxD,MAAM,4BAA4B,GAAW,wCAAwC,CAAC;AAEtF;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACzF,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAOD,2DAA2D;AAC3D,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC;AAcD;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CACzB,MAA0B,EAC1B,MAAc,EACd,QAAsB,EACtB,MAAM,GAAgB,oBAAoB;IAE1C,OAAO;QACL,MAAM,EAAE,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QACzD,QAAQ;KACT,CAAC;AACJ,CAAC","sourcesContent":["import { CURRENCY_CODE_PATTERN } from '@azx-pbc/axiom-runtime';\nimport { DEFAULT_DIGIT_POLICY } from './digits.js';\nimport type { DigitPolicy } from './digits.js';\nimport type { Locale } from './locale.js';\nimport { groupCanonicalNumericText } from './number.js';\n\ndeclare const canonicalMoneyTextBrand: unique symbol;\n\n/**\n * Money text at a declared scale: the `.`-separated amount the existing buffer prints, such as\n * `1200.00` or `-0.50`.\n *\n * It is deliberately not canonical decimal text: a scale of two legitimately keeps two trailing\n * zeros, and the amount is still exact because the declaration, not the spelling, states the\n * scale.\n */\nexport type CanonicalMoneyText = string & {\n readonly [canonicalMoneyTextBrand]: 'CanonicalMoneyText';\n};\n\nconst CANONICAL_MONEY_TEXT_PATTERN: RegExp = /^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]{1,6})?$/;\n\n/**\n * True when `value` is the `.`-separated money text a declared scale produces.\n *\n * The wire allows a scale of `0..6`, so one to six fraction digits is the bound. Negative zero\n * is refused for the same reason the wire refuses `-0`: two spellings of zero would be two\n * amounts to a reader and one amount to the record.\n */\nexport function isCanonicalMoneyText(value: unknown): value is CanonicalMoneyText {\n if (typeof value !== 'string' || !CANONICAL_MONEY_TEXT_PATTERN.test(value)) return false;\n return !value.startsWith('-') || /[1-9]/u.test(value);\n}\n\ndeclare const currencyCodeBrand: unique symbol;\n\n/** An ISO 4217-shaped currency code: three upper-case ASCII letters. */\nexport type CurrencyCode = string & { readonly [currencyCodeBrand]: 'CurrencyCode' };\n\n/** True when `value` is three upper-case ASCII letters. */\nexport function isCurrencyCode(value: unknown): value is CurrencyCode {\n return typeof value === 'string' && CURRENCY_CODE_PATTERN.test(value);\n}\n\n/**\n * One amount as the chrome prints it, with the currency it is denominated in.\n *\n * `amount` carries the locale's grouping and decimal marks and no currency mark at all. The copy\n * layer owns placement, so this function cannot invent a symbol before or after the digits; it\n * returns the currency code beside the amount so the layer that writes the sentence has both.\n */\nexport interface MoneyDisplay {\n readonly amount: string;\n readonly currency: CurrencyCode;\n}\n\n/**\n * The money display for one amount, locale and currency.\n *\n * The digits, sign and scale are the caller's canonical text unchanged; only the integer part is\n * grouped and only the two marks are localised. CLDR's `minimumGroupingDigits` applies: Spanish\n * prints a four-digit amount as `1234,00` and a five-digit one as `12.345,00`, while German\n * prints `1.234,00` at four. The currency is passed through, not printed, because placement\n * belongs to the copy layer.\n */\nexport function formatMoney(\n amount: CanonicalMoneyText,\n locale: Locale,\n currency: CurrencyCode,\n policy: DigitPolicy = DEFAULT_DIGIT_POLICY,\n): MoneyDisplay {\n return {\n amount: groupCanonicalNumericText(amount, locale, policy),\n currency,\n };\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DecimalString } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import type { DigitPolicy } from './digits.js';
|
|
3
|
+
import type { Locale } from './locale.js';
|
|
4
|
+
/**
|
|
5
|
+
* True when `value` is canonical decimal text.
|
|
6
|
+
*
|
|
7
|
+
* The brand is the runtime's own, so a value that passes here is the same value every other
|
|
8
|
+
* package accepts; this module does not mint a second decimal brand. The shape pattern admits
|
|
9
|
+
* `-0` and the canonical language does not, so the one excluded spelling is refused here as
|
|
10
|
+
* the runtime's own constructor refuses it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isDecimalString(value: unknown): value is DecimalString;
|
|
13
|
+
/**
|
|
14
|
+
* Groups the integer part of already-canonical numeric text and writes the locale's two marks.
|
|
15
|
+
*
|
|
16
|
+
* The caller owns the brand: `formatDecimal` hands it a `DecimalString`, and the money formatter
|
|
17
|
+
* hands it money text at a declared scale. The function therefore re-validates nothing; it
|
|
18
|
+
* splits on the canonical `.`, groups the whole part from the right and leaves the fraction's
|
|
19
|
+
* digits in the order the value holds them.
|
|
20
|
+
*/
|
|
21
|
+
export declare function groupCanonicalNumericText(text: string, locale: Locale, policy: DigitPolicy): string;
|
|
22
|
+
/**
|
|
23
|
+
* A canonical decimal as the locale prints it: `1234.5` is `1,234.5` in `en` and `1234,5` in
|
|
24
|
+
* `es`, which does not group a four-digit integer. The value is the caller's brand, so a
|
|
25
|
+
* non-canonical spelling is unrepresentable here.
|
|
26
|
+
*/
|
|
27
|
+
export declare function formatDecimal(value: DecimalString, locale: Locale, policy?: DigitPolicy): string;
|
|
28
|
+
//# sourceMappingURL=number.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/format/number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAmD1C;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,GAClB,MAAM,CAWR;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,WAAkC,GACzC,MAAM,CAER"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { DECIMAL_TEXT_PATTERN } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import { DEFAULT_DIGIT_POLICY, presentDigits } from './digits.js';
|
|
3
|
+
/**
|
|
4
|
+
* The display marks, vendored rather than read from the host.
|
|
5
|
+
*
|
|
6
|
+
* Locale Group Decimal minimumGroupingDigits
|
|
7
|
+
* en `,` U+002C `.` U+002E 1
|
|
8
|
+
* es `.` U+002E `,` U+002C 2
|
|
9
|
+
* fr U+202F NARROW NO-BREAK SPACE `,` U+002C 1
|
|
10
|
+
* de `.` U+002E `,` U+002C 1
|
|
11
|
+
* ru U+00A0 NO-BREAK SPACE `,` U+002C 1
|
|
12
|
+
* it `.` U+002E `,` U+002C 2
|
|
13
|
+
* zh `,` U+002C `.` U+002E 1
|
|
14
|
+
* ar `,` U+002C `.` U+002E 1
|
|
15
|
+
* pt `.` U+002E `,` U+002C 1
|
|
16
|
+
*
|
|
17
|
+
* French groups with U+202F because a group must not break across a line and the narrow form is
|
|
18
|
+
* the typographic width French text uses; Russian groups with U+00A0 for the same no-break
|
|
19
|
+
* reason at the ordinary space's width. Arabic keeps the ASCII comma and full stop: the
|
|
20
|
+
* separator and the numeral set are independent choices, and the digit policy is where the
|
|
21
|
+
* numerals change. This is the display table; the buffered input has its own table because it
|
|
22
|
+
* must accept what a reader types rather than what a page prints.
|
|
23
|
+
*/
|
|
24
|
+
const NUMBER_MECHANICS = Object.freeze({
|
|
25
|
+
en: { group: ',', decimal: '.', minimumGroupingDigits: 1 },
|
|
26
|
+
es: { group: '.', decimal: ',', minimumGroupingDigits: 2 },
|
|
27
|
+
fr: { group: '\u202F', decimal: ',', minimumGroupingDigits: 1 },
|
|
28
|
+
de: { group: '.', decimal: ',', minimumGroupingDigits: 1 },
|
|
29
|
+
ru: { group: '\u00A0', decimal: ',', minimumGroupingDigits: 1 },
|
|
30
|
+
it: { group: '.', decimal: ',', minimumGroupingDigits: 2 },
|
|
31
|
+
zh: { group: ',', decimal: '.', minimumGroupingDigits: 1 },
|
|
32
|
+
ar: { group: ',', decimal: '.', minimumGroupingDigits: 1 },
|
|
33
|
+
pt: { group: '.', decimal: ',', minimumGroupingDigits: 1 },
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* True when `value` is canonical decimal text.
|
|
37
|
+
*
|
|
38
|
+
* The brand is the runtime's own, so a value that passes here is the same value every other
|
|
39
|
+
* package accepts; this module does not mint a second decimal brand. The shape pattern admits
|
|
40
|
+
* `-0` and the canonical language does not, so the one excluded spelling is refused here as
|
|
41
|
+
* the runtime's own constructor refuses it.
|
|
42
|
+
*/
|
|
43
|
+
export function isDecimalString(value) {
|
|
44
|
+
return typeof value === 'string' && value !== '-0' && DECIMAL_TEXT_PATTERN.test(value);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Groups the integer part of already-canonical numeric text and writes the locale's two marks.
|
|
48
|
+
*
|
|
49
|
+
* The caller owns the brand: `formatDecimal` hands it a `DecimalString`, and the money formatter
|
|
50
|
+
* hands it money text at a declared scale. The function therefore re-validates nothing; it
|
|
51
|
+
* splits on the canonical `.`, groups the whole part from the right and leaves the fraction's
|
|
52
|
+
* digits in the order the value holds them.
|
|
53
|
+
*/
|
|
54
|
+
export function groupCanonicalNumericText(text, locale, policy) {
|
|
55
|
+
const marks = NUMBER_MECHANICS[locale];
|
|
56
|
+
const negative = text.startsWith('-');
|
|
57
|
+
const unsigned = negative ? text.slice(1) : text;
|
|
58
|
+
const point = unsigned.indexOf('.');
|
|
59
|
+
const whole = point === -1 ? unsigned : unsigned.slice(0, point);
|
|
60
|
+
const fraction = point === -1 ? '' : unsigned.slice(point + 1);
|
|
61
|
+
const grouped = groupWhole(whole, marks.group, marks.minimumGroupingDigits);
|
|
62
|
+
const sign = negative ? '-' : '';
|
|
63
|
+
const decimal = fraction === '' ? '' : `${marks.decimal}${fraction}`;
|
|
64
|
+
return presentDigits(`${sign}${grouped}${decimal}`, policy);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A canonical decimal as the locale prints it: `1234.5` is `1,234.5` in `en` and `1234,5` in
|
|
68
|
+
* `es`, which does not group a four-digit integer. The value is the caller's brand, so a
|
|
69
|
+
* non-canonical spelling is unrepresentable here.
|
|
70
|
+
*/
|
|
71
|
+
export function formatDecimal(value, locale, policy = DEFAULT_DIGIT_POLICY) {
|
|
72
|
+
return groupCanonicalNumericText(value, locale, policy);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A digit run grouped from the right once it is long enough for the locale to warrant a separator.
|
|
76
|
+
*
|
|
77
|
+
* CLDR's `minimumGroupingDigits` is the threshold: a locale with 2 leaves a four-digit integer
|
|
78
|
+
* ungrouped and starts at five. The fraction never reaches this function.
|
|
79
|
+
*/
|
|
80
|
+
function groupWhole(digits, mark, minimumGroupingDigits) {
|
|
81
|
+
if (digits.length < 3 + minimumGroupingDigits)
|
|
82
|
+
return digits;
|
|
83
|
+
let grouped = '';
|
|
84
|
+
for (let end = digits.length; end > 0; end -= 3) {
|
|
85
|
+
const start = Math.max(0, end - 3);
|
|
86
|
+
const chunk = digits.slice(start, end);
|
|
87
|
+
grouped = grouped === '' ? chunk : `${chunk}${mark}${grouped}`;
|
|
88
|
+
}
|
|
89
|
+
return grouped;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../src/format/number.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAoBlE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,gBAAgB,GAA8C,MAAM,CAAC,MAAM,CAAC;IAChF,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,CAAC,EAAE;IAC1D,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,CAAC,EAAE;IAC1D,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,CAAC,EAAE;IAC/D,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,CAAC,EAAE;IAC1D,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,CAAC,EAAE;IAC/D,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EA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C;AACjB,CAAC","sourcesContent":["import type { DecimalString } from '@azx-pbc/axiom-runtime';\nimport { DECIMAL_TEXT_PATTERN } from '@azx-pbc/axiom-runtime';\nimport { DEFAULT_DIGIT_POLICY, presentDigits } from './digits.js';\nimport type { DigitPolicy } from './digits.js';\nimport type { Locale } from './locale.js';\n\n/** The marks one locale prints between digits, and when it starts grouping. */\ninterface NumberMechanics {\n readonly group: string;\n readonly decimal: string;\n /**\n * CLDR's `minimumGroupingDigits`: the count of digits the integer part must exceed before a\n * separator appears.\n *\n * Spanish and Italian hold back a four-digit integer (`1234`) and group from five (`12.345`).\n * The other seven group from four. The table below is CLDR 48's answer, read through Node\n * 26.13.0's ICU when the marks were authored: en, fr, de, ru, zh, ar and pt state 1; es and it\n * state 2.\n */\n readonly minimumGroupingDigits: 1 | 2;\n}\n\n/**\n * The display marks, vendored rather than read from the host.\n *\n * Locale Group Decimal minimumGroupingDigits\n * en `,` U+002C `.` U+002E 1\n * es `.` U+002E `,` U+002C 2\n * fr U+202F NARROW NO-BREAK SPACE `,` U+002C 1\n * de `.` U+002E `,` U+002C 1\n * ru U+00A0 NO-BREAK SPACE `,` U+002C 1\n * it `.` U+002E `,` U+002C 2\n * zh `,` U+002C `.` U+002E 1\n * ar `,` U+002C `.` U+002E 1\n * pt `.` U+002E `,` U+002C 1\n *\n * French groups with U+202F because a group must not break across a line and the narrow form is\n * the typographic width French text uses; Russian groups with U+00A0 for the same no-break\n * reason at the ordinary space's width. Arabic keeps the ASCII comma and full stop: the\n * separator and the numeral set are independent choices, and the digit policy is where the\n * numerals change. This is the display table; the buffered input has its own table because it\n * must accept what a reader types rather than what a page prints.\n */\nconst NUMBER_MECHANICS: Readonly<Record<Locale, NumberMechanics>> = Object.freeze({\n en: { group: ',', decimal: '.', minimumGroupingDigits: 1 },\n es: { group: '.', decimal: ',', minimumGroupingDigits: 2 },\n fr: { group: '\\u202F', decimal: ',', minimumGroupingDigits: 1 },\n de: { group: '.', decimal: ',', minimumGroupingDigits: 1 },\n ru: { group: '\\u00A0', decimal: ',', minimumGroupingDigits: 1 },\n it: { group: '.', decimal: ',', minimumGroupingDigits: 2 },\n zh: { group: ',', decimal: '.', minimumGroupingDigits: 1 },\n ar: { group: ',', decimal: '.', minimumGroupingDigits: 1 },\n pt: { group: '.', decimal: ',', minimumGroupingDigits: 1 },\n});\n\n/**\n * True when `value` is canonical decimal text.\n *\n * The brand is the runtime's own, so a value that passes here is the same value every other\n * package accepts; this module does not mint a second decimal brand. The shape pattern admits\n * `-0` and the canonical language does not, so the one excluded spelling is refused here as\n * the runtime's own constructor refuses it.\n */\nexport function isDecimalString(value: unknown): value is DecimalString {\n return typeof value === 'string' && value !== '-0' && DECIMAL_TEXT_PATTERN.test(value);\n}\n\n/**\n * Groups the integer part of already-canonical numeric text and writes the locale's two marks.\n *\n * The caller owns the brand: `formatDecimal` hands it a `DecimalString`, and the money formatter\n * hands it money text at a declared scale. The function therefore re-validates nothing; it\n * splits on the canonical `.`, groups the whole part from the right and leaves the fraction's\n * digits in the order the value holds them.\n */\nexport function groupCanonicalNumericText(\n text: string,\n locale: Locale,\n policy: DigitPolicy,\n): string {\n const marks = NUMBER_MECHANICS[locale];\n const negative = text.startsWith('-');\n const unsigned = negative ? text.slice(1) : text;\n const point = unsigned.indexOf('.');\n const whole = point === -1 ? unsigned : unsigned.slice(0, point);\n const fraction = point === -1 ? '' : unsigned.slice(point + 1);\n const grouped = groupWhole(whole, marks.group, marks.minimumGroupingDigits);\n const sign = negative ? '-' : '';\n const decimal = fraction === '' ? '' : `${marks.decimal}${fraction}`;\n return presentDigits(`${sign}${grouped}${decimal}`, policy);\n}\n\n/**\n * A canonical decimal as the locale prints it: `1234.5` is `1,234.5` in `en` and `1234,5` in\n * `es`, which does not group a four-digit integer. The value is the caller's brand, so a\n * non-canonical spelling is unrepresentable here.\n */\nexport function formatDecimal(\n value: DecimalString,\n locale: Locale,\n policy: DigitPolicy = DEFAULT_DIGIT_POLICY,\n): string {\n return groupCanonicalNumericText(value, locale, policy);\n}\n\n/**\n * A digit run grouped from the right once it is long enough for the locale to warrant a separator.\n *\n * CLDR's `minimumGroupingDigits` is the threshold: a locale with 2 leaves a four-digit integer\n * ungrouped and starts at five. The fraction never reaches this function.\n */\nfunction groupWhole(digits: string, mark: string, minimumGroupingDigits: 1 | 2): string {\n if (digits.length < 3 + minimumGroupingDigits) return digits;\n let grouped = '';\n for (let end = digits.length; end > 0; end -= 3) {\n const start = Math.max(0, end - 3);\n const chunk = digits.slice(start, end);\n grouped = grouped === '' ? chunk : `${chunk}${mark}${grouped}`;\n }\n return grouped;\n}\n"]}
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { Context } from 'react';
|
|
2
|
+
import type { WireRecord } from '@azx-pbc/axiom-runtime';
|
|
3
|
+
/**
|
|
4
|
+
* How a host's request for the device's position ended.
|
|
5
|
+
*
|
|
6
|
+
* A denial and an absent device are different facts, so the result is a tagged union rather than
|
|
7
|
+
* `undefined`: a control that collapsed them would tell the reader nothing about why the button
|
|
8
|
+
* did nothing or whether asking again could help. The adapter owns canonical decimal text; the
|
|
9
|
+
* host reports the platform's numbers and the instant it read them.
|
|
10
|
+
*/
|
|
11
|
+
export type HostPositionResult = {
|
|
12
|
+
readonly outcome: 'granted';
|
|
13
|
+
/** Decimal degrees, as the platform reports them. The adapter canonicalises the text. */
|
|
14
|
+
readonly latitude: number;
|
|
15
|
+
readonly longitude: number;
|
|
16
|
+
/** The horizontal radius in metres, when the platform reports one. */
|
|
17
|
+
readonly accuracy?: number;
|
|
18
|
+
/** The instant the reading was taken, as an ISO 8601 UTC instant. */
|
|
19
|
+
readonly capturedAt: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly outcome: 'denied';
|
|
22
|
+
} | {
|
|
23
|
+
readonly outcome: 'unavailable';
|
|
24
|
+
} | {
|
|
25
|
+
readonly outcome: 'timed-out';
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The declared constraints a capture action must honour before it stores anything.
|
|
29
|
+
*
|
|
30
|
+
* The adapter checks the reference it receives, but a host that opens a picker or a camera can
|
|
31
|
+
* honour the same declaration earlier: the file dialog can name the accepted types, and an
|
|
32
|
+
* oversize file can be refused before it crosses the network. Passing the declaration keeps the
|
|
33
|
+
* two checks one contract rather than two guesses.
|
|
34
|
+
*/
|
|
35
|
+
export interface MediaCaptureRequest {
|
|
36
|
+
/** The field's translated label, so a host panel names what it is capturing for. */
|
|
37
|
+
readonly label?: string;
|
|
38
|
+
/** The declaration's `accept` entries, already in their canonical lower-case spelling. */
|
|
39
|
+
readonly accept?: readonly string[];
|
|
40
|
+
/** The declaration's lower byte bound, when it states one. */
|
|
41
|
+
readonly minBytes?: number;
|
|
42
|
+
/** The declaration's upper byte bound, when it states one. */
|
|
43
|
+
readonly maxBytes?: number;
|
|
44
|
+
}
|
|
45
|
+
/** The label a capture action paints, so a host dialog can name the field it is capturing for. */
|
|
46
|
+
export interface SignatureCaptureRequest {
|
|
47
|
+
readonly label?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The capabilities a host brings to a document the device cannot perform itself.
|
|
51
|
+
*
|
|
52
|
+
* A `signature_capture` field is one: the signer is a service, not a browser, so a page that can
|
|
53
|
+
* sign states how here and a page that cannot says nothing — the control then stays a read-only
|
|
54
|
+
* value rather than a button that would fail. Every capability is keyed by the binding it acts on,
|
|
55
|
+
* so a host answers for one field and the tree needs no knowledge of which document it paints.
|
|
56
|
+
*/
|
|
57
|
+
export interface HostActions {
|
|
58
|
+
/**
|
|
59
|
+
* Signs the record as this page currently shows it, and returns the failure when it could not.
|
|
60
|
+
*
|
|
61
|
+
* The values travel, because a signature binds what its signer was shown: a branch the page
|
|
62
|
+
* excluded is not signed, which is what lets the projection carry the signature while omitting
|
|
63
|
+
* that branch.
|
|
64
|
+
*/
|
|
65
|
+
readonly captureSignature?: (fieldId: string, request?: SignatureCaptureRequest) => Promise<string | undefined>;
|
|
66
|
+
/**
|
|
67
|
+
* Asks the host for one `media_ref` for a field, usually by opening its capture panel.
|
|
68
|
+
*
|
|
69
|
+
* The library uploads nothing and stores nothing: the host chooses the file or the live source,
|
|
70
|
+
* computes the reference and its digest, and returns the closed `media_ref` record. The adapter
|
|
71
|
+
* writes the answer (or appends it, for a `media_ref[]` field) and never pretends the file has
|
|
72
|
+
* left the device. A host with no durable storage returns a reference it can still resolve on
|
|
73
|
+
* submit. The request carries the declaration's bounds so a host can refuse before it uploads.
|
|
74
|
+
*/
|
|
75
|
+
readonly captureMedia?: (fieldId: string, request?: MediaCaptureRequest) => Promise<WireRecord | undefined>;
|
|
76
|
+
/**
|
|
77
|
+
* The object URL a captured `media_ref` can be previewed from.
|
|
78
|
+
*
|
|
79
|
+
* The library never stores bytes, so only the host can answer this. Returning `undefined` is a
|
|
80
|
+
* capability answer: the control paints a neutral file glyph and the media type rather than an
|
|
81
|
+
* empty image frame. The host owns the URL's lifetime and revokes it when it chooses.
|
|
82
|
+
*/
|
|
83
|
+
readonly mediaSrc?: (reference: WireRecord) => string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Asks the host for the device's current position for a `coordinate` field.
|
|
86
|
+
*
|
|
87
|
+
* A page that supplies this offers its reader a capture button beside the manual latitude and
|
|
88
|
+
* longitude entries; a page that does not keeps the manual path alone. The adapter never reads
|
|
89
|
+
* `navigator.geolocation` itself: permission, hardware and the timeout are the host's policy,
|
|
90
|
+
* and a denial must be a stated outcome rather than an empty promise. No network request and no
|
|
91
|
+
* map tiles are involved — a host that wants a map brings its own control through the slot map.
|
|
92
|
+
*/
|
|
93
|
+
readonly capturePosition?: (fieldId: string) => Promise<HostPositionResult>;
|
|
94
|
+
/**
|
|
95
|
+
* Paint a multi-pick list as the native `<select multiple>` instead of a checkbox group.
|
|
96
|
+
*
|
|
97
|
+
* The default is a checkbox group: a native multi-select needs Ctrl/Cmd-click on desktop and
|
|
98
|
+
* has no usable affordance on iOS. A host that has styled and tested the native control for
|
|
99
|
+
* its own platform asks for it here; the binding, value and errors are the same either way.
|
|
100
|
+
*/
|
|
101
|
+
readonly nativeMultiSelect?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Paint a `timeslot` as the native `<select>` instead of the calendar and day column. The
|
|
104
|
+
* default is the scheduler, which keeps the same wire value and rules.
|
|
105
|
+
*/
|
|
106
|
+
readonly nativeTimeslot?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/** The capabilities in force; a page that supplies none keeps every control read-only. */
|
|
109
|
+
export declare const HostActionsContext: Context<HostActions>;
|
|
110
|
+
/** The host capabilities this page supplies. */
|
|
111
|
+
export declare function useHostActions(): HostActions;
|
|
112
|
+
/**
|
|
113
|
+
* The locale the adapter paints, for the punctuation a text control reads.
|
|
114
|
+
*
|
|
115
|
+
* Messages resolve their own locale through the host's formatter; this is the narrower fact a
|
|
116
|
+
* buffered number needs — which mark separates a whole from its fraction (`125,50` in `es`,
|
|
117
|
+
* `125.50` in `en`) and which groups digits. `undefined` keeps the canonical pair.
|
|
118
|
+
*/
|
|
119
|
+
export declare const LocaleContext: Context<string | undefined>;
|
|
120
|
+
/** The locale in force for the tree being rendered. */
|
|
121
|
+
export declare function useLocale(): string | undefined;
|
|
122
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IACE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,M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K,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC5E;;;;;;OAMG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,0FAA0F;AAC1F,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,WAAW,CAAkC,CAAC;AAEvF,gDAAgD;AAChD,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,MAAM,GAAG,SAAS,CAErD,CAAC;AAEF,uDAAuD;AACvD,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAE9C"}
|
package/dist/host.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
/** The capabilities in force; a page that supplies none keeps every control read-only. */
|
|
3
|
+
export const HostActionsContext = createContext({});
|
|
4
|
+
/** The host capabilities this page supplies. */
|
|
5
|
+
export function useHostActions() {
|
|
6
|
+
return useContext(HostActionsContext);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The locale the adapter paints, for the punctuation a text control reads.
|
|
10
|
+
*
|
|
11
|
+
* Messages resolve their own locale through the host's formatter; this is the narrower fact a
|
|
12
|
+
* buffered number needs — which mark separates a whole from its fraction (`125,50` in `es`,
|
|
13
|
+
* `125.50` in `en`) and which groups digits. `undefined` keeps the canonical pair.
|
|
14
|
+
*/
|
|
15
|
+
export const LocaleContext = createContext(undefined);
|
|
16
|
+
/** The locale in force for the tree being rendered. */
|
|
17
|
+
export function useLocale() {
|
|
18
|
+
return useContext(LocaleContext);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=host.js.map
|
package/dist/host.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAqHlD,0FAA0F;AAC1F,MAAM,CAAC,MAAM,kBAAkB,GAAyB,aAAa,CAAc,EAAE,CAAC,CAAC;AAEvF,gDAAgD;AAChD,MAAM,UAAU,cAAc;IAC5B,OAAO,UAAU,CAAC,kBAAkB,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAgC,aAAa,CACrE,SAAS,CACV,CAAC;AAEF,uDAAuD;AACvD,MAAM,UAAU,SAAS;IACvB,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import { createContext, useContext } from 'react';\nimport type { Context } from 'react';\nimport type { WireRecord } from '@azx-pbc/axiom-runtime';\n\n/**\n * How a host's request for the device's position ended.\n *\n * A denial and an absent device are different facts, so the result is a tagged union rather than\n * `undefined`: a control that collapsed them would tell the reader nothing about why the button\n * did nothing or whether asking again could help. The adapter owns canonical decimal text; the\n * host reports the platform's numbers and the instant it read them.\n */\nexport type HostPositionResult =\n | {\n readonly outcome: 'granted';\n /** Decimal degrees, as the platform reports them. The adapter canonicalises the text. */\n readonly latitude: number;\n readonly longitude: number;\n /** The horizontal radius in metres, when the platform reports one. */\n readonly accuracy?: number;\n /** The instant the reading was taken, as an ISO 8601 UTC instant. */\n readonly capturedAt: string;\n }\n | { readonly outcome: 'denied' }\n | { readonly outcome: 'unavailable' }\n | { readonly outcome: 'timed-out' };\n\n/**\n * The declared constraints a capture action must honour before it stores anything.\n *\n * The adapter checks the reference it receives, but a host that opens a picker or a camera can\n * honour the same declaration earlier: the file dialog can name the accepted types, and an\n * oversize file can be refused before it crosses the network. Passing the declaration keeps the\n * two checks one contract rather than two guesses.\n */\nexport interface MediaCaptureRequest {\n /** The field's translated label, so a host panel names what it is capturing for. */\n readonly label?: string;\n /** The declaration's `accept` entries, already in their canonical lower-case spelling. */\n readonly accept?: readonly string[];\n /** The declaration's lower byte bound, when it states one. */\n readonly minBytes?: number;\n /** The declaration's upper byte bound, when it states one. */\n readonly maxBytes?: number;\n}\n\n/** The label a capture action paints, so a host dialog can name the field it is capturing for. */\nexport interface SignatureCaptureRequest {\n readonly label?: string;\n}\n\n/**\n * The capabilities a host brings to a document the device cannot perform itself.\n *\n * A `signature_capture` field is one: the signer is a service, not a browser, so a page that can\n * sign states how here and a page that cannot says nothing — the control then stays a read-only\n * value rather than a button that would fail. Every capability is keyed by the binding it acts on,\n * so a host answers for one field and the tree needs no knowledge of which document it paints.\n */\nexport interface HostActions {\n /**\n * Signs the record as this page currently shows it, and returns the failure when it could not.\n *\n * The values travel, because a signature binds what its signer was shown: a branch the page\n * excluded is not signed, which is what lets the projection carry the signature while omitting\n * that branch.\n */\n readonly captureSignature?: (\n fieldId: string,\n request?: SignatureCaptureRequest,\n ) => Promise<string | undefined>;\n /**\n * Asks the host for one `media_ref` for a field, usually by opening its capture panel.\n *\n * The library uploads nothing and stores nothing: the host chooses the file or the live source,\n * computes the reference and its digest, and returns the closed `media_ref` record. The adapter\n * writes the answer (or appends it, for a `media_ref[]` field) and never pretends the file has\n * left the device. A host with no durable storage returns a reference it can still resolve on\n * submit. The request carries the declaration's bounds so a host can refuse before it uploads.\n */\n readonly captureMedia?: (\n fieldId: string,\n request?: MediaCaptureRequest,\n ) => Promise<WireRecord | undefined>;\n /**\n * The object URL a captured `media_ref` can be previewed from.\n *\n * The library never stores bytes, so only the host can answer this. Returning `undefined` is a\n * capability answer: the control paints a neutral file glyph and the media type rather than an\n * empty image frame. The host owns the URL's lifetime and revokes it when it chooses.\n */\n readonly mediaSrc?: (reference: WireRecord) => string | undefined;\n /**\n * Asks the host for the device's current position for a `coordinate` field.\n *\n * A page that supplies this offers its reader a capture button beside the manual latitude and\n * longitude entries; a page that does not keeps the manual path alone. The adapter never reads\n * `navigator.geolocation` itself: permission, hardware and the timeout are the host's policy,\n * and a denial must be a stated outcome rather than an empty promise. No network request and no\n * map tiles are involved — a host that wants a map brings its own control through the slot map.\n */\n readonly capturePosition?: (fieldId: string) => Promise<HostPositionResult>;\n /**\n * Paint a multi-pick list as the native `<select multiple>` instead of a checkbox group.\n *\n * The default is a checkbox group: a native multi-select needs Ctrl/Cmd-click on desktop and\n * has no usable affordance on iOS. A host that has styled and tested the native control for\n * its own platform asks for it here; the binding, value and errors are the same either way.\n */\n readonly nativeMultiSelect?: boolean;\n /**\n * Paint a `timeslot` as the native `<select>` instead of the calendar and day column. The\n * default is the scheduler, which keeps the same wire value and rules.\n */\n readonly nativeTimeslot?: boolean;\n}\n\n/** The capabilities in force; a page that supplies none keeps every control read-only. */\nexport const HostActionsContext: Context<HostActions> = createContext<HostActions>({});\n\n/** The host capabilities this page supplies. */\nexport function useHostActions(): HostActions {\n return useContext(HostActionsContext);\n}\n\n/**\n * The locale the adapter paints, for the punctuation a text control reads.\n *\n * Messages resolve their own locale through the host's formatter; this is the narrower fact a\n * buffered number needs — which mark separates a whole from its fraction (`125,50` in `es`,\n * `125.50` in `en`) and which groups digits. `undefined` keeps the canonical pair.\n */\nexport const LocaleContext: Context<string | undefined> = createContext<string | undefined>(\n undefined,\n);\n\n/** The locale in force for the tree being rendered. */\nexport function useLocale(): string | undefined {\n return useContext(LocaleContext);\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Axiom's reference web renderer, as one door.
|
|
3
|
+
*
|
|
4
|
+
* It paints the host-neutral `RenderNode` tree `@azx-pbc/axiom-react` produces: every layout
|
|
5
|
+
* container, every control in `CONTROLS`, the error summary and the records row bindings. The
|
|
6
|
+
* package owns no rules and compiles nothing; a host supplies the compiled artifact through
|
|
7
|
+
* `FormProvider`, its copy through `FormCopy`, and the capabilities the device cannot perform
|
|
8
|
+
* (a signature service, a media picker, a position reading) through `HostActions`.
|
|
9
|
+
*
|
|
10
|
+
* The two seams replace different scopes, which is why both exist. `ControlComponents` replaces one
|
|
11
|
+
* control and keeps the adapter's label, hint, error and wrapper; `LayoutComponents` replaces one
|
|
12
|
+
* container and keeps the children the adapter already rendered. A host that wants both replaces
|
|
13
|
+
* both, and a host with its own design system imports neither: it takes the bindings and paints the
|
|
14
|
+
* tree itself.
|
|
15
|
+
*
|
|
16
|
+
* The stylesheets are separate doors so a host can ship its own:
|
|
17
|
+
*
|
|
18
|
+
* import '@azx-pbc/axiom-web/tokens.css';
|
|
19
|
+
* import '@azx-pbc/axiom-web/styles.css';
|
|
20
|
+
*/
|
|
21
|
+
export { Control, ControlComponentsContext } from './controls.js';
|
|
22
|
+
export type { ControlComponent, ControlComponentProps, ControlComponents, ControlConstraints, } from './controls.js';
|
|
23
|
+
export { LayoutComponentsContext } from './render/layout.js';
|
|
24
|
+
export type { ContainerKind, LayoutComponent, LayoutComponents, LayoutSlotProps, } from './render/layout.js';
|
|
25
|
+
export { ErrorSummary, ERROR_SUMMARY_SUFFIX, LayoutTree, RenderedForm, useIssueList, } from './render/dom.js';
|
|
26
|
+
export { WizardCheckpoints } from './wizard-checkpoints.js';
|
|
27
|
+
export type { IssueList } from './render/dom.js';
|
|
28
|
+
export type { FormWidth } from './render/dom.js';
|
|
29
|
+
export { FORM_COPY_LOCALES, FormCopyContext, formCopy, useFormCopy, useHostCopy, } from './copy.js';
|
|
30
|
+
export type { FormCopy, HostCopy } from './copy.js';
|
|
31
|
+
export { HostActionsContext, useHostActions, } from './host.js';
|
|
32
|
+
export type { HostActions, HostPositionResult, MediaCaptureRequest, SignatureCaptureRequest, } from './host.js';
|
|
33
|
+
export { CaptureRefusedError, CAPTURE_COPY_LOCALES, DEFAULT_CAPTURE_MESSAGES, MediaCapture, SignatureCapture, browserCapturePlatform, cameraCount, captureKinds, captureMessages, classifyCaptureError, constraintsFor, elapsedText, fileAccept, forgetCaptureOutcome, hasLiveSource, kindNoun, rememberCaptureOutcome, rememberedCaptureOutcome, requestDevice, stopStream, } from './capture/index.js';
|
|
34
|
+
export type { CapturedMedia, CaptureDevice, CaptureMediaKind, CaptureMessages, CapturePermission, CapturePermissionKind, CapturePlatform, CaptureRecorder, MediaCaptureProps, SignatureCaptureProps, SignatureMode, } from './capture/index.js';
|
|
35
|
+
export { LocaleContext, useLocale } from './host.js';
|
|
36
|
+
/**
|
|
37
|
+
* The browser's timer, as the wait a host hands `FormProvider` for a searched option source.
|
|
38
|
+
*
|
|
39
|
+
* The bindings read no clock, so a search that waits for the reader to stop typing borrows the
|
|
40
|
+
* one this package's target has. A browser host passes this and gets the documented wait; a
|
|
41
|
+
* search without a timer is refused before a loader is called.
|
|
42
|
+
*/
|
|
43
|
+
export declare function browserDefer(callback: () => void, delayMs: number): () => void;
|
|
44
|
+
export { DatePicker } from './pickers/DatePicker.js';
|
|
45
|
+
export type { DatePickerProps } from './pickers/DatePicker.js';
|
|
46
|
+
export { TimeSegments } from './pickers/TimeSegments.js';
|
|
47
|
+
export type { TimeSegmentsProps } from './pickers/TimeSegments.js';
|
|
48
|
+
export { ScheduleField, SchedulePicker } from './schedule/SchedulePicker.js';
|
|
49
|
+
export type { SchedulePickerControlProps, SchedulePickerProps } from './schedule/SchedulePicker.js';
|
|
50
|
+
export { civilDate, civilKey, clockMinutes, durationLabel, isTimeslotValue, rangeLabel, scheduleText, slotOf, timeLabel, } from './schedule/timeslot.js';
|
|
51
|
+
export type { ScheduleText, TimeslotSlot } from './schedule/timeslot.js';
|
|
52
|
+
export { THEME_ATTRIBUTES, THEME_DENSITIES, THEME_SCHEMES, applyBrandAccent, applyTheme, } from './theme/index.js';
|
|
53
|
+
export type { AccentBrand, ApplyBrandResult, ThemeDensity, ThemeOptions, ThemeScheme, } from './theme/index.js';
|
|
54
|
+
export { MEDIA_BYTE_BASE, friendlyMediaType, humanSize, isImageMedia, mediaBytes, mediaDisplayLine, mediaId, mediaLine, mediaMime, mediaName, truncateMiddle, } from './media.js';
|
|
55
|
+
export { DEFAULT_DIGIT_POLICY, DIGIT_POLICIES, LOCALES, formatCivilDate, formatDecimal, formatMoney, isCanonicalMoneyText, isCivilDateString, isCurrencyCode, isDecimalString, resolveLocale, toArabicIndicDigits, } from './format/index.js';
|
|
56
|
+
export type { CanonicalMoneyText, CivilDateString, CurrencyCode, DigitPolicy, Locale, MoneyDisplay, } from './format/index.js';
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAClE,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,YAAY,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,UAAU,EACV,YAAY,EACZ,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,QAAQ,EACR,WAAW,EACX,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EACL,kBAAkB,EAClB,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,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B,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAS,EACT,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,WAAW,EACX,MAAM,EACN,YAAY,GACb,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Axiom's reference web renderer, as one door.
|
|
3
|
+
*
|
|
4
|
+
* It paints the host-neutral `RenderNode` tree `@azx-pbc/axiom-react` produces: every layout
|
|
5
|
+
* container, every control in `CONTROLS`, the error summary and the records row bindings. The
|
|
6
|
+
* package owns no rules and compiles nothing; a host supplies the compiled artifact through
|
|
7
|
+
* `FormProvider`, its copy through `FormCopy`, and the capabilities the device cannot perform
|
|
8
|
+
* (a signature service, a media picker, a position reading) through `HostActions`.
|
|
9
|
+
*
|
|
10
|
+
* The two seams replace different scopes, which is why both exist. `ControlComponents` replaces one
|
|
11
|
+
* control and keeps the adapter's label, hint, error and wrapper; `LayoutComponents` replaces one
|
|
12
|
+
* container and keeps the children the adapter already rendered. A host that wants both replaces
|
|
13
|
+
* both, and a host with its own design system imports neither: it takes the bindings and paints the
|
|
14
|
+
* tree itself.
|
|
15
|
+
*
|
|
16
|
+
* The stylesheets are separate doors so a host can ship its own:
|
|
17
|
+
*
|
|
18
|
+
* import '@azx-pbc/axiom-web/tokens.css';
|
|
19
|
+
* import '@azx-pbc/axiom-web/styles.css';
|
|
20
|
+
*/
|
|
21
|
+
export { Control, ControlComponentsContext } from './controls.js';
|
|
22
|
+
export { LayoutComponentsContext } from './render/layout.js';
|
|
23
|
+
export { ErrorSummary, ERROR_SUMMARY_SUFFIX, LayoutTree, RenderedForm, useIssueList, } from './render/dom.js';
|
|
24
|
+
export { WizardCheckpoints } from './wizard-checkpoints.js';
|
|
25
|
+
export { FORM_COPY_LOCALES, FormCopyContext, formCopy, useFormCopy, useHostCopy, } from './copy.js';
|
|
26
|
+
export { HostActionsContext, useHostActions, } from './host.js';
|
|
27
|
+
export { CaptureRefusedError, CAPTURE_COPY_LOCALES, DEFAULT_CAPTURE_MESSAGES, MediaCapture, SignatureCapture, browserCapturePlatform, cameraCount, captureKinds, captureMessages, classifyCaptureError, constraintsFor, elapsedText, fileAccept, forgetCaptureOutcome, hasLiveSource, kindNoun, rememberCaptureOutcome, rememberedCaptureOutcome, requestDevice, stopStream, } from './capture/index.js';
|
|
28
|
+
export { LocaleContext, useLocale } from './host.js';
|
|
29
|
+
/**
|
|
30
|
+
* The browser's timer, as the wait a host hands `FormProvider` for a searched option source.
|
|
31
|
+
*
|
|
32
|
+
* The bindings read no clock, so a search that waits for the reader to stop typing borrows the
|
|
33
|
+
* one this package's target has. A browser host passes this and gets the documented wait; a
|
|
34
|
+
* search without a timer is refused before a loader is called.
|
|
35
|
+
*/
|
|
36
|
+
export function browserDefer(callback, delayMs) {
|
|
37
|
+
const handle = window.setTimeout(callback, delayMs);
|
|
38
|
+
return () => {
|
|
39
|
+
window.clearTimeout(handle);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export { DatePicker } from './pickers/DatePicker.js';
|
|
43
|
+
export { TimeSegments } from './pickers/TimeSegments.js';
|
|
44
|
+
export { ScheduleField, SchedulePicker } from './schedule/SchedulePicker.js';
|
|
45
|
+
export { civilDate, civilKey, clockMinutes, durationLabel, isTimeslotValue, rangeLabel, scheduleText, slotOf, timeLabel, } from './schedule/timeslot.js';
|
|
46
|
+
export { THEME_ATTRIBUTES, THEME_DENSITIES, THEME_SCHEMES, applyBrandAccent, applyTheme, } from './theme/index.js';
|
|
47
|
+
export { MEDIA_BYTE_BASE, friendlyMediaType, humanSize, isImageMedia, mediaBytes, mediaDisplayLine, mediaId, mediaLine, mediaMime, mediaName, truncateMiddle, } from './media.js';
|
|
48
|
+
export { DEFAULT_DIGIT_POLICY, DIGIT_POLICIES, LOCALES, formatCivilDate, formatDecimal, formatMoney, isCanonicalMoneyText, isCivilDateString, isCurrencyCode, isDecimalString, resolveLocale, toArabicIndicDigits, } from './format/index.js';
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAQlE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAQ7D,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,UAAU,EACV,YAAY,EACZ,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,QAAQ,EACR,WAAW,EACX,WAAW,GACZ,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,kBAAkB,EAClB,cAAc,GACf,MAAM,WAAW,CAAC;AAQnB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,QAAQ,EACR,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACb,UAAU,GACX,MAAM,oBAAoB,CAAC;AAe5B,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,QAAoB,EAAE,OAAe;IAChE,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACpD,OAAO,GAAS,EAAE;QAChB,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE7E,OAAO,EACL,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,eAAe,EACf,UAAU,EACV,YAAY,EACZ,MAAM,EACN,SAAS,GACV,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,UAAU,GACX,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAS,EACT,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,mBAAmB,GACpB,MAAM,mBAAmB,CAAC","sourcesContent":["/**\n * Axiom's reference web renderer, as one door.\n *\n * It paints the host-neutral `RenderNode` tree `@azx-pbc/axiom-react` produces: every layout\n * container, every control in `CONTROLS`, the error summary and the records row bindings. The\n * package owns no rules and compiles nothing; a host supplies the compiled artifact through\n * `FormProvider`, its copy through `FormCopy`, and the capabilities the device cannot perform\n * (a signature service, a media picker, a position reading) through `HostActions`.\n *\n * The two seams replace different scopes, which is why both exist. `ControlComponents` replaces one\n * control and keeps the adapter's label, hint, error and wrapper; `LayoutComponents` replaces one\n * container and keeps the children the adapter already rendered. A host that wants both replaces\n * both, and a host with its own design system imports neither: it takes the bindings and paints the\n * tree itself.\n *\n * The stylesheets are separate doors so a host can ship its own:\n *\n * import '@azx-pbc/axiom-web/tokens.css';\n * import '@azx-pbc/axiom-web/styles.css';\n */\nexport { Control, ControlComponentsContext } from './controls.js';\nexport type {\n ControlComponent,\n ControlComponentProps,\n ControlComponents,\n ControlConstraints,\n} from './controls.js';\n\nexport { LayoutComponentsContext } from './render/layout.js';\nexport type {\n ContainerKind,\n LayoutComponent,\n LayoutComponents,\n LayoutSlotProps,\n} from './render/layout.js';\n\nexport {\n ErrorSummary,\n ERROR_SUMMARY_SUFFIX,\n LayoutTree,\n RenderedForm,\n useIssueList,\n} from './render/dom.js';\nexport { WizardCheckpoints } from './wizard-checkpoints.js';\nexport type { IssueList } from './render/dom.js';\nexport type { FormWidth } from './render/dom.js';\n\nexport {\n FORM_COPY_LOCALES,\n FormCopyContext,\n formCopy,\n useFormCopy,\n useHostCopy,\n} from './copy.js';\nexport type { FormCopy, HostCopy } from './copy.js';\n\nexport {\n HostActionsContext,\n useHostActions,\n} from './host.js';\nexport type {\n HostActions,\n HostPositionResult,\n MediaCaptureRequest,\n SignatureCaptureRequest,\n} from './host.js';\n\nexport {\n CaptureRefusedError,\n CAPTURE_COPY_LOCALES,\n DEFAULT_CAPTURE_MESSAGES,\n MediaCapture,\n SignatureCapture,\n browserCapturePlatform,\n cameraCount,\n captureKinds,\n captureMessages,\n classifyCaptureError,\n constraintsFor,\n elapsedText,\n fileAccept,\n forgetCaptureOutcome,\n hasLiveSource,\n kindNoun,\n rememberCaptureOutcome,\n rememberedCaptureOutcome,\n requestDevice,\n stopStream,\n} from './capture/index.js';\nexport type {\n CapturedMedia,\n CaptureDevice,\n CaptureMediaKind,\n CaptureMessages,\n CapturePermission,\n CapturePermissionKind,\n CapturePlatform,\n CaptureRecorder,\n MediaCaptureProps,\n SignatureCaptureProps,\n SignatureMode,\n} from './capture/index.js';\n\nexport { LocaleContext, useLocale } from './host.js';\n\n/**\n * The browser's timer, as the wait a host hands `FormProvider` for a searched option source.\n *\n * The bindings read no clock, so a search that waits for the reader to stop typing borrows the\n * one this package's target has. A browser host passes this and gets the documented wait; a\n * search without a timer is refused before a loader is called.\n */\nexport function browserDefer(callback: () => void, delayMs: number): () => void {\n const handle = window.setTimeout(callback, delayMs);\n return (): void => {\n window.clearTimeout(handle);\n };\n}\n\nexport { DatePicker } from './pickers/DatePicker.js';\nexport type { DatePickerProps } from './pickers/DatePicker.js';\nexport { TimeSegments } from './pickers/TimeSegments.js';\nexport type { TimeSegmentsProps } from './pickers/TimeSegments.js';\nexport { ScheduleField, SchedulePicker } from './schedule/SchedulePicker.js';\nexport type { SchedulePickerControlProps, SchedulePickerProps } from './schedule/SchedulePicker.js';\nexport {\n civilDate,\n civilKey,\n clockMinutes,\n durationLabel,\n isTimeslotValue,\n rangeLabel,\n scheduleText,\n slotOf,\n timeLabel,\n} from './schedule/timeslot.js';\nexport type { ScheduleText, TimeslotSlot } from './schedule/timeslot.js';\n\nexport {\n THEME_ATTRIBUTES,\n THEME_DENSITIES,\n THEME_SCHEMES,\n applyBrandAccent,\n applyTheme,\n} from './theme/index.js';\nexport type {\n AccentBrand,\n ApplyBrandResult,\n ThemeDensity,\n ThemeOptions,\n ThemeScheme,\n} from './theme/index.js';\n\nexport {\n MEDIA_BYTE_BASE,\n friendlyMediaType,\n humanSize,\n isImageMedia,\n mediaBytes,\n mediaDisplayLine,\n mediaId,\n mediaLine,\n mediaMime,\n mediaName,\n truncateMiddle,\n} from './media.js';\n\nexport {\n DEFAULT_DIGIT_POLICY,\n DIGIT_POLICIES,\n LOCALES,\n formatCivilDate,\n formatDecimal,\n formatMoney,\n isCanonicalMoneyText,\n isCivilDateString,\n isCurrencyCode,\n isDecimalString,\n resolveLocale,\n toArabicIndicDigits,\n} from './format/index.js';\nexport type {\n CanonicalMoneyText,\n CivilDateString,\n CurrencyCode,\n DigitPolicy,\n Locale,\n MoneyDisplay,\n} from './format/index.js';\n"]}
|
package/dist/media.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { WireValue } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
/**
|
|
3
|
+
* One media reference as a line of text and, when the host has one, a preview.
|
|
4
|
+
*
|
|
5
|
+
* The wire holds an id, a media type and a byte count. A screenshot that concatenated the id and
|
|
6
|
+
* the type read as one malformed token (`coverimage/jpeg`), so every line here separates the
|
|
7
|
+
* members with ` · ` and states the size in the units a person reads. Sizes are base 1000, the
|
|
8
|
+
* unit spelling storage services and file managers use (`2 KB` is 2000 bytes); the base is
|
|
9
|
+
* exported so a host or a test states the same convention rather than guessing.
|
|
10
|
+
*/
|
|
11
|
+
/** The byte base this module's sizes use: 1000, not 1024. */
|
|
12
|
+
export declare const MEDIA_BYTE_BASE = 1000;
|
|
13
|
+
/** A byte count in human units, one decimal at most: `0 B`, `999 B`, `2 KB`, `1.4 MB`. */
|
|
14
|
+
export declare function humanSize(bytes: number, locale?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* `text` shortened in the middle when it exceeds `limit`, with the full value kept by the
|
|
17
|
+
* caller's `title`. A trailing identifier is usually the distinguishing part, so the middle is
|
|
18
|
+
* what is dropped rather than the end.
|
|
19
|
+
*/
|
|
20
|
+
export declare function truncateMiddle(text: string, limit?: number): string;
|
|
21
|
+
/** The reference's id, or empty text for a value that is not a reference. */
|
|
22
|
+
export declare function mediaId(value: WireValue | undefined): string;
|
|
23
|
+
/** The reference's media type, or empty text for a value that is not a reference. */
|
|
24
|
+
export declare function mediaMime(value: WireValue | undefined): string;
|
|
25
|
+
/** The host's filename for a reference, when it supplies one; otherwise empty text. */
|
|
26
|
+
export declare function mediaName(value: WireValue | undefined): string;
|
|
27
|
+
/** The reference's byte count, or `undefined` for a value that is not a reference. */
|
|
28
|
+
export declare function mediaBytes(value: WireValue | undefined): number | undefined;
|
|
29
|
+
/** The friendly name of a common media type, or the subtype upper-cased. */
|
|
30
|
+
export declare function friendlyMediaType(mime: string): string;
|
|
31
|
+
/** Whether a reference names an image this adapter can preview. */
|
|
32
|
+
export declare function isImageMedia(value: WireValue | undefined): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The full line: `<id> · <mime> · <size>`, omitting a member the reference does not carry.
|
|
35
|
+
*
|
|
36
|
+
* It is the text a `title` holds and an accessible label states; the shorter form below is what
|
|
37
|
+
* fits a row.
|
|
38
|
+
*/
|
|
39
|
+
export declare function mediaLine(value: WireValue | undefined, locale?: string): string;
|
|
40
|
+
/** The line a row shows, with a long id shortened in the middle. */
|
|
41
|
+
export declare function mediaDisplayLine(value: WireValue | undefined, limit?: number, locale?: string): string;
|
|
42
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAMxD;;;;;;;;GAQG;AAEH,6DAA6D;AAC7D,eAAO,MAAM,eAAe,OAAO,CAAC;AAkCpC,0FAA0F;AAC1F,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAehE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,MAAM,CAI/D;AAED,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAE5D;AAED,qFAAqF;AACrF,wBAAg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