@ember-joinery/maskito 0.0.0-stage → 1.1.0

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +178 -0
  2. package/LICENSE.md +9 -0
  3. package/NOTICE +532 -0
  4. package/README.md +55 -2
  5. package/addon-main.cjs +4 -0
  6. package/declarations/components/masked-input.d.ts +30 -0
  7. package/declarations/components/masked-input.d.ts.map +1 -0
  8. package/declarations/components/phone-input.d.ts +167 -0
  9. package/declarations/components/phone-input.d.ts.map +1 -0
  10. package/declarations/index.d.ts +9 -0
  11. package/declarations/index.d.ts.map +1 -0
  12. package/declarations/maskito.d.ts +42 -0
  13. package/declarations/maskito.d.ts.map +1 -0
  14. package/declarations/messages.d.ts +21 -0
  15. package/declarations/messages.d.ts.map +1 -0
  16. package/declarations/phone.d.ts +49 -0
  17. package/declarations/phone.d.ts.map +1 -0
  18. package/declarations/presets.d.ts +53 -0
  19. package/declarations/presets.d.ts.map +1 -0
  20. package/declarations/test-support/-private/typing.d.ts +28 -0
  21. package/declarations/test-support/-private/typing.d.ts.map +1 -0
  22. package/declarations/test-support/index.d.ts +3 -0
  23. package/declarations/test-support/index.d.ts.map +1 -0
  24. package/declarations/test-support/masked-input.d.ts +36 -0
  25. package/declarations/test-support/masked-input.d.ts.map +1 -0
  26. package/declarations/test-support/phone-input.d.ts +70 -0
  27. package/declarations/test-support/phone-input.d.ts.map +1 -0
  28. package/declarations/test-support.d.ts +2 -0
  29. package/dist/components/masked-input.js +31 -0
  30. package/dist/components/masked-input.js.map +1 -0
  31. package/dist/components/phone-input.js +374 -0
  32. package/dist/components/phone-input.js.map +1 -0
  33. package/dist/index.js +7 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/maskito.js +87 -0
  36. package/dist/maskito.js.map +1 -0
  37. package/dist/messages.js +23 -0
  38. package/dist/messages.js.map +1 -0
  39. package/dist/phone.js +99 -0
  40. package/dist/phone.js.map +1 -0
  41. package/dist/presets.js +122 -0
  42. package/dist/presets.js.map +1 -0
  43. package/dist/test-support.js +330 -0
  44. package/dist/test-support.js.map +1 -0
  45. package/package.json +117 -3
