@tempoxyz/ds 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/dist/mobile/components/Avatar.d.ts +1 -1
- package/dist/mobile/components/Avatar.d.ts.map +1 -1
- package/dist/mobile/components/Avatar.js.map +1 -1
- package/dist/mobile/components/Button.d.ts +1 -1
- package/dist/mobile/components/Button.d.ts.map +1 -1
- package/dist/mobile/components/Button.js +5 -1
- package/dist/mobile/components/Button.js.map +1 -1
- package/dist/mobile/components/CodeInput.d.ts +1 -1
- package/dist/mobile/components/CodeInput.d.ts.map +1 -1
- package/dist/mobile/components/CodeInput.js.map +1 -1
- package/dist/mobile/components/IconButton.d.ts +1 -1
- package/dist/mobile/components/IconButton.d.ts.map +1 -1
- package/dist/mobile/components/IconButton.js +5 -1
- package/dist/mobile/components/IconButton.js.map +1 -1
- package/dist/mobile/components/Skeleton.d.ts.map +1 -1
- package/dist/mobile/components/Skeleton.js.map +1 -1
- package/dist/mobile/components/Spinner.d.ts +1 -1
- package/dist/mobile/components/Spinner.d.ts.map +1 -1
- package/dist/mobile/components/Spinner.js.map +1 -1
- package/dist/mobile/components/TextButton.d.ts.map +1 -1
- package/dist/mobile/components/TextButton.js +7 -2
- package/dist/mobile/components/TextButton.js.map +1 -1
- package/dist/mobile/components/TextInput.d.ts.map +1 -1
- package/dist/mobile/components/TextInput.js +1 -1
- package/dist/mobile/components/TextInput.js.map +1 -1
- package/dist/oxlint/index.d.ts +43 -0
- package/dist/oxlint/index.d.ts.map +1 -0
- package/dist/oxlint/index.js +68 -0
- package/dist/oxlint/index.js.map +1 -0
- package/dist/oxlint/internal/Imports.d.ts +22 -0
- package/dist/oxlint/internal/Imports.d.ts.map +1 -0
- package/dist/oxlint/internal/Imports.js +52 -0
- package/dist/oxlint/internal/Imports.js.map +1 -0
- package/dist/oxlint/rules/NoCrossSurface.d.ts +16 -0
- package/dist/oxlint/rules/NoCrossSurface.d.ts.map +1 -0
- package/dist/oxlint/rules/NoCrossSurface.js +55 -0
- package/dist/oxlint/rules/NoCrossSurface.js.map +1 -0
- package/dist/oxlint/rules/NoInternalImports.d.ts +8 -0
- package/dist/oxlint/rules/NoInternalImports.d.ts.map +1 -0
- package/dist/oxlint/rules/NoInternalImports.js +22 -0
- package/dist/oxlint/rules/NoInternalImports.js.map +1 -0
- package/dist/oxlint/rules/NoRawValues.d.ts +9 -0
- package/dist/oxlint/rules/NoRawValues.d.ts.map +1 -0
- package/dist/oxlint/rules/NoRawValues.js +73 -0
- package/dist/oxlint/rules/NoRawValues.js.map +1 -0
- package/dist/oxlint/rules/PreferComponent.d.ts +16 -0
- package/dist/oxlint/rules/PreferComponent.d.ts.map +1 -0
- package/dist/oxlint/rules/PreferComponent.js +92 -0
- package/dist/oxlint/rules/PreferComponent.js.map +1 -0
- package/dist/oxlint/rules/RequireAccessibleName.d.ts +9 -0
- package/dist/oxlint/rules/RequireAccessibleName.d.ts.map +1 -0
- package/dist/oxlint/rules/RequireAccessibleName.js +104 -0
- package/dist/oxlint/rules/RequireAccessibleName.js.map +1 -0
- package/dist/web/components/Amount.d.ts +10 -3
- package/dist/web/components/Amount.d.ts.map +1 -1
- package/dist/web/components/Amount.js +19 -9
- package/dist/web/components/Amount.js.map +1 -1
- package/dist/web/components/AmountInput.d.ts +15 -2
- package/dist/web/components/AmountInput.d.ts.map +1 -1
- package/dist/web/components/AmountInput.js +42 -11
- package/dist/web/components/AmountInput.js.map +1 -1
- package/dist/web/components/AmountInput.js.zyzz.json +1 -1
- package/dist/web/components/Autocomplete.js.zyzz.json +1 -1
- package/dist/web/components/Banner.js +1 -1
- package/dist/web/components/Calendar.d.ts.map +1 -1
- package/dist/web/components/Calendar.js +7 -5
- package/dist/web/components/Calendar.js.map +1 -1
- package/dist/web/components/Callout.d.ts.map +1 -1
- package/dist/web/components/Callout.js +4 -1
- package/dist/web/components/Callout.js.map +1 -1
- package/dist/web/components/Combobox.js.zyzz.json +1 -1
- package/dist/web/components/DatePicker.css +1 -1
- package/dist/web/components/DatePicker.d.ts +1 -1
- package/dist/web/components/DatePicker.js.zyzz.json +1 -1
- package/dist/web/components/Dialog.js +2 -2
- package/dist/web/components/Dialog.js.map +1 -1
- package/dist/web/components/Drawer.js +2 -2
- package/dist/web/components/Drawer.js.map +1 -1
- package/dist/web/components/Field.d.ts +7 -0
- package/dist/web/components/Field.d.ts.map +1 -1
- package/dist/web/components/Field.js +25 -3
- package/dist/web/components/Field.js.map +1 -1
- package/dist/web/components/Input.css +1 -1
- package/dist/web/components/Input.js.zyzz.json +1 -1
- package/dist/web/components/Kbd.d.ts +31 -9
- package/dist/web/components/Kbd.d.ts.map +1 -1
- package/dist/web/components/Kbd.js +55 -13
- package/dist/web/components/Kbd.js.map +1 -1
- package/dist/web/components/Menu.css +1 -1
- package/dist/web/components/Menu.js +1 -1
- package/dist/web/components/Menu.js.zyzz.json +1 -1
- package/dist/web/components/NumberField.css +1 -1
- package/dist/web/components/NumberField.js.zyzz.json +1 -1
- package/dist/web/components/Pagination.css +1 -1
- package/dist/web/components/Pagination.d.ts +1 -1
- package/dist/web/components/Pagination.js.zyzz.json +1 -1
- package/dist/web/components/Rows.css +1 -1
- package/dist/web/components/Rows.d.ts +1 -1
- package/dist/web/components/Rows.d.ts.map +1 -1
- package/dist/web/components/Rows.js +3 -3
- package/dist/web/components/Rows.js.map +1 -1
- package/dist/web/components/Rows.js.zyzz.json +1 -1
- package/dist/web/components/Select.css +1 -1
- package/dist/web/components/Select.js.zyzz.json +1 -1
- package/dist/web/components/Snippet.css +1 -1
- package/dist/web/components/Snippet.js +2 -2
- package/dist/web/components/Snippet.js.zyzz.json +1 -1
- package/dist/web/components/Table.css +1 -1
- package/dist/web/components/Table.d.ts +6 -3
- package/dist/web/components/Table.d.ts.map +1 -1
- package/dist/web/components/Table.js +5 -2
- package/dist/web/components/Table.js.map +1 -1
- package/dist/web/components/Table.js.zyzz.json +1 -1
- package/dist/web/components/Textarea.css +1 -1
- package/dist/web/components/Textarea.d.ts +1 -1
- package/dist/web/components/Textarea.js.zyzz.json +1 -1
- package/dist/web/components/Toast.d.ts.map +1 -1
- package/dist/web/components/Toast.js +5 -1
- package/dist/web/components/Toast.js.map +1 -1
- package/dist/web/components/internal/Field.css +1 -1
- package/dist/web/components/internal/Field.js.zyzz.json +1 -1
- package/dist/web/components/internal/InputGroup.d.ts.map +1 -1
- package/dist/web/components/internal/InputGroup.js.map +1 -1
- package/dist/web/components/internal/Listbox.css +1 -1
- package/dist/web/components/internal/Listbox.js.zyzz.json +1 -1
- package/dist/web/icons/BadgeX.d.ts.map +1 -1
- package/dist/web/icons/BadgeX.js.map +1 -1
- package/dist/web/icons/InfinityIcon.d.ts.map +1 -1
- package/dist/web/icons/InfinityIcon.js.map +1 -1
- package/dist/web/icons/LightMode.d.ts.map +1 -1
- package/dist/web/icons/LightMode.js.map +1 -1
- package/dist/web/icons/OctagonAlert.d.ts.map +1 -1
- package/dist/web/icons/OctagonAlert.js.map +1 -1
- package/dist/web/icons/Unlink.d.ts.map +1 -1
- package/dist/web/icons/Unlink.js.map +1 -1
- package/dist/web/index.js.zyzz.json +1 -1
- package/package.json +7 -1
- package/src/mobile/components/Avatar.tsx +2 -2
- package/src/mobile/components/Button.tsx +5 -2
- package/src/mobile/components/CodeInput.tsx +2 -2
- package/src/mobile/components/IconButton.tsx +5 -2
- package/src/mobile/components/Skeleton.tsx +1 -1
- package/src/mobile/components/Spinner.tsx +1 -1
- package/src/mobile/components/TextButton.tsx +6 -2
- package/src/mobile/components/TextInput.tsx +1 -1
- package/src/oxlint/index.ts +89 -0
- package/src/oxlint/internal/Imports.ts +68 -0
- package/src/oxlint/rules/NoCrossSurface.ts +71 -0
- package/src/oxlint/rules/NoInternalImports.ts +25 -0
- package/src/oxlint/rules/NoRawValues.ts +76 -0
- package/src/oxlint/rules/PreferComponent.ts +113 -0
- package/src/oxlint/rules/RequireAccessibleName.ts +132 -0
- package/src/web/components/Amount.tsx +29 -9
- package/src/web/components/AmountInput.tsx +48 -12
- package/src/web/components/Banner.tsx +1 -1
- package/src/web/components/Calendar.tsx +5 -6
- package/src/web/components/Callout.tsx +4 -1
- package/src/web/components/DatePicker.tsx +1 -1
- package/src/web/components/Dialog.tsx +2 -2
- package/src/web/components/Drawer.tsx +2 -2
- package/src/web/components/Field.tsx +37 -2
- package/src/web/components/Input.tsx +1 -1
- package/src/web/components/Kbd.tsx +76 -20
- package/src/web/components/Menu.tsx +2 -2
- package/src/web/components/NumberField.tsx +1 -1
- package/src/web/components/Pagination.tsx +1 -1
- package/src/web/components/Rows.tsx +1 -2
- package/src/web/components/Select.tsx +1 -1
- package/src/web/components/Snippet.tsx +1 -1
- package/src/web/components/Table.tsx +7 -3
- package/src/web/components/Textarea.tsx +1 -1
- package/src/web/components/Toast.tsx +5 -1
- package/src/web/components/internal/Field.ts +1 -1
- package/src/web/components/internal/InputGroup.ts +1 -1
- package/src/web/components/internal/Listbox.ts +2 -2
- package/src/web/icons/BadgeX.tsx +1 -1
- package/src/web/icons/InfinityIcon.tsx +1 -1
- package/src/web/icons/LightMode.tsx +1 -1
- package/src/web/icons/OctagonAlert.tsx +1 -1
- package/src/web/icons/Unlink.tsx +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as Imports from '../internal/Imports.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reports an import from the other surface. With `surface` set, every import from the other surface
|
|
4
|
+
* is reported. Without it, the rule reports a file that imports from both surfaces.
|
|
5
|
+
*/
|
|
6
|
+
export const rule = {
|
|
7
|
+
meta: {
|
|
8
|
+
docs: { description: 'Keep an app on one `@tempoxyz/ds` surface.' },
|
|
9
|
+
messages: {
|
|
10
|
+
configured: "'{{source}}' belongs to the {{found}} surface, but this app uses the {{surface}} surface.",
|
|
11
|
+
mixed: "'{{source}}' belongs to the {{found}} surface, but this file imports the {{surface}} surface.",
|
|
12
|
+
},
|
|
13
|
+
schema: [
|
|
14
|
+
{
|
|
15
|
+
additionalProperties: false,
|
|
16
|
+
properties: { surface: { enum: ['mobile', 'web'], type: 'string' } },
|
|
17
|
+
type: 'object',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
type: 'problem',
|
|
21
|
+
},
|
|
22
|
+
create(context) {
|
|
23
|
+
const options = context.options[0];
|
|
24
|
+
const references = [];
|
|
25
|
+
return {
|
|
26
|
+
...Imports.visit((source, node) => {
|
|
27
|
+
const surface = Imports.surface(source);
|
|
28
|
+
if (!surface)
|
|
29
|
+
return;
|
|
30
|
+
if (options?.surface && surface !== options.surface)
|
|
31
|
+
context.report({
|
|
32
|
+
data: { found: surface, source, surface: options.surface },
|
|
33
|
+
messageId: 'configured',
|
|
34
|
+
node,
|
|
35
|
+
});
|
|
36
|
+
references.push({ node, source, surface });
|
|
37
|
+
}),
|
|
38
|
+
'Program:exit'() {
|
|
39
|
+
if (options?.surface)
|
|
40
|
+
return;
|
|
41
|
+
const first = references[0];
|
|
42
|
+
if (!first)
|
|
43
|
+
return;
|
|
44
|
+
for (const reference of references)
|
|
45
|
+
if (reference.surface !== first.surface)
|
|
46
|
+
context.report({
|
|
47
|
+
data: { found: reference.surface, source: reference.source, surface: first.surface },
|
|
48
|
+
messageId: 'mixed',
|
|
49
|
+
node: reference.node,
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=NoCrossSurface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoCrossSurface.js","sourceRoot":"","sources":["../../../src/oxlint/rules/NoCrossSurface.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,IAAI,EAAE;QACJ,IAAI,EAAE,EAAE,WAAW,EAAE,4CAA4C,EAAE;QACnE,QAAQ,EAAE;YACR,UAAU,EACR,2FAA2F;YA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EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;4BACpF,SAAS,EAAE,OAAO;4BAClB,IAAI,EAAE,SAAS,CAAC,IAAI;yBACrB,CAAC,CAAA;YACR,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Restricts `@tempoxyz/ds` imports to the subpaths that the package publishes. @module */
|
|
2
|
+
import type { Rule } from '@oxlint/plugins';
|
|
3
|
+
/**
|
|
4
|
+
* Reports a `@tempoxyz/ds` specifier that the package `exports` map does not publish, such as
|
|
5
|
+
* `@tempoxyz/ds/src/web/components/Button`. Internal paths change without a release note.
|
|
6
|
+
*/
|
|
7
|
+
export declare const rule: Rule;
|
|
8
|
+
//# sourceMappingURL=NoInternalImports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoInternalImports.d.ts","sourceRoot":"","sources":["../../../src/oxlint/rules/NoInternalImports.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAG3C;;;GAGG;AACH,eAAO,MAAM,IAAI,EAAE,IAgBlB,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as Imports from '../internal/Imports.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reports a `@tempoxyz/ds` specifier that the package `exports` map does not publish, such as
|
|
4
|
+
* `@tempoxyz/ds/src/web/components/Button`. Internal paths change without a release note.
|
|
5
|
+
*/
|
|
6
|
+
export const rule = {
|
|
7
|
+
meta: {
|
|
8
|
+
docs: { description: 'Allow only the published `@tempoxyz/ds` entrypoints.' },
|
|
9
|
+
messages: {
|
|
10
|
+
internal: "'{{source}}' is not a published entrypoint. Import from '@tempoxyz/ds', '@tempoxyz/ds/mobile', or their `icons` subpaths.",
|
|
11
|
+
},
|
|
12
|
+
schema: [],
|
|
13
|
+
type: 'problem',
|
|
14
|
+
},
|
|
15
|
+
create(context) {
|
|
16
|
+
return Imports.visit((source, node) => {
|
|
17
|
+
if (Imports.owned(source) && !Imports.published(source))
|
|
18
|
+
context.report({ data: { source }, messageId: 'internal', node });
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=NoInternalImports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoInternalImports.js","sourceRoot":"","sources":["../../../src/oxlint/rules/NoInternalImports.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,IAAI,EAAE;QACJ,IAAI,EAAE,EAAE,WAAW,EAAE,sDAAsD,EAAE;QAC7E,QAAQ,EAAE;YACR,QAAQ,EACN,2HAA2H;SAC9H;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAChB;IACD,MAAM,CAAC,OAAO;QACZ,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;YACpC,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC;gBACrD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;QACrE,CAAC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Finds raw colors, lengths, and font stacks in inline `style` props. @module */
|
|
2
|
+
import type { Rule } from '@oxlint/plugins';
|
|
3
|
+
/**
|
|
4
|
+
* Reports a color, length, or font family written as a literal in a JSX `style` prop. Values that
|
|
5
|
+
* read a custom property through `var()` pass, since they resolve to a token. Style values
|
|
6
|
+
* inside `style()` and `variants()` calls belong to `zyzz/valid-styles`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const rule: Rule;
|
|
9
|
+
//# sourceMappingURL=NoRawValues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoRawValues.d.ts","sourceRoot":"","sources":["../../../src/oxlint/rules/NoRawValues.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,OAAO,KAAK,EAAU,IAAI,EAAE,MAAM,iBAAiB,CAAA;AASnD;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,IA4DlB,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const color = /#[\da-f]{3,8}\b|\b(?:color|hsla?|hwb|lab|lch|oklab|oklch|rgba?)\(/i;
|
|
2
|
+
const length = /(?:^|[\s(,])-?(?:\d*\.)?\d+(?:em|pt|px|rem)\b/i;
|
|
3
|
+
// React and React Native read a bare number on these properties as pixels or points.
|
|
4
|
+
const lengths = /^(?:bottom|columnGap|end|flexBasis|fontSize|gap|height|inset\w*|left|margin\w*|maxHeight|maxWidth|minHeight|minWidth|padding\w*|right|rowGap|start|top|width|\w*Radius|\w*Width)$/;
|
|
5
|
+
/**
|
|
6
|
+
* Reports a color, length, or font family written as a literal in a JSX `style` prop. Values that
|
|
7
|
+
* read a custom property through `var()` pass, since they resolve to a token. Style values
|
|
8
|
+
* inside `style()` and `variants()` calls belong to `zyzz/valid-styles`.
|
|
9
|
+
*/
|
|
10
|
+
export const rule = {
|
|
11
|
+
meta: {
|
|
12
|
+
docs: { description: 'Use design tokens instead of raw values in inline styles.' },
|
|
13
|
+
messages: {
|
|
14
|
+
raw: "'{{property}}' sets the raw value {{value}}. Use a token through a Zyzz style instead.",
|
|
15
|
+
},
|
|
16
|
+
schema: [],
|
|
17
|
+
type: 'suggestion',
|
|
18
|
+
},
|
|
19
|
+
create(context) {
|
|
20
|
+
function raw(property, node) {
|
|
21
|
+
if (node.type === 'UnaryExpression' && node.operator === '-')
|
|
22
|
+
return raw(property, node.argument);
|
|
23
|
+
if (node.type === 'Literal' && typeof node.value === 'number')
|
|
24
|
+
return node.value !== 0 && lengths.test(property);
|
|
25
|
+
if (node.type === 'TemplateLiteral' && node.expressions.length === 0)
|
|
26
|
+
return text(property, node.quasis.map((quasi) => quasi.value.cooked ?? '').join(''));
|
|
27
|
+
if (node.type === 'Literal' && typeof node.value === 'string')
|
|
28
|
+
return text(property, node.value);
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
function text(property, value) {
|
|
32
|
+
if (value.includes('var('))
|
|
33
|
+
return false;
|
|
34
|
+
return property === 'fontFamily' || color.test(value) || length.test(value);
|
|
35
|
+
}
|
|
36
|
+
function check(node) {
|
|
37
|
+
if (node.type !== 'ObjectExpression')
|
|
38
|
+
return;
|
|
39
|
+
for (const property of node.properties) {
|
|
40
|
+
if (property.type !== 'Property' || property.computed)
|
|
41
|
+
continue;
|
|
42
|
+
const key = (() => {
|
|
43
|
+
if (property.key.type === 'Identifier')
|
|
44
|
+
return property.key.name;
|
|
45
|
+
if (property.key.type === 'Literal')
|
|
46
|
+
return String(property.key.value);
|
|
47
|
+
return undefined;
|
|
48
|
+
})();
|
|
49
|
+
if (key !== undefined && raw(key, property.value))
|
|
50
|
+
context.report({
|
|
51
|
+
data: { property: key, value: context.sourceCode.getText(property.value) },
|
|
52
|
+
messageId: 'raw',
|
|
53
|
+
node: property.value,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
JSXAttribute(node) {
|
|
59
|
+
if (node.name.type !== 'JSXIdentifier' || node.name.name !== 'style')
|
|
60
|
+
return;
|
|
61
|
+
if (node.value?.type !== 'JSXExpressionContainer')
|
|
62
|
+
return;
|
|
63
|
+
const expression = node.value.expression;
|
|
64
|
+
if (expression.type === 'ArrayExpression')
|
|
65
|
+
for (const element of expression.elements)
|
|
66
|
+
if (element)
|
|
67
|
+
check(element);
|
|
68
|
+
check(expression);
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=NoRawValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoRawValues.js","sourceRoot":"","sources":["../../../src/oxlint/rules/NoRawValues.ts"],"names":[],"mappings":"AAGA,MAAM,KAAK,GAAG,oEAAoE,CAAA;AAClF,MAAM,MAAM,GAAG,gDAAgD,CAAA;AAE/D,qFAAqF;AACrF,MAAM,OAAO,GACX,mLAAmL,CAAA;AAErL;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,IAAI,EAAE;QACJ,IAAI,EAAE,EAAE,WAAW,EAAE,2DAA2D,EAAE;QAClF,QAAQ,EAAE;YACR,GAAG,EAAE,wFAAwF;SAC9F;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,YAAY;KACnB;IACD,MAAM,CAAC,OAAO;QACZ,SAAS,GAAG,CAAC,QAAgB,EAAE,IAAiB;YAC9C,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,IAAI,IAAI,CAAC,QAAQ,KAAK,GAAG;gBAC1D,OAAO,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;YACrC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;gBAC3D,OAAO,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YACnD,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC;gBAClE,OAAO,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,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AAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;wBAC1E,SAAS,EAAE,KAAK;wBAChB,IAAI,EAAE,QAAQ,CAAC,KAAK;qBACrB,CAAC,CAAA;YACN,CAAC;QACH,CAAC;QAED,OAAO;YACL,YAAY,CAAC,IAAI;gBACf,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO;oBAAE,OAAM;gBAC5E,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI,KAAK,wBAAwB;oBAAE,OAAM;gBAEzD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAA;gBAExC,IAAI,UAAU,CAAC,IAAI,KAAK,iBAAiB;oBACvC,KAAK,MAAM,OAAO,IAAI,UAAU,CAAC,QAAQ;wBAAE,IAAI,OAAO;4BAAE,KAAK,CAAC,OAAO,CAAC,CAAA;gBACxE,KAAK,CAAC,UAAU,CAAC,CAAA;YACnB,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Points native HTML controls and structures at the Web components that replace them. @module */
|
|
2
|
+
import type { Rule } from '@oxlint/plugins';
|
|
3
|
+
/**
|
|
4
|
+
* Reports a native element that a `@tempoxyz/ds` component replaces, such as `<button>` or
|
|
5
|
+
* `<input type="checkbox">`. Elements inside a `render` prop are skipped, since the component that
|
|
6
|
+
* receives them supplies the styles.
|
|
7
|
+
*/
|
|
8
|
+
export declare const rule: Rule;
|
|
9
|
+
export declare namespace rule {
|
|
10
|
+
/** Options for `tds/prefer-component`. */
|
|
11
|
+
type Options = {
|
|
12
|
+
/** Element names to accept, such as `['table']` for a page that renders raw data. */
|
|
13
|
+
allow?: readonly string[] | undefined;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=PreferComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreferComponent.d.ts","sourceRoot":"","sources":["../../../src/oxlint/rules/PreferComponent.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,OAAO,KAAK,EAAU,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAmCnD;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,IA+DlB,CAAA;AAED,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,0CAA0C;IAC1C,KAAK,OAAO,GAAG;QACb,qFAAqF;QACrF,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;KACtC,CAAA;CACF"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Each element maps to the component that renders it with Tempo styles, states, and semantics.
|
|
2
|
+
const elements = {
|
|
3
|
+
button: 'Button',
|
|
4
|
+
details: 'Accordion',
|
|
5
|
+
dialog: 'Dialog',
|
|
6
|
+
fieldset: 'Fieldset',
|
|
7
|
+
hr: 'Separator',
|
|
8
|
+
kbd: 'Kbd',
|
|
9
|
+
meter: 'Gauge',
|
|
10
|
+
progress: 'Progress',
|
|
11
|
+
select: 'Select',
|
|
12
|
+
table: 'Table',
|
|
13
|
+
textarea: 'Textarea',
|
|
14
|
+
};
|
|
15
|
+
// Input types without an entry, such as `file`, `hidden`, and `color`, have no replacement.
|
|
16
|
+
const inputs = {
|
|
17
|
+
button: 'Button',
|
|
18
|
+
checkbox: 'Checkbox',
|
|
19
|
+
date: 'DatePicker',
|
|
20
|
+
email: 'Input',
|
|
21
|
+
number: 'NumberField',
|
|
22
|
+
password: 'Input',
|
|
23
|
+
radio: 'RadioGroup',
|
|
24
|
+
range: 'Slider',
|
|
25
|
+
reset: 'Button',
|
|
26
|
+
search: 'Input',
|
|
27
|
+
submit: 'Button',
|
|
28
|
+
tel: 'Input',
|
|
29
|
+
text: 'Input',
|
|
30
|
+
url: 'Input',
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Reports a native element that a `@tempoxyz/ds` component replaces, such as `<button>` or
|
|
34
|
+
* `<input type="checkbox">`. Elements inside a `render` prop are skipped, since the component that
|
|
35
|
+
* receives them supplies the styles.
|
|
36
|
+
*/
|
|
37
|
+
export const rule = {
|
|
38
|
+
meta: {
|
|
39
|
+
docs: {
|
|
40
|
+
description: 'Prefer `@tempoxyz/ds` components over the native elements they replace.',
|
|
41
|
+
},
|
|
42
|
+
messages: {
|
|
43
|
+
component: "Use '{{component}}' from '@tempoxyz/ds' instead of <{{element}}>.",
|
|
44
|
+
},
|
|
45
|
+
schema: [
|
|
46
|
+
{
|
|
47
|
+
additionalProperties: false,
|
|
48
|
+
properties: { allow: { items: { type: 'string' }, type: 'array' } },
|
|
49
|
+
type: 'object',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
type: 'suggestion',
|
|
53
|
+
},
|
|
54
|
+
create(context) {
|
|
55
|
+
const options = context.options[0];
|
|
56
|
+
const allow = new Set(options?.allow);
|
|
57
|
+
function component(node) {
|
|
58
|
+
if (node.name.type !== 'JSXIdentifier')
|
|
59
|
+
return undefined;
|
|
60
|
+
const element = node.name.name;
|
|
61
|
+
if (element !== 'input')
|
|
62
|
+
return elements[element];
|
|
63
|
+
const type = node.attributes.find((attribute) => attribute.type === 'JSXAttribute' &&
|
|
64
|
+
attribute.name.type === 'JSXIdentifier' &&
|
|
65
|
+
attribute.name.name === 'type');
|
|
66
|
+
if (!type)
|
|
67
|
+
return inputs.text;
|
|
68
|
+
if (type.type !== 'JSXAttribute' || type.value?.type !== 'Literal')
|
|
69
|
+
return undefined;
|
|
70
|
+
return typeof type.value.value === 'string' ? inputs[type.value.value] : undefined;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
JSXOpeningElement(node) {
|
|
74
|
+
if (node.name.type !== 'JSXIdentifier' || allow.has(node.name.name))
|
|
75
|
+
return;
|
|
76
|
+
for (let parent = node.parent; parent; parent = parent.parent)
|
|
77
|
+
if (parent.type === 'JSXAttribute' &&
|
|
78
|
+
parent.name.type === 'JSXIdentifier' &&
|
|
79
|
+
parent.name.name === 'render')
|
|
80
|
+
return;
|
|
81
|
+
const replacement = component(node);
|
|
82
|
+
if (replacement)
|
|
83
|
+
context.report({
|
|
84
|
+
data: { component: replacement, element: node.name.name },
|
|
85
|
+
messageId: 'component',
|
|
86
|
+
node,
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=PreferComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreferComponent.js","sourceRoot":"","sources":["../../../src/oxlint/rules/PreferComponent.ts"],"names":[],"mappings":"AAGA,+FAA+F;AAC/F,MAAM,QAAQ,GAA2B;IACvC,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,WAAW;IACpB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,EAAE,EAAE,WAAW;IACf,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;CACrB,CAAA;AAED,4FAA4F;AAC5F,MAAM,MAAM,GAA2B;IACrC,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,aAAa;IACrB,QAAQ,EAAE,OAAO;IACjB,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,OAAO;IACf,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,OAAO;IACZ,IAAI,EAAE,OAAO;IACb,GAAG,EAAE,OAAO;CACb,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,IA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AK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACpF,CAAC;QAED,OAAO;YACL,iBAAiB,CAAC,IAAI;gBACpB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;oBAAE,OAAM;gBAE3E,KAAK,IAAI,MAAM,GAAuB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM;oBAC/E,IACE,MAAM,CAAC,IAAI,KAAK,cAAc;wBAC9B,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;wBACpC,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ;wBAE7B,OAAM;gBAEV,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;gBAEnC,IAAI,WAAW;oBACb,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;wBACzD,SAAS,EAAE,WAAW;wBACtB,IAAI;qBACL,CAAC,CAAA;YACN,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Requires a name on `@tempoxyz/ds` components that render no text of their own. @module */
|
|
2
|
+
import type { Rule } from '@oxlint/plugins';
|
|
3
|
+
/**
|
|
4
|
+
* Reports an icon-only `Button` or `Button.Link`, a `Gauge`, or a Mobile `IconButton` without an
|
|
5
|
+
* accessible name. An element passed to a `render` prop can take its name from the element that
|
|
6
|
+
* owns the prop. Elements with a spread attribute are skipped, since the spread can supply the name.
|
|
7
|
+
*/
|
|
8
|
+
export declare const rule: Rule;
|
|
9
|
+
//# sourceMappingURL=RequireAccessibleName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequireAccessibleName.d.ts","sourceRoot":"","sources":["../../../src/oxlint/rules/RequireAccessibleName.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,KAAK,EAAU,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAwBnD;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,IAqGlB,CAAA"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as Imports from '../internal/Imports.js';
|
|
2
|
+
const list = new Intl.ListFormat('en', { type: 'disjunction' });
|
|
3
|
+
const web = ['aria-label', 'aria-labelledby'];
|
|
4
|
+
const mobile = ['accessibilityLabel', 'accessibilityLabelledBy', 'aria-label', 'aria-labelledby'];
|
|
5
|
+
// Components from each surface whose rendered output has no text to name it.
|
|
6
|
+
const targets = {
|
|
7
|
+
mobile: { IconButton: { names: mobile } },
|
|
8
|
+
web: {
|
|
9
|
+
Button: { names: web, when: { attribute: 'shape', value: 'icon' } },
|
|
10
|
+
'Button.Link': { names: web, when: { attribute: 'shape', value: 'icon' } },
|
|
11
|
+
Gauge: { names: web },
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Reports an icon-only `Button` or `Button.Link`, a `Gauge`, or a Mobile `IconButton` without an
|
|
16
|
+
* accessible name. An element passed to a `render` prop can take its name from the element that
|
|
17
|
+
* owns the prop. Elements with a spread attribute are skipped, since the spread can supply the name.
|
|
18
|
+
*/
|
|
19
|
+
export const rule = {
|
|
20
|
+
meta: {
|
|
21
|
+
docs: { description: 'Name `@tempoxyz/ds` components that render no text.' },
|
|
22
|
+
messages: {
|
|
23
|
+
missing: "'{{component}}' renders no text. Name it with {{names}}.",
|
|
24
|
+
},
|
|
25
|
+
schema: [],
|
|
26
|
+
type: 'problem',
|
|
27
|
+
},
|
|
28
|
+
create(context) {
|
|
29
|
+
const bindings = new Map();
|
|
30
|
+
function attribute(node, name) {
|
|
31
|
+
return node.attributes.find((attribute) => attribute.type === 'JSXAttribute' &&
|
|
32
|
+
attribute.name.type === 'JSXIdentifier' &&
|
|
33
|
+
attribute.name.name === name);
|
|
34
|
+
}
|
|
35
|
+
function literal(node) {
|
|
36
|
+
const value = node.value?.type === 'JSXExpressionContainer' ? node.value.expression : node.value;
|
|
37
|
+
return value?.type === 'Literal' ? value.value : undefined;
|
|
38
|
+
}
|
|
39
|
+
function named(target, node) {
|
|
40
|
+
if (node.attributes.some((attribute) => attribute.type === 'JSXSpreadAttribute'))
|
|
41
|
+
return true;
|
|
42
|
+
return target.names.some((name) => {
|
|
43
|
+
const found = attribute(node, name);
|
|
44
|
+
return found !== undefined && literal(found) !== '';
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function path(node) {
|
|
48
|
+
if (node.type === 'JSXIdentifier')
|
|
49
|
+
return [node.name];
|
|
50
|
+
if (node.type === 'JSXMemberExpression')
|
|
51
|
+
return [...path(node.object), node.property.name];
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
ImportDeclaration(node) {
|
|
56
|
+
const surface = Imports.surface(node.source.value);
|
|
57
|
+
if (!surface || node.importKind === 'type')
|
|
58
|
+
return;
|
|
59
|
+
for (const specifier of node.specifiers) {
|
|
60
|
+
if (specifier.type === 'ImportNamespaceSpecifier')
|
|
61
|
+
bindings.set(specifier.local.name, { imported: undefined, surface });
|
|
62
|
+
if (specifier.type === 'ImportSpecifier' && specifier.importKind !== 'type')
|
|
63
|
+
bindings.set(specifier.local.name, {
|
|
64
|
+
imported: specifier.imported.type === 'Identifier'
|
|
65
|
+
? specifier.imported.name
|
|
66
|
+
: String(specifier.imported.value),
|
|
67
|
+
surface,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
JSXOpeningElement(node) {
|
|
72
|
+
const [head, ...rest] = path(node.name);
|
|
73
|
+
const binding = head === undefined ? undefined : bindings.get(head);
|
|
74
|
+
if (!binding)
|
|
75
|
+
return;
|
|
76
|
+
const component = (binding.imported ? [binding.imported, ...rest] : rest).join('.');
|
|
77
|
+
const target = targets[binding.surface][component];
|
|
78
|
+
if (!target)
|
|
79
|
+
return;
|
|
80
|
+
if (target.when) {
|
|
81
|
+
const condition = attribute(node, target.when.attribute);
|
|
82
|
+
if (!condition || literal(condition) !== target.when.value)
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// An element passed to `render` takes its attributes from the element that owns the prop.
|
|
86
|
+
const owner = (() => {
|
|
87
|
+
for (let parent = node.parent; parent; parent = parent.parent)
|
|
88
|
+
if (parent.type === 'JSXAttribute' &&
|
|
89
|
+
parent.name.type === 'JSXIdentifier' &&
|
|
90
|
+
parent.name.name === 'render')
|
|
91
|
+
return parent.parent.type === 'JSXOpeningElement' ? parent.parent : undefined;
|
|
92
|
+
return undefined;
|
|
93
|
+
})();
|
|
94
|
+
if (!named(target, node) && (!owner || !named(target, owner)))
|
|
95
|
+
context.report({
|
|
96
|
+
data: { component, names: list.format(target.names.map((name) => `\`${name}\``)) },
|
|
97
|
+
messageId: 'missing',
|
|
98
|
+
node,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=RequireAccessibleName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequireAccessibleName.js","sourceRoot":"","sources":["../../../src/oxlint/rules/RequireAccessibleName.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AASjD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAA;AAC/D,MAAM,GAAG,GAAG,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAA;AAC7C,MAAM,MAAM,GAAG,CAAC,oBAAoB,EAAE,yBAAyB,EAAE,YAAY,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AAO,CAAC,SAAS,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK;wBAAE,OAAM;gBACpE,CAAC;gBAED,0FAA0F;gBAC1F,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE;oBAClB,KAAK,IAAI,MAAM,GAAuB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM;wBAC/E,IACE,MAAM,CAAC,IAAI,KAAK,cAAc;4BAC9B,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;4BACpC,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ;4BAE7B,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;oBACjF,OAAO,SAAS,CAAA;gBAClB,CAAC,CAAC,EAAE,CAAA;gBAEJ,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBAC3D,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,EAAE;wBAClF,SAAS,EAAE,SAAS;wBACpB,IAAI;qBACL,CAAC,CAAA;YACN,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ComponentPropsWithRef } from 'react';
|
|
2
2
|
import type * as zyzz from 'zyzz';
|
|
3
3
|
/**
|
|
4
|
-
* Formats a number in
|
|
5
|
-
* an ISO 4217 code as money, and `symbol` follows the number with a token
|
|
6
|
-
* mutually exclusive.
|
|
4
|
+
* Formats a number in `en-US`, or in `locale` when set, inside a `span` with tabular figures.
|
|
5
|
+
* `currency` formats an ISO 4217 code as money, and `symbol` follows the number with a token
|
|
6
|
+
* symbol. The two are mutually exclusive.
|
|
7
7
|
*
|
|
8
8
|
* - Pass amounts as decimal strings to avoid floating-point rounding.
|
|
9
9
|
* - Always pass `currency` or `symbol` so the unit does not depend on surrounding context.
|
|
@@ -21,6 +21,13 @@ import type * as zyzz from 'zyzz';
|
|
|
21
21
|
export declare function Amount(props: Amount.Props): import("react").JSX.Element;
|
|
22
22
|
export declare namespace Amount {
|
|
23
23
|
type Props = Omit<ComponentPropsWithRef<'span'>, 'children'> & zyzz.Props.Variants<typeof styles.amount> & {
|
|
24
|
+
/**
|
|
25
|
+
* BCP 47 tag, such as `de-DE`, for grouping, decimal marks, and currency symbols. The default
|
|
26
|
+
* does not depend on the runtime locale, so server and browser render the same text. A tag
|
|
27
|
+
* that `Intl` rejects, such as `""` or `"en_US"`, falls back to `en-US` instead of throwing.
|
|
28
|
+
* @default 'en-US'
|
|
29
|
+
*/
|
|
30
|
+
locale?: string | undefined;
|
|
24
31
|
/**
|
|
25
32
|
* Caps the fraction digits shown. With `currency`, it never exceeds the currency's own digits
|
|
26
33
|
* and sets the exact count, so `0` renders `$5`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Amount.d.ts","sourceRoot":"","sources":["../../../src/web/components/Amount.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAA;AAGjC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,+
|
|
1
|
+
{"version":3,"file":"Amount.d.ts","sourceRoot":"","sources":["../../../src/web/components/Amount.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAA;AAGjC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,+BAiCzC;AAED,yBAAiB,MAAM,CAAC;IACtB,KAAY,KAAK,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,GACjE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG;QAC1C;;;;;WAKG;QACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC3B;;;WAGG;QACH,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAChC;;;WAGG;QACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;QAC7B,mCAAmC;QACnC,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,SAAS,CAAA;QAClC;;;WAGG;QACH,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KACvB,GAAG,CACA;QACE,oCAAoC;QACpC,QAAQ,EAAE,MAAM,CAAA;QAChB,MAAM,CAAC,EAAE,SAAS,CAAA;KACnB,GACD;QACE,QAAQ,CAAC,EAAE,SAAS,CAAA;QACpB,8DAA8D;QAC9D,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAC5B,CACJ,CAAA;CACJ;AAyDD,kBAAU,MAAM,CAAC;IACR,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA2BlB,CAAA;IAEM,MAAM,MAAM,gCAAgE,CAAA;CACpF"}
|
|
@@ -3,9 +3,9 @@ import { Props as __zyzzProps, Recipe as __zyzzRecipe } from 'zyzz/runtime';
|
|
|
3
3
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { style, variants } from '../zyzz.config.js';
|
|
5
5
|
/**
|
|
6
|
-
* Formats a number in
|
|
7
|
-
* an ISO 4217 code as money, and `symbol` follows the number with a token
|
|
8
|
-
* mutually exclusive.
|
|
6
|
+
* Formats a number in `en-US`, or in `locale` when set, inside a `span` with tabular figures.
|
|
7
|
+
* `currency` formats an ISO 4217 code as money, and `symbol` follows the number with a token
|
|
8
|
+
* symbol. The two are mutually exclusive.
|
|
9
9
|
*
|
|
10
10
|
* - Pass amounts as decimal strings to avoid floating-point rounding.
|
|
11
11
|
* - Always pass `currency` or `symbol` so the unit does not depend on surrounding context.
|
|
@@ -21,7 +21,7 @@ import { style, variants } from '../zyzz.config.js';
|
|
|
21
21
|
* @see {@link https://www.w3.org/WAI/WCAG22/Understanding/meaningful-sequence.html | WCAG 2.2 Meaningful Sequence}
|
|
22
22
|
*/
|
|
23
23
|
export function Amount(props) {
|
|
24
|
-
const { className, currency, maxDecimals, precise, sign, size, strikethrough, symbol, value, vars, ...attributes } = props;
|
|
24
|
+
const { className, currency, locale, maxDecimals, precise, sign, size, strikethrough, symbol, value, vars, ...attributes } = props;
|
|
25
25
|
return (_jsxs("span", { ...attributes, ...styles.amount({
|
|
26
26
|
align: props.align,
|
|
27
27
|
className,
|
|
@@ -29,25 +29,35 @@ export function Amount(props) {
|
|
|
29
29
|
strikethrough,
|
|
30
30
|
style: props.style,
|
|
31
31
|
vars,
|
|
32
|
-
}), children: [sign, format({ currency, maxDecimals, precise, value }), symbol && _jsxs("span", { ...styles.symbol(), children: [" ", symbol] })] }));
|
|
32
|
+
}), children: [sign, format({ currency, locale, maxDecimals, precise, value }), symbol && _jsxs("span", { ...styles.symbol(), children: [" ", symbol] })] }));
|
|
33
33
|
}
|
|
34
34
|
function format(options) {
|
|
35
35
|
const { currency, maxDecimals, precise, value } = options;
|
|
36
36
|
// ES2023 formats decimal strings exactly. The signature keeps ES2022 libs compiling.
|
|
37
37
|
const exact = (formatter) => formatter.format(value);
|
|
38
|
+
// `Intl.NumberFormat` throws for a malformed tag and replaces an unsupported one with the
|
|
39
|
+
// runtime locale, so both resolve to `en-US` here.
|
|
40
|
+
const locale = (() => {
|
|
41
|
+
try {
|
|
42
|
+
return Intl.NumberFormat.supportedLocalesOf(options.locale)[0] ?? 'en-US';
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return 'en-US';
|
|
46
|
+
}
|
|
47
|
+
})();
|
|
38
48
|
if (currency) {
|
|
39
49
|
const money = { currency, style: 'currency' };
|
|
40
|
-
const max = new Intl.NumberFormat(
|
|
50
|
+
const max = new Intl.NumberFormat(locale, money).resolvedOptions().maximumFractionDigits;
|
|
41
51
|
const digits = Math.min(maxDecimals ?? max, max);
|
|
42
52
|
const number = Number(value);
|
|
43
53
|
const sub = number !== 0 && Math.abs(number) < 10 ** -digits;
|
|
44
54
|
if (sub && precise)
|
|
45
|
-
return exact(new Intl.NumberFormat(
|
|
55
|
+
return exact(new Intl.NumberFormat(locale, {
|
|
46
56
|
...money,
|
|
47
57
|
maximumFractionDigits: 20,
|
|
48
58
|
maximumSignificantDigits: 2,
|
|
49
59
|
}));
|
|
50
|
-
const formatter = new Intl.NumberFormat(
|
|
60
|
+
const formatter = new Intl.NumberFormat(locale, {
|
|
51
61
|
...money,
|
|
52
62
|
maximumFractionDigits: digits,
|
|
53
63
|
minimumFractionDigits: digits,
|
|
@@ -57,7 +67,7 @@ function format(options) {
|
|
|
57
67
|
// A string keeps its own fraction digits. A number shows as many as it holds.
|
|
58
68
|
const fraction = typeof value === 'string' ? (value.split('.')[1]?.length ?? 0) : 20;
|
|
59
69
|
const digits = Math.min(maxDecimals ?? fraction, fraction);
|
|
60
|
-
return exact(new Intl.NumberFormat(
|
|
70
|
+
return exact(new Intl.NumberFormat(locale, {
|
|
61
71
|
maximumFractionDigits: digits,
|
|
62
72
|
minimumFractionDigits: typeof value === 'string' ? digits : 0,
|
|
63
73
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Amount.js","sourceRoot":"","sources":["../../../src/web/components/Amount.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,MAAM,CAAC,KAAmB;IACxC,MAAM,EACJ,SAAS,EACT,QAAQ,EACR,WAAW,EACX,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,MAAM,EACN,KAAK,EACL,IAAI,EACJ,GAAG,UAAU,EACd,GAAG,KAAK,CAAA;IAET,OAAO,CACL,mBACM,UAAU,KACV,MAAM,CAAC,MAAM,CAAC;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS;YACT,IAAI;YACJ,aAAa;YACb,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,IAAI;SACL,CAAC,aAED,IAAI,EACJ,MAAM,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"Amount.js","sourceRoot":"","sources":["../../../src/web/components/Amount.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,MAAM,CAAC,KAAmB;IACxC,MAAM,EACJ,SAAS,EACT,QAAQ,EACR,MAAM,EACN,WAAW,EACX,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,MAAM,EACN,KAAK,EACL,IAAI,EACJ,GAAG,UAAU,EACd,GAAG,KAAK,CAAA;IAET,OAAO,CACL,mBACM,UAAU,KACV,MAAM,CAAC,MAAM,CAAC;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS;YACT,IAAI;YACJ,aAAa;YACb,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,IAAI;SACL,CAAC,aAED,IAAI,EACJ,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EA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MAAM,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE;gBAC/B,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;gBAC3B,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE;aAC9B;YACD,IAAI,EAAE;gBACJ,EAAE,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE;gBAChC,EAAE,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE;gBAChC,EAAE,EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAE;gBACpC,EAAE,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE;aACjC;YACD,aAAa,EAAE;gBACb,KAAK,EAAE,EAAE;gBACT,IAAI,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,sBAAsB,EAAE;aACpE;SACF;KACF,EACD,EAAE,EAAE,EAAE,gBAAgB,EAAE,CACzB,CAAA;IAEY,aAAM,GAAG,KAAK,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE,uBAAuB,EAAE,CAAC,CAAA;AACrF,CAAC,EA/BS,MAAM,KAAN,MAAM,QA+Bf"}
|
|
@@ -2,8 +2,21 @@ import { type ComponentPropsWithRef } from 'react';
|
|
|
2
2
|
import type * as zyzz from 'zyzz';
|
|
3
3
|
import { Input } from './Input.js';
|
|
4
4
|
/**
|
|
5
|
-
* Decimal amount entry. The value is a raw string
|
|
6
|
-
* not a non-negative decimal is rejected.
|
|
5
|
+
* Decimal amount entry. The value is a raw string with a dot separator and no grouping
|
|
6
|
+
* separators, and input that is not a non-negative decimal is rejected.
|
|
7
|
+
*
|
|
8
|
+
* The text around a comma decides whether it groups thousands or separates decimals:
|
|
9
|
+
*
|
|
10
|
+
* - With both a dot and a comma, the last one separates decimals and the other groups thousands:
|
|
11
|
+
* `1,250.50` and `1.250,50` are both `1250.50`.
|
|
12
|
+
* - Several commas group thousands: `1,250,000` is `1250000`.
|
|
13
|
+
* - A lone comma groups thousands after one to three digits that do not start with `0`, when
|
|
14
|
+
* exactly three digits follow it: `1,250` is `1250`.
|
|
15
|
+
* - Any other lone comma separates decimals: `1,5` is `1.5`, `0,250` is `0.250`, `1234,567` is
|
|
16
|
+
* `1234.567`, and `12,` is `12.`.
|
|
17
|
+
*
|
|
18
|
+
* The field shows a lone comma as typed until a dot or a second comma settles it, then shows the
|
|
19
|
+
* value.
|
|
7
20
|
*
|
|
8
21
|
* `Control` is a text input with `inputMode="decimal"`, so mobile keyboards show digits without
|
|
9
22
|
* the scroll and spinner behavior of `type="number"`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmountInput.d.ts","sourceRoot":"","sources":["../../../src/web/components/AmountInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAY,MAAM,OAAO,CAAA;AAE5D,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAA;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGlC
|
|
1
|
+
{"version":3,"file":"AmountInput.d.ts","sourceRoot":"","sources":["../../../src/web/components/AmountInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAY,MAAM,OAAO,CAAA;AAE5D,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAA;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,yBAAiB,WAAW,CAAC;IAC3B;;;;OAIG;IACH,SAAgB,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,+BAkBrC;IAED,UAAiB,IAAI,CAAC;QACpB,KAAY,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,CAAC,GAAG;YACzE,kBAAkB;YAClB,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;YACjC,aAAa,CAA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