@cdx-ui/components 0.3.7 → 0.3.8
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/docs/components/content.md +2 -1
- package/docs/components/country-flag/content.md +3 -3
- package/docs/components/currency-flag/content.md +202 -0
- package/docs/components/currency-input/content.md +175 -56
- package/docs/foundations/expressions/icons/content.md +1 -1
- package/docs/getting-started/developers/styling/content.md +2 -2
- package/docs/llms.txt +3 -1
- package/docs/resources/release-notes/0.3.7/content.md +27 -0
- package/docs/resources/release-notes/content.md +1 -0
- package/lib/commonjs/components/CountryFlag/index.js +2 -2
- package/lib/commonjs/components/CountryFlag/index.js.map +1 -1
- package/lib/commonjs/components/CurrencyFlag/index.js +77 -0
- package/lib/commonjs/components/CurrencyFlag/index.js.map +1 -0
- package/lib/commonjs/components/CurrencyInput/index.js +3 -1
- package/lib/commonjs/components/CurrencyInput/index.js.map +1 -1
- package/lib/commonjs/components/CurrencyInput/styles.js +23 -7
- package/lib/commonjs/components/CurrencyInput/styles.js.map +1 -1
- package/lib/commonjs/components/index.js +12 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/module/components/CountryFlag/index.js +2 -2
- package/lib/module/components/CountryFlag/index.js.map +1 -1
- package/lib/module/components/CurrencyFlag/index.js +72 -0
- package/lib/module/components/CurrencyFlag/index.js.map +1 -0
- package/lib/module/components/CurrencyInput/index.js +3 -1
- package/lib/module/components/CurrencyInput/index.js.map +1 -1
- package/lib/module/components/CurrencyInput/styles.js +23 -7
- package/lib/module/components/CurrencyInput/styles.js.map +1 -1
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/typescript/components/CountryFlag/index.d.ts +8 -3
- package/lib/typescript/components/CountryFlag/index.d.ts.map +1 -1
- package/lib/typescript/components/CurrencyFlag/index.d.ts +47 -0
- package/lib/typescript/components/CurrencyFlag/index.d.ts.map +1 -0
- package/lib/typescript/components/CurrencyInput/index.d.ts.map +1 -1
- package/lib/typescript/components/CurrencyInput/styles.d.ts +6 -1
- package/lib/typescript/components/CurrencyInput/styles.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/components/CountryFlag/index.tsx +8 -3
- package/src/components/CurrencyFlag/index.tsx +71 -0
- package/src/components/CurrencyInput/index.tsx +2 -1
- package/src/components/CurrencyInput/styles.ts +29 -3
- package/src/components/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ColorSwatch","HStack","VStack"],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":";;AAAA,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,OAAO;AACrB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,QAAQ;AACtB,cAAc,aAAa;AAC3B,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,eAAe;AAC7B,SAASA,WAAW,QAA6D,eAAe;AAChG,cAAc,qBAAqB;AACnC,cAAc,iBAAiB;AAC/B,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB;AAC/B,cAAc,cAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,gBAAgB;AAC9B,cAAc,kBAAkB;AAChC,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,oBAAoB;AAClC,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,gBAAgB;AAC9B,cAAc,uBAAuB;AACrC,cAAc,SAAS;AACvB,cAAc,YAAY;AAC1B,cAAc,mBAA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iB;AAC/B,cAAc,cAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,gBAAgB;AAC9B,cAAc,kBAAkB;AAChC,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,oBAAoB;AAClC,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,gBAAgB;AAC9B,cAAc,uBAAuB;AACrC,cAAc,SAAS;AACvB,cAAc,YAAY;AAC1B,cAAc,mBAAmB;AACjC,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,QAAQ;AACtB,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,qBAAqB;AACnC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,mBAAmB;AAMjC,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,YAAY;AAC1B,cAAc,QAAQ;AACtB,cAAc,gBAAgB;AAC9B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,SAASC,MAAM,EAAEC,MAAM,QAAQ,SAAS;AACxC,cAAc,WAAW;AACzB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,cAAc;AAC5B,cAAc,qBAAqB","ignoreList":[]}
|
|
@@ -2,11 +2,16 @@ import { type FlagCode } from '@cdx-ui/icons/flags';
|
|
|
2
2
|
import { type IconProps } from '../Icon';
|
|
3
3
|
export type { FlagCode };
|
|
4
4
|
export interface CountryFlagProps extends Omit<IconProps, 'as' | 'filled' | 'color'> {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Code from the country-flag-icons 3x2 set. Includes officially assigned
|
|
7
|
+
* ISO 3166-1 alpha-2 codes, the unofficial codes that package ships for
|
|
8
|
+
* libphonenumber-js, and its subdivision codes. Subdivision codes keep
|
|
9
|
+
* their hyphen (`GB-ENG`).
|
|
10
|
+
*/
|
|
6
11
|
code: FlagCode;
|
|
7
12
|
}
|
|
8
13
|
/**
|
|
9
|
-
* Renders the
|
|
14
|
+
* Renders the flag for a country-flag-icons code, including unofficial libphonenumber-js codes.
|
|
10
15
|
*
|
|
11
16
|
* The flag is drawn through `Icon`, so `className` sizing and `asChild` icon slots
|
|
12
17
|
* apply. Flag artwork keeps its own colors. The flag is decorative unless
|
|
@@ -22,7 +27,7 @@ export interface CountryFlagProps extends Omit<IconProps, 'as' | 'filled' | 'col
|
|
|
22
27
|
* <CountryFlag code="US" className="size-6" accessibilityLabel="United States" />
|
|
23
28
|
* ```
|
|
24
29
|
*
|
|
25
|
-
* @param {FlagCode} code -
|
|
30
|
+
* @param {FlagCode} code - Code from the country-flag-icons 3x2 set. Subdivision codes keep their hyphen (`GB-ENG`).
|
|
26
31
|
* @param {string} className - Utility classes for size and placement, merged after the default `size-5` box.
|
|
27
32
|
* @param {string} accessibilityLabel - When set, the flag is announced as an image with this name.
|
|
28
33
|
* @param {object} style - Style overrides passed through to the icon.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/CountryFlag/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAE/C,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,QAAQ,GAAG,OAAO,CAAC;IAClF
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/CountryFlag/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAE/C,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,QAAQ,GAAG,OAAO,CAAC;IAClF;;;;;OAKG;IACH,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,kDAe1E;yBAfe,WAAW"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type FlagCode } from '@cdx-ui/icons/flags';
|
|
2
|
+
import { type IconProps } from '../Icon';
|
|
3
|
+
export interface CurrencyFlagProps extends Omit<IconProps, 'as' | 'filled' | 'color'> {
|
|
4
|
+
/** ISO 4217 alphabetic currency code, such as `USD` or `EUR`. */
|
|
5
|
+
code: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns the flag code for the country or union that issues an ISO 4217 currency.
|
|
9
|
+
*
|
|
10
|
+
* National codes start with the issuer's ISO 3166-1 alpha-2 code (`DKK` → `DK`), so a
|
|
11
|
+
* currency shared by several countries resolves to its issuer. `EUR` resolves to `EU`.
|
|
12
|
+
* `X` codes (`XOF`, `XCD`, `XAU`) have no single issuer and resolve to `undefined`, as
|
|
13
|
+
* do malformed codes.
|
|
14
|
+
*/
|
|
15
|
+
export declare function currencyFlagCode(code: string): FlagCode | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Renders the flag of the country or union that issues an ISO 4217 currency.
|
|
18
|
+
*
|
|
19
|
+
* The flag shows the issuer, not the user's country: `DKK` renders Denmark's flag for
|
|
20
|
+
* accounts in Greenland too. Use `CountryFlag` with a country code when the flag should
|
|
21
|
+
* show where the user is. Codes with no single issuer, such as `XOF` and `XCD`, render
|
|
22
|
+
* nothing and log a warning in development.
|
|
23
|
+
*
|
|
24
|
+
* The flag is drawn through `Icon`, so `className` sizing and `asChild` icon slots
|
|
25
|
+
* apply. Flag artwork keeps its own colors. The flag is decorative unless
|
|
26
|
+
* `accessibilityLabel` is set.
|
|
27
|
+
*
|
|
28
|
+
* @component
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* import { CurrencyFlag } from '@cdx-ui/components';
|
|
32
|
+
*
|
|
33
|
+
* <CurrencyFlag code="USD" />
|
|
34
|
+
* <CurrencyFlag code="EUR" className="size-6" accessibilityLabel="Euro" />
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param {string} code - ISO 4217 alphabetic currency code.
|
|
38
|
+
* @param {string} className - Utility classes for size and placement, merged after the default `size-5` box.
|
|
39
|
+
* @param {string} accessibilityLabel - When set, the flag is announced as an image with this name.
|
|
40
|
+
* @param {object} style - Style overrides passed through to the icon.
|
|
41
|
+
* @param {string} data-testid - Test identifier forwarded to the rendered icon.
|
|
42
|
+
*/
|
|
43
|
+
export declare function CurrencyFlag({ code, className, ...props }: CurrencyFlagProps): import("react/jsx-runtime").JSX.Element | null;
|
|
44
|
+
export declare namespace CurrencyFlag {
|
|
45
|
+
var displayName: string;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/CurrencyFlag/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,QAAQ,GAAG,OAAO,CAAC;IACnF,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAOnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,kDAc5E;yBAde,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/CurrencyInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACzF,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,KAAK,yBAAyB,EAI/B,MAAM,UAAU,CAAC;AAqBlB,MAAM,WAAW,kBACf,SACE,gBAAgB,EAChB,yBAAyB,EACzB,IAAI,CACF,cAAc,EACd,oBAAoB,GAAG,mBAAmB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,eAAe,CAC/F;IACH,wGAAwG;IACxG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uGAAuG;IACvG,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/CurrencyInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACzF,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,KAAK,yBAAyB,EAI/B,MAAM,UAAU,CAAC;AAqBlB,MAAM,WAAW,kBACf,SACE,gBAAgB,EAChB,yBAAyB,EACzB,IAAI,CACF,cAAc,EACd,oBAAoB,GAAG,mBAAmB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,eAAe,CAC/F;IACH,wGAAwG;IACxG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uGAAuG;IACvG,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,aAAa,0GAgKzB,CAAC"}
|
|
@@ -11,9 +11,14 @@ export interface CurrencyInputVariantProps {
|
|
|
11
11
|
* @default 'default'
|
|
12
12
|
*/
|
|
13
13
|
size?: 'default' | 'small';
|
|
14
|
+
/**
|
|
15
|
+
* Horizontal alignment of the amount. Defaults to `center` on `ghost`. On `outline`, the amount
|
|
16
|
+
* stays at the start of the field until `align` is set.
|
|
17
|
+
*/
|
|
18
|
+
align?: 'center' | 'end';
|
|
14
19
|
}
|
|
15
20
|
export declare const currencyInputRootVariants: ({ variant, size, }?: CurrencyInputVariantProps) => string;
|
|
16
|
-
export declare const currencyInputFieldVariants: ({ variant, size, }?: CurrencyInputVariantProps) => string;
|
|
21
|
+
export declare const currencyInputFieldVariants: ({ variant, size, align, }?: CurrencyInputVariantProps) => string;
|
|
17
22
|
export declare const currencyInputPrefixVariants: (props?: ({
|
|
18
23
|
size?: "small" | "default" | null | undefined;
|
|
19
24
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/CurrencyInput/styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/CurrencyInput/styles.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,yBAAyB;IACxC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;CAC1B;AAwDD,eAAO,MAAM,yBAAyB,GAAI,qBAGvC,yBAA8B,KAAG,MAGU,CAAC;AAE/C,eAAO,MAAM,0BAA0B,GAAI,4BAIxC,yBAA8B,KAAG,MASnC,CAAC;AAGF,eAAO,MAAM,2BAA2B;;8EAavC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,uBAAuB,E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CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdx-ui/components",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -106,10 +106,10 @@
|
|
|
106
106
|
"@marceloterreiro/flash-calendar": "2.0.0",
|
|
107
107
|
"react-native-reanimated-carousel": "5.0.0-beta.5",
|
|
108
108
|
"uniwind": "1.10.0",
|
|
109
|
-
"@cdx-ui/formatters": "0.3.
|
|
110
|
-
"@cdx-ui/icons": "0.3.
|
|
111
|
-
"@cdx-ui/
|
|
112
|
-
"@cdx-ui/
|
|
109
|
+
"@cdx-ui/formatters": "0.3.8",
|
|
110
|
+
"@cdx-ui/icons": "0.3.8",
|
|
111
|
+
"@cdx-ui/primitives": "0.3.8",
|
|
112
|
+
"@cdx-ui/utils": "0.3.8"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
115
|
"@dnd-kit/core": "6.3.1",
|
|
@@ -6,12 +6,17 @@ import { Icon, type IconProps } from '../Icon';
|
|
|
6
6
|
export type { FlagCode };
|
|
7
7
|
|
|
8
8
|
export interface CountryFlagProps extends Omit<IconProps, 'as' | 'filled' | 'color'> {
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Code from the country-flag-icons 3x2 set. Includes officially assigned
|
|
11
|
+
* ISO 3166-1 alpha-2 codes, the unofficial codes that package ships for
|
|
12
|
+
* libphonenumber-js, and its subdivision codes. Subdivision codes keep
|
|
13
|
+
* their hyphen (`GB-ENG`).
|
|
14
|
+
*/
|
|
10
15
|
code: FlagCode;
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
/**
|
|
14
|
-
* Renders the
|
|
19
|
+
* Renders the flag for a country-flag-icons code, including unofficial libphonenumber-js codes.
|
|
15
20
|
*
|
|
16
21
|
* The flag is drawn through `Icon`, so `className` sizing and `asChild` icon slots
|
|
17
22
|
* apply. Flag artwork keeps its own colors. The flag is decorative unless
|
|
@@ -27,7 +32,7 @@ export interface CountryFlagProps extends Omit<IconProps, 'as' | 'filled' | 'col
|
|
|
27
32
|
* <CountryFlag code="US" className="size-6" accessibilityLabel="United States" />
|
|
28
33
|
* ```
|
|
29
34
|
*
|
|
30
|
-
* @param {FlagCode} code -
|
|
35
|
+
* @param {FlagCode} code - Code from the country-flag-icons 3x2 set. Subdivision codes keep their hyphen (`GB-ENG`).
|
|
31
36
|
* @param {string} className - Utility classes for size and placement, merged after the default `size-5` box.
|
|
32
37
|
* @param {string} accessibilityLabel - When set, the flag is announced as an image with this name.
|
|
33
38
|
* @param {object} style - Style overrides passed through to the icon.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { flags, type FlagCode } from '@cdx-ui/icons/flags';
|
|
2
|
+
import { dataAttributes, mergeDataAttributes } from '@cdx-ui/primitives';
|
|
3
|
+
import { cn } from '@cdx-ui/utils';
|
|
4
|
+
import { Icon, type IconProps } from '../Icon';
|
|
5
|
+
|
|
6
|
+
export interface CurrencyFlagProps extends Omit<IconProps, 'as' | 'filled' | 'color'> {
|
|
7
|
+
/** ISO 4217 alphabetic currency code, such as `USD` or `EUR`. */
|
|
8
|
+
code: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns the flag code for the country or union that issues an ISO 4217 currency.
|
|
13
|
+
*
|
|
14
|
+
* National codes start with the issuer's ISO 3166-1 alpha-2 code (`DKK` → `DK`), so a
|
|
15
|
+
* currency shared by several countries resolves to its issuer. `EUR` resolves to `EU`.
|
|
16
|
+
* `X` codes (`XOF`, `XCD`, `XAU`) have no single issuer and resolve to `undefined`, as
|
|
17
|
+
* do malformed codes.
|
|
18
|
+
*/
|
|
19
|
+
export function currencyFlagCode(code: string): FlagCode | undefined {
|
|
20
|
+
if (!/^[A-Z]{3}$/.test(code)) return undefined;
|
|
21
|
+
if (code === 'EUR') return 'EU';
|
|
22
|
+
// `X` prefixes would otherwise hit user-assigned flags (`XAF` → `XA`, `XCD` → `XC`).
|
|
23
|
+
if (code.startsWith('X')) return undefined;
|
|
24
|
+
const region = code.slice(0, 2);
|
|
25
|
+
return Object.prototype.hasOwnProperty.call(flags, region) ? (region as FlagCode) : undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Renders the flag of the country or union that issues an ISO 4217 currency.
|
|
30
|
+
*
|
|
31
|
+
* The flag shows the issuer, not the user's country: `DKK` renders Denmark's flag for
|
|
32
|
+
* accounts in Greenland too. Use `CountryFlag` with a country code when the flag should
|
|
33
|
+
* show where the user is. Codes with no single issuer, such as `XOF` and `XCD`, render
|
|
34
|
+
* nothing and log a warning in development.
|
|
35
|
+
*
|
|
36
|
+
* The flag is drawn through `Icon`, so `className` sizing and `asChild` icon slots
|
|
37
|
+
* apply. Flag artwork keeps its own colors. The flag is decorative unless
|
|
38
|
+
* `accessibilityLabel` is set.
|
|
39
|
+
*
|
|
40
|
+
* @component
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* import { CurrencyFlag } from '@cdx-ui/components';
|
|
44
|
+
*
|
|
45
|
+
* <CurrencyFlag code="USD" />
|
|
46
|
+
* <CurrencyFlag code="EUR" className="size-6" accessibilityLabel="Euro" />
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param {string} code - ISO 4217 alphabetic currency code.
|
|
50
|
+
* @param {string} className - Utility classes for size and placement, merged after the default `size-5` box.
|
|
51
|
+
* @param {string} accessibilityLabel - When set, the flag is announced as an image with this name.
|
|
52
|
+
* @param {object} style - Style overrides passed through to the icon.
|
|
53
|
+
* @param {string} data-testid - Test identifier forwarded to the rendered icon.
|
|
54
|
+
*/
|
|
55
|
+
export function CurrencyFlag({ code, className, ...props }: CurrencyFlagProps) {
|
|
56
|
+
const flagCode = currencyFlagCode(code);
|
|
57
|
+
if (!flagCode) {
|
|
58
|
+
if (__DEV__) console.warn(`CurrencyFlag: no flag for currency "${code}"`);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return (
|
|
62
|
+
<Icon
|
|
63
|
+
as={flags[flagCode]}
|
|
64
|
+
className={cn('size-5', className)}
|
|
65
|
+
{...props}
|
|
66
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'currency-flag' }))}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
CurrencyFlag.displayName = 'CurrencyFlag';
|
|
@@ -62,6 +62,7 @@ export const CurrencyInput = forwardRef<TextInput, CurrencyInputProps>(
|
|
|
62
62
|
currencySymbol = '$',
|
|
63
63
|
variant = 'ghost',
|
|
64
64
|
size = 'default',
|
|
65
|
+
align,
|
|
65
66
|
isDisabled,
|
|
66
67
|
isInvalid,
|
|
67
68
|
isReadOnly,
|
|
@@ -206,7 +207,7 @@ export const CurrencyInput = forwardRef<TextInput, CurrencyInputProps>(
|
|
|
206
207
|
onFocus={handleFocus}
|
|
207
208
|
onBlur={handleBlur}
|
|
208
209
|
className={cn(
|
|
209
|
-
currencyInputFieldVariants({ variant, size }),
|
|
210
|
+
currencyInputFieldVariants({ variant, size, align }),
|
|
210
211
|
isEmpty ? 'text-content-tertiary' : 'text-content-primary',
|
|
211
212
|
)}
|
|
212
213
|
/>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
1
2
|
import { cn, cva } from '@cdx-ui/utils';
|
|
2
3
|
import { DISABLED_CURSOR } from '../../styles/constants';
|
|
3
4
|
import { inputFieldVariants, inputRootVariants } from '../Input/styles';
|
|
@@ -15,6 +16,11 @@ export interface CurrencyInputVariantProps {
|
|
|
15
16
|
* @default 'default'
|
|
16
17
|
*/
|
|
17
18
|
size?: 'default' | 'small';
|
|
19
|
+
/**
|
|
20
|
+
* Horizontal alignment of the amount. Defaults to `center` on `ghost`. On `outline`, the amount
|
|
21
|
+
* stays at the start of the field until `align` is set.
|
|
22
|
+
*/
|
|
23
|
+
align?: 'center' | 'end';
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
const currencyInputGhostRootVariants = cva(
|
|
@@ -37,9 +43,20 @@ const currencyInputGhostRootVariants = cva(
|
|
|
37
43
|
},
|
|
38
44
|
);
|
|
39
45
|
|
|
46
|
+
// TextInput only accepts textAlign left, center, and right. `text-end` is valid CSS, so web
|
|
47
|
+
// uses it, but native ignores it and the amount stays at the start in LTR. Direction
|
|
48
|
+
// variants compile to left/right, matching Table's native text alignment.
|
|
49
|
+
const currencyInputAlignClass = {
|
|
50
|
+
center: 'text-center',
|
|
51
|
+
end: Platform.select({
|
|
52
|
+
web: 'text-end',
|
|
53
|
+
default: 'ltr:text-right rtl:text-left',
|
|
54
|
+
}),
|
|
55
|
+
} as const;
|
|
56
|
+
|
|
40
57
|
const currencyInputGhostFieldVariants = cva(
|
|
41
58
|
[
|
|
42
|
-
'w-full bg-transparent p-0
|
|
59
|
+
'w-full bg-transparent p-0',
|
|
43
60
|
'placeholder:text-content-tertiary',
|
|
44
61
|
'web:outline-none',
|
|
45
62
|
'data-[invalid=true]:text-content-danger',
|
|
@@ -71,8 +88,17 @@ export const currencyInputRootVariants = ({
|
|
|
71
88
|
export const currencyInputFieldVariants = ({
|
|
72
89
|
variant = 'ghost',
|
|
73
90
|
size = 'default',
|
|
74
|
-
|
|
75
|
-
|
|
91
|
+
align,
|
|
92
|
+
}: CurrencyInputVariantProps = {}): string => {
|
|
93
|
+
const resolvedAlign = align ?? (variant === 'outline' ? undefined : 'center');
|
|
94
|
+
|
|
95
|
+
return cn(
|
|
96
|
+
variant === 'outline'
|
|
97
|
+
? inputFieldVariants({ size })
|
|
98
|
+
: currencyInputGhostFieldVariants({ size }),
|
|
99
|
+
resolvedAlign ? currencyInputAlignClass[resolvedAlign] : undefined,
|
|
100
|
+
);
|
|
101
|
+
};
|
|
76
102
|
|
|
77
103
|
// Figma keeps the symbol at body-md on every viewport; only the amount grows to 16px on web <600px.
|
|
78
104
|
export const currencyInputPrefixVariants = cva(
|