@cdx-ui/components 0.2.3 → 0.2.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/AGENTS.md +24 -0
- package/README.md +2 -0
- package/coverage.svg +1 -1
- package/docs/components/accordion/content.md +538 -0
- package/docs/components/alert/content.md +203 -0
- package/docs/components/alert-dialog/content.md +319 -0
- package/docs/components/avatar/content.md +368 -0
- package/docs/components/avatar/design.md +202 -0
- package/docs/components/badge/content.md +225 -0
- package/docs/components/bottom-sheet/content.md +353 -0
- package/docs/components/bottom-sheet/design.md +249 -0
- package/docs/components/box/content.md +141 -0
- package/docs/components/breadcrumbs/content.md +169 -0
- package/docs/components/button/content.md +398 -0
- package/docs/components/button/design.md +258 -0
- package/docs/components/calendar/content.md +137 -0
- package/docs/components/card/content.md +283 -0
- package/docs/components/carousel/content.md +417 -0
- package/docs/components/checkbox/content.md +236 -0
- package/docs/components/checkbox/design.md +214 -0
- package/docs/components/chip/content.md +439 -0
- package/docs/components/chip/design.md +418 -0
- package/docs/components/color-area/content.md +84 -0
- package/docs/components/color-field/content.md +132 -0
- package/docs/components/color-picker/content.md +209 -0
- package/docs/components/color-slider/content.md +118 -0
- package/docs/components/color-swatch/content.md +62 -0
- package/docs/components/color-swatch-picker/content.md +124 -0
- package/docs/components/content.md +98 -0
- package/docs/components/currency-input/content.md +205 -0
- package/docs/components/data-grid/content.md +521 -0
- package/docs/components/date-field/content.md +147 -0
- package/docs/components/date-picker/content.md +360 -0
- package/docs/components/date-range-picker/content.md +301 -0
- package/docs/components/date-time-field/content.md +157 -0
- package/docs/components/date-time-list/content.md +105 -0
- package/docs/components/date-time-picker/content.md +272 -0
- package/docs/components/dialog/content.md +436 -0
- package/docs/components/dialog/design.md +192 -0
- package/docs/components/divider/content.md +112 -0
- package/docs/components/drawer/content.md +428 -0
- package/docs/components/field/content.md +277 -0
- package/docs/components/form/content.md +62 -0
- package/docs/components/full-screen-dialog/content.md +881 -0
- package/docs/components/heading/content.md +55 -0
- package/docs/components/icon/content.md +190 -0
- package/docs/components/icon-button/content.md +200 -0
- package/docs/components/icon-button/design.md +165 -0
- package/docs/components/image/content.md +104 -0
- package/docs/components/input/content.md +346 -0
- package/docs/components/input/design.md +389 -0
- package/docs/components/insurance-disclosure/content.md +103 -0
- package/docs/components/link/content.md +180 -0
- package/docs/components/link/design.md +160 -0
- package/docs/components/list-item/content.md +695 -0
- package/docs/components/menu/content.md +1254 -0
- package/docs/components/month-calendar/content.md +84 -0
- package/docs/components/month-picker/content.md +273 -0
- package/docs/components/otp-input/content.md +327 -0
- package/docs/components/progress-bar/content.md +87 -0
- package/docs/components/progress-circle/content.md +176 -0
- package/docs/components/progress-segmented/content.md +119 -0
- package/docs/components/quick-action-button/content.md +154 -0
- package/docs/components/quick-action-button/design.md +170 -0
- package/docs/components/radio/content.md +224 -0
- package/docs/components/range-calendar/content.md +123 -0
- package/docs/components/reorderable-list/content.md +311 -0
- package/docs/components/scoped-theme/content.md +47 -0
- package/docs/components/scroll-shadow/content.md +693 -0
- package/docs/components/select/content.md +473 -0
- package/docs/components/select/design.md +301 -0
- package/docs/components/skeleton/content.md +104 -0
- package/docs/components/slider/content.md +423 -0
- package/docs/components/stack/content.md +161 -0
- package/docs/components/switch/content.md +150 -0
- package/docs/components/switch/design.md +208 -0
- package/docs/components/table/content.md +548 -0
- package/docs/components/table-pagination/content.md +177 -0
- package/docs/components/tabs/content.md +297 -0
- package/docs/components/text/content.md +142 -0
- package/docs/components/textarea/content.md +222 -0
- package/docs/components/tile/content.md +702 -0
- package/docs/components/toast/content.md +456 -0
- package/docs/components/toggle-button/content.md +505 -0
- package/docs/components/tooltip/content.md +350 -0
- package/docs/components/virtualized-list/content.md +250 -0
- package/docs/foundations/content.md +9 -0
- package/docs/foundations/expressions/icons/content.md +19 -0
- package/docs/foundations/styles/tokens/all-tokens/content.md +192 -0
- package/docs/foundations/styles/tokens/what-are-tokens/content.md +33 -0
- package/docs/foundations/styles/tokens/what-are-tokens/design.md +33 -0
- package/docs/getting-started/content.md +4 -0
- package/docs/getting-started/designers/content.md +13 -0
- package/docs/getting-started/designers/design.md +13 -0
- package/docs/getting-started/developers/accessibility/content.md +31 -0
- package/docs/getting-started/developers/content.md +612 -0
- package/docs/getting-started/developers/styling/content.md +195 -0
- package/docs/llms.txt +195 -0
- package/docs/patterns/account-management/content.md +75 -0
- package/docs/patterns/authentication/content.md +50 -0
- package/docs/patterns/content.md +10 -0
- package/docs/patterns/dashboard/content.md +34 -0
- package/docs/patterns/empty-states/content.md +32 -0
- package/docs/patterns/forms/content.md +108 -0
- package/docs/patterns/onboarding/content.md +69 -0
- package/docs/patterns/payments/content.md +35 -0
- package/docs/patterns/settings/content.md +72 -0
- package/docs/resources/content.md +9 -0
- package/docs/resources/figma-libraries/content.md +42 -0
- package/docs/resources/release-notes/0.0.1-beta.118/content.md +27 -0
- package/docs/resources/release-notes/0.0.1-beta.122/content.md +21 -0
- package/docs/resources/release-notes/0.0.1-beta.124/content.md +16 -0
- package/docs/resources/release-notes/0.0.1-beta.126/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.127/content.md +14 -0
- package/docs/resources/release-notes/0.0.1-beta.128/content.md +9 -0
- package/docs/resources/release-notes/0.0.1-beta.129/content.md +18 -0
- package/docs/resources/release-notes/0.0.1-beta.130/content.md +18 -0
- package/docs/resources/release-notes/0.0.1-beta.133/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.134/content.md +17 -0
- package/docs/resources/release-notes/0.0.1-beta.136/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.137/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.138/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.139/content.md +13 -0
- package/docs/resources/release-notes/0.0.1-beta.140/content.md +26 -0
- package/docs/resources/release-notes/0.0.1-beta.141/content.md +63 -0
- package/docs/resources/release-notes/0.0.1-beta.142/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.143/content.md +12 -0
- package/docs/resources/release-notes/0.0.1-beta.144/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.145/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.147/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.149/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.150/content.md +13 -0
- package/docs/resources/release-notes/0.0.1-beta.152/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.154/content.md +15 -0
- package/docs/resources/release-notes/0.0.1-beta.156/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.158/content.md +9 -0
- package/docs/resources/release-notes/0.0.1-beta.159/content.md +11 -0
- package/docs/resources/release-notes/0.0.1-beta.160/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.161/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.163/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.164/content.md +9 -0
- package/docs/resources/release-notes/0.0.1-beta.166/content.md +17 -0
- package/docs/resources/release-notes/0.0.1-beta.167/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.168/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.169/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.171/content.md +16 -0
- package/docs/resources/release-notes/0.0.1-beta.172/content.md +24 -0
- package/docs/resources/release-notes/0.0.1-beta.173/content.md +15 -0
- package/docs/resources/release-notes/0.0.1-beta.174/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.176/content.md +32 -0
- package/docs/resources/release-notes/0.0.1-beta.179/content.md +11 -0
- package/docs/resources/release-notes/0.0.1-beta.182/content.md +13 -0
- package/docs/resources/release-notes/0.0.1-beta.185/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.187/content.md +27 -0
- package/docs/resources/release-notes/0.1.1/content.md +23 -0
- package/docs/resources/release-notes/0.1.2/content.md +7 -0
- package/docs/resources/release-notes/0.1.4/content.md +19 -0
- package/docs/resources/release-notes/0.1.5/content.md +7 -0
- package/docs/resources/release-notes/0.1.6/content.md +7 -0
- package/docs/resources/release-notes/0.2.0/content.md +31 -0
- package/docs/resources/release-notes/0.2.1/content.md +17 -0
- package/docs/resources/release-notes/0.2.2/content.md +11 -0
- package/docs/resources/release-notes/0.2.3/content.md +15 -0
- package/docs/resources/release-notes/0.2.4/content.md +17 -0
- package/docs/resources/release-notes/content.md +65 -0
- package/lib/commonjs/components/Box/Box.js +9 -1
- package/lib/commonjs/components/Box/Box.js.map +1 -1
- package/lib/commonjs/components/Breadcrumbs/index.js +28 -3
- package/lib/commonjs/components/Breadcrumbs/index.js.map +1 -1
- package/lib/commonjs/components/Breadcrumbs/styles.js +27 -0
- package/lib/commonjs/components/Breadcrumbs/styles.js.map +1 -1
- package/lib/commonjs/components/DateTimeList/index.js +11 -26
- package/lib/commonjs/components/DateTimeList/index.js.map +1 -1
- package/lib/commonjs/components/DateTimeList/styles.js +2 -12
- package/lib/commonjs/components/DateTimeList/styles.js.map +1 -1
- package/lib/commonjs/components/ListItem/index.js.map +1 -1
- package/lib/commonjs/components/ListItem/styles.js +2 -1
- package/lib/commonjs/components/ListItem/styles.js.map +1 -1
- package/lib/commonjs/components/Menu/index.js +11 -5
- package/lib/commonjs/components/Menu/index.js.map +1 -1
- package/lib/commonjs/components/ScrollShadow/gradient.js +29 -0
- package/lib/commonjs/components/ScrollShadow/gradient.js.map +1 -0
- package/lib/commonjs/components/ScrollShadow/index.js +171 -44
- package/lib/commonjs/components/ScrollShadow/index.js.map +1 -1
- package/lib/commonjs/components/ScrollShadow/styles.js +58 -14
- package/lib/commonjs/components/ScrollShadow/styles.js.map +1 -1
- package/lib/commonjs/components/ScrollShadow/useComposedScrollHandler.js +63 -0
- package/lib/commonjs/components/ScrollShadow/useComposedScrollHandler.js.map +1 -0
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js +48 -8
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/commonjs/components/Stack/HStack.js +6 -2
- package/lib/commonjs/components/Stack/HStack.js.map +1 -1
- package/lib/commonjs/components/Stack/VStack.js +6 -2
- package/lib/commonjs/components/Stack/VStack.js.map +1 -1
- package/lib/commonjs/components/Tabs/index.js +16 -23
- package/lib/commonjs/components/Tabs/index.js.map +1 -1
- package/lib/commonjs/components/Tabs/styles.js +1 -10
- package/lib/commonjs/components/Tabs/styles.js.map +1 -1
- package/lib/commonjs/figma/ListItem.SectionHeader.figma.js +20 -5
- package/lib/commonjs/figma/ListItem.SectionHeader.figma.js.map +1 -1
- package/lib/commonjs/index.js +10 -10
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/components/Box/Box.js +9 -1
- package/lib/module/components/Box/Box.js.map +1 -1
- package/lib/module/components/Breadcrumbs/index.js +29 -4
- package/lib/module/components/Breadcrumbs/index.js.map +1 -1
- package/lib/module/components/Breadcrumbs/styles.js +26 -0
- package/lib/module/components/Breadcrumbs/styles.js.map +1 -1
- package/lib/module/components/DateTimeList/index.js +12 -27
- package/lib/module/components/DateTimeList/index.js.map +1 -1
- package/lib/module/components/DateTimeList/styles.js +1 -11
- package/lib/module/components/DateTimeList/styles.js.map +1 -1
- package/lib/module/components/ListItem/index.js.map +1 -1
- package/lib/module/components/ListItem/styles.js +2 -1
- package/lib/module/components/ListItem/styles.js.map +1 -1
- package/lib/module/components/Menu/index.js +11 -5
- package/lib/module/components/Menu/index.js.map +1 -1
- package/lib/module/components/ScrollShadow/gradient.js +24 -0
- package/lib/module/components/ScrollShadow/gradient.js.map +1 -0
- package/lib/module/components/ScrollShadow/index.js +170 -48
- package/lib/module/components/ScrollShadow/index.js.map +1 -1
- package/lib/module/components/ScrollShadow/styles.js +57 -13
- package/lib/module/components/ScrollShadow/styles.js.map +1 -1
- package/lib/module/components/ScrollShadow/useComposedScrollHandler.js +57 -0
- package/lib/module/components/ScrollShadow/useComposedScrollHandler.js.map +1 -0
- package/lib/module/components/ScrollShadow/useScrollShadow.js +46 -8
- package/lib/module/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/module/components/Stack/HStack.js +6 -2
- package/lib/module/components/Stack/HStack.js.map +1 -1
- package/lib/module/components/Stack/VStack.js +6 -2
- package/lib/module/components/Stack/VStack.js.map +1 -1
- package/lib/module/components/Tabs/index.js +17 -24
- package/lib/module/components/Tabs/index.js.map +1 -1
- package/lib/module/components/Tabs/styles.js +0 -9
- package/lib/module/components/Tabs/styles.js.map +1 -1
- package/lib/module/figma/ListItem.SectionHeader.figma.js +20 -5
- package/lib/module/figma/ListItem.SectionHeader.figma.js.map +1 -1
- package/lib/module/index.js +6 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/animation/hooks/usePopupDialogContentAnimation.d.ts +2 -2
- package/lib/typescript/animation/hooks/usePopupOverlayAnimation.d.ts +2 -2
- package/lib/typescript/components/Box/Box.d.ts +4 -0
- package/lib/typescript/components/Box/Box.d.ts.map +1 -1
- package/lib/typescript/components/Breadcrumbs/index.d.ts +3 -1
- package/lib/typescript/components/Breadcrumbs/index.d.ts.map +1 -1
- package/lib/typescript/components/Breadcrumbs/styles.d.ts +2 -0
- package/lib/typescript/components/Breadcrumbs/styles.d.ts.map +1 -1
- package/lib/typescript/components/DateTimeList/index.d.ts.map +1 -1
- package/lib/typescript/components/DateTimeList/styles.d.ts +1 -4
- package/lib/typescript/components/DateTimeList/styles.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/index.d.ts +5 -4
- package/lib/typescript/components/ListItem/index.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/styles.d.ts +1 -1
- package/lib/typescript/components/ListItem/styles.d.ts.map +1 -1
- package/lib/typescript/components/Menu/index.d.ts.map +1 -1
- package/lib/typescript/components/ScrollShadow/gradient.d.ts +7 -0
- package/lib/typescript/components/ScrollShadow/gradient.d.ts.map +1 -0
- package/lib/typescript/components/ScrollShadow/index.d.ts +57 -15
- package/lib/typescript/components/ScrollShadow/index.d.ts.map +1 -1
- package/lib/typescript/components/ScrollShadow/styles.d.ts +8 -2
- package/lib/typescript/components/ScrollShadow/styles.d.ts.map +1 -1
- package/lib/typescript/components/ScrollShadow/useComposedScrollHandler.d.ts +13 -0
- package/lib/typescript/components/ScrollShadow/useComposedScrollHandler.d.ts.map +1 -0
- package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts +15 -2
- package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts.map +1 -1
- package/lib/typescript/components/Stack/HStack.d.ts +3 -2
- package/lib/typescript/components/Stack/HStack.d.ts.map +1 -1
- package/lib/typescript/components/Stack/VStack.d.ts +3 -2
- package/lib/typescript/components/Stack/VStack.d.ts.map +1 -1
- package/lib/typescript/components/Tabs/index.d.ts.map +1 -1
- package/lib/typescript/components/Tabs/styles.d.ts +0 -7
- package/lib/typescript/components/Tabs/styles.d.ts.map +1 -1
- package/lib/typescript/components/Toast/animation.d.ts +3 -3
- package/lib/typescript/components/Toast/animation.d.ts.map +1 -1
- package/lib/typescript/figma/ListItem.SectionHeader.figma.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +6 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +11 -9
- package/src/components/Box/Box.tsx +18 -4
- package/src/components/Breadcrumbs/index.tsx +28 -4
- package/src/components/Breadcrumbs/styles.ts +30 -0
- package/src/components/DateTimeList/index.tsx +13 -26
- package/src/components/DateTimeList/styles.ts +1 -10
- package/src/components/ListItem/index.tsx +5 -4
- package/src/components/ListItem/styles.ts +1 -0
- package/src/components/Menu/index.tsx +11 -8
- package/src/components/ScrollShadow/gradient.ts +48 -0
- package/src/components/ScrollShadow/index.tsx +300 -69
- package/src/components/ScrollShadow/styles.ts +45 -28
- package/src/components/ScrollShadow/useComposedScrollHandler.ts +58 -0
- package/src/components/ScrollShadow/useScrollShadow.ts +72 -10
- package/src/components/Stack/HStack.tsx +8 -4
- package/src/components/Stack/VStack.tsx +8 -4
- package/src/components/Tabs/index.tsx +25 -35
- package/src/components/Tabs/styles.ts +0 -9
- package/src/index.ts +8 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Image (https://design.candescent.com/docs/components/image)
|
|
2
|
+
|
|
3
|
+
Resources: [Figma](https://www.figma.com/design/0lEVMVlLj8ZS4fgItr3pmd/%E2%AD%90-Forge-DS--Components?node-id=9091-16186), [Storybook](https://victorious-wave-0daadf00f.6.azurestaticapps.net/?path=/story/content-image--default)
|
|
4
|
+
|
|
5
|
+
A thin wrapper around React Native's `Image` that accepts a URI string as `source` and adds web-oriented image attributes without imposing loading or error UI.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Image } from '@cdx-ui/components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic
|
|
12
|
+
|
|
13
|
+
Pass a URI string directly to `source`. It is normalized to React Native's `{ uri }` format.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Image } from '@cdx-ui/components';
|
|
17
|
+
|
|
18
|
+
export default function ImageBasicDemo() {
|
|
19
|
+
// Interim: Image has no radius or shape prop yet, so the corner radius is a class.
|
|
20
|
+
return (
|
|
21
|
+
<Image
|
|
22
|
+
source="/candescent/intelligent-banking.jpg"
|
|
23
|
+
alt="A person using digital banking on a mobile phone"
|
|
24
|
+
className="h-48 w-72 rounded-xl"
|
|
25
|
+
resizeMode="cover"
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Resize modes
|
|
32
|
+
|
|
33
|
+
Use `resizeMode` to control how an image fits its dimensions.
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { HStack, Image, Text, VStack } from '@cdx-ui/components';
|
|
37
|
+
|
|
38
|
+
const resizeModes = ['cover', 'contain', 'stretch', 'center'] as const;
|
|
39
|
+
|
|
40
|
+
export default function ImageResizeModesDemo() {
|
|
41
|
+
return (
|
|
42
|
+
<HStack space="lg" className="flex-wrap justify-center">
|
|
43
|
+
{resizeModes.map((resizeMode) => (
|
|
44
|
+
<VStack key={resizeMode} space="xs" className="items-center">
|
|
45
|
+
<Image
|
|
46
|
+
source="/candescent/intelligent-banking.jpg"
|
|
47
|
+
alt=""
|
|
48
|
+
resizeMode={resizeMode}
|
|
49
|
+
className="h-24 w-36 rounded-lg bg-surface-secondary"
|
|
50
|
+
/>
|
|
51
|
+
<Text size="sm" color="secondary">
|
|
52
|
+
{resizeMode}
|
|
53
|
+
</Text>
|
|
54
|
+
</VStack>
|
|
55
|
+
))}
|
|
56
|
+
</HStack>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Web attributes
|
|
62
|
+
|
|
63
|
+
On web, use `loading`, `decoding`, `draggable`, and responsive image attributes such as `sizes` and `srcSet`. Native platforms ignore these web-only hints.
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import { Image } from '@cdx-ui/components';
|
|
67
|
+
|
|
68
|
+
export default function ImageWebAttributesDemo() {
|
|
69
|
+
// Interim: Image has no radius or shape prop yet, so the corner radius is a class.
|
|
70
|
+
return (
|
|
71
|
+
<Image
|
|
72
|
+
source="/candescent/intelligent-banking.jpg"
|
|
73
|
+
alt="A person using digital banking on a mobile phone"
|
|
74
|
+
srcSet="/candescent/intelligent-banking.jpg 1x"
|
|
75
|
+
sizes="(max-width: 640px) 100vw, 288px"
|
|
76
|
+
loading="lazy"
|
|
77
|
+
decoding="async"
|
|
78
|
+
draggable={false}
|
|
79
|
+
className="h-48 w-72 rounded-xl"
|
|
80
|
+
resizeMode="cover"
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
For avatars with initials or icon fallbacks, use the [Avatar](https://design.candescent.com/docs/components/avatar/content.md) component.
|
|
87
|
+
|
|
88
|
+
## API
|
|
89
|
+
|
|
90
|
+
### Image
|
|
91
|
+
|
|
92
|
+
| Prop | Type | Default | Description |
|
|
93
|
+
| --- | --- | --- | --- |
|
|
94
|
+
| `className?` | `string` | — | — |
|
|
95
|
+
| `source` | `string \| ImageSourcePropType` | — | URI string (normalized to `{ uri }`) or standard `ImageSourcePropType`. |
|
|
96
|
+
| `sizes?` | `string` | — | DOM `sizes` for responsive selection with `srcSet` — web only. |
|
|
97
|
+
| `loading?` | `'lazy' \| 'eager'` | — | DOM lazy-loading hint — web only. |
|
|
98
|
+
| `decoding?` | `'async' \| 'auto' \| 'sync'` | — | DOM decode hint — web only. |
|
|
99
|
+
| `draggable?` | `boolean` | — | DOM drag behavior — web only. |
|
|
100
|
+
| `tabIndex?` | `number` | — | DOM focus order — web only. |
|
|
101
|
+
|
|
102
|
+
Inherits all [`ImageProps`](https://reactnative.dev/docs/image#props). `source` accepts either a URI string or a standard React Native `ImageSourcePropType`, including bundled assets.
|
|
103
|
+
|
|
104
|
+
Web-only props are forwarded to the underlying DOM image where supported by React Native Web and have no effect on iOS or Android.
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# Input Field (https://design.candescent.com/docs/components/input)
|
|
2
|
+
|
|
3
|
+
Resources: [Figma](https://www.figma.com/design/0lEVMVlLj8ZS4fgItr3pmd/%E2%AD%90-CDS-V2--React-Native?node-id=159-22), [Storybook](https://victorious-wave-0daadf00f.6.azurestaticapps.net/?path=/story/inputs-input--default)
|
|
4
|
+
|
|
5
|
+
A compound component with sub-components for the editable field, slots, and icons.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Input } from '@cdx-ui/components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Input } from '@cdx-ui/components';
|
|
15
|
+
|
|
16
|
+
export default function InputBasicDemo() {
|
|
17
|
+
return (
|
|
18
|
+
<Input>
|
|
19
|
+
<Input.Field accessibilityLabel="Name" placeholder="Enter your name" />
|
|
20
|
+
</Input>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Sizes
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { Box, Input, Text, type InputProps } from '@cdx-ui/components';
|
|
29
|
+
|
|
30
|
+
const sizes = ['default', 'small'] as const satisfies readonly NonNullable<InputProps['size']>[];
|
|
31
|
+
|
|
32
|
+
export default function InputSizesDemo() {
|
|
33
|
+
return (
|
|
34
|
+
<Box className="w-full gap-4">
|
|
35
|
+
{sizes.map((size) => (
|
|
36
|
+
<Box key={size} className="gap-2">
|
|
37
|
+
<Text size="sm" color="secondary">
|
|
38
|
+
{size}
|
|
39
|
+
</Text>
|
|
40
|
+
<Input size={size}>
|
|
41
|
+
<Input.Field accessibilityLabel={`${size} input`} placeholder={`${size} input`} />
|
|
42
|
+
</Input>
|
|
43
|
+
</Box>
|
|
44
|
+
))}
|
|
45
|
+
</Box>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## With icons
|
|
51
|
+
|
|
52
|
+
Use `Input.Slot` and `Input.Icon` to add leading or trailing adornments.
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { Input } from '@cdx-ui/components';
|
|
56
|
+
import { Search } from '@cdx-ui/icons';
|
|
57
|
+
|
|
58
|
+
export default function InputWithIconsDemo() {
|
|
59
|
+
return (
|
|
60
|
+
<Input>
|
|
61
|
+
<Input.Slot>
|
|
62
|
+
<Input.Icon as={Search} />
|
|
63
|
+
</Input.Slot>
|
|
64
|
+
<Input.Field accessibilityLabel="Search transactions" placeholder="Search transactions" />
|
|
65
|
+
</Input>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Password
|
|
71
|
+
|
|
72
|
+
Place an interactive visibility toggle inside `Input.Slot`.
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import { useState } from 'react';
|
|
76
|
+
import { IconButton, Input } from '@cdx-ui/components';
|
|
77
|
+
import { Visibility, VisibilityOff } from '@cdx-ui/icons';
|
|
78
|
+
|
|
79
|
+
export default function InputPasswordDemo() {
|
|
80
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Input>
|
|
84
|
+
<Input.Field
|
|
85
|
+
accessibilityLabel="Password"
|
|
86
|
+
placeholder="Enter your password"
|
|
87
|
+
type={isVisible ? 'text' : 'password'}
|
|
88
|
+
secureTextEntry={!isVisible}
|
|
89
|
+
/>
|
|
90
|
+
<Input.Slot>
|
|
91
|
+
<IconButton
|
|
92
|
+
as={isVisible ? VisibilityOff : Visibility}
|
|
93
|
+
variant="ghost"
|
|
94
|
+
size="small"
|
|
95
|
+
accessibilityLabel={isVisible ? 'Hide password' : 'Show password'}
|
|
96
|
+
onPress={() => setIsVisible((visible) => !visible)}
|
|
97
|
+
/>
|
|
98
|
+
</Input.Slot>
|
|
99
|
+
</Input>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Character count
|
|
105
|
+
|
|
106
|
+
Derive the count from the field value and render it as adornment text in a trailing `Input.Slot` — a raw count, or the count alongside a limit.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { useState } from 'react';
|
|
110
|
+
import { Box, Input, Text } from '@cdx-ui/components';
|
|
111
|
+
|
|
112
|
+
const MEMO_LIMIT = 40;
|
|
113
|
+
|
|
114
|
+
export default function InputCharacterCountDemo() {
|
|
115
|
+
const [nickname, setNickname] = useState('Checking');
|
|
116
|
+
const [memo, setMemo] = useState('Rent for October');
|
|
117
|
+
const nicknameCount = String(nickname.length);
|
|
118
|
+
const memoLength = String(memo.length);
|
|
119
|
+
const memoLimit = String(MEMO_LIMIT);
|
|
120
|
+
const memoCount = `${memoLength}/${memoLimit}`;
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<Box className="w-full gap-4">
|
|
124
|
+
<Box className="gap-2">
|
|
125
|
+
<Text size="sm" color="secondary">
|
|
126
|
+
Count
|
|
127
|
+
</Text>
|
|
128
|
+
<Input>
|
|
129
|
+
<Input.Field
|
|
130
|
+
accessibilityLabel="Account nickname"
|
|
131
|
+
value={nickname}
|
|
132
|
+
onChangeText={setNickname}
|
|
133
|
+
/>
|
|
134
|
+
<Input.Slot>
|
|
135
|
+
<Text
|
|
136
|
+
size="sm"
|
|
137
|
+
color="tertiary"
|
|
138
|
+
className="tabular-nums"
|
|
139
|
+
accessibilityLabel={`${nicknameCount} characters`}
|
|
140
|
+
>
|
|
141
|
+
{nicknameCount}
|
|
142
|
+
</Text>
|
|
143
|
+
</Input.Slot>
|
|
144
|
+
</Input>
|
|
145
|
+
</Box>
|
|
146
|
+
<Box className="gap-2">
|
|
147
|
+
<Text size="sm" color="secondary">
|
|
148
|
+
Count and limit
|
|
149
|
+
</Text>
|
|
150
|
+
<Input>
|
|
151
|
+
<Input.Field accessibilityLabel="Transfer memo" value={memo} onChangeText={setMemo} />
|
|
152
|
+
<Input.Slot>
|
|
153
|
+
<Text
|
|
154
|
+
size="sm"
|
|
155
|
+
color="tertiary"
|
|
156
|
+
className="tabular-nums"
|
|
157
|
+
accessibilityLabel={`${memoLength} of ${memoLimit} characters`}
|
|
158
|
+
>
|
|
159
|
+
{memoCount}
|
|
160
|
+
</Text>
|
|
161
|
+
</Input.Slot>
|
|
162
|
+
</Input>
|
|
163
|
+
</Box>
|
|
164
|
+
</Box>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## States
|
|
170
|
+
|
|
171
|
+
The root controls disabled, read-only, required, and invalid state for the field.
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
import { Box, Input, Text } from '@cdx-ui/components';
|
|
175
|
+
|
|
176
|
+
export default function InputStatesDemo() {
|
|
177
|
+
return (
|
|
178
|
+
<Box className="w-full gap-4">
|
|
179
|
+
<Box className="gap-2">
|
|
180
|
+
<Text size="sm" color="secondary">
|
|
181
|
+
Disabled
|
|
182
|
+
</Text>
|
|
183
|
+
<Input isDisabled>
|
|
184
|
+
<Input.Field accessibilityLabel="Disabled input" defaultValue="Account number" />
|
|
185
|
+
</Input>
|
|
186
|
+
</Box>
|
|
187
|
+
<Box className="gap-2">
|
|
188
|
+
<Text size="sm" color="secondary">
|
|
189
|
+
Read-only
|
|
190
|
+
</Text>
|
|
191
|
+
<Input isReadOnly>
|
|
192
|
+
<Input.Field accessibilityLabel="Read-only input" defaultValue="jane.doe@example.com" />
|
|
193
|
+
</Input>
|
|
194
|
+
</Box>
|
|
195
|
+
<Box className="gap-2">
|
|
196
|
+
<Text size="sm" color="secondary">
|
|
197
|
+
Invalid
|
|
198
|
+
</Text>
|
|
199
|
+
<Input isInvalid>
|
|
200
|
+
<Input.Field accessibilityLabel="Invalid input" defaultValue="not-an-email" />
|
|
201
|
+
</Input>
|
|
202
|
+
</Box>
|
|
203
|
+
</Box>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## With field
|
|
209
|
+
|
|
210
|
+
Compose with `Field` to provide a visible label, helper text, and validation messaging.
|
|
211
|
+
|
|
212
|
+
```tsx
|
|
213
|
+
import { Field, Input } from '@cdx-ui/components';
|
|
214
|
+
|
|
215
|
+
export default function InputWithFieldDemo() {
|
|
216
|
+
return (
|
|
217
|
+
<Field className="w-full" isRequired>
|
|
218
|
+
<Field.Label>Email address</Field.Label>
|
|
219
|
+
<Input isRequired>
|
|
220
|
+
<Input.Field
|
|
221
|
+
autoCapitalize="none"
|
|
222
|
+
autoComplete="email"
|
|
223
|
+
keyboardType="email-address"
|
|
224
|
+
placeholder="you@example.com"
|
|
225
|
+
/>
|
|
226
|
+
</Input>
|
|
227
|
+
<Field.Helper>We will only use this for account notifications.</Field.Helper>
|
|
228
|
+
</Field>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## With field and validation
|
|
234
|
+
|
|
235
|
+
Set the invalid state on both `Field` and `Input` so the error message and input styling stay in sync.
|
|
236
|
+
|
|
237
|
+
```tsx
|
|
238
|
+
import { Field, Input } from '@cdx-ui/components';
|
|
239
|
+
|
|
240
|
+
export default function InputWithFieldInvalidDemo() {
|
|
241
|
+
return (
|
|
242
|
+
<Field className="w-full" isRequired isInvalid>
|
|
243
|
+
<Field.Label>Email address</Field.Label>
|
|
244
|
+
<Input isRequired isInvalid>
|
|
245
|
+
<Input.Field
|
|
246
|
+
autoCapitalize="none"
|
|
247
|
+
autoComplete="email"
|
|
248
|
+
defaultValue="not-an-email"
|
|
249
|
+
keyboardType="email-address"
|
|
250
|
+
/>
|
|
251
|
+
</Input>
|
|
252
|
+
<Field.Error>Enter a valid email address.</Field.Error>
|
|
253
|
+
</Field>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## API
|
|
259
|
+
|
|
260
|
+
### Input
|
|
261
|
+
|
|
262
|
+
The root shell that lays out the field alongside optional slots and icons, and provides variant/size context to its sub-components.
|
|
263
|
+
|
|
264
|
+
| Prop | Type | Default | Description |
|
|
265
|
+
| --- | --- | --- | --- |
|
|
266
|
+
| `className?` | `string` | — | Additional Uniwind/Tailwind classes, merged after the shell's own styles. |
|
|
267
|
+
| `children?` | `ReactNode` | — | Shell content — typically `Input.Field` plus optional `Input.Slot`/`Input.Icon`. |
|
|
268
|
+
| `asChild?` | `boolean` | — | Render the consumer's child element in place of the default `View` host. |
|
|
269
|
+
| `variant?` | `'outline'` | `'outline'` | Visual style variant. |
|
|
270
|
+
| `size?` | `'default' \| 'small'` | `'default'` | Height, padding, and field font size. |
|
|
271
|
+
| `isInvalid?` | `boolean` | — | If true, the input will indicate an error. |
|
|
272
|
+
| `isDisabled?` | `boolean` | — | If true, the input will be disabled. |
|
|
273
|
+
| `isRequired?` | `boolean` | — | Sets `aria-required="true"` on web when passed in form control. |
|
|
274
|
+
| `isReadOnly?` | `boolean` | — | If true, prevents the value of the input from being edited. |
|
|
275
|
+
| `isFullWidth?` | `boolean` | — | If true, the input element will span the full width of its parent. |
|
|
276
|
+
|
|
277
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
278
|
+
|
|
279
|
+
## Sub-components
|
|
280
|
+
|
|
281
|
+
### Input.Field
|
|
282
|
+
|
|
283
|
+
The editable text entry. A discriminated union on `type` — `'text'`/`'password'` render the standard field, while `'file'` switches to the web file-picker branch and enables the file-only props.
|
|
284
|
+
|
|
285
|
+
| Prop | Type | Default | Description |
|
|
286
|
+
| --- | --- | --- | --- |
|
|
287
|
+
| `className?` | `string` | — | — |
|
|
288
|
+
| `children?` | `ReactNode` | — | — |
|
|
289
|
+
| `type?` | `'text' \| 'password' \| 'file'` | — | — |
|
|
290
|
+
| `disabled?` | `boolean` | — | — |
|
|
291
|
+
| `isDisabled?` | `boolean` | — | — |
|
|
292
|
+
| `isInvalid?` | `boolean` | — | — |
|
|
293
|
+
| `isReadOnly?` | `boolean` | — | — |
|
|
294
|
+
| `isRequired?` | `boolean` | — | — |
|
|
295
|
+
| `asChild?` | `boolean` | — | — |
|
|
296
|
+
| `placeholderTextColorClassName?` | `string` | — | — |
|
|
297
|
+
| `accept?` | `string` | — | — |
|
|
298
|
+
| `multiple?` | `boolean` | — | — |
|
|
299
|
+
| `capture?` | `'user' \| 'environment'` | — | — |
|
|
300
|
+
| `onFiles?` | `((files: File[]) => void)` | — | — |
|
|
301
|
+
|
|
302
|
+
Inherits all [`TextInputProps`](https://reactnative.dev/docs/textinput#props). `Input.Field` is a
|
|
303
|
+
discriminated union on `type`; the file-only props (`accept`/`multiple`/`capture`/`onFiles`) apply
|
|
304
|
+
when `type="file"`. `type="file"` is web-only. On native the field stays a text input, so use a
|
|
305
|
+
platform file-picker library there.
|
|
306
|
+
|
|
307
|
+
On web viewports below 600px, field text renders at 16px (`text-base`) for both sizes so iOS Safari
|
|
308
|
+
does not auto-zoom the page when the input is focused. At 600px and above, web matches native sizes
|
|
309
|
+
(14px default, 12px small).
|
|
310
|
+
|
|
311
|
+
### Input.Slot
|
|
312
|
+
|
|
313
|
+
A layout slot for adornments (icons, buttons, adornment text) rendered inside the shell before or after the field. The slot does not handle presses — wrap an interactive control in a `Pressable`.
|
|
314
|
+
|
|
315
|
+
| Prop | Type | Default | Description |
|
|
316
|
+
| --- | --- | --- | --- |
|
|
317
|
+
| `className?` | `string` | — | Additional Uniwind/Tailwind classes, merged after the slot's own styles. |
|
|
318
|
+
| `children?` | `ReactNode` | — | Adornment content (icons, buttons, or adornment text). |
|
|
319
|
+
| `asChild?` | `boolean` | — | Render the consumer's child element in place of the default `View` host. |
|
|
320
|
+
| `isDisabled?` | `boolean` | — | — |
|
|
321
|
+
|
|
322
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
323
|
+
|
|
324
|
+
### Input.Icon
|
|
325
|
+
|
|
326
|
+
Renders a Forge icon sized to the input. Inherits size from the parent Input context.
|
|
327
|
+
|
|
328
|
+
| Prop | Type | Default | Description |
|
|
329
|
+
| --- | --- | --- | --- |
|
|
330
|
+
| `className?` | `string` | — | Utility classes for size (`size-*`) and placement, merged after the defaults. |
|
|
331
|
+
| `filled?` | `boolean` | — | When `true`, renders the filled variant of the icon (if available). Defaults to `false` (outlined). |
|
|
332
|
+
| `size?` | `string \| number` | — | Width and height of the icon, in pixels or any SVG length. The bare icon renders at 24 when omitted. |
|
|
333
|
+
| `data-testid?` | `string` | — | Test identifier forwarded to the rendered SVG. |
|
|
334
|
+
| `as?` | `ForgeIcon` | — | Forge icon component to render. Required unless `asChild` is set, in which case the consumer's substituted element is rendered instead. |
|
|
335
|
+
| `asChild?` | `boolean` | — | Render the consumer's child element in place of the default icon host. |
|
|
336
|
+
|
|
337
|
+
Inherits all `ForgeIconProps` (react-native-svg `SvgProps` plus `filled` and `size`).
|
|
338
|
+
|
|
339
|
+
## Accessibility
|
|
340
|
+
|
|
341
|
+
| Item | Behavior |
|
|
342
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------- |
|
|
343
|
+
| Accessible name | Compose with `Field.Label` (recommended) or pass `accessibilityLabel` on `Input.Field`. |
|
|
344
|
+
| Validation | Pair `isInvalid` with `Field.Error` so the error is not communicated by color alone. |
|
|
345
|
+
| Required | `isRequired` sets `aria-required` on web. |
|
|
346
|
+
| Disabled and read-only | `isDisabled` and `isReadOnly` prevent editing and expose `aria-disabled` / `aria-readonly` on web. |
|