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.
@@ -5,6 +5,7 @@ export interface LabelBaseProps extends LabelHTMLAttributes<HTMLLabelElement> {
5
5
  type?: 'block' | 'inline';
6
6
  disabled?: boolean;
7
7
  optional?: boolean;
8
+ optionalClassName?: string;
8
9
  testId?: string;
9
10
  }
10
11
  export type LabelProps = LabelBaseProps & MarginProps;
@@ -9,4 +9,5 @@ export declare const Default: Story;
9
9
  export declare const Inline: Story;
10
10
  export declare const Disabled: Story;
11
11
  export declare const Optional: Story;
12
+ export declare const OptionalWithCustomStyle: Story;
12
13
  export declare const WithLongText: Story;
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
- testId: r = dl,
20954
- className: l,
20955
- children: i,
20956
- ...a
20957
- }, c) => {
20958
- const [u] = L(), {
20959
- disabled: s,
20960
- optional: f,
20961
- id: h
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 ?? s, o = o ?? f;
20964
- const p = a.htmlFor ?? h, { md: m, mdSemibold: y } = u.typography.body, b = d`
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: ${u.colour.text.default};
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: ${u.colour.text.disabled};
20978
+ color: ${s.colour.text.disabled};
20978
20979
  `, S = A(
20979
20980
  dl,
20980
20981
  b,
20981
- He(a, u),
20982
+ He(c, s),
20982
20983
  e === "block" && C,
20983
20984
  e === "inline" && k,
20984
20985
  t && x,
20985
- l
20986
- ), M = d`
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: c,
20994
- htmlFor: p,
20991
+ ref: u,
20992
+ htmlFor: m,
20995
20993
  className: S,
20996
- "data-testid": r,
20997
- ...a,
20994
+ "data-testid": l,
20995
+ ...c,
20998
20996
  children: [
20999
- i,
20997
+ a,
21000
20998
  o && /* @__PURE__ */ g(Oe, { children: [
21001
20999
  " ",
21002
- /* @__PURE__ */ n("span", { className: M, children: "(optional)" })
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 { md, mdSemibold } = theme.typography.body;
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={optionalStyle}>(optional)</span>
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>
@@ -68,9 +68,7 @@ exports[`Label > snapshot: with optional prop 1`] = `
68
68
  >
69
69
  Name
70
70
 
71
- <span
72
- class="css-1fd72bb"
73
- >
71
+ <span>
74
72
  (optional)
75
73
  </span>
76
74
  </label>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "uikit-react-public",
3
3
  "private": false,
4
4
  "license": "UNLICENSED",
5
- "version": "0.45.4",
5
+ "version": "0.45.5",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",