uikit-react-public 0.45.4 → 0.45.5
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/components/Label/Label.d.ts +1 -0
- package/dist/components/Label/Label.stories.d.ts +1 -0
- package/dist/index.js +23 -25
- package/lib/components/Label/Label.stories.tsx +17 -0
- package/lib/components/Label/Label.tsx +4 -7
- package/lib/components/Label/__tests__/Label.test.tsx +15 -0
- package/lib/components/Label/__tests__/__snapshots__/Label.test.tsx.snap +1 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20950,20 +20950,21 @@ const M3 = (e, t) => {
|
|
|
20950
20950
|
type: e = "block",
|
|
20951
20951
|
disabled: t,
|
|
20952
20952
|
optional: o,
|
|
20953
|
-
|
|
20954
|
-
|
|
20955
|
-
|
|
20956
|
-
|
|
20957
|
-
|
|
20958
|
-
|
|
20959
|
-
|
|
20960
|
-
|
|
20961
|
-
|
|
20953
|
+
optionalClassName: r,
|
|
20954
|
+
testId: l = dl,
|
|
20955
|
+
className: i,
|
|
20956
|
+
children: a,
|
|
20957
|
+
...c
|
|
20958
|
+
}, u) => {
|
|
20959
|
+
const [s] = L(), {
|
|
20960
|
+
disabled: f,
|
|
20961
|
+
optional: h,
|
|
20962
|
+
id: p
|
|
20962
20963
|
} = St(Tt);
|
|
20963
|
-
t = t ??
|
|
20964
|
-
const
|
|
20964
|
+
t = t ?? f, o = o ?? h;
|
|
20965
|
+
const m = c.htmlFor ?? p, { mdSemibold: y } = s.typography.body, b = d`
|
|
20965
20966
|
width: 100%;
|
|
20966
|
-
color: ${
|
|
20967
|
+
color: ${s.colour.text.default};
|
|
20967
20968
|
font-family: ${y.fontFamily};
|
|
20968
20969
|
font-feature-settings: ${y.fontSettings};
|
|
20969
20970
|
font-size: ${y.fontSize}px;
|
|
@@ -20974,32 +20975,29 @@ const M3 = (e, t) => {
|
|
|
20974
20975
|
`, k = d`
|
|
20975
20976
|
display: inline;
|
|
20976
20977
|
`, x = d`
|
|
20977
|
-
color: ${
|
|
20978
|
+
color: ${s.colour.text.disabled};
|
|
20978
20979
|
`, S = A(
|
|
20979
20980
|
dl,
|
|
20980
20981
|
b,
|
|
20981
|
-
He(
|
|
20982
|
+
He(c, s),
|
|
20982
20983
|
e === "block" && C,
|
|
20983
20984
|
e === "inline" && k,
|
|
20984
20985
|
t && x,
|
|
20985
|
-
|
|
20986
|
-
)
|
|
20987
|
-
font-weight: ${m.fontWeight};
|
|
20988
|
-
font-style: italic;
|
|
20989
|
-
`;
|
|
20986
|
+
i
|
|
20987
|
+
);
|
|
20990
20988
|
return /* @__PURE__ */ g(
|
|
20991
20989
|
"label",
|
|
20992
20990
|
{
|
|
20993
|
-
ref:
|
|
20994
|
-
htmlFor:
|
|
20991
|
+
ref: u,
|
|
20992
|
+
htmlFor: m,
|
|
20995
20993
|
className: S,
|
|
20996
|
-
"data-testid":
|
|
20997
|
-
...
|
|
20994
|
+
"data-testid": l,
|
|
20995
|
+
...c,
|
|
20998
20996
|
children: [
|
|
20999
|
-
|
|
20997
|
+
a,
|
|
21000
20998
|
o && /* @__PURE__ */ g(Oe, { children: [
|
|
21001
20999
|
" ",
|
|
21002
|
-
/* @__PURE__ */ n("span", { className:
|
|
21000
|
+
/* @__PURE__ */ n("span", { className: r, children: "(optional)" })
|
|
21003
21001
|
] })
|
|
21004
21002
|
]
|
|
21005
21003
|
}
|
|
@@ -38,6 +38,23 @@ export const Optional: Story = {
|
|
|
38
38
|
},
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
export const OptionalWithCustomStyle: Story = {
|
|
42
|
+
name: 'Optional with custom style',
|
|
43
|
+
args: {
|
|
44
|
+
children: 'Optional label',
|
|
45
|
+
optional: true,
|
|
46
|
+
optionalClassName: 'custom-optional-style',
|
|
47
|
+
},
|
|
48
|
+
decorators: [
|
|
49
|
+
(Story) => (
|
|
50
|
+
<>
|
|
51
|
+
<style>{`.custom-optional-style { font-weight: normal; color: #565656; }`}</style>
|
|
52
|
+
<Story />
|
|
53
|
+
</>
|
|
54
|
+
),
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
|
|
41
58
|
export const WithLongText: Story = {
|
|
42
59
|
name: 'With long text',
|
|
43
60
|
args: {
|
|
@@ -10,6 +10,7 @@ export interface LabelBaseProps extends LabelHTMLAttributes<HTMLLabelElement> {
|
|
|
10
10
|
type?: 'block' | 'inline';
|
|
11
11
|
disabled?: boolean;
|
|
12
12
|
optional?: boolean;
|
|
13
|
+
optionalClassName?: string;
|
|
13
14
|
testId?: string;
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -23,6 +24,7 @@ const Label = forwardRef<Ref, LabelProps>(
|
|
|
23
24
|
type = 'block',
|
|
24
25
|
disabled,
|
|
25
26
|
optional,
|
|
27
|
+
optionalClassName,
|
|
26
28
|
testId = NAME,
|
|
27
29
|
className,
|
|
28
30
|
children,
|
|
@@ -40,7 +42,7 @@ const Label = forwardRef<Ref, LabelProps>(
|
|
|
40
42
|
disabled = disabled ?? contextDisabled;
|
|
41
43
|
optional = optional ?? contextOptional;
|
|
42
44
|
const htmlFor = props.htmlFor ?? contextId;
|
|
43
|
-
const {
|
|
45
|
+
const { mdSemibold } = theme.typography.body;
|
|
44
46
|
|
|
45
47
|
const baseStyle = css`
|
|
46
48
|
width: 100%;
|
|
@@ -74,11 +76,6 @@ const Label = forwardRef<Ref, LabelProps>(
|
|
|
74
76
|
className
|
|
75
77
|
);
|
|
76
78
|
|
|
77
|
-
const optionalStyle = css`
|
|
78
|
-
font-weight: ${md.fontWeight};
|
|
79
|
-
font-style: italic;
|
|
80
|
-
`;
|
|
81
|
-
|
|
82
79
|
return (
|
|
83
80
|
<label
|
|
84
81
|
ref={ref}
|
|
@@ -91,7 +88,7 @@ const Label = forwardRef<Ref, LabelProps>(
|
|
|
91
88
|
{optional && (
|
|
92
89
|
<>
|
|
93
90
|
{' '}
|
|
94
|
-
<span className={
|
|
91
|
+
<span className={optionalClassName}>(optional)</span>
|
|
95
92
|
</>
|
|
96
93
|
)}
|
|
97
94
|
</label>
|
|
@@ -51,6 +51,21 @@ describe('Label', () => {
|
|
|
51
51
|
expect(renderResult.container.firstChild).toMatchSnapshot();
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
+
test('optional text can accept a custom class name', () => {
|
|
55
|
+
render(
|
|
56
|
+
<ThemeContextProvider>
|
|
57
|
+
<Label
|
|
58
|
+
optional
|
|
59
|
+
optionalClassName='custom-optional-class'
|
|
60
|
+
>
|
|
61
|
+
Name
|
|
62
|
+
</Label>
|
|
63
|
+
</ThemeContextProvider>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
expect(screen.getByText('(optional)')).toHaveClass('custom-optional-class');
|
|
67
|
+
});
|
|
68
|
+
|
|
54
69
|
test('snapshot: testId prop', () => {
|
|
55
70
|
const renderResult = render(
|
|
56
71
|
<ThemeContextProvider>
|