@astryxdesign/core 0.2.0-canary.bdc7cde → 0.2.0-canary.ea693ac
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Field/FieldLabel.d.ts +2 -1
- package/dist/Field/FieldLabel.d.ts.map +1 -1
- package/dist/Field/FieldLabel.js +7 -3
- package/dist/astryx.umd.js +19 -19
- package/dist/astryx.umd.js.map +3 -3
- package/locales/en.json +8 -0
- package/locales/pseudo.json +6 -0
- package/package.json +1 -1
- package/src/Field/FieldLabel.test.tsx +25 -0
- package/src/Field/FieldLabel.tsx +11 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file FieldLabel.tsx
|
|
3
|
-
* @input Uses React, Icon, IconType
|
|
3
|
+
* @input Uses React, Icon, IconType, useTranslator
|
|
4
4
|
* @output Exports FieldLabel component, FieldLabelProps
|
|
5
5
|
* @position Core label implementation; used by Field, CheckboxInput, Switch
|
|
6
6
|
*
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* - /packages/core/src/Field/Field.doc.mjs (props table, features, implementation notes)
|
|
9
9
|
* - /packages/core/src/Field/index.ts (exports if types change)
|
|
10
10
|
* - /packages/cli/templates/blocks/components/Field/ (showcase blocks)
|
|
11
|
+
* - /packages/core/locales/en.json (@astryx.field.required / @astryx.field.optional)
|
|
11
12
|
*/
|
|
12
13
|
import type { ReactNode } from 'react';
|
|
13
14
|
import type { BaseProps } from '../BaseProps';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldLabel.d.ts","sourceRoot":"","sources":["../../src/Field/FieldLabel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FieldLabel.d.ts","sourceRoot":"","sources":["../../src/Field/FieldLabel.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAErC,OAAO,KAA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. and affiliates.
|
|
2
2
|
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* @file FieldLabel.tsx
|
|
5
|
-
* @input Uses React, Icon, IconType
|
|
7
|
+
* @input Uses React, Icon, IconType, useTranslator
|
|
6
8
|
* @output Exports FieldLabel component, FieldLabelProps
|
|
7
9
|
* @position Core label implementation; used by Field, CheckboxInput, Switch
|
|
8
10
|
*
|
|
@@ -10,14 +12,15 @@
|
|
|
10
12
|
* - /packages/core/src/Field/Field.doc.mjs (props table, features, implementation notes)
|
|
11
13
|
* - /packages/core/src/Field/index.ts (exports if types change)
|
|
12
14
|
* - /packages/cli/templates/blocks/components/Field/ (showcase blocks)
|
|
15
|
+
* - /packages/core/locales/en.json (@astryx.field.required / @astryx.field.optional)
|
|
13
16
|
*/
|
|
14
|
-
|
|
15
17
|
import * as stylex from '@stylexjs/stylex';
|
|
16
18
|
import { mergeProps } from "../utils/index.js";
|
|
17
19
|
import "../theme/tokens.stylex.js";
|
|
18
20
|
import { colorVars, fontWeightVars, spacingVars, typographyVars, typeScaleVars } from "../theme/tokens.stylex.js";
|
|
19
21
|
import { Icon, renderIconSlot } from "../Icon/index.js";
|
|
20
22
|
import { Tooltip } from "../Tooltip/index.js";
|
|
23
|
+
import { useTranslator } from "../i18n/index.js";
|
|
21
24
|
import { themeProps } from "../utils/themeProps.js";
|
|
22
25
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
23
26
|
const styles = {
|
|
@@ -87,7 +90,8 @@ export function FieldLabel({
|
|
|
87
90
|
ref,
|
|
88
91
|
...rest
|
|
89
92
|
}) {
|
|
90
|
-
const
|
|
93
|
+
const t = useTranslator();
|
|
94
|
+
const statusText = isOptional ? t('@astryx.field.optional') : isRequired ? t('@astryx.field.required') : null;
|
|
91
95
|
|
|
92
96
|
// A group label (e.g. for a radiogroup) must not be a literal `<label>`
|
|
93
97
|
// element: a `<label>` semantically names a single form control and can't be
|