@xanui/ui 1.1.36 → 1.1.38
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.js +19 -21
- package/Accordion/index.js.map +1 -1
- package/Alert/index.js +33 -35
- package/Alert/index.js.map +1 -1
- package/Autocomplete/index.js +23 -25
- package/Autocomplete/index.js.map +1 -1
- package/Avatar/index.js +15 -17
- package/Avatar/index.js.map +1 -1
- package/Badge/index.js +12 -14
- package/Badge/index.js.map +1 -1
- package/Box/index.js +7 -9
- package/Box/index.js.map +1 -1
- package/Button/index.js +17 -19
- package/Button/index.js.map +1 -1
- package/ButtonGroup/index.js +12 -14
- package/ButtonGroup/index.js.map +1 -1
- package/Calendar/index.js +39 -41
- package/Calendar/index.js.map +1 -1
- package/CalendarInput/index.js +19 -21
- package/CalendarInput/index.js.map +1 -1
- package/Checkbox/index.js +14 -16
- package/Checkbox/index.js.map +1 -1
- package/Chip/index.js +12 -14
- package/Chip/index.js.map +1 -1
- package/CircleProgress/index.js +13 -15
- package/CircleProgress/index.js.map +1 -1
- package/ClickOutside/index.js +9 -11
- package/ClickOutside/index.js.map +1 -1
- package/Collaps/index.js +9 -11
- package/Collaps/index.js.map +1 -1
- package/Container/index.js +9 -11
- package/Container/index.js.map +1 -1
- package/DataFilter/index.js +30 -41
- package/DataFilter/index.js.map +1 -1
- package/DataFilter/options/DateFilter.js +16 -18
- package/DataFilter/options/DateFilter.js.map +1 -1
- package/DataFilter/options/DateRangeFilter.js +12 -14
- package/DataFilter/options/DateRangeFilter.js.map +1 -1
- package/DataFilter/options/MultiSelectFilter.js +20 -22
- package/DataFilter/options/MultiSelectFilter.js.map +1 -1
- package/DataFilter/options/NumberFilter.js +11 -13
- package/DataFilter/options/NumberFilter.js.map +1 -1
- package/DataFilter/options/NumberRangeFilter.js +12 -14
- package/DataFilter/options/NumberRangeFilter.js.map +1 -1
- package/DataFilter/options/SelectFilter.js +18 -20
- package/DataFilter/options/SelectFilter.js.map +1 -1
- package/DataFilter/options/TextFilter.js +11 -13
- package/DataFilter/options/TextFilter.js.map +1 -1
- package/Datatable/FilterBox.js +21 -23
- package/Datatable/FilterBox.js.map +1 -1
- package/Datatable/Row.js +19 -21
- package/Datatable/Row.js.map +1 -1
- package/Datatable/SelectedBox.js +10 -12
- package/Datatable/SelectedBox.js.map +1 -1
- package/Datatable/Table.js +8 -10
- package/Datatable/Table.js.map +1 -1
- package/Datatable/TableHead.js +18 -20
- package/Datatable/TableHead.js.map +1 -1
- package/Datatable/index.js +21 -23
- package/Datatable/index.js.map +1 -1
- package/Divider/index.js +8 -10
- package/Divider/index.js.map +1 -1
- package/Drawer/index.js +12 -14
- package/Drawer/index.js.map +1 -1
- package/Form/index.js +8 -10
- package/Form/index.js.map +1 -1
- package/GridContainer/index.js +7 -9
- package/GridContainer/index.js.map +1 -1
- package/GridItem/index.js +7 -9
- package/GridItem/index.js.map +1 -1
- package/IconButton/index.js +12 -14
- package/IconButton/index.js.map +1 -1
- package/Image/index.js +9 -11
- package/Image/index.js.map +1 -1
- package/Input/index.js +18 -20
- package/Input/index.js.map +1 -1
- package/InputNumber/index.js +6 -8
- package/InputNumber/index.js.map +1 -1
- package/Label/index.js +7 -9
- package/Label/index.js.map +1 -1
- package/Layer/index.js +19 -21
- package/Layer/index.js.map +1 -1
- package/LineProgress/index.js +11 -13
- package/LineProgress/index.js.map +1 -1
- package/List/ListContext.js +2 -5
- package/List/ListContext.js.map +1 -1
- package/List/index.js +12 -14
- package/List/index.js.map +1 -1
- package/ListItem/index.js +12 -14
- package/ListItem/index.js.map +1 -1
- package/LoadingBox/index.js +11 -13
- package/LoadingBox/index.js.map +1 -1
- package/Menu/index.js +18 -20
- package/Menu/index.js.map +1 -1
- package/Modal/index.js +15 -17
- package/Modal/index.js.map +1 -1
- package/NoSSR/index.js +4 -6
- package/NoSSR/index.js.map +1 -1
- package/Option/index.js +7 -9
- package/Option/index.js.map +1 -1
- package/Paper/index.js +8 -10
- package/Paper/index.js.map +1 -1
- package/Portal/index.js +9 -11
- package/Portal/index.js.map +1 -1
- package/Radio/index.js +9 -11
- package/Radio/index.js.map +1 -1
- package/Scrollbar/index.js +10 -12
- package/Scrollbar/index.js.map +1 -1
- package/Select/index.js +22 -24
- package/Select/index.js.map +1 -1
- package/Skeleton/index.js +7 -9
- package/Skeleton/index.js.map +1 -1
- package/Stack/index.js +7 -9
- package/Stack/index.js.map +1 -1
- package/Switch/index.js +12 -14
- package/Switch/index.js.map +1 -1
- package/Tab/index.js +9 -11
- package/Tab/index.js.map +1 -1
- package/Table/index.js +13 -15
- package/Table/index.js.map +1 -1
- package/TableBody/index.js +7 -9
- package/TableBody/index.js.map +1 -1
- package/TableCell/index.js +7 -9
- package/TableCell/index.js.map +1 -1
- package/TableFooter/index.js +7 -9
- package/TableFooter/index.js.map +1 -1
- package/TableHead/index.js +7 -9
- package/TableHead/index.js.map +1 -1
- package/TablePagination/index.js +21 -23
- package/TablePagination/index.js.map +1 -1
- package/TableRow/index.js +7 -9
- package/TableRow/index.js.map +1 -1
- package/Tabs/index.js +19 -21
- package/Tabs/index.js.map +1 -1
- package/Text/index.js +8 -10
- package/Text/index.js.map +1 -1
- package/Toast/index.js +18 -20
- package/Toast/index.js.map +1 -1
- package/Tooltip/index.js +11 -13
- package/Tooltip/index.js.map +1 -1
- package/ViewBox/index.js +11 -13
- package/ViewBox/index.js.map +1 -1
- package/index.js +64 -133
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/useAlert/index.js +12 -14
- package/useAlert/index.js.map +1 -1
- package/useBlurCss/index.js +5 -7
- package/useBlurCss/index.js.map +1 -1
- package/useCorner/index.js +1 -3
- package/useCorner/index.js.map +1 -1
- package/useLayer/index.js +7 -9
- package/useLayer/index.js.map +1 -1
- package/useModal/index.js +8 -10
- package/useModal/index.js.map +1 -1
package/Badge/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var core = require('@xanui/core');
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { useInterface, useBreakpointProps, useColorTemplate, Tag, Transition } from '@xanui/core';
|
|
7
5
|
|
|
8
6
|
const Badge = React.forwardRef((_a, ref) => {
|
|
9
|
-
var { children, content, refs } = _a, rest =
|
|
10
|
-
let [_b] =
|
|
7
|
+
var { children, content, refs } = _a, rest = __rest(_a, ["children", "content", "refs"]);
|
|
8
|
+
let [_b] = useInterface("Badge", rest, {}), { color, placement, visible, slotProps, disableTransition, disableSpace } = _b, props = __rest(_b, ["color", "placement", "visible", "slotProps", "disableTransition", "disableSpace"]);
|
|
11
9
|
color !== null && color !== void 0 ? color : (color = "danger");
|
|
12
10
|
visible !== null && visible !== void 0 ? visible : (visible = true);
|
|
13
11
|
placement !== null && placement !== void 0 ? placement : (placement = "right-top");
|
|
@@ -19,14 +17,14 @@ const Badge = React.forwardRef((_a, ref) => {
|
|
|
19
17
|
_p.placement = placement;
|
|
20
18
|
_p.visible = visible;
|
|
21
19
|
_p.disableTransition = disableTransition !== null && disableTransition !== void 0 ? disableTransition : false;
|
|
22
|
-
const p =
|
|
20
|
+
const p = useBreakpointProps(_p);
|
|
23
21
|
content = p.content;
|
|
24
22
|
color = p.color;
|
|
25
23
|
placement = p.placement;
|
|
26
24
|
visible = p.visible;
|
|
27
25
|
disableTransition = p.disableTransition;
|
|
28
26
|
const isReactElement = React.isValidElement(content);
|
|
29
|
-
let template =
|
|
27
|
+
let template = useColorTemplate(color, "fill");
|
|
30
28
|
let _css = {
|
|
31
29
|
position: "absolute",
|
|
32
30
|
};
|
|
@@ -90,8 +88,8 @@ const Badge = React.forwardRef((_a, ref) => {
|
|
|
90
88
|
else {
|
|
91
89
|
template = {};
|
|
92
90
|
}
|
|
93
|
-
const _badge =
|
|
94
|
-
return (
|
|
91
|
+
const _badge = jsx(Tag, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.content, { ref: refs === null || refs === void 0 ? void 0 : refs.content, component: 'span', baseClass: 'badge-content', sxr: Object.assign(Object.assign({ position: "absolute", zIndex: 1, display: 'flex', justifyContent: "center", alignItems: 'center' }, template.primary), _css), children: content }));
|
|
92
|
+
return (jsxs(Tag, Object.assign({}, props, { position: "relative", display: "inline-block", baseClass: 'badge', ref: ref, children: [!disableTransition ? (jsx(Transition, Object.assign({ open: content !== undefined && visible }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.transition, { variant: () => {
|
|
95
93
|
return {
|
|
96
94
|
from: {
|
|
97
95
|
opacity: 0,
|
|
@@ -102,8 +100,8 @@ const Badge = React.forwardRef((_a, ref) => {
|
|
|
102
100
|
transform: `scale(1) ${translate}`.trim(),
|
|
103
101
|
},
|
|
104
102
|
};
|
|
105
|
-
}, ref: refs === null || refs === void 0 ? void 0 : refs.transition, children: _badge }))) :
|
|
103
|
+
}, ref: refs === null || refs === void 0 ? void 0 : refs.transition, children: _badge }))) : jsx(Fragment, { children: _badge }), children] })));
|
|
106
104
|
});
|
|
107
105
|
|
|
108
|
-
|
|
106
|
+
export { Badge as default };
|
|
109
107
|
//# sourceMappingURL=index.js.map
|
package/Badge/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Badge/index.tsx"],"sourcesContent":["import React, { ReactElement } from 'react';\r\nimport { Tag, TagProps, TagComponentType, Transition, useInterface, UseColorTemplateColor, useColorTemplate, useBreakpointPropsType, useBreakpointProps, TransitionProps } from '@xanui/core';\r\n\r\nexport type BadgeProps<T extends TagComponentType = \"div\"> = Omit<TagProps<T>, \"baseClass\" | \"content\"> & {\r\n content?: useBreakpointPropsType<number | string | ReactElement>;\r\n color?: useBreakpointPropsType<UseColorTemplateColor>;\r\n placement?: useBreakpointPropsType<\"left-top\" | \"left-bottom\" | \"right-top\" | \"right-bottom\">;\r\n visible?: useBreakpointPropsType<boolean>;\r\n disableTransition?: boolean;\r\n disableSpace?: boolean;\r\n slotProps?: {\r\n transition?: Omit<TransitionProps, \"open\">;\r\n content?: Omit<TagProps<\"span\">, \"children\">;\r\n },\r\n refs?: {\r\n content?: React.Ref<any>;\r\n transition?: React.Ref<any>;\r\n };\r\n}\r\n\r\nconst Badge = React.forwardRef(<T extends TagComponentType = \"div\">({ children, content, refs, ...rest }: BadgeProps<T>, ref: React.Ref<any>) => {\r\n let [{ color, placement, visible, slotProps, disableTransition, disableSpace, ...props }] = useInterface<any>(\"Badge\", rest, {})\r\n color ??= \"danger\"\r\n visible ??= true\r\n placement ??= \"right-top\"\r\n disableTransition ??= false\r\n disableSpace ??= false\r\n\r\n const _p: any = {}\r\n\r\n _p.content = content\r\n _p.color = color\r\n _p.placement = placement\r\n _p.visible = visible\r\n _p.disableTransition = disableTransition ?? false\r\n\r\n const p: any = useBreakpointProps(_p)\r\n\r\n content = p.content\r\n color = p.color\r\n placement = p.placement\r\n visible = p.visible\r\n disableTransition = p.disableTransition\r\n\r\n const isReactElement = React.isValidElement(content);\r\n\r\n let template: any = useColorTemplate(color, \"fill\")\r\n let _css: any = {\r\n position: \"absolute\",\r\n }\r\n\r\n let translate = ''\r\n\r\n switch (placement) {\r\n case \"right-top\":\r\n _css.top = 0;\r\n _css.right = 0;\r\n if (!disableSpace) {\r\n translate = \"translate(50%, -50%)\";\r\n }\r\n break;\r\n case \"right-bottom\":\r\n _css.bottom = 0;\r\n _css.right = 0;\r\n if (!disableSpace) {\r\n translate = \"translate(50%, 50%)\";\r\n }\r\n break;\r\n case \"left-top\":\r\n _css.top = 0;\r\n _css.left = 0;\r\n if (!disableSpace) {\r\n translate = \"translate(-50%, -50%)\";\r\n }\r\n break;\r\n case \"left-bottom\":\r\n _css.bottom = 0;\r\n _css.left = 0;\r\n if (!disableSpace) {\r\n translate = \"translate(-50%, 50%)\";\r\n }\r\n break;\r\n }\r\n\r\n if (disableTransition) {\r\n _css.transform = translate\r\n }\r\n\r\n if (!isReactElement) {\r\n _css.userSelect = \"none\"\r\n _css.pointerEvents = \"none\"\r\n _css.fontSize = \"small\"\r\n _css.lineHeight = 1\r\n _css.fontWeight = 500\r\n _css.radius = 2\r\n\r\n if (typeof content === 'number') {\r\n if (content > 99) {\r\n content = \"99+\"\r\n }\r\n }\r\n\r\n if (content !== undefined) {\r\n _css.minWidth = 16\r\n _css.height = 16\r\n _css.p = .8\r\n _css.px = .4\r\n } else {\r\n _css.width = 8\r\n _css.height = 8\r\n }\r\n } else {\r\n template = {}\r\n }\r\n\r\n const _badge = <Tag\r\n {...slotProps?.content}\r\n ref={refs?.content}\r\n component='span'\r\n baseClass='badge-content'\r\n sxr={{\r\n position: \"absolute\",\r\n zIndex: 1,\r\n display: 'flex',\r\n justifyContent: \"center\",\r\n alignItems: 'center',\r\n ...template.primary,\r\n ..._css,\r\n }}\r\n >\r\n {content}\r\n </Tag>\r\n\r\n return (\r\n <Tag\r\n {...props}\r\n position=\"relative\"\r\n display=\"inline-block\"\r\n baseClass='badge'\r\n ref={ref}\r\n >\r\n {\r\n !disableTransition ? (<Transition\r\n open={content !== undefined && visible}\r\n {...slotProps?.transition}\r\n variant={() => {\r\n return {\r\n from: {\r\n opacity: 0,\r\n transform: `scale(0) ${translate}`.trim(),\r\n },\r\n to: {\r\n opacity: 1,\r\n transform: `scale(1) ${translate}`.trim(),\r\n },\r\n }\r\n }}\r\n ref={refs?.transition}\r\n >\r\n {_badge}\r\n </Transition>) : <>{_badge}</>\r\n }\r\n\r\n {children}\r\n </Tag>\r\n )\r\n})\r\n\r\nexport default Badge\r\n\r\n"],"names":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Badge/index.tsx"],"sourcesContent":["import React, { ReactElement } from 'react';\r\nimport { Tag, TagProps, TagComponentType, Transition, useInterface, UseColorTemplateColor, useColorTemplate, useBreakpointPropsType, useBreakpointProps, TransitionProps } from '@xanui/core';\r\n\r\nexport type BadgeProps<T extends TagComponentType = \"div\"> = Omit<TagProps<T>, \"baseClass\" | \"content\"> & {\r\n content?: useBreakpointPropsType<number | string | ReactElement>;\r\n color?: useBreakpointPropsType<UseColorTemplateColor>;\r\n placement?: useBreakpointPropsType<\"left-top\" | \"left-bottom\" | \"right-top\" | \"right-bottom\">;\r\n visible?: useBreakpointPropsType<boolean>;\r\n disableTransition?: boolean;\r\n disableSpace?: boolean;\r\n slotProps?: {\r\n transition?: Omit<TransitionProps, \"open\">;\r\n content?: Omit<TagProps<\"span\">, \"children\">;\r\n },\r\n refs?: {\r\n content?: React.Ref<any>;\r\n transition?: React.Ref<any>;\r\n };\r\n}\r\n\r\nconst Badge = React.forwardRef(<T extends TagComponentType = \"div\">({ children, content, refs, ...rest }: BadgeProps<T>, ref: React.Ref<any>) => {\r\n let [{ color, placement, visible, slotProps, disableTransition, disableSpace, ...props }] = useInterface<any>(\"Badge\", rest, {})\r\n color ??= \"danger\"\r\n visible ??= true\r\n placement ??= \"right-top\"\r\n disableTransition ??= false\r\n disableSpace ??= false\r\n\r\n const _p: any = {}\r\n\r\n _p.content = content\r\n _p.color = color\r\n _p.placement = placement\r\n _p.visible = visible\r\n _p.disableTransition = disableTransition ?? false\r\n\r\n const p: any = useBreakpointProps(_p)\r\n\r\n content = p.content\r\n color = p.color\r\n placement = p.placement\r\n visible = p.visible\r\n disableTransition = p.disableTransition\r\n\r\n const isReactElement = React.isValidElement(content);\r\n\r\n let template: any = useColorTemplate(color, \"fill\")\r\n let _css: any = {\r\n position: \"absolute\",\r\n }\r\n\r\n let translate = ''\r\n\r\n switch (placement) {\r\n case \"right-top\":\r\n _css.top = 0;\r\n _css.right = 0;\r\n if (!disableSpace) {\r\n translate = \"translate(50%, -50%)\";\r\n }\r\n break;\r\n case \"right-bottom\":\r\n _css.bottom = 0;\r\n _css.right = 0;\r\n if (!disableSpace) {\r\n translate = \"translate(50%, 50%)\";\r\n }\r\n break;\r\n case \"left-top\":\r\n _css.top = 0;\r\n _css.left = 0;\r\n if (!disableSpace) {\r\n translate = \"translate(-50%, -50%)\";\r\n }\r\n break;\r\n case \"left-bottom\":\r\n _css.bottom = 0;\r\n _css.left = 0;\r\n if (!disableSpace) {\r\n translate = \"translate(-50%, 50%)\";\r\n }\r\n break;\r\n }\r\n\r\n if (disableTransition) {\r\n _css.transform = translate\r\n }\r\n\r\n if (!isReactElement) {\r\n _css.userSelect = \"none\"\r\n _css.pointerEvents = \"none\"\r\n _css.fontSize = \"small\"\r\n _css.lineHeight = 1\r\n _css.fontWeight = 500\r\n _css.radius = 2\r\n\r\n if (typeof content === 'number') {\r\n if (content > 99) {\r\n content = \"99+\"\r\n }\r\n }\r\n\r\n if (content !== undefined) {\r\n _css.minWidth = 16\r\n _css.height = 16\r\n _css.p = .8\r\n _css.px = .4\r\n } else {\r\n _css.width = 8\r\n _css.height = 8\r\n }\r\n } else {\r\n template = {}\r\n }\r\n\r\n const _badge = <Tag\r\n {...slotProps?.content}\r\n ref={refs?.content}\r\n component='span'\r\n baseClass='badge-content'\r\n sxr={{\r\n position: \"absolute\",\r\n zIndex: 1,\r\n display: 'flex',\r\n justifyContent: \"center\",\r\n alignItems: 'center',\r\n ...template.primary,\r\n ..._css,\r\n }}\r\n >\r\n {content}\r\n </Tag>\r\n\r\n return (\r\n <Tag\r\n {...props}\r\n position=\"relative\"\r\n display=\"inline-block\"\r\n baseClass='badge'\r\n ref={ref}\r\n >\r\n {\r\n !disableTransition ? (<Transition\r\n open={content !== undefined && visible}\r\n {...slotProps?.transition}\r\n variant={() => {\r\n return {\r\n from: {\r\n opacity: 0,\r\n transform: `scale(0) ${translate}`.trim(),\r\n },\r\n to: {\r\n opacity: 1,\r\n transform: `scale(1) ${translate}`.trim(),\r\n },\r\n }\r\n }}\r\n ref={refs?.transition}\r\n >\r\n {_badge}\r\n </Transition>) : <>{_badge}</>\r\n }\r\n\r\n {children}\r\n </Tag>\r\n )\r\n})\r\n\r\nexport default Badge\r\n\r\n"],"names":["_jsx","_jsxs","_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AI,EAGjC,QAAQ,CAAA,EAAA,CAAA,CACP;AAEd,CAAC;;;;"}
|
package/Box/index.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var core = require('@xanui/core');
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Tag } from '@xanui/core';
|
|
7
5
|
|
|
8
6
|
const Box = React.forwardRef((_a, ref) => {
|
|
9
|
-
var { children } = _a, props =
|
|
10
|
-
return (
|
|
7
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
8
|
+
return (jsx(Tag, Object.assign({}, props, { baseClass: 'box', ref: ref, children: children })));
|
|
11
9
|
});
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
export { Box as default };
|
|
14
12
|
//# sourceMappingURL=index.js.map
|
package/Box/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Box/index.tsx"],"sourcesContent":["import React from 'react';\r\nimport { Tag, TagProps, TagComponentType } from '@xanui/core';\r\n\r\nexport type BoxProps<T extends TagComponentType = \"div\"> = TagProps<T>\r\n\r\nconst Box = React.forwardRef(<T extends TagComponentType = \"div\">({ children, ...props }: BoxProps<T>, ref: React.Ref<any>) => {\r\n return (\r\n <Tag\r\n {...props}\r\n baseClass='box'\r\n ref={ref}\r\n >{children}</Tag>\r\n )\r\n})\r\n\r\nexport default Box\r\n\r\n"],"names":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Box/index.tsx"],"sourcesContent":["import React from 'react';\r\nimport { Tag, TagProps, TagComponentType } from '@xanui/core';\r\n\r\nexport type BoxProps<T extends TagComponentType = \"div\"> = TagProps<T>\r\n\r\nconst Box = React.forwardRef(<T extends TagComponentType = \"div\">({ children, ...props }: BoxProps<T>, ref: React.Ref<any>) => {\r\n return (\r\n <Tag\r\n {...props}\r\n baseClass='box'\r\n ref={ref}\r\n >{children}</Tag>\r\n )\r\n})\r\n\r\nexport default Box\r\n\r\n"],"names":["_jsx"],"mappings":";;;;;AAKA,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC,CAAqC,EAAmC,EAAE,GAAmB,KAAI;AAA5D,IAAA,IAAA,EAAE,QAAQ,EAAA,GAAA,EAAyB,EAApB,KAAK,GAAA,MAAA,CAAA,EAAA,EAApB,YAAsB,CAAF;AAClF,IAAA,QACIA,GAAA,CAAC,GAAG,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACI,KAAK,IACT,SAAS,EAAC,KAAK,EACf,GAAG,EAAE,GAAG,YACV,QAAQ,EAAA,CAAA,CAAO;AAEzB,CAAC;;;;"}
|
package/Button/index.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var index$2 = require('../CircleProgress/index.js');
|
|
10
|
-
var index = require('../Skeleton/index.js');
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useInterface, useBreakpointProps, useColorTemplate, Tag } from '@xanui/core';
|
|
6
|
+
import useCorner from '../useCorner/index.js';
|
|
7
|
+
import CircleProgress from '../CircleProgress/index.js';
|
|
8
|
+
import Skeleton from '../Skeleton/index.js';
|
|
11
9
|
|
|
12
10
|
const Button = React.forwardRef((_a, ref) => {
|
|
13
11
|
var _b, _c;
|
|
14
|
-
var { children, skeleton } = _a, rest =
|
|
15
|
-
let [_d] =
|
|
12
|
+
var { children, skeleton } = _a, rest = __rest(_a, ["children", "skeleton"]);
|
|
13
|
+
let [_d] = useInterface('Button', rest, {
|
|
16
14
|
variant: "fill",
|
|
17
15
|
color: "brand",
|
|
18
16
|
corner: "rounded",
|
|
19
17
|
size: "medium"
|
|
20
|
-
}), { variant, startIcon, endIcon, color, corner, size, loading, direction, slotProps } = _d, _props =
|
|
18
|
+
}), { variant, startIcon, endIcon, color, corner, size, loading, direction, slotProps } = _d, _props = __rest(_d, ["variant", "startIcon", "endIcon", "color", "corner", "size", "loading", "direction", "slotProps"]);
|
|
21
19
|
const _p = {};
|
|
22
20
|
if (startIcon)
|
|
23
21
|
_p.startIcon = startIcon;
|
|
@@ -33,7 +31,7 @@ const Button = React.forwardRef((_a, ref) => {
|
|
|
33
31
|
_p.size = size;
|
|
34
32
|
if (direction)
|
|
35
33
|
_p.direction = direction;
|
|
36
|
-
const p =
|
|
34
|
+
const p = useBreakpointProps(_p);
|
|
37
35
|
startIcon = p.startIcon;
|
|
38
36
|
endIcon = p.endIcon;
|
|
39
37
|
color = p.color;
|
|
@@ -41,8 +39,8 @@ const Button = React.forwardRef((_a, ref) => {
|
|
|
41
39
|
corner = p.corner;
|
|
42
40
|
size = p.size;
|
|
43
41
|
direction = p.direction || "row";
|
|
44
|
-
const template =
|
|
45
|
-
const cornerCss =
|
|
42
|
+
const template = useColorTemplate(color, variant);
|
|
43
|
+
const cornerCss = useCorner(corner);
|
|
46
44
|
const sizes = {
|
|
47
45
|
small: {
|
|
48
46
|
height: 38,
|
|
@@ -75,9 +73,9 @@ const Button = React.forwardRef((_a, ref) => {
|
|
|
75
73
|
_size.py = 1;
|
|
76
74
|
}
|
|
77
75
|
if (skeleton) {
|
|
78
|
-
return
|
|
76
|
+
return jsx(Skeleton, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.skeleton, { height: _size.height, animation: "wave", sx: Object.assign(Object.assign(Object.assign({}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.skeleton) === null || _b === void 0 ? void 0 : _b.sx), _size), cornerCss) }));
|
|
79
77
|
}
|
|
80
|
-
return (
|
|
78
|
+
return (jsxs(Tag, Object.assign({ component: 'button', baseClass: 'button' }, _props, { sxr: Object.assign(Object.assign(Object.assign({ flexShrink: "0", whiteSpace: "nowrap", cursor: "pointer", display: "flex", textTransform: "uppercase", flexDirection: direction, alignItems: "center", justifyContent: "center", position: "relative", overflow: "hidden", userSelect: "none", fontWeight: 500 }, _size), cornerCss), template.primary), hover: Object.assign(Object.assign({}, template.secondary), ((_props === null || _props === void 0 ? void 0 : _props.hover) || {})), disabled: (_c = loading !== null && loading !== void 0 ? loading : _props.disabled) !== null && _c !== void 0 ? _c : false, ref: ref, children: [loading && jsx(Tag, { baseClass: 'button-loading-container', sxr: {
|
|
81
79
|
position: "absolute",
|
|
82
80
|
top: 0,
|
|
83
81
|
left: 0,
|
|
@@ -87,8 +85,8 @@ const Button = React.forwardRef((_a, ref) => {
|
|
|
87
85
|
display: "flex",
|
|
88
86
|
justifyContent: "center",
|
|
89
87
|
alignItems: "center",
|
|
90
|
-
}, children:
|
|
88
|
+
}, children: jsx(CircleProgress, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.loading, { color: color === 'default' ? `brand` : "default", size: progressSizes[size], className: 'button-loading-progress' })) }), startIcon && jsx(Tag, { baseClass: 'button-start-icon', component: 'span', display: "inline-block", flexShrink: 0, children: startIcon }), children, endIcon && jsx(Tag, { baseClass: 'button-end-icon', component: 'span', display: "inline-block", flexShrink: 0, children: endIcon })] })));
|
|
91
89
|
});
|
|
92
90
|
|
|
93
|
-
|
|
91
|
+
export { Button as default };
|
|
94
92
|
//# sourceMappingURL=index.js.map
|
package/Button/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Button/index.tsx"],"sourcesContent":["\"use client\";\r\nimport React, { ReactElement } from 'react';\r\nimport { Tag, TagProps, TagComponentType, useInterface, useColorTemplate, UseColorTemplateColor, UseColorTemplateType, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\r\nimport useCorner, { UseCornerTypes } from '../useCorner'\r\nimport CircleProgress, { CircleProgressProps } from '../CircleProgress'\r\nimport Skeleton, { SkeletonProps } from '../Skeleton';\r\n\r\n\r\nexport type ButtonProps<T extends TagComponentType = 'button'> = Omit<TagProps<T>, \"color\" | \"size\" | \"direction\"> & {\r\n startIcon?: useBreakpointPropsType<ReactElement>;\r\n endIcon?: useBreakpointPropsType<ReactElement>;\r\n color?: useBreakpointPropsType<UseColorTemplateColor>;\r\n variant?: useBreakpointPropsType<UseColorTemplateType>;\r\n corner?: useBreakpointPropsType<UseCornerTypes>;\r\n size?: useBreakpointPropsType<\"small\" | \"medium\" | \"large\">;\r\n direction?: useBreakpointPropsType<\"row\" | \"column\">;\r\n loading?: boolean;\r\n skeleton?: boolean;\r\n slotProps?: {\r\n loading?: Omit<CircleProgressProps, \"color\" | \"hideTrack\" | \"size\">;\r\n skeleton?: Omit<SkeletonProps, \"height\" | \"width\" | \"loading\" | \"children\">\r\n }\r\n}\r\n\r\n\r\nconst Button = React.forwardRef(<T extends TagComponentType = 'button'>({ children, skeleton, ...rest }: ButtonProps<T>, ref: React.Ref<any>) => {\r\n let [{ variant, startIcon, endIcon, color, corner, size, loading, direction, slotProps, ..._props }] = useInterface<any>('Button', rest, {\r\n variant: \"fill\",\r\n color: \"brand\",\r\n corner: \"rounded\",\r\n size: \"medium\"\r\n })\r\n\r\n const _p: any = {}\r\n if (startIcon) _p.startIcon = startIcon\r\n if (endIcon) _p.endIcon = endIcon\r\n if (color) _p.color = color\r\n if (variant) _p.variant = variant\r\n if (corner) _p.corner = corner\r\n if (size) _p.size = size\r\n if (direction) _p.direction = direction\r\n const p: any = useBreakpointProps(_p)\r\n\r\n startIcon = p.startIcon\r\n endIcon = p.endIcon\r\n color = p.color\r\n variant = p.variant\r\n corner = p.corner\r\n size = p.size\r\n direction = p.direction || \"row\"\r\n\r\n const template = useColorTemplate(color, variant)\r\n const cornerCss = useCorner(corner)\r\n\r\n const sizes: any = {\r\n small: {\r\n height: 38,\r\n px: (startIcon || endIcon) ? 1 : 1.5,\r\n gap: .5,\r\n fontSize: 'button'\r\n },\r\n medium: {\r\n height: 44,\r\n px: (startIcon || endIcon) ? 1.5 : 2,\r\n gap: 1,\r\n fontSize: 'button'\r\n },\r\n large: {\r\n height: 52,\r\n px: (startIcon || endIcon) ? 2 : 3,\r\n gap: 1,\r\n fontSize: \"text\"\r\n }\r\n }\r\n\r\n const progressSizes: any = {\r\n small: 20,\r\n medium: 25,\r\n large: 30\r\n }\r\n\r\n let _size = (sizes[size as any] || {})\r\n if (direction === 'column') {\r\n delete _size.height\r\n _size.gap = .5\r\n _size.py = 1\r\n }\r\n\r\n if (skeleton) {\r\n return <Skeleton\r\n {...slotProps?.skeleton}\r\n height={_size.height}\r\n animation={\"wave\"}\r\n sx={{\r\n ...slotProps?.skeleton?.sx,\r\n ..._size,\r\n ...cornerCss,\r\n }}\r\n />\r\n }\r\n\r\n return (\r\n <Tag\r\n component='button'\r\n baseClass='button'\r\n {..._props}\r\n sxr={{\r\n flexShrink: \"0\",\r\n whiteSpace: \"nowrap\",\r\n cursor: \"pointer\",\r\n display: \"flex\",\r\n textTransform: \"uppercase\",\r\n flexDirection: direction,\r\n alignItems: \"center\",\r\n justifyContent: \"center\",\r\n position: \"relative\",\r\n overflow: \"hidden\",\r\n userSelect: \"none\",\r\n fontWeight: 500,\r\n ..._size,\r\n ...cornerCss,\r\n ...template.primary,\r\n\r\n }}\r\n hover={{\r\n ...template.secondary,\r\n ...((_props as any)?.hover || {})\r\n }}\r\n disabled={loading ?? _props.disabled ?? false}\r\n ref={ref}\r\n >\r\n {loading && <Tag\r\n baseClass='button-loading-container'\r\n sxr={{\r\n position: \"absolute\",\r\n top: 0,\r\n left: 0,\r\n right: 0,\r\n bottom: 0,\r\n zIndex: 1,\r\n display: \"flex\",\r\n justifyContent: \"center\",\r\n alignItems: \"center\",\r\n }}\r\n >\r\n <CircleProgress\r\n {...slotProps?.loading}\r\n color={color === 'default' ? `brand` : \"default\"}\r\n size={progressSizes[size]}\r\n className='button-loading-progress'\r\n />\r\n </Tag>}\r\n {startIcon && <Tag\r\n baseClass='button-start-icon'\r\n component='span'\r\n display=\"inline-block\"\r\n flexShrink={0}\r\n >{startIcon}</Tag>}\r\n {children}\r\n {endIcon && <Tag\r\n baseClass='button-end-icon'\r\n component='span'\r\n display=\"inline-block\"\r\n flexShrink={0}\r\n >{endIcon}</Tag>}\r\n </Tag>\r\n )\r\n})\r\n\r\nexport default Button\r\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Button/index.tsx"],"sourcesContent":["\"use client\";\r\nimport React, { ReactElement } from 'react';\r\nimport { Tag, TagProps, TagComponentType, useInterface, useColorTemplate, UseColorTemplateColor, UseColorTemplateType, useBreakpointProps, useBreakpointPropsType } from '@xanui/core';\r\nimport useCorner, { UseCornerTypes } from '../useCorner'\r\nimport CircleProgress, { CircleProgressProps } from '../CircleProgress'\r\nimport Skeleton, { SkeletonProps } from '../Skeleton';\r\n\r\n\r\nexport type ButtonProps<T extends TagComponentType = 'button'> = Omit<TagProps<T>, \"color\" | \"size\" | \"direction\"> & {\r\n startIcon?: useBreakpointPropsType<ReactElement>;\r\n endIcon?: useBreakpointPropsType<ReactElement>;\r\n color?: useBreakpointPropsType<UseColorTemplateColor>;\r\n variant?: useBreakpointPropsType<UseColorTemplateType>;\r\n corner?: useBreakpointPropsType<UseCornerTypes>;\r\n size?: useBreakpointPropsType<\"small\" | \"medium\" | \"large\">;\r\n direction?: useBreakpointPropsType<\"row\" | \"column\">;\r\n loading?: boolean;\r\n skeleton?: boolean;\r\n slotProps?: {\r\n loading?: Omit<CircleProgressProps, \"color\" | \"hideTrack\" | \"size\">;\r\n skeleton?: Omit<SkeletonProps, \"height\" | \"width\" | \"loading\" | \"children\">\r\n }\r\n}\r\n\r\n\r\nconst Button = React.forwardRef(<T extends TagComponentType = 'button'>({ children, skeleton, ...rest }: ButtonProps<T>, ref: React.Ref<any>) => {\r\n let [{ variant, startIcon, endIcon, color, corner, size, loading, direction, slotProps, ..._props }] = useInterface<any>('Button', rest, {\r\n variant: \"fill\",\r\n color: \"brand\",\r\n corner: \"rounded\",\r\n size: \"medium\"\r\n })\r\n\r\n const _p: any = {}\r\n if (startIcon) _p.startIcon = startIcon\r\n if (endIcon) _p.endIcon = endIcon\r\n if (color) _p.color = color\r\n if (variant) _p.variant = variant\r\n if (corner) _p.corner = corner\r\n if (size) _p.size = size\r\n if (direction) _p.direction = direction\r\n const p: any = useBreakpointProps(_p)\r\n\r\n startIcon = p.startIcon\r\n endIcon = p.endIcon\r\n color = p.color\r\n variant = p.variant\r\n corner = p.corner\r\n size = p.size\r\n direction = p.direction || \"row\"\r\n\r\n const template = useColorTemplate(color, variant)\r\n const cornerCss = useCorner(corner)\r\n\r\n const sizes: any = {\r\n small: {\r\n height: 38,\r\n px: (startIcon || endIcon) ? 1 : 1.5,\r\n gap: .5,\r\n fontSize: 'button'\r\n },\r\n medium: {\r\n height: 44,\r\n px: (startIcon || endIcon) ? 1.5 : 2,\r\n gap: 1,\r\n fontSize: 'button'\r\n },\r\n large: {\r\n height: 52,\r\n px: (startIcon || endIcon) ? 2 : 3,\r\n gap: 1,\r\n fontSize: \"text\"\r\n }\r\n }\r\n\r\n const progressSizes: any = {\r\n small: 20,\r\n medium: 25,\r\n large: 30\r\n }\r\n\r\n let _size = (sizes[size as any] || {})\r\n if (direction === 'column') {\r\n delete _size.height\r\n _size.gap = .5\r\n _size.py = 1\r\n }\r\n\r\n if (skeleton) {\r\n return <Skeleton\r\n {...slotProps?.skeleton}\r\n height={_size.height}\r\n animation={\"wave\"}\r\n sx={{\r\n ...slotProps?.skeleton?.sx,\r\n ..._size,\r\n ...cornerCss,\r\n }}\r\n />\r\n }\r\n\r\n return (\r\n <Tag\r\n component='button'\r\n baseClass='button'\r\n {..._props}\r\n sxr={{\r\n flexShrink: \"0\",\r\n whiteSpace: \"nowrap\",\r\n cursor: \"pointer\",\r\n display: \"flex\",\r\n textTransform: \"uppercase\",\r\n flexDirection: direction,\r\n alignItems: \"center\",\r\n justifyContent: \"center\",\r\n position: \"relative\",\r\n overflow: \"hidden\",\r\n userSelect: \"none\",\r\n fontWeight: 500,\r\n ..._size,\r\n ...cornerCss,\r\n ...template.primary,\r\n\r\n }}\r\n hover={{\r\n ...template.secondary,\r\n ...((_props as any)?.hover || {})\r\n }}\r\n disabled={loading ?? _props.disabled ?? false}\r\n ref={ref}\r\n >\r\n {loading && <Tag\r\n baseClass='button-loading-container'\r\n sxr={{\r\n position: \"absolute\",\r\n top: 0,\r\n left: 0,\r\n right: 0,\r\n bottom: 0,\r\n zIndex: 1,\r\n display: \"flex\",\r\n justifyContent: \"center\",\r\n alignItems: \"center\",\r\n }}\r\n >\r\n <CircleProgress\r\n {...slotProps?.loading}\r\n color={color === 'default' ? `brand` : \"default\"}\r\n size={progressSizes[size]}\r\n className='button-loading-progress'\r\n />\r\n </Tag>}\r\n {startIcon && <Tag\r\n baseClass='button-start-icon'\r\n component='span'\r\n display=\"inline-block\"\r\n flexShrink={0}\r\n >{startIcon}</Tag>}\r\n {children}\r\n {endIcon && <Tag\r\n baseClass='button-end-icon'\r\n component='span'\r\n display=\"inline-block\"\r\n flexShrink={0}\r\n >{endIcon}</Tag>}\r\n </Tag>\r\n )\r\n})\r\n\r\nexport default Button\r\n"],"names":[],"mappings":";;;;;;;;;AAyBA;;;AACI;AACI;AACA;AACA;AACA;;;AAIJ;AAAe;AACf;AAAa;AACb;AAAW;AACX;AAAa;AACb;AAAY;AACZ;AAAU;AACV;AAAe;AACf;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AAEA;AACI;AACI;AACA;AACA;AACA;AACH;AACD;AACI;AACA;AACA;AACA;AACH;AACD;AACI;AACA;AACA;AACA;AACH;;AAGL;AACI;AACA;AACA;;;AAIJ;;AAEI;AACA;;;AAIA;;;AA6CY;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACH;AAwBjB;;"}
|
package/ButtonGroup/index.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var core = require('@xanui/core');
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React, { Children, cloneElement } from 'react';
|
|
4
|
+
import { useInterface, useBreakpointProps, Tag } from '@xanui/core';
|
|
7
5
|
|
|
8
6
|
const ButtonGroup = React.forwardRef((_a, ref) => {
|
|
9
|
-
var { children } = _a, rest =
|
|
10
|
-
let [_b] =
|
|
7
|
+
var { children } = _a, rest = __rest(_a, ["children"]);
|
|
8
|
+
let [_b] = useInterface("ButtonGroup", rest, {
|
|
11
9
|
size: "medium",
|
|
12
10
|
variant: "outline",
|
|
13
11
|
color: "default"
|
|
14
|
-
}), { color, variant, size } = _b, props =
|
|
12
|
+
}), { color, variant, size } = _b, props = __rest(_b, ["color", "variant", "size"]);
|
|
15
13
|
const _p = {};
|
|
16
14
|
if (color)
|
|
17
15
|
_p.color = color;
|
|
18
|
-
const p =
|
|
16
|
+
const p = useBreakpointProps(_p);
|
|
19
17
|
color = p.color;
|
|
20
18
|
const sizes = {
|
|
21
19
|
small: {
|
|
@@ -29,7 +27,7 @@ const ButtonGroup = React.forwardRef((_a, ref) => {
|
|
|
29
27
|
}
|
|
30
28
|
};
|
|
31
29
|
let borderColor = color === 'default' ? 'divider.secondary' : `${color}.secondary`;
|
|
32
|
-
return (
|
|
30
|
+
return (jsx(Tag, Object.assign({}, props, sizes[size], { sxr: {
|
|
33
31
|
display: "inline-flex",
|
|
34
32
|
flexWrap: "nowrap",
|
|
35
33
|
overflow: "hidden",
|
|
@@ -43,8 +41,8 @@ const ButtonGroup = React.forwardRef((_a, ref) => {
|
|
|
43
41
|
"& button:last-child, & button:last-child:hover": {
|
|
44
42
|
borderRight: "none"
|
|
45
43
|
}
|
|
46
|
-
}, baseClass: 'button-group', ref: ref, children:
|
|
47
|
-
return
|
|
44
|
+
}, baseClass: 'button-group', ref: ref, children: Children.map(children, (child) => {
|
|
45
|
+
return cloneElement(child, {
|
|
48
46
|
flex: "0 0 auto",
|
|
49
47
|
color,
|
|
50
48
|
variant,
|
|
@@ -54,5 +52,5 @@ const ButtonGroup = React.forwardRef((_a, ref) => {
|
|
|
54
52
|
}) })));
|
|
55
53
|
});
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
export { ButtonGroup as default };
|
|
58
56
|
//# sourceMappingURL=index.js.map
|
package/ButtonGroup/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/ButtonGroup/index.tsx"],"sourcesContent":["import React, { ReactElement, Children, cloneElement } from 'react';\r\nimport { Tag, TagProps, TagComponentType, useInterface, UseColorTemplateColor, UseColorTemplateType, useBreakpointPropsType, useBreakpointProps } from '@xanui/core';\r\nimport { ButtonProps } from '../Button';\r\n\r\nexport type ButtonGroupProps<T extends TagComponentType = \"div\"> = Omit<TagProps<T>, 'children' | \"size\"> & {\r\n children?: ReactElement<ButtonProps> | ReactElement<ButtonProps>[];\r\n color?: useBreakpointPropsType<UseColorTemplateColor>;\r\n variant?: useBreakpointPropsType<UseColorTemplateType>;\r\n size?: useBreakpointPropsType<\"small\" | \"medium\" | \"large\">;\r\n}\r\n\r\nconst ButtonGroup = React.forwardRef(<T extends TagComponentType = \"div\">({ children, ...rest }: ButtonGroupProps<T>, ref: React.Ref<any>) => {\r\n let [{ color, variant, size, ...props }] = useInterface<any>(\"ButtonGroup\", rest, {\r\n size: \"medium\",\r\n variant: \"outline\",\r\n color: \"default\"\r\n })\r\n const _p: any = {}\r\n if (color) _p.color = color\r\n const p: any = useBreakpointProps(_p)\r\n color = p.color\r\n\r\n const sizes: any = {\r\n small: {\r\n height: 40,\r\n },\r\n medium: {\r\n height: 46,\r\n },\r\n large: {\r\n height: 52,\r\n }\r\n }\r\n\r\n let borderColor = color === 'default' ? 'divider.secondary' : `${color}.secondary`\r\n\r\n return (\r\n <Tag\r\n {...props}\r\n {...sizes[size]}\r\n sxr={{\r\n display: \"inline-flex\",\r\n flexWrap: \"nowrap\",\r\n overflow: \"hidden\",\r\n radius: 1,\r\n border: \"1px solid\",\r\n borderColor: borderColor,\r\n '& button, & button:hover': {\r\n borderRight: \"1px solid\",\r\n borderColor: borderColor\r\n },\r\n \"& button:last-child, & button:last-child:hover\": {\r\n borderRight: \"none\"\r\n }\r\n }}\r\n baseClass='button-group'\r\n ref={ref}\r\n >\r\n {Children.map(children, (child: any) => {\r\n return cloneElement(child, {\r\n flex: \"0 0 auto\",\r\n color,\r\n variant,\r\n size,\r\n corner: \"squar\",\r\n })\r\n })}\r\n </Tag>\r\n )\r\n})\r\n\r\nexport default ButtonGroup\r\n\r\n\r\n"],"names":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/ButtonGroup/index.tsx"],"sourcesContent":["import React, { ReactElement, Children, cloneElement } from 'react';\r\nimport { Tag, TagProps, TagComponentType, useInterface, UseColorTemplateColor, UseColorTemplateType, useBreakpointPropsType, useBreakpointProps } from '@xanui/core';\r\nimport { ButtonProps } from '../Button';\r\n\r\nexport type ButtonGroupProps<T extends TagComponentType = \"div\"> = Omit<TagProps<T>, 'children' | \"size\"> & {\r\n children?: ReactElement<ButtonProps> | ReactElement<ButtonProps>[];\r\n color?: useBreakpointPropsType<UseColorTemplateColor>;\r\n variant?: useBreakpointPropsType<UseColorTemplateType>;\r\n size?: useBreakpointPropsType<\"small\" | \"medium\" | \"large\">;\r\n}\r\n\r\nconst ButtonGroup = React.forwardRef(<T extends TagComponentType = \"div\">({ children, ...rest }: ButtonGroupProps<T>, ref: React.Ref<any>) => {\r\n let [{ color, variant, size, ...props }] = useInterface<any>(\"ButtonGroup\", rest, {\r\n size: \"medium\",\r\n variant: \"outline\",\r\n color: \"default\"\r\n })\r\n const _p: any = {}\r\n if (color) _p.color = color\r\n const p: any = useBreakpointProps(_p)\r\n color = p.color\r\n\r\n const sizes: any = {\r\n small: {\r\n height: 40,\r\n },\r\n medium: {\r\n height: 46,\r\n },\r\n large: {\r\n height: 52,\r\n }\r\n }\r\n\r\n let borderColor = color === 'default' ? 'divider.secondary' : `${color}.secondary`\r\n\r\n return (\r\n <Tag\r\n {...props}\r\n {...sizes[size]}\r\n sxr={{\r\n display: \"inline-flex\",\r\n flexWrap: \"nowrap\",\r\n overflow: \"hidden\",\r\n radius: 1,\r\n border: \"1px solid\",\r\n borderColor: borderColor,\r\n '& button, & button:hover': {\r\n borderRight: \"1px solid\",\r\n borderColor: borderColor\r\n },\r\n \"& button:last-child, & button:last-child:hover\": {\r\n borderRight: \"none\"\r\n }\r\n }}\r\n baseClass='button-group'\r\n ref={ref}\r\n >\r\n {Children.map(children, (child: any) => {\r\n return cloneElement(child, {\r\n flex: \"0 0 auto\",\r\n color,\r\n variant,\r\n size,\r\n corner: \"squar\",\r\n })\r\n })}\r\n </Tag>\r\n )\r\n})\r\n\r\nexport default ButtonGroup\r\n\r\n\r\n"],"names":["_jsx"],"mappings":";;;;;AAWA,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,CAAqC,EAA0C,EAAE,GAAmB,KAAI;AAAnE,IAAA,IAAA,EAAE,QAAQ,EAAA,GAAA,EAAgC,EAA3B,IAAI,GAAA,MAAA,CAAA,EAAA,EAAnB,YAAqB,CAAF;AACzF,IAAA,IAAI,OAAuC,YAAY,CAAM,aAAa,EAAE,IAAI,EAAE;AAC9E,QAAA,IAAI,EAAE,QAAQ;AACd,QAAA,OAAO,EAAE,SAAS;AAClB,QAAA,KAAK,EAAE;AACV,KAAA,CAAC,EAJG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAA,GAAA,EAAY,EAAP,KAAK,GAAA,MAAA,CAAA,EAAA,EAAhC,CAAA,OAAA,EAAA,SAAA,EAAA,MAAA,CAAkC,CAIrC;IACF,MAAM,EAAE,GAAQ,EAAE;AAClB,IAAA,IAAI,KAAK;AAAE,QAAA,EAAE,CAAC,KAAK,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"}
|
package/Calendar/index.js
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var index = require('../ViewBox/index.js');
|
|
15
|
-
var core = require('@xanui/core');
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import { useState, useRef, useEffect } from 'react';
|
|
5
|
+
import Stack from '../Stack/index.js';
|
|
6
|
+
import IconButton from '../IconButton/index.js';
|
|
7
|
+
import IconKeyboardArrowRight from '@xanui/icons/KeyboardArrowRight';
|
|
8
|
+
import IconKeyboardArrowLeft from '@xanui/icons/KeyboardArrowLeft';
|
|
9
|
+
import Text from '../Text/index.js';
|
|
10
|
+
import Button from '../Button/index.js';
|
|
11
|
+
import ResetIcon from '@xanui/icons/Replay';
|
|
12
|
+
import ViewBox from '../ViewBox/index.js';
|
|
13
|
+
import { useInterface, useBreakpointProps } from '@xanui/core';
|
|
16
14
|
|
|
17
15
|
const ShowYears = ({ color, year, today, onClick }) => {
|
|
18
16
|
let years = [];
|
|
19
|
-
const selectedRef =
|
|
17
|
+
const selectedRef = useRef(null);
|
|
20
18
|
for (let y = 1900; y < today.getFullYear() + 40; y++) {
|
|
21
19
|
const selected = year == y;
|
|
22
|
-
years.push(
|
|
20
|
+
years.push(jsx(Stack, { sx: {
|
|
23
21
|
width: 50,
|
|
24
22
|
p: .1
|
|
25
|
-
}, className: 'calender-year-item', children:
|
|
23
|
+
}, className: 'calender-year-item', children: jsx(Button, { color: selected ? color : "default", className: 'calender-year-button', size: 'small', corner: "circle", ref: selected ? selectedRef : null, onClick: () => onClick(y), variant: selected ? "fill" : "text", children: y }) }, y));
|
|
26
24
|
}
|
|
27
|
-
|
|
25
|
+
useEffect(() => {
|
|
28
26
|
if (selectedRef === null || selectedRef === void 0 ? void 0 : selectedRef.current) {
|
|
29
27
|
selectedRef === null || selectedRef === void 0 ? void 0 : selectedRef.current.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" });
|
|
30
28
|
}
|
|
31
29
|
}, []);
|
|
32
|
-
return (
|
|
30
|
+
return (jsx(Stack, { sx: {
|
|
33
31
|
flexWrap: "wrap",
|
|
34
32
|
flexDirection: "row",
|
|
35
33
|
overflow: "hidden",
|
|
@@ -37,19 +35,19 @@ const ShowYears = ({ color, year, today, onClick }) => {
|
|
|
37
35
|
}, className: 'calender-years', children: years }));
|
|
38
36
|
};
|
|
39
37
|
const Calendar = (_a) => {
|
|
40
|
-
var { value } = _a, rest =
|
|
41
|
-
let [{ onChange, viewMode: VMode, onButtonClick, color }] =
|
|
38
|
+
var { value } = _a, rest = __rest(_a, ["value"]);
|
|
39
|
+
let [{ onChange, viewMode: VMode, onButtonClick, color }] = useInterface("Calender", rest, {});
|
|
42
40
|
const _p = {};
|
|
43
41
|
if (VMode)
|
|
44
42
|
_p.VMode = VMode;
|
|
45
43
|
if (color)
|
|
46
44
|
_p.color = color;
|
|
47
|
-
const p =
|
|
45
|
+
const p = useBreakpointProps(_p);
|
|
48
46
|
color = p.color || "brand";
|
|
49
|
-
let [viewMode, setViewMode] =
|
|
50
|
-
let [selectedDate, setSelectedDate] =
|
|
47
|
+
let [viewMode, setViewMode] = useState(p.VMode || "day");
|
|
48
|
+
let [selectedDate, setSelectedDate] = useState(new Date());
|
|
51
49
|
selectedDate = value instanceof Date ? value : selectedDate;
|
|
52
|
-
const [currentDate, setCurrentDate] =
|
|
50
|
+
const [currentDate, setCurrentDate] = useState(selectedDate);
|
|
53
51
|
const year = currentDate.getFullYear();
|
|
54
52
|
const month = currentDate.getMonth();
|
|
55
53
|
const daysInMonth = 32 - new Date(year, month, 32).getDate();
|
|
@@ -63,20 +61,20 @@ const Calendar = (_a) => {
|
|
|
63
61
|
const dayNames = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
|
|
64
62
|
for (let i = 0; i < dayNames.length; i++) {
|
|
65
63
|
const k = dayNames[i];
|
|
66
|
-
row.push(
|
|
64
|
+
row.push(jsx(Stack, { sx: {
|
|
67
65
|
width: btnWidth,
|
|
68
66
|
height: btnWidth,
|
|
69
67
|
alignItems: "center",
|
|
70
68
|
justifyContent: "center"
|
|
71
|
-
}, children:
|
|
69
|
+
}, children: jsx(IconButton, { variant: "text", color: "default", disabled: true, children: k }) }, "dayname-" + i));
|
|
72
70
|
}
|
|
73
|
-
rows.push(
|
|
71
|
+
rows.push(jsx(Stack, { flexRow: true, className: 'calender-day-row', children: row }, "header"));
|
|
74
72
|
let date = 1;
|
|
75
73
|
for (let i = 0; i < 6; i++) {
|
|
76
74
|
let row = [];
|
|
77
75
|
for (let j = 0; j < 7; j++) {
|
|
78
76
|
if (i === 0 && j < firstDay) {
|
|
79
|
-
row.push(
|
|
77
|
+
row.push(jsx(Stack, { alignItems: "center", justifyContent: "center", sx: {
|
|
80
78
|
width: btnWidth,
|
|
81
79
|
height: btnWidth,
|
|
82
80
|
alignItems: "center",
|
|
@@ -102,12 +100,12 @@ const Calendar = (_a) => {
|
|
|
102
100
|
color: color
|
|
103
101
|
};
|
|
104
102
|
}
|
|
105
|
-
row.push(
|
|
103
|
+
row.push(jsx(Stack, { sx: {
|
|
106
104
|
width: btnWidth,
|
|
107
105
|
height: btnWidth,
|
|
108
106
|
alignItems: "center",
|
|
109
107
|
justifyContent: "center"
|
|
110
|
-
}, className: 'calender-day-item', children:
|
|
108
|
+
}, className: 'calender-day-item', children: jsx(IconButton, Object.assign({ className: 'calender-day-button', variant: isSelected ? "fill" : "text", color: isToday ? color : "default" }, css, { "data-value": date, onClick: (e) => {
|
|
111
109
|
let d = e.target.getAttribute("data-value");
|
|
112
110
|
if (!d)
|
|
113
111
|
return;
|
|
@@ -118,7 +116,7 @@ const Calendar = (_a) => {
|
|
|
118
116
|
date++;
|
|
119
117
|
}
|
|
120
118
|
}
|
|
121
|
-
rows.push(
|
|
119
|
+
rows.push(jsx(Stack, { flexRow: true, className: 'calender-day-row', children: row }, "row" + i));
|
|
122
120
|
}
|
|
123
121
|
return rows;
|
|
124
122
|
};
|
|
@@ -127,7 +125,7 @@ const Calendar = (_a) => {
|
|
|
127
125
|
const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
128
126
|
for (let m = 0; m < monthNames.length; m++) {
|
|
129
127
|
const selected = currentDate.getMonth() === m;
|
|
130
|
-
months.push(
|
|
128
|
+
months.push(jsx(Stack, { width: "50%", alignItems: "center", justifyContent: "center", p: .1, className: 'calender-months-item', children: jsx(Button, { color: selected ? color : "default", className: 'calender-month-button', size: 'small', corner: "circle", variant: selected ? "fill" : 'text', onClick: () => {
|
|
131
129
|
const v = new Date(currentDate.getFullYear(), m);
|
|
132
130
|
setCurrentDate(v);
|
|
133
131
|
setViewMode("day");
|
|
@@ -136,7 +134,7 @@ const Calendar = (_a) => {
|
|
|
136
134
|
color: selected ? "brand.text" : "text.primary"
|
|
137
135
|
}, children: monthNames[m] }) }, m));
|
|
138
136
|
}
|
|
139
|
-
return (
|
|
137
|
+
return (jsx(Stack, { className: 'calender-months', sx: {
|
|
140
138
|
flexWrap: "wrap",
|
|
141
139
|
overflow: "hidden",
|
|
142
140
|
overflowY: "auto",
|
|
@@ -146,7 +144,7 @@ const Calendar = (_a) => {
|
|
|
146
144
|
let view = null;
|
|
147
145
|
switch (viewMode) {
|
|
148
146
|
case "year":
|
|
149
|
-
view =
|
|
147
|
+
view = jsx(ShowYears, { color: color, today: today, year: year, boxWidth: boxWidth, onClick: (y) => {
|
|
150
148
|
currentDate.setFullYear(y);
|
|
151
149
|
setCurrentDate(currentDate);
|
|
152
150
|
setViewMode("month");
|
|
@@ -157,18 +155,18 @@ const Calendar = (_a) => {
|
|
|
157
155
|
view = showMonth();
|
|
158
156
|
break;
|
|
159
157
|
default:
|
|
160
|
-
view = (
|
|
158
|
+
view = (jsx(Fragment, { children: showCalendar() }));
|
|
161
159
|
break;
|
|
162
160
|
}
|
|
163
|
-
return (
|
|
161
|
+
return (jsx(ViewBox, { className: 'calender-root', maxHeight: 308, width: 250, radius: 1, bgcolor: "background.secondary", startContent: jsxs(Stack, { className: 'calender-header', flexRow: true, alignItems: "center", justifyContent: "space-between", p: 1, children: [jsx(Text, { fontWeight: "bold", cursor: "pointer", onClick: () => setViewMode(viewMode !== 'day' ? "day" : "year"), flex: 1, children: currentDate.toLocaleDateString(undefined, { year: 'numeric', month: 'long' }) }), jsx(IconButton, { color: "default", variant: 'text', size: 28, onClick: () => {
|
|
164
162
|
setCurrentDate(new Date());
|
|
165
163
|
onChange ? onChange(new Date()) : setSelectedDate(new Date());
|
|
166
|
-
}, children:
|
|
164
|
+
}, children: jsx(ResetIcon, { fontSize: 20 }) }), jsx(IconButton, { color: "default", variant: 'text', size: 28, onClick: () => {
|
|
167
165
|
setCurrentDate(new Date(currentDate.getFullYear(), currentDate.getMonth() - 1, 1));
|
|
168
|
-
}, children:
|
|
166
|
+
}, children: jsx(IconKeyboardArrowLeft, {}) }), jsx(IconButton, { color: "default", variant: 'text', size: 28, onClick: () => {
|
|
169
167
|
setCurrentDate(new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 1));
|
|
170
|
-
}, children:
|
|
168
|
+
}, children: jsx(IconKeyboardArrowRight, {}) })] }), children: jsx(Stack, { height: "100%", p: .5, className: 'calender-container', children: view }) }));
|
|
171
169
|
};
|
|
172
170
|
|
|
173
|
-
|
|
171
|
+
export { Calendar as default };
|
|
174
172
|
//# sourceMappingURL=index.js.map
|
package/Calendar/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Calendar/index.tsx"],"sourcesContent":["\"use client\";\r\nimport { useEffect, useRef, useState } from 'react';\r\nimport Stack from '../Stack'\r\nimport IconButton from '../IconButton';\r\nimport IconKeyboardArrowRight from '@xanui/icons/KeyboardArrowRight';\r\nimport IconKeyboardArrowLeft from '@xanui/icons/KeyboardArrowLeft';\r\nimport Text from '../Text';\r\nimport Button from '../Button';\r\nimport ResetIcon from '@xanui/icons/Replay';\r\nimport ViewBox from '../ViewBox';\r\nimport { UseColorTemplateColor, useInterface, useBreakpointPropsType, useBreakpointProps } from '@xanui/core';\r\n\r\nexport type CalendarProps = {\r\n value?: Date | null;\r\n onChange?: (date: Date | null) => void;\r\n viewMode?: useBreakpointPropsType<\"year\" | \"month\" | \"day\">;\r\n onButtonClick?: (mode: CalendarProps[\"viewMode\"], value: CalendarProps[\"value\"]) => void;\r\n color?: useBreakpointPropsType<UseColorTemplateColor>;\r\n}\r\n\r\n\r\nconst ShowYears = ({ color, year, today, onClick }: any) => {\r\n let years: any[] = []\r\n const selectedRef: any = useRef(null)\r\n for (let y = 1900; y < today.getFullYear() + 40; y++) {\r\n const selected = year == y\r\n years.push(<Stack\r\n key={y}\r\n sx={{\r\n width: 50,\r\n p: .1\r\n }}\r\n className='calender-year-item'\r\n >\r\n <Button\r\n color={selected ? color : \"default\"}\r\n className='calender-year-button'\r\n size='small'\r\n corner=\"circle\"\r\n ref={selected ? selectedRef : null}\r\n onClick={() => onClick(y)}\r\n variant={selected ? \"fill\" : \"text\"}\r\n >\r\n {y}\r\n </Button>\r\n </Stack>)\r\n }\r\n\r\n useEffect(() => {\r\n if (selectedRef?.current) {\r\n selectedRef?.current.scrollIntoView({ behavior: \"smooth\", block: \"center\", inline: \"nearest\" })\r\n }\r\n }, [])\r\n\r\n return (\r\n <Stack\r\n sx={{\r\n flexWrap: \"wrap\",\r\n flexDirection: \"row\",\r\n overflow: \"hidden\",\r\n overflowY: \"auto\"\r\n }}\r\n className='calender-years'\r\n >\r\n {years}\r\n </Stack>\r\n )\r\n}\r\n\r\n\r\nconst Calendar = ({ value, ...rest }: CalendarProps) => {\r\n let [{ onChange, viewMode: VMode, onButtonClick, color }] = useInterface<any>(\"Calender\", rest, {})\r\n const _p: any = {}\r\n if (VMode) _p.VMode = VMode\r\n if (color) _p.color = color\r\n const p: any = useBreakpointProps(_p)\r\n color = p.color || \"brand\"\r\n\r\n let [viewMode, setViewMode] = useState<any>(p.VMode || \"day\");\r\n let [selectedDate, setSelectedDate] = useState(new Date());\r\n selectedDate = value instanceof Date ? value : selectedDate\r\n const [currentDate, setCurrentDate] = useState(selectedDate);\r\n const year = currentDate.getFullYear()\r\n const month = currentDate.getMonth()\r\n const daysInMonth = 32 - new Date(year, month, 32).getDate()\r\n const today = new Date();\r\n const btnWidth = 36\r\n const boxWidth = btnWidth * 7\r\n\r\n const showCalendar = () => {\r\n\r\n let firstDay = (new Date(year, month)).getDay();\r\n let rows = []\r\n let row = []\r\n\r\n const dayNames = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];\r\n for (let i = 0; i < dayNames.length; i++) {\r\n const k = dayNames[i];\r\n row.push(<Stack\r\n key={\"dayname-\" + i}\r\n sx={{\r\n width: btnWidth,\r\n height: btnWidth,\r\n alignItems: \"center\",\r\n justifyContent: \"center\"\r\n }}\r\n >\r\n <IconButton\r\n variant={\"text\"}\r\n color=\"default\"\r\n disabled\r\n >\r\n {k}\r\n </IconButton>\r\n </Stack>)\r\n }\r\n\r\n rows.push(<Stack flexRow key={\"header\"} className='calender-day-row'>\r\n {row}\r\n </Stack>);\r\n\r\n let date = 1;\r\n for (let i = 0; i < 6; i++) {\r\n let row = []\r\n for (let j = 0; j < 7; j++) {\r\n if (i === 0 && j < firstDay) {\r\n row.push(<Stack\r\n alignItems=\"center\"\r\n justifyContent=\"center\"\r\n key={date + j + i}\r\n sx={{\r\n width: btnWidth,\r\n height: btnWidth,\r\n alignItems: \"center\",\r\n justifyContent: \"center\"\r\n }}\r\n >\r\n\r\n </Stack>)\r\n } else if (date > daysInMonth) {\r\n break;\r\n } else {\r\n let isToday = date === today.getDate() && year === today.getFullYear() && month === today.getMonth()\r\n let isSelected = date === selectedDate.getDate() && year === selectedDate.getFullYear() && month === selectedDate.getMonth()\r\n\r\n let css: any = {}\r\n if (isToday) {\r\n css = {\r\n variant: \"fill\",\r\n color: \"default\"\r\n }\r\n }\r\n\r\n if (isSelected) {\r\n css = {\r\n variant: \"fill\",\r\n color: color\r\n }\r\n }\r\n\r\n row.push(<Stack\r\n sx={{\r\n width: btnWidth,\r\n height: btnWidth,\r\n alignItems: \"center\",\r\n justifyContent: \"center\"\r\n }}\r\n key={date + j + i}\r\n className='calender-day-item'\r\n >\r\n <IconButton\r\n className='calender-day-button'\r\n variant={isSelected ? \"fill\" : \"text\"}\r\n color={isToday ? color : \"default\"}\r\n {...css}\r\n data-value={date}\r\n onClick={(e: any) => {\r\n let d = e.target.getAttribute(\"data-value\")\r\n if (!d) return\r\n let selectedDate = new Date(year, month, parseInt(d))\r\n onChange ? onChange(selectedDate) : setSelectedDate(selectedDate)\r\n onButtonClick && onButtonClick(\"day\", selectedDate)\r\n }}\r\n >\r\n {date}\r\n </IconButton>\r\n </Stack>)\r\n date++;\r\n }\r\n }\r\n rows.push(<Stack flexRow key={\"row\" + i} className='calender-day-row'>\r\n {row}\r\n </Stack>);\r\n }\r\n return rows\r\n }\r\n\r\n const showMonth = () => {\r\n let months: any[] = []\r\n const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\r\n for (let m = 0; m < monthNames.length; m++) {\r\n const selected = currentDate.getMonth() === m\r\n\r\n months.push(<Stack\r\n key={m}\r\n width={\"50%\"}\r\n alignItems=\"center\"\r\n justifyContent=\"center\"\r\n p={.1}\r\n className='calender-months-item'\r\n >\r\n <Button\r\n color={selected ? color : \"default\"}\r\n className='calender-month-button'\r\n size='small'\r\n corner=\"circle\"\r\n variant={selected ? \"fill\" : 'text'}\r\n onClick={() => {\r\n const v = new Date(currentDate.getFullYear(), m)\r\n setCurrentDate(v)\r\n setViewMode(\"day\")\r\n onButtonClick && onButtonClick(\"month\", v)\r\n }}\r\n sx={{\r\n color: selected ? \"brand.text\" : \"text.primary\"\r\n }}\r\n >\r\n {monthNames[m]}\r\n </Button>\r\n </Stack>)\r\n }\r\n\r\n return (\r\n <Stack\r\n className='calender-months'\r\n sx={{\r\n flexWrap: \"wrap\",\r\n overflow: \"hidden\",\r\n overflowY: \"auto\",\r\n flexDirection: \"row\"\r\n }}\r\n >\r\n {months}\r\n </Stack>\r\n )\r\n }\r\n\r\n let view: any = null\r\n switch (viewMode) {\r\n case \"year\":\r\n view = <ShowYears\r\n color={color}\r\n today={today}\r\n year={year}\r\n boxWidth={boxWidth}\r\n onClick={(y: any) => {\r\n currentDate.setFullYear(y)\r\n setCurrentDate(currentDate)\r\n setViewMode(\"month\")\r\n onButtonClick && onButtonClick(\"year\", currentDate)\r\n }}\r\n />\r\n break;\r\n case \"month\":\r\n view = showMonth()\r\n break;\r\n default:\r\n view = (<>\r\n\r\n {showCalendar()}\r\n </>\r\n )\r\n break;\r\n }\r\n\r\n return (\r\n <ViewBox\r\n className='calender-root'\r\n maxHeight={308}\r\n width={250}\r\n radius={1}\r\n bgcolor=\"background.secondary\"\r\n startContent={\r\n <Stack className='calender-header' flexRow alignItems=\"center\" justifyContent=\"space-between\" p={1}>\r\n <Text\r\n fontWeight=\"bold\"\r\n cursor=\"pointer\"\r\n onClick={() => setViewMode(viewMode !== 'day' ? \"day\" : \"year\")}\r\n flex={1}\r\n >\r\n {currentDate.toLocaleDateString(undefined, { year: 'numeric', month: 'long' })}\r\n </Text>\r\n <IconButton\r\n color=\"default\"\r\n variant='text'\r\n size={28}\r\n onClick={() => {\r\n setCurrentDate(new Date())\r\n onChange ? onChange(new Date()) : setSelectedDate(new Date())\r\n }}\r\n >\r\n <ResetIcon fontSize={20} />\r\n </IconButton>\r\n <IconButton\r\n color=\"default\"\r\n variant='text'\r\n size={28}\r\n onClick={() => {\r\n setCurrentDate(new Date(currentDate.getFullYear(), currentDate.getMonth() - 1, 1))\r\n }}\r\n >\r\n <IconKeyboardArrowLeft />\r\n </IconButton>\r\n <IconButton\r\n color=\"default\"\r\n variant='text'\r\n size={28}\r\n onClick={() => {\r\n setCurrentDate(new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 1))\r\n }}\r\n >\r\n <IconKeyboardArrowRight />\r\n </IconButton>\r\n </Stack>\r\n }\r\n >\r\n <Stack height=\"100%\" p={.5} className='calender-container'>\r\n {view}\r\n </Stack>\r\n </ViewBox>\r\n );\r\n};\r\n\r\nexport default Calendar;"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAqBA;;AAEI;AACA;AACI;AACA;AAGQ;AACA;AACH;;;;;;;AAuBT;AAGY;AACA;AACA;AACA;AACH;AAMb;AAGA;AAAkB;;;AAGd;AAAW;AACX;AAAW;AACX;AACA;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAII;;;AAIA;AACA;AACI;AACA;AAGQ;AACA;AACA;AACA;;;AAaZ;;AAKA;;AAEI;;AAEQ;AAKQ;AACA;AACA;AACA;AACH;;AAIF;;;;;;;;AAQC;AACI;AACA;;;;AAKJ;AACI;AACA;;;AAIR;AAEQ;AACA;AACA;AACA;;;AAaI;;AACA;AACA;AACA;;AAMZ;;;AAGR;;AAIJ;AACJ;;;;AAKI;;AAGI;AAeY;;;AAGA;;;;;;AAeJ;AACA;AACA;AACA;;AAMhB;;;AAII;;AAOY;;;AAGA;AACJ;;AAGR;;;AAGA;AACI;;;;AA8BgB;AACA;AACJ;AASI;;AAUA;;AAa5B;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Calendar/index.tsx"],"sourcesContent":["\"use client\";\r\nimport { useEffect, useRef, useState } from 'react';\r\nimport Stack from '../Stack'\r\nimport IconButton from '../IconButton';\r\nimport IconKeyboardArrowRight from '@xanui/icons/KeyboardArrowRight';\r\nimport IconKeyboardArrowLeft from '@xanui/icons/KeyboardArrowLeft';\r\nimport Text from '../Text';\r\nimport Button from '../Button';\r\nimport ResetIcon from '@xanui/icons/Replay';\r\nimport ViewBox from '../ViewBox';\r\nimport { UseColorTemplateColor, useInterface, useBreakpointPropsType, useBreakpointProps } from '@xanui/core';\r\n\r\nexport type CalendarProps = {\r\n value?: Date | null;\r\n onChange?: (date: Date | null) => void;\r\n viewMode?: useBreakpointPropsType<\"year\" | \"month\" | \"day\">;\r\n onButtonClick?: (mode: CalendarProps[\"viewMode\"], value: CalendarProps[\"value\"]) => void;\r\n color?: useBreakpointPropsType<UseColorTemplateColor>;\r\n}\r\n\r\n\r\nconst ShowYears = ({ color, year, today, onClick }: any) => {\r\n let years: any[] = []\r\n const selectedRef: any = useRef(null)\r\n for (let y = 1900; y < today.getFullYear() + 40; y++) {\r\n const selected = year == y\r\n years.push(<Stack\r\n key={y}\r\n sx={{\r\n width: 50,\r\n p: .1\r\n }}\r\n className='calender-year-item'\r\n >\r\n <Button\r\n color={selected ? color : \"default\"}\r\n className='calender-year-button'\r\n size='small'\r\n corner=\"circle\"\r\n ref={selected ? selectedRef : null}\r\n onClick={() => onClick(y)}\r\n variant={selected ? \"fill\" : \"text\"}\r\n >\r\n {y}\r\n </Button>\r\n </Stack>)\r\n }\r\n\r\n useEffect(() => {\r\n if (selectedRef?.current) {\r\n selectedRef?.current.scrollIntoView({ behavior: \"smooth\", block: \"center\", inline: \"nearest\" })\r\n }\r\n }, [])\r\n\r\n return (\r\n <Stack\r\n sx={{\r\n flexWrap: \"wrap\",\r\n flexDirection: \"row\",\r\n overflow: \"hidden\",\r\n overflowY: \"auto\"\r\n }}\r\n className='calender-years'\r\n >\r\n {years}\r\n </Stack>\r\n )\r\n}\r\n\r\n\r\nconst Calendar = ({ value, ...rest }: CalendarProps) => {\r\n let [{ onChange, viewMode: VMode, onButtonClick, color }] = useInterface<any>(\"Calender\", rest, {})\r\n const _p: any = {}\r\n if (VMode) _p.VMode = VMode\r\n if (color) _p.color = color\r\n const p: any = useBreakpointProps(_p)\r\n color = p.color || \"brand\"\r\n\r\n let [viewMode, setViewMode] = useState<any>(p.VMode || \"day\");\r\n let [selectedDate, setSelectedDate] = useState(new Date());\r\n selectedDate = value instanceof Date ? value : selectedDate\r\n const [currentDate, setCurrentDate] = useState(selectedDate);\r\n const year = currentDate.getFullYear()\r\n const month = currentDate.getMonth()\r\n const daysInMonth = 32 - new Date(year, month, 32).getDate()\r\n const today = new Date();\r\n const btnWidth = 36\r\n const boxWidth = btnWidth * 7\r\n\r\n const showCalendar = () => {\r\n\r\n let firstDay = (new Date(year, month)).getDay();\r\n let rows = []\r\n let row = []\r\n\r\n const dayNames = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];\r\n for (let i = 0; i < dayNames.length; i++) {\r\n const k = dayNames[i];\r\n row.push(<Stack\r\n key={\"dayname-\" + i}\r\n sx={{\r\n width: btnWidth,\r\n height: btnWidth,\r\n alignItems: \"center\",\r\n justifyContent: \"center\"\r\n }}\r\n >\r\n <IconButton\r\n variant={\"text\"}\r\n color=\"default\"\r\n disabled\r\n >\r\n {k}\r\n </IconButton>\r\n </Stack>)\r\n }\r\n\r\n rows.push(<Stack flexRow key={\"header\"} className='calender-day-row'>\r\n {row}\r\n </Stack>);\r\n\r\n let date = 1;\r\n for (let i = 0; i < 6; i++) {\r\n let row = []\r\n for (let j = 0; j < 7; j++) {\r\n if (i === 0 && j < firstDay) {\r\n row.push(<Stack\r\n alignItems=\"center\"\r\n justifyContent=\"center\"\r\n key={date + j + i}\r\n sx={{\r\n width: btnWidth,\r\n height: btnWidth,\r\n alignItems: \"center\",\r\n justifyContent: \"center\"\r\n }}\r\n >\r\n\r\n </Stack>)\r\n } else if (date > daysInMonth) {\r\n break;\r\n } else {\r\n let isToday = date === today.getDate() && year === today.getFullYear() && month === today.getMonth()\r\n let isSelected = date === selectedDate.getDate() && year === selectedDate.getFullYear() && month === selectedDate.getMonth()\r\n\r\n let css: any = {}\r\n if (isToday) {\r\n css = {\r\n variant: \"fill\",\r\n color: \"default\"\r\n }\r\n }\r\n\r\n if (isSelected) {\r\n css = {\r\n variant: \"fill\",\r\n color: color\r\n }\r\n }\r\n\r\n row.push(<Stack\r\n sx={{\r\n width: btnWidth,\r\n height: btnWidth,\r\n alignItems: \"center\",\r\n justifyContent: \"center\"\r\n }}\r\n key={date + j + i}\r\n className='calender-day-item'\r\n >\r\n <IconButton\r\n className='calender-day-button'\r\n variant={isSelected ? \"fill\" : \"text\"}\r\n color={isToday ? color : \"default\"}\r\n {...css}\r\n data-value={date}\r\n onClick={(e: any) => {\r\n let d = e.target.getAttribute(\"data-value\")\r\n if (!d) return\r\n let selectedDate = new Date(year, month, parseInt(d))\r\n onChange ? onChange(selectedDate) : setSelectedDate(selectedDate)\r\n onButtonClick && onButtonClick(\"day\", selectedDate)\r\n }}\r\n >\r\n {date}\r\n </IconButton>\r\n </Stack>)\r\n date++;\r\n }\r\n }\r\n rows.push(<Stack flexRow key={\"row\" + i} className='calender-day-row'>\r\n {row}\r\n </Stack>);\r\n }\r\n return rows\r\n }\r\n\r\n const showMonth = () => {\r\n let months: any[] = []\r\n const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\r\n for (let m = 0; m < monthNames.length; m++) {\r\n const selected = currentDate.getMonth() === m\r\n\r\n months.push(<Stack\r\n key={m}\r\n width={\"50%\"}\r\n alignItems=\"center\"\r\n justifyContent=\"center\"\r\n p={.1}\r\n className='calender-months-item'\r\n >\r\n <Button\r\n color={selected ? color : \"default\"}\r\n className='calender-month-button'\r\n size='small'\r\n corner=\"circle\"\r\n variant={selected ? \"fill\" : 'text'}\r\n onClick={() => {\r\n const v = new Date(currentDate.getFullYear(), m)\r\n setCurrentDate(v)\r\n setViewMode(\"day\")\r\n onButtonClick && onButtonClick(\"month\", v)\r\n }}\r\n sx={{\r\n color: selected ? \"brand.text\" : \"text.primary\"\r\n }}\r\n >\r\n {monthNames[m]}\r\n </Button>\r\n </Stack>)\r\n }\r\n\r\n return (\r\n <Stack\r\n className='calender-months'\r\n sx={{\r\n flexWrap: \"wrap\",\r\n overflow: \"hidden\",\r\n overflowY: \"auto\",\r\n flexDirection: \"row\"\r\n }}\r\n >\r\n {months}\r\n </Stack>\r\n )\r\n }\r\n\r\n let view: any = null\r\n switch (viewMode) {\r\n case \"year\":\r\n view = <ShowYears\r\n color={color}\r\n today={today}\r\n year={year}\r\n boxWidth={boxWidth}\r\n onClick={(y: any) => {\r\n currentDate.setFullYear(y)\r\n setCurrentDate(currentDate)\r\n setViewMode(\"month\")\r\n onButtonClick && onButtonClick(\"year\", currentDate)\r\n }}\r\n />\r\n break;\r\n case \"month\":\r\n view = showMonth()\r\n break;\r\n default:\r\n view = (<>\r\n\r\n {showCalendar()}\r\n </>\r\n )\r\n break;\r\n }\r\n\r\n return (\r\n <ViewBox\r\n className='calender-root'\r\n maxHeight={308}\r\n width={250}\r\n radius={1}\r\n bgcolor=\"background.secondary\"\r\n startContent={\r\n <Stack className='calender-header' flexRow alignItems=\"center\" justifyContent=\"space-between\" p={1}>\r\n <Text\r\n fontWeight=\"bold\"\r\n cursor=\"pointer\"\r\n onClick={() => setViewMode(viewMode !== 'day' ? \"day\" : \"year\")}\r\n flex={1}\r\n >\r\n {currentDate.toLocaleDateString(undefined, { year: 'numeric', month: 'long' })}\r\n </Text>\r\n <IconButton\r\n color=\"default\"\r\n variant='text'\r\n size={28}\r\n onClick={() => {\r\n setCurrentDate(new Date())\r\n onChange ? onChange(new Date()) : setSelectedDate(new Date())\r\n }}\r\n >\r\n <ResetIcon fontSize={20} />\r\n </IconButton>\r\n <IconButton\r\n color=\"default\"\r\n variant='text'\r\n size={28}\r\n onClick={() => {\r\n setCurrentDate(new Date(currentDate.getFullYear(), currentDate.getMonth() - 1, 1))\r\n }}\r\n >\r\n <IconKeyboardArrowLeft />\r\n </IconButton>\r\n <IconButton\r\n color=\"default\"\r\n variant='text'\r\n size={28}\r\n onClick={() => {\r\n setCurrentDate(new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 1))\r\n }}\r\n >\r\n <IconKeyboardArrowRight />\r\n </IconButton>\r\n </Stack>\r\n }\r\n >\r\n <Stack height=\"100%\" p={.5} className='calender-container'>\r\n {view}\r\n </Stack>\r\n </ViewBox>\r\n );\r\n};\r\n\r\nexport default Calendar;"],"names":[],"mappings":";;;;;;;;;;;;;;AAqBA;;AAEI;AACA;AACI;AACA;AAGQ;AACA;AACH;;;;;;;AAuBT;AAGY;AACA;AACA;AACA;AACH;AAMb;AAGA;AAAkB;;;AAGd;AAAW;AACX;AAAW;AACX;AACA;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAII;;;AAIA;AACA;AACI;AACA;AAGQ;AACA;AACA;AACA;;;AAaZ;;AAKA;;AAEI;;AAEQ;AAKQ;AACA;AACA;AACA;AACH;;AAIF;;;;;;;;AAQC;AACI;AACA;;;;AAKJ;AACI;AACA;;;AAIR;AAEQ;AACA;AACA;AACA;;;AAaI;;AACA;AACA;AACA;;AAMZ;;;AAGR;;AAIJ;AACJ;;;;AAKI;;AAGI;AAeY;;;AAGA;;;;;;AAeJ;AACA;AACA;AACA;;AAMhB;;;AAII;;AAOY;;;AAGA;AACJ;;AAGR;;;AAGA;AACI;;;;AA8BgB;AACA;AACJ;AASI;;AAUA;;AAa5B;;"}
|