@xanui/ui 1.2.6 → 1.2.7
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 +5 -5
- package/Accordion/index.cjs.map +1 -1
- package/Accordion/index.d.ts +3 -3
- package/Accordion/index.js +5 -5
- package/Accordion/index.js.map +1 -1
- package/Alert/index.cjs +19 -17
- package/Alert/index.cjs.map +1 -1
- package/Alert/index.d.ts +2 -2
- package/Alert/index.js +19 -17
- package/Alert/index.js.map +1 -1
- package/Autocomplete/index.cjs +2 -2
- package/Autocomplete/index.cjs.map +1 -1
- package/Autocomplete/index.d.ts +7 -7
- package/Autocomplete/index.js +2 -2
- package/Autocomplete/index.js.map +1 -1
- package/Avatar/index.cjs +2 -2
- package/Avatar/index.cjs.map +1 -1
- package/Avatar/index.d.ts +2 -2
- package/Avatar/index.js +2 -2
- package/Avatar/index.js.map +1 -1
- package/AvatarBox/index.cjs +19 -0
- package/AvatarBox/index.cjs.map +1 -0
- package/AvatarBox/index.d.ts +19 -0
- package/AvatarBox/index.js +17 -0
- package/AvatarBox/index.js.map +1 -0
- package/AvatarPicker/index.cjs +80 -0
- package/AvatarPicker/index.cjs.map +1 -0
- package/AvatarPicker/index.d.ts +27 -0
- package/AvatarPicker/index.js +78 -0
- package/AvatarPicker/index.js.map +1 -0
- package/Badge/index.cjs +1 -1
- package/Badge/index.cjs.map +1 -1
- package/Badge/index.d.ts +4 -4
- package/Badge/index.js +1 -1
- package/Badge/index.js.map +1 -1
- package/Box/index.d.ts +2 -2
- package/Button/index.cjs +5 -3
- package/Button/index.cjs.map +1 -1
- package/Button/index.d.ts +2 -2
- package/Button/index.js +5 -3
- package/Button/index.js.map +1 -1
- package/ButtonGroup/index.cjs +3 -2
- package/ButtonGroup/index.cjs.map +1 -1
- package/ButtonGroup/index.d.ts +2 -2
- package/ButtonGroup/index.js +3 -2
- package/ButtonGroup/index.js.map +1 -1
- package/Calendar/index.cjs +10 -10
- package/Calendar/index.cjs.map +1 -1
- package/Calendar/index.js +10 -10
- package/Calendar/index.js.map +1 -1
- package/CalendarInput/index.cjs +1 -1
- package/CalendarInput/index.cjs.map +1 -1
- package/CalendarInput/index.js +1 -1
- package/CalendarInput/index.js.map +1 -1
- package/Carousel/index.cjs +231 -0
- package/Carousel/index.cjs.map +1 -0
- package/Carousel/index.d.ts +28 -0
- package/Carousel/index.js +229 -0
- package/Carousel/index.js.map +1 -0
- package/Checkbox/index.cjs +2 -2
- package/Checkbox/index.cjs.map +1 -1
- package/Checkbox/index.d.ts +2 -2
- package/Checkbox/index.js +2 -2
- package/Checkbox/index.js.map +1 -1
- package/Chip/index.cjs +3 -3
- package/Chip/index.cjs.map +1 -1
- package/Chip/index.d.ts +2 -2
- package/Chip/index.js +3 -3
- package/Chip/index.js.map +1 -1
- package/CircleProgress/index.cjs +10 -10
- package/CircleProgress/index.cjs.map +1 -1
- package/CircleProgress/index.d.ts +2 -2
- package/CircleProgress/index.js +10 -10
- package/CircleProgress/index.js.map +1 -1
- package/ClickOutside/index.cjs +3 -12
- package/ClickOutside/index.cjs.map +1 -1
- package/ClickOutside/index.d.ts +3 -3
- package/ClickOutside/index.js +4 -13
- package/ClickOutside/index.js.map +1 -1
- package/Collaps/index.cjs +5 -5
- package/Collaps/index.cjs.map +1 -1
- package/Collaps/index.d.ts +2 -2
- package/Collaps/index.js +5 -5
- package/Collaps/index.js.map +1 -1
- package/Container/index.d.ts +2 -2
- package/DataFilter/index.d.ts +2 -2
- package/DataFilter/options/DateFilter.cjs +3 -3
- package/DataFilter/options/DateFilter.cjs.map +1 -1
- package/DataFilter/options/DateFilter.js +3 -3
- package/DataFilter/options/DateFilter.js.map +1 -1
- package/DataFilter/options/DateRangeFilter.cjs +2 -2
- package/DataFilter/options/DateRangeFilter.cjs.map +1 -1
- package/DataFilter/options/DateRangeFilter.js +2 -2
- package/DataFilter/options/DateRangeFilter.js.map +1 -1
- package/DataFilter/options/MultiSelectFilter.cjs +3 -3
- package/DataFilter/options/MultiSelectFilter.cjs.map +1 -1
- package/DataFilter/options/MultiSelectFilter.js +3 -3
- package/DataFilter/options/MultiSelectFilter.js.map +1 -1
- package/DataFilter/options/NumberFilter.cjs +2 -2
- package/DataFilter/options/NumberFilter.cjs.map +1 -1
- package/DataFilter/options/NumberFilter.js +2 -2
- package/DataFilter/options/NumberFilter.js.map +1 -1
- package/DataFilter/options/NumberRangeFilter.cjs +2 -2
- package/DataFilter/options/NumberRangeFilter.cjs.map +1 -1
- package/DataFilter/options/NumberRangeFilter.js +2 -2
- package/DataFilter/options/NumberRangeFilter.js.map +1 -1
- package/DataFilter/options/SelectFilter.cjs +3 -3
- package/DataFilter/options/SelectFilter.cjs.map +1 -1
- package/DataFilter/options/SelectFilter.js +3 -3
- package/DataFilter/options/SelectFilter.js.map +1 -1
- package/DataFilter/options/TextFilter.cjs +2 -2
- package/DataFilter/options/TextFilter.cjs.map +1 -1
- package/DataFilter/options/TextFilter.js +2 -2
- package/DataFilter/options/TextFilter.js.map +1 -1
- package/Datatable/FilterBox.cjs +2 -2
- package/Datatable/FilterBox.cjs.map +1 -1
- package/Datatable/FilterBox.js +2 -2
- package/Datatable/FilterBox.js.map +1 -1
- package/Datatable/Row.cjs +2 -2
- package/Datatable/Row.cjs.map +1 -1
- package/Datatable/Row.js +2 -2
- package/Datatable/Row.js.map +1 -1
- package/Datatable/SelectedBox.cjs +2 -2
- package/Datatable/SelectedBox.cjs.map +1 -1
- package/Datatable/SelectedBox.js +2 -2
- package/Datatable/SelectedBox.js.map +1 -1
- package/Datatable/Table.cjs +1 -1
- package/Datatable/Table.cjs.map +1 -1
- package/Datatable/Table.js +1 -1
- package/Datatable/Table.js.map +1 -1
- package/Datatable/TableHead.cjs +3 -3
- package/Datatable/TableHead.cjs.map +1 -1
- package/Datatable/TableHead.js +3 -3
- package/Datatable/TableHead.js.map +1 -1
- package/Datatable/index.cjs +1 -1
- package/Datatable/index.cjs.map +1 -1
- package/Datatable/index.d.ts +2 -2
- package/Datatable/index.js +1 -1
- package/Datatable/index.js.map +1 -1
- package/Divider/index.cjs +3 -3
- package/Divider/index.cjs.map +1 -1
- package/Divider/index.d.ts +2 -2
- package/Divider/index.js +3 -3
- package/Divider/index.js.map +1 -1
- package/Drawer/index.cjs +2 -2
- package/Drawer/index.cjs.map +1 -1
- package/Drawer/index.js +2 -2
- package/Drawer/index.js.map +1 -1
- package/FilePicker/index.cjs +115 -0
- package/FilePicker/index.cjs.map +1 -0
- package/FilePicker/index.d.ts +23 -0
- package/FilePicker/index.js +113 -0
- package/FilePicker/index.js.map +1 -0
- package/Form/index.cjs +1 -1
- package/Form/index.cjs.map +1 -1
- package/Form/index.d.ts +2 -2
- package/Form/index.js +1 -1
- package/Form/index.js.map +1 -1
- package/GalleryPicker/index.cjs +88 -0
- package/GalleryPicker/index.cjs.map +1 -0
- package/GalleryPicker/index.d.ts +26 -0
- package/GalleryPicker/index.js +86 -0
- package/GalleryPicker/index.js.map +1 -0
- package/GridContainer/index.d.ts +2 -2
- package/GridItem/index.d.ts +2 -2
- package/IconButton/index.cjs +6 -3
- package/IconButton/index.cjs.map +1 -1
- package/IconButton/index.d.ts +2 -2
- package/IconButton/index.js +6 -3
- package/IconButton/index.js.map +1 -1
- package/Image/index.cjs +2 -14
- package/Image/index.cjs.map +1 -1
- package/Image/index.d.ts +3 -5
- package/Image/index.js +3 -15
- package/Image/index.js.map +1 -1
- package/Input/index.cjs +10 -10
- package/Input/index.cjs.map +1 -1
- package/Input/index.d.ts +14 -14
- package/Input/index.js +10 -10
- package/Input/index.js.map +1 -1
- package/InputNumber/index.d.ts +2 -2
- package/Label/index.cjs +1 -1
- package/Label/index.cjs.map +1 -1
- package/Label/index.d.ts +2 -2
- package/Label/index.js +1 -1
- package/Label/index.js.map +1 -1
- package/Layer/index.cjs +12 -13
- package/Layer/index.cjs.map +1 -1
- package/Layer/index.d.ts +5 -5
- package/Layer/index.js +13 -14
- package/Layer/index.js.map +1 -1
- package/LineProgress/index.cjs +6 -6
- package/LineProgress/index.cjs.map +1 -1
- package/LineProgress/index.d.ts +2 -2
- package/LineProgress/index.js +6 -6
- package/LineProgress/index.js.map +1 -1
- package/Link/index.cjs +41 -0
- package/Link/index.cjs.map +1 -0
- package/Link/index.d.ts +17 -0
- package/Link/index.js +39 -0
- package/Link/index.js.map +1 -0
- package/List/index.cjs +1 -1
- package/List/index.cjs.map +1 -1
- package/List/index.d.ts +2 -2
- package/List/index.js +1 -1
- package/List/index.js.map +1 -1
- package/ListItem/index.cjs +8 -8
- package/ListItem/index.cjs.map +1 -1
- package/ListItem/index.d.ts +2 -2
- package/ListItem/index.js +8 -8
- package/ListItem/index.js.map +1 -1
- package/LoadingBox/index.cjs +2 -2
- package/LoadingBox/index.cjs.map +1 -1
- package/LoadingBox/index.d.ts +2 -2
- package/LoadingBox/index.js +2 -2
- package/LoadingBox/index.js.map +1 -1
- package/Menu/index.cjs +6 -21
- package/Menu/index.cjs.map +1 -1
- package/Menu/index.d.ts +6 -4
- package/Menu/index.js +6 -21
- package/Menu/index.js.map +1 -1
- package/Modal/index.cjs +5 -5
- package/Modal/index.cjs.map +1 -1
- package/Modal/index.js +5 -5
- package/Modal/index.js.map +1 -1
- package/Option/index.d.ts +2 -2
- package/PasswordInput/index.cjs +21 -0
- package/PasswordInput/index.cjs.map +1 -0
- package/PasswordInput/index.d.ts +11 -0
- package/PasswordInput/index.js +19 -0
- package/PasswordInput/index.js.map +1 -0
- package/Portal/index.d.ts +3 -3
- package/Radio/index.d.ts +2 -2
- package/RangeSlider/index.cjs +158 -0
- package/RangeSlider/index.cjs.map +1 -0
- package/RangeSlider/index.d.ts +24 -0
- package/RangeSlider/index.js +156 -0
- package/RangeSlider/index.js.map +1 -0
- package/Scrollbar/index.cjs +6 -6
- package/Scrollbar/index.cjs.map +1 -1
- package/Scrollbar/index.d.ts +3 -3
- package/Scrollbar/index.js +6 -6
- package/Scrollbar/index.js.map +1 -1
- package/Select/index.cjs +2 -2
- package/Select/index.cjs.map +1 -1
- package/Select/index.d.ts +5 -5
- package/Select/index.js +2 -2
- package/Select/index.js.map +1 -1
- package/Skeleton/index.cjs +7 -5
- package/Skeleton/index.cjs.map +1 -1
- package/Skeleton/index.js +7 -5
- package/Skeleton/index.js.map +1 -1
- package/Stack/index.d.ts +2 -2
- package/Switch/index.cjs +2 -2
- package/Switch/index.cjs.map +1 -1
- package/Switch/index.d.ts +3 -3
- package/Switch/index.js +2 -2
- package/Switch/index.js.map +1 -1
- package/Tab/index.cjs +23 -2
- package/Tab/index.cjs.map +1 -1
- package/Tab/index.d.ts +2 -2
- package/Tab/index.js +25 -4
- package/Tab/index.js.map +1 -1
- package/Table/index.cjs +9 -9
- package/Table/index.cjs.map +1 -1
- package/Table/index.d.ts +2 -2
- package/Table/index.js +9 -9
- package/Table/index.js.map +1 -1
- package/TableBody/index.d.ts +2 -2
- package/TableCell/index.cjs +1 -1
- package/TableCell/index.cjs.map +1 -1
- package/TableCell/index.d.ts +2 -2
- package/TableCell/index.js +1 -1
- package/TableCell/index.js.map +1 -1
- package/TableFooter/index.d.ts +2 -2
- package/TableHead/index.d.ts +2 -2
- package/TablePagination/index.cjs +2 -2
- package/TablePagination/index.cjs.map +1 -1
- package/TablePagination/index.d.ts +2 -2
- package/TablePagination/index.js +2 -2
- package/TablePagination/index.js.map +1 -1
- package/TableRow/index.d.ts +2 -2
- package/Tabs/context.cjs +11 -0
- package/Tabs/context.cjs.map +1 -0
- package/Tabs/context.js +8 -0
- package/Tabs/context.js.map +1 -0
- package/Tabs/index.cjs +83 -168
- package/Tabs/index.cjs.map +1 -1
- package/Tabs/index.d.ts +4 -22
- package/Tabs/index.js +86 -171
- package/Tabs/index.js.map +1 -1
- package/Tabs/types.d.ts +16 -0
- package/Text/index.cjs +1 -1
- package/Text/index.cjs.map +1 -1
- package/Text/index.d.ts +2 -2
- package/Text/index.js +1 -1
- package/Text/index.js.map +1 -1
- package/Toast/index.cjs +15 -16
- package/Toast/index.cjs.map +1 -1
- package/Toast/index.js +16 -17
- package/Toast/index.js.map +1 -1
- package/Tooltip/index.cjs +2 -2
- package/Tooltip/index.cjs.map +1 -1
- package/Tooltip/index.js +2 -2
- package/Tooltip/index.js.map +1 -1
- package/ViewBox/index.d.ts +2 -2
- package/index.cjs +124 -110
- package/index.cjs.map +1 -1
- package/index.d.ts +8 -1
- package/index.js +8 -1
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +1 -1
- package/useBlurCss/index.cjs +1 -2
- package/useBlurCss/index.cjs.map +1 -1
- package/useBlurCss/index.js +1 -2
- package/useBlurCss/index.js.map +1 -1
- package/useContextMenu/index.cjs +2 -2
- package/useContextMenu/index.cjs.map +1 -1
- package/useContextMenu/index.d.ts +1 -1
- package/useContextMenu/index.js +2 -2
- package/useContextMenu/index.js.map +1 -1
- package/Paper/index.cjs +0 -16
- package/Paper/index.cjs.map +0 -1
- package/Paper/index.d.ts +0 -8
- package/Paper/index.js +0 -14
- package/Paper/index.js.map +0 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import FilePicker from '../FilePicker/index.js';
|
|
6
|
+
import Alert from '../Alert/index.js';
|
|
7
|
+
import Box from '../Box/index.js';
|
|
8
|
+
import Button from '../Button/index.js';
|
|
9
|
+
import IconButton from '../IconButton/index.js';
|
|
10
|
+
import Stack from '../Stack/index.js';
|
|
11
|
+
import Text from '../Text/index.js';
|
|
12
|
+
import AddPhotoAlternateOutlined from '@xanui/icons/AddPhotoAlternateOutlined';
|
|
13
|
+
import DeleteOutline from '@xanui/icons/DeleteOutline';
|
|
14
|
+
import { useBreakpointProps, Tag } from '@xanui/core';
|
|
15
|
+
|
|
16
|
+
const FileCard = ({ file, onRemove }) => {
|
|
17
|
+
const url = typeof file === "string" ? file : URL.createObjectURL(file);
|
|
18
|
+
return (jsxs(Box, { width: 100, height: 100, border: "1px solid", borderColor: 'surface.divider', radius: 1, overflow: "hidden", position: "relative", children: [jsx(IconButton, { size: 25, color: "danger", sx: {
|
|
19
|
+
position: 'absolute',
|
|
20
|
+
top: 2,
|
|
21
|
+
right: 2,
|
|
22
|
+
}, onClick: onRemove, children: jsx(DeleteOutline, {}) }), jsx(Box, { component: "img", src: url, style: {
|
|
23
|
+
width: '100%',
|
|
24
|
+
height: '100%',
|
|
25
|
+
objectFit: 'cover',
|
|
26
|
+
} })] }));
|
|
27
|
+
};
|
|
28
|
+
const GalleryPicker = React.forwardRef((_a, ref) => {
|
|
29
|
+
var { title, subtitle, icon, value, maxFileLimits, maxFileSize, onSelect, onDelete, onChange, onError, slotProps } = _a, props = __rest(_a, ["title", "subtitle", "icon", "value", "maxFileLimits", "maxFileSize", "onSelect", "onDelete", "onChange", "onError", "slotProps"]);
|
|
30
|
+
const bp = useBreakpointProps({
|
|
31
|
+
title,
|
|
32
|
+
subtitle,
|
|
33
|
+
icon
|
|
34
|
+
});
|
|
35
|
+
title = bp.title;
|
|
36
|
+
subtitle = bp.subtitle;
|
|
37
|
+
icon = bp.icon;
|
|
38
|
+
const [error, setError] = React.useState(null);
|
|
39
|
+
maxFileLimits !== null && maxFileLimits !== void 0 ? maxFileLimits : (maxFileLimits = 10);
|
|
40
|
+
const filePickerProps = Object.assign(Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.filePicker), { multiple: true, accept: ['image/*'], maxFileSize: maxFileSize !== null && maxFileSize !== void 0 ? maxFileSize : 5 * 1024, // 5MB
|
|
41
|
+
maxFileLimits, onChange: (_files) => {
|
|
42
|
+
let all = [...((value || [])), ...(_files || [])];
|
|
43
|
+
if (all.length > maxFileLimits) {
|
|
44
|
+
setError({
|
|
45
|
+
message: `You can upload maximum ${maxFileLimits} files.`,
|
|
46
|
+
file: null
|
|
47
|
+
});
|
|
48
|
+
setTimeout(() => setError(null), 4000);
|
|
49
|
+
all = all.slice(0, 10);
|
|
50
|
+
}
|
|
51
|
+
if (onSelect && _files)
|
|
52
|
+
onSelect(_files, value || []);
|
|
53
|
+
onChange && onChange(all);
|
|
54
|
+
}, onError: (err) => {
|
|
55
|
+
setError(err);
|
|
56
|
+
onError && onError(err);
|
|
57
|
+
setTimeout(() => setError(null), 4000);
|
|
58
|
+
} });
|
|
59
|
+
if (value && value.length > 0) {
|
|
60
|
+
return (jsxs(Stack, { gap: 2, children: [error && jsx(Alert, { variant: "fill", color: "danger", mb: 2, icon: jsx(Box, { component: "img", src: URL.createObjectURL(error.file) }), children: error.message }), jsxs(Stack, { direction: "row", gap: 1, flexWrap: "wrap", children: [value.map((file, index) => (jsx(FileCard, { file: file, onRemove: () => {
|
|
61
|
+
const newFiles = value.filter((_, i) => i !== index);
|
|
62
|
+
onDelete && onDelete(file);
|
|
63
|
+
onChange && onChange(newFiles.length > 0 ? newFiles : null);
|
|
64
|
+
} }, index))), jsxs(Stack, { width: 100, height: 100, bgcolor: "surface.light", radius: 1, alignItems: "center", overflow: "hidden", border: "1px solid", borderColor: 'surface.divider', children: [jsx(FilePicker, Object.assign({}, filePickerProps, { alignItems: "center", justifyContent: "center", width: "100%", flex: 1, cursor: "pointer", borderBottom: "1px solid", borderColor: "surface.divider", sx: {
|
|
65
|
+
'& svg': {
|
|
66
|
+
opacity: 0.6,
|
|
67
|
+
},
|
|
68
|
+
"&:hover svg": {
|
|
69
|
+
opacity: 1,
|
|
70
|
+
}
|
|
71
|
+
}, children: jsx(AddPhotoAlternateOutlined, { fontSize: 28, color: "surface.muted" }) })), jsx(Button, { size: "small", variant: "text", onClick: () => onChange && onChange(null), sx: {
|
|
72
|
+
height: 28,
|
|
73
|
+
}, children: "CLEAR" })] })] })] }));
|
|
74
|
+
}
|
|
75
|
+
return (jsxs(Tag, Object.assign({}, props, { baseClass: 'gallery-picker', ref: ref, sxr: {
|
|
76
|
+
display: "flex"
|
|
77
|
+
}, children: [error && jsx(Alert, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.alert, { variant: "fill", color: "danger", mb: 2, icon: jsx(Box, { component: "img", src: URL.createObjectURL(error.file) }), children: error.message })), jsx(FilePicker, Object.assign({}, filePickerProps, { width: "100%", border: "1px dashed", borderColor: 'surface.divider', radius: 2, alignItems: "center", justifyContent: "center", children: jsxs(Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.content, { baseClass: 'gallery-picker-content', sxr: {
|
|
78
|
+
display: "flex",
|
|
79
|
+
justifyContent: "center",
|
|
80
|
+
alignItems: "center",
|
|
81
|
+
p: 4,
|
|
82
|
+
}, children: [jsx(Tag, { mb: 2, children: icon || jsx(AddPhotoAlternateOutlined, { fontSize: 38, color: "surface.muted" }) }), jsx(Text, { children: title || "Drag & drop images here or click to upload." }), jsx(Text, { variant: "button", color: "surface.muted", children: subtitle || `Images only · Max ${filePickerProps.maxFileSize / 1024}MB each · Up to ${filePickerProps.maxFileLimits} files.` })] })) }))] })));
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export { GalleryPicker as default };
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/GalleryPicker/index.tsx"],"sourcesContent":["\"use client\"\nimport React from 'react'\nimport FilePicker, { FilePickerError, FilePickerProps } from '../FilePicker'\nimport Alert, { AlertProps } from \"../Alert\"\nimport Box from \"../Box\"\nimport Button from \"../Button\"\nimport IconButton from \"../IconButton\"\nimport Stack from \"../Stack\"\nimport Text from \"../Text\"\nimport AddPhotoAlternateOutlined from '@xanui/icons/AddPhotoAlternateOutlined'\nimport DeleteOutline from '@xanui/icons/DeleteOutline'\nimport { Tag, TagComponentType, TagProps, useBreakpointProps, useBreakpointPropsType } from '@xanui/core'\n\n\nconst FileCard = ({ file, onRemove }: { file: File | string, onRemove: () => void }) => {\n const url = typeof file === \"string\" ? file : URL.createObjectURL(file);\n\n return (\n <Box\n width={100}\n height={100}\n border=\"1px solid\"\n borderColor='surface.divider'\n radius={1}\n overflow=\"hidden\"\n position=\"relative\"\n >\n <IconButton\n size={25}\n color=\"danger\"\n sx={{\n position: 'absolute',\n top: 2,\n right: 2,\n }}\n onClick={onRemove}\n >\n <DeleteOutline />\n </IconButton>\n <Box\n component=\"img\"\n src={url}\n style={{\n width: '100%',\n height: '100%',\n objectFit: 'cover',\n }}\n />\n </Box>\n )\n}\n\n\nexport type GalleryPickerProps<T extends TagComponentType = \"div\"> = Omit<TagProps<T>, \"children\"> & {\n title?: useBreakpointPropsType<string>;\n subtitle?: useBreakpointPropsType<string>;\n icon?: useBreakpointPropsType<React.ReactNode>;\n value?: (File | string)[] | null;\n maxFileSize?: number; // in kb\n maxFileLimits?: number;\n onSelect?: (files: File[], oldFiles: (File | string)[] | null) => void;\n onDelete?: (file: File | string) => void;\n onChange?: (files: (File | string)[] | null) => void;\n onError?: (error: FilePickerError) => void;\n\n slotProps?: {\n alert?: Omit<AlertProps, \"children\" | \"variant\" | \"color\" | \"icon\">;\n filePicker?: Omit<FilePickerProps, \"multiple\" | \"accept\" | \"onChange\">;\n content?: Omit<TagProps, \"children\">;\n }\n}\n\nconst GalleryPicker = React.forwardRef(<T extends TagComponentType = \"div\">({ title, subtitle, icon, value, maxFileLimits, maxFileSize, onSelect, onDelete, onChange, onError, slotProps, ...props }: GalleryPickerProps, ref: React.Ref<T>) => {\n\n const bp: any = useBreakpointProps({\n title,\n subtitle,\n icon\n })\n\n title = bp.title\n subtitle = bp.subtitle\n icon = bp.icon\n\n const [error, setError] = React.useState<FilePickerError | null>(null);\n maxFileLimits ??= 10\n const filePickerProps = {\n ...slotProps?.filePicker,\n multiple: true,\n accept: ['image/*'],\n maxFileSize: maxFileSize ?? 5 * 1024, // 5MB\n maxFileLimits,\n onChange: (_files: File[] | null) => {\n let all = [...((value || [])), ...(_files || [])]\n if (all.length > maxFileLimits) {\n setError({\n message: `You can upload maximum ${maxFileLimits} files.`,\n file: null as any\n });\n setTimeout(() => setError(null), 4000);\n all = all.slice(0, 10);\n }\n if (onSelect && _files) onSelect(_files, value || [])\n onChange && onChange(all);\n },\n onError: (err: FilePickerError) => {\n setError(err);\n onError && onError(err)\n setTimeout(() => setError(null), 4000);\n },\n }\n\n if (value && value.length > 0) {\n return (\n <Stack gap={2}>\n {error && <Alert\n variant={\"fill\"}\n color=\"danger\"\n mb={2}\n icon={<Box\n component={\"img\"}\n src={URL.createObjectURL(error.file)}\n />}\n >\n {error.message}\n </Alert>}\n <Stack direction=\"row\" gap={1} flexWrap=\"wrap\">\n {value.map((file, index) => (\n <FileCard\n key={index}\n file={file}\n onRemove={() => {\n const newFiles = value.filter((_, i) => i !== index);\n onDelete && onDelete(file)\n onChange && onChange(newFiles.length > 0 ? newFiles : null);\n }}\n />\n ))}\n <Stack\n width={100}\n height={100}\n bgcolor=\"surface.light\"\n radius={1}\n alignItems=\"center\"\n overflow={\"hidden\"}\n border=\"1px solid\"\n borderColor='surface.divider'\n >\n <FilePicker\n {...filePickerProps}\n alignItems=\"center\"\n justifyContent=\"center\"\n width={\"100%\"}\n flex={1}\n cursor={\"pointer\"}\n borderBottom={\"1px solid\"}\n borderColor=\"surface.divider\"\n sx={{\n '& svg': {\n opacity: 0.6,\n },\n \"&:hover svg\": {\n opacity: 1,\n }\n }}\n >\n <AddPhotoAlternateOutlined fontSize={28} color=\"surface.muted\" />\n </FilePicker>\n <Button\n size=\"small\"\n variant={\"text\"}\n onClick={() => onChange && onChange(null)}\n sx={{\n height: 28,\n }}\n >CLEAR</Button>\n </Stack>\n </Stack>\n\n </Stack>\n )\n }\n return (\n <Tag\n {...props}\n baseClass='gallery-picker'\n ref={ref}\n sxr={{\n display: \"flex\"\n }}\n >\n {error && <Alert\n {...slotProps?.alert}\n variant={\"fill\"}\n color=\"danger\"\n mb={2}\n icon={<Box\n component={\"img\"}\n src={URL.createObjectURL(error.file)}\n />}\n >\n {error.message}\n </Alert>}\n <FilePicker\n {...filePickerProps}\n width=\"100%\"\n border=\"1px dashed\"\n borderColor='surface.divider'\n radius={2}\n alignItems=\"center\"\n justifyContent=\"center\"\n >\n <Tag\n {...slotProps?.content}\n baseClass='gallery-picker-content'\n sxr={{\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n p: 4,\n }}\n >\n <Tag mb={2}>\n {(icon as any) || <AddPhotoAlternateOutlined fontSize={38} color=\"surface.muted\" />}\n </Tag>\n <Text>{(title as any) || \"Drag & drop images here or click to upload.\"}</Text>\n <Text variant=\"button\" color=\"surface.muted\">\n {\n (subtitle as any) || `Images only · Max ${filePickerProps.maxFileSize / 1024}MB each · Up to ${filePickerProps.maxFileLimits} files.`\n }\n </Text>\n </Tag>\n </FilePicker>\n </Tag>\n )\n})\n\nexport default GalleryPicker"],"names":[],"mappings":";;;;;;;;;;;;;;;AAcA;AACG;;AAgBY;AACA;AACA;;AAUA;AACA;AACA;;AAKf;AAsBA;;;;;;AAMI;AAED;AACA;AACA;AAEA;;AAEA;AAKG;AAEG;AACA;AACG;;AAEG;AACF;;;;;AAIoB;AACxB;AACH;;AAGG;;AAEH;;AAIA;AAmBkB;AACA;AACA;AACH;AAuBG;AACG;AACF;AACD;AACG;AACF;AACH;AASE;AACF;;AAQnB;AAMS;;AA4BM;AACA;AACA;AACA;;AAgBlB;;"}
|
package/GridContainer/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from 'react';
|
|
2
2
|
import { TagComponentType, TagProps } from '@xanui/core';
|
|
3
3
|
|
|
4
4
|
type GridContainerProps<T extends TagComponentType = "div"> = TagProps<T>;
|
|
5
|
-
declare const GridContainer:
|
|
5
|
+
declare const GridContainer: React__default.ForwardRefExoticComponent<Omit<GridContainerProps<TagComponentType>, "ref"> & React__default.RefAttributes<any>>;
|
|
6
6
|
|
|
7
7
|
export { GridContainer as default };
|
|
8
8
|
export type { GridContainerProps };
|
package/GridItem/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from 'react';
|
|
2
2
|
import { TagComponentType, TagProps } from '@xanui/core';
|
|
3
3
|
|
|
4
4
|
type GridItemProps<T extends TagComponentType = "div"> = TagProps<T> & {
|
|
@@ -8,7 +8,7 @@ type GridItemProps<T extends TagComponentType = "div"> = TagProps<T> & {
|
|
|
8
8
|
lg?: number;
|
|
9
9
|
xl?: number;
|
|
10
10
|
};
|
|
11
|
-
declare const GridItem:
|
|
11
|
+
declare const GridItem: React__default.ForwardRefExoticComponent<Omit<GridItemProps<TagComponentType>, "ref"> & React__default.RefAttributes<any>>;
|
|
12
12
|
|
|
13
13
|
export { GridItem as default };
|
|
14
14
|
export type { GridItemProps };
|
package/IconButton/index.cjs
CHANGED
|
@@ -26,7 +26,7 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
26
26
|
color = p.color;
|
|
27
27
|
variant = p.variant;
|
|
28
28
|
corner = (_c = p.corner) !== null && _c !== void 0 ? _c : "circle";
|
|
29
|
-
let template = core.useColorTemplate(color || "
|
|
29
|
+
let template = core.useColorTemplate(color || "primary", variant || "fill");
|
|
30
30
|
const cornerCss = index(corner);
|
|
31
31
|
if (size === 'small') {
|
|
32
32
|
size = 28;
|
|
@@ -37,7 +37,7 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
37
37
|
else if (size === 'large') {
|
|
38
38
|
size = 52;
|
|
39
39
|
}
|
|
40
|
-
return (jsxRuntime.jsx(core.Tag, Object.assign({ component: 'button', ref: ref }, cornerCss, _props, template.
|
|
40
|
+
return (jsxRuntime.jsx(core.Tag, Object.assign({ component: 'button', ref: ref }, cornerCss, _props, template.main, { baseClass: 'icon-button', sxr: {
|
|
41
41
|
border: 0,
|
|
42
42
|
radius: size,
|
|
43
43
|
height: size,
|
|
@@ -50,6 +50,9 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
50
50
|
lineHeight: 1,
|
|
51
51
|
fontSize: "button",
|
|
52
52
|
bgcolor: "transparent",
|
|
53
|
+
"&:active": {
|
|
54
|
+
transform: variant !== "text" ? "scale(0.97)" : undefined
|
|
55
|
+
},
|
|
53
56
|
"& svg": {
|
|
54
57
|
fontSize: Math.round((size / 3) * 1.8),
|
|
55
58
|
display: "block",
|
|
@@ -57,7 +60,7 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
57
60
|
height: "1em",
|
|
58
61
|
flexShrink: 0,
|
|
59
62
|
},
|
|
60
|
-
}, hover: Object.assign(Object.assign({}, template.
|
|
63
|
+
}, hover: Object.assign(Object.assign({}, template.hover), ((_props === null || _props === void 0 ? void 0 : _props.hover) || {})), children: children })));
|
|
61
64
|
});
|
|
62
65
|
|
|
63
66
|
module.exports = IconButton;
|
package/IconButton/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/IconButton/index.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useInterface, UseColorTemplateColor, UseColorTemplateType, useColorTemplate, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\nimport useCorner from '../useCorner'\n\n\nexport type IconButtonProps<T extends TagComponentType = 'button'> = Omit<TagProps<T>, \"color\" | \"size\"> & {\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n color?: useBreakpointPropsType<UseColorTemplateColor>;\n variant?: useBreakpointPropsType<UseColorTemplateType>;\n corner?: useBreakpointPropsType<\"square\" | \"rounded\" | \"circle\">;\n}\n\nconst IconButton = React.forwardRef(<T extends TagComponentType = 'button'>({ children, ...rest }: IconButtonProps<T>, ref: React.Ref<any>) => {\n rest.sx = (rest as any).sx || {};\n let [{ variant, corner, color, size, ..._props }] = useInterface<any>(\"IconButton\", rest, {})\n\n const _p: any = {}\n if (size) _p.size = size\n if (color) _p.color = color\n if (variant) _p.variant = variant\n if (corner) _p.corner = corner\n const p: any = useBreakpointProps(_p)\n\n size = p.size ?? \"medium\"\n color = p.color\n variant = p.variant\n corner = p.corner ?? \"circle\"\n\n let template = useColorTemplate(color || \"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/IconButton/index.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useInterface, UseColorTemplateColor, UseColorTemplateType, useColorTemplate, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\nimport useCorner from '../useCorner'\n\n\nexport type IconButtonProps<T extends TagComponentType = 'button'> = Omit<TagProps<T>, \"color\" | \"size\"> & {\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n color?: useBreakpointPropsType<UseColorTemplateColor>;\n variant?: useBreakpointPropsType<UseColorTemplateType>;\n corner?: useBreakpointPropsType<\"square\" | \"rounded\" | \"circle\">;\n}\n\nconst IconButton = React.forwardRef(<T extends TagComponentType = 'button'>({ children, ...rest }: IconButtonProps<T>, ref: React.Ref<any>) => {\n rest.sx = (rest as any).sx || {};\n let [{ variant, corner, color, size, ..._props }] = useInterface<any>(\"IconButton\", rest, {})\n\n const _p: any = {}\n if (size) _p.size = size\n if (color) _p.color = color\n if (variant) _p.variant = variant\n if (corner) _p.corner = corner\n const p: any = useBreakpointProps(_p)\n\n size = p.size ?? \"medium\"\n color = p.color\n variant = p.variant\n corner = p.corner ?? \"circle\"\n\n let template = useColorTemplate(color || \"primary\", variant || \"fill\")\n const cornerCss = useCorner(corner)\n\n if (size === 'small') {\n size = 28\n } else if (size === 'medium') {\n size = 34\n } else if (size === 'large') {\n size = 52\n }\n\n return (\n <Tag\n component='button'\n ref={ref}\n {...cornerCss}\n {..._props}\n {...template.main}\n baseClass='icon-button'\n sxr={{\n border: 0,\n radius: size,\n height: size,\n width: size,\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n\n lineHeight: 1,\n fontSize: \"button\",\n\n bgcolor: \"transparent\",\n \"&:active\": {\n transform: variant !== \"text\" ? \"scale(0.97)\" : undefined\n },\n\n \"& svg\": {\n fontSize: Math.round((size / 3) * 1.8),\n display: \"block\",\n width: \"1em\",\n height: \"1em\",\n flexShrink: 0,\n },\n }}\n hover={{\n ...template.hover,\n ...((_props as any)?.hover || {})\n }}\n >\n {children}\n </Tag>\n )\n})\n\nexport default IconButton\n"],"names":[],"mappings":";;;;;;;;;AAaA;;AAA4E;;;;AAKxE;AAAU;AACV;AAAW;AACX;AAAa;AACb;AAAY;AACZ;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;;;AAEO;;;AAEA;;;;AAaK;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;;AAEC;AAED;AACI;AACA;AACA;AACA;AACA;AACH;;AAUjB;;"}
|
package/IconButton/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from 'react';
|
|
2
2
|
import { TagComponentType, TagProps, useBreakpointPropsType, UseColorTemplateColor, UseColorTemplateType } from '@xanui/core';
|
|
3
3
|
|
|
4
4
|
type IconButtonProps<T extends TagComponentType = 'button'> = Omit<TagProps<T>, "color" | "size"> & {
|
|
@@ -7,7 +7,7 @@ type IconButtonProps<T extends TagComponentType = 'button'> = Omit<TagProps<T>,
|
|
|
7
7
|
variant?: useBreakpointPropsType<UseColorTemplateType>;
|
|
8
8
|
corner?: useBreakpointPropsType<"square" | "rounded" | "circle">;
|
|
9
9
|
};
|
|
10
|
-
declare const IconButton:
|
|
10
|
+
declare const IconButton: React__default.ForwardRefExoticComponent<Omit<IconButtonProps<TagComponentType>, "ref"> & React__default.RefAttributes<any>>;
|
|
11
11
|
|
|
12
12
|
export { IconButton as default };
|
|
13
13
|
export type { IconButtonProps };
|
package/IconButton/index.js
CHANGED
|
@@ -24,7 +24,7 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
24
24
|
color = p.color;
|
|
25
25
|
variant = p.variant;
|
|
26
26
|
corner = (_c = p.corner) !== null && _c !== void 0 ? _c : "circle";
|
|
27
|
-
let template = useColorTemplate(color || "
|
|
27
|
+
let template = useColorTemplate(color || "primary", variant || "fill");
|
|
28
28
|
const cornerCss = useCorner(corner);
|
|
29
29
|
if (size === 'small') {
|
|
30
30
|
size = 28;
|
|
@@ -35,7 +35,7 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
35
35
|
else if (size === 'large') {
|
|
36
36
|
size = 52;
|
|
37
37
|
}
|
|
38
|
-
return (jsx(Tag, Object.assign({ component: 'button', ref: ref }, cornerCss, _props, template.
|
|
38
|
+
return (jsx(Tag, Object.assign({ component: 'button', ref: ref }, cornerCss, _props, template.main, { baseClass: 'icon-button', sxr: {
|
|
39
39
|
border: 0,
|
|
40
40
|
radius: size,
|
|
41
41
|
height: size,
|
|
@@ -48,6 +48,9 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
48
48
|
lineHeight: 1,
|
|
49
49
|
fontSize: "button",
|
|
50
50
|
bgcolor: "transparent",
|
|
51
|
+
"&:active": {
|
|
52
|
+
transform: variant !== "text" ? "scale(0.97)" : undefined
|
|
53
|
+
},
|
|
51
54
|
"& svg": {
|
|
52
55
|
fontSize: Math.round((size / 3) * 1.8),
|
|
53
56
|
display: "block",
|
|
@@ -55,7 +58,7 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
55
58
|
height: "1em",
|
|
56
59
|
flexShrink: 0,
|
|
57
60
|
},
|
|
58
|
-
}, hover: Object.assign(Object.assign({}, template.
|
|
61
|
+
}, hover: Object.assign(Object.assign({}, template.hover), ((_props === null || _props === void 0 ? void 0 : _props.hover) || {})), children: children })));
|
|
59
62
|
});
|
|
60
63
|
|
|
61
64
|
export { IconButton as default };
|
package/IconButton/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/IconButton/index.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useInterface, UseColorTemplateColor, UseColorTemplateType, useColorTemplate, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\nimport useCorner from '../useCorner'\n\n\nexport type IconButtonProps<T extends TagComponentType = 'button'> = Omit<TagProps<T>, \"color\" | \"size\"> & {\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n color?: useBreakpointPropsType<UseColorTemplateColor>;\n variant?: useBreakpointPropsType<UseColorTemplateType>;\n corner?: useBreakpointPropsType<\"square\" | \"rounded\" | \"circle\">;\n}\n\nconst IconButton = React.forwardRef(<T extends TagComponentType = 'button'>({ children, ...rest }: IconButtonProps<T>, ref: React.Ref<any>) => {\n rest.sx = (rest as any).sx || {};\n let [{ variant, corner, color, size, ..._props }] = useInterface<any>(\"IconButton\", rest, {})\n\n const _p: any = {}\n if (size) _p.size = size\n if (color) _p.color = color\n if (variant) _p.variant = variant\n if (corner) _p.corner = corner\n const p: any = useBreakpointProps(_p)\n\n size = p.size ?? \"medium\"\n color = p.color\n variant = p.variant\n corner = p.corner ?? \"circle\"\n\n let template = useColorTemplate(color || \"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/IconButton/index.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType, useInterface, UseColorTemplateColor, UseColorTemplateType, useColorTemplate, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\nimport useCorner from '../useCorner'\n\n\nexport type IconButtonProps<T extends TagComponentType = 'button'> = Omit<TagProps<T>, \"color\" | \"size\"> & {\n size?: useBreakpointPropsType<number | \"small\" | \"medium\" | \"large\">;\n color?: useBreakpointPropsType<UseColorTemplateColor>;\n variant?: useBreakpointPropsType<UseColorTemplateType>;\n corner?: useBreakpointPropsType<\"square\" | \"rounded\" | \"circle\">;\n}\n\nconst IconButton = React.forwardRef(<T extends TagComponentType = 'button'>({ children, ...rest }: IconButtonProps<T>, ref: React.Ref<any>) => {\n rest.sx = (rest as any).sx || {};\n let [{ variant, corner, color, size, ..._props }] = useInterface<any>(\"IconButton\", rest, {})\n\n const _p: any = {}\n if (size) _p.size = size\n if (color) _p.color = color\n if (variant) _p.variant = variant\n if (corner) _p.corner = corner\n const p: any = useBreakpointProps(_p)\n\n size = p.size ?? \"medium\"\n color = p.color\n variant = p.variant\n corner = p.corner ?? \"circle\"\n\n let template = useColorTemplate(color || \"primary\", variant || \"fill\")\n const cornerCss = useCorner(corner)\n\n if (size === 'small') {\n size = 28\n } else if (size === 'medium') {\n size = 34\n } else if (size === 'large') {\n size = 52\n }\n\n return (\n <Tag\n component='button'\n ref={ref}\n {...cornerCss}\n {..._props}\n {...template.main}\n baseClass='icon-button'\n sxr={{\n border: 0,\n radius: size,\n height: size,\n width: size,\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n\n lineHeight: 1,\n fontSize: \"button\",\n\n bgcolor: \"transparent\",\n \"&:active\": {\n transform: variant !== \"text\" ? \"scale(0.97)\" : undefined\n },\n\n \"& svg\": {\n fontSize: Math.round((size / 3) * 1.8),\n display: \"block\",\n width: \"1em\",\n height: \"1em\",\n flexShrink: 0,\n },\n }}\n hover={{\n ...template.hover,\n ...((_props as any)?.hover || {})\n }}\n >\n {children}\n </Tag>\n )\n})\n\nexport default IconButton\n"],"names":[],"mappings":";;;;;;;AAaA;;AAA4E;;;;AAKxE;AAAU;AACV;AAAW;AACX;AAAa;AACb;AAAY;AACZ;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;;;AAEO;;;AAEA;;;;AAaK;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;;AAEC;AAED;AACI;AACA;AACA;AACA;AACA;AACH;;AAUjB;;"}
|
package/Image/index.cjs
CHANGED
|
@@ -7,20 +7,8 @@ var React = require('react');
|
|
|
7
7
|
var core = require('@xanui/core');
|
|
8
8
|
|
|
9
9
|
const Image = React.forwardRef((_a, ref) => {
|
|
10
|
-
var {
|
|
11
|
-
|
|
12
|
-
if (faild === false) {
|
|
13
|
-
let t = errorView || (alt === null || alt === void 0 ? void 0 : alt.charAt(0).toUpperCase()) || children;
|
|
14
|
-
return (jsxRuntime.jsx(core.Tag, Object.assign({ src: src }, rest, { sxr: {
|
|
15
|
-
display: "inline-flex",
|
|
16
|
-
justifyContent: "center",
|
|
17
|
-
alignItems: "center",
|
|
18
|
-
}, component: "div", baseClass: 'image', ref: ref, children: t })));
|
|
19
|
-
}
|
|
20
|
-
return (jsxRuntime.jsx(core.Tag, Object.assign({ objectFit: "cover" }, rest, { component: "img", alt: alt, src: src, baseClass: 'image', onError: (e) => {
|
|
21
|
-
setFaild(false);
|
|
22
|
-
rest.onError && rest.onError(e);
|
|
23
|
-
}, ref: ref })));
|
|
10
|
+
var { src, alt } = _a, rest = tslib.__rest(_a, ["src", "alt"]);
|
|
11
|
+
return (jsxRuntime.jsx(core.Tag, Object.assign({ objectFit: "cover" }, rest, { component: "img", alt: alt, src: src, baseClass: 'image', ref: ref })));
|
|
24
12
|
});
|
|
25
13
|
|
|
26
14
|
module.exports = Image;
|
package/Image/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Image/index.tsx"],"sourcesContent":["\"use client\";\nimport React
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Image/index.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType } from '@xanui/core';\n\nexport type ImageProps<T extends TagComponentType = \"img\"> = Omit<TagProps<T>, \"children\">\n\nconst Image = React.forwardRef(<T extends TagComponentType = \"img\">({ src, alt, ...rest }: ImageProps<T>, ref: any) => {\n return (\n <Tag\n objectFit=\"cover\"\n {...rest as any}\n component=\"img\"\n alt={alt}\n src={src}\n baseClass='image'\n ref={ref}\n />\n )\n})\n\nexport default Image\n\n\n"],"names":[],"mappings":";;;;;;;;AAMA;;AACI;AAWJ;;"}
|
package/Image/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from 'react';
|
|
2
2
|
import { TagComponentType, TagProps } from '@xanui/core';
|
|
3
3
|
|
|
4
|
-
type ImageProps<T extends TagComponentType = "img"> = TagProps<T
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
declare const Image: React.ForwardRefExoticComponent<Omit<ImageProps<TagComponentType>, "ref"> & React.RefAttributes<unknown>>;
|
|
4
|
+
type ImageProps<T extends TagComponentType = "img"> = Omit<TagProps<T>, "children">;
|
|
5
|
+
declare const Image: React__default.ForwardRefExoticComponent<Omit<ImageProps<TagComponentType>, "ref"> & React__default.RefAttributes<unknown>>;
|
|
8
6
|
|
|
9
7
|
export { Image as default };
|
|
10
8
|
export type { ImageProps };
|
package/Image/index.js
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { __rest } from 'tslib';
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
|
-
import React
|
|
4
|
+
import React from 'react';
|
|
5
5
|
import { Tag } from '@xanui/core';
|
|
6
6
|
|
|
7
7
|
const Image = React.forwardRef((_a, ref) => {
|
|
8
|
-
var {
|
|
9
|
-
|
|
10
|
-
if (faild === false) {
|
|
11
|
-
let t = errorView || (alt === null || alt === void 0 ? void 0 : alt.charAt(0).toUpperCase()) || children;
|
|
12
|
-
return (jsx(Tag, Object.assign({ src: src }, rest, { sxr: {
|
|
13
|
-
display: "inline-flex",
|
|
14
|
-
justifyContent: "center",
|
|
15
|
-
alignItems: "center",
|
|
16
|
-
}, component: "div", baseClass: 'image', ref: ref, children: t })));
|
|
17
|
-
}
|
|
18
|
-
return (jsx(Tag, Object.assign({ objectFit: "cover" }, rest, { component: "img", alt: alt, src: src, baseClass: 'image', onError: (e) => {
|
|
19
|
-
setFaild(false);
|
|
20
|
-
rest.onError && rest.onError(e);
|
|
21
|
-
}, ref: ref })));
|
|
8
|
+
var { src, alt } = _a, rest = __rest(_a, ["src", "alt"]);
|
|
9
|
+
return (jsx(Tag, Object.assign({ objectFit: "cover" }, rest, { component: "img", alt: alt, src: src, baseClass: 'image', ref: ref })));
|
|
22
10
|
});
|
|
23
11
|
|
|
24
12
|
export { Image as default };
|
package/Image/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Image/index.tsx"],"sourcesContent":["\"use client\";\nimport React
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Image/index.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport { Tag, TagProps, TagComponentType } from '@xanui/core';\n\nexport type ImageProps<T extends TagComponentType = \"img\"> = Omit<TagProps<T>, \"children\">\n\nconst Image = React.forwardRef(<T extends TagComponentType = \"img\">({ src, alt, ...rest }: ImageProps<T>, ref: any) => {\n return (\n <Tag\n objectFit=\"cover\"\n {...rest as any}\n component=\"img\"\n alt={alt}\n src={src}\n baseClass='image'\n ref={ref}\n />\n )\n})\n\nexport default Image\n\n\n"],"names":[],"mappings":";;;;;;AAMA;;AACI;AAWJ;;"}
|
package/Input/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
36
36
|
startIcon = p.startIcon;
|
|
37
37
|
endIcon = p.endIcon;
|
|
38
38
|
iconPlacement = p.iconPlacement;
|
|
39
|
-
color = (_b = p.color) !== null && _b !== void 0 ? _b : "
|
|
39
|
+
color = (_b = p.color) !== null && _b !== void 0 ? _b : "primary";
|
|
40
40
|
variant = (_c = p.variant) !== null && _c !== void 0 ? _c : "fill";
|
|
41
41
|
helperText = p.helperText;
|
|
42
42
|
size = (_d = p.size) !== null && _d !== void 0 ? _d : 'medium';
|
|
@@ -92,8 +92,8 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
const _size = sizes[size];
|
|
95
|
-
let borderColor = _focus ? color : (variant === "fill" ? "transparent" :
|
|
96
|
-
borderColor = error ? "danger.
|
|
95
|
+
let borderColor = _focus ? color : (variant === "fill" ? "transparent" : `${color}.divider`);
|
|
96
|
+
borderColor = error ? "danger.divider" : borderColor;
|
|
97
97
|
let multiprops = {};
|
|
98
98
|
if (multiline) {
|
|
99
99
|
multiprops = {
|
|
@@ -110,9 +110,9 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
110
110
|
}, children: [!!label && jsxRuntime.jsx(index, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.label, { ref: refs === null || refs === void 0 ? void 0 : refs.label, children: label })), jsxRuntime.jsxs(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.inputRoot, { ref: refs === null || refs === void 0 ? void 0 : refs.inputRoot, baseClass: 'input-root', sxr: {
|
|
111
111
|
width: "100%",
|
|
112
112
|
overflow: "hidden",
|
|
113
|
-
}, children: [jsxRuntime.jsxs(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.rootContainer, { ref: refs === null || refs === void 0 ? void 0 : refs.rootContainer, baseClass: 'input-root-container', sxr: Object.assign(Object.assign(Object.assign(Object.assign({ width: "100%", display: "flex", flexDirection: "row", alignItems: iconPlacement === 'center' ? iconPlacement : `flex-${iconPlacement}`, flexWrap: "nowrap", transitionProperty: "border, box-shadow, background", bgcolor: error ? "danger.
|
|
114
|
-
"-webkit-text-fill-color": "
|
|
115
|
-
"box-shadow": `0 0 0px 1000px ${variant === "fill" ? theme.colors.
|
|
113
|
+
}, children: [jsxRuntime.jsxs(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.rootContainer, { ref: refs === null || refs === void 0 ? void 0 : refs.rootContainer, baseClass: 'input-root-container', sxr: Object.assign(Object.assign(Object.assign(Object.assign({ width: "100%", display: "flex", flexDirection: "row", alignItems: iconPlacement === 'center' ? iconPlacement : `flex-${iconPlacement}`, flexWrap: "nowrap", transitionProperty: "border, box-shadow, background", bgcolor: error ? "danger.ghost" : variant === "fill" ? "surface.light" : "transparent", border: variant === "text" ? 0 : "1px solid", borderColor: borderColor, borderRadius: 1, px: 1 }, _size), { height: multiline ? "auto" : _size.height, minHeight: _size.height, "& > input:-webkit-autofill,& > input:-webkit-autofill:hover, & > input:-webkit-autofill:focus,& > input:-webkit-autofill:active": {
|
|
114
|
+
"-webkit-text-fill-color": "surface.contrast",
|
|
115
|
+
"box-shadow": `0 0 0px 1000px ${variant === "fill" ? theme.colors.surface.light : theme.colors.surface.main} inset`,
|
|
116
116
|
transition: "background-color 5000s ease-in-out 0s"
|
|
117
117
|
}, "& textarea": {
|
|
118
118
|
resize: "none"
|
|
@@ -122,7 +122,7 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
122
122
|
alignItems: 'center',
|
|
123
123
|
justifyContent: "center",
|
|
124
124
|
display: "flex",
|
|
125
|
-
color: error ? "danger.
|
|
125
|
+
color: error ? "danger.main" : "surface.muted",
|
|
126
126
|
flex: "0 0 auto",
|
|
127
127
|
},
|
|
128
128
|
})), (!!endIcon && {
|
|
@@ -131,14 +131,14 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
131
131
|
alignItems: 'center',
|
|
132
132
|
justifyContent: "center",
|
|
133
133
|
display: 'flex',
|
|
134
|
-
color: error ? "danger.
|
|
134
|
+
color: error ? "danger.main" : "surface.muted",
|
|
135
135
|
flex: "0 0 auto",
|
|
136
136
|
},
|
|
137
137
|
})), disabled: disabled || false, children: [startIcon, jsxRuntime.jsx(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.input, { ref: inputMergeRef, baseClass: 'input', component: multiline ? 'textarea' : 'input' }, multiprops, { sxr: {
|
|
138
138
|
border: 0,
|
|
139
139
|
outline: 0,
|
|
140
140
|
bgcolor: "transparent",
|
|
141
|
-
color: error ? "danger.
|
|
141
|
+
color: error ? "danger.main" : "surface.contrast",
|
|
142
142
|
fontSize: _size.fontSize,
|
|
143
143
|
height: multiline ? "auto" : _size.height + "px!important",
|
|
144
144
|
width: "100%",
|
|
@@ -150,7 +150,7 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
150
150
|
focused !== null && focused !== void 0 ? focused : setFocused(false);
|
|
151
151
|
onBlur && onBlur(e);
|
|
152
152
|
}, onKeyDown: onKeyDown, onKeyUp: onKeyUp, name: name, placeholder: placeholder, type: type, readOnly: readOnly, autoComplete: autoComplete })), endIcon] })), helperText && jsxRuntime.jsx(core.Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.helperText, { ref: refs === null || refs === void 0 ? void 0 : refs.helperText, baseClass: "input-helper-text", sxr: {
|
|
153
|
-
color: error ? "danger.
|
|
153
|
+
color: error ? "danger.main" : "surface.contrast",
|
|
154
154
|
fontSize: "small",
|
|
155
155
|
lineHeight: "text",
|
|
156
156
|
fontWeight: 'text',
|
package/Input/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Input/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { ReactElement, useEffect, useMemo, useState } from 'react';\nimport { Tag, TagProps, TagComponentType, UseColorTemplateColor, useBreakpointPropsType, useInterface, useBreakpointProps, useMergeRefs } from '@xanui/core';\nimport Label, { LabelProps } from '../Label';\n\nexport type InputProps<T extends TagComponentType = \"div\"> = Omit<TagProps<T>, \"size\" | \"color\" | \"label\"> & {\n value?: string;\n type?: TagProps<'input'>['type'];\n name?: string;\n placeholder?: string;\n readOnly?: boolean;\n autoFocus?: boolean;\n autoComplete?: string;\n label?: useBreakpointPropsType<string>;\n\n onFocus?: (e: React.FocusEvent<any>) => void;\n onBlur?: (e: React.FocusEvent<any>) => void;\n onChange?: (e: React.ChangeEvent<any>) => void;\n onInput?: (e: React.FormEvent<any>) => void;\n onKeyDown?: (e: React.KeyboardEvent<any>) => void;\n onKeyUp?: (e: React.KeyboardEvent<any>) => void;\n\n rows?: useBreakpointPropsType<number>;\n minRows?: useBreakpointPropsType<number>;\n maxRows?: useBreakpointPropsType<number>;\n fullWidth?: boolean;\n\n startIcon?: useBreakpointPropsType<ReactElement>;\n endIcon?: useBreakpointPropsType<ReactElement>;\n iconPlacement?: useBreakpointPropsType<\"start\" | \"center\" | \"end\">;\n focused?: boolean;\n color?: useBreakpointPropsType<Omit<UseColorTemplateColor, \"default\">>;\n variant?: useBreakpointPropsType<\"fill\" | \"outline\" | \"text\">;\n error?: boolean;\n helperText?: useBreakpointPropsType<string>;\n multiline?: boolean;\n size?: useBreakpointPropsType<\"small\" | \"medium\" | \"large\">;\n\n refs?: {\n inputRoot?: React.Ref<\"div\">;\n label?: React.Ref<\"label\">;\n rootContainer?: React.Ref<\"div\">;\n // startIcon?: React.Ref<ReactElement>;\n // endIcon?: React.Ref<ReactElement>;\n // inputContainer?: React.Ref<\"div\">;\n input?: React.Ref<'input' | 'textarea'>;\n helperText?: React.Ref<\"div\">;\n };\n\n slotProps?: {\n inputRoot?: Omit<TagProps<\"div\">, \"children\">;\n label?: Omit<LabelProps, \"children\">;\n rootContainer?: Omit<TagProps<\"div\">, \"children\">;\n // startIcon?: Omit<TagProps<'div'>, \"children\">;\n // endIcon?: Omit<TagProps<'div'>, \"children\">;\n // inputContainer?: Omit<TagProps<\"div\">, \"children\">;\n helperText?: Omit<TagProps<\"div\">, \"children\">;\n input?: Partial<TagProps<T>>;\n }\n}\n\nconst Input = React.forwardRef(<T extends TagComponentType = \"div\">({ value, refs, ...props }: InputProps<T>, ref?: React.Ref<any>) => {\n let [{\n startIcon,\n endIcon,\n iconPlacement,\n color,\n label,\n name,\n placeholder,\n type,\n readOnly,\n autoFocus,\n autoComplete,\n onFocus,\n onBlur,\n onChange,\n onKeyDown,\n onKeyUp,\n\n focused,\n disabled,\n variant,\n error,\n helperText,\n multiline,\n size,\n rows,\n minRows,\n maxRows,\n fullWidth,\n slotProps,\n\n ...rest\n }, theme] = useInterface<any>(\"Input\", props, {})\n\n const _p: any = {}\n if (startIcon) _p.startIcon = startIcon\n if (endIcon) _p.endIcon = endIcon\n if (iconPlacement) _p.iconPlacement = iconPlacement\n if (color) _p.color = color\n if (variant) _p.variant = variant\n if (helperText) _p.helperText = helperText\n if (size) _p.size = size\n if (rows) _p.rows = rows\n if (minRows) _p.minRows = minRows\n if (maxRows) _p.maxRows = maxRows\n const p: any = useBreakpointProps(_p)\n startIcon = p.startIcon\n endIcon = p.endIcon\n iconPlacement = p.iconPlacement\n color = p.color ?? \"brand\"\n variant = p.variant ?? \"fill\"\n helperText = p.helperText\n size = p.size ?? 'medium'\n rows = p.rows\n minRows = p.minRows\n maxRows = p.maxRows\n\n iconPlacement ??= multiline ? \"end\" : \"center\"\n if (!value) iconPlacement = 'center'\n\n const [_focused, setFocused] = useState(false)\n let _focus = focused || _focused\n const inputRef = React.useRef<HTMLInputElement | HTMLTextAreaElement>(null);\n const inputMergeRef = useMergeRefs(inputRef, refs?.input as any);\n\n useEffect(() => {\n if (autoFocus) {\n setTimeout(() => {\n inputRef.current?.focus()\n }, 100);\n }\n }, [autoFocus])\n\n let _rows = useMemo(() => {\n if (rows) return rows\n if (value && multiline) {\n let lines = (value as string).split(`\\n`).length\n if (minRows && minRows > lines) {\n return minRows\n } else if (maxRows && maxRows < lines) {\n return maxRows\n } else {\n return lines\n }\n }\n }, [value]) || 1\n\n const sizes: any = {\n small: {\n height: 38,\n gap: .5,\n fontSize: 'button',\n },\n medium: {\n height: 46,\n gap: 1,\n fontSize: \"text\"\n },\n large: {\n height: 52,\n gap: 1,\n fontSize: 'big'\n }\n }\n\n const _size = sizes[size]\n let borderColor = _focus ? color : (variant === \"fill\" ? \"transparent\" : \"divider\")\n borderColor = error ? \"danger.primary\" : borderColor\n let multiprops: any = {}\n if (multiline) {\n multiprops = {\n rows: _rows,\n sx: {\n resize: \"none\"\n }\n }\n }\n\n return (\n <Tag\n width={fullWidth ? \"100%\" : \"auto\"}\n {...rest}\n ref={ref}\n baseClass=\"input-wrapper\"\n sxr={{\n display: 'flex',\n flexDirection: 'column',\n gap: .5,\n }}\n >\n {!!label && <Label {...slotProps?.label} ref={refs?.label}>{label}</Label>}\n <Tag\n {...slotProps?.inputRoot}\n ref={refs?.inputRoot}\n baseClass={'input-root'}\n sxr={{\n width: \"100%\",\n overflow: \"hidden\",\n }}\n >\n <Tag\n {...slotProps?.rootContainer}\n ref={refs?.rootContainer}\n baseClass='input-root-container'\n sxr={{\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: iconPlacement === 'center' ? iconPlacement : `flex-${iconPlacement}`,\n flexWrap: \"nowrap\",\n transitionProperty: \"border, box-shadow, background\",\n bgcolor: error ? \"danger.soft.primary\" : variant === \"fill\" ? \"background.secondary\" : \"background.primary\",\n border: variant === \"text\" ? 0 : \"1px solid\",\n borderColor: borderColor,\n borderRadius: 1,\n px: 1,\n // py: .5,\n ..._size,\n height: multiline ? \"auto\" : _size.height,\n minHeight: _size.height,\n \"& > input:-webkit-autofill,& > input:-webkit-autofill:hover, & > input:-webkit-autofill:focus,& > input:-webkit-autofill:active\": {\n \"-webkit-text-fill-color\": \"text.primary\",\n \"box-shadow\": `0 0 0px 1000px ${variant === \"fill\" ? theme.colors.background.secondary : theme.colors.background.primary} inset`,\n transition: \"background-color 5000s ease-in-out 0s\"\n } as any,\n \"& textarea\": {\n resize: \"none\"\n },\n\n ...(!!startIcon && {\n \"& > :first-child:not(.xui-input)\": {\n height: \"100%\",\n alignItems: 'center',\n justifyContent: \"center\",\n display: \"flex\",\n color: error ? \"danger.primary\" : \"text.secondary\",\n flex: \"0 0 auto\",\n },\n }),\n\n ...(!!endIcon && {\n \"& > :last-child:not(.xui-input)\": {\n height: \"100%\",\n alignItems: 'center',\n justifyContent: \"center\",\n display: 'flex',\n color: error ? \"danger.primary\" : \"text.secondary\",\n flex: \"0 0 auto\",\n },\n })\n\n }}\n disabled={disabled || false}\n >\n {startIcon}\n <Tag\n {...slotProps?.input}\n ref={inputMergeRef}\n baseClass='input'\n component={multiline ? 'textarea' : 'input'}\n {...multiprops}\n sxr={{\n border: 0,\n outline: 0,\n bgcolor: \"transparent\",\n color: error ? \"danger.primary\" : \"text.primary\",\n fontSize: _size.fontSize,\n height: multiline ? \"auto\" : _size.height + \"px!important\",\n width: \"100%\",\n maxHeight: 200,\n }}\n value={value}\n onChange={onChange}\n onFocus={(e: any) => {\n focused ?? setFocused(true)\n onFocus && onFocus(e)\n }}\n onBlur={(e: any) => {\n focused ?? setFocused(false)\n onBlur && onBlur(e)\n }}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n name={name}\n placeholder={placeholder}\n type={type}\n readOnly={readOnly}\n autoComplete={autoComplete}\n />\n {endIcon}\n </Tag>\n {helperText && <Tag\n {...slotProps?.helperText}\n ref={refs?.helperText}\n baseClass=\"input-helper-text\"\n sxr={{\n color: error ? \"danger.primary\" : \"text.primary\",\n fontSize: \"small\",\n lineHeight: \"text\",\n fontWeight: 'text',\n pl: .5,\n }}\n >{helperText}</Tag>}\n </Tag>\n </Tag>\n )\n})\n\nexport default Input\n"],"names":[],"mappings":";;;;;;;;;AA6DA;;;AACI;;AAmCA;AAAe;AACf;AAAa;AACb;AAAmB;AACnB;AAAW;AACX;AAAa;AACb;AAAgB;AAChB;AAAU;AACV;AAAU;AACV;AAAa;AACb;AAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;;AAGA;;AAEA;;;;;AAKY;;;AAGZ;AAEA;AACI;AAAU;AACV;;AAEI;AACI;;AACG;AACH;;;AAEA;;;AAGZ;AAEA;AACI;AACI;AACA;AACA;AACH;AACD;AACI;AACA;AACA;AACH;AACD;AACI;AACA;AACA;AACH;;AAGL;;;;;AAKI;AACI;AACA;AACI;AACH;;;;AAWG;AACA;AACA;;AASI;AACA;AACH;AAuBW;;AAEA;AACI;AAEJ;AACH;AAGG;AACI;AACA;AACA;AACA;;AAEA;AACH;AACJ;AAGG;AACI;AACA;AACA;AACA;;AAEA;AACH;AACJ;AAaG;AACA;AACA;;;AAGA;AACA;AACA;AACH;;AAKG;AACJ;;AAGI;AACJ;;AAiBA;AACA;AACA;AACA;AACH;AAKrB;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Input/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { ReactElement, useEffect, useMemo, useState } from 'react';\nimport { Tag, TagProps, TagComponentType, UseColorTemplateColor, useBreakpointPropsType, useInterface, useBreakpointProps, useMergeRefs } from '@xanui/core';\nimport Label, { LabelProps } from '../Label';\n\nexport type InputProps<T extends TagComponentType = \"div\"> = Omit<TagProps<T>, \"size\" | \"color\" | \"label\"> & {\n value?: string;\n type?: TagProps<'input'>['type'];\n name?: string;\n placeholder?: string;\n readOnly?: boolean;\n autoFocus?: boolean;\n autoComplete?: string;\n label?: useBreakpointPropsType<string>;\n\n onFocus?: (e: React.FocusEvent<any>) => void;\n onBlur?: (e: React.FocusEvent<any>) => void;\n onChange?: (e: React.ChangeEvent<any>) => void;\n onInput?: (e: React.FormEvent<any>) => void;\n onKeyDown?: (e: React.KeyboardEvent<any>) => void;\n onKeyUp?: (e: React.KeyboardEvent<any>) => void;\n\n rows?: useBreakpointPropsType<number>;\n minRows?: useBreakpointPropsType<number>;\n maxRows?: useBreakpointPropsType<number>;\n fullWidth?: boolean;\n\n startIcon?: useBreakpointPropsType<ReactElement>;\n endIcon?: useBreakpointPropsType<ReactElement>;\n iconPlacement?: useBreakpointPropsType<\"start\" | \"center\" | \"end\">;\n focused?: boolean;\n color?: useBreakpointPropsType<Omit<UseColorTemplateColor, 'surface'>>;\n variant?: useBreakpointPropsType<\"fill\" | \"outline\" | \"text\">;\n error?: boolean;\n helperText?: useBreakpointPropsType<string>;\n multiline?: boolean;\n size?: useBreakpointPropsType<\"small\" | \"medium\" | \"large\">;\n\n refs?: {\n inputRoot?: React.Ref<\"div\">;\n label?: React.Ref<\"label\">;\n rootContainer?: React.Ref<\"div\">;\n // startIcon?: React.Ref<ReactElement>;\n // endIcon?: React.Ref<ReactElement>;\n // inputContainer?: React.Ref<\"div\">;\n input?: React.Ref<'input' | 'textarea'>;\n helperText?: React.Ref<\"div\">;\n };\n\n slotProps?: {\n inputRoot?: Omit<TagProps<\"div\">, \"children\">;\n label?: Omit<LabelProps, \"children\">;\n rootContainer?: Omit<TagProps<\"div\">, \"children\">;\n // startIcon?: Omit<TagProps<'div'>, \"children\">;\n // endIcon?: Omit<TagProps<'div'>, \"children\">;\n // inputContainer?: Omit<TagProps<\"div\">, \"children\">;\n helperText?: Omit<TagProps<\"div\">, \"children\">;\n input?: Partial<TagProps<T>>;\n }\n}\n\nconst Input = React.forwardRef(<T extends TagComponentType = \"div\">({ value, refs, ...props }: InputProps<T>, ref?: React.Ref<any>) => {\n let [{\n startIcon,\n endIcon,\n iconPlacement,\n color,\n label,\n name,\n placeholder,\n type,\n readOnly,\n autoFocus,\n autoComplete,\n onFocus,\n onBlur,\n onChange,\n onKeyDown,\n onKeyUp,\n\n focused,\n disabled,\n variant,\n error,\n helperText,\n multiline,\n size,\n rows,\n minRows,\n maxRows,\n fullWidth,\n slotProps,\n\n ...rest\n }, theme] = useInterface<any>(\"Input\", props, {})\n\n const _p: any = {}\n if (startIcon) _p.startIcon = startIcon\n if (endIcon) _p.endIcon = endIcon\n if (iconPlacement) _p.iconPlacement = iconPlacement\n if (color) _p.color = color\n if (variant) _p.variant = variant\n if (helperText) _p.helperText = helperText\n if (size) _p.size = size\n if (rows) _p.rows = rows\n if (minRows) _p.minRows = minRows\n if (maxRows) _p.maxRows = maxRows\n const p: any = useBreakpointProps(_p)\n startIcon = p.startIcon\n endIcon = p.endIcon\n iconPlacement = p.iconPlacement\n color = p.color ?? \"primary\"\n variant = p.variant ?? \"fill\"\n helperText = p.helperText\n size = p.size ?? 'medium'\n rows = p.rows\n minRows = p.minRows\n maxRows = p.maxRows\n\n iconPlacement ??= multiline ? \"end\" : \"center\"\n if (!value) iconPlacement = 'center'\n\n const [_focused, setFocused] = useState(false)\n let _focus = focused || _focused\n const inputRef = React.useRef<HTMLInputElement | HTMLTextAreaElement>(null);\n const inputMergeRef = useMergeRefs(inputRef, refs?.input as any);\n\n useEffect(() => {\n if (autoFocus) {\n setTimeout(() => {\n inputRef.current?.focus()\n }, 100);\n }\n }, [autoFocus])\n\n let _rows = useMemo(() => {\n if (rows) return rows\n if (value && multiline) {\n let lines = (value as string).split(`\\n`).length\n if (minRows && minRows > lines) {\n return minRows\n } else if (maxRows && maxRows < lines) {\n return maxRows\n } else {\n return lines\n }\n }\n }, [value]) || 1\n\n const sizes: any = {\n small: {\n height: 38,\n gap: .5,\n fontSize: 'button',\n },\n medium: {\n height: 46,\n gap: 1,\n fontSize: \"text\"\n },\n large: {\n height: 52,\n gap: 1,\n fontSize: 'big'\n }\n }\n\n const _size = sizes[size]\n let borderColor = _focus ? color : (variant === \"fill\" ? \"transparent\" : `${color}.divider`)\n borderColor = error ? \"danger.divider\" : borderColor\n let multiprops: any = {}\n if (multiline) {\n multiprops = {\n rows: _rows,\n sx: {\n resize: \"none\"\n }\n }\n }\n\n return (\n <Tag\n width={fullWidth ? \"100%\" : \"auto\"}\n {...rest}\n ref={ref}\n baseClass=\"input-wrapper\"\n sxr={{\n display: 'flex',\n flexDirection: 'column',\n gap: .5,\n }}\n >\n {!!label && <Label {...slotProps?.label} ref={refs?.label}>{label}</Label>}\n <Tag\n {...slotProps?.inputRoot}\n ref={refs?.inputRoot}\n baseClass={'input-root'}\n sxr={{\n width: \"100%\",\n overflow: \"hidden\",\n }}\n >\n <Tag\n {...slotProps?.rootContainer}\n ref={refs?.rootContainer}\n baseClass='input-root-container'\n sxr={{\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: iconPlacement === 'center' ? iconPlacement : `flex-${iconPlacement}`,\n flexWrap: \"nowrap\",\n transitionProperty: \"border, box-shadow, background\",\n bgcolor: error ? \"danger.ghost\" : variant === \"fill\" ? \"surface.light\" : \"transparent\",\n border: variant === \"text\" ? 0 : \"1px solid\",\n borderColor: borderColor,\n borderRadius: 1,\n px: 1,\n // py: .5,\n ..._size,\n height: multiline ? \"auto\" : _size.height,\n minHeight: _size.height,\n \"& > input:-webkit-autofill,& > input:-webkit-autofill:hover, & > input:-webkit-autofill:focus,& > input:-webkit-autofill:active\": {\n \"-webkit-text-fill-color\": \"surface.contrast\",\n \"box-shadow\": `0 0 0px 1000px ${variant === \"fill\" ? theme.colors.surface.light : theme.colors.surface.main} inset`,\n transition: \"background-color 5000s ease-in-out 0s\"\n } as any,\n \"& textarea\": {\n resize: \"none\"\n },\n\n ...(!!startIcon && {\n \"& > :first-child:not(.xui-input)\": {\n height: \"100%\",\n alignItems: 'center',\n justifyContent: \"center\",\n display: \"flex\",\n color: error ? \"danger.main\" : \"surface.muted\",\n flex: \"0 0 auto\",\n },\n }),\n\n ...(!!endIcon && {\n \"& > :last-child:not(.xui-input)\": {\n height: \"100%\",\n alignItems: 'center',\n justifyContent: \"center\",\n display: 'flex',\n color: error ? \"danger.main\" : \"surface.muted\",\n flex: \"0 0 auto\",\n },\n })\n\n }}\n disabled={disabled || false}\n >\n {startIcon}\n <Tag\n {...slotProps?.input}\n ref={inputMergeRef}\n baseClass='input'\n component={multiline ? 'textarea' : 'input'}\n {...multiprops}\n sxr={{\n border: 0,\n outline: 0,\n bgcolor: \"transparent\",\n color: error ? \"danger.main\" : \"surface.contrast\",\n fontSize: _size.fontSize,\n height: multiline ? \"auto\" : _size.height + \"px!important\",\n width: \"100%\",\n maxHeight: 200,\n }}\n value={value}\n onChange={onChange}\n onFocus={(e: any) => {\n focused ?? setFocused(true)\n onFocus && onFocus(e)\n }}\n onBlur={(e: any) => {\n focused ?? setFocused(false)\n onBlur && onBlur(e)\n }}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n name={name}\n placeholder={placeholder}\n type={type}\n readOnly={readOnly}\n autoComplete={autoComplete}\n />\n {endIcon}\n </Tag>\n {helperText && <Tag\n {...slotProps?.helperText}\n ref={refs?.helperText}\n baseClass=\"input-helper-text\"\n sxr={{\n color: error ? \"danger.main\" : \"surface.contrast\",\n fontSize: \"small\",\n lineHeight: \"text\",\n fontWeight: 'text',\n pl: .5,\n }}\n >{helperText}</Tag>}\n </Tag>\n </Tag>\n )\n})\n\nexport default Input\n"],"names":[],"mappings":";;;;;;;;;AA6DA;;;AACI;;AAmCA;AAAe;AACf;AAAa;AACb;AAAmB;AACnB;AAAW;AACX;AAAa;AACb;AAAgB;AAChB;AAAU;AACV;AAAU;AACV;AAAa;AACb;AAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;;AAGA;;AAEA;;;;;AAKY;;;AAGZ;AAEA;AACI;AAAU;AACV;;AAEI;AACI;;AACG;AACH;;;AAEA;;;AAGZ;AAEA;AACI;AACI;AACA;AACA;AACH;AACD;AACI;AACA;AACA;AACH;AACD;AACI;AACA;AACA;AACH;;AAGL;;;;;AAKI;AACI;AACA;AACI;AACH;;;;AAWG;AACA;AACA;;AASI;AACA;AACH;AAuBW;;AAEA;AACI;AAEJ;AACH;AAGG;AACI;AACA;AACA;AACA;;AAEA;AACH;AACJ;AAGG;AACI;AACA;AACA;AACA;;AAEA;AACH;AACJ;AAaG;AACA;AACA;;;AAGA;AACA;AACA;AACH;;AAKG;AACJ;;AAGI;AACJ;;AAiBA;AACA;AACA;AACA;AACH;AAKrB;;"}
|
package/Input/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default, { ReactElement } from 'react';
|
|
2
2
|
import { TagComponentType, TagProps, useBreakpointPropsType, UseColorTemplateColor } from '@xanui/core';
|
|
3
3
|
import { LabelProps } from '../Label/index.js';
|
|
4
4
|
|
|
@@ -11,12 +11,12 @@ type InputProps<T extends TagComponentType = "div"> = Omit<TagProps<T>, "size" |
|
|
|
11
11
|
autoFocus?: boolean;
|
|
12
12
|
autoComplete?: string;
|
|
13
13
|
label?: useBreakpointPropsType<string>;
|
|
14
|
-
onFocus?: (e:
|
|
15
|
-
onBlur?: (e:
|
|
16
|
-
onChange?: (e:
|
|
17
|
-
onInput?: (e:
|
|
18
|
-
onKeyDown?: (e:
|
|
19
|
-
onKeyUp?: (e:
|
|
14
|
+
onFocus?: (e: React__default.FocusEvent<any>) => void;
|
|
15
|
+
onBlur?: (e: React__default.FocusEvent<any>) => void;
|
|
16
|
+
onChange?: (e: React__default.ChangeEvent<any>) => void;
|
|
17
|
+
onInput?: (e: React__default.FormEvent<any>) => void;
|
|
18
|
+
onKeyDown?: (e: React__default.KeyboardEvent<any>) => void;
|
|
19
|
+
onKeyUp?: (e: React__default.KeyboardEvent<any>) => void;
|
|
20
20
|
rows?: useBreakpointPropsType<number>;
|
|
21
21
|
minRows?: useBreakpointPropsType<number>;
|
|
22
22
|
maxRows?: useBreakpointPropsType<number>;
|
|
@@ -25,18 +25,18 @@ type InputProps<T extends TagComponentType = "div"> = Omit<TagProps<T>, "size" |
|
|
|
25
25
|
endIcon?: useBreakpointPropsType<ReactElement>;
|
|
26
26
|
iconPlacement?: useBreakpointPropsType<"start" | "center" | "end">;
|
|
27
27
|
focused?: boolean;
|
|
28
|
-
color?: useBreakpointPropsType<Omit<UseColorTemplateColor,
|
|
28
|
+
color?: useBreakpointPropsType<Omit<UseColorTemplateColor, 'surface'>>;
|
|
29
29
|
variant?: useBreakpointPropsType<"fill" | "outline" | "text">;
|
|
30
30
|
error?: boolean;
|
|
31
31
|
helperText?: useBreakpointPropsType<string>;
|
|
32
32
|
multiline?: boolean;
|
|
33
33
|
size?: useBreakpointPropsType<"small" | "medium" | "large">;
|
|
34
34
|
refs?: {
|
|
35
|
-
inputRoot?:
|
|
36
|
-
label?:
|
|
37
|
-
rootContainer?:
|
|
38
|
-
input?:
|
|
39
|
-
helperText?:
|
|
35
|
+
inputRoot?: React__default.Ref<"div">;
|
|
36
|
+
label?: React__default.Ref<"label">;
|
|
37
|
+
rootContainer?: React__default.Ref<"div">;
|
|
38
|
+
input?: React__default.Ref<'input' | 'textarea'>;
|
|
39
|
+
helperText?: React__default.Ref<"div">;
|
|
40
40
|
};
|
|
41
41
|
slotProps?: {
|
|
42
42
|
inputRoot?: Omit<TagProps<"div">, "children">;
|
|
@@ -46,7 +46,7 @@ type InputProps<T extends TagComponentType = "div"> = Omit<TagProps<T>, "size" |
|
|
|
46
46
|
input?: Partial<TagProps<T>>;
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
-
declare const Input:
|
|
49
|
+
declare const Input: React__default.ForwardRefExoticComponent<Omit<InputProps<TagComponentType>, "ref"> & React__default.RefAttributes<any>>;
|
|
50
50
|
|
|
51
51
|
export { Input as default };
|
|
52
52
|
export type { InputProps };
|