@xanui/ui 1.1.35 → 1.1.37
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/DataFilter/index.js +3 -3
- package/package.json +4 -4
- package/Accordion/index.mjs +0 -94
- package/Accordion/index.mjs.map +0 -1
- package/Alert/index.mjs +0 -119
- package/Alert/index.mjs.map +0 -1
- package/Autocomplete/index.mjs +0 -134
- package/Autocomplete/index.mjs.map +0 -1
- package/Avatar/index.mjs +0 -48
- package/Avatar/index.mjs.map +0 -1
- package/Badge/index.mjs +0 -107
- package/Badge/index.mjs.map +0 -1
- package/Box/index.mjs +0 -12
- package/Box/index.mjs.map +0 -1
- package/Button/index.mjs +0 -92
- package/Button/index.mjs.map +0 -1
- package/ButtonGroup/index.mjs +0 -56
- package/ButtonGroup/index.mjs.map +0 -1
- package/Calendar/index.mjs +0 -172
- package/Calendar/index.mjs.map +0 -1
- package/CalendarInput/index.mjs +0 -32
- package/CalendarInput/index.mjs.map +0 -1
- package/Checkbox/index.mjs +0 -56
- package/Checkbox/index.mjs.map +0 -1
- package/Chip/index.mjs +0 -74
- package/Chip/index.mjs.map +0 -1
- package/CircleProgress/index.mjs +0 -127
- package/CircleProgress/index.mjs.map +0 -1
- package/ClickOutside/index.mjs +0 -35
- package/ClickOutside/index.mjs.map +0 -1
- package/Collaps/index.mjs +0 -24
- package/Collaps/index.mjs.map +0 -1
- package/Container/index.mjs +0 -27
- package/Container/index.mjs.map +0 -1
- package/DataFilter/index.mjs +0 -67
- package/DataFilter/index.mjs.map +0 -1
- package/DataFilter/options/DateFilter.mjs +0 -30
- package/DataFilter/options/DateFilter.mjs.map +0 -1
- package/DataFilter/options/DateRangeFilter.mjs +0 -25
- package/DataFilter/options/DateRangeFilter.mjs.map +0 -1
- package/DataFilter/options/MultiSelectFilter.mjs +0 -36
- package/DataFilter/options/MultiSelectFilter.mjs.map +0 -1
- package/DataFilter/options/NumberFilter.mjs +0 -22
- package/DataFilter/options/NumberFilter.mjs.map +0 -1
- package/DataFilter/options/NumberRangeFilter.mjs +0 -27
- package/DataFilter/options/NumberRangeFilter.mjs.map +0 -1
- package/DataFilter/options/SelectFilter.mjs +0 -32
- package/DataFilter/options/SelectFilter.mjs.map +0 -1
- package/DataFilter/options/TextFilter.mjs +0 -22
- package/DataFilter/options/TextFilter.mjs.map +0 -1
- package/Datatable/FilterBox.mjs +0 -37
- package/Datatable/FilterBox.mjs.map +0 -1
- package/Datatable/Row.mjs +0 -57
- package/Datatable/Row.mjs.map +0 -1
- package/Datatable/SelectedBox.mjs +0 -19
- package/Datatable/SelectedBox.mjs.map +0 -1
- package/Datatable/Table.mjs +0 -21
- package/Datatable/Table.mjs.map +0 -1
- package/Datatable/TableHead.mjs +0 -59
- package/Datatable/TableHead.mjs.map +0 -1
- package/Datatable/index.mjs +0 -91
- package/Datatable/index.mjs.map +0 -1
- package/Divider/index.mjs +0 -29
- package/Divider/index.mjs.map +0 -1
- package/Drawer/index.mjs +0 -76
- package/Drawer/index.mjs.map +0 -1
- package/Form/index.mjs +0 -43
- package/Form/index.mjs.map +0 -1
- package/GridContainer/index.mjs +0 -17
- package/GridContainer/index.mjs.map +0 -1
- package/GridItem/index.mjs +0 -18
- package/GridItem/index.mjs.map +0 -1
- package/IconButton/index.mjs +0 -62
- package/IconButton/index.mjs.map +0 -1
- package/Image/index.mjs +0 -25
- package/Image/index.mjs.map +0 -1
- package/Input/index.mjs +0 -142
- package/Input/index.mjs.map +0 -1
- package/InputNumber/index.mjs +0 -30
- package/InputNumber/index.mjs.map +0 -1
- package/Label/index.mjs +0 -22
- package/Label/index.mjs.map +0 -1
- package/Layer/index.mjs +0 -60
- package/Layer/index.mjs.map +0 -1
- package/LineProgress/index.mjs +0 -57
- package/LineProgress/index.mjs.map +0 -1
- package/List/ListContext.mjs +0 -8
- package/List/ListContext.mjs.map +0 -1
- package/List/index.mjs +0 -61
- package/List/index.mjs.map +0 -1
- package/ListItem/index.mjs +0 -52
- package/ListItem/index.mjs.map +0 -1
- package/LoadingBox/index.mjs +0 -30
- package/LoadingBox/index.mjs.map +0 -1
- package/Menu/index.mjs +0 -148
- package/Menu/index.mjs.map +0 -1
- package/Modal/index.mjs +0 -57
- package/Modal/index.mjs.map +0 -1
- package/NoSSR/index.mjs +0 -13
- package/NoSSR/index.mjs.map +0 -1
- package/Option/index.mjs +0 -12
- package/Option/index.mjs.map +0 -1
- package/Paper/index.mjs +0 -13
- package/Paper/index.mjs.map +0 -1
- package/Portal/index.mjs +0 -25
- package/Portal/index.mjs.map +0 -1
- package/Radio/index.mjs +0 -14
- package/Radio/index.mjs.map +0 -1
- package/Scrollbar/index.mjs +0 -57
- package/Scrollbar/index.mjs.map +0 -1
- package/Select/index.mjs +0 -57
- package/Select/index.mjs.map +0 -1
- package/Skeleton/index.mjs +0 -58
- package/Skeleton/index.mjs.map +0 -1
- package/Stack/index.mjs +0 -15
- package/Stack/index.mjs.map +0 -1
- package/Switch/index.mjs +0 -77
- package/Switch/index.mjs.map +0 -1
- package/Tab/index.mjs +0 -15
- package/Tab/index.mjs.map +0 -1
- package/Table/index.mjs +0 -86
- package/Table/index.mjs.map +0 -1
- package/TableBody/index.mjs +0 -12
- package/TableBody/index.mjs.map +0 -1
- package/TableCell/index.mjs +0 -12
- package/TableCell/index.mjs.map +0 -1
- package/TableFooter/index.mjs +0 -12
- package/TableFooter/index.mjs.map +0 -1
- package/TableHead/index.mjs +0 -12
- package/TableHead/index.mjs.map +0 -1
- package/TablePagination/index.mjs +0 -57
- package/TablePagination/index.mjs.map +0 -1
- package/TableRow/index.mjs +0 -12
- package/TableRow/index.mjs.map +0 -1
- package/Tabs/index.mjs +0 -199
- package/Tabs/index.mjs.map +0 -1
- package/Text/index.mjs +0 -23
- package/Text/index.mjs.map +0 -1
- package/Toast/index.mjs +0 -118
- package/Toast/index.mjs.map +0 -1
- package/Tooltip/index.mjs +0 -38
- package/Tooltip/index.mjs.map +0 -1
- package/ViewBox/index.mjs +0 -30
- package/ViewBox/index.mjs.map +0 -1
- package/index.mjs +0 -65
- package/index.mjs.map +0 -1
- package/useAlert/index.mjs +0 -92
- package/useAlert/index.mjs.map +0 -1
- package/useBlurCss/index.mjs +0 -17
- package/useBlurCss/index.mjs.map +0 -1
- package/useCorner/index.mjs +0 -20
- package/useCorner/index.mjs.map +0 -1
- package/useLayer/index.mjs +0 -36
- package/useLayer/index.mjs.map +0 -1
- package/useModal/index.mjs +0 -35
- package/useModal/index.mjs.map +0 -1
package/DataFilter/index.js
CHANGED
|
@@ -16,7 +16,7 @@ var DateRangeFilter = require('./options/DateRangeFilter.js');
|
|
|
16
16
|
var React = require('react');
|
|
17
17
|
var core = require('@xanui/core');
|
|
18
18
|
|
|
19
|
-
const DataFilter
|
|
19
|
+
const DataFilter = (_a, ref) => {
|
|
20
20
|
var { inline, options, onChange, value } = _a, props = tslib.__rest(_a, ["inline", "options", "onChange", "value"]);
|
|
21
21
|
inline !== null && inline !== void 0 ? inline : (inline = false);
|
|
22
22
|
value !== null && value !== void 0 ? value : (value = {});
|
|
@@ -65,7 +65,7 @@ const DataFilter$1 = (_a, ref) => {
|
|
|
65
65
|
}
|
|
66
66
|
}) })));
|
|
67
67
|
};
|
|
68
|
-
var DataFilter = React.forwardRef(DataFilter
|
|
68
|
+
var DataFilter$1 = React.forwardRef(DataFilter);
|
|
69
69
|
|
|
70
70
|
exports.SelectFilter = SelectFilter;
|
|
71
71
|
exports.MultiSelectFilter = MultiSelectFilter;
|
|
@@ -74,5 +74,5 @@ exports.TextFilter = TextFilter;
|
|
|
74
74
|
exports.NumberRangeFilter = NumberRangeFilter;
|
|
75
75
|
exports.DateFilter = DateFilter;
|
|
76
76
|
exports.DateRangeFilter = DateRangeFilter;
|
|
77
|
-
exports.default = DataFilter;
|
|
77
|
+
exports.default = DataFilter$1;
|
|
78
78
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xanui/ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.37",
|
|
4
4
|
"description": "",
|
|
5
5
|
"private": false,
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@xanui/core": "^1.2.
|
|
8
|
-
"@xanui/icons": "^1.1.
|
|
7
|
+
"@xanui/core": "^1.2.39",
|
|
8
|
+
"@xanui/icons": "^1.1.10",
|
|
9
9
|
"pretty-class": "^1.0.8",
|
|
10
10
|
"react-state-bucket": "^1.2.6"
|
|
11
11
|
},
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"exports": {
|
|
15
15
|
"./*": {
|
|
16
|
-
"import": "./*/index.
|
|
16
|
+
"import": "./*/index.js",
|
|
17
17
|
"require": "./*/index.js",
|
|
18
18
|
"types": "./*/index.d.ts"
|
|
19
19
|
}
|
package/Accordion/index.mjs
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { __rest } from 'tslib';
|
|
3
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
-
import React, { useState } from 'react';
|
|
5
|
-
import { useInterface, useBreakpointProps, Tag } from '@xanui/core';
|
|
6
|
-
import ExpandIcon from '@xanui/icons/ExpandMore';
|
|
7
|
-
import Collaps from '../Collaps/index.mjs';
|
|
8
|
-
import List from '../List/index.mjs';
|
|
9
|
-
import ListItem from '../ListItem/index.mjs';
|
|
10
|
-
|
|
11
|
-
const Accordion = React.forwardRef((_a, ref) => {
|
|
12
|
-
var { children, title, subtitle } = _a, rest = __rest(_a, ["children", "title", "subtitle"]);
|
|
13
|
-
const [_expand, setExpand] = useState(false);
|
|
14
|
-
let [_b] = useInterface("Accordion", rest, {
|
|
15
|
-
onClick: () => setExpand(!_expand),
|
|
16
|
-
color: "brand",
|
|
17
|
-
variant: "soft"
|
|
18
|
-
}), { expand, onClick, color, variant, hoverColor, hoverVariant, expandIcon, expandIconPlacement, startIcon, endIcon, expandAction, classNames, slotProps } = _b, rootProps = __rest(_b, ["expand", "onClick", "color", "variant", "hoverColor", "hoverVariant", "expandIcon", "expandIconPlacement", "startIcon", "endIcon", "expandAction", "classNames", "slotProps"]);
|
|
19
|
-
const _p = {};
|
|
20
|
-
if (title)
|
|
21
|
-
_p.title = title;
|
|
22
|
-
if (subtitle)
|
|
23
|
-
_p.subtitle = subtitle;
|
|
24
|
-
if (startIcon)
|
|
25
|
-
_p.startIcon = startIcon;
|
|
26
|
-
if (endIcon)
|
|
27
|
-
_p.endIcon = endIcon;
|
|
28
|
-
if (expandIcon)
|
|
29
|
-
_p.expandIcon = expandIcon;
|
|
30
|
-
if (expandIconPlacement)
|
|
31
|
-
_p.expandIconPlacement = expandIconPlacement;
|
|
32
|
-
if (expandAction)
|
|
33
|
-
_p.expandAction = expandAction;
|
|
34
|
-
if (color)
|
|
35
|
-
_p.color = color;
|
|
36
|
-
if (variant)
|
|
37
|
-
_p.variant = variant;
|
|
38
|
-
if (hoverColor)
|
|
39
|
-
_p.hoverColor = hoverColor;
|
|
40
|
-
if (hoverVariant)
|
|
41
|
-
_p.hoverVariant = hoverVariant;
|
|
42
|
-
const p = useBreakpointProps(_p);
|
|
43
|
-
title = p.title;
|
|
44
|
-
subtitle = p.subtitle;
|
|
45
|
-
startIcon = p.startIcon;
|
|
46
|
-
endIcon = p.endIcon;
|
|
47
|
-
expandIcon = p.expandIcon;
|
|
48
|
-
expandIconPlacement = p.expandIconPlacement;
|
|
49
|
-
expandAction = p.expandAction;
|
|
50
|
-
color = p.color;
|
|
51
|
-
variant = p.variant;
|
|
52
|
-
hoverColor = p.hoverColor;
|
|
53
|
-
hoverVariant = p.hoverVariant;
|
|
54
|
-
expand = expand === undefined ? _expand : expand;
|
|
55
|
-
expandIcon = expandIcon ? jsx(Tag, Object.assign({ cursor: "pointer" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.expandIconContainer, { onClick: expandAction === 'icon' && onClick ? () => onClick() : () => { }, className: 'expand-icon-container', children: expandIcon })) : jsx(Tag, Object.assign({ transform: `rotate(${expand ? 0 : -180}deg)`, transition: "transform .4s", cursor: "pointer" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.expandIconContainer, { onClick: expandAction === 'icon' && onClick ? () => onClick() : () => { }, className: 'expand-icon-container', children: jsx(ExpandIcon, {}) }));
|
|
56
|
-
let itemsx = {};
|
|
57
|
-
if (expandIconPlacement === 'start') {
|
|
58
|
-
itemsx = {
|
|
59
|
-
startIcon: jsxs(Tag, { className: 'start-icon-container', sxr: {
|
|
60
|
-
display: "flex",
|
|
61
|
-
flexDirection: "row",
|
|
62
|
-
alignItems: "center",
|
|
63
|
-
gap: 1
|
|
64
|
-
}, children: [expandIcon, startIcon] }),
|
|
65
|
-
endIcon
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
itemsx = {
|
|
70
|
-
endIcon: jsxs(Tag, { className: 'end-icon-container', sxr: {
|
|
71
|
-
display: "flex",
|
|
72
|
-
flexDirection: "row",
|
|
73
|
-
alignItems: "center",
|
|
74
|
-
gap: 1
|
|
75
|
-
}, children: [endIcon, expandIcon] }),
|
|
76
|
-
startIcon
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
if (expandAction === 'icon') {
|
|
80
|
-
itemsx.onClick = () => { };
|
|
81
|
-
itemsx.cursor = "initial!important";
|
|
82
|
-
}
|
|
83
|
-
return (jsx(Tag, Object.assign({}, rootProps, { sxr: {
|
|
84
|
-
bgcolor: "background.primary"
|
|
85
|
-
}, baseClass: 'accordion', classNames: [{ "accordion-expanded": expand }, ...(classNames || [])], ref: ref, children: jsxs(List, Object.assign({ component: 'div' }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.header, { color: color, variant: variant, hoverColor: hoverColor, hoverVariant: hoverVariant, className: 'accoutdion-header', children: [jsx(ListItem, Object.assign({ minHeight: 55, radius: 0, component: 'div' }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.headerContent, itemsx, { subtitle: subtitle, selected: expand, onClick: () => onClick && onClick(), className: "accordion-header-content", children: title })), jsx(Collaps, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.collaps, { open: expand, className: "accordion-collaps", children: jsx(Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.content, { sxr: {
|
|
86
|
-
color: "text.primary",
|
|
87
|
-
p: 2,
|
|
88
|
-
py: 1,
|
|
89
|
-
bgcolor: "background.primary"
|
|
90
|
-
}, baseClass: 'accordion-content', children: children })) }))] })) })));
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
export { Accordion as default };
|
|
94
|
-
//# sourceMappingURL=index.mjs.map
|
package/Accordion/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Accordion/index.tsx"],"sourcesContent":["\"use client\";\r\nimport React, { ReactElement, useState } from 'react';\r\nimport { Tag, TagProps, useInterface, UseColorTemplateColor, UseColorTemplateType, TagComponentType, useBreakpointPropsType, useBreakpointProps } from '@xanui/core';\r\nimport ExpandIcon from \"@xanui/icons/ExpandMore\";\r\nimport Collaps, { CollapsProps } from '../Collaps';\r\nimport List, { ListProps } from '../List';\r\nimport ListItem, { ListItemProps } from '../ListItem';\r\n\r\nexport type AccordionProps<T extends TagComponentType = \"div\"> = Omit<TagProps<T>, \"color\"> & {\r\n expand?: boolean;\r\n onClick?: () => void;\r\n title: useBreakpointPropsType<ReactElement | string>;\r\n subtitle?: useBreakpointPropsType<ReactElement | string>;\r\n startIcon?: useBreakpointPropsType<ReactElement>;\r\n endIcon?: useBreakpointPropsType<ReactElement>;\r\n expandIcon?: useBreakpointPropsType<ReactElement>;\r\n expandIconPlacement?: useBreakpointPropsType<\"start\" | \"end\">;\r\n expandAction?: useBreakpointPropsType<\"header\" | \"icon\">;\r\n color?: useBreakpointPropsType<UseColorTemplateColor>;\r\n variant?: useBreakpointPropsType<UseColorTemplateType>;\r\n hoverColor?: useBreakpointPropsType<UseColorTemplateColor>;\r\n hoverVariant?: useBreakpointPropsType<UseColorTemplateType>;\r\n\r\n slotProps?: {\r\n header?: Omit<ListProps, \"children\" | \"color\" | \"variant\" | \"hoverColor\" | \"hoverVariant\" | \"className\">;\r\n headerContent?: Omit<ListItemProps, \"children\" | \"subtitle\" | \"selected\" | \"startIcon\" | \"endIcon\" | \"onClick\" | \"className\">\r\n collaps?: Omit<CollapsProps, \"children\" | \"in\">;\r\n content?: Omit<TagProps, \"children\">;\r\n expandIconContainer?: Omit<TagProps<\"div\">, 'children' | 'className'>;\r\n }\r\n}\r\n\r\nconst Accordion = React.forwardRef(<T extends TagComponentType = \"div\">({ children, title, subtitle, ...rest }: AccordionProps<T>, ref: React.Ref<any>) => {\r\n const [_expand, setExpand] = useState(false)\r\n let [{\r\n expand,\r\n onClick,\r\n color,\r\n variant,\r\n hoverColor,\r\n hoverVariant,\r\n expandIcon,\r\n expandIconPlacement,\r\n startIcon,\r\n endIcon,\r\n expandAction,\r\n classNames,\r\n slotProps,\r\n ...rootProps\r\n }] = useInterface<any>(\"Accordion\", rest, {\r\n onClick: () => setExpand(!_expand) as any,\r\n color: \"brand\",\r\n variant: \"soft\"\r\n })\r\n\r\n const _p: any = {}\r\n if (title) _p.title = title\r\n if (subtitle) _p.subtitle = subtitle\r\n if (startIcon) _p.startIcon = startIcon\r\n if (endIcon) _p.endIcon = endIcon\r\n if (expandIcon) _p.expandIcon = expandIcon\r\n if (expandIconPlacement) _p.expandIconPlacement = expandIconPlacement\r\n if (expandAction) _p.expandAction = expandAction\r\n if (color) _p.color = color\r\n if (variant) _p.variant = variant\r\n if (hoverColor) _p.hoverColor = hoverColor\r\n if (hoverVariant) _p.hoverVariant = hoverVariant\r\n\r\n const p: any = useBreakpointProps(_p)\r\n\r\n title = p.title\r\n subtitle = p.subtitle\r\n startIcon = p.startIcon\r\n endIcon = p.endIcon\r\n expandIcon = p.expandIcon\r\n expandIconPlacement = p.expandIconPlacement\r\n expandAction = p.expandAction\r\n color = p.color\r\n variant = p.variant\r\n hoverColor = p.hoverColor\r\n hoverVariant = p.hoverVariant\r\n\r\n expand = expand === undefined ? _expand : expand\r\n expandIcon = expandIcon ? <Tag\r\n cursor=\"pointer\"\r\n {...slotProps?.expandIconContainer}\r\n onClick={expandAction === 'icon' && onClick ? () => onClick() : () => { }}\r\n className='expand-icon-container'\r\n >\r\n {expandIcon}\r\n </Tag> : <Tag\r\n transform={`rotate(${expand ? 0 : -180}deg)`}\r\n transition=\"transform .4s\"\r\n cursor=\"pointer\"\r\n {...slotProps?.expandIconContainer}\r\n onClick={expandAction === 'icon' && onClick ? () => onClick() : () => { }}\r\n className='expand-icon-container'\r\n >\r\n <ExpandIcon />\r\n </Tag>\r\n\r\n let itemsx: any = {}\r\n\r\n if (expandIconPlacement === 'start') {\r\n itemsx = {\r\n startIcon: <Tag\r\n className='start-icon-container'\r\n sxr={{\r\n display: \"flex\",\r\n flexDirection: \"row\",\r\n alignItems: \"center\",\r\n gap: 1\r\n }}\r\n >\r\n {expandIcon}\r\n {startIcon}\r\n </Tag>,\r\n endIcon\r\n }\r\n\r\n } else {\r\n itemsx = {\r\n endIcon: <Tag\r\n className='end-icon-container'\r\n sxr={{\r\n display: \"flex\",\r\n flexDirection: \"row\",\r\n alignItems: \"center\",\r\n gap: 1\r\n }}\r\n >\r\n {endIcon}\r\n {expandIcon}\r\n </Tag>,\r\n startIcon\r\n }\r\n }\r\n\r\n if (expandAction === 'icon') {\r\n itemsx.onClick = () => { }\r\n itemsx.cursor = \"initial!important\"\r\n }\r\n\r\n return (\r\n <Tag\r\n {...rootProps}\r\n sxr={{\r\n bgcolor: \"background.primary\"\r\n }}\r\n baseClass='accordion'\r\n classNames={[{ \"accordion-expanded\": expand }, ...(classNames || [])]}\r\n ref={ref}\r\n >\r\n <List\r\n component='div'\r\n {...slotProps?.header}\r\n color={color}\r\n variant={variant}\r\n hoverColor={hoverColor}\r\n hoverVariant={hoverVariant}\r\n className='accoutdion-header'\r\n >\r\n <ListItem\r\n minHeight={55}\r\n radius={0}\r\n component='div'\r\n {...slotProps?.headerContent}\r\n {...itemsx}\r\n subtitle={subtitle}\r\n selected={expand}\r\n onClick={() => onClick && onClick()}\r\n className=\"accordion-header-content\"\r\n >{title}</ListItem>\r\n <Collaps\r\n {...slotProps?.collaps}\r\n open={expand}\r\n className=\"accordion-collaps\"\r\n >\r\n <Tag\r\n {...slotProps?.content}\r\n sxr={{\r\n color: \"text.primary\",\r\n p: 2,\r\n py: 1,\r\n bgcolor: \"background.primary\"\r\n }}\r\n baseClass='accordion-content'\r\n >\r\n {children}\r\n </Tag>\r\n </Collaps>\r\n </List>\r\n </Tag>\r\n )\r\n})\r\nexport default Accordion\r\n\r\n\r\n"],"names":[],"mappings":";;;;;;;;;;AAgCA;;;AAEI;;AAiBI;AACA;AACH;;AAGD;AAAW;AACX;AAAc;AACd;AAAe;AACf;AAAa;AACb;AAAgB;AAChB;AAAyB;AACzB;AAAkB;AAClB;AAAW;AACX;AAAa;AACb;AAAgB;AAChB;AAAkB;AAElB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;;AAqBA;AACI;;AAIY;AACA;AACA;AACA;;;;;;AAUZ;;AAIY;AACA;AACA;AACA;;;;;AAUhB;AACI;AACA;;AAGJ;AAIY;AACH;AAiCe;AACA;AACA;AACA;;AAU5B;;"}
|
package/Alert/index.mjs
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { __rest } from 'tslib';
|
|
3
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import { useInterface, useBreakpointProps, useColorTemplate, Tag, Renderar } from '@xanui/core';
|
|
5
|
-
import { isValidElement, useRef, useEffect } from 'react';
|
|
6
|
-
import Text from '../Text/index.mjs';
|
|
7
|
-
import InfoIcon from '@xanui/icons/Info';
|
|
8
|
-
import WarningIcon from '@xanui/icons/Warning';
|
|
9
|
-
import SuccessIcon from '@xanui/icons/CheckCircle';
|
|
10
|
-
import ErrorIcon from '@xanui/icons/Cancel';
|
|
11
|
-
import Close from '@xanui/icons/Close';
|
|
12
|
-
import IconButton from '../IconButton/index.mjs';
|
|
13
|
-
import useAlert from '../useAlert/index.mjs';
|
|
14
|
-
|
|
15
|
-
const Alert = (_a) => {
|
|
16
|
-
var { children } = _a, rest = __rest(_a, ["children"]);
|
|
17
|
-
let [_b] = useInterface("Alert", rest, {
|
|
18
|
-
variant: "fill"
|
|
19
|
-
}), { title, variant, icon, color, direction, slotProps, onClose } = _b, _props = __rest(_b, ["title", "variant", "icon", "color", "direction", "slotProps", "onClose"]);
|
|
20
|
-
color !== null && color !== void 0 ? color : (color = "default");
|
|
21
|
-
direction !== null && direction !== void 0 ? direction : (direction = "row");
|
|
22
|
-
const _p = {};
|
|
23
|
-
if (title)
|
|
24
|
-
_p.title = title;
|
|
25
|
-
if (variant)
|
|
26
|
-
_p.variant = variant;
|
|
27
|
-
if (icon)
|
|
28
|
-
_p.icon = icon;
|
|
29
|
-
if (color)
|
|
30
|
-
_p.color = color;
|
|
31
|
-
if (direction)
|
|
32
|
-
_p.direction = direction;
|
|
33
|
-
const p = useBreakpointProps(_p);
|
|
34
|
-
title = p.title;
|
|
35
|
-
variant = p.variant;
|
|
36
|
-
icon = p.icon;
|
|
37
|
-
color = p.color;
|
|
38
|
-
direction = p.direction;
|
|
39
|
-
let isRow = direction === 'row';
|
|
40
|
-
const template = useColorTemplate(color, variant);
|
|
41
|
-
let iconsx = {
|
|
42
|
-
fontSize: isRow ? 22 : 40,
|
|
43
|
-
color: color === 'default' ? "text.primary" : template.primary.color
|
|
44
|
-
};
|
|
45
|
-
const icons = {
|
|
46
|
-
"info": jsx(InfoIcon, { sx: iconsx }),
|
|
47
|
-
"warning": jsx(WarningIcon, { sx: iconsx }),
|
|
48
|
-
"success": jsx(SuccessIcon, { sx: iconsx }),
|
|
49
|
-
"danger": jsx(ErrorIcon, { sx: iconsx })
|
|
50
|
-
};
|
|
51
|
-
let _icon = icons[icon] || icons[color];
|
|
52
|
-
return (jsxs(Tag, Object.assign({}, _props, { baseClass: "alert", sxr: Object.assign({ justifyContent: "flex-start", position: "relative", radius: 1, px: isRow ? (_icon ? .5 : 2) : 3, py: isRow ? .5 : 3, flexDirection: "column", display: 'flex' }, _props === null || _props === void 0 ? void 0 : _props.sx) }, template.primary, { children: [onClose && jsx(IconButton, { color: color, variant: variant === 'fill' ? "fill" : "text", size: 25, sx: {
|
|
53
|
-
position: "absolute",
|
|
54
|
-
top: 5,
|
|
55
|
-
right: 5
|
|
56
|
-
}, onClick: onClose, className: "alert-close-button", children: jsx(Close, { fontSize: 18 }) }), jsxs(Tag, { sx: {
|
|
57
|
-
display: "flex",
|
|
58
|
-
gap: 1,
|
|
59
|
-
flexDirection: direction,
|
|
60
|
-
alignItems: isRow ? "flex-start" : "center"
|
|
61
|
-
}, baseClass: "alert-container", children: [_icon && jsx(Tag, { baseClass: "alert-icon", sxr: {
|
|
62
|
-
display: "flex",
|
|
63
|
-
alignItems: "center",
|
|
64
|
-
justifyContent: "center",
|
|
65
|
-
p: isRow ? 1 : 0,
|
|
66
|
-
"& svg": {
|
|
67
|
-
color: template.primary.color
|
|
68
|
-
}
|
|
69
|
-
}, children: _icon }), jsxs(Tag, { baseClass: "alert-content", sxr: {
|
|
70
|
-
display: "flex",
|
|
71
|
-
flexDirection: "column",
|
|
72
|
-
flex: 1,
|
|
73
|
-
color: template.primary.color,
|
|
74
|
-
py: 1,
|
|
75
|
-
textAlign: isRow ? "left" : "center",
|
|
76
|
-
gap: isRow ? 0 : 1
|
|
77
|
-
}, children: [title && jsx(Fragment, { children: isValidElement(title) ? jsx(Tag, { className: "alert-title", children: title }) : jsx(Text, { className: "alert-title", variant: "text", sx: {
|
|
78
|
-
font: "text",
|
|
79
|
-
fontWeight: "bold!important",
|
|
80
|
-
color: template.primary.color
|
|
81
|
-
}, children: title }) }), jsx(Tag, { sxr: {
|
|
82
|
-
font: "button",
|
|
83
|
-
}, children: children })] })] })] })));
|
|
84
|
-
};
|
|
85
|
-
const ActionAlert = (props) => {
|
|
86
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
87
|
-
const ref = useRef(null);
|
|
88
|
-
const alert = useAlert(Object.assign(Object.assign({}, props), { slotProps: Object.assign(Object.assign({}, props.slotProps), { modal: Object.assign(Object.assign({}, (_a = props.slotProps) === null || _a === void 0 ? void 0 : _a.modal), { slotProps: Object.assign(Object.assign({}, (_c = (_b = props.slotProps) === null || _b === void 0 ? void 0 : _b.modal) === null || _c === void 0 ? void 0 : _c.slotProps), { layer: Object.assign(Object.assign({}, (_f = (_e = (_d = props.slotProps) === null || _d === void 0 ? void 0 : _d.modal) === null || _e === void 0 ? void 0 : _e.slotProps) === null || _f === void 0 ? void 0 : _f.layer), { portal: Object.assign(Object.assign({}, (_k = (_j = (_h = (_g = props.slotProps) === null || _g === void 0 ? void 0 : _g.modal) === null || _h === void 0 ? void 0 : _h.slotProps) === null || _j === void 0 ? void 0 : _j.layer) === null || _k === void 0 ? void 0 : _k.portal), { container: ref.current || undefined }) }) }) }) }) }));
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
if (props.open) {
|
|
91
|
-
alert.open();
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
alert.close();
|
|
95
|
-
}
|
|
96
|
-
}, [props.open]);
|
|
97
|
-
return jsx(Tag, { ref: ref });
|
|
98
|
-
};
|
|
99
|
-
Alert.confirm = (props) => {
|
|
100
|
-
var _a;
|
|
101
|
-
const a = Renderar.render(ActionAlert, Object.assign(Object.assign({ open: true }, props), { slotProps: Object.assign(Object.assign({}, props.slotProps), { modal: Object.assign(Object.assign({}, (_a = props.slotProps) === null || _a === void 0 ? void 0 : _a.modal), { onClosed: () => {
|
|
102
|
-
var _a, _b, _c, _d;
|
|
103
|
-
a.unrender();
|
|
104
|
-
if ((_b = (_a = props === null || props === void 0 ? void 0 : props.slotProps) === null || _a === void 0 ? void 0 : _a.modal) === null || _b === void 0 ? void 0 : _b.onClosed) {
|
|
105
|
-
(_d = (_c = props.slotProps) === null || _c === void 0 ? void 0 : _c.modal) === null || _d === void 0 ? void 0 : _d.onClosed();
|
|
106
|
-
}
|
|
107
|
-
} }) }) }));
|
|
108
|
-
return {
|
|
109
|
-
open: () => {
|
|
110
|
-
a.updateProps({ open: true });
|
|
111
|
-
},
|
|
112
|
-
close: () => {
|
|
113
|
-
a.updateProps({ open: false });
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export { Alert as default };
|
|
119
|
-
//# sourceMappingURL=index.mjs.map
|
package/Alert/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Alert/index.tsx"],"sourcesContent":["\"use client\";\r\nimport { Tag, TagProps, useBreakpointProps, useColorTemplate, useInterface, useBreakpointPropsType, Renderar, UseColorTemplateType, UseColorTemplateColor } from \"@xanui/core\"\r\nimport React, { isValidElement, ReactElement, useEffect, useRef } from \"react\"\r\nimport Text from \"../Text\"\r\nimport InfoIcon from '@xanui/icons/Info';\r\nimport WarningIcon from '@xanui/icons/Warning';\r\nimport SuccessIcon from '@xanui/icons/CheckCircle';\r\nimport ErrorIcon from '@xanui/icons/Cancel';\r\nimport IconClose from '@xanui/icons/Close';\r\nimport IconButton from \"../IconButton\";\r\nimport useAlert, { UseAlerProps } from \"../useAlert\";\r\n\r\n\r\nexport type AlertProps = Omit<TagProps<\"div\">, \"content\" | \"title\" | \"direction\"> & {\r\n title?: useBreakpointPropsType<string | ReactElement>;\r\n direction?: useBreakpointPropsType<\"row\" | \"column\">;\r\n variant?: useBreakpointPropsType<UseColorTemplateType>;\r\n color?: useBreakpointPropsType<UseColorTemplateColor>;\r\n icon?: useBreakpointPropsType<\"info\" | \"warning\" | \"success\" | \"error\" | false | ReactElement>;\r\n onClose?: React.DOMAttributes<\"button\">['onClick'];\r\n}\r\n\r\nexport type AlertMesssageType = string | ReactElement | AlertProps\r\n\r\nconst Alert = ({ children, ...rest }: AlertProps) => {\r\n let [{\r\n title,\r\n variant,\r\n icon,\r\n color,\r\n direction,\r\n slotProps,\r\n onClose,\r\n ..._props\r\n }] = useInterface<any>(\"Alert\", rest, {\r\n variant: \"fill\"\r\n })\r\n color ??= \"default\"\r\n direction ??= \"row\"\r\n\r\n const _p: any = {}\r\n if (title) _p.title = title\r\n if (variant) _p.variant = variant\r\n if (icon) _p.icon = icon\r\n if (color) _p.color = color\r\n if (direction) _p.direction = direction\r\n\r\n const p: any = useBreakpointProps(_p)\r\n\r\n title = p.title\r\n variant = p.variant\r\n icon = p.icon\r\n color = p.color\r\n direction = p.direction\r\n\r\n let isRow = direction === 'row'\r\n\r\n\r\n const template = useColorTemplate(color, variant)\r\n\r\n let iconsx = {\r\n fontSize: isRow ? 22 : 40,\r\n color: color === 'default' ? \"text.primary\" : template.primary.color\r\n }\r\n\r\n const icons: any = {\r\n \"info\": <InfoIcon sx={iconsx} />,\r\n \"warning\": <WarningIcon sx={iconsx} />,\r\n \"success\": <SuccessIcon sx={iconsx} />,\r\n \"danger\": <ErrorIcon sx={iconsx} />\r\n }\r\n\r\n let _icon = icons[icon] || icons[color]\r\n\r\n return (\r\n <Tag\r\n {..._props}\r\n baseClass=\"alert\"\r\n sxr={{\r\n justifyContent: \"flex-start\",\r\n position: \"relative\",\r\n radius: 1,\r\n px: isRow ? (_icon ? .5 : 2) : 3,\r\n py: isRow ? .5 : 3,\r\n flexDirection: \"column\",\r\n display: 'flex',\r\n ..._props?.sx\r\n }}\r\n {...template.primary}\r\n >\r\n {\r\n onClose && <IconButton\r\n color={color}\r\n variant={variant === 'fill' ? \"fill\" : \"text\"}\r\n size={25}\r\n sx={{\r\n position: \"absolute\",\r\n top: 5,\r\n right: 5\r\n }}\r\n onClick={onClose}\r\n className=\"alert-close-button\"\r\n >\r\n <IconClose fontSize={18} />\r\n </IconButton>\r\n }\r\n <Tag\r\n sx={{\r\n display: \"flex\",\r\n gap: 1,\r\n flexDirection: direction,\r\n alignItems: isRow ? \"flex-start\" : \"center\"\r\n }}\r\n baseClass=\"alert-container\"\r\n >\r\n {\r\n _icon && <Tag\r\n baseClass=\"alert-icon\"\r\n sxr={{\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"center\",\r\n p: isRow ? 1 : 0,\r\n \"& svg\": {\r\n color: template.primary.color\r\n }\r\n }}\r\n >\r\n {_icon}\r\n </Tag>\r\n }\r\n <Tag\r\n baseClass=\"alert-content\"\r\n sxr={{\r\n display: \"flex\",\r\n flexDirection: \"column\",\r\n flex: 1,\r\n color: template.primary.color,\r\n py: 1,\r\n textAlign: isRow ? \"left\" : \"center\",\r\n gap: isRow ? 0 : 1\r\n }}\r\n >\r\n {title && <>\r\n {\r\n isValidElement(title) ? <Tag className=\"alert-title\">{title}</Tag> : <Text\r\n className=\"alert-title\"\r\n variant=\"text\"\r\n sx={{\r\n font: \"text\",\r\n fontWeight: \"bold!important\",\r\n color: template.primary.color\r\n }}\r\n >{title}</Text>\r\n }\r\n </>}\r\n <Tag\r\n sxr={{\r\n font: \"button\",\r\n }}\r\n >\r\n {children}\r\n </Tag>\r\n </Tag>\r\n </Tag>\r\n </Tag>\r\n )\r\n}\r\n\r\nconst ActionAlert = (props: UseAlerProps) => {\r\n const ref = useRef<HTMLDivElement>(null);\r\n const alert = useAlert({\r\n ...props,\r\n slotProps: {\r\n ...props.slotProps,\r\n modal: {\r\n ...props.slotProps?.modal,\r\n slotProps: {\r\n ...props.slotProps?.modal?.slotProps,\r\n layer: {\r\n ...props.slotProps?.modal?.slotProps?.layer,\r\n portal: {\r\n ...props.slotProps?.modal?.slotProps?.layer?.portal,\r\n container: ref.current || undefined\r\n }\r\n }\r\n }\r\n }\r\n }\r\n })\r\n\r\n useEffect(() => {\r\n if (props.open) {\r\n alert.open()\r\n } else {\r\n alert.close()\r\n }\r\n }, [props.open])\r\n return <Tag ref={ref}></Tag>\r\n}\r\n\r\nAlert.confirm = (props: UseAlerProps) => {\r\n const a = Renderar.render(ActionAlert as any, {\r\n open: true,\r\n ...props,\r\n slotProps: {\r\n ...props.slotProps,\r\n modal: {\r\n ...props.slotProps?.modal,\r\n onClosed: () => {\r\n a.unrender()\r\n if (props?.slotProps?.modal?.onClosed) {\r\n props.slotProps?.modal?.onClosed()\r\n }\r\n },\r\n }\r\n },\r\n })\r\n\r\n return {\r\n open: () => {\r\n a.updateProps({ open: true })\r\n },\r\n close: () => {\r\n a.updateProps({ open: false })\r\n },\r\n }\r\n}\r\n\r\nexport default Alert"],"names":[],"mappings":";;;;;;;;;;;;;;AAwBA;AAAe;AACX;AAUI;;;;;AAMJ;AAAW;AACX;AAAa;AACb;AAAU;AACV;AAAW;AACX;AAAe;AAEf;AAEA;AACA;AACA;AACA;AACA;AAEA;;AAKA;;AAEI;;AAGJ;AACI;AACA;AACA;AACA;;;;AA2BgB;AACA;AACA;;AAUJ;AACA;AACA;;AAEH;AAOW;AACA;AACA;;AAEA;AACI;AACH;;AASL;AACA;AACA;AACA;AACA;;;AAGH;AAQe;AACA;AACA;;AAOR;AACH;AAQzB;AAEA;;AACI;AACA;;AAqBI;;;;;;AAKJ;AACA;AACJ;AAEA;;AACI;;;AASgB;;;AAGJ;;;;;;;;;AAahB;;"}
|
package/Autocomplete/index.mjs
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import Input from '../Input/index.mjs';
|
|
5
|
-
import Menu from '../Menu/index.mjs';
|
|
6
|
-
import List from '../List/index.mjs';
|
|
7
|
-
import ListItem from '../ListItem/index.mjs';
|
|
8
|
-
import Chip from '../Chip/index.mjs';
|
|
9
|
-
import IconButton from '../IconButton/index.mjs';
|
|
10
|
-
import Close from '@xanui/icons/Close';
|
|
11
|
-
import CircleProgress from '../CircleProgress/index.mjs';
|
|
12
|
-
|
|
13
|
-
const Autocomplete = (_a) => {
|
|
14
|
-
var { value, onChange, renderOption, options, getLabel, multiple } = _a, inputProps = __rest(_a, ["value", "onChange", "renderOption", "options", "getLabel", "multiple"]);
|
|
15
|
-
const [_options, setOptions] = React.useState();
|
|
16
|
-
const [inputValue, setInputValue] = React.useState("");
|
|
17
|
-
const [timer, setTimer] = React.useState(null);
|
|
18
|
-
const [loading, setLoading] = React.useState(false);
|
|
19
|
-
const [open, setOpen] = React.useState(false);
|
|
20
|
-
const menuRef = React.useRef(null);
|
|
21
|
-
getLabel !== null && getLabel !== void 0 ? getLabel : (getLabel = (option) => option.toString());
|
|
22
|
-
multiple !== null && multiple !== void 0 ? multiple : (multiple = false);
|
|
23
|
-
let startIcons = [
|
|
24
|
-
inputProps.startIcon
|
|
25
|
-
];
|
|
26
|
-
if (!!value && multiple && Array.isArray(value)) {
|
|
27
|
-
value.map((v, index) => {
|
|
28
|
-
startIcons.push(jsx(Chip, { size: "small", label: getLabel(v), variant: "fill", color: "default", endIcon: jsx(IconButton, { size: 20, variant: "text", color: "default", onClick: (e) => {
|
|
29
|
-
e.stopPropagation();
|
|
30
|
-
let newValue = Array.isArray(value) ? [...value] : [];
|
|
31
|
-
newValue = newValue.filter((val) => getLabel(val) !== getLabel(v));
|
|
32
|
-
onChange && onChange(newValue);
|
|
33
|
-
}, children: jsx(Close, {}) }) }, index));
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
let endIcons = [
|
|
37
|
-
inputProps.endIcon
|
|
38
|
-
];
|
|
39
|
-
if (loading) {
|
|
40
|
-
endIcons.push(jsx(CircleProgress, { size: "small" }, "auto-complete-loading-icon"));
|
|
41
|
-
}
|
|
42
|
-
else if (!!value && !multiple) {
|
|
43
|
-
endIcons.push(jsx(IconButton, { variant: "text", color: "default", onClick: (e) => {
|
|
44
|
-
e.stopPropagation();
|
|
45
|
-
onChange && onChange(undefined);
|
|
46
|
-
setInputValue("");
|
|
47
|
-
}, children: jsx(Close, {}) }, "auto-complete-clear-button"));
|
|
48
|
-
}
|
|
49
|
-
return (jsxs(Fragment, { children: [jsx(Input, Object.assign({}, inputProps, { ref: menuRef, slotProps: {
|
|
50
|
-
rootContainer: Object.assign({ flexWrap: 'wrap' }, (multiple ? { height: "auto", gap: .5 } : {})),
|
|
51
|
-
input: {
|
|
52
|
-
width: multiple ? 'auto' : '100%',
|
|
53
|
-
flex: 1,
|
|
54
|
-
minWidth: 20,
|
|
55
|
-
}
|
|
56
|
-
}, startIcon: startIcons, endIcon: endIcons, value: inputValue, onKeyDown: (e) => {
|
|
57
|
-
if (inputProps === null || inputProps === void 0 ? void 0 : inputProps.onKeyDown) {
|
|
58
|
-
inputProps.onKeyDown(e);
|
|
59
|
-
}
|
|
60
|
-
if (multiple && e.key === 'Backspace' && inputValue === "" && Array.isArray(value) && value.length > 0) {
|
|
61
|
-
let newValue = [...value];
|
|
62
|
-
newValue.pop();
|
|
63
|
-
onChange && onChange(newValue);
|
|
64
|
-
}
|
|
65
|
-
}, onChange: (e) => {
|
|
66
|
-
const value = e.target.value;
|
|
67
|
-
setInputValue(value);
|
|
68
|
-
if (!value) {
|
|
69
|
-
setOptions([]);
|
|
70
|
-
setOpen(false);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
setOpen(true);
|
|
74
|
-
clearTimeout(timer);
|
|
75
|
-
setTimer(setTimeout(async () => {
|
|
76
|
-
if (typeof options === 'function') {
|
|
77
|
-
setLoading(true);
|
|
78
|
-
const result = await options(value);
|
|
79
|
-
setOptions(result);
|
|
80
|
-
setLoading(false);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
const filtered = options.filter(option => getLabel(option).toLowerCase().includes(value.toLowerCase()));
|
|
84
|
-
setOptions(filtered);
|
|
85
|
-
}
|
|
86
|
-
}, 300));
|
|
87
|
-
} })), jsx(Menu, { target: open ? menuRef.current : null, onClickOutside: () => {
|
|
88
|
-
setOptions([]);
|
|
89
|
-
setInputValue("");
|
|
90
|
-
}, slotProps: {
|
|
91
|
-
content: { minWidth: menuRef.current ? menuRef.current.offsetWidth : 'auto' }
|
|
92
|
-
}, children: jsx(List, { maxHeight: 400, overflow: "auto", children: _options === null || _options === void 0 ? void 0 : _options.map((option, index) => (renderOption ? jsx("div", { children: renderOption(option, {
|
|
93
|
-
onClick: () => {
|
|
94
|
-
if (multiple) {
|
|
95
|
-
let newValue = Array.isArray(value) ? [...value] : [];
|
|
96
|
-
const has = newValue.find((v) => getLabel(v) === getLabel(option));
|
|
97
|
-
if (!has) {
|
|
98
|
-
newValue.push(option);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
newValue = newValue.filter((v) => getLabel(v) !== getLabel(option));
|
|
102
|
-
}
|
|
103
|
-
onChange && onChange(newValue);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
onChange && onChange(option);
|
|
107
|
-
setOpen(false);
|
|
108
|
-
setInputValue(getLabel(option));
|
|
109
|
-
setOptions([]);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}) }, "auto-complete" + index + getLabel(option)) : jsx(ListItem, { onClick: () => {
|
|
113
|
-
if (multiple) {
|
|
114
|
-
let newValue = Array.isArray(value) ? [...value] : [];
|
|
115
|
-
const has = newValue.find((v) => getLabel(v) === getLabel(option));
|
|
116
|
-
if (!has) {
|
|
117
|
-
newValue.push(option);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
newValue = newValue.filter((v) => getLabel(v) !== getLabel(option));
|
|
121
|
-
}
|
|
122
|
-
onChange && onChange(newValue);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
onChange && onChange(option);
|
|
126
|
-
setOpen(false);
|
|
127
|
-
setInputValue(getLabel(option));
|
|
128
|
-
setOptions([]);
|
|
129
|
-
}
|
|
130
|
-
}, children: getLabel(option) }, index))) }) })] }));
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export { Autocomplete as default };
|
|
134
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Autocomplete/index.tsx"],"sourcesContent":["import React, { ReactElement } from 'react'\r\nimport Input from '../Input'\r\nimport Menu from '../Menu'\r\nimport List from '../List';\r\nimport ListItem, { ListItemProps } from '../ListItem';\r\nimport Chip from '../Chip';\r\nimport IconButton from '../IconButton';\r\nimport Close from '@xanui/icons/Close';\r\nimport CircleProgress from '../CircleProgress';\r\nimport { useBreakpointPropsType, UseColorTemplateColor } from '@xanui/core';\r\n\r\nexport type AutocompleteProps = {\r\n\r\n options: any[] | ((text: string) => Promise<any[]>)\r\n getLabel: (option: any) => string;\r\n onChange?: (value: any) => void;\r\n value?: any;\r\n multiple?: boolean;\r\n renderOption?: (option: any, props: any) => ReactElement<ListItemProps>\r\n\r\n // input props customization\r\n name?: string;\r\n placeholder?: string;\r\n readOnly?: boolean;\r\n autoFocus?: boolean;\r\n autoComplete?: string;\r\n label?: useBreakpointPropsType<string>;\r\n\r\n onFocus?: (e: React.FocusEvent<any>) => void;\r\n onBlur?: (e: React.FocusEvent<any>) => void;\r\n onInput?: (e: React.FormEvent<any>) => void;\r\n onKeyDown?: (e: React.KeyboardEvent<any>) => void;\r\n onKeyUp?: (e: React.KeyboardEvent<any>) => void;\r\n\r\n rows?: useBreakpointPropsType<number>;\r\n minRows?: useBreakpointPropsType<number>;\r\n maxRows?: useBreakpointPropsType<number>;\r\n fullWidth?: boolean;\r\n\r\n startIcon?: useBreakpointPropsType<ReactElement>;\r\n endIcon?: useBreakpointPropsType<ReactElement>;\r\n iconPlacement?: useBreakpointPropsType<\"start\" | \"center\" | \"end\">;\r\n focused?: boolean;\r\n color?: useBreakpointPropsType<Omit<UseColorTemplateColor, \"default\">>;\r\n variant?: useBreakpointPropsType<\"fill\" | \"outline\" | \"text\">;\r\n error?: boolean;\r\n helperText?: useBreakpointPropsType<string>;\r\n\r\n}\r\n\r\nconst Autocomplete = ({ value, onChange, renderOption, options, getLabel, multiple, ...inputProps }: AutocompleteProps) => {\r\n const [_options, setOptions] = React.useState<any[]>()\r\n const [inputValue, setInputValue] = React.useState(\"\")\r\n const [timer, setTimer] = React.useState<any>(null)\r\n const [loading, setLoading] = React.useState(false)\r\n const [open, setOpen] = React.useState(false)\r\n const menuRef = React.useRef<any>(null)\r\n\r\n getLabel ??= (option: any) => option.toString();\r\n multiple ??= false;\r\n\r\n let startIcons = [\r\n inputProps.startIcon\r\n ]\r\n\r\n if (!!value && multiple && Array.isArray(value)) {\r\n value.map((v: any, index: number) => {\r\n startIcons.push(<Chip\r\n key={index}\r\n size=\"small\"\r\n label={getLabel!(v)}\r\n variant={\"fill\"}\r\n color=\"default\"\r\n endIcon={<IconButton\r\n size={20}\r\n variant={\"text\"}\r\n color=\"default\"\r\n onClick={(e) => {\r\n e.stopPropagation();\r\n let newValue = Array.isArray(value) ? [...value] : []\r\n newValue = newValue.filter((val: any) => getLabel!(val) !== getLabel!(v))\r\n onChange && onChange(newValue)\r\n }}\r\n >\r\n <Close />\r\n </IconButton>}\r\n />)\r\n })\r\n }\r\n\r\n let endIcons = [\r\n inputProps.endIcon\r\n ]\r\n\r\n if (loading) {\r\n endIcons.push(<CircleProgress\r\n key=\"auto-complete-loading-icon\"\r\n size=\"small\"\r\n />)\r\n } else if (!!value && !multiple) {\r\n endIcons.push(<IconButton\r\n key=\"auto-complete-clear-button\"\r\n variant={\"text\"}\r\n color=\"default\"\r\n onClick={(e) => {\r\n e.stopPropagation();\r\n onChange && onChange(undefined)\r\n setInputValue(\"\")\r\n }}\r\n >\r\n <Close />\r\n </IconButton>)\r\n }\r\n\r\n\r\n return (\r\n <>\r\n <Input\r\n {...inputProps as any}\r\n ref={menuRef}\r\n slotProps={{\r\n rootContainer: {\r\n flexWrap: 'wrap',\r\n ...(multiple ? { height: \"auto\", gap: .5 } : {})\r\n },\r\n input: {\r\n width: multiple ? 'auto' : '100%',\r\n flex: 1,\r\n minWidth: 20,\r\n }\r\n }}\r\n startIcon={startIcons}\r\n endIcon={endIcons}\r\n value={inputValue}\r\n onKeyDown={(e) => {\r\n if (inputProps?.onKeyDown) {\r\n inputProps.onKeyDown(e)\r\n }\r\n if (multiple && e.key === 'Backspace' && inputValue === \"\" && Array.isArray(value) && value.length > 0) {\r\n let newValue = [...value]\r\n newValue.pop()\r\n onChange && onChange(newValue)\r\n }\r\n }}\r\n onChange={(e) => {\r\n const value = e.target.value;\r\n setInputValue(value)\r\n if (!value) {\r\n setOptions([])\r\n setOpen(false)\r\n return;\r\n }\r\n setOpen(true)\r\n\r\n clearTimeout(timer)\r\n setTimer(setTimeout(async () => {\r\n if (typeof options === 'function') {\r\n setLoading(true)\r\n const result = await options(value)\r\n setOptions(result)\r\n setLoading(false)\r\n } else {\r\n const filtered = options.filter(option => getLabel!(option).toLowerCase().includes(value.toLowerCase()))\r\n setOptions(filtered)\r\n }\r\n }, 300))\r\n }}\r\n />\r\n <Menu\r\n target={open ? menuRef.current : null}\r\n onClickOutside={() => {\r\n setOptions([])\r\n setInputValue(\"\")\r\n }}\r\n slotProps={{\r\n content: { minWidth: menuRef.current ? menuRef.current.offsetWidth : 'auto' }\r\n }}\r\n >\r\n <List\r\n maxHeight={400}\r\n overflow={\"auto\"}\r\n >\r\n {_options?.map((option, index) => (\r\n renderOption ? <div key={\"auto-complete\" + index + getLabel!(option)}>{renderOption(option, {\r\n onClick: () => {\r\n if (multiple) {\r\n let newValue = Array.isArray(value) ? [...value] : []\r\n const has = newValue.find((v: any) => getLabel!(v) === getLabel!(option))\r\n if (!has) {\r\n newValue.push(option)\r\n } else {\r\n newValue = newValue.filter((v: any) => getLabel!(v) !== getLabel!(option))\r\n }\r\n onChange && onChange(newValue)\r\n } else {\r\n onChange && onChange(option)\r\n setOpen(false)\r\n setInputValue(getLabel!(option))\r\n setOptions([])\r\n }\r\n }\r\n })}</div> : <ListItem\r\n key={index}\r\n onClick={() => {\r\n if (multiple) {\r\n let newValue = Array.isArray(value) ? [...value] : []\r\n const has = newValue.find((v: any) => getLabel!(v) === getLabel!(option))\r\n if (!has) {\r\n newValue.push(option)\r\n } else {\r\n newValue = newValue.filter((v: any) => getLabel!(v) !== getLabel!(option))\r\n }\r\n onChange && onChange(newValue)\r\n } else {\r\n onChange && onChange(option)\r\n setOpen(false)\r\n setInputValue(getLabel!(option))\r\n setOptions([])\r\n }\r\n }}\r\n >\r\n {getLabel!(option)}\r\n </ListItem>\r\n ))}\r\n </List>\r\n </Menu>\r\n </>\r\n )\r\n}\r\n\r\nexport default Autocomplete\r\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;;;;;;AAkDA,MAAM,YAAY,GAAG,CAAC,EAAgG,KAAI;AAApG,IAAA,IAAA,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAA,GAAA,EAAoC,EAA/B,UAAU,GAAA,MAAA,CAAA,EAAA,EAA3E,wEAA6E,CAAF;IAC9F,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAS;AACtD,IAAA,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;AACtD,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAM,IAAI,CAAC;AACnD,IAAA,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;AACnD,IAAA,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAM,IAAI,CAAC;AAEvC,IAAA,QAAQ,aAAR,QAAQ,KAAA,MAAA,GAAR,QAAQ,IAAR,QAAQ,GAAK,CAAC,MAAW,KAAK,MAAM,CAAC,QAAQ,EAAE,CAAA;IAC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,CAAC,EAAE,CAAC;gCACjB;4BACH;AACF,yBAAA,CAAC,IAlBuB,eAAe,GAAG,KAAK,GAAG,QAAS,CAAC,MAAM,CAAC,CAkB3D,GAAGA,GAAA,CAAC,QAAQ,IAElB,OAAO,EAAE,MAAK;4BACX,IAAI,QAAQ,EAAE;AACX,gCAAA,IAAI,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE;gCACrD,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAM,KAAK,QAAS,CAAC,CAAC,CAAC,KAAK,QAAS,CAAC,MAAM,CAAC,CAAC;gCACzE,IAAI,CAAC,GAAG,EAAE;AACP,oCAAA,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;gCACxB;qCAAO;oCACJ,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAM,KAAK,QAAS,CAAC,CAAC,CAAC,KAAK,QAAS,CAAC,MAAM,CAAC,CAAC;gCAC7E;AACA,gCAAA,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC;4BACjC;iCAAO;AACJ,gCAAA,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC;gCAC5B,OAAO,CAAC,KAAK,CAAC;AACd,gCAAA,aAAa,CAAC,QAAS,CAAC,MAAM,CAAC,CAAC;gCAChC,UAAU,CAAC,EAAE,CAAC;4BACjB;AACH,wBAAA,CAAC,EAAA,QAAA,EAEA,QAAS,CAAC,MAAM,CAAC,EAAA,EAnBb,KAAK,CAoBF,CACb,CAAC,EAAA,CACE,EAAA,CACH,CAAA,EAAA,CACP;AAET;;;;"}
|
package/Avatar/index.mjs
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import React, { useState } from 'react';
|
|
4
|
-
import { useInterface, useBreakpointProps, Tag } from '@xanui/core';
|
|
5
|
-
import PersonIcon from '@xanui/icons/Person';
|
|
6
|
-
import Skeleton from '../Skeleton/index.mjs';
|
|
7
|
-
|
|
8
|
-
const Avatar = React.forwardRef((_a, ref) => {
|
|
9
|
-
var _b;
|
|
10
|
-
var { children, src, alt, skeleton } = _a, rest = __rest(_a, ["children", "src", "alt", "skeleton"]);
|
|
11
|
-
const [faild, setFaild] = useState();
|
|
12
|
-
let [_c] = useInterface("Avatar", rest, {}), { size, slotProps } = _c, props = __rest(_c, ["size", "slotProps"]);
|
|
13
|
-
size !== null && size !== void 0 ? size : (size = 36);
|
|
14
|
-
const _p = {};
|
|
15
|
-
if (size)
|
|
16
|
-
_p.size = size;
|
|
17
|
-
const p = useBreakpointProps(_p);
|
|
18
|
-
size = p.size;
|
|
19
|
-
if (skeleton) {
|
|
20
|
-
return jsx(Skeleton, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.skeleton, { height: size, width: size, animation: "wave", sx: Object.assign(Object.assign({}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.skeleton) === null || _b === void 0 ? void 0 : _b.sx), { borderRadius: size }) }));
|
|
21
|
-
}
|
|
22
|
-
if (faild === false || !src) {
|
|
23
|
-
let t = (alt === null || alt === void 0 ? void 0 : alt.charAt(0).toUpperCase()) || (children || jsx(PersonIcon, {}));
|
|
24
|
-
return (jsx(Tag, Object.assign({ component: "div", src: src }, props, { baseClass: 'avatar', sxr: {
|
|
25
|
-
display: "inline-flex",
|
|
26
|
-
justifyContent: "center",
|
|
27
|
-
alignItems: "center",
|
|
28
|
-
bgcolor: "background.secondary",
|
|
29
|
-
radius: size,
|
|
30
|
-
fontSize: (size / 3) * 2,
|
|
31
|
-
width: size,
|
|
32
|
-
height: size,
|
|
33
|
-
userSelect: "none",
|
|
34
|
-
color: "text.primary",
|
|
35
|
-
'& svg': {
|
|
36
|
-
fontSize: (size / 3) * 2,
|
|
37
|
-
opacity: .6
|
|
38
|
-
}
|
|
39
|
-
}, ref: ref, children: t })));
|
|
40
|
-
}
|
|
41
|
-
return (jsx(Tag, Object.assign({ component: "img", radius: size, width: size, height: size, objectFit: "cover" }, props, { alt: alt, src: src, baseClass: 'avatar', onError: (e) => {
|
|
42
|
-
setFaild(false);
|
|
43
|
-
props.onError && props.onError(e);
|
|
44
|
-
}, ref: ref })));
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
export { Avatar as default };
|
|
48
|
-
//# sourceMappingURL=index.mjs.map
|
package/Avatar/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Avatar/index.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { Tag, TagProps, TagComponentType, useInterface, useBreakpointPropsType, useBreakpointProps } from '@xanui/core';\r\nimport PersonIcon from '@xanui/icons/Person'\r\nimport Skeleton, { SkeletonProps } from '../Skeleton';\r\n\r\nexport type AvatarProps<T extends TagComponentType = \"img\"> = TagProps<T> & {\r\n size?: useBreakpointPropsType<number>;\r\n skeleton?: boolean;\r\n slotProps?: {\r\n skeleton?: Omit<SkeletonProps, \"height\" | \"width\" | \"loading\" | \"children\">\r\n }\r\n}\r\n\r\nconst Avatar = React.forwardRef(<T extends TagComponentType = \"img\">({ children, src, alt, skeleton, ...rest }: AvatarProps<T>, ref: any) => {\r\n const [faild, setFaild] = useState<boolean>()\r\n let [{ size, slotProps, ...props }] = useInterface<any>(\"Avatar\", rest, {})\r\n size ??= 36\r\n const _p: any = {}\r\n if (size) _p.size = size\r\n const p: any = useBreakpointProps(_p)\r\n size = p.size\r\n\r\n if (skeleton) {\r\n return <Skeleton\r\n {...slotProps?.skeleton}\r\n height={size}\r\n width={size}\r\n animation={\"wave\"}\r\n sx={{\r\n ...slotProps?.skeleton?.sx,\r\n borderRadius: size,\r\n }}\r\n />\r\n }\r\n\r\n if (faild === false || !src) {\r\n let t = alt?.charAt(0).toUpperCase() || (children || <PersonIcon />)\r\n return (\r\n <Tag\r\n component=\"div\"\r\n src={src}\r\n {...props}\r\n baseClass='avatar'\r\n sxr={{\r\n display: \"inline-flex\",\r\n justifyContent: \"center\",\r\n alignItems: \"center\",\r\n bgcolor: \"background.secondary\",\r\n radius: size,\r\n fontSize: (size / 3) * 2,\r\n width: size,\r\n height: size,\r\n userSelect: \"none\",\r\n color: \"text.primary\",\r\n '& svg': {\r\n fontSize: (size / 3) * 2,\r\n opacity: .6\r\n }\r\n }}\r\n ref={ref}\r\n >{t}</Tag>\r\n )\r\n }\r\n return (\r\n <Tag\r\n component=\"img\"\r\n radius={size}\r\n width={size}\r\n height={size}\r\n objectFit=\"cover\"\r\n {...props}\r\n alt={alt}\r\n src={src}\r\n baseClass='avatar'\r\n onError={(e) => {\r\n setFaild(false)\r\n props.onError && props.onError(e as any)\r\n }}\r\n ref={ref}\r\n />\r\n )\r\n})\r\n\r\nexport default Avatar\r\n\r\n\r\n"],"names":["_jsx"],"mappings":";;;;;;;AAaA,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAqC,EAAyD,EAAE,GAAQ,KAAI;;AAAvE,IAAA,IAAA,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAA,GAAA,EAA2B,EAAtB,IAAI,GAAA,MAAA,CAAA,EAAA,EAAvC,CAAA,UAAA,EAAA,KAAA,EAAA,KAAA,EAAA,UAAA,CAAyC,CAAF;IACxG,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAW;IAC7C,IAAI,CAAA,EAAA,CAAA,GAAkC,YAAY,CAAM,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,EAAtE,EAAE,IAAI,EAAE,SAAS,EAAA,GAAA,EAAY,EAAP,KAAK,GAAA,MAAA,CAAA,EAAA,EAA3B,CAAA,MAAA,EAAA,WAAA,CAA6B,CAAyC;IAC3E,IAAI,KAAA,IAAA,IAAJ,IAAI,KAAA,MAAA,GAAJ,IAAI,IAAJ,IAAI,GAAK,EA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