@canlooks/can-ui 0.0.118 → 0.0.120
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/dist/cjs/components/calendar/calendar.d.ts +2 -1
- package/dist/cjs/components/calendar/calendar.js +2 -1
- package/dist/cjs/components/calendar/panelDates.d.ts +1 -1
- package/dist/cjs/components/calendar/panelDates.js +13 -5
- package/dist/cjs/components/divider/divider.style.js +2 -0
- package/dist/cjs/components/flex/flex.js +1 -1
- package/dist/cjs/utils/cubedStyles.d.ts +8 -0
- package/dist/cjs/utils/cubedStyles.js +25 -0
- package/dist/cjs/utils/style.d.ts +1 -1
- package/dist/cjs/utils/style.js +3 -2
- package/dist/esm/components/calendar/calendar.d.ts +2 -1
- package/dist/esm/components/calendar/calendar.js +2 -1
- package/dist/esm/components/calendar/panelDates.d.ts +1 -1
- package/dist/esm/components/calendar/panelDates.js +12 -4
- package/dist/esm/components/divider/divider.style.js +2 -0
- package/dist/esm/components/flex/flex.js +1 -1
- package/dist/esm/utils/cubedStyles.d.ts +8 -0
- package/dist/esm/utils/cubedStyles.js +20 -0
- package/dist/esm/utils/style.d.ts +1 -1
- package/dist/esm/utils/style.js +3 -2
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ export type ViewLevel = 'date' | 'month' | 'year';
|
|
|
7
7
|
type SharedProps = {
|
|
8
8
|
min?: Dayjs;
|
|
9
9
|
max?: Dayjs;
|
|
10
|
+
dateButtonProps?: ButtonProps | ((date: Dayjs) => ButtonProps);
|
|
10
11
|
disabledDates?: (date: Dayjs) => boolean;
|
|
11
12
|
/** 是否显示`回今天`按钮,默认为`true` */
|
|
12
13
|
showToday?: boolean;
|
|
@@ -31,5 +32,5 @@ export interface PanelProps extends SharedProps {
|
|
|
31
32
|
setViewType: Dispatch<SetStateAction<'date' | 'month' | 'year'>>;
|
|
32
33
|
onSelected(newValue: Dayjs): void;
|
|
33
34
|
}
|
|
34
|
-
export declare const Calendar: ({ viewLevel, showToday, todayButtonText, todayButtonProps, size, defaultValue, min, max, disabledDates, value, onChange, _defaultNull, ...props }: CalendarProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare const Calendar: ({ viewLevel, showToday, dateButtonProps, todayButtonText, todayButtonProps, size, defaultValue, min, max, disabledDates, value, onChange, _defaultNull, ...props }: CalendarProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
35
36
|
export {};
|
|
@@ -11,7 +11,7 @@ const calendar_style_1 = require("./calendar.style");
|
|
|
11
11
|
const flex_1 = require("../flex");
|
|
12
12
|
const panelYear_1 = require("./panelYear");
|
|
13
13
|
const panelMonth_1 = require("./panelMonth");
|
|
14
|
-
const Calendar = ({ viewLevel = 'date', showToday = true, todayButtonText = '回今天', todayButtonProps, size = 'medium', defaultValue = null, min, max, disabledDates, value, onChange, _defaultNull, ...props }) => {
|
|
14
|
+
const Calendar = ({ viewLevel = 'date', showToday = true, dateButtonProps, todayButtonText = '回今天', todayButtonProps, size = 'medium', defaultValue = null, min, max, disabledDates, value, onChange, _defaultNull, ...props }) => {
|
|
15
15
|
const [innerValue, setInnerValue] = (0, utils_1.useControlled)(defaultValue, value, onChange);
|
|
16
16
|
const [viewType, setViewType] = (0, react_1.useState)(viewLevel);
|
|
17
17
|
const [innerD, setInnerD] = (0, react_1.useState)(() => innerValue.current ?? (0, dayjs_1.default)().startOf('date'));
|
|
@@ -34,6 +34,7 @@ const Calendar = ({ viewLevel = 'date', showToday = true, todayButtonText = '回
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
showToday,
|
|
37
|
+
dateButtonProps,
|
|
37
38
|
todayButtonText,
|
|
38
39
|
todayButtonProps,
|
|
39
40
|
_defaultNull
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { PanelProps } from './calendar';
|
|
2
|
-
export declare const PanelDates: import("react").MemoExoticComponent<({ value, setValue, innerD, setInnerD, setViewType, min, max, disabledDates, showToday, todayButtonText, todayButtonProps, _defaultNull }: PanelProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
2
|
+
export declare const PanelDates: import("react").MemoExoticComponent<({ value, setValue, innerD, setInnerD, setViewType, min, max, disabledDates, showToday, dateButtonProps, todayButtonText, todayButtonProps, _defaultNull }: PanelProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PanelDates = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = require("@emotion/react");
|
|
5
6
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
6
|
-
const
|
|
7
|
+
const react_2 = require("react");
|
|
7
8
|
const button_1 = require("../button");
|
|
8
9
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
9
10
|
const tooltip_1 = require("../tooltip");
|
|
@@ -13,6 +14,7 @@ const faAngleLeft_1 = require("@fortawesome/free-solid-svg-icons/faAngleLeft");
|
|
|
13
14
|
const faAngleRight_1 = require("@fortawesome/free-solid-svg-icons/faAngleRight");
|
|
14
15
|
const faAnglesRight_1 = require("@fortawesome/free-solid-svg-icons/faAnglesRight");
|
|
15
16
|
const calendar_style_1 = require("./calendar.style");
|
|
17
|
+
const utils_1 = require("../../utils");
|
|
16
18
|
const days = ['一', '二', '三', '四', '五', '六', '日'];
|
|
17
19
|
const renderedDaysList = (() => {
|
|
18
20
|
const ret = [];
|
|
@@ -26,7 +28,7 @@ const commonButtonProps = {
|
|
|
26
28
|
size: 'small',
|
|
27
29
|
color: 'text'
|
|
28
30
|
};
|
|
29
|
-
exports.PanelDates = (0,
|
|
31
|
+
exports.PanelDates = (0, react_2.memo)(({ value, setValue, innerD, setInnerD, setViewType, min, max, disabledDates, showToday, dateButtonProps, todayButtonText = '回今天', todayButtonProps, _defaultNull }) => {
|
|
30
32
|
const today = (0, dayjs_1.default)();
|
|
31
33
|
const prevMonth = () => {
|
|
32
34
|
setInnerD(d => d.subtract(1, 'month'));
|
|
@@ -63,15 +65,21 @@ exports.PanelDates = (0, react_1.memo)(({ value, setValue, innerD, setInnerD, se
|
|
|
63
65
|
const selected = !_defaultNull && _d.isSame(value, 'day');
|
|
64
66
|
const isCurrentMonth = _d.isSame(innerD, 'month');
|
|
65
67
|
const disabled = isDisabled(_d);
|
|
66
|
-
|
|
68
|
+
const outerProps = typeof dateButtonProps === 'function' ? dateButtonProps(_d) : dateButtonProps;
|
|
69
|
+
ret.push((0, react_1.createElement)(button_1.Button, { size: "small", variant: disabled || selected ? 'filled'
|
|
67
70
|
: isToday ? 'outlined'
|
|
68
|
-
: 'text',
|
|
71
|
+
: 'text', color: selected ? 'primary' : 'text', ...outerProps, key: i, className: (0, utils_1.clsx)(calendar_style_1.classes.dateItem, outerProps?.className), disabled: disabled, "data-other-month": !isCurrentMonth, onClick: e => {
|
|
72
|
+
outerProps?.onClick?.(e);
|
|
73
|
+
!selected && setValue(_d);
|
|
74
|
+
} }, _d.date()));
|
|
69
75
|
}
|
|
70
76
|
return ret;
|
|
71
77
|
};
|
|
72
78
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: calendar_style_1.classes.head, children: [(0, jsx_runtime_1.jsxs)("div", { className: calendar_style_1.classes.headSide, children: [renderHeadControl((0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faAnglesLeft_1.faAnglesLeft }), '上一年', prevYear), renderHeadControl((0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faAngleLeft_1.faAngleLeft }), '上一月', prevMonth)] }), (0, jsx_runtime_1.jsxs)("div", { className: calendar_style_1.classes.headSide, children: [renderHeadControl((0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faAngleRight_1.faAngleRight }), '下一月', nextMonth), renderHeadControl((0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faAnglesRight_1.faAnglesRight }), '下一年', nextYear)] }), (0, jsx_runtime_1.jsxs)("div", { className: calendar_style_1.classes.headCenter, children: [(0, jsx_runtime_1.jsxs)(button_1.Button, { ...commonButtonProps, className: calendar_style_1.classes.headButton, onClick: () => setViewType('year'), children: [innerD.year(), "\u5E74"] }), (0, jsx_runtime_1.jsxs)(button_1.Button, { ...commonButtonProps, className: calendar_style_1.classes.headButton, onClick: () => setViewType('month'), children: [(innerD.month() + 1).toString().padStart(2, '0'), "\u6708"] })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: calendar_style_1.classes.body, "data-view-type": "date", children: [renderedDaysList, renderDates()] }), showToday &&
|
|
73
79
|
(0, jsx_runtime_1.jsx)("div", { className: calendar_style_1.classes.foot, children: (0, jsx_runtime_1.jsx)(button_1.Button, { variant: "text", ...todayButtonProps, onClick: e => {
|
|
74
80
|
todayButtonProps?.onClick?.(e);
|
|
75
|
-
|
|
81
|
+
const d = (0, dayjs_1.default)();
|
|
82
|
+
setInnerD(d);
|
|
83
|
+
setValue(d);
|
|
76
84
|
}, children: todayButtonText }) })] }));
|
|
77
85
|
});
|
|
@@ -19,6 +19,7 @@ exports.style = (0, utils_1.defineCss)(({ spacing, divider }) => (0, react_1.css
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
&[data-orientation=horizontal] {
|
|
22
|
+
width: 100%;
|
|
22
23
|
display: flex;
|
|
23
24
|
|
|
24
25
|
.${exports.classes.line} {
|
|
@@ -27,6 +28,7 @@ exports.style = (0, utils_1.defineCss)(({ spacing, divider }) => (0, react_1.css
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
&[data-orientation=vertical] {
|
|
31
|
+
height: 100%;
|
|
30
32
|
display: inline-flex;
|
|
31
33
|
flex-direction: column;
|
|
32
34
|
|
|
@@ -6,7 +6,7 @@ const react_1 = require("react");
|
|
|
6
6
|
const flex_style_1 = require("./flex.style");
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
8
|
const transportStyle_1 = require("../transportStyle");
|
|
9
|
-
exports.Flex = (({ inline, direction = 'row', wrap, gap
|
|
9
|
+
exports.Flex = (({ inline, direction = 'row', wrap, gap, columnGap, rowGap, compact, ...props }) => {
|
|
10
10
|
const renderChildren = () => {
|
|
11
11
|
if (!compact) {
|
|
12
12
|
return props.children;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SerializedStyles } from '@emotion/react';
|
|
2
|
+
export type ConfigurableValue<T extends string | SerializedStyles> = T | T[] | (() => T | T[]);
|
|
3
|
+
export type ConfigMapping<T> = {
|
|
4
|
+
[K in keyof T]?: keyof T[K];
|
|
5
|
+
};
|
|
6
|
+
export declare function cubed<Def extends Record<string, Record<string, ConfigurableValue<Value>>>, Value extends string | SerializedStyles>(definitions: Def, defaultProps?: ConfigMapping<Def>): (props?: ConfigMapping<Def>) => Value[];
|
|
7
|
+
export declare function cubedClasses<Def extends Record<string, Record<string, ConfigurableValue<string>>>>(definitions: Def, defaultProps?: ConfigMapping<Def>): (props?: ConfigMapping<Def> | undefined) => string[];
|
|
8
|
+
export declare function cubedStyles<Def extends Record<string, Record<string, ConfigurableValue<SerializedStyles>>>>(definitions: Def, defaultProps?: ConfigMapping<Def>): (props?: ConfigMapping<Def> | undefined) => SerializedStyles[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cubed = cubed;
|
|
4
|
+
exports.cubedClasses = cubedClasses;
|
|
5
|
+
exports.cubedStyles = cubedStyles;
|
|
6
|
+
function cubed(definitions, defaultProps) {
|
|
7
|
+
return (props) => {
|
|
8
|
+
const resolvedValues = [];
|
|
9
|
+
const assignedProps = { ...defaultProps, ...props };
|
|
10
|
+
for (const p in assignedProps) {
|
|
11
|
+
const configurableValue = definitions[p][assignedProps[p].toString()];
|
|
12
|
+
const value = typeof configurableValue === 'function' ? configurableValue() : configurableValue;
|
|
13
|
+
Array.isArray(value)
|
|
14
|
+
? resolvedValues.push(...value)
|
|
15
|
+
: resolvedValues.push(value);
|
|
16
|
+
}
|
|
17
|
+
return resolvedValues;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function cubedClasses(definitions, defaultProps) {
|
|
21
|
+
return cubed(definitions, defaultProps);
|
|
22
|
+
}
|
|
23
|
+
function cubedStyles(definitions, defaultProps) {
|
|
24
|
+
return cubed(definitions, defaultProps);
|
|
25
|
+
}
|
|
@@ -58,7 +58,7 @@ export declare function useColor(colorPropsValue: ColorPropsValue | undefined):
|
|
|
58
58
|
*/
|
|
59
59
|
export declare function useTouchSpread(colorPropsValue: ColorPropsValue): (element: Animatable) => void;
|
|
60
60
|
/**
|
|
61
|
-
* 生成响应式样式,与{@link responsiveStyles}
|
|
61
|
+
* 生成响应式样式,与{@link responsiveStyles}的区别在于,本方法会遍历所有`breakpoints`,触发回调函数
|
|
62
62
|
* @param breakpoints 传入{@link Theme}中的断点,或自定义断点
|
|
63
63
|
* @param callback 每个断点触发一次回调
|
|
64
64
|
*/
|
package/dist/cjs/utils/style.js
CHANGED
|
@@ -38,8 +38,9 @@ function defineClasses(prefixName, names) {
|
|
|
38
38
|
});
|
|
39
39
|
return ret;
|
|
40
40
|
}
|
|
41
|
+
const INNER_PREFIX = 'CanUI';
|
|
41
42
|
function defineInnerClasses(prefixName, names) {
|
|
42
|
-
const prefix = definePrefix(
|
|
43
|
+
const prefix = definePrefix(`${INNER_PREFIX}-${(0, utils_1.humpToSegmented)(prefixName)}`);
|
|
43
44
|
const ret = { root: prefix() };
|
|
44
45
|
names?.forEach(name => {
|
|
45
46
|
ret[name] = prefix((0, utils_1.humpToSegmented)(name));
|
|
@@ -127,7 +128,7 @@ function useTouchSpread(colorPropsValue) {
|
|
|
127
128
|
};
|
|
128
129
|
}
|
|
129
130
|
/**
|
|
130
|
-
* 生成响应式样式,与{@link responsiveStyles}
|
|
131
|
+
* 生成响应式样式,与{@link responsiveStyles}的区别在于,本方法会遍历所有`breakpoints`,触发回调函数
|
|
131
132
|
* @param breakpoints 传入{@link Theme}中的断点,或自定义断点
|
|
132
133
|
* @param callback 每个断点触发一次回调
|
|
133
134
|
*/
|
|
@@ -7,6 +7,7 @@ export type ViewLevel = 'date' | 'month' | 'year';
|
|
|
7
7
|
type SharedProps = {
|
|
8
8
|
min?: Dayjs;
|
|
9
9
|
max?: Dayjs;
|
|
10
|
+
dateButtonProps?: ButtonProps | ((date: Dayjs) => ButtonProps);
|
|
10
11
|
disabledDates?: (date: Dayjs) => boolean;
|
|
11
12
|
/** 是否显示`回今天`按钮,默认为`true` */
|
|
12
13
|
showToday?: boolean;
|
|
@@ -31,5 +32,5 @@ export interface PanelProps extends SharedProps {
|
|
|
31
32
|
setViewType: Dispatch<SetStateAction<'date' | 'month' | 'year'>>;
|
|
32
33
|
onSelected(newValue: Dayjs): void;
|
|
33
34
|
}
|
|
34
|
-
export declare const Calendar: ({ viewLevel, showToday, todayButtonText, todayButtonProps, size, defaultValue, min, max, disabledDates, value, onChange, _defaultNull, ...props }: CalendarProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare const Calendar: ({ viewLevel, showToday, dateButtonProps, todayButtonText, todayButtonProps, size, defaultValue, min, max, disabledDates, value, onChange, _defaultNull, ...props }: CalendarProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
35
36
|
export {};
|
|
@@ -7,7 +7,7 @@ import { classes, style } from './calendar.style';
|
|
|
7
7
|
import { Flex } from '../flex';
|
|
8
8
|
import { PanelYear } from './panelYear';
|
|
9
9
|
import { PanelMonth } from './panelMonth';
|
|
10
|
-
export const Calendar = ({ viewLevel = 'date', showToday = true, todayButtonText = '回今天', todayButtonProps, size = 'medium', defaultValue = null, min, max, disabledDates, value, onChange, _defaultNull, ...props }) => {
|
|
10
|
+
export const Calendar = ({ viewLevel = 'date', showToday = true, dateButtonProps, todayButtonText = '回今天', todayButtonProps, size = 'medium', defaultValue = null, min, max, disabledDates, value, onChange, _defaultNull, ...props }) => {
|
|
11
11
|
const [innerValue, setInnerValue] = useControlled(defaultValue, value, onChange);
|
|
12
12
|
const [viewType, setViewType] = useState(viewLevel);
|
|
13
13
|
const [innerD, setInnerD] = useState(() => innerValue.current ?? dayjs().startOf('date'));
|
|
@@ -30,6 +30,7 @@ export const Calendar = ({ viewLevel = 'date', showToday = true, todayButtonText
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
showToday,
|
|
33
|
+
dateButtonProps,
|
|
33
34
|
todayButtonText,
|
|
34
35
|
todayButtonProps,
|
|
35
36
|
_defaultNull
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { PanelProps } from './calendar';
|
|
2
|
-
export declare const PanelDates: import("react").MemoExoticComponent<({ value, setValue, innerD, setInnerD, setViewType, min, max, disabledDates, showToday, todayButtonText, todayButtonProps, _defaultNull }: PanelProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
2
|
+
export declare const PanelDates: import("react").MemoExoticComponent<({ value, setValue, innerD, setInnerD, setViewType, min, max, disabledDates, showToday, dateButtonProps, todayButtonText, todayButtonProps, _defaultNull }: PanelProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createElement as _createElement } from "@emotion/react";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
3
|
import { memo } from 'react';
|
|
3
4
|
import { Button } from '../button';
|
|
@@ -9,6 +10,7 @@ import { faAngleLeft } from '@fortawesome/free-solid-svg-icons/faAngleLeft';
|
|
|
9
10
|
import { faAngleRight } from '@fortawesome/free-solid-svg-icons/faAngleRight';
|
|
10
11
|
import { faAnglesRight } from '@fortawesome/free-solid-svg-icons/faAnglesRight';
|
|
11
12
|
import { classes } from './calendar.style';
|
|
13
|
+
import { clsx } from '../../utils';
|
|
12
14
|
const days = ['一', '二', '三', '四', '五', '六', '日'];
|
|
13
15
|
const renderedDaysList = (() => {
|
|
14
16
|
const ret = [];
|
|
@@ -22,7 +24,7 @@ const commonButtonProps = {
|
|
|
22
24
|
size: 'small',
|
|
23
25
|
color: 'text'
|
|
24
26
|
};
|
|
25
|
-
export const PanelDates = memo(({ value, setValue, innerD, setInnerD, setViewType, min, max, disabledDates, showToday, todayButtonText = '回今天', todayButtonProps, _defaultNull }) => {
|
|
27
|
+
export const PanelDates = memo(({ value, setValue, innerD, setInnerD, setViewType, min, max, disabledDates, showToday, dateButtonProps, todayButtonText = '回今天', todayButtonProps, _defaultNull }) => {
|
|
26
28
|
const today = dayjs();
|
|
27
29
|
const prevMonth = () => {
|
|
28
30
|
setInnerD(d => d.subtract(1, 'month'));
|
|
@@ -59,15 +61,21 @@ export const PanelDates = memo(({ value, setValue, innerD, setInnerD, setViewTyp
|
|
|
59
61
|
const selected = !_defaultNull && _d.isSame(value, 'day');
|
|
60
62
|
const isCurrentMonth = _d.isSame(innerD, 'month');
|
|
61
63
|
const disabled = isDisabled(_d);
|
|
62
|
-
|
|
64
|
+
const outerProps = typeof dateButtonProps === 'function' ? dateButtonProps(_d) : dateButtonProps;
|
|
65
|
+
ret.push(_createElement(Button, { size: "small", variant: disabled || selected ? 'filled'
|
|
63
66
|
: isToday ? 'outlined'
|
|
64
|
-
: 'text',
|
|
67
|
+
: 'text', color: selected ? 'primary' : 'text', ...outerProps, key: i, className: clsx(classes.dateItem, outerProps?.className), disabled: disabled, "data-other-month": !isCurrentMonth, onClick: e => {
|
|
68
|
+
outerProps?.onClick?.(e);
|
|
69
|
+
!selected && setValue(_d);
|
|
70
|
+
} }, _d.date()));
|
|
65
71
|
}
|
|
66
72
|
return ret;
|
|
67
73
|
};
|
|
68
74
|
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: classes.head, children: [_jsxs("div", { className: classes.headSide, children: [renderHeadControl(_jsx(Icon, { icon: faAnglesLeft }), '上一年', prevYear), renderHeadControl(_jsx(Icon, { icon: faAngleLeft }), '上一月', prevMonth)] }), _jsxs("div", { className: classes.headSide, children: [renderHeadControl(_jsx(Icon, { icon: faAngleRight }), '下一月', nextMonth), renderHeadControl(_jsx(Icon, { icon: faAnglesRight }), '下一年', nextYear)] }), _jsxs("div", { className: classes.headCenter, children: [_jsxs(Button, { ...commonButtonProps, className: classes.headButton, onClick: () => setViewType('year'), children: [innerD.year(), "\u5E74"] }), _jsxs(Button, { ...commonButtonProps, className: classes.headButton, onClick: () => setViewType('month'), children: [(innerD.month() + 1).toString().padStart(2, '0'), "\u6708"] })] })] }), _jsxs("div", { className: classes.body, "data-view-type": "date", children: [renderedDaysList, renderDates()] }), showToday &&
|
|
69
75
|
_jsx("div", { className: classes.foot, children: _jsx(Button, { variant: "text", ...todayButtonProps, onClick: e => {
|
|
70
76
|
todayButtonProps?.onClick?.(e);
|
|
71
|
-
|
|
77
|
+
const d = dayjs();
|
|
78
|
+
setInnerD(d);
|
|
79
|
+
setValue(d);
|
|
72
80
|
}, children: todayButtonText }) })] }));
|
|
73
81
|
});
|
|
@@ -16,6 +16,7 @@ export const style = defineCss(({ spacing, divider }) => css `
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
&[data-orientation=horizontal] {
|
|
19
|
+
width: 100%;
|
|
19
20
|
display: flex;
|
|
20
21
|
|
|
21
22
|
.${classes.line} {
|
|
@@ -24,6 +25,7 @@ export const style = defineCss(({ spacing, divider }) => css `
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
&[data-orientation=vertical] {
|
|
28
|
+
height: 100%;
|
|
27
29
|
display: inline-flex;
|
|
28
30
|
flex-direction: column;
|
|
29
31
|
|
|
@@ -3,7 +3,7 @@ import { Children, cloneElement, isValidElement } from 'react';
|
|
|
3
3
|
import { classes } from './flex.style';
|
|
4
4
|
import { clsx, filterProperties } from '../../utils';
|
|
5
5
|
import { TransportStyle } from '../transportStyle';
|
|
6
|
-
export const Flex = (({ inline, direction = 'row', wrap, gap
|
|
6
|
+
export const Flex = (({ inline, direction = 'row', wrap, gap, columnGap, rowGap, compact, ...props }) => {
|
|
7
7
|
const renderChildren = () => {
|
|
8
8
|
if (!compact) {
|
|
9
9
|
return props.children;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SerializedStyles } from '@emotion/react';
|
|
2
|
+
export type ConfigurableValue<T extends string | SerializedStyles> = T | T[] | (() => T | T[]);
|
|
3
|
+
export type ConfigMapping<T> = {
|
|
4
|
+
[K in keyof T]?: keyof T[K];
|
|
5
|
+
};
|
|
6
|
+
export declare function cubed<Def extends Record<string, Record<string, ConfigurableValue<Value>>>, Value extends string | SerializedStyles>(definitions: Def, defaultProps?: ConfigMapping<Def>): (props?: ConfigMapping<Def>) => Value[];
|
|
7
|
+
export declare function cubedClasses<Def extends Record<string, Record<string, ConfigurableValue<string>>>>(definitions: Def, defaultProps?: ConfigMapping<Def>): (props?: ConfigMapping<Def> | undefined) => string[];
|
|
8
|
+
export declare function cubedStyles<Def extends Record<string, Record<string, ConfigurableValue<SerializedStyles>>>>(definitions: Def, defaultProps?: ConfigMapping<Def>): (props?: ConfigMapping<Def> | undefined) => SerializedStyles[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function cubed(definitions, defaultProps) {
|
|
2
|
+
return (props) => {
|
|
3
|
+
const resolvedValues = [];
|
|
4
|
+
const assignedProps = { ...defaultProps, ...props };
|
|
5
|
+
for (const p in assignedProps) {
|
|
6
|
+
const configurableValue = definitions[p][assignedProps[p].toString()];
|
|
7
|
+
const value = typeof configurableValue === 'function' ? configurableValue() : configurableValue;
|
|
8
|
+
Array.isArray(value)
|
|
9
|
+
? resolvedValues.push(...value)
|
|
10
|
+
: resolvedValues.push(value);
|
|
11
|
+
}
|
|
12
|
+
return resolvedValues;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function cubedClasses(definitions, defaultProps) {
|
|
16
|
+
return cubed(definitions, defaultProps);
|
|
17
|
+
}
|
|
18
|
+
export function cubedStyles(definitions, defaultProps) {
|
|
19
|
+
return cubed(definitions, defaultProps);
|
|
20
|
+
}
|
|
@@ -58,7 +58,7 @@ export declare function useColor(colorPropsValue: ColorPropsValue | undefined):
|
|
|
58
58
|
*/
|
|
59
59
|
export declare function useTouchSpread(colorPropsValue: ColorPropsValue): (element: Animatable) => void;
|
|
60
60
|
/**
|
|
61
|
-
* 生成响应式样式,与{@link responsiveStyles}
|
|
61
|
+
* 生成响应式样式,与{@link responsiveStyles}的区别在于,本方法会遍历所有`breakpoints`,触发回调函数
|
|
62
62
|
* @param breakpoints 传入{@link Theme}中的断点,或自定义断点
|
|
63
63
|
* @param callback 每个断点触发一次回调
|
|
64
64
|
*/
|
package/dist/esm/utils/style.js
CHANGED
|
@@ -22,8 +22,9 @@ export function defineClasses(prefixName, names) {
|
|
|
22
22
|
});
|
|
23
23
|
return ret;
|
|
24
24
|
}
|
|
25
|
+
const INNER_PREFIX = 'CanUI';
|
|
25
26
|
export function defineInnerClasses(prefixName, names) {
|
|
26
|
-
const prefix = definePrefix(
|
|
27
|
+
const prefix = definePrefix(`${INNER_PREFIX}-${humpToSegmented(prefixName)}`);
|
|
27
28
|
const ret = { root: prefix() };
|
|
28
29
|
names?.forEach(name => {
|
|
29
30
|
ret[name] = prefix(humpToSegmented(name));
|
|
@@ -111,7 +112,7 @@ export function useTouchSpread(colorPropsValue) {
|
|
|
111
112
|
};
|
|
112
113
|
}
|
|
113
114
|
/**
|
|
114
|
-
* 生成响应式样式,与{@link responsiveStyles}
|
|
115
|
+
* 生成响应式样式,与{@link responsiveStyles}的区别在于,本方法会遍历所有`breakpoints`,触发回调函数
|
|
115
116
|
* @param breakpoints 传入{@link Theme}中的断点,或自定义断点
|
|
116
117
|
* @param callback 每个断点触发一次回调
|
|
117
118
|
*/
|