@canlooks/can-ui 0.0.45 → 0.0.47
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/button/button.js +2 -2
- package/dist/cjs/components/button/button.style.js +2 -0
- package/dist/cjs/components/calendar/calendar.d.ts +32 -0
- package/dist/cjs/components/calendar/calendar.js +51 -0
- package/dist/cjs/components/calendar/calendar.style.d.ts +15 -0
- package/dist/cjs/components/{dateTimePicker → calendar}/calendar.style.js +131 -91
- package/dist/cjs/components/calendar/index.d.ts +1 -0
- package/dist/cjs/components/calendar/index.js +4 -0
- package/dist/cjs/components/calendar/panelDates.d.ts +2 -0
- package/dist/cjs/components/{dateTimePicker/calendarDates.js → calendar/panelDates.js} +11 -19
- package/dist/cjs/components/calendar/panelMonth.d.ts +2 -0
- package/dist/cjs/components/calendar/panelMonth.js +29 -0
- package/dist/cjs/components/calendar/panelYear.d.ts +2 -0
- package/dist/cjs/components/calendar/panelYear.js +36 -0
- package/dist/cjs/components/checkboxBase/checkboxBase.js +2 -2
- package/dist/cjs/components/colorPicker/colorPicker.js +2 -2
- package/dist/cjs/components/colorPicker/colorPicker.style.js +1 -1
- package/dist/cjs/components/dateTimePicker/dateTimePicker.d.ts +1 -1
- package/dist/cjs/components/dateTimePicker/dateTimePicker.js +10 -13
- package/dist/cjs/components/dateTimePicker/dateTimePicker.style.d.ts +4 -4
- package/dist/cjs/components/dateTimePicker/dateTimePicker.style.js +1 -1
- package/dist/cjs/components/dateTimePicker/index.d.ts +1 -1
- package/dist/cjs/components/dateTimePicker/index.js +1 -1
- package/dist/cjs/components/dateTimeRangePicker/dateTimeRangePicker.d.ts +1 -0
- package/dist/cjs/components/icon/icon.d.ts +6 -0
- package/dist/cjs/components/icon/icon.js +9 -0
- package/dist/cjs/components/icon/index.d.ts +1 -0
- package/dist/cjs/components/icon/index.js +4 -0
- package/dist/cjs/components/menuItem/menuItem.style.js +8 -3
- package/dist/cjs/components/pinchable/pinchable.style.js +1 -1
- package/dist/cjs/components/popper/popper.js +1 -1
- package/dist/cjs/components/slider/slider.d.ts +0 -1
- package/dist/cjs/components/tooltip/tooltip.style.js +1 -0
- package/dist/cjs/components/touchRipple/touchRipple.js +0 -4
- package/dist/cjs/components/waterfall/waterfall.style.js +1 -1
- package/dist/cjs/components/waterfall/waterfallItem.js +1 -1
- package/dist/cjs/extensions/documentViewer/documentViewer.js +1 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +2 -3
- package/dist/cjs/utils/style.d.ts +2 -2
- package/dist/cjs/utils/style.js +3 -3
- package/dist/esm/components/button/button.js +3 -3
- package/dist/esm/components/button/button.style.js +2 -0
- package/dist/esm/components/calendar/calendar.d.ts +32 -0
- package/dist/esm/components/calendar/calendar.js +46 -0
- package/dist/esm/components/calendar/calendar.style.d.ts +15 -0
- package/dist/esm/components/{dateTimePicker → calendar}/calendar.style.js +131 -91
- package/dist/esm/components/calendar/index.d.ts +1 -0
- package/dist/esm/components/calendar/index.js +1 -0
- package/dist/esm/components/calendar/panelDates.d.ts +2 -0
- package/dist/esm/components/{dateTimePicker/calendarDates.js → calendar/panelDates.js} +11 -19
- package/dist/esm/components/calendar/panelMonth.d.ts +2 -0
- package/dist/esm/components/calendar/panelMonth.js +26 -0
- package/dist/esm/components/calendar/panelYear.d.ts +2 -0
- package/dist/esm/components/calendar/panelYear.js +33 -0
- package/dist/esm/components/checkboxBase/checkboxBase.js +3 -3
- package/dist/esm/components/colorPicker/colorPicker.js +3 -3
- package/dist/esm/components/colorPicker/colorPicker.style.js +1 -1
- package/dist/esm/components/dateTimePicker/dateTimePicker.d.ts +1 -1
- package/dist/esm/components/dateTimePicker/dateTimePicker.js +11 -14
- package/dist/esm/components/dateTimePicker/dateTimePicker.style.d.ts +4 -4
- package/dist/esm/components/dateTimePicker/dateTimePicker.style.js +1 -1
- package/dist/esm/components/dateTimePicker/index.d.ts +1 -1
- package/dist/esm/components/dateTimePicker/index.js +1 -1
- package/dist/esm/components/dateTimeRangePicker/dateTimeRangePicker.d.ts +1 -0
- package/dist/esm/components/icon/icon.d.ts +6 -0
- package/dist/esm/components/icon/icon.js +6 -0
- package/dist/esm/components/icon/index.d.ts +1 -0
- package/dist/esm/components/icon/index.js +1 -0
- package/dist/esm/components/menuItem/menuItem.style.js +8 -3
- package/dist/esm/components/pinchable/pinchable.style.js +2 -2
- package/dist/esm/components/popper/popper.js +1 -1
- package/dist/esm/components/slider/slider.d.ts +0 -1
- package/dist/esm/components/tooltip/tooltip.style.js +1 -0
- package/dist/esm/components/touchRipple/touchRipple.js +0 -4
- package/dist/esm/components/waterfall/waterfall.style.js +2 -2
- package/dist/esm/components/waterfall/waterfallItem.js +1 -1
- package/dist/esm/extensions/documentViewer/documentViewer.js +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/utils/style.d.ts +2 -2
- package/dist/esm/utils/style.js +2 -2
- package/documentation/dist/assets/{index-Dqm5gD_7.js → index-DpTyMkMP.js} +1707 -1660
- package/documentation/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/cjs/components/dateTimePicker/calendar.d.ts +0 -18
- package/dist/cjs/components/dateTimePicker/calendar.js +0 -29
- package/dist/cjs/components/dateTimePicker/calendar.style.d.ts +0 -15
- package/dist/cjs/components/dateTimePicker/calendarDates.d.ts +0 -2
- package/dist/cjs/components/dateTimePicker/calendarMonths.d.ts +0 -2
- package/dist/cjs/components/dateTimePicker/calendarMonths.js +0 -22
- package/dist/cjs/components/dateTimePicker/calendarYears.d.ts +0 -2
- package/dist/cjs/components/dateTimePicker/calendarYears.js +0 -29
- package/dist/esm/components/dateTimePicker/calendar.d.ts +0 -18
- package/dist/esm/components/dateTimePicker/calendar.js +0 -25
- package/dist/esm/components/dateTimePicker/calendar.style.d.ts +0 -15
- package/dist/esm/components/dateTimePicker/calendarDates.d.ts +0 -2
- package/dist/esm/components/dateTimePicker/calendarMonths.d.ts +0 -2
- package/dist/esm/components/dateTimePicker/calendarMonths.js +0 -19
- package/dist/esm/components/dateTimePicker/calendarYears.d.ts +0 -2
- package/dist/esm/components/dateTimePicker/calendarYears.js +0 -26
|
@@ -11,7 +11,7 @@ const utils_1 = require("../../utils");
|
|
|
11
11
|
const dateTimePicker_style_1 = require("./dateTimePicker.style");
|
|
12
12
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
13
13
|
const customParseFormat_1 = tslib_1.__importDefault(require("dayjs/plugin/customParseFormat"));
|
|
14
|
-
const calendar_1 = require("
|
|
14
|
+
const calendar_1 = require("../calendar");
|
|
15
15
|
const timer_1 = require("./timer");
|
|
16
16
|
const __1 = require("../..");
|
|
17
17
|
const faCalendar_1 = require("@fortawesome/free-regular-svg-icons/faCalendar");
|
|
@@ -81,11 +81,11 @@ exports.DateTimePicker = (0, react_1.memo)(({ inputProps, popperProps, min, max,
|
|
|
81
81
|
}
|
|
82
82
|
selectFn();
|
|
83
83
|
};
|
|
84
|
-
const focusHandler = (
|
|
84
|
+
const focusHandler = () => {
|
|
85
85
|
focused.current = true;
|
|
86
86
|
selectFn();
|
|
87
87
|
};
|
|
88
|
-
const blurHandler = (
|
|
88
|
+
const blurHandler = () => {
|
|
89
89
|
resetContinue();
|
|
90
90
|
focused.current = false;
|
|
91
91
|
_setInnerOpen(false);
|
|
@@ -207,21 +207,18 @@ exports.DateTimePicker = (0, react_1.memo)(({ inputProps, popperProps, min, max,
|
|
|
207
207
|
input.setSelectionRange(nextRange.start, nextRange.end);
|
|
208
208
|
};
|
|
209
209
|
const contextValue = (0, react_1.useMemo)(() => ({
|
|
210
|
-
min, max,
|
|
211
|
-
disabledHours, disabledMinutes, disabledSeconds
|
|
210
|
+
min, max, disabledHours, disabledMinutes, disabledSeconds
|
|
212
211
|
}), [
|
|
213
|
-
min, max,
|
|
214
|
-
disabledHours, disabledMinutes, disabledSeconds
|
|
212
|
+
min, max, disabledHours, disabledMinutes, disabledSeconds
|
|
215
213
|
]);
|
|
216
214
|
const showCalendar = /[YMD]/.test(format);
|
|
217
215
|
const showTimer = /[Hms]/.test(format);
|
|
218
216
|
const _dateVal = dateValue.current || (0, dayjs_1.default)();
|
|
219
|
-
return ((0, jsx_runtime_1.jsx)(popper_1.Popper, { css: dateTimePicker_style_1.datePickerPopperStyle, open: innerOpen.current, placement: "bottomLeft", trigger: ['click', 'enter'], disabled: props.disabled || props.readOnly, content: (0, jsx_runtime_1.jsxs)(
|
|
220
|
-
(0, jsx_runtime_1.jsx)(calendar_1.Calendar, {
|
|
221
|
-
: format.includes('M') ? '
|
|
222
|
-
:
|
|
223
|
-
|
|
224
|
-
(0, jsx_runtime_1.jsx)(timer_1.Timer, { showHours: format.includes('H'), showMinutes: format.includes('m'), showSeconds: format.includes('s'), value: _dateVal, onChange: setDateValue })] }), ...popperProps, onOpenChange: setInnerOpen, onPointerDown: e => {
|
|
217
|
+
return ((0, jsx_runtime_1.jsx)(popper_1.Popper, { css: dateTimePicker_style_1.datePickerPopperStyle, open: innerOpen.current, placement: "bottomLeft", trigger: ['click', 'enter'], disabled: props.disabled || props.readOnly, content: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showCalendar &&
|
|
218
|
+
(0, jsx_runtime_1.jsx)(calendar_1.Calendar, { viewLevel: format.includes('D') ? 'date'
|
|
219
|
+
: format.includes('M') ? 'month'
|
|
220
|
+
: 'year', _defaultNull: !dateValue.current, value: _dateVal, onChange: setDateValue, min: min, max: max, disabledDates: disabledDates }), showTimer &&
|
|
221
|
+
(0, jsx_runtime_1.jsx)(DateTimePickerContext, { value: contextValue, children: (0, jsx_runtime_1.jsx)(timer_1.Timer, { showHours: format.includes('H'), showMinutes: format.includes('m'), showSeconds: format.includes('s'), value: _dateVal, onChange: setDateValue }) })] }), ...popperProps, onOpenChange: setInnerOpen, onPointerDown: e => {
|
|
225
222
|
popperProps?.onPointerDown?.(e);
|
|
226
223
|
e.preventDefault();
|
|
227
224
|
}, children: (0, jsx_runtime_1.jsx)(inputBase_1.InputBase, { ...props, css: dateTimePicker_style_1.style, className: (0, utils_1.clsx)(dateTimePicker_style_1.classes.root, props.className), "data-focused": innerOpen.current, value: dateValue.current, onClear: clearHandler, onSelect: selectHandler, onFocus: focusHandler, onBlur: blurHandler, onKeyDown: keydownHandler, children: ({ ref, value, onChange, ...rest }) => (0, jsx_runtime_1.jsxs)("div", { className: dateTimePicker_style_1.classes.container, children: [(0, jsx_runtime_1.jsx)("input", { ...rest, ...inputProps, ref: (0, utils_1.cloneRef)(ref, inputProps?.ref, innerInputRef), className: (0, utils_1.clsx)(dateTimePicker_style_1.classes.input, inputProps?.className) }), (0, jsx_runtime_1.jsx)("div", { className: dateTimePicker_style_1.classes.dateTimeIcon, children: showTimer && !showCalendar
|
|
@@ -2,16 +2,16 @@ export declare const classes: {
|
|
|
2
2
|
input: string;
|
|
3
3
|
container: string;
|
|
4
4
|
calendar: string;
|
|
5
|
+
dateItem: string;
|
|
6
|
+
inputGroup: string;
|
|
7
|
+
inputUnit: string;
|
|
8
|
+
dateTimeIcon: string;
|
|
5
9
|
calendarHead: string;
|
|
6
10
|
calendarHeadSide: string;
|
|
7
11
|
calendarHeadControl: string;
|
|
8
12
|
calendarHeadCenter: string;
|
|
9
13
|
calendarHeadButton: string;
|
|
10
14
|
calendarBody: string;
|
|
11
|
-
dateItem: string;
|
|
12
|
-
inputGroup: string;
|
|
13
|
-
inputUnit: string;
|
|
14
|
-
dateTimeIcon: string;
|
|
15
15
|
calendarDays: string;
|
|
16
16
|
} & {
|
|
17
17
|
root: string;
|
|
@@ -4,7 +4,7 @@ exports.datePickerPopperStyle = exports.style = exports.classes = void 0;
|
|
|
4
4
|
const react_1 = require("@emotion/react");
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const input_style_1 = require("../input/input.style");
|
|
7
|
-
const calendar_style_1 = require("
|
|
7
|
+
const calendar_style_1 = require("../calendar/calendar.style");
|
|
8
8
|
const timer_style_1 = require("./timer.style");
|
|
9
9
|
const popper_style_1 = require("../popper/popper.style");
|
|
10
10
|
exports.classes = (0, utils_1.defineInnerClasses)('date-time-picker', [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("
|
|
4
|
+
tslib_1.__exportStar(require("../calendar/calendar"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./dateTimePicker"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./timer"), exports);
|
|
@@ -15,6 +15,7 @@ export interface DateTimeRangePickerProps extends DatePickerSharedProps, Omit<Di
|
|
|
15
15
|
onOpenPickerChange?(openPicker?: 'start' | 'end' | 'closed'): void;
|
|
16
16
|
autoClose?: boolean;
|
|
17
17
|
separator?: ReactNode;
|
|
18
|
+
disabledDates?: (date: Dayjs) => any;
|
|
18
19
|
variant?: 'outlined' | 'underlined' | 'plain';
|
|
19
20
|
size?: Size;
|
|
20
21
|
color?: ColorPropsValue;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FontAwesomeIconProps } from '@fortawesome/react-fontawesome';
|
|
2
|
+
import { ColorPropsValue } from '../../types';
|
|
3
|
+
export interface IconProps extends Omit<FontAwesomeIconProps, 'color'> {
|
|
4
|
+
color?: ColorPropsValue;
|
|
5
|
+
}
|
|
6
|
+
export declare function Icon({ color, ...props }: IconProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Icon = Icon;
|
|
4
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
+
const react_fontawesome_1 = require("@fortawesome/react-fontawesome");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
function Icon({ color, ...props }) {
|
|
8
|
+
return (0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { ...props, color: (0, utils_1.useColor)(color) });
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './icon';
|
|
@@ -28,6 +28,7 @@ function useStyle({ color }) {
|
|
|
28
28
|
const c = (0, color_1.default)(colorValue);
|
|
29
29
|
const selectedBg = c.alpha(.1).string();
|
|
30
30
|
const selectedAndFocused = c.alpha(.15).string();
|
|
31
|
+
const selectedActive = c.alpha(.08).string();
|
|
31
32
|
const focusedBg = gray(mode === 'light' ? .05 : .23);
|
|
32
33
|
const disabledOrActive = gray(mode === 'light' ? .1 : .17);
|
|
33
34
|
return (0, react_1.css) `
|
|
@@ -38,6 +39,7 @@ function useStyle({ color }) {
|
|
|
38
39
|
cursor: pointer;
|
|
39
40
|
color: ${text.primary};
|
|
40
41
|
padding: ${exports.paddingHorizontal.medium}px 12px;
|
|
42
|
+
position: relative;
|
|
41
43
|
-webkit-tap-highlight-color: transparent;
|
|
42
44
|
|
|
43
45
|
&[data-size=small] {
|
|
@@ -52,8 +54,7 @@ function useStyle({ color }) {
|
|
|
52
54
|
|
|
53
55
|
transition: background-color .25s ${easing.easeOut};
|
|
54
56
|
|
|
55
|
-
&:hover,
|
|
56
|
-
&[data-focused=true] {
|
|
57
|
+
&:hover, &[data-focused=true] {
|
|
57
58
|
background-color: ${focusedBg};
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -69,7 +70,7 @@ function useStyle({ color }) {
|
|
|
69
70
|
&[data-selected=true] {
|
|
70
71
|
background-color: ${selectedBg};
|
|
71
72
|
|
|
72
|
-
&[data-focused=true] {
|
|
73
|
+
&:hover, &[data-focused=true] {
|
|
73
74
|
background-color: ${selectedAndFocused};
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -77,6 +78,10 @@ function useStyle({ color }) {
|
|
|
77
78
|
font-weight: bold;
|
|
78
79
|
color: ${colorValue};
|
|
79
80
|
}
|
|
81
|
+
|
|
82
|
+
&:active {
|
|
83
|
+
background-color: ${selectedActive};
|
|
84
|
+
}
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
&[data-disabled=true] {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.style = exports.classes = void 0;
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
const react_1 = require("@emotion/react");
|
|
6
|
-
exports.classes = (0, utils_1.
|
|
6
|
+
exports.classes = (0, utils_1.defineInnerClasses)('pinchable', [
|
|
7
7
|
'content'
|
|
8
8
|
]);
|
|
9
9
|
exports.style = (0, utils_1.defineCss)(({ easing }) => (0, react_1.css) `
|
|
@@ -484,7 +484,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, cont
|
|
|
484
484
|
onChildrenOpenChange,
|
|
485
485
|
beforeOpenCallbacks: beforeOpenCallbacks.current
|
|
486
486
|
}), [innerOpen.current, autoClose]);
|
|
487
|
-
const childRef = (0, react_1.useCallback)((0, utils_1.cloneRef)(children?.props.ref, anchorRef, ref), [children?.props.ref]);
|
|
487
|
+
const childRef = (0, react_1.useCallback)((0, utils_1.cloneRef)(children?.props.ref, anchorRef, ref), [children?.props.ref, ref]);
|
|
488
488
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, react_1.isValidElement)(children)
|
|
489
489
|
? (0, react_1.cloneElement)(children, { ref: childRef })
|
|
490
490
|
: children, renderedOnce.current && (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(clickAway_1.ClickAway, { disabled: !clickable && !enterable && !contextMenuable,
|
|
@@ -15,6 +15,7 @@ function useStyle({ color }) {
|
|
|
15
15
|
let colorValue = (0, utils_1.useColor)(color);
|
|
16
16
|
colorValue = (0, color_1.default)(colorValue).alpha(.7).string();
|
|
17
17
|
return (0, utils_1.useCss)(({ spacing, borderRadius, boxShadow }) => (0, react_1.css) `
|
|
18
|
+
pointer-events: none;
|
|
18
19
|
z-index: ${theme_1.zIndex.tooltip};
|
|
19
20
|
|
|
20
21
|
.${exports.classes.title} {
|
|
@@ -20,10 +20,6 @@ exports.Ripple = (0, react_1.memo)(({ ref, color = 'primary', ...props }) => {
|
|
|
20
20
|
(0, react_1.useLayoutEffect)(() => {
|
|
21
21
|
const wrapper = rippleRef.current?.parentElement;
|
|
22
22
|
if (wrapper) {
|
|
23
|
-
const { position } = getComputedStyle(wrapper);
|
|
24
|
-
if (position === 'static') {
|
|
25
|
-
wrapper.style.position = 'relative';
|
|
26
|
-
}
|
|
27
23
|
const pointerDown = (e) => {
|
|
28
24
|
setRipples(o => [
|
|
29
25
|
...o,
|
|
@@ -4,7 +4,7 @@ exports.classes = void 0;
|
|
|
4
4
|
exports.useStyle = useStyle;
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const react_1 = require("@emotion/react");
|
|
7
|
-
exports.classes = (0, utils_1.
|
|
7
|
+
exports.classes = (0, utils_1.defineInnerClasses)('waterfall', [
|
|
8
8
|
'item'
|
|
9
9
|
]);
|
|
10
10
|
function useStyle({ columnCount, columnGap, rowGap }) {
|
|
@@ -24,7 +24,7 @@ const WaterfallItem = ({ ref, onLoad, child }) => {
|
|
|
24
24
|
}
|
|
25
25
|
})).then(() => onLoad());
|
|
26
26
|
});
|
|
27
|
-
const clonedRef = (0, react_1.useCallback)((0, utils_1.cloneRef)(child.props.ref, innerRef, ref), [child.props.ref]);
|
|
27
|
+
const clonedRef = (0, react_1.useCallback)((0, utils_1.cloneRef)(child.props.ref, innerRef, ref), [child.props.ref, ref]);
|
|
28
28
|
return (0, react_1.cloneElement)(child, {
|
|
29
29
|
ref: clonedRef,
|
|
30
30
|
className: (0, utils_1.clsx)(waterfall_style_1.classes.item, child.props.className),
|
|
@@ -31,7 +31,7 @@ exports.DocumentViewer = (0, react_1.memo)(({ src, filename, onError, type, exte
|
|
|
31
31
|
return ext && mime_1.default.getType(ext);
|
|
32
32
|
}
|
|
33
33
|
return null;
|
|
34
|
-
}, [src, type, extension]);
|
|
34
|
+
}, [src, type, extension, filename]);
|
|
35
35
|
const downloadHandler = () => {
|
|
36
36
|
if (src) {
|
|
37
37
|
const a = document.createElement('a');
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from './utils';
|
|
2
|
-
export { FontAwesomeIcon as Icon } from '@fortawesome/react-fontawesome';
|
|
3
2
|
export * from './components/accordion';
|
|
4
3
|
export * from './components/actionSheet';
|
|
5
4
|
export * from './components/alert';
|
|
@@ -15,6 +14,7 @@ export * from './components/breadcrumb';
|
|
|
15
14
|
export * from './components/bubble';
|
|
16
15
|
export * from './components/bubbleConfirm';
|
|
17
16
|
export * from './components/button';
|
|
17
|
+
export * from './components/calendar';
|
|
18
18
|
export * from './components/card';
|
|
19
19
|
export * from './components/cascade';
|
|
20
20
|
export * from './components/checkbox';
|
|
@@ -40,6 +40,7 @@ export * from './components/formDialog';
|
|
|
40
40
|
export * from './components/gallery';
|
|
41
41
|
export * from './components/grid';
|
|
42
42
|
export * from './components/highlight';
|
|
43
|
+
export * from './components/icon';
|
|
43
44
|
export * from './components/image';
|
|
44
45
|
export * from './components/input';
|
|
45
46
|
export * from './components/inputBase';
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Icon = void 0;
|
|
4
3
|
const tslib_1 = require("tslib");
|
|
5
4
|
tslib_1.__exportStar(require("./utils"), exports);
|
|
6
|
-
var react_fontawesome_1 = require("@fortawesome/react-fontawesome");
|
|
7
|
-
Object.defineProperty(exports, "Icon", { enumerable: true, get: function () { return react_fontawesome_1.FontAwesomeIcon; } });
|
|
8
5
|
tslib_1.__exportStar(require("./components/accordion"), exports);
|
|
9
6
|
tslib_1.__exportStar(require("./components/actionSheet"), exports);
|
|
10
7
|
tslib_1.__exportStar(require("./components/alert"), exports);
|
|
@@ -20,6 +17,7 @@ tslib_1.__exportStar(require("./components/breadcrumb"), exports);
|
|
|
20
17
|
tslib_1.__exportStar(require("./components/bubble"), exports);
|
|
21
18
|
tslib_1.__exportStar(require("./components/bubbleConfirm"), exports);
|
|
22
19
|
tslib_1.__exportStar(require("./components/button"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./components/calendar"), exports);
|
|
23
21
|
tslib_1.__exportStar(require("./components/card"), exports);
|
|
24
22
|
tslib_1.__exportStar(require("./components/cascade"), exports);
|
|
25
23
|
tslib_1.__exportStar(require("./components/checkbox"), exports);
|
|
@@ -45,6 +43,7 @@ tslib_1.__exportStar(require("./components/formDialog"), exports);
|
|
|
45
43
|
tslib_1.__exportStar(require("./components/gallery"), exports);
|
|
46
44
|
tslib_1.__exportStar(require("./components/grid"), exports);
|
|
47
45
|
tslib_1.__exportStar(require("./components/highlight"), exports);
|
|
46
|
+
tslib_1.__exportStar(require("./components/icon"), exports);
|
|
48
47
|
tslib_1.__exportStar(require("./components/image"), exports);
|
|
49
48
|
tslib_1.__exportStar(require("./components/input"), exports);
|
|
50
49
|
tslib_1.__exportStar(require("./components/inputBase"), exports);
|
|
@@ -51,12 +51,12 @@ export declare function colorTransfer(colorPropsValue: ColorPropsValue, theme: T
|
|
|
51
51
|
* 将useCss()与colorTransfer()方法结合封装
|
|
52
52
|
* @param colorPropsValue
|
|
53
53
|
*/
|
|
54
|
-
export declare function useColor(colorPropsValue: ColorPropsValue): string;
|
|
54
|
+
export declare function useColor(colorPropsValue: ColorPropsValue | undefined): string | undefined;
|
|
55
55
|
/**
|
|
56
56
|
* 点击的波纹效果
|
|
57
57
|
* @param colorPropsValue
|
|
58
58
|
*/
|
|
59
|
-
export declare function
|
|
59
|
+
export declare function useTouchSpread(colorPropsValue: ColorPropsValue): (element: Animatable) => void;
|
|
60
60
|
/**
|
|
61
61
|
* 生成响应式样式,与{@link responsiveStyles}的区别在于,本方法会遍历{@link Theme}中的所有`breakpoints`,触发回调函数
|
|
62
62
|
* @param breakpoints 传入{@link Theme}中的断点,或自定义断点
|
package/dist/cjs/utils/style.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.defineCss = defineCss;
|
|
|
7
7
|
exports.useCss = useCss;
|
|
8
8
|
exports.colorTransfer = colorTransfer;
|
|
9
9
|
exports.useColor = useColor;
|
|
10
|
-
exports.
|
|
10
|
+
exports.useTouchSpread = useTouchSpread;
|
|
11
11
|
exports.responsiveVariables = responsiveVariables;
|
|
12
12
|
exports.responsiveStyles = responsiveStyles;
|
|
13
13
|
exports.toResponsiveValue = toResponsiveValue;
|
|
@@ -96,14 +96,14 @@ function colorTransfer(colorPropsValue, theme) {
|
|
|
96
96
|
*/
|
|
97
97
|
function useColor(colorPropsValue) {
|
|
98
98
|
return useCss(theme => {
|
|
99
|
-
return colorTransfer(colorPropsValue, theme);
|
|
99
|
+
return colorPropsValue && colorTransfer(colorPropsValue, theme);
|
|
100
100
|
}, [colorPropsValue]);
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* 点击的波纹效果
|
|
104
104
|
* @param colorPropsValue
|
|
105
105
|
*/
|
|
106
|
-
function
|
|
106
|
+
function useTouchSpread(colorPropsValue) {
|
|
107
107
|
const theme = (0, theme_1.useTheme)();
|
|
108
108
|
const outlineColor = (0, react_1.useMemo)(() => {
|
|
109
109
|
return (0, color_1.default)(colorTransfer(colorPropsValue, theme)).alpha(.6).string();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useTheme } from '../theme';
|
|
3
|
-
import {
|
|
3
|
+
import { useTouchSpread } from '../../utils';
|
|
4
4
|
import { clsx } from '../../utils';
|
|
5
5
|
import { LoadingIndicator } from '../loadingIndicator';
|
|
6
6
|
import { classes, useStyle } from './button.style';
|
|
@@ -8,14 +8,14 @@ import { Collapse } from '../transitionBase';
|
|
|
8
8
|
export const Button = ({ component: Component = 'button', color = 'primary', shape = 'square', size, variant = 'filled', orientation = 'horizontal', prefix, suffix, loading = false, readOnly, icon, label, ...props }) => {
|
|
9
9
|
const theme = useTheme();
|
|
10
10
|
size ??= theme.size;
|
|
11
|
-
const
|
|
11
|
+
const showSpread = useTouchSpread(color);
|
|
12
12
|
const onPointerUp = (e) => {
|
|
13
13
|
props.onPointerUp?.(e);
|
|
14
14
|
if (!props.disabled
|
|
15
15
|
&& !loading
|
|
16
16
|
&& !readOnly
|
|
17
17
|
&& { flatted: true, filled: true, outlined: true, dashed: true }[variant]) {
|
|
18
|
-
|
|
18
|
+
showSpread(e.currentTarget);
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
const onClick = (e) => {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Size } from '../../types';
|
|
2
|
+
import { Dayjs } from 'dayjs';
|
|
3
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
4
|
+
import { FlexProps } from '../flex';
|
|
5
|
+
export type ViewLevel = 'date' | 'month' | 'year';
|
|
6
|
+
type SharedProps = {
|
|
7
|
+
min?: Dayjs;
|
|
8
|
+
max?: Dayjs;
|
|
9
|
+
disabledDates?: (date: Dayjs) => boolean;
|
|
10
|
+
/** 是否显示`回今天`按钮,默认为`true` */
|
|
11
|
+
showToday?: boolean;
|
|
12
|
+
/** @private */
|
|
13
|
+
_defaultNull?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export interface CalendarProps extends SharedProps, Omit<FlexProps, 'defaultValue' | 'onChange'> {
|
|
16
|
+
/** 视图等级,默认为`date` */
|
|
17
|
+
viewLevel?: ViewLevel;
|
|
18
|
+
size?: Size;
|
|
19
|
+
defaultValue?: Dayjs | null;
|
|
20
|
+
value?: Dayjs | null;
|
|
21
|
+
onChange?(value: Dayjs | null): void;
|
|
22
|
+
}
|
|
23
|
+
export interface PanelProps extends SharedProps {
|
|
24
|
+
value: Dayjs | null;
|
|
25
|
+
setValue: Dispatch<SetStateAction<Dayjs | null>>;
|
|
26
|
+
innerD: Dayjs;
|
|
27
|
+
setInnerD: Dispatch<SetStateAction<Dayjs>>;
|
|
28
|
+
setViewType: Dispatch<SetStateAction<'date' | 'month' | 'year'>>;
|
|
29
|
+
onSelected(newValue: Dayjs): void;
|
|
30
|
+
}
|
|
31
|
+
export declare const Calendar: ({ viewLevel, showToday, size, defaultValue, min, max, disabledDates, value, onChange, _defaultNull, ...props }: CalendarProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { clsx, useControlled } from '../../utils';
|
|
4
|
+
import { PanelDates } from './panelDates';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { classes, style } from './calendar.style';
|
|
7
|
+
import { Flex } from '../flex';
|
|
8
|
+
import { PanelYear } from './panelYear';
|
|
9
|
+
import { PanelMonth } from './panelMonth';
|
|
10
|
+
export const Calendar = ({ viewLevel = 'date', showToday = true, size = 'medium', defaultValue = null, min, max, disabledDates, value, onChange, _defaultNull, ...props }) => {
|
|
11
|
+
const [innerValue, setInnerValue] = useControlled(defaultValue, value, onChange);
|
|
12
|
+
const [viewType, setViewType] = useState(viewLevel);
|
|
13
|
+
const [innerD, setInnerD] = useState(() => innerValue.current ?? dayjs().startOf('date'));
|
|
14
|
+
const commonProps = {
|
|
15
|
+
value: innerValue.current,
|
|
16
|
+
setValue: setInnerValue,
|
|
17
|
+
innerD,
|
|
18
|
+
setInnerD,
|
|
19
|
+
setViewType,
|
|
20
|
+
min,
|
|
21
|
+
max,
|
|
22
|
+
disabledDates,
|
|
23
|
+
onSelected: (newValue) => {
|
|
24
|
+
if (viewLevel === 'date') {
|
|
25
|
+
setViewType('date');
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// 视图等级不为`date`时,选中年或月即完成
|
|
29
|
+
setInnerValue(newValue);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
showToday,
|
|
33
|
+
_defaultNull
|
|
34
|
+
};
|
|
35
|
+
const renderPanel = () => {
|
|
36
|
+
switch (viewType) {
|
|
37
|
+
case 'date':
|
|
38
|
+
return _jsx(PanelDates, { ...commonProps });
|
|
39
|
+
case 'month':
|
|
40
|
+
return _jsx(PanelMonth, { ...commonProps });
|
|
41
|
+
default:
|
|
42
|
+
return _jsx(PanelYear, { ...commonProps });
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return (_jsx(Flex, { inline: true, direction: "column", ...props, css: style, className: clsx(classes.root, props.className), "data-size": size, children: renderPanel() }));
|
|
46
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const classes: {
|
|
2
|
+
body: string;
|
|
3
|
+
head: string;
|
|
4
|
+
headSide: string;
|
|
5
|
+
headControl: string;
|
|
6
|
+
headCenter: string;
|
|
7
|
+
headButton: string;
|
|
8
|
+
dateItem: string;
|
|
9
|
+
monthItem: string;
|
|
10
|
+
yearItem: string;
|
|
11
|
+
foot: string;
|
|
12
|
+
} & {
|
|
13
|
+
root: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const style: () => import("@emotion/react").SerializedStyles;
|