@undefine-ui/design-system 2.12.0 → 2.13.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/README.md +118 -1
- package/dist/index.cjs +367 -158
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -2
- package/dist/index.d.ts +73 -2
- package/dist/index.js +366 -158
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -113,6 +113,123 @@ import { Icon } from '@undefine-ui/design-system';
|
|
|
113
113
|
|
|
114
114
|
The Icon component renders SVG icons with full theme integration and accepts any MUI Box props for flexible styling.
|
|
115
115
|
|
|
116
|
+
### Image
|
|
117
|
+
|
|
118
|
+
A high-performance lazy-loading image component with responsive image support, fallback handling, and smooth loading transitions. Perfect for optimizing image delivery across different devices and screen sizes.
|
|
119
|
+
|
|
120
|
+
**Usage:**
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
import { Image } from '@undefine-ui/design-system';
|
|
124
|
+
|
|
125
|
+
// Basic usage with lazy loading
|
|
126
|
+
<Image
|
|
127
|
+
src="/path/to/image.jpg"
|
|
128
|
+
alt="Description"
|
|
129
|
+
aspectRatio="16 / 9"
|
|
130
|
+
/>
|
|
131
|
+
|
|
132
|
+
// Responsive images with srcSet
|
|
133
|
+
<Image
|
|
134
|
+
src="/image-1280w.jpg"
|
|
135
|
+
srcSet="/image-320w.jpg 320w, /image-640w.jpg 640w, /image-1280w.jpg 1280w"
|
|
136
|
+
sizes="(max-width: 600px) 100vw, (max-width: 1200px) 50vw, 33vw"
|
|
137
|
+
alt="Responsive image"
|
|
138
|
+
aspectRatio="16 / 9"
|
|
139
|
+
/>
|
|
140
|
+
|
|
141
|
+
// Retina display support
|
|
142
|
+
<Image
|
|
143
|
+
src="/image.jpg"
|
|
144
|
+
srcSet="/image.jpg 1x, /image@2x.jpg 2x, /image@3x.jpg 3x"
|
|
145
|
+
alt="High DPI image"
|
|
146
|
+
/>
|
|
147
|
+
|
|
148
|
+
// With fallback for error handling
|
|
149
|
+
<Image
|
|
150
|
+
src="/primary-image.jpg"
|
|
151
|
+
fallbackSrc="/fallback-image.jpg"
|
|
152
|
+
alt="Image with fallback"
|
|
153
|
+
aspectRatio="4 / 3"
|
|
154
|
+
/>
|
|
155
|
+
|
|
156
|
+
// Disable lazy loading for above-the-fold images
|
|
157
|
+
<Image
|
|
158
|
+
src="/hero-image.jpg"
|
|
159
|
+
alt="Hero image"
|
|
160
|
+
lazy={false}
|
|
161
|
+
aspectRatio="21 / 9"
|
|
162
|
+
/>
|
|
163
|
+
|
|
164
|
+
// Custom loading indicator
|
|
165
|
+
<Image
|
|
166
|
+
src="/image.jpg"
|
|
167
|
+
alt="Custom loading"
|
|
168
|
+
loadingIndicator={<CircularProgress />}
|
|
169
|
+
/>
|
|
170
|
+
|
|
171
|
+
// With overlay content
|
|
172
|
+
<Image
|
|
173
|
+
src="/image.jpg"
|
|
174
|
+
alt="Image with overlay"
|
|
175
|
+
overlay={
|
|
176
|
+
<Box sx={{ p: 2, color: 'white' }}>
|
|
177
|
+
<Typography variant="h5">Overlay Text</Typography>
|
|
178
|
+
</Box>
|
|
179
|
+
}
|
|
180
|
+
/>
|
|
181
|
+
|
|
182
|
+
// Custom object-fit and position
|
|
183
|
+
<Image
|
|
184
|
+
src="/portrait.jpg"
|
|
185
|
+
alt="Portrait"
|
|
186
|
+
aspectRatio="1"
|
|
187
|
+
fit="contain"
|
|
188
|
+
position="top center"
|
|
189
|
+
/>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Props:**
|
|
193
|
+
|
|
194
|
+
- `src` - Image source URL (required)
|
|
195
|
+
- `alt` - Alternative text for accessibility (required)
|
|
196
|
+
- `lazy` - Enable lazy loading with Intersection Observer (default: `true`)
|
|
197
|
+
- `srcSet` - Responsive image sources for different screen sizes/resolutions
|
|
198
|
+
- `sizes` - Defines which image size to use at different viewport widths
|
|
199
|
+
- `fallbackSrc` - Fallback URL when the main source fails to load
|
|
200
|
+
- `aspectRatio` - Aspect ratio to prevent layout shift (e.g., `"16 / 9"`, `1.5`)
|
|
201
|
+
- `fit` - Controls `object-fit` CSS property (default: `"cover"`)
|
|
202
|
+
- `position` - Controls `object-position` CSS property (default: `"center"`)
|
|
203
|
+
- `overlay` - Optional overlay content rendered above the image
|
|
204
|
+
- `withOverlay` - Enables overlay even without content
|
|
205
|
+
- `loadingIndicator` - Custom loading indicator component
|
|
206
|
+
- `renderError` - Custom error fallback UI
|
|
207
|
+
- `observerMargin` - Intersection Observer root margin (default: `"200px"`)
|
|
208
|
+
- `imgSx` - Additional styles for the image element
|
|
209
|
+
- `imgProps` - Additional props for the underlying image element
|
|
210
|
+
- `onLoad` - Callback fired when the image loads
|
|
211
|
+
- `onError` - Callback fired when the image fails to load
|
|
212
|
+
|
|
213
|
+
**Features:**
|
|
214
|
+
|
|
215
|
+
- **Lazy loading:** Uses Intersection Observer for efficient viewport detection
|
|
216
|
+
- **Responsive images:** Full support for `srcSet` and `sizes` attributes
|
|
217
|
+
- **Fallback handling:** Automatic retry with fallback source on error
|
|
218
|
+
- **Layout stability:** Prevents layout shift with aspect ratio control
|
|
219
|
+
- **Smooth transitions:** Fade-in animation when image loads
|
|
220
|
+
- **Custom loading states:** Skeleton loader by default, customizable
|
|
221
|
+
- **Error handling:** Graceful error UI with customization options
|
|
222
|
+
- **Overlay support:** Render content on top of images
|
|
223
|
+
- **Browser fallback:** Uses native `loading="lazy"` when IntersectionObserver unavailable
|
|
224
|
+
- **Flexible styling:** Supports all MUI Box props for container and image
|
|
225
|
+
|
|
226
|
+
**Performance Tips:**
|
|
227
|
+
|
|
228
|
+
- Use `lazy={false}` for above-the-fold images to avoid lazy loading delay
|
|
229
|
+
- Always specify `aspectRatio` to prevent layout shift during loading
|
|
230
|
+
- Use `srcSet` with appropriate sizes for optimal image delivery
|
|
231
|
+
- Set `observerMargin="400px"` to preload images slightly before viewport
|
|
232
|
+
|
|
116
233
|
### OTP Input
|
|
117
234
|
|
|
118
235
|
A one-time password input component with keyboard navigation, paste support, and validation. Perfect for email/SMS verification, PIN codes, and security codes.
|
|
@@ -234,7 +351,7 @@ Everything is re-exported from `src/index.ts`. Key groups:
|
|
|
234
351
|
|
|
235
352
|
| Group | Exports |
|
|
236
353
|
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
237
|
-
| Components | `CopyButton`, `HookForm` helpers (`Form`, `Field`, `RHFSwitch`, etc.), `Icon`, `Logo`, `LoadingScreen`, `Table`, `Upload`
|
|
354
|
+
| Components | `CopyButton`, `HookForm` helpers (`Form`, `Field`, `RHFSwitch`, etc.), `Icon`, `Image`, `Logo`, `LoadingScreen`, `OTPInput`, `Table`, `Upload` |
|
|
238
355
|
| Hooks | `useBoolean`, `useCopyToClipboard`, `useEventListener`, `useLocalStorage`, `useResponsive`, `useSettings`, `useSetState`, `useScrollOffsetTop`, `usePopover`, `useCountdown` |
|
|
239
356
|
| Contexts | `SettingsProvider`, `SettingsContext`, `defaultSettings`, `SettingsValueProps` |
|
|
240
357
|
| Theme | `ThemeProvider`, `createTheme`, `colorSchemes`, `components`, `palette`, `radius`, `shadows`, `customSpacing`, utilities such as `varAlpha`, `bgGradient`, `hideScrollX/Y` |
|