@xanui/ui 1.1.50 → 1.1.51
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/Accordion/index.cjs.map +1 -1
- package/Accordion/index.js.map +1 -1
- package/Alert/index.cjs.map +1 -1
- package/Alert/index.js.map +1 -1
- package/Autocomplete/index.cjs.map +1 -1
- package/Autocomplete/index.js.map +1 -1
- package/Avatar/index.cjs.map +1 -1
- package/Avatar/index.js.map +1 -1
- package/Badge/index.cjs.map +1 -1
- package/Badge/index.js.map +1 -1
- package/Box/index.cjs.map +1 -1
- package/Box/index.js.map +1 -1
- package/Button/index.cjs.map +1 -1
- package/Button/index.js.map +1 -1
- package/ButtonGroup/index.cjs.map +1 -1
- package/ButtonGroup/index.js.map +1 -1
- package/Calendar/index.cjs.map +1 -1
- package/Calendar/index.js.map +1 -1
- package/CalendarInput/index.cjs.map +1 -1
- package/CalendarInput/index.js.map +1 -1
- package/Checkbox/index.cjs.map +1 -1
- package/Checkbox/index.js.map +1 -1
- package/Chip/index.cjs.map +1 -1
- package/Chip/index.js.map +1 -1
- package/CircleProgress/index.cjs.map +1 -1
- package/CircleProgress/index.js.map +1 -1
- package/ClickOutside/index.cjs.map +1 -1
- package/ClickOutside/index.js.map +1 -1
- package/Collaps/index.cjs.map +1 -1
- package/Collaps/index.js.map +1 -1
- package/Container/index.cjs.map +1 -1
- package/Container/index.js.map +1 -1
- package/DataFilter/index.cjs.map +1 -1
- package/DataFilter/index.js.map +1 -1
- package/DataFilter/options/DateFilter.cjs.map +1 -1
- package/DataFilter/options/DateFilter.js.map +1 -1
- package/DataFilter/options/DateRangeFilter.cjs.map +1 -1
- package/DataFilter/options/DateRangeFilter.js.map +1 -1
- package/DataFilter/options/MultiSelectFilter.cjs.map +1 -1
- package/DataFilter/options/MultiSelectFilter.js.map +1 -1
- package/DataFilter/options/NumberFilter.cjs.map +1 -1
- package/DataFilter/options/NumberFilter.js.map +1 -1
- package/DataFilter/options/NumberRangeFilter.cjs.map +1 -1
- package/DataFilter/options/NumberRangeFilter.js.map +1 -1
- package/DataFilter/options/SelectFilter.cjs.map +1 -1
- package/DataFilter/options/SelectFilter.js.map +1 -1
- package/DataFilter/options/TextFilter.cjs.map +1 -1
- package/DataFilter/options/TextFilter.js.map +1 -1
- package/Datatable/FilterBox.cjs.map +1 -1
- package/Datatable/FilterBox.js.map +1 -1
- package/Datatable/Row.cjs.map +1 -1
- package/Datatable/Row.js.map +1 -1
- package/Datatable/SelectedBox.cjs.map +1 -1
- package/Datatable/SelectedBox.js.map +1 -1
- package/Datatable/Table.cjs.map +1 -1
- package/Datatable/Table.js.map +1 -1
- package/Datatable/TableHead.cjs.map +1 -1
- package/Datatable/TableHead.js.map +1 -1
- package/Datatable/index.cjs +1 -1
- package/Datatable/index.cjs.map +1 -1
- package/Datatable/index.js +1 -1
- package/Datatable/index.js.map +1 -1
- package/Divider/index.cjs.map +1 -1
- package/Divider/index.js.map +1 -1
- package/Drawer/index.cjs.map +1 -1
- package/Drawer/index.js.map +1 -1
- package/Form/index.cjs.map +1 -1
- package/Form/index.js.map +1 -1
- package/GridContainer/index.cjs.map +1 -1
- package/GridContainer/index.js.map +1 -1
- package/GridItem/index.cjs.map +1 -1
- package/GridItem/index.js.map +1 -1
- package/IconButton/index.cjs.map +1 -1
- package/IconButton/index.js.map +1 -1
- package/Image/index.cjs.map +1 -1
- package/Image/index.js.map +1 -1
- package/Input/index.cjs.map +1 -1
- package/Input/index.js.map +1 -1
- package/InputNumber/index.cjs.map +1 -1
- package/InputNumber/index.js.map +1 -1
- package/Label/index.cjs.map +1 -1
- package/Label/index.js.map +1 -1
- package/Layer/index.cjs.map +1 -1
- package/Layer/index.js.map +1 -1
- package/LineProgress/index.cjs.map +1 -1
- package/LineProgress/index.js.map +1 -1
- package/List/ListContext.cjs.map +1 -1
- package/List/ListContext.js.map +1 -1
- package/List/index.cjs.map +1 -1
- package/List/index.js.map +1 -1
- package/ListItem/index.cjs.map +1 -1
- package/ListItem/index.js.map +1 -1
- package/LoadingBox/index.cjs.map +1 -1
- package/LoadingBox/index.js.map +1 -1
- package/Menu/index.cjs.map +1 -1
- package/Menu/index.js.map +1 -1
- package/Modal/index.cjs.map +1 -1
- package/Modal/index.js.map +1 -1
- package/NoSSR/index.cjs.map +1 -1
- package/NoSSR/index.js.map +1 -1
- package/Option/index.cjs.map +1 -1
- package/Option/index.js.map +1 -1
- package/Paper/index.cjs.map +1 -1
- package/Paper/index.js.map +1 -1
- package/Portal/index.cjs.map +1 -1
- package/Portal/index.js.map +1 -1
- package/Radio/index.cjs.map +1 -1
- package/Radio/index.js.map +1 -1
- package/Scrollbar/index.cjs.map +1 -1
- package/Scrollbar/index.js.map +1 -1
- package/Select/index.cjs.map +1 -1
- package/Select/index.js.map +1 -1
- package/Skeleton/index.cjs.map +1 -1
- package/Skeleton/index.js.map +1 -1
- package/Stack/index.cjs.map +1 -1
- package/Stack/index.js.map +1 -1
- package/Switch/index.cjs.map +1 -1
- package/Switch/index.js.map +1 -1
- package/Tab/index.cjs.map +1 -1
- package/Tab/index.js.map +1 -1
- package/Table/index.cjs.map +1 -1
- package/Table/index.js.map +1 -1
- package/TableBody/index.cjs.map +1 -1
- package/TableBody/index.js.map +1 -1
- package/TableCell/index.cjs.map +1 -1
- package/TableCell/index.js.map +1 -1
- package/TableFooter/index.cjs.map +1 -1
- package/TableFooter/index.js.map +1 -1
- package/TableHead/index.cjs.map +1 -1
- package/TableHead/index.js.map +1 -1
- package/TablePagination/index.cjs.map +1 -1
- package/TablePagination/index.js.map +1 -1
- package/TableRow/index.cjs.map +1 -1
- package/TableRow/index.js.map +1 -1
- package/Tabs/index.cjs.map +1 -1
- package/Tabs/index.js.map +1 -1
- package/Text/index.cjs.map +1 -1
- package/Text/index.js.map +1 -1
- package/Toast/index.cjs.map +1 -1
- package/Toast/index.js.map +1 -1
- package/Tooltip/index.cjs.map +1 -1
- package/Tooltip/index.js.map +1 -1
- package/ViewBox/index.cjs.map +1 -1
- package/ViewBox/index.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +104 -104
- package/useAlert/index.cjs.map +1 -1
- package/useAlert/index.js.map +1 -1
- package/useBlurCss/index.cjs.map +1 -1
- package/useBlurCss/index.js.map +1 -1
- package/useCorner/index.cjs.map +1 -1
- package/useCorner/index.js.map +1 -1
- package/useLayer/index.cjs.map +1 -1
- package/useLayer/index.js.map +1 -1
- package/useModal/index.cjs.map +1 -1
- package/useModal/index.js.map +1 -1
package/readme.md
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
# Xanui Library
|
|
2
|
-
|
|
3
|
-
Xanui is a React design-system toolkit powered by `@xanui/core`. It combines low-level primitives (e.g., `Box`, `Stack`, `Layer`) with application-ready components (e.g., `Accordion`, `Modal`, `Datatable`, `Toast`) so product teams can build polished surfaces quickly while keeping full control over styling tokens.
|
|
4
|
-
|
|
5
|
-
## Highlights
|
|
6
|
-
|
|
7
|
-
- **Unified prop surface** – every component extends the `Tag` API, so spacing, layout, breakpoints, and system tokens behave identically across the library.
|
|
8
|
-
- **Production-ready defaults** – the color palette, typography scale, shadows, and radii mirror modern SaaS expectations yet remain overridable.
|
|
9
|
-
- **Server compatible** – SSR-safe patterns ensure components render on the server and hydrate cleanly on the client.
|
|
10
|
-
- **Documentation first** – each component ships with a dedicated Markdown guide in `docs/`, ready for consumption by the upcoming Next.js documentation site.
|
|
11
|
-
- **Hooks & utilities** – helpers such as `useClickOutside` mirror the component APIs so lower-level integrations feel consistent.
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install @xanui/ui
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Required peer packages (`react`, `react-dom`, `@xanui/core`, `@xanui/icons`) should already exist in your project; otherwise, install them alongside Xanui.
|
|
21
|
-
|
|
22
|
-
## Quick Start
|
|
23
|
-
|
|
24
|
-
```tsx
|
|
25
|
-
import ThemeProvider from '@xanui/ui/ThemeProvider';
|
|
26
|
-
import Box from '@xanui/ui/Box';
|
|
27
|
-
import Button from '@xanui/ui/Button';
|
|
28
|
-
|
|
29
|
-
export default function App() {
|
|
30
|
-
return (
|
|
31
|
-
<ThemeProvider theme="light">
|
|
32
|
-
<Box p={3} gap={2} display="flex" flexDirection="column">
|
|
33
|
-
<h1>Welcome</h1>
|
|
34
|
-
<Button color="brand" onClick={() => alert('Hello from Xanui!')}>
|
|
35
|
-
Get Started
|
|
36
|
-
</Button>
|
|
37
|
-
</Box>
|
|
38
|
-
</ThemeProvider>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Theming and Tokens
|
|
44
|
-
|
|
45
|
-
`ThemeProvider` injects the active token set from `@xanui/core`. At the component level you can:
|
|
46
|
-
|
|
47
|
-
- Provide responsive props (`{ xs: 'column', md: 'row' }`) via `useBreakpointProps`.
|
|
48
|
-
- Override styles with `sx`/`sxr` objects or custom CSS classes via `baseClass`.
|
|
49
|
-
- Extend color templates by registering new palettes in the core theme manager.
|
|
50
|
-
|
|
51
|
-
## Documentation & Examples
|
|
52
|
-
|
|
53
|
-
- **Component guides** – `docs/<Component>.md` follows a consistent structure (overview → basic example → props table → scenario examples). These files serve both as standalone references and as the content source for the forthcoming Next.js docs site (`documentation/`).
|
|
54
|
-
- **Playground** – `example/` contains runnable demos that mirror the documentation examples.
|
|
55
|
-
|
|
56
|
-
Once the Next.js docs site scaffolding is complete, run it with:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
cd documentation
|
|
60
|
-
npm install
|
|
61
|
-
npm run dev
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Component Index
|
|
65
|
-
|
|
66
|
-
| Category | Components | Docs |
|
|
67
|
-
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
68
|
-
| Layout & Surfaces | Box, Stack, Container, GridContainer, GridItem, Paper, Layer, ViewBox, Divider | `docs/Box.md`, `docs/Stack.md`, `docs/Container.md`, `docs/GridContainer.md`, `docs/GridItem.md`, `docs/Paper.md`, `docs/Layer.md`, `docs/ViewBox.md`, `docs/Divider.md` |
|
|
69
|
-
| Navigation | Tabs, Tab, List, ListItem, Menu, Drawer | `docs/Tabs.md`, `docs/Tab.md`, `docs/List.md`, `docs/ListItem.md`, `docs/Menu.md`, `docs/Drawer.md` |
|
|
70
|
-
| Data Display | Table (and TableBody/TableCell/TableFooter/TableHead/TablePagination/TableRow), Datatable, Chip, Avatar, Image, Badge, CircleProgress, LineProgress, LoadingBox | `docs/Table*.md`, `docs/Datatable.md`, `docs/Chip.md`, `docs/Avatar.md`, `docs/Image.md`, `docs/Badge.md`, `docs/CircleProgress.md`, `docs/LineProgress.md`, `docs/LoadingBox.md` |
|
|
71
|
-
| Inputs & Forms | Button, ButtonGroup, IconButton, Form, Input, Select, Option, Checkbox, Radio, Switch, Calendar, CalendarInput, Label | `docs/Button.md`, `docs/ButtonGroup.md`, `docs/IconButton.md`, `docs/Form.md`, `docs/Input.md`, `docs/Select.md`, `docs/Option.md`, `docs/Checkbox.md`, `docs/Radio.md`, `docs/Switch.md`, `docs/Calendar.md`, `docs/CalendarInput.md`, `docs/Label.md` |
|
|
72
|
-
| Disclosure & Feedback | Accordion, Collaps, Alert, Toast, Tooltip, Modal, Portal, Scrollbar, Toast, NoSSR | `docs/Accordion.md`, `docs/Collaps.md`, `docs/Alert.md`, `docs/Toast.md`, `docs/Tooltip.md`, `docs/Modal.md`, `docs/Portal.md`, `docs/Scrollbar.md`, `docs/NoSSR.md` |
|
|
73
|
-
| Typography & Utilities | Text, ThemeProvider, ClickOutside, useCorner, useClickOutside, View helpers | `docs/Text.md`, `docs/ThemeProvider.md`, `docs/ClickOutside.md`, `docs/useCorner.md`, `docs/useClickOutside.md`, `docs/ViewBox.md` |
|
|
74
|
-
|
|
75
|
-
> The full list is available in `docs/`. Each entry adheres to the shared documentation template for easy navigation and consistency.
|
|
76
|
-
|
|
77
|
-
## Local Development
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
npm install
|
|
81
|
-
npm run start # runs makepack dev server plus the example playground
|
|
82
|
-
npm run build # bundles the library via makepack
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
The development workflow encourages updating `docs/` alongside the corresponding component so examples stay truthful. The `example/` playground hot-reloads component changes for rapid iteration.
|
|
86
|
-
|
|
87
|
-
## Contributing
|
|
88
|
-
|
|
89
|
-
1. Fork this repository and clone your fork.
|
|
90
|
-
2. Install dependencies via `npm install`.
|
|
91
|
-
3. Implement your change (component, hook, docs, or tooling) inside `src/` and update/author `docs/<Component>.md` accordingly.
|
|
92
|
-
4. Run `npm run start` to validate the example playground and lint output.
|
|
93
|
-
5. Open a pull request with a clear description, screenshots when UI changes occur, and reference to relevant documentation updates.
|
|
94
|
-
|
|
95
|
-
Guidelines:
|
|
96
|
-
|
|
97
|
-
- Keep new components aligned with the `TagProps` surface (spacing, layout, color tokens, responsive props).
|
|
98
|
-
- Provide at least one example in `example/` when adding new UI patterns.
|
|
99
|
-
- Maintain the established documentation structure (overview, basic example, props table, scenario demos).
|
|
100
|
-
|
|
101
|
-
## License
|
|
102
|
-
|
|
103
|
-
Distributed under the MIT License. Refer to `LICENSE` for full text.
|
|
104
|
-
|
|
1
|
+
# Xanui Library
|
|
2
|
+
|
|
3
|
+
Xanui is a React design-system toolkit powered by `@xanui/core`. It combines low-level primitives (e.g., `Box`, `Stack`, `Layer`) with application-ready components (e.g., `Accordion`, `Modal`, `Datatable`, `Toast`) so product teams can build polished surfaces quickly while keeping full control over styling tokens.
|
|
4
|
+
|
|
5
|
+
## Highlights
|
|
6
|
+
|
|
7
|
+
- **Unified prop surface** – every component extends the `Tag` API, so spacing, layout, breakpoints, and system tokens behave identically across the library.
|
|
8
|
+
- **Production-ready defaults** – the color palette, typography scale, shadows, and radii mirror modern SaaS expectations yet remain overridable.
|
|
9
|
+
- **Server compatible** – SSR-safe patterns ensure components render on the server and hydrate cleanly on the client.
|
|
10
|
+
- **Documentation first** – each component ships with a dedicated Markdown guide in `docs/`, ready for consumption by the upcoming Next.js documentation site.
|
|
11
|
+
- **Hooks & utilities** – helpers such as `useClickOutside` mirror the component APIs so lower-level integrations feel consistent.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @xanui/ui
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Required peer packages (`react`, `react-dom`, `@xanui/core`, `@xanui/icons`) should already exist in your project; otherwise, install them alongside Xanui.
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import ThemeProvider from '@xanui/ui/ThemeProvider';
|
|
26
|
+
import Box from '@xanui/ui/Box';
|
|
27
|
+
import Button from '@xanui/ui/Button';
|
|
28
|
+
|
|
29
|
+
export default function App() {
|
|
30
|
+
return (
|
|
31
|
+
<ThemeProvider theme="light">
|
|
32
|
+
<Box p={3} gap={2} display="flex" flexDirection="column">
|
|
33
|
+
<h1>Welcome</h1>
|
|
34
|
+
<Button color="brand" onClick={() => alert('Hello from Xanui!')}>
|
|
35
|
+
Get Started
|
|
36
|
+
</Button>
|
|
37
|
+
</Box>
|
|
38
|
+
</ThemeProvider>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Theming and Tokens
|
|
44
|
+
|
|
45
|
+
`ThemeProvider` injects the active token set from `@xanui/core`. At the component level you can:
|
|
46
|
+
|
|
47
|
+
- Provide responsive props (`{ xs: 'column', md: 'row' }`) via `useBreakpointProps`.
|
|
48
|
+
- Override styles with `sx`/`sxr` objects or custom CSS classes via `baseClass`.
|
|
49
|
+
- Extend color templates by registering new palettes in the core theme manager.
|
|
50
|
+
|
|
51
|
+
## Documentation & Examples
|
|
52
|
+
|
|
53
|
+
- **Component guides** – `docs/<Component>.md` follows a consistent structure (overview → basic example → props table → scenario examples). These files serve both as standalone references and as the content source for the forthcoming Next.js docs site (`documentation/`).
|
|
54
|
+
- **Playground** – `example/` contains runnable demos that mirror the documentation examples.
|
|
55
|
+
|
|
56
|
+
Once the Next.js docs site scaffolding is complete, run it with:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
cd documentation
|
|
60
|
+
npm install
|
|
61
|
+
npm run dev
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Component Index
|
|
65
|
+
|
|
66
|
+
| Category | Components | Docs |
|
|
67
|
+
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
68
|
+
| Layout & Surfaces | Box, Stack, Container, GridContainer, GridItem, Paper, Layer, ViewBox, Divider | `docs/Box.md`, `docs/Stack.md`, `docs/Container.md`, `docs/GridContainer.md`, `docs/GridItem.md`, `docs/Paper.md`, `docs/Layer.md`, `docs/ViewBox.md`, `docs/Divider.md` |
|
|
69
|
+
| Navigation | Tabs, Tab, List, ListItem, Menu, Drawer | `docs/Tabs.md`, `docs/Tab.md`, `docs/List.md`, `docs/ListItem.md`, `docs/Menu.md`, `docs/Drawer.md` |
|
|
70
|
+
| Data Display | Table (and TableBody/TableCell/TableFooter/TableHead/TablePagination/TableRow), Datatable, Chip, Avatar, Image, Badge, CircleProgress, LineProgress, LoadingBox | `docs/Table*.md`, `docs/Datatable.md`, `docs/Chip.md`, `docs/Avatar.md`, `docs/Image.md`, `docs/Badge.md`, `docs/CircleProgress.md`, `docs/LineProgress.md`, `docs/LoadingBox.md` |
|
|
71
|
+
| Inputs & Forms | Button, ButtonGroup, IconButton, Form, Input, Select, Option, Checkbox, Radio, Switch, Calendar, CalendarInput, Label | `docs/Button.md`, `docs/ButtonGroup.md`, `docs/IconButton.md`, `docs/Form.md`, `docs/Input.md`, `docs/Select.md`, `docs/Option.md`, `docs/Checkbox.md`, `docs/Radio.md`, `docs/Switch.md`, `docs/Calendar.md`, `docs/CalendarInput.md`, `docs/Label.md` |
|
|
72
|
+
| Disclosure & Feedback | Accordion, Collaps, Alert, Toast, Tooltip, Modal, Portal, Scrollbar, Toast, NoSSR | `docs/Accordion.md`, `docs/Collaps.md`, `docs/Alert.md`, `docs/Toast.md`, `docs/Tooltip.md`, `docs/Modal.md`, `docs/Portal.md`, `docs/Scrollbar.md`, `docs/NoSSR.md` |
|
|
73
|
+
| Typography & Utilities | Text, ThemeProvider, ClickOutside, useCorner, useClickOutside, View helpers | `docs/Text.md`, `docs/ThemeProvider.md`, `docs/ClickOutside.md`, `docs/useCorner.md`, `docs/useClickOutside.md`, `docs/ViewBox.md` |
|
|
74
|
+
|
|
75
|
+
> The full list is available in `docs/`. Each entry adheres to the shared documentation template for easy navigation and consistency.
|
|
76
|
+
|
|
77
|
+
## Local Development
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm install
|
|
81
|
+
npm run start # runs makepack dev server plus the example playground
|
|
82
|
+
npm run build # bundles the library via makepack
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The development workflow encourages updating `docs/` alongside the corresponding component so examples stay truthful. The `example/` playground hot-reloads component changes for rapid iteration.
|
|
86
|
+
|
|
87
|
+
## Contributing
|
|
88
|
+
|
|
89
|
+
1. Fork this repository and clone your fork.
|
|
90
|
+
2. Install dependencies via `npm install`.
|
|
91
|
+
3. Implement your change (component, hook, docs, or tooling) inside `src/` and update/author `docs/<Component>.md` accordingly.
|
|
92
|
+
4. Run `npm run start` to validate the example playground and lint output.
|
|
93
|
+
5. Open a pull request with a clear description, screenshots when UI changes occur, and reference to relevant documentation updates.
|
|
94
|
+
|
|
95
|
+
Guidelines:
|
|
96
|
+
|
|
97
|
+
- Keep new components aligned with the `TagProps` surface (spacing, layout, color tokens, responsive props).
|
|
98
|
+
- Provide at least one example in `example/` when adding new UI patterns.
|
|
99
|
+
- Maintain the established documentation structure (overview, basic example, props table, scenario demos).
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
Distributed under the MIT License. Refer to `LICENSE` for full text.
|
|
104
|
+
|
package/useAlert/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/useAlert/index.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/useAlert/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { Tag, UseTransitionVariantTypes } from \"@xanui/core\"\nimport Button, { ButtonProps } from \"../Button\";\nimport useModal, { UseModalProps } from \"../useModal\";\nimport Alert, { AlertProps } from \"../Alert\";\nimport React from \"react\";\nexport type UseAlertContentProps = {\n open: () => void;\n close: () => void;\n loading: (is: boolean) => void;\n isLoading: () => boolean;\n}\n\nexport type UseAlertContent = React.ReactElement | ((props: UseAlertContentProps) => React.ReactElement)\n\nexport type UseAlerProps = Omit<AlertProps, 'children' | 'onClose' | 'variant' | \"size\"> & {\n content: string | UseAlertContent,\n size?: \"small\" | \"medium\" | \"large\" | number;\n closeButton?: boolean;\n clickOutsideToClose?: boolean;\n okButtonText?: string;\n cancelButtonText?: string;\n hideOkButton?: boolean;\n hideCancelButton?: boolean;\n buttonPlacement?: \"start\" | \"end\" | \"between\" | \"full\";\n variant?: \"text\" | \"fill\"\n onConfirm?: () => Promise<void> | void;\n onCancel?: () => Promise<void> | void;\n transition?: UseTransitionVariantTypes;\n blurMode?: UseModalProps['blurMode'];\n slotProps?: {\n modal?: UseModalProps;\n okButton?: Omit<ButtonProps, \"children\">;\n closeButton?: Omit<ButtonProps, \"children\">;\n }\n}\n\n\nconst useAlert = (props: UseAlerProps) => {\n const [loading, setLoading] = React.useState(false)\n let {\n content,\n size,\n color,\n direction,\n variant,\n closeButton,\n clickOutsideToClose,\n okButtonText,\n cancelButtonText,\n hideOkButton,\n hideCancelButton,\n buttonPlacement,\n onConfirm,\n onCancel,\n transition,\n blurMode,\n slotProps,\n ...rest\n } = props\n\n hideOkButton ??= false\n hideCancelButton ??= false\n\n size ??= \"small\"\n color ??= 'default'\n variant ??= \"text\"\n direction ??= \"column\"\n buttonPlacement ??= \"end\"\n let sx: any = {};\n\n switch (buttonPlacement) {\n case \"start\":\n sx.justifyContent = 'flex-start'\n break;\n case \"end\":\n sx.justifyContent = 'flex-end'\n break;\n case \"between\":\n sx.justifyContent = 'space-between'\n break;\n case \"full\":\n sx = {\n \"& button\": {\n flex: 1\n }\n }\n break;\n }\n\n let sizes: any = {\n small: 320,\n medium: 400,\n large: 600\n }\n\n let okcolor = color\n let closecolor = color\n if (color === 'default') {\n okcolor = 'brand'\n closecolor = 'default'\n variant = 'text'\n } else {\n if (variant === 'fill') {\n okcolor = 'default'\n closecolor = 'default'\n } else {\n okcolor = color\n closecolor = 'default'\n }\n }\n\n const modal = useModal(<Alert\n direction={direction}\n sx={{\n px: 2,\n py: 1,\n pt: direction === 'row' ? 1 : 2\n }}\n color={color}\n variant={variant}\n onClose={closeButton ? close : undefined}\n {...rest}\n >\n {typeof content === \"function\" ? content({\n open: () => modal.open(),\n close: () => modal.close(),\n loading: (is: boolean) => setLoading(is),\n isLoading: () => loading\n }) : content}\n <Tag\n sxr={{\n display: \"flex\",\n gap: 1,\n pt: 4,\n flexDirection: \"row\",\n ...sx,\n }}\n >\n {!hideCancelButton && <Button\n disabled={loading}\n color={closecolor}\n variant=\"fill\"\n {...slotProps?.closeButton}\n onClick={async () => {\n setLoading(true)\n onCancel && await onCancel()\n setLoading(false)\n modal.close()\n }}\n >{cancelButtonText || \"Close\"}</Button>}\n <Button\n loading={loading}\n color={okcolor}\n variant=\"fill\"\n {...slotProps?.okButton}\n\n onClick={async () => {\n setLoading(true)\n onConfirm && await onConfirm()\n setLoading(false)\n modal.close()\n }}\n >{okButtonText || \"OK\"}</Button>\n </Tag>\n </Alert>, {\n ...slotProps?.modal,\n size: sizes[size] || size,\n blur: 40,\n blurMode: blurMode || \"transparent\",\n transition: transition || \"zoom\",\n onClickOutside: async () => {\n if (clickOutsideToClose && !loading) {\n setLoading(true)\n onCancel && await onCancel()\n setLoading(false)\n modal.close()\n }\n }\n })\n\n return {\n ...modal,\n loading: (is: boolean) => setLoading(is),\n isLoading: () => loading\n }\n}\n\nexport default useAlert"],"names":[],"mappings":";;;;;;;;;;;AAuCA;AACI;AACA;;;;;;;;;;AAgCI;AACI;;AAEJ;AACI;;AAEJ;AACI;;AAEJ;AACI;AACI;AACI;AACH;;;;AAKb;AACI;AACA;AACA;;;;AAKJ;;;;;;AAKI;;;;;;;;;AASJ;AAGQ;AACA;;AAEH;AAOG;AACA;;AAEA;;;AAkBQ;;;AAGJ;;AAUI;;;;AAaR;;AAEI;;;;AAIR;;AAQR;;"}
|
package/useAlert/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useAlert/index.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useAlert/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { Tag, UseTransitionVariantTypes } from \"@xanui/core\"\nimport Button, { ButtonProps } from \"../Button\";\nimport useModal, { UseModalProps } from \"../useModal\";\nimport Alert, { AlertProps } from \"../Alert\";\nimport React from \"react\";\nexport type UseAlertContentProps = {\n open: () => void;\n close: () => void;\n loading: (is: boolean) => void;\n isLoading: () => boolean;\n}\n\nexport type UseAlertContent = React.ReactElement | ((props: UseAlertContentProps) => React.ReactElement)\n\nexport type UseAlerProps = Omit<AlertProps, 'children' | 'onClose' | 'variant' | \"size\"> & {\n content: string | UseAlertContent,\n size?: \"small\" | \"medium\" | \"large\" | number;\n closeButton?: boolean;\n clickOutsideToClose?: boolean;\n okButtonText?: string;\n cancelButtonText?: string;\n hideOkButton?: boolean;\n hideCancelButton?: boolean;\n buttonPlacement?: \"start\" | \"end\" | \"between\" | \"full\";\n variant?: \"text\" | \"fill\"\n onConfirm?: () => Promise<void> | void;\n onCancel?: () => Promise<void> | void;\n transition?: UseTransitionVariantTypes;\n blurMode?: UseModalProps['blurMode'];\n slotProps?: {\n modal?: UseModalProps;\n okButton?: Omit<ButtonProps, \"children\">;\n closeButton?: Omit<ButtonProps, \"children\">;\n }\n}\n\n\nconst useAlert = (props: UseAlerProps) => {\n const [loading, setLoading] = React.useState(false)\n let {\n content,\n size,\n color,\n direction,\n variant,\n closeButton,\n clickOutsideToClose,\n okButtonText,\n cancelButtonText,\n hideOkButton,\n hideCancelButton,\n buttonPlacement,\n onConfirm,\n onCancel,\n transition,\n blurMode,\n slotProps,\n ...rest\n } = props\n\n hideOkButton ??= false\n hideCancelButton ??= false\n\n size ??= \"small\"\n color ??= 'default'\n variant ??= \"text\"\n direction ??= \"column\"\n buttonPlacement ??= \"end\"\n let sx: any = {};\n\n switch (buttonPlacement) {\n case \"start\":\n sx.justifyContent = 'flex-start'\n break;\n case \"end\":\n sx.justifyContent = 'flex-end'\n break;\n case \"between\":\n sx.justifyContent = 'space-between'\n break;\n case \"full\":\n sx = {\n \"& button\": {\n flex: 1\n }\n }\n break;\n }\n\n let sizes: any = {\n small: 320,\n medium: 400,\n large: 600\n }\n\n let okcolor = color\n let closecolor = color\n if (color === 'default') {\n okcolor = 'brand'\n closecolor = 'default'\n variant = 'text'\n } else {\n if (variant === 'fill') {\n okcolor = 'default'\n closecolor = 'default'\n } else {\n okcolor = color\n closecolor = 'default'\n }\n }\n\n const modal = useModal(<Alert\n direction={direction}\n sx={{\n px: 2,\n py: 1,\n pt: direction === 'row' ? 1 : 2\n }}\n color={color}\n variant={variant}\n onClose={closeButton ? close : undefined}\n {...rest}\n >\n {typeof content === \"function\" ? content({\n open: () => modal.open(),\n close: () => modal.close(),\n loading: (is: boolean) => setLoading(is),\n isLoading: () => loading\n }) : content}\n <Tag\n sxr={{\n display: \"flex\",\n gap: 1,\n pt: 4,\n flexDirection: \"row\",\n ...sx,\n }}\n >\n {!hideCancelButton && <Button\n disabled={loading}\n color={closecolor}\n variant=\"fill\"\n {...slotProps?.closeButton}\n onClick={async () => {\n setLoading(true)\n onCancel && await onCancel()\n setLoading(false)\n modal.close()\n }}\n >{cancelButtonText || \"Close\"}</Button>}\n <Button\n loading={loading}\n color={okcolor}\n variant=\"fill\"\n {...slotProps?.okButton}\n\n onClick={async () => {\n setLoading(true)\n onConfirm && await onConfirm()\n setLoading(false)\n modal.close()\n }}\n >{okButtonText || \"OK\"}</Button>\n </Tag>\n </Alert>, {\n ...slotProps?.modal,\n size: sizes[size] || size,\n blur: 40,\n blurMode: blurMode || \"transparent\",\n transition: transition || \"zoom\",\n onClickOutside: async () => {\n if (clickOutsideToClose && !loading) {\n setLoading(true)\n onCancel && await onCancel()\n setLoading(false)\n modal.close()\n }\n }\n })\n\n return {\n ...modal,\n loading: (is: boolean) => setLoading(is),\n isLoading: () => loading\n }\n}\n\nexport default useAlert"],"names":[],"mappings":";;;;;;;;;AAuCA;AACI;AACA;;;;;;;;;;AAgCI;AACI;;AAEJ;AACI;;AAEJ;AACI;;AAEJ;AACI;AACI;AACI;AACH;;;;AAKb;AACI;AACA;AACA;;;;AAKJ;;;;;;AAKI;;;;;;;;;AASJ;AAGQ;AACA;;AAEH;AAOG;AACA;;AAEA;;;AAkBQ;;;AAGJ;;AAUI;;;;AAaR;;AAEI;;;;AAIR;;AAQR;;"}
|
package/useBlurCss/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/useBlurCss/index.tsx"],"sourcesContent":["import { useMemo } from \"react\"\
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/useBlurCss/index.tsx"],"sourcesContent":["import { useMemo } from \"react\"\nimport { alpha } from \"@xanui/core\";\n\nlet _d: CSSStyleDeclaration;\n\nconst useBlurCss = (blur: number, mode?: \"transparent\" | \"blur\") => {\n return useMemo(() => {\n let transparent = { bgcolor: alpha(\"#000000\", blur / 100) }\n if (typeof window === 'undefined' || mode === 'transparent') {\n return transparent\n }\n const d = _d || (_d = window.document.createElement(\"div\").style)\n return d['backdropFilter'] !== undefined ? { backdropFilter: `blur(${(blur / 100) * 10}px)` } : transparent\n }, [blur])\n}\n\n\nexport default useBlurCss"],"names":["useMemo","alpha"],"mappings":";;;;;AAGA,IAAI,EAAuB;AAE3B,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,IAA6B,KAAI;IAChE,OAAOA,aAAO,CAAC,MAAK;AACjB,QAAA,IAAI,WAAW,GAAG,EAAE,OAAO,EAAEC,UAAK,CAAC,SAAS,EAAE,IAAI,GAAG,GAAG,CAAC,EAAE;QAC3D,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,IAAI,KAAK,aAAa,EAAE;AAC1D,YAAA,OAAO,WAAW;QACrB;AACA,QAAA,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;QACjE,OAAO,CAAC,CAAC,gBAAgB,CAAC,KAAK,SAAS,GAAG,EAAE,cAAc,EAAE,CAAA,KAAA,EAAQ,CAAC,IAAI,GAAG,GAAG,IAAI,EAAE,CAAA,GAAA,CAAK,EAAE,GAAG,WAAW;AAC9G,IAAA,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AACb;;;;"}
|
package/useBlurCss/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useBlurCss/index.tsx"],"sourcesContent":["import { useMemo } from \"react\"\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useBlurCss/index.tsx"],"sourcesContent":["import { useMemo } from \"react\"\nimport { alpha } from \"@xanui/core\";\n\nlet _d: CSSStyleDeclaration;\n\nconst useBlurCss = (blur: number, mode?: \"transparent\" | \"blur\") => {\n return useMemo(() => {\n let transparent = { bgcolor: alpha(\"#000000\", blur / 100) }\n if (typeof window === 'undefined' || mode === 'transparent') {\n return transparent\n }\n const d = _d || (_d = window.document.createElement(\"div\").style)\n return d['backdropFilter'] !== undefined ? { backdropFilter: `blur(${(blur / 100) * 10}px)` } : transparent\n }, [blur])\n}\n\n\nexport default useBlurCss"],"names":[],"mappings":";;;AAGA,IAAI,EAAuB;AAE3B,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,IAA6B,KAAI;IAChE,OAAO,OAAO,CAAC,MAAK;AACjB,QAAA,IAAI,WAAW,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,GAAG,GAAG,CAAC,EAAE;QAC3D,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,IAAI,KAAK,aAAa,EAAE;AAC1D,YAAA,OAAO,WAAW;QACrB;AACA,QAAA,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;QACjE,OAAO,CAAC,CAAC,gBAAgB,CAAC,KAAK,SAAS,GAAG,EAAE,cAAc,EAAE,CAAA,KAAA,EAAQ,CAAC,IAAI,GAAG,GAAG,IAAI,EAAE,CAAA,GAAA,CAAK,EAAE,GAAG,WAAW;AAC9G,IAAA,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AACb;;;;"}
|
package/useCorner/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/useCorner/index.ts"],"sourcesContent":["\
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/useCorner/index.ts"],"sourcesContent":["\nexport type UseCornerTypes = \"square\" | \"rounded\" | \"circle\"\nconst useCorner = (type?: UseCornerTypes): object => {\n switch (type) {\n case 'square':\n return {\n radius: 0\n }\n case 'rounded':\n return {\n radius: 1\n }\n case 'circle':\n return {\n radius: 100\n }\n }\n return {}\n}\n\nexport default useCorner"],"names":[],"mappings":";;AAEA,MAAM,SAAS,GAAG,CAAC,IAAqB,KAAY;IAChD,QAAQ,IAAI;AACR,QAAA,KAAK,QAAQ;YACT,OAAO;AACH,gBAAA,MAAM,EAAE;aACX;AACL,QAAA,KAAK,SAAS;YACV,OAAO;AACH,gBAAA,MAAM,EAAE;aACX;AACL,QAAA,KAAK,QAAQ;YACT,OAAO;AACH,gBAAA,MAAM,EAAE;aACX;;AAET,IAAA,OAAO,EAAE;AACb;;;;"}
|
package/useCorner/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useCorner/index.ts"],"sourcesContent":["\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useCorner/index.ts"],"sourcesContent":["\nexport type UseCornerTypes = \"square\" | \"rounded\" | \"circle\"\nconst useCorner = (type?: UseCornerTypes): object => {\n switch (type) {\n case 'square':\n return {\n radius: 0\n }\n case 'rounded':\n return {\n radius: 1\n }\n case 'circle':\n return {\n radius: 100\n }\n }\n return {}\n}\n\nexport default useCorner"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,CAAC,IAAqB,KAAY;IAChD,QAAQ,IAAI;AACR,QAAA,KAAK,QAAQ;YACT,OAAO;AACH,gBAAA,MAAM,EAAE;aACX;AACL,QAAA,KAAK,SAAS;YACV,OAAO;AACH,gBAAA,MAAM,EAAE;aACX;AACL,QAAA,KAAK,QAAQ;YACT,OAAO;AACH,gBAAA,MAAM,EAAE;aACX;;AAET,IAAA,OAAO,EAAE;AACb;;;;"}
|
package/useLayer/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/useLayer/index.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/useLayer/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { usePortal } from \"@xanui/core\"\nimport { useState } from \"react\"\nimport Layer, { LayerProps } from \"../Layer\"\nimport { UsePortalOptions } from \"@xanui/core/hooks/usePortal\"\n\nexport type UseLayerProps = Omit<LayerProps, \"open\" | \"children\" | \"slotProps\"> & {\n slotProps?: LayerProps[\"slotProps\"] & {\n portal?: UsePortalOptions\n }\n}\n\nexport type UseLayerReturn = {\n open: () => void;\n close: () => void;\n}\n\nexport type UseLayerChildren = React.ReactElement | ((props: UseLayerReturn) => React.ReactElement)\n\nconst useLayer = (children: UseLayerChildren, props?: UseLayerProps): UseLayerReturn => {\n const [open, setOpen] = useState(false)\n const portalProps = props?.slotProps?.portal || {}\n const portal = usePortal(<Layer\n blur={20}\n {...props}\n open={open}\n onClosed={() => {\n portal.unmount()\n if (props?.onClosed) {\n props.onClosed()\n }\n }}\n onClickOutside={() => {\n if (props?.onClickOutside) {\n props.onClickOutside()\n } else {\n setOpen(false)\n }\n }}\n >\n {typeof children === \"function\" ? children({ open: () => setOpen(true), close: () => setOpen(false) }) : children}\n </Layer>, portalProps)\n\n return {\n open: () => {\n portal.mount()\n setOpen(true)\n },\n close: () => {\n setOpen(false)\n },\n }\n}\n\nexport default useLayer"],"names":[],"mappings":";;;;;;;;AAoBA;;;AAEG;;;;;;AAUG;;;;;;;AAOA;;;;;;;;;;AAcN;;"}
|
package/useLayer/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useLayer/index.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useLayer/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { usePortal } from \"@xanui/core\"\nimport { useState } from \"react\"\nimport Layer, { LayerProps } from \"../Layer\"\nimport { UsePortalOptions } from \"@xanui/core/hooks/usePortal\"\n\nexport type UseLayerProps = Omit<LayerProps, \"open\" | \"children\" | \"slotProps\"> & {\n slotProps?: LayerProps[\"slotProps\"] & {\n portal?: UsePortalOptions\n }\n}\n\nexport type UseLayerReturn = {\n open: () => void;\n close: () => void;\n}\n\nexport type UseLayerChildren = React.ReactElement | ((props: UseLayerReturn) => React.ReactElement)\n\nconst useLayer = (children: UseLayerChildren, props?: UseLayerProps): UseLayerReturn => {\n const [open, setOpen] = useState(false)\n const portalProps = props?.slotProps?.portal || {}\n const portal = usePortal(<Layer\n blur={20}\n {...props}\n open={open}\n onClosed={() => {\n portal.unmount()\n if (props?.onClosed) {\n props.onClosed()\n }\n }}\n onClickOutside={() => {\n if (props?.onClickOutside) {\n props.onClickOutside()\n } else {\n setOpen(false)\n }\n }}\n >\n {typeof children === \"function\" ? children({ open: () => setOpen(true), close: () => setOpen(false) }) : children}\n </Layer>, portalProps)\n\n return {\n open: () => {\n portal.mount()\n setOpen(true)\n },\n close: () => {\n setOpen(false)\n },\n }\n}\n\nexport default useLayer"],"names":[],"mappings":";;;;;;AAoBA;;;AAEG;;;;;;AAUG;;;;;;;AAOA;;;;;;;;;;AAcN;;"}
|
package/useModal/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/useModal/index.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/useModal/index.tsx"],"sourcesContent":["\"use client\";\n\nimport useLayer, { UseLayerProps } from \"../useLayer\";\nimport { Tag, TagProps } from '@xanui/core'\n\nexport type UseModalProps = Omit<UseLayerProps, \"slotProps\"> & {\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\" | number;\n slotProps?: {\n layer?: UseLayerProps['slotProps'];\n root?: Omit<TagProps<'div'>, \"children\">\n }\n}\n\nexport type UseModalChildren = React.ReactElement | ((props: UseModalReturn) => React.ReactElement)\n\nexport type UseModalReturn = {\n open: () => void;\n close: () => void;\n}\n\nconst useModal = (children: UseModalChildren, props?: UseModalProps) => {\n\n let sizes: any = {\n xs: 420,\n sm: 760,\n md: 990,\n lg: 1120,\n xl: 1300,\n full: \"100%\"\n }\n let { size, slotProps, ...useLayerProps } = props || {}\n size = size ?? \"xs\"\n slotProps = slotProps || {} as any\n const root: any = slotProps?.root || {}\n\n const layer = useLayer(() => {\n return (\n <Tag\n {...root}\n sxr={{\n maxWidth: sizes[size as any] || size,\n width: \"100%\",\n radius: 2,\n bgcolor: \"background.primary\",\n shadow: 15,\n ...root?.sx\n }}\n baseClass='modal'\n >\n {typeof children === \"function\" ? children({ open: layer.open, close: layer.close }) : children}\n </Tag>\n )\n }, {\n ...useLayerProps,\n onClickOutside: () => {\n if (props?.onClickOutside) {\n props.onClickOutside()\n } else {\n layer.close()\n }\n },\n slotProps: {\n ...slotProps?.layer,\n clickOutside: {\n maxWidth: sizes[size as any] || size,\n width: \"100%\",\n ...slotProps?.layer?.clickOutside,\n },\n root: {\n display: \"flex\",\n alignItems: 'center',\n justifyContent: \"center\",\n ...slotProps?.layer?.root,\n }\n }\n })\n\n return layer\n}\n\nexport default useModal;"],"names":[],"mappings":";;;;;;;;AAoBA;;AAEG;AACG;AACA;AACA;AACA;AACA;AACA;;AAEH;;AAEA;AACA;AAEA;AACG;AAgBH;;;;;;;AAQG;AAiBH;AACH;;"}
|
package/useModal/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useModal/index.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useModal/index.tsx"],"sourcesContent":["\"use client\";\n\nimport useLayer, { UseLayerProps } from \"../useLayer\";\nimport { Tag, TagProps } from '@xanui/core'\n\nexport type UseModalProps = Omit<UseLayerProps, \"slotProps\"> & {\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\" | number;\n slotProps?: {\n layer?: UseLayerProps['slotProps'];\n root?: Omit<TagProps<'div'>, \"children\">\n }\n}\n\nexport type UseModalChildren = React.ReactElement | ((props: UseModalReturn) => React.ReactElement)\n\nexport type UseModalReturn = {\n open: () => void;\n close: () => void;\n}\n\nconst useModal = (children: UseModalChildren, props?: UseModalProps) => {\n\n let sizes: any = {\n xs: 420,\n sm: 760,\n md: 990,\n lg: 1120,\n xl: 1300,\n full: \"100%\"\n }\n let { size, slotProps, ...useLayerProps } = props || {}\n size = size ?? \"xs\"\n slotProps = slotProps || {} as any\n const root: any = slotProps?.root || {}\n\n const layer = useLayer(() => {\n return (\n <Tag\n {...root}\n sxr={{\n maxWidth: sizes[size as any] || size,\n width: \"100%\",\n radius: 2,\n bgcolor: \"background.primary\",\n shadow: 15,\n ...root?.sx\n }}\n baseClass='modal'\n >\n {typeof children === \"function\" ? children({ open: layer.open, close: layer.close }) : children}\n </Tag>\n )\n }, {\n ...useLayerProps,\n onClickOutside: () => {\n if (props?.onClickOutside) {\n props.onClickOutside()\n } else {\n layer.close()\n }\n },\n slotProps: {\n ...slotProps?.layer,\n clickOutside: {\n maxWidth: sizes[size as any] || size,\n width: \"100%\",\n ...slotProps?.layer?.clickOutside,\n },\n root: {\n display: \"flex\",\n alignItems: 'center',\n justifyContent: \"center\",\n ...slotProps?.layer?.root,\n }\n }\n })\n\n return layer\n}\n\nexport default useModal;"],"names":[],"mappings":";;;;;;AAoBA;;AAEG;AACG;AACA;AACA;AACA;AACA;AACA;;AAEH;;AAEA;AACA;AAEA;AACG;AAgBH;;;;;;;AAQG;AAiBH;AACH;;"}
|