uikit-react-public 0.47.1 → 0.48.0
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/ConfidentialInput/ConfidentialInput.d.ts +9 -0
- package/dist/components/ConfidentialInput/ConfidentialInput.stories.d.ts +20 -0
- package/dist/components/ConfidentialInput/__tests__/ConfidentialInput.test.d.ts +1 -0
- package/dist/components/ConfidentialInput/index.d.ts +2 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/index.js +4620 -4463
- package/lib/components/ConfidentialInput/ConfidentialInput.stories.tsx +45 -0
- package/lib/components/ConfidentialInput/ConfidentialInput.tsx +273 -0
- package/lib/components/ConfidentialInput/Documentation.mdx +62 -0
- package/lib/components/ConfidentialInput/__tests__/ConfidentialInput.test.tsx +272 -0
- package/lib/components/ConfidentialInput/index.ts +2 -0
- package/lib/components/Input/Input.tsx +18 -2
- package/lib/components/Input/__tests__/Input.test.tsx +34 -0
- package/lib/components/Label/Label.tsx +8 -2
- package/lib/components/Label/__tests__/__snapshots__/Label.test.tsx.snap +3 -1
- package/lib/components/index.ts +3 -0
- package/package.json +1 -1
|
@@ -3,6 +3,8 @@ import { render, screen } from '@testing-library/react';
|
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import Input from '../Input';
|
|
5
5
|
import { ThemeContextProvider } from '../../../theme/useTheme';
|
|
6
|
+
import Icon from '../../Icon';
|
|
7
|
+
import IconButton from '../../IconButton';
|
|
6
8
|
|
|
7
9
|
describe('Input', () => {
|
|
8
10
|
// Snapshot tests
|
|
@@ -105,4 +107,36 @@ describe('Input', () => {
|
|
|
105
107
|
const input = screen.getByRole('textbox') as HTMLInputElement;
|
|
106
108
|
expect(input.id).toBe('custom-id');
|
|
107
109
|
});
|
|
110
|
+
|
|
111
|
+
test('positions a right icon before an icon button', () => {
|
|
112
|
+
render(
|
|
113
|
+
<ThemeContextProvider>
|
|
114
|
+
<Input
|
|
115
|
+
icon={
|
|
116
|
+
<Icon.Search
|
|
117
|
+
testId='right-icon'
|
|
118
|
+
aria-hidden='true'
|
|
119
|
+
/>
|
|
120
|
+
}
|
|
121
|
+
iconPosition='right'
|
|
122
|
+
iconButton={
|
|
123
|
+
<IconButton
|
|
124
|
+
testId='icon-button'
|
|
125
|
+
aria-label='Search'
|
|
126
|
+
>
|
|
127
|
+
<Icon.Search />
|
|
128
|
+
</IconButton>
|
|
129
|
+
}
|
|
130
|
+
/>
|
|
131
|
+
</ThemeContextProvider>
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const input = screen.getByTestId('ucl-uikit-input');
|
|
135
|
+
const iconWrapper = screen.getByTestId('right-icon').parentElement;
|
|
136
|
+
const buttonWrapper = screen.getByTestId('icon-button').parentElement;
|
|
137
|
+
|
|
138
|
+
expect(input).toHaveStyle({ paddingRight: '80px' });
|
|
139
|
+
expect(iconWrapper).toHaveStyle({ right: '48px' });
|
|
140
|
+
expect(buttonWrapper).toHaveStyle({ right: '16px' });
|
|
141
|
+
});
|
|
108
142
|
});
|
|
@@ -42,7 +42,7 @@ const Label = forwardRef<Ref, LabelProps>(
|
|
|
42
42
|
disabled = disabled ?? contextDisabled;
|
|
43
43
|
optional = optional ?? contextOptional;
|
|
44
44
|
const htmlFor = props.htmlFor ?? contextId;
|
|
45
|
-
const { mdSemibold } = theme.typography.body;
|
|
45
|
+
const { md, mdSemibold } = theme.typography.body;
|
|
46
46
|
|
|
47
47
|
const baseStyle = css`
|
|
48
48
|
width: 100%;
|
|
@@ -76,6 +76,10 @@ const Label = forwardRef<Ref, LabelProps>(
|
|
|
76
76
|
className
|
|
77
77
|
);
|
|
78
78
|
|
|
79
|
+
const optionalStyle = css`
|
|
80
|
+
font-weight: ${md.fontWeight};
|
|
81
|
+
`;
|
|
82
|
+
|
|
79
83
|
return (
|
|
80
84
|
<label
|
|
81
85
|
ref={ref}
|
|
@@ -88,7 +92,9 @@ const Label = forwardRef<Ref, LabelProps>(
|
|
|
88
92
|
{optional && (
|
|
89
93
|
<>
|
|
90
94
|
{' '}
|
|
91
|
-
<span className={optionalClassName}>
|
|
95
|
+
<span className={cx(optionalStyle, optionalClassName)}>
|
|
96
|
+
(optional)
|
|
97
|
+
</span>
|
|
92
98
|
</>
|
|
93
99
|
)}
|
|
94
100
|
</label>
|
package/lib/components/index.ts
CHANGED
|
@@ -4,6 +4,9 @@ export type { IconProps } from './Icon';
|
|
|
4
4
|
export { default as Input } from './Input';
|
|
5
5
|
export type { InputProps } from './Input';
|
|
6
6
|
|
|
7
|
+
export { default as ConfidentialInput } from './ConfidentialInput';
|
|
8
|
+
export type { ConfidentialInputProps } from './ConfidentialInput';
|
|
9
|
+
|
|
7
10
|
export { default as Link } from './Link';
|
|
8
11
|
export type { LinkProps } from './Link';
|
|
9
12
|
|