@delightui/components 0.1.105 → 0.1.107
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 +104 -1
- package/dist/cjs/components/molecules/Modal/DemoModal.d.ts +8 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/ModalContext.d.ts +41 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/ModalContext.types.d.ts +87 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/index.d.ts +3 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/useModal.d.ts +34 -0
- package/dist/cjs/components/molecules/Modal/index.d.ts +2 -0
- package/dist/cjs/components/molecules/index.d.ts +2 -0
- package/dist/cjs/library.css +19 -6
- package/dist/cjs/library.js +3 -3
- package/dist/cjs/library.js.map +1 -1
- package/dist/esm/components/molecules/Modal/DemoModal.d.ts +8 -0
- package/dist/esm/components/molecules/Modal/ModalContext/ModalContext.d.ts +41 -0
- package/dist/esm/components/molecules/Modal/ModalContext/ModalContext.types.d.ts +87 -0
- package/dist/esm/components/molecules/Modal/ModalContext/index.d.ts +3 -0
- package/dist/esm/components/molecules/Modal/ModalContext/useModal.d.ts +34 -0
- package/dist/esm/components/molecules/Modal/index.d.ts +2 -0
- package/dist/esm/components/molecules/index.d.ts +2 -0
- package/dist/esm/library.css +19 -6
- package/dist/esm/library.js +3 -3
- package/dist/esm/library.js.map +1 -1
- package/dist/index.d.ts +108 -2
- package/docs/README.md +264 -0
- package/docs/components/atoms/ActionImage.md +119 -0
- package/docs/components/atoms/Button.md +197 -0
- package/docs/components/atoms/Checkbox.md +299 -0
- package/docs/components/atoms/CheckboxItem.md +314 -0
- package/docs/components/atoms/Chip.md +380 -0
- package/docs/components/atoms/CustomToggle.md +270 -0
- package/docs/components/atoms/Icon.md +365 -0
- package/docs/components/atoms/IconButton.md +407 -0
- package/docs/components/atoms/Image.md +448 -0
- package/docs/components/atoms/Input.md +430 -0
- package/docs/components/atoms/ListItem.md +502 -0
- package/docs/components/atoms/Password.md +472 -0
- package/docs/components/atoms/RadioButton.md +614 -0
- package/docs/components/atoms/RadioButtonItem.md +588 -0
- package/docs/components/atoms/ResponsiveComponent.md +612 -0
- package/docs/components/atoms/SelectListItem.md +609 -0
- package/docs/components/atoms/Slider.md +605 -0
- package/docs/components/atoms/Spinner.md +605 -0
- package/docs/components/atoms/Text.md +463 -0
- package/docs/components/atoms/TextArea.md +670 -0
- package/docs/components/atoms/ToastNotification.md +668 -0
- package/docs/components/atoms/Toggle.md +737 -0
- package/docs/components/atoms/ToggleButton.md +751 -0
- package/docs/components/atoms/Tooltip.md +391 -0
- package/docs/components/molecules/Accordion.md +440 -0
- package/docs/components/molecules/AccordionGroup.md +547 -0
- package/docs/components/molecules/ActionCard.md +546 -0
- package/docs/components/molecules/Breadcrumb.md +403 -0
- package/docs/components/molecules/Breadcrumbs.md +485 -0
- package/docs/components/molecules/ButtonGroup.md +383 -0
- package/docs/components/molecules/Card.md +298 -0
- package/docs/components/molecules/ChipInput.md +646 -0
- package/docs/components/molecules/ContextMenu.md +768 -0
- package/docs/components/molecules/CustomTimeSelector.md +116 -0
- package/docs/components/molecules/DatePicker.md +516 -0
- package/docs/components/molecules/DateTimeSelector.md +166 -0
- package/docs/components/molecules/FormField.md +312 -0
- package/docs/components/molecules/Grid.md +577 -0
- package/docs/components/molecules/GridItem.md +834 -0
- package/docs/components/molecules/GridList.md +244 -0
- package/docs/components/molecules/List.md +485 -0
- package/docs/components/molecules/Modal.md +470 -0
- package/docs/components/molecules/ModalFooter.md +702 -0
- package/docs/components/molecules/ModalHeader.md +756 -0
- package/docs/components/molecules/ModalProvider.md +205 -0
- package/docs/components/molecules/Nav.md +530 -0
- package/docs/components/molecules/NavItem.md +572 -0
- package/docs/components/molecules/NavLink.md +499 -0
- package/docs/components/molecules/Option.md +521 -0
- package/docs/components/molecules/Pagination.md +592 -0
- package/docs/components/molecules/PaginationNumberField.md +722 -0
- package/docs/components/molecules/Popover.md +516 -0
- package/docs/components/molecules/ProgressBar.md +624 -0
- package/docs/components/molecules/RadioGroup.md +831 -0
- package/docs/components/molecules/RepeaterList.md +185 -0
- package/docs/components/molecules/Select.md +402 -0
- package/docs/components/molecules/SortableTrigger.md +82 -0
- package/docs/components/molecules/useModal.md +379 -0
- package/docs/components/organisms/Dropzone.md +346 -0
- package/docs/components/organisms/DropzoneClear.md +135 -0
- package/docs/components/organisms/DropzoneContent.md +216 -0
- package/docs/components/organisms/DropzoneFilename.md +191 -0
- package/docs/components/organisms/DropzoneSupportedFormats.md +184 -0
- package/docs/components/organisms/DropzoneTrigger.md +209 -0
- package/docs/components/organisms/Form.md +533 -0
- package/docs/components/organisms/SlideOutPanel.md +662 -0
- package/docs/components/organisms/TabContent.md +902 -0
- package/docs/components/organisms/TabItem.md +1091 -0
- package/docs/components/organisms/Table.md +611 -0
- package/docs/components/organisms/TableBody.md +679 -0
- package/docs/components/organisms/TableCell.md +482 -0
- package/docs/components/organisms/TableHeader.md +513 -0
- package/docs/components/organisms/TableHeaderCell.md +661 -0
- package/docs/components/organisms/TableRow.md +715 -0
- package/docs/components/organisms/Tabs.md +1330 -0
- package/docs/components/utils/ConditionalView.md +568 -0
- package/docs/components/utils/RenderStateView.md +726 -0
- package/docs/components/utils/WrapTextNodes.md +614 -0
- package/package.json +3 -2
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# ModalProvider
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
Context provider component that manages modal state across your application. The ModalProvider enables programmatic modal management by maintaining a centralized registry of active modals and providing functions to open and close them from anywhere in your component tree.
|
|
6
|
+
|
|
7
|
+
## Aliases
|
|
8
|
+
|
|
9
|
+
- ModalProvider
|
|
10
|
+
- ModalContext
|
|
11
|
+
|
|
12
|
+
## Props Breakdown
|
|
13
|
+
|
|
14
|
+
**Extends:** Standalone interface (no HTML element inheritance)
|
|
15
|
+
|
|
16
|
+
| Prop | Type | Default | Required | Description |
|
|
17
|
+
|------|------|---------|----------|-------------|
|
|
18
|
+
| `children` | `ReactNode` | - | Yes | Child components that will have access to modal context |
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### Basic Setup
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import React from 'react';
|
|
26
|
+
import ReactDOM from 'react-dom/client';
|
|
27
|
+
import { ModalProvider } from '@delightui/components';
|
|
28
|
+
import App from './App';
|
|
29
|
+
|
|
30
|
+
ReactDOM.createRoot(document.getElementById('root')).render(
|
|
31
|
+
<ModalProvider>
|
|
32
|
+
<App />
|
|
33
|
+
</ModalProvider>
|
|
34
|
+
);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### With Theme Provider
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import React from 'react';
|
|
41
|
+
import ReactDOM from 'react-dom/client';
|
|
42
|
+
import { ModalProvider, ThemeProvider } from '@delightui/components';
|
|
43
|
+
import App from './App';
|
|
44
|
+
|
|
45
|
+
ReactDOM.createRoot(document.getElementById('root')).render(
|
|
46
|
+
<ThemeProvider theme="dark">
|
|
47
|
+
<ModalProvider>
|
|
48
|
+
<App />
|
|
49
|
+
</ModalProvider>
|
|
50
|
+
</ThemeProvider>
|
|
51
|
+
);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Multiple Provider Setup
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import React from 'react';
|
|
58
|
+
import {
|
|
59
|
+
ModalProvider,
|
|
60
|
+
ThemeProvider,
|
|
61
|
+
NotificationProvider
|
|
62
|
+
} from '@delightui/components';
|
|
63
|
+
|
|
64
|
+
function Providers({ children }) {
|
|
65
|
+
return (
|
|
66
|
+
<ThemeProvider theme="light">
|
|
67
|
+
<NotificationProvider>
|
|
68
|
+
<ModalProvider>
|
|
69
|
+
{children}
|
|
70
|
+
</ModalProvider>
|
|
71
|
+
</NotificationProvider>
|
|
72
|
+
</ThemeProvider>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default function App() {
|
|
77
|
+
return (
|
|
78
|
+
<Providers>
|
|
79
|
+
<YourAppContent />
|
|
80
|
+
</Providers>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Usage Notes
|
|
86
|
+
|
|
87
|
+
### Provider Placement
|
|
88
|
+
|
|
89
|
+
- **Place at application root**: The ModalProvider should be placed as high as possible in your component tree
|
|
90
|
+
- **Above modal consumers**: All components that use `useModal` must be children of ModalProvider
|
|
91
|
+
- **Order matters**: If using multiple providers, ModalProvider should typically be inner to theme providers
|
|
92
|
+
|
|
93
|
+
### State Management
|
|
94
|
+
|
|
95
|
+
- **Centralized**: All modal state is managed centrally by the provider
|
|
96
|
+
- **Automatic cleanup**: Modals are automatically cleaned up when closed
|
|
97
|
+
- **Multiple modals**: Supports multiple simultaneous modals with unique IDs
|
|
98
|
+
- **Render order**: Modals render in the order they were opened
|
|
99
|
+
|
|
100
|
+
### Performance
|
|
101
|
+
|
|
102
|
+
- **Memoized rendering**: Modal components are memoized to prevent unnecessary re-renders
|
|
103
|
+
- **Efficient updates**: Only affected modals re-render when state changes
|
|
104
|
+
- **Memory management**: Closed modals are immediately removed from memory
|
|
105
|
+
|
|
106
|
+
## Best Practices
|
|
107
|
+
|
|
108
|
+
1. **Single provider instance**: Use only one ModalProvider per application
|
|
109
|
+
2. **Root level placement**: Place the provider at or near your application root
|
|
110
|
+
3. **Consistent placement**: Keep provider placement consistent across your app
|
|
111
|
+
4. **Error boundaries**: Consider wrapping with error boundaries for robust error handling
|
|
112
|
+
|
|
113
|
+
## Integration Examples
|
|
114
|
+
|
|
115
|
+
### With React Router
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
119
|
+
import { ModalProvider } from '@delightui/components';
|
|
120
|
+
|
|
121
|
+
function App() {
|
|
122
|
+
return (
|
|
123
|
+
<BrowserRouter>
|
|
124
|
+
<ModalProvider>
|
|
125
|
+
<Routes>
|
|
126
|
+
<Route path="/" element={<HomePage />} />
|
|
127
|
+
<Route path="/dashboard" element={<Dashboard />} />
|
|
128
|
+
</Routes>
|
|
129
|
+
</ModalProvider>
|
|
130
|
+
</BrowserRouter>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### With Redux
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import { Provider as ReduxProvider } from 'react-redux';
|
|
139
|
+
import { ModalProvider } from '@delightui/components';
|
|
140
|
+
import { store } from './store';
|
|
141
|
+
|
|
142
|
+
function App() {
|
|
143
|
+
return (
|
|
144
|
+
<ReduxProvider store={store}>
|
|
145
|
+
<ModalProvider>
|
|
146
|
+
<AppContent />
|
|
147
|
+
</ModalProvider>
|
|
148
|
+
</ReduxProvider>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Error Boundary Integration
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
157
|
+
import { ModalProvider } from '@delightui/components';
|
|
158
|
+
|
|
159
|
+
function ErrorFallback({ error }) {
|
|
160
|
+
return (
|
|
161
|
+
<div>
|
|
162
|
+
<h2>Something went wrong:</h2>
|
|
163
|
+
<pre>{error.message}</pre>
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function App() {
|
|
169
|
+
return (
|
|
170
|
+
<ErrorBoundary FallbackComponent={ErrorFallback}>
|
|
171
|
+
<ModalProvider>
|
|
172
|
+
<AppContent />
|
|
173
|
+
</ModalProvider>
|
|
174
|
+
</ErrorBoundary>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## TypeScript Support
|
|
180
|
+
|
|
181
|
+
The ModalProvider is fully typed and will provide proper TypeScript intellisense:
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
import { ReactNode } from 'react';
|
|
185
|
+
import { ModalProvider } from '@delightui/components';
|
|
186
|
+
|
|
187
|
+
interface AppProvidersProps {
|
|
188
|
+
children: ReactNode;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function AppProviders({ children }: AppProvidersProps) {
|
|
192
|
+
return (
|
|
193
|
+
<ModalProvider>
|
|
194
|
+
{children}
|
|
195
|
+
</ModalProvider>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Related Components
|
|
201
|
+
|
|
202
|
+
- **[useModal Hook](./useModal.md)** - Hook for programmatic modal management
|
|
203
|
+
- **[Modal](./Modal.md)** - Base modal component
|
|
204
|
+
- **[ModalHeader](./ModalHeader.md)** - Modal header component
|
|
205
|
+
- **[ModalFooter](./ModalFooter.md)** - Modal footer component
|