@redis-ui/components 42.8.0 → 43.2.1
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/AutoCompleteSelect/AutoCompleteSelect.cjs +7 -1
- package/dist/AutoCompleteSelect/AutoCompleteSelect.js +7 -1
- package/dist/AutoCompleteSelect/hooks/useAutoCompleteSelect.cjs +7 -1
- package/dist/AutoCompleteSelect/hooks/useAutoCompleteSelect.d.ts +8 -1
- package/dist/AutoCompleteSelect/hooks/useAutoCompleteSelect.js +7 -1
- package/dist/BoxSelectionGroup/components/Item/components/BoxStateIndicator/BoxStateIndicator.cjs +8 -4
- package/dist/BoxSelectionGroup/components/Item/components/BoxStateIndicator/BoxStateIndicator.js +8 -4
- package/dist/BoxSelectionGroup/components/Item/components/Compose/Compose.style.cjs +18 -4
- package/dist/BoxSelectionGroup/components/Item/components/Compose/Compose.style.js +18 -4
- package/dist/BoxSelectionGroup/hooks/useBoxSelectionGroup.cjs +3 -1
- package/dist/BoxSelectionGroup/hooks/useBoxSelectionGroup.js +3 -1
- package/dist/Button/Button.style.cjs +4 -1
- package/dist/Button/Button.style.js +4 -1
- package/dist/Button/Button.style.utils.cjs +16 -1
- package/dist/Button/Button.style.utils.js +16 -1
- package/dist/Button/Button.types.cjs +1 -1
- package/dist/Button/Button.types.d.ts +1 -1
- package/dist/Button/Button.types.js +1 -1
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.cjs +59 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.d.ts +4 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.js +57 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.style.cjs +40 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.style.d.ts +8 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.style.js +38 -0
- package/dist/Button/CopyToClipboardButton/CopyToClipboardButton.types.d.ts +5 -0
- package/dist/Button/TextButton/TextButton.style.cjs +4 -1
- package/dist/Button/TextButton/TextButton.style.js +4 -1
- package/dist/Button/TextButton/TextButton.types.cjs +1 -1
- package/dist/Button/TextButton/TextButton.types.d.ts +1 -1
- package/dist/Button/TextButton/TextButton.types.js +1 -1
- package/dist/Button/index.d.ts +2 -0
- package/dist/Checkbox/components/Label/Label.style.cjs +15 -3
- package/dist/Checkbox/components/Label/Label.style.js +15 -3
- package/dist/Chip/components/CloseButton/CloseButton.cjs +3 -1
- package/dist/Chip/components/CloseButton/CloseButton.js +3 -1
- package/dist/Chip/components/Compose/Compose.style.cjs +4 -1
- package/dist/Chip/components/Compose/Compose.style.js +4 -1
- package/dist/Drawer/components/Description/Description.cjs +3 -1
- package/dist/Drawer/components/Description/Description.js +3 -1
- package/dist/Helpers/contexts/Popper/PopperCollisionBoundaryManager.cjs +3 -1
- package/dist/Helpers/contexts/Popper/PopperCollisionBoundaryManager.js +3 -1
- package/dist/Helpers/contexts/PrimitiveContextState.cjs +28 -16
- package/dist/Helpers/contexts/PrimitiveContextState.js +28 -16
- package/dist/Helpers/contexts/SharedId.context.cjs +9 -5
- package/dist/Helpers/contexts/SharedId.context.js +9 -5
- package/dist/Helpers/css.utils.cjs +18 -4
- package/dist/Helpers/css.utils.d.ts +15 -3
- package/dist/Helpers/css.utils.js +18 -4
- package/dist/Helpers/hooks/useScrollable.cjs +3 -1
- package/dist/Helpers/hooks/useScrollable.js +3 -1
- package/dist/Helpers/react.utils.cjs +6 -2
- package/dist/Helpers/react.utils.js +6 -2
- package/dist/HighlightedIcon/HighlightedIcon.cjs +26 -0
- package/dist/HighlightedIcon/HighlightedIcon.d.ts +3 -0
- package/dist/HighlightedIcon/HighlightedIcon.js +26 -0
- package/dist/HighlightedIcon/HighlightedIcon.style.cjs +49 -0
- package/dist/HighlightedIcon/HighlightedIcon.style.d.ts +5 -0
- package/dist/HighlightedIcon/HighlightedIcon.style.js +47 -0
- package/dist/HighlightedIcon/HighlightedIcon.types.d.ts +8 -0
- package/dist/HighlightedIcon/index.d.ts +3 -0
- package/dist/Inputs/QuantityCounter/components/InputGroup/components/ValueLabel/ValueLabel.cjs +9 -5
- package/dist/Inputs/QuantityCounter/components/InputGroup/components/ValueLabel/ValueLabel.js +9 -5
- package/dist/Inputs/components/Compose/Compose.style.cjs +29 -6
- package/dist/Inputs/components/Compose/Compose.style.js +29 -6
- package/dist/Inputs/hooks/numericInput/numericInput.utils.cjs +12 -4
- package/dist/Inputs/hooks/numericInput/numericInput.utils.js +12 -4
- package/dist/Inputs/hooks/numericInput/useNumericInput.cjs +15 -3
- package/dist/Inputs/hooks/numericInput/useNumericInput.js +15 -3
- package/dist/Loader/Loader.cjs +1 -0
- package/dist/Loader/Loader.js +1 -0
- package/dist/Menu/components/Content/components/Item/Components/Compose/Compose.style.cjs +19 -4
- package/dist/Menu/components/Content/components/Item/Components/Compose/Compose.style.js +19 -4
- package/dist/Menu/components/Content/components/Label/components/Compose/Compose.style.cjs +4 -1
- package/dist/Menu/components/Content/components/Label/components/Compose/Compose.style.js +4 -1
- package/dist/Modal/components/Content/components/Compose/Compose.cjs +3 -1
- package/dist/Modal/components/Content/components/Compose/Compose.js +3 -1
- package/dist/Modal/components/Content/components/Description/Description.cjs +3 -1
- package/dist/Modal/components/Content/components/Description/Description.js +3 -1
- package/dist/MultiSelect/components/Compose/hooks/useMultiSelectContextApi.cjs +3 -1
- package/dist/MultiSelect/components/Compose/hooks/useMultiSelectContextApi.js +3 -1
- package/dist/MultiSelect/components/Trigger/components/MultiValue/MultiValue.cjs +3 -1
- package/dist/MultiSelect/components/Trigger/components/MultiValue/MultiValue.js +3 -1
- package/dist/Overflow/Overflow.cjs +3 -1
- package/dist/Overflow/Overflow.js +3 -1
- package/dist/Overflow/Overflow.utils.cjs +15 -6
- package/dist/Overflow/Overflow.utils.js +15 -6
- package/dist/Overflow/components/OverflowContainer/OverflowContainer.cjs +3 -1
- package/dist/Overflow/components/OverflowContainer/OverflowContainer.js +3 -1
- package/dist/Pagination/components/PageSizeSelect.cjs +3 -1
- package/dist/Pagination/components/PageSizeSelect.js +3 -1
- package/dist/Popover/components/Content/Content.cjs +3 -1
- package/dist/Popover/components/Content/Content.js +3 -1
- package/dist/Popover/components/Content/components/Footer/Footer.cjs +3 -1
- package/dist/Popover/components/Content/components/Footer/Footer.js +3 -1
- package/dist/RadioGroup/components/Item/components/Label/Label.style.cjs +15 -3
- package/dist/RadioGroup/components/Item/components/Label/Label.style.js +15 -3
- package/dist/ScreenReaderAnnounce/ScreenReaderAnnounce.cjs +3 -1
- package/dist/ScreenReaderAnnounce/ScreenReaderAnnounce.js +3 -1
- package/dist/Section/components/Header/components/CollapseButton/CollapseButton.cjs +3 -1
- package/dist/Section/components/Header/components/CollapseButton/CollapseButton.js +3 -1
- package/dist/Select/components/Content/components/Option/components/Compose/Compose.style.cjs +16 -4
- package/dist/Select/components/Content/components/Option/components/Compose/Compose.style.js +16 -4
- package/dist/Select/components/Content/components/OptionList/OptionList.cjs +6 -4
- package/dist/Select/components/Content/components/OptionList/OptionList.js +6 -4
- package/dist/Select/components/Content/components/OptionList/Virtual.cjs +9 -5
- package/dist/Select/components/Content/components/OptionList/Virtual.js +9 -5
- package/dist/Select/components/Context/hooks/useSearch.cjs +3 -1
- package/dist/Select/components/Context/hooks/useSearch.js +3 -1
- package/dist/Select/components/Trigger/components/Compose/Compose.style.cjs +33 -7
- package/dist/Select/components/Trigger/components/Compose/Compose.style.js +33 -7
- package/dist/SideBar/components/Item/Item.style.cjs +14 -3
- package/dist/SideBar/components/Item/Item.style.js +14 -3
- package/dist/Skeleton/components/Circle/Circle.cjs +1 -1
- package/dist/Skeleton/components/Circle/Circle.js +1 -1
- package/dist/Skeleton/components/Square/Square.cjs +1 -1
- package/dist/Skeleton/components/Square/Square.js +1 -1
- package/dist/Slider/components/Label/Compose/Compose.cjs +3 -1
- package/dist/Slider/components/Label/Compose/Compose.js +3 -1
- package/dist/Slider/components/Mark/Compose/Compose.cjs +3 -1
- package/dist/Slider/components/Mark/Compose/Compose.js +3 -1
- package/dist/Slider/hooks/useOffset.cjs +3 -1
- package/dist/Slider/hooks/useOffset.js +3 -1
- package/dist/Stepper/Stepper.cjs +14 -5
- package/dist/Stepper/Stepper.d.ts +2 -0
- package/dist/Stepper/Stepper.js +14 -5
- package/dist/Stepper/Stepper.utils.cjs +12 -0
- package/dist/Stepper/Stepper.utils.d.ts +2 -0
- package/dist/Stepper/Stepper.utils.js +12 -0
- package/dist/Stepper/components/Compose/Compose.d.ts +1 -0
- package/dist/Stepper/components/Step/Step.cjs +2 -0
- package/dist/Stepper/components/Step/Step.d.ts +1 -0
- package/dist/Stepper/components/Step/Step.js +2 -0
- package/dist/Stepper/components/Step/components/Compose/Compose.cjs +5 -10
- package/dist/Stepper/components/Step/components/Compose/Compose.js +5 -10
- package/dist/Stepper/components/Step/components/Separator/Separator.cjs +15 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.d.ts +3 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.js +15 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.style.cjs +24 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.style.d.ts +1 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.style.js +22 -0
- package/dist/Stepper/components/Step/components/Separator/Separator.types.d.ts +5 -0
- package/dist/Stepper/hooks/useStepperInteractive.cjs +12 -4
- package/dist/Stepper/hooks/useStepperInteractive.js +12 -4
- package/dist/Switch/components/Switcher/Switcher.cjs +3 -1
- package/dist/Switch/components/Switcher/Switcher.js +3 -1
- package/dist/Switch/components/Switcher/Switcher.style.cjs +31 -8
- package/dist/Switch/components/Switcher/Switcher.style.js +31 -8
- package/dist/Tabs/components/TabBar/components/Trigger/components/Marker/Marker.style.cjs +24 -5
- package/dist/Tabs/components/TabBar/components/Trigger/components/Marker/Marker.style.js +24 -5
- package/dist/Tabs/components/TabBar/components/Trigger/components/Tab/Tab.style.cjs +24 -5
- package/dist/Tabs/components/TabBar/components/Trigger/components/Tab/Tab.style.js +24 -5
- package/dist/ThemeModeSwitch/useThemeModeSwitch.cjs +6 -2
- package/dist/ThemeModeSwitch/useThemeModeSwitch.js +6 -2
- package/dist/Toast/core/content.helper.cjs +8 -4
- package/dist/Toast/core/content.helper.js +8 -4
- package/dist/Tooltip/components/Content/Content.cjs +3 -1
- package/dist/Tooltip/components/Content/Content.js +3 -1
- package/dist/TreeView/TreeView.cjs +3 -1
- package/dist/TreeView/TreeView.js +3 -1
- package/dist/TreeView/components/TreeItem/components/Compose/Compose.cjs +6 -4
- package/dist/TreeView/components/TreeItem/components/Compose/Compose.js +6 -4
- package/dist/Typography/Typography.types.cjs +4 -0
- package/dist/Typography/Typography.types.d.ts +2 -1
- package/dist/Typography/Typography.types.js +4 -0
- package/dist/index.cjs +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +98 -90
- package/package.json +10 -9
- package/skills/redis-ui-components/SKILL.md +126 -0
- package/skills/redis-ui-components/references/ActionIconButton.md +96 -0
- package/skills/redis-ui-components/references/AppBar.md +161 -0
- package/skills/redis-ui-components/references/AppSelectionMenu.md +184 -0
- package/skills/redis-ui-components/references/AutoCompleteSelect.md +193 -0
- package/skills/redis-ui-components/references/Badge.md +77 -0
- package/skills/redis-ui-components/references/Banner.md +563 -0
- package/skills/redis-ui-components/references/BoxSelectionGroup.md +487 -0
- package/skills/redis-ui-components/references/Breadcrumbs.md +214 -0
- package/skills/redis-ui-components/references/Button.md +169 -0
- package/skills/redis-ui-components/references/ButtonGroup.md +126 -0
- package/skills/redis-ui-components/references/Card.md +56 -0
- package/skills/redis-ui-components/references/Checkbox.md +171 -0
- package/skills/redis-ui-components/references/Chip.md +154 -0
- package/skills/redis-ui-components/references/ChipList.md +307 -0
- package/skills/redis-ui-components/references/CopyToClipboardButton.md +47 -0
- package/skills/redis-ui-components/references/CountryFlag.md +57 -0
- package/skills/redis-ui-components/references/Drawer.md +298 -0
- package/skills/redis-ui-components/references/Filters.md +162 -0
- package/skills/redis-ui-components/references/FlexDivider.md +152 -0
- package/skills/redis-ui-components/references/FlexGroup.md +149 -0
- package/skills/redis-ui-components/references/FlexItem.md +58 -0
- package/skills/redis-ui-components/references/FlexSplit.md +37 -0
- package/skills/redis-ui-components/references/FormField.md +678 -0
- package/skills/redis-ui-components/references/IconButton.md +63 -0
- package/skills/redis-ui-components/references/Input.md +295 -0
- package/skills/redis-ui-components/references/KeyValueList.md +501 -0
- package/skills/redis-ui-components/references/Label.md +238 -0
- package/skills/redis-ui-components/references/Link.md +402 -0
- package/skills/redis-ui-components/references/Loader.md +100 -0
- package/skills/redis-ui-components/references/Menu.md +988 -0
- package/skills/redis-ui-components/references/MidBar.md +358 -0
- package/skills/redis-ui-components/references/Modal.md +525 -0
- package/skills/redis-ui-components/references/MoreInfoIcon.md +119 -0
- package/skills/redis-ui-components/references/MultiSelect.md +558 -0
- package/skills/redis-ui-components/references/NumericInput.md +322 -0
- package/skills/redis-ui-components/references/Overflow.md +127 -0
- package/skills/redis-ui-components/references/Pagination.md +151 -0
- package/skills/redis-ui-components/references/PasswordInput.md +262 -0
- package/skills/redis-ui-components/references/Popover.md +868 -0
- package/skills/redis-ui-components/references/ProfileIcon.md +65 -0
- package/skills/redis-ui-components/references/ProgressBar.md +103 -0
- package/skills/redis-ui-components/references/QuantityCounter.md +555 -0
- package/skills/redis-ui-components/references/RadioGroup.md +265 -0
- package/skills/redis-ui-components/references/ScreenReaderAnnounce.md +147 -0
- package/skills/redis-ui-components/references/SearchBar.md +242 -0
- package/skills/redis-ui-components/references/SearchInput.md +213 -0
- package/skills/redis-ui-components/references/Section.md +349 -0
- package/skills/redis-ui-components/references/Select.md +517 -0
- package/skills/redis-ui-components/references/SideBar.md +468 -0
- package/skills/redis-ui-components/references/Slider.md +398 -0
- package/skills/redis-ui-components/references/Stepper.md +288 -0
- package/skills/redis-ui-components/references/Switch.md +193 -0
- package/skills/redis-ui-components/references/Tabs.md +383 -0
- package/skills/redis-ui-components/references/TextArea.md +139 -0
- package/skills/redis-ui-components/references/TextButton.md +217 -0
- package/skills/redis-ui-components/references/Toast.md +399 -0
- package/skills/redis-ui-components/references/ToggleButton.md +163 -0
- package/skills/redis-ui-components/references/Tooltip.md +636 -0
- package/skills/redis-ui-components/references/Typography.md +323 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# PasswordInput
|
|
2
|
+
|
|
3
|
+
A password input component with exposure toggle, validation states, reset affordance, and compose support for custom layouts.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { PasswordInput } from '@redislabsdev/redis-ui-components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> Some examples also use icons from `@redislabsdev/redis-ui-icons`:
|
|
12
|
+
> ```tsx
|
|
13
|
+
> import { SendIcon } from '@redislabsdev/redis-ui-icons';
|
|
14
|
+
> ```
|
|
15
|
+
|
|
16
|
+
## Props
|
|
17
|
+
|
|
18
|
+
| Prop | Type | Default | Description |
|
|
19
|
+
|------|------|---------|-------------|
|
|
20
|
+
| id | `string` | - | Shared id for the compose wrapper and the inner input. |
|
|
21
|
+
| variant | `'outline' \| 'underline'` | `'outline'` | Visual style for the input wrapper. |
|
|
22
|
+
| error | `ReactElement \| string` | - | Error content. Enables error state and tooltip content. |
|
|
23
|
+
| valid | `boolean` | - | Enables the success state. |
|
|
24
|
+
| readOnly | `boolean` | - | Switches the input into read-only mode. |
|
|
25
|
+
| value | `string` | - | Controlled input value. |
|
|
26
|
+
| defaultValue | `string` | - | Uncontrolled initial value. |
|
|
27
|
+
| onChange | `(value: string) => void` | - | Called when the parsed value changes. |
|
|
28
|
+
| showExposureToggle | `'always' \| 'never' \| 'has-value'` | `'always'` | Controls when the show/hide password button is visible. |
|
|
29
|
+
| exposed | `boolean` | - | Controlled exposure state. |
|
|
30
|
+
| defaultExposed | `boolean` | - | Uncontrolled initial exposure state. |
|
|
31
|
+
| onExposedChange | `(exposed: boolean) => void` | - | Called when the exposure state changes. |
|
|
32
|
+
| allowReset | `boolean` | `false` | Shows the reset button when a value is present. |
|
|
33
|
+
|
|
34
|
+
The component also forwards standard `input` attributes through the underlying password field, excluding `children`, `defaultValue`, `value`, `onChange`, and `readOnly`.
|
|
35
|
+
|
|
36
|
+
## Sub-components
|
|
37
|
+
|
|
38
|
+
- `PasswordInput.Compose` - Compose wrapper that manages value state, validation state, read-only rendering, and exposure state. It uses the shared compose API props for id, variant, value, defaultValue, onChange, showExposureToggle, exposed, defaultExposed, onExposedChange, plus `readonlyRender` and `readonlyProps`.
|
|
39
|
+
- `PasswordInput.Tag` - The underlying password input element. It accepts native `input` props except `type` and `readOnly`, and switches between `password` and `text` based on exposure state.
|
|
40
|
+
- `PasswordInput.StatusIndicator` - Success/error indicator with tooltip support for error content. It uses the shared indicator props plus `className` and `style`.
|
|
41
|
+
- `PasswordInput.PasswordButton` - Show/hide password toggle button. It inherits `IconButton` props except `onClick`, `icon`, and `disabled`.
|
|
42
|
+
- `PasswordInput.ResetButton` - Reset action button used when a value is present. It accepts `allowReset` plus partial `IconButton` props.
|
|
43
|
+
|
|
44
|
+
## Examples
|
|
45
|
+
|
|
46
|
+
### Basic Usage
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
<PasswordInput placeholder="PasswordInput" type="text" id="custom-id" disabled={false} />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Status
|
|
53
|
+
|
|
54
|
+
> Adding `valid` prop enables valid status.
|
|
55
|
+
>
|
|
56
|
+
> Adding some text to the `error` prop of `PasswordInput` enables error status. Hover the error indicator to see the specified text in a tooltip.
|
|
57
|
+
>
|
|
58
|
+
> `error` status overrides `valid` status.
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
<>
|
|
62
|
+
Valid status
|
|
63
|
+
<PasswordInput placeholder="Password Input" valid />
|
|
64
|
+
Error status
|
|
65
|
+
<PasswordInput placeholder="Password Input" error="Error message" />
|
|
66
|
+
</>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### ResetButton
|
|
70
|
+
|
|
71
|
+
> `PasswordInput` allows the user to clear the value. Set `allowReset` to show the reset button.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<PasswordInput placeholder="Password Input" defaultValue="orange" allowReset />
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### ExposureButtonControl
|
|
78
|
+
|
|
79
|
+
> Visibility of the exposure (show password) button and exposure state can be controlled.
|
|
80
|
+
>
|
|
81
|
+
> The button can be always visible, always hidden, or visible only when the input has a value.
|
|
82
|
+
> Set `showExposureToggle` to `always`, `never`, or `has-value`.
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { useState } from 'react';
|
|
86
|
+
import { FormField, PasswordInput, Typography } from '@redislabsdev/redis-ui-components';
|
|
87
|
+
|
|
88
|
+
function Render() {
|
|
89
|
+
const [exposed, setExposed] = useState(false);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<>
|
|
93
|
+
<Typography.Heading size="M">Controlled exposure state, various "Exposure" button visibility</Typography.Heading>
|
|
94
|
+
<FormField label="Button is always visible (default)">
|
|
95
|
+
<PasswordInput defaultValue="password" exposed={exposed} onExposedChange={setExposed} />
|
|
96
|
+
</FormField>
|
|
97
|
+
<FormField label="Button is always hidden">
|
|
98
|
+
<PasswordInput
|
|
99
|
+
showExposureToggle="never"
|
|
100
|
+
defaultValue="password"
|
|
101
|
+
exposed={exposed}
|
|
102
|
+
onExposedChange={setExposed}
|
|
103
|
+
/>
|
|
104
|
+
</FormField>
|
|
105
|
+
<FormField label="Button is visible if input has value">
|
|
106
|
+
<PasswordInput
|
|
107
|
+
allowReset
|
|
108
|
+
showExposureToggle="has-value"
|
|
109
|
+
defaultValue="password"
|
|
110
|
+
exposed={exposed}
|
|
111
|
+
onExposedChange={setExposed}
|
|
112
|
+
/>
|
|
113
|
+
</FormField>
|
|
114
|
+
<Typography.Heading size="M">Uncontrolled exposure state</Typography.Heading>
|
|
115
|
+
<FormField label="Initially covert (default)">
|
|
116
|
+
<PasswordInput defaultValue="password" />
|
|
117
|
+
</FormField>
|
|
118
|
+
<FormField label="Initially exposed">
|
|
119
|
+
<PasswordInput defaultValue="password" defaultExposed />
|
|
120
|
+
</FormField>
|
|
121
|
+
</>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### DisabledAndReadonly
|
|
127
|
+
|
|
128
|
+
> Adding `disabled` or `readOnly` switches the component to the corresponding state.
|
|
129
|
+
>
|
|
130
|
+
> In read-only mode only the value is visible. Other indicators are ignored.
|
|
131
|
+
>
|
|
132
|
+
> `readOnly` overrides `disabled`.
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
<>
|
|
136
|
+
Disabled
|
|
137
|
+
<PasswordInput disabled />
|
|
138
|
+
Disabled with value
|
|
139
|
+
<PasswordInput disabled defaultValue="orange" />
|
|
140
|
+
Disabled with indicators
|
|
141
|
+
<PasswordInput disabled defaultValue="banana" error="Error message" allowReset />
|
|
142
|
+
Read only
|
|
143
|
+
<PasswordInput value="read-only input value" readOnly />
|
|
144
|
+
</>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### WithLabel
|
|
148
|
+
|
|
149
|
+
> `PasswordInput` does not have its own label or other external decoration elements.
|
|
150
|
+
>
|
|
151
|
+
> Use `FormField` for those cases. If a custom id is specified, `FormField` inherits it;
|
|
152
|
+
> otherwise the label is connected automatically via a generated id.
|
|
153
|
+
>
|
|
154
|
+
> Custom ids must start with a letter to work correctly.
|
|
155
|
+
>
|
|
156
|
+
> `FormField` also inherits status and some states from the input.
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
<>
|
|
160
|
+
<FormField label="FormField Label with custom id">
|
|
161
|
+
<PasswordInput placeholder="Password Input" id="custom-id" />
|
|
162
|
+
</FormField>
|
|
163
|
+
<FormField
|
|
164
|
+
label="FormField Label with auto-generated id"
|
|
165
|
+
additionalText="FormField additional text"
|
|
166
|
+
>
|
|
167
|
+
<PasswordInput placeholder="Password Input" />
|
|
168
|
+
</FormField>
|
|
169
|
+
<FormField
|
|
170
|
+
label="FormField Label with read-only mode"
|
|
171
|
+
additionalText="FormField additional text"
|
|
172
|
+
>
|
|
173
|
+
<PasswordInput value="read-only input value" readOnly />
|
|
174
|
+
</FormField>
|
|
175
|
+
</>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Variants
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
<>
|
|
182
|
+
<FormField label="Outline (default)" additionalText="outline">
|
|
183
|
+
<PasswordInput placeholder="Password Input" />
|
|
184
|
+
</FormField>
|
|
185
|
+
<FormField label="Underline" additionalText="underline">
|
|
186
|
+
<PasswordInput placeholder="Password Input" variant="underline" />
|
|
187
|
+
</FormField>
|
|
188
|
+
</>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### ComposeTokenInput
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import { useState } from 'react';
|
|
195
|
+
import {
|
|
196
|
+
ActionIconButton,
|
|
197
|
+
FormField,
|
|
198
|
+
PasswordInput,
|
|
199
|
+
Tooltip,
|
|
200
|
+
Typography
|
|
201
|
+
} from '@redislabsdev/redis-ui-components';
|
|
202
|
+
import { SendIcon } from '@redislabsdev/redis-ui-icons';
|
|
203
|
+
|
|
204
|
+
function Render() {
|
|
205
|
+
const [token, setToken] = useState('');
|
|
206
|
+
const [error, setError] = useState('');
|
|
207
|
+
|
|
208
|
+
const sendToken = () => {
|
|
209
|
+
if (!token.match(/^[a-z0-9]{10}$/)) {
|
|
210
|
+
setError('token must contain letters (a-z) or digits and be 10 symbols long');
|
|
211
|
+
} else {
|
|
212
|
+
// eslint-disable-next-line no-alert
|
|
213
|
+
alert('Token has been sent');
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
218
|
+
if (token && e.key.toLowerCase() === 'enter') {
|
|
219
|
+
sendToken();
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
return (
|
|
224
|
+
<FormField
|
|
225
|
+
required
|
|
226
|
+
label="Token"
|
|
227
|
+
additionalText="Enter symbols and press Enter or click Send button"
|
|
228
|
+
>
|
|
229
|
+
<PasswordInput.Compose
|
|
230
|
+
id="token_input"
|
|
231
|
+
value={token}
|
|
232
|
+
onChange={(newValue) => {
|
|
233
|
+
setToken(newValue.replace(/\s/g, ''));
|
|
234
|
+
setError('');
|
|
235
|
+
}}
|
|
236
|
+
error={error}
|
|
237
|
+
>
|
|
238
|
+
<PasswordInput.Tag onKeyDown={onKeyDown} placeholder="Enter Token" autoComplete="off" />
|
|
239
|
+
<PasswordInput.StatusIndicator />
|
|
240
|
+
<Tooltip disabled={!!token} content="Token is mandatory">
|
|
241
|
+
<ActionIconButton
|
|
242
|
+
size="M"
|
|
243
|
+
disabled={!token || !!error}
|
|
244
|
+
icon={SendIcon}
|
|
245
|
+
variant="secondary"
|
|
246
|
+
onClick={sendToken}
|
|
247
|
+
/>
|
|
248
|
+
</Tooltip>
|
|
249
|
+
</PasswordInput.Compose>
|
|
250
|
+
</FormField>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Notes
|
|
256
|
+
|
|
257
|
+
- `error` status overrides `valid`.
|
|
258
|
+
- `showExposureToggle` accepts `always`, `never`, and `has-value`.
|
|
259
|
+
- `allowReset` shows the reset button when a value is present.
|
|
260
|
+
- `readOnly` overrides `disabled`, and read-only mode hides the extra indicators.
|
|
261
|
+
- Custom ids used with `FormField` must start with a letter.
|
|
262
|
+
- Exposure state controls whether the field renders as `password` or `text`.
|