package/dist/phone.js ADDED
@@ -0,0 +1,99 @@
1
+ import { maskitoAddOnFocusPlugin, maskitoRemoveOnBlurPlugin } from '@maskito/kit';
2
+ import { maskitoPhone } from '@maskito/phone';
3
+ import minMetadata from 'libphonenumber-js/min/metadata';
4
+ import { parsePhoneNumberFromString, getCountryCallingCode, getCountries, AsYouType, isValidPhoneNumber } from 'libphonenumber-js/core';
5
+
6
+ /** libphonenumber-js's `min` metadata, the default everywhere here. */
7
+ const phoneMetadata = minMetadata;
8
+
9
+ /** What a phone mask is for: a country, shown with or without its calling code. */
10
+
11
+ /**
12
+ * The Maskito options for one country's phone numbers (`@maskito/phone`, strict). In the
13
+ * international format, its calling code is fixed in front: it goes in when the input takes
14
+ * focus, as `@maskito/kit`'s focus plugin puts it (the mask needs it there before the first
15
+ * digit), and comes out again on blur if nothing follows it. Each call makes new options, as a
16
+ * phone mask keeps state of its own.
17
+ */
18
+ function phoneMask(country, {
19
+ national = false,
20
+ metadata = phoneMetadata
21
+ } = {}) {
22
+ const options = maskitoPhone({
23
+ countryIsoCode: country,
24
+ metadata,
25
+ strict: true,
26
+ format: national ? 'NATIONAL' : 'INTERNATIONAL'
27
+ });
28
+ if (national) return options;
29
+ const prefix = `+${getCountryCallingCode(country, metadata)} `;
30
+ return {
31
+ ...options,
32
+ plugins: [...options.plugins, maskitoAddOnFocusPlugin(prefix), maskitoRemoveOnBlurPlugin(prefix)]
33
+ };
34
+ }
35
+
36
+ /** Every country the metadata has numbers for, as ISO 3166 codes. */
37
+ function phoneCountries(metadata = phoneMetadata) {
38
+ return getCountries(metadata);
39
+ }
40
+
41
+ /** A country's calling code, without the `+`: `1` for `US`, `44` for `GB`. */
42
+ function callingCode(country, metadata = phoneMetadata) {
43
+ return getCountryCallingCode(country, metadata);
44
+ }
45
+
46
+ /** A country's flag, as the emoji its code spells in regional indicator letters. */
47
+ function countryFlag(country) {
48
+ return [...country.toUpperCase()].map(letter => String.fromCodePoint(0x1f1e6 + letter.charCodeAt(0) - 65)).join('');
49
+ }
50
+
51
+ /** The calling code an E.164 number (whole or begun) starts with, or `undefined`. */
52
+ function callingCodeOf(value, metadata = phoneMetadata) {
53
+ if (!value?.startsWith('+')) return undefined;
54
+ const formatter = new AsYouType(undefined, metadata);
55
+ formatter.input(value);
56
+ return formatter.getCallingCode();
57
+ }
58
+
59
+ /**
60
+ * The country of an E.164 number: `current` when the number has its calling code (so a
61
+ * Canadian number stays Canadian while `+1` is typed), else the country the number belongs to,
62
+ * else the main country of its calling code (`US` for `+1`, `GB` for `+44`). `undefined` for a
63
+ * number with no calling code yet.
64
+ */
65
+ function countryOfPhone(value, current, metadata = phoneMetadata) {
66
+ const code = callingCodeOf(value, metadata);
67
+ if (!code) return undefined;
68
+ if (current && callingCode(current, metadata) === code) return current;
69
+ const parsed = parsePhoneNumberFromString(value, metadata);
70
+ if (parsed?.country) return parsed.country;
71
+ const main = metadata.country_calling_codes?.[code]?.[0];
72
+ return main;
73
+ }
74
+
75
+ /**
76
+ * Whether a stored number is a valid phone number, for a validator. A number without a `+`
77
+ * is read as `country`'s. Uses libphonenumber-js's `min` metadata unless given other metadata,
78
+ * which checks a number's length for its country.
79
+ *
80
+ * isValidPhone('+12125550123') // true
81
+ */
82
+ function isValidPhone(value, country, metadata = phoneMetadata) {
83
+ if (!value) return false;
84
+ return isValidPhoneNumber(value, {
85
+ defaultCountry: country
86
+ }, metadata);
87
+ }
88
+
89
+ /**
90
+ * A stored number in international format (`+1 212 555 0123`), to show it outside an input.
91
+ * Anything that doesn't parse is shown as it is.
92
+ */
93
+ function formatPhone(value, metadata = phoneMetadata) {
94
+ if (!value) return '';
95
+ return parsePhoneNumberFromString(value, metadata)?.formatInternational() ?? value;
96
+ }
97
+
98
+ export { callingCode, callingCodeOf, countryFlag, countryOfPhone, formatPhone, isValidPhone, phoneCountries, phoneMask, phoneMetadata };
99
+ //# sourceMappingURL=phone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phone.js","sources":["../src/phone.ts"],"sourcesContent":["import type { MaskitoOptions } from '@maskito/core'\nimport { maskitoAddOnFocusPlugin, maskitoRemoveOnBlurPlugin } from '@maskito/kit'\nimport { maskitoPhone } from '@maskito/phone'\nimport minMetadata from 'libphonenumber-js/min/metadata'\nimport {\n AsYouType,\n getCountries,\n getCountryCallingCode,\n isValidPhoneNumber,\n parsePhoneNumberFromString,\n type CountryCode,\n type MetadataJson,\n} from 'libphonenumber-js/core'\n\nexport type { CountryCode, MetadataJson }\n\n/** libphonenumber-js's `min` metadata, the default everywhere here. */\nexport const phoneMetadata = minMetadata as unknown as MetadataJson\n\n/** What a phone mask is for: a country, shown with or without its calling code. */\nexport interface PhoneMaskOptions {\n /** Show the national format, `(212) 555-0123`, rather than `+1 212 555-0123`. */\n national?: boolean\n /** libphonenumber-js metadata. Default its `min` metadata. */\n metadata?: MetadataJson\n}\n\n/**\n * The Maskito options for one country's phone numbers (`@maskito/phone`, strict). In the\n * international format, its calling code is fixed in front: it goes in when the input takes\n * focus, as `@maskito/kit`'s focus plugin puts it (the mask needs it there before the first\n * digit), and comes out again on blur if nothing follows it. Each call makes new options, as a\n * phone mask keeps state of its own.\n */\nexport function phoneMask(\n country: CountryCode,\n { national = false, metadata = phoneMetadata }: PhoneMaskOptions = {},\n): MaskitoOptions {\n const options = maskitoPhone({\n countryIsoCode: country,\n metadata,\n strict: true,\n format: national ? 'NATIONAL' : 'INTERNATIONAL',\n })\n if (national) return options\n const prefix = `+${getCountryCallingCode(country, metadata)} `\n return {\n ...options,\n plugins: [\n ...options.plugins,\n maskitoAddOnFocusPlugin(prefix),\n maskitoRemoveOnBlurPlugin(prefix),\n ],\n }\n}\n\n/** Every country the metadata has numbers for, as ISO 3166 codes. */\nexport function phoneCountries(metadata: MetadataJson = phoneMetadata): CountryCode[] {\n return getCountries(metadata)\n}\n\n/** A country's calling code, without the `+`: `1` for `US`, `44` for `GB`. */\nexport function callingCode(country: CountryCode, metadata: MetadataJson = phoneMetadata): string {\n return getCountryCallingCode(country, metadata)\n}\n\n/** A country's flag, as the emoji its code spells in regional indicator letters. */\nexport function countryFlag(country: string): string {\n return [...country.toUpperCase()]\n .map(letter => String.fromCodePoint(0x1f1e6 + letter.charCodeAt(0) - 65))\n .join('')\n}\n\n/** The calling code an E.164 number (whole or begun) starts with, or `undefined`. */\nexport function callingCodeOf(\n value: string | null | undefined,\n metadata: MetadataJson = phoneMetadata,\n): string | undefined {\n if (!value?.startsWith('+')) return undefined\n const formatter = new AsYouType(undefined, metadata)\n formatter.input(value)\n return formatter.getCallingCode()\n}\n\n/**\n * The country of an E.164 number: `current` when the number has its calling code (so a\n * Canadian number stays Canadian while `+1` is typed), else the country the number belongs to,\n * else the main country of its calling code (`US` for `+1`, `GB` for `+44`). `undefined` for a\n * number with no calling code yet.\n */\nexport function countryOfPhone(\n value: string | null | undefined,\n current?: CountryCode,\n metadata: MetadataJson = phoneMetadata,\n): CountryCode | undefined {\n const code = callingCodeOf(value, metadata)\n if (!code) return undefined\n if (current && callingCode(current, metadata) === code) return current\n const parsed = parsePhoneNumberFromString(value!, metadata)\n if (parsed?.country) return parsed.country\n const main = (metadata as { country_calling_codes?: Record<string, string[]> })\n .country_calling_codes?.[code]?.[0]\n return main as CountryCode | undefined\n}\n\n/**\n * Whether a stored number is a valid phone number, for a validator. A number without a `+`\n * is read as `country`'s. Uses libphonenumber-js's `min` metadata unless given other metadata,\n * which checks a number's length for its country.\n *\n * isValidPhone('+12125550123') // true\n */\nexport function isValidPhone(\n value: string | null | undefined,\n country?: CountryCode,\n metadata: MetadataJson = phoneMetadata,\n): boolean {\n if (!value) return false\n return isValidPhoneNumber(value, { defaultCountry: country }, metadata)\n}\n\n/**\n * A stored number in international format (`+1 212 555 0123`), to show it outside an input.\n * Anything that doesn't parse is shown as it is.\n */\nexport function formatPhone(\n value: string | null | undefined,\n metadata: MetadataJson = phoneMetadata,\n): string {\n if (!value) return ''\n return parsePhoneNumberFromString(value, metadata)?.formatInternational() ?? value\n}\n"],"names":["phoneMetadata","minMetadata","phoneMask","country","national","metadata","options","maskitoPhone","countryIsoCode","strict","format","prefix","getCountryCallingCode","plugins","maskitoAddOnFocusPlugin","maskitoRemoveOnBlurPlugin","phoneCountries","getCountries","callingCode","countryFlag","toUpperCase","map","letter","String","fromCodePoint","charCodeAt","join","callingCodeOf","value","startsWith","undefined","formatter","AsYouType","input","getCallingCode","countryOfPhone","current","code","parsed","parsePhoneNumberFromString","main","country_calling_codes","isValidPhone","isValidPhoneNumber","defaultCountry","formatPhone","formatInternational"],"mappings":";;;;;AAgBA;AACO,MAAMA,aAAa,GAAGC;;AAE7B;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CACvBC,OAAoB,EACpB;AAAEC,EAAAA,QAAQ,GAAG,KAAK;AAAEC,EAAAA,QAAQ,GAAGL;AAAgC,CAAC,GAAG,EAAE,EACrD;EAChB,MAAMM,OAAO,GAAGC,YAAY,CAAC;AAC3BC,IAAAA,cAAc,EAAEL,OAAO;IACvBE,QAAQ;AACRI,IAAAA,MAAM,EAAE,IAAI;AACZC,IAAAA,MAAM,EAAEN,QAAQ,GAAG,UAAU,GAAG;AAClC,GAAC,CAAC;EACF,IAAIA,QAAQ,EAAE,OAAOE,OAAO;EAC5B,MAAMK,MAAM,GAAG,CAAA,CAAA,EAAIC,qBAAqB,CAACT,OAAO,EAAEE,QAAQ,CAAC,CAAA,CAAA,CAAG;EAC9D,OAAO;AACL,IAAA,GAAGC,OAAO;AACVO,IAAAA,OAAO,EAAE,CACP,GAAGP,OAAO,CAACO,OAAO,EAClBC,uBAAuB,CAACH,MAAM,CAAC,EAC/BI,yBAAyB,CAACJ,MAAM,CAAC;GAEpC;AACH;;AAEA;AACO,SAASK,cAAcA,CAACX,QAAsB,GAAGL,aAAa,EAAiB;EACpF,OAAOiB,YAA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O,EAAE,OAAOmC,MAAM,CAACnC,OAAO;EAC1C,MAAMqC,IAAI,GAAInC,QAAQ,CACnBoC,qBAAqB,GAAGJ,IAAI,CAAC,GAAG,CAAC,CAAC;AACrC,EAAA,OAAOG,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAC1Bd,KAAgC,EAChCzB,OAAqB,EACrBE,QAAsB,GAAGL,aAAa,EAC7B;AACT,EAAA,IAAI,CAAC4B,KAAK,EAAE,OAAO,KAAK;EACxB,OAAOe,kBAAkB,CAACf,KAAK,EAAE;AAAEgB,IAAAA,cAAc,EAAEzC;GAAS,EAAEE,QAAQ,CAAC;AACzE;;AAEA;AACA;AACA;AACA;AACO,SAASwC,WAAWA,CACzBjB,KAAgC,EAChCvB,QAAsB,GAAGL,aAAa,EAC9B;AACR,EAAA,IAAI,CAAC4B,KAAK,EAAE,OAAO,EAAE;EACrB,OAAOW,0BAA0B,CAACX,KAAK,EAAEvB,QAAQ,CAAC,EAAEyC,mBAAmB,EAAE,IAAIlB,KAAK;AACpF;;"}
@@ -0,0 +1,122 @@
1
+ import { maskitoDate, maskitoDateRange, maskitoDateTime, maskitoStringifyDate, maskitoStringifyNumber, maskitoStringifyTime, maskitoNumber, maskitoParseDate, maskitoParseNumber, maskitoParseTime, maskitoTime } from '@maskito/kit';
2
+
3
+ /** A date preset's parameters: `@maskito/kit`'s, each optional. */
4
+
5
+ /** A time preset's parameters: `@maskito/kit`'s, each optional. */
6
+
7
+ /** A date and time preset's parameters: `@maskito/kit`'s, each optional. */
8
+
9
+ /** A date range preset's parameters: `@maskito/kit`'s, each optional. */
10
+
11
+ /**
12
+ * Without a mode or a locale, dates are written `dd/mm/yyyy`, with slashes, as the mode's name
13
+ * says (`@maskito/kit` would separate them with dots).
14
+ */
15
+ const DATE_MODE = 'dd/mm/yyyy';
16
+ const DATE_SEPARATOR = '/';
17
+ /** Without a mode, times are `HH:MM`. */
18
+ const TIME_MODE = 'HH:MM';
19
+ function dateParams(params) {
20
+ if (params.locale) return params;
21
+ return {
22
+ ...params,
23
+ mode: params.mode ?? DATE_MODE,
24
+ separator: params.separator ?? DATE_SEPARATOR
25
+ };
26
+ }
27
+ function timeParams(params) {
28
+ return {
29
+ ...params,
30
+ mode: params.mode ?? TIME_MODE
31
+ };
32
+ }
33
+
34
+ /**
35
+ * A number: digits, a decimal separator, a thousands separator, and a minus sign, a prefix or a
36
+ * postfix if you give them (`@maskito/kit`'s `maskitoNumber`).
37
+ *
38
+ * <MaskedInput @mask={{numberMask maximumFractionDigits=2 prefix="$"}} />
39
+ *
40
+ * `min` and `max` clamp it, and `locale` takes its separators from that locale.
41
+ */
42
+ function numberMask(params = {}) {
43
+ return maskitoNumber(params);
44
+ }
45
+
46
+ /**
47
+ * A date (`@maskito/kit`'s `maskitoDate`): `dd/mm/yyyy` unless `mode` (`mm/dd/yyyy`,
48
+ * `yyyy/mm/dd`, `mm/yy`…) says otherwise, separated by `separator` (default `/`), within `min`
49
+ * and `max`. With `locale` (`en-US`, `de-DE`), the order and separator are that locale's.
50
+ */
51
+ function dateMask(params = {}) {
52
+ return maskitoDate(dateParams(params));
53
+ }
54
+
55
+ /**
56
+ * A time (`@maskito/kit`'s `maskitoTime`): `HH:MM` unless `mode` (`HH:MM:SS`, `HH:MM AA`, `MM:SS`…)
57
+ * says otherwise, with `step` for the arrow keys.
58
+ */
59
+ function timeMask(params = {}) {
60
+ return maskitoTime(timeParams(params));
61
+ }
62
+
63
+ /** A date and a time (`@maskito/kit`'s `maskitoDateTime`): `dd/mm/yyyy, HH:MM` by default. */
64
+ function dateTimeMask(params = {}) {
65
+ const date = params.locale ? params : {
66
+ ...params,
67
+ dateMode: params.dateMode ?? DATE_MODE,
68
+ dateSeparator: params.dateSeparator ?? DATE_SEPARATOR
69
+ };
70
+ return maskitoDateTime({
71
+ ...date,
72
+ timeMode: params.timeMode ?? TIME_MODE
73
+ });
74
+ }
75
+
76
+ /** Two dates (`@maskito/kit`'s `maskitoDateRange`): `dd/mm/yyyy – dd/mm/yyyy` by default. */
77
+ function dateRangeMask(params = {}) {
78
+ const range = params.locale ? params : {
79
+ ...params,
80
+ mode: params.mode ?? DATE_MODE,
81
+ dateSeparator: params.dateSeparator ?? DATE_SEPARATOR
82
+ };
83
+ return maskitoDateRange(range);
84
+ }
85
+
86
+ /**
87
+ * The number a `numberMask` input shows, or `NaN` while it shows none. Give it the preset's
88
+ * parameters, so it reads the same separators.
89
+ *
90
+ * parseNumber('$1,234.50', { prefix: '$' }) // 1234.5
91
+ */
92
+ function parseNumber(text, params = {}) {
93
+ return maskitoParseNumber(text, params);
94
+ }
95
+
96
+ /** A number as a `numberMask` input with these parameters shows it. */
97
+ function formatNumber(number, params = {}) {
98
+ return maskitoStringifyNumber(number, params);
99
+ }
100
+
101
+ /** The date a `dateMask` input shows, or `null` while it shows no whole date. */
102
+ function parseDate(text, params = {}) {
103
+ return maskitoParseDate(text, dateParams(params));
104
+ }
105
+
106
+ /** A date as a `dateMask` input with these parameters shows it. */
107
+ function formatDate(date, params = {}) {
108
+ return maskitoStringifyDate(date, dateParams(params));
109
+ }
110
+
111
+ /** The time a `timeMask` input shows, in milliseconds since midnight. */
112
+ function parseTime(text, params = {}) {
113
+ return maskitoParseTime(text, timeParams(params));
114
+ }
115
+
116
+ /** A time, in milliseconds since midnight, as a `timeMask` input with these parameters shows it. */
117
+ function formatTime(milliseconds, params = {}) {
118
+ return maskitoStringifyTime(milliseconds, timeParams(params));
119
+ }
120
+
121
+ export { dateMask, dateRangeMask, dateTimeMask, formatDate, formatNumber, formatTime, numberMask, parseDate, parseNumber, parseTime, timeMask };
122
+ //# sourceMappingURL=presets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.js","sources":["../src/presets.ts"],"sourcesContent":["import type { MaskitoOptions } from '@maskito/core'\nimport {\n maskitoDate,\n maskitoDateRange,\n maskitoDateTime,\n maskitoNumber,\n maskitoParseDate,\n maskitoParseNumber,\n maskitoParseTime,\n maskitoStringifyDate,\n maskitoStringifyNumber,\n maskitoStringifyTime,\n maskitoTime,\n type MaskitoDateMode,\n type MaskitoDateParams,\n type MaskitoDateRangeParams,\n type MaskitoDateTimeParams,\n type MaskitoNumberParams,\n type MaskitoTimeMode,\n type MaskitoTimeParams,\n} from '@maskito/kit'\n\nexport type {\n MaskitoDateMode,\n MaskitoDateParams,\n MaskitoDateRangeParams,\n MaskitoDateTimeParams,\n MaskitoNumberParams,\n MaskitoTimeMode,\n MaskitoTimeParams,\n}\n\n/** A date preset's parameters: `@maskito/kit`'s, each optional. */\nexport type DateMaskParams = Partial<MaskitoDateParams>\n\n/** A time preset's parameters: `@maskito/kit`'s, each optional. */\nexport type TimeMaskParams = Partial<MaskitoTimeParams>\n\n/** A date and time preset's parameters: `@maskito/kit`'s, each optional. */\nexport type DateTimeMaskParams = Partial<MaskitoDateTimeParams>\n\n/** A date range preset's parameters: `@maskito/kit`'s, each optional. */\nexport type DateRangeMaskParams = Partial<MaskitoDateRangeParams>\n\n/**\n * Without a mode or a locale, dates are written `dd/mm/yyyy`, with slashes, as the mode's name\n * says (`@maskito/kit` would separate them with dots).\n */\nconst DATE_MODE: MaskitoDateMode = 'dd/mm/yyyy'\nconst DATE_SEPARATOR = '/'\n/** Without a mode, times are `HH:MM`. */\nconst TIME_MODE: MaskitoTimeMode = 'HH:MM'\n\nfunction dateParams(params: DateMaskParams): MaskitoDateParams {\n if (params.locale) return params as MaskitoDateParams\n return {\n ...params,\n mode: params.mode ?? DATE_MODE,\n separator: params.separator ?? DATE_SEPARATOR,\n }\n}\n\nfunction timeParams(params: TimeMaskParams): MaskitoTimeParams {\n return { ...params, mode: params.mode ?? TIME_MODE }\n}\n\n/**\n * A number: digits, a decimal separator, a thousands separator, and a minus sign, a prefix or a\n * postfix if you give them (`@maskito/kit`'s `maskitoNumber`).\n *\n * <MaskedInput @mask={{numberMask maximumFractionDigits=2 prefix=\"$\"}} />\n *\n * `min` and `max` clamp it, and `locale` takes its separators from that locale.\n */\nexport function numberMask(params: MaskitoNumberParams = {}): MaskitoOptions {\n return maskitoNumber(params)\n}\n\n/**\n * A date (`@maskito/kit`'s `maskitoDate`): `dd/mm/yyyy` unless `mode` (`mm/dd/yyyy`,\n * `yyyy/mm/dd`, `mm/yy`…) says otherwise, separated by `separator` (default `/`), within `min`\n * and `max`. With `locale` (`en-US`, `de-DE`), the order and separator are that locale's.\n */\nexport function dateMask(params: DateMaskParams = {}): MaskitoOptions {\n return maskitoDate(dateParams(params))\n}\n\n/**\n * A time (`@maskito/kit`'s `maskitoTime`): `HH:MM` unless `mode` (`HH:MM:SS`, `HH:MM AA`, `MM:SS`…)\n * says otherwise, with `step` for the arrow keys.\n */\nexport function timeMask(params: TimeMaskParams = {}): MaskitoOptions {\n return maskitoTime(timeParams(params))\n}\n\n/** A date and a time (`@maskito/kit`'s `maskitoDateTime`): `dd/mm/yyyy, HH:MM` by default. */\nexport function dateTimeMask(params: DateTimeMaskParams = {}): MaskitoOptions {\n const date = params.locale\n ? params\n : {\n ...params,\n dateMode: params.dateMode ?? DATE_MODE,\n dateSeparator: params.dateSeparator ?? DATE_SEPARATOR,\n }\n return maskitoDateTime({\n ...date,\n timeMode: params.timeMode ?? TIME_MODE,\n } as MaskitoDateTimeParams)\n}\n\n/** Two dates (`@maskito/kit`'s `maskitoDateRange`): `dd/mm/yyyy – dd/mm/yyyy` by default. */\nexport function dateRangeMask(params: DateRangeMaskParams = {}): MaskitoOptions {\n const range = params.locale\n ? params\n : {\n ...params,\n mode: params.mode ?? DATE_MODE,\n dateSeparator: params.dateSeparator ?? DATE_SEPARATOR,\n }\n return maskitoDateRange(range as MaskitoDateRangeParams)\n}\n\n/**\n * The number a `numberMask` input shows, or `NaN` while it shows none. Give it the preset's\n * parameters, so it reads the same separators.\n *\n * parseNumber('$1,234.50', { prefix: '$' }) // 1234.5\n */\nexport function parseNumber(text: string, params: MaskitoNumberParams = {}): number {\n return maskitoParseNumber(text, params)\n}\n\n/** A number as a `numberMask` input with these parameters shows it. */\nexport function formatNumber(number: number | null, params: MaskitoNumberParams = {}): string {\n return maskitoStringifyNumber(number, params)\n}\n\n/** The date a `dateMask` input shows, or `null` while it shows no whole date. */\nexport function parseDate(text: string, params: DateMaskParams = {}): Date | null {\n return maskitoParseDate(text, dateParams(params))\n}\n\n/** A date as a `dateMask` input with these parameters shows it. */\nexport function formatDate(date: Date, params: DateMaskParams = {}): string {\n return maskitoStringifyDate(date, dateParams(params))\n}\n\n/** The time a `timeMask` input shows, in milliseconds since midnight. */\nexport function parseTime(text: string, params: TimeMaskParams = {}): number {\n return maskitoParseTime(text, timeParams(params))\n}\n\n/** A time, in milliseconds since midnight, as a `timeMask` input with these parameters shows it. */\nexport function formatTime(milliseconds: number, params: TimeMaskParams = {}): string {\n return maskitoStringifyTime(milliseconds, timeParams(params))\n}\n"],"names":["DATE_MODE","DATE_SEPARATOR","TIME_MODE","dateParams","params","locale","mode","separator","timeParams","numberMask","maskitoNumber","dateMask","maskitoDate","timeMask","maskitoTime","dateTimeMask","date","dateMode","dateSeparator","maskitoDateTime","timeMode","dateRangeMask","range","maskitoDateRange","parseNumber","text","maskitoParseNumber","formatNumber","number","maskitoStringifyNumber","parseDate","maskitoParseDate","formatDate","maskitoStringifyDate","parseTime","maskitoParseTime","formatTime","milliseconds","maskitoStringifyTime"],"mappings":";;AAgCA;;AAGA;;AAGA;;AAGA;;AAGA;AACA;AACA;AACA;AACA,MAAMA,SAA0B,GAAG,YAAY;AAC/C,MAAMC,cAAc,GAAG,GAAG;AAC1B;AACA,MAAMC,SAA0B,GAAG,OAAO;AAE1C,SAASC,UAAUA,CAACC,MAAsB,EAAqB;AAC7D,EAAA,IAAIA,MAAM,CAACC,MAAM,EAAE,OAAOD,MAAM;EAChC,OAAO;AACL,IAAA,GAAGA,MAAM;AACTE,IAAAA,IAAI,EAAEF,MAAM,CAACE,IAAI,IAAIN,SAAS;AAC9BO,IAAAA,SAAS,EAAEH,MAAM,CAACG,SAAS,IAAIN;GAChC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AEd,MAAM,CAACc,aAAa,IAAIjB;GACxC;EACL,OAAOsB,gBAAgB,CAACD,KAA+B,CAAC;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,WAAWA,CAACC,IAAY,EAAErB,MAA2B,GAAG,EAAE,EAAU;AAClF,EAAA,OAAOsB,kBAAkB,CAACD,IAAI,EAAErB,MAAM,CAAC;AACzC;;AAEA;AACO,SAASuB,YAAYA,CAACC,MAAqB,EAAExB,MAA2B,GAAG,EAAE,EAAU;AAC5F,EAAA,OAAOyB,sBAAsB,CAACD,MAAM,EAAExB,MAAM,CAAC;AAC/C;;AAEA;AACO,SAAS0B,SAASA,CAACL,IAAY,EAAErB,MAAsB,GAAG,EAAE,EAAe;EAChF,OAAO2B,gBAAgB,CAACN,IAAI,EAAEtB,UAAU,CAACC,MAAM,CAAC,CAAC;AACnD;;AAEA;AACO,SAAS4B,UAAUA,CAAChB,IAAU,EAAEZ,MAAsB,GAAG,EAAE,EAAU;EAC1E,OAAO6B,oBAAoB,CAACjB,IAAI,EAAEb,UAAU,CAACC,MAAM,CAAC,CAAC;AACvD;;AAEA;AACO,SAAS8B,SAASA,CAACT,IAAY,EAAErB,MAAsB,GAAG,EAAE,EAAU;EAC3E,OAAO+B,gBAAgB,CAACV,IAAI,EAAEjB,UAAU,CAACJ,MAAM,CAAC,CAAC;AACnD;;AAEA;AACO,SAASgC,UAAUA,CAACC,YAAoB,EAAEjC,MAAsB,GAAG,EAAE,EAAU;EACpF,OAAOkC,oBAAoB,CAACD,YAAY,EAAE7B,UAAU,CAACJ,MAAM,CAAC,CAAC;AAC/D;;"}
@@ -0,0 +1,330 @@
1
+ import { InputHarness, Harness, SelectHarness } from '@ember-joinery/test-support';
2
+ import { focus, settled, triggerKeyEvent } from '@ember/test-helpers';
3
+
4
+ /**
5
+ * One edit as a browser makes it: a cancelable `beforeinput` (which Maskito answers), then, if
6
+ * nothing cancelled it, the edit itself and an `input`.
7
+ */
8
+ function edit(element, inputType, data, apply, dataTransfer = null) {
9
+ const before = new InputEvent('beforeinput', {
10
+ inputType,
11
+ data,
12
+ dataTransfer,
13
+ bubbles: true,
14
+ cancelable: true,
15
+ composed: true
16
+ });
17
+ if (!element.dispatchEvent(before)) return;
18
+ const from = element.selectionStart ?? element.value.length;
19
+ const to = element.selectionEnd ?? from;
20
+ apply(from, to);
21
+ element.dispatchEvent(new InputEvent('input', {
22
+ inputType,
23
+ data,
24
+ dataTransfer,
25
+ bubbles: true,
26
+ composed: true
27
+ }));
28
+ }
29
+
30
+ /** Puts the caret at the end, as a click after the text would. */
31
+ function caretToEnd(element) {
32
+ const end = element.value.length;
33
+ element.setSelectionRange(end, end);
34
+ }
35
+
36
+ /** Types `text` one character at a time at the caret (the end), as a keyboard does. */
37
+ async function typeText(element, text) {
38
+ await focus(element);
39
+ caretToEnd(element);
40
+ for (const char of text) {
41
+ edit(element, 'insertText', char, (from, to) => element.setRangeText(char, from, to, 'end'));
42
+ }
43
+ await settled();
44
+ }
45
+
46
+ /** Presses Backspace `times` times with the caret at the end. */
47
+ async function backspace(element, times = 1) {
48
+ await focus(element);
49
+ caretToEnd(element);
50
+ for (let i = 0; i < times; i++) {
51
+ edit(element, 'deleteContentBackward', null, (from, to) => {
52
+ if (from === to && from > 0) element.setRangeText('', from - 1, to, 'end');else element.setRangeText('', from, to, 'end');
53
+ });
54
+ }
55
+ await settled();
56
+ }
57
+
58
+ /**
59
+ * Presses Delete `times` times, starting with the caret at `at` (a character's index), as a
60
+ * keyboard does: the caret stays where it is and the text after it moves up.
61
+ */
62
+ async function deleteForward(element, at, times = 1) {
63
+ await focus(element);
64
+ element.setSelectionRange(at, at);
65
+ for (let i = 0; i < times; i++) {
66
+ edit(element, 'deleteContentForward', null, (from, to) => {
67
+ if (from === to) element.setRangeText('', from, Math.min(from + 1, element.value.length));else element.setRangeText('', from, to, 'start');
68
+ });
69
+ }
70
+ await settled();
71
+ }
72
+
73
+ /** Z's key code, which Maskito's undo and redo shortcuts read (`keyCode`, as layouts differ). */
74
+ const Z = 90;
75
+
76
+ /** Presses Ctrl+Z, which undoes the last edit. */
77
+ async function undo(element) {
78
+ await focus(element);
79
+ await triggerKeyEvent(element, 'keydown', Z, {
80
+ ctrlKey: true
81
+ });
82
+ }
83
+
84
+ /** Presses Ctrl+Shift+Z, which redoes the edit undone last. */
85
+ async function redo(element) {
86
+ await focus(element);
87
+ await triggerKeyEvent(element, 'keydown', Z, {
88
+ ctrlKey: true,
89
+ shiftKey: true
90
+ });
91
+ }
92
+
93
+ /**
94
+ * Drops `text` at the end, as a drag and drop of text does: a cancelable `beforeinput`
95
+ * (`insertFromDrop`, with the text as its `data` and on its `dataTransfer`), then, if nothing
96
+ * cancelled it, the insertion and an `input`.
97
+ */
98
+ async function dropText(element, text) {
99
+ await focus(element);
100
+ caretToEnd(element);
101
+ const dataTransfer = new DataTransfer();
102
+ dataTransfer.setData('text/plain', text);
103
+ edit(element, 'insertFromDrop', text, (from, to) => element.setRangeText(text, from, to, 'end'), dataTransfer);
104
+ await settled();
105
+ }
106
+
107
+ /**
108
+ * Pastes `text` over what the element holds, as a user who selects it all and pastes does: a
109
+ * `paste` event with the text on its clipboard (which a component may take over), then, if
110
+ * nothing cancelled it, the insertion.
111
+ */
112
+ async function pasteText(element, text) {
113
+ await focus(element);
114
+ element.setSelectionRange(0, element.value.length);
115
+ const clipboardData = new DataTransfer();
116
+ clipboardData.setData('text/plain', text);
117
+ const paste = new ClipboardEvent('paste', {
118
+ clipboardData,
119
+ bubbles: true,
120
+ cancelable: true,
121
+ composed: true
122
+ });
123
+ if (element.dispatchEvent(paste)) {
124
+ edit(element, 'insertFromPaste', text, (from, to) => element.setRangeText(text, from, to, 'end'));
125
+ }
126
+ await settled();
127
+ }
128
+
129
+ /**
130
+ * Drives a `<MaskedInput>` from `@ember-joinery/maskito`. It is an `InputHarness` (its `value`,
131
+ * `label`, `fillIn()` and the rest), and it types the way a browser does, so the mask answers
132
+ * each keystroke as it would a user's.
133
+ *
134
+ * const price = new MaskedInputHarness('price') // <MaskedInput @name="price">
135
+ * await price.typeText('1234.5')
136
+ * assert.strictEqual(price.value, '1,234.5')
137
+ *
138
+ * `fillIn()` replaces the text at once, as autofill does, and the mask shapes the result.
139
+ */
140
+ class MaskedInputHarness extends InputHarness {
141
+ static component = 'masked-input';
142
+
143
+ /**
144
+ * Types `text` at the end, one character at a time, each with the `beforeinput` and `input`
145
+ * a keyboard sends; the mask turns away what doesn't fit.
146
+ */
147
+ async typeText(text) {
148
+ await typeText(this.control, text);
149
+ }
150
+
151
+ /** Presses Backspace at the end, `times` times; the mask steps over its fixed characters. */
152
+ async backspace(times = 1) {
153
+ await backspace(this.control, times);
154
+ }
155
+
156
+ /**
157
+ * Presses Delete `times` times with the caret at `at` (a character's index); the mask steps
158
+ * over its fixed characters.
159
+ */
160
+ async deleteForward(at, times = 1) {
161
+ await deleteForward(this.control, at, times);
162
+ }
163
+
164
+ /** Selects everything and pastes `text` over it, as a user does. */
165
+ async paste(text) {
166
+ await pasteText(this.control, text);
167
+ }
168
+
169
+ /** Drops `text` at the end, as a drag and drop does; the mask shapes it. */
170
+ async drop(text) {
171
+ await dropText(this.control, text);
172
+ }
173
+
174
+ /** Presses Ctrl+Z: the mask undoes the last edit. */
175
+ async undo() {
176
+ await undo(this.control);
177
+ }
178
+
179
+ /** Presses Ctrl+Shift+Z: the mask redoes the edit undone last. */
180
+ async redo() {
181
+ await redo(this.control);
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Drives a `<PhoneInput>` from `@ember-joinery/maskito`: its input (an `InputHarness`) and its
187
+ * country picker (a `SelectHarness`). It reads what the input shows, masked, and the country
188
+ * chosen; the number it stores, in E.164 form, is what `@onValueChange` hears.
189
+ *
190
+ * const phone = new PhoneInputHarness('phone') // <PhoneInput @name="phone">
191
+ * await phone.selectCountry('GB')
192
+ * await phone.typeText('7911123456')
193
+ * assert.strictEqual(phone.value, '+44 7911 123456')
194
+ * assert.strictEqual(phone.country, 'GB')
195
+ */
196
+ class PhoneInputHarness extends Harness {
197
+ static component = 'phone-input';
198
+
199
+ /** The input, as an `InputHarness`: its `label`, `description`, `isInvalid`, `fillIn()`… */
200
+ get input() {
201
+ return this.child(InputHarness);
202
+ }
203
+
204
+ /** The country picker, as a `SelectHarness`: its `options`, `open()`, `typeahead()`… */
205
+ get picker() {
206
+ return this.child(SelectHarness, 'country');
207
+ }
208
+
209
+ /** The `<input type="tel">` itself. */
210
+ get control() {
211
+ return this.input.control;
212
+ }
213
+
214
+ /** The Input Group around the input and the picker. */
215
+ get group() {
216
+ return this.picker.part('group');
217
+ }
218
+
219
+ /** What the input shows, masked: `+1 212 555-0123`. */
220
+ get value() {
221
+ return this.control.value;
222
+ }
223
+
224
+ /** The country shown, as its ISO 3166 code (`US`). */
225
+ get country() {
226
+ return this.element.getAttribute('data-test-jn-value') ?? '';
227
+ }
228
+
229
+ /** The name of the country shown, as the picker reads it to assistive technology. */
230
+ get countryName() {
231
+ return this.picker.part('country-name').textContent?.trim() ?? '';
232
+ }
233
+
234
+ /** The flag the picker shows. */
235
+ get flag() {
236
+ return this.picker.trigger.querySelector('.jn-phone-input-flag')?.textContent?.trim() ?? '';
237
+ }
238
+
239
+ /** The calling code beside the flag (`+1`), in the national format; `''` otherwise. */
240
+ get callingCode() {
241
+ return this.picker.queryPart('calling-code')?.textContent?.trim() ?? '';
242
+ }
243
+
244
+ /** The input's accessible name. */
245
+ get label() {
246
+ return this.input.label;
247
+ }
248
+
249
+ /** The text of what the input's `aria-describedby` names. */
250
+ get description() {
251
+ return this.input.description;
252
+ }
253
+
254
+ /** The input's placeholder. */
255
+ get placeholder() {
256
+ return this.input.placeholder;
257
+ }
258
+
259
+ /** Whether the input and the picker are disabled. */
260
+ get isDisabled() {
261
+ return this.input.isDisabled && this.picker.isDisabled;
262
+ }
263
+
264
+ /** Whether the input is marked invalid (`aria-invalid`), which rings the whole group. */
265
+ get isInvalid() {
266
+ return this.input.isInvalid;
267
+ }
268
+
269
+ /** Whether the input has focus. */
270
+ get isFocused() {
271
+ return this.input.isFocused;
272
+ }
273
+
274
+ /** The country codes the picker offers, in order. It opens the picker to read them. */
275
+ async countries() {
276
+ if (!this.picker.isOpen) await this.picker.open();
277
+ return this.picker.options;
278
+ }
279
+
280
+ /** Opens the picker and chooses the country with this ISO 3166 code. */
281
+ async selectCountry(code) {
282
+ await this.picker.select(code);
283
+ }
284
+
285
+ /** Types `text` at the end, one character at a time, as a keyboard does. */
286
+ async typeText(text) {
287
+ await typeText(this.control, text);
288
+ }
289
+
290
+ /** Presses Backspace at the end, `times` times. */
291
+ async backspace(times = 1) {
292
+ await backspace(this.control, times);
293
+ }
294
+
295
+ /** Selects everything and pastes `text` over it; an international number switches country. */
296
+ async paste(text) {
297
+ await pasteText(this.control, text);
298
+ }
299
+
300
+ /** Drops `text` at the end, as a drag and drop does; an international number switches country. */
301
+ async drop(text) {
302
+ await dropText(this.control, text);
303
+ }
304
+
305
+ /**
306
+ * Replaces the text at once, with an `input` and no `inputType`, as Chrome's autofill does;
307
+ * an international number switches country, and the mask shapes anything else.
308
+ */
309
+ async fillIn(text) {
310
+ await this.input.fillIn(text);
311
+ }
312
+
313
+ /** Empties the input. */
314
+ async clear() {
315
+ await this.input.fillIn('');
316
+ }
317
+
318
+ /** Moves focus to the input. */
319
+ async focus() {
320
+ await this.input.focus();
321
+ }
322
+
323
+ /** Takes focus off the input; a calling code with nothing after it comes out. */
324
+ async blur() {
325
+ await this.input.blur();
326
+ }
327
+ }
328
+
329
+ export { MaskedInputHarness, PhoneInputHarness };
330
+ //# sourceMappingURL=test-support.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-support.js","sources":["../src/test-support/-private/typing.ts","../src/test-support/masked-input.ts","../src/test-support/phone-input.ts"],"sourcesContent":["import { focus, settled, triggerKeyEvent } from '@ember/test-helpers'\n\ntype TextControl = HTMLInputElement | HTMLTextAreaElement\n\n/**\n * One edit as a browser makes it: a cancelable `beforeinput` (which Maskito answers), then, if\n * nothing cancelled it, the edit itself and an `input`.\n */\nfunction edit(\n element: TextControl,\n inputType: string,\n data: string | null,\n apply: (from: number, to: number) => void,\n dataTransfer: DataTransfer | null = null,\n): void {\n const before = new InputEvent('beforeinput', {\n inputType,\n data,\n dataTransfer,\n bubbles: true,\n cancelable: true,\n composed: true,\n })\n if (!element.dispatchEvent(before)) return\n const from = element.selectionStart ?? element.value.length\n const to = element.selectionEnd ?? from\n apply(from, to)\n element.dispatchEvent(\n new InputEvent('input', { inputType, data, dataTransfer, bubbles: true, composed: true }),\n )\n}\n\n/** Puts the caret at the end, as a click after the text would. */\nfunction caretToEnd(element: TextControl): void {\n const end = element.value.length\n element.setSelectionRange(end, end)\n}\n\n/** Types `text` one character at a time at the caret (the end), as a keyboard does. */\nexport async function typeText(element: TextControl, text: string): Promise<void> {\n await focus(element)\n caretToEnd(element)\n for (const char of text) {\n edit(element, 'insertText', char, (from, to) => element.setRangeText(char, from, to, 'end'))\n }\n await settled()\n}\n\n/** Presses Backspace `times` times with the caret at the end. */\nexport async function backspace(element: TextControl, times = 1): Promise<void> {\n await focus(element)\n caretToEnd(element)\n for (let i = 0; i < times; i++) {\n edit(element, 'deleteContentBackward', null, (from, to) => {\n if (from === to && from > 0) element.setRangeText('', from - 1, to, 'end')\n else element.setRangeText('', from, to, 'end')\n })\n }\n await settled()\n}\n\n/**\n * Presses Delete `times` times, starting with the caret at `at` (a character's index), as a\n * keyboard does: the caret stays where it is and the text after it moves up.\n */\nexport async function deleteForward(element: TextControl, at: number, times = 1): Promise<void> {\n await focus(element)\n element.setSelectionRange(at, at)\n for (let i = 0; i < times; i++) {\n edit(element, 'deleteContentForward', null, (from, to) => {\n if (from === to) element.setRangeText('', from, Math.min(from + 1, element.value.length))\n else element.setRangeText('', from, to, 'start')\n })\n }\n await settled()\n}\n\n/** Z's key code, which Maskito's undo and redo shortcuts read (`keyCode`, as layouts differ). */\nconst Z = 90\n\n/** Presses Ctrl+Z, which undoes the last edit. */\nexport async function undo(element: TextControl): Promise<void> {\n await focus(element)\n await triggerKeyEvent(element, 'keydown', Z, { ctrlKey: true })\n}\n\n/** Presses Ctrl+Shift+Z, which redoes the edit undone last. */\nexport async function redo(element: TextControl): Promise<void> {\n await focus(element)\n await triggerKeyEvent(element, 'keydown', Z, { ctrlKey: true, shiftKey: true })\n}\n\n/**\n * Drops `text` at the end, as a drag and drop of text does: a cancelable `beforeinput`\n * (`insertFromDrop`, with the text as its `data` and on its `dataTransfer`), then, if nothing\n * cancelled it, the insertion and an `input`.\n */\nexport async function dropText(element: TextControl, text: string): Promise<void> {\n await focus(element)\n caretToEnd(element)\n const dataTransfer = new DataTransfer()\n dataTransfer.setData('text/plain', text)\n edit(\n element,\n 'insertFromDrop',\n text,\n (from, to) => element.setRangeText(text, from, to, 'end'),\n dataTransfer,\n )\n await settled()\n}\n\n/**\n * Pastes `text` over what the element holds, as a user who selects it all and pastes does: a\n * `paste` event with the text on its clipboard (which a component may take over), then, if\n * nothing cancelled it, the insertion.\n */\nexport async function pasteText(element: TextControl, text: string): Promise<void> {\n await focus(element)\n element.setSelectionRange(0, element.value.length)\n const clipboardData = new DataTransfer()\n clipboardData.setData('text/plain', text)\n const paste = new ClipboardEvent('paste', {\n clipboardData,\n bubbles: true,\n cancelable: true,\n composed: true,\n })\n if (element.dispatchEvent(paste)) {\n edit(element, 'insertFromPaste', text, (from, to) =>\n element.setRangeText(text, from, to, 'end'),\n )\n }\n await settled()\n}\n","import { InputHarness } from '@ember-joinery/test-support'\nimport {\n backspace,\n deleteForward,\n dropText,\n pasteText,\n redo,\n typeText,\n undo,\n} from './-private/typing.ts'\n\n/**\n * Drives a `<MaskedInput>` from `@ember-joinery/maskito`. It is an `InputHarness` (its `value`,\n * `label`, `fillIn()` and the rest), and it types the way a browser does, so the mask answers\n * each keystroke as it would a user's.\n *\n * const price = new MaskedInputHarness('price') // <MaskedInput @name=\"price\">\n * await price.typeText('1234.5')\n * assert.strictEqual(price.value, '1,234.5')\n *\n * `fillIn()` replaces the text at once, as autofill does, and the mask shapes the result.\n */\nexport class MaskedInputHarness extends InputHarness {\n static override component = 'masked-input'\n\n /**\n * Types `text` at the end, one character at a time, each with the `beforeinput` and `input`\n * a keyboard sends; the mask turns away what doesn't fit.\n */\n async typeText(text: string): Promise<void> {\n await typeText(this.control, text)\n }\n\n /** Presses Backspace at the end, `times` times; the mask steps over its fixed characters. */\n async backspace(times = 1): Promise<void> {\n await backspace(this.control, times)\n }\n\n /**\n * Presses Delete `times` times with the caret at `at` (a character's index); the mask steps\n * over its fixed characters.\n */\n async deleteForward(at: number, times = 1): Promise<void> {\n await deleteForward(this.control, at, times)\n }\n\n /** Selects everything and pastes `text` over it, as a user does. */\n async paste(text: string): Promise<void> {\n await pasteText(this.control, text)\n }\n\n /** Drops `text` at the end, as a drag and drop does; the mask shapes it. */\n async drop(text: string): Promise<void> {\n await dropText(this.control, text)\n }\n\n /** Presses Ctrl+Z: the mask undoes the last edit. */\n async undo(): Promise<void> {\n await undo(this.control)\n }\n\n /** Presses Ctrl+Shift+Z: the mask redoes the edit undone last. */\n async redo(): Promise<void> {\n await redo(this.control)\n }\n}\n","import { InputHarness, SelectHarness } from '@ember-joinery/test-support'\nimport { Harness } from '@ember-joinery/test-support'\nimport { backspace, dropText, pasteText, typeText } from './-private/typing.ts'\n\n/**\n * Drives a `<PhoneInput>` from `@ember-joinery/maskito`: its input (an `InputHarness`) and its\n * country picker (a `SelectHarness`). It reads what the input shows, masked, and the country\n * chosen; the number it stores, in E.164 form, is what `@onValueChange` hears.\n *\n * const phone = new PhoneInputHarness('phone') // <PhoneInput @name=\"phone\">\n * await phone.selectCountry('GB')\n * await phone.typeText('7911123456')\n * assert.strictEqual(phone.value, '+44 7911 123456')\n * assert.strictEqual(phone.country, 'GB')\n */\nexport class PhoneInputHarness extends Harness {\n static override component = 'phone-input'\n\n /** The input, as an `InputHarness`: its `label`, `description`, `isInvalid`, `fillIn()`… */\n get input(): InputHarness {\n return this.child(InputHarness)\n }\n\n /** The country picker, as a `SelectHarness`: its `options`, `open()`, `typeahead()`… */\n get picker(): SelectHarness {\n return this.child(SelectHarness, 'country')\n }\n\n /** The `<input type=\"tel\">` itself. */\n get control(): HTMLInputElement {\n return this.input.control\n }\n\n /** The Input Group around the input and the picker. */\n get group(): HTMLElement {\n return this.picker.part('group')\n }\n\n /** What the input shows, masked: `+1 212 555-0123`. */\n get value(): string {\n return this.control.value\n }\n\n /** The country shown, as its ISO 3166 code (`US`). */\n get country(): string {\n return this.element.getAttribute('data-test-jn-value') ?? ''\n }\n\n /** The name of the country shown, as the picker reads it to assistive technology. */\n get countryName(): string {\n return this.picker.part('country-name').textContent?.trim() ?? ''\n }\n\n /** The flag the picker shows. */\n get flag(): string {\n return this.picker.trigger.querySelector('.jn-phone-input-flag')?.textContent?.trim() ?? ''\n }\n\n /** The calling code beside the flag (`+1`), in the national format; `''` otherwise. */\n get callingCode(): string {\n return this.picker.queryPart('calling-code')?.textContent?.trim() ?? ''\n }\n\n /** The input's accessible name. */\n get label(): string {\n return this.input.label\n }\n\n /** The text of what the input's `aria-describedby` names. */\n get description(): string {\n return this.input.description\n }\n\n /** The input's placeholder. */\n get placeholder(): string {\n return this.input.placeholder\n }\n\n /** Whether the input and the picker are disabled. */\n get isDisabled(): boolean {\n return this.input.isDisabled && this.picker.isDisabled\n }\n\n /** Whether the input is marked invalid (`aria-invalid`), which rings the whole group. */\n get isInvalid(): boolean {\n return this.input.isInvalid\n }\n\n /** Whether the input has focus. */\n get isFocused(): boolean {\n return this.input.isFocused\n }\n\n /** The country codes the picker offers, in order. It opens the picker to read them. */\n async countries(): Promise<string[]> {\n if (!this.picker.isOpen) await this.picker.open()\n return this.picker.options\n }\n\n /** Opens the picker and chooses the country with this ISO 3166 code. */\n async selectCountry(code: string): Promise<void> {\n await this.picker.select(code)\n }\n\n /** Types `text` at the end, one character at a time, as a keyboard does. */\n async typeText(text: string): Promise<void> {\n await typeText(this.control, text)\n }\n\n /** Presses Backspace at the end, `times` times. */\n async backspace(times = 1): Promise<void> {\n await backspace(this.control, times)\n }\n\n /** Selects everything and pastes `text` over it; an international number switches country. */\n async paste(text: string): Promise<void> {\n await pasteText(this.control, text)\n }\n\n /** Drops `text` at the end, as a drag and drop does; an international number switches country. */\n async drop(text: string): Promise<void> {\n await dropText(this.control, text)\n }\n\n /**\n * Replaces the text at once, with an `input` and no `inputType`, as Chrome's autofill does;\n * an international number switches country, and the mask shapes anything else.\n */\n async fillIn(text: string): Promise<void> {\n await this.input.fillIn(text)\n }\n\n /** Empties the input. */\n async clear(): Promise<void> {\n await this.input.fillIn('')\n }\n\n /** Moves focus to the input. */\n async focus(): Promise<void> {\n await this.input.focus()\n }\n\n /** Takes focus off the input; a calling code with nothing after it comes out. */\n async blur(): Promise<void> {\n await this.input.blur()\n }\n}\n"],"names":["edit","element","inputType","data","apply","dataTransfer","before","InputEvent","bubbles","cancelable","composed","dispatchEvent","from","selectionStart","value","length","to","selectionEnd","caretToEnd","end","setSelectionRange","typeText","text","focus","char","setRangeText","settled","backspace","times","i","deleteForward","at","Math","min","Z","undo","triggerKeyEvent","ctrlKey","redo","shiftKey","dropText","DataTransfer","setData","pasteText","clipboardData","paste","ClipboardEvent","MaskedInputHarness","InputHarness","component","control","drop","PhoneInputHarness","Harness","input","child","picker","SelectHarness","group","part","country","getAttribute","countryName","textContent","trim","flag","trigger","querySelector","callingCode","queryPart","label","description","placeholder","isDisabled","isInvalid","isFocused","countries","isOpen","open","options","selectCountry","code","select","fillIn","clear","blur"],"mappings":";;;AAIA;AACA;AACA;AACA;AACA,SAASA,IAAIA,CACXC,OAAoB,EACpBC,SAAiB,EACjBC,IAAmB,EACnBC,KAAyC,EACzCC,YAAiC,GAAG,IAAI,EAClC;AACN,EAAA,MAAMC,MAAM,GAAG,IAAIC,UAAU,CAAC,aAAa,EAAE;IAC3CL,SAAS;IACTC,IAAI;IACJE,YAAY;AACZG,IAAAA,OAAO,EAAE,IAAI;AACbC,IAAAA,UAAU,EAAE,IAAI;AAChBC,IAAAA,QAAQ,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