musae 1.0.27-beta.22 → 1.0.27-beta.24

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.
@@ -38,6 +38,7 @@ var Calendar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
38
38
  var className$1 = _ref.className,
39
39
  style = _ref.style,
40
40
  value = _ref.value,
41
+ disabledDate = _ref.disabledDate,
41
42
  _onClick = _ref.onClick;
42
43
  var classNames = useClassNames.useClassNames(context.CLASS_NAMES);
43
44
  var _useValue = hooks.useValue({
@@ -59,6 +60,7 @@ var Calendar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
59
60
  timespan: timespan,
60
61
  focusedAt: focusedAt,
61
62
  onClick: onClick,
63
+ disabledDate: disabledDate,
62
64
  classNames: classNames
63
65
  });
64
66
  var headCells = hooks.useHeadCells({
@@ -3,5 +3,6 @@ import type { CalendarRef } from "../../types/calendar";
3
3
  declare const Calendar: React.ForwardRefExoticComponent<import("../../types/element").ComponentProps & {
4
4
  value?: import("dayjs").Dayjs | [import("@aiszlab/relax/types").Partialable<import("dayjs").Dayjs>, import("@aiszlab/relax/types").Partialable<import("dayjs").Dayjs>];
5
5
  onClick?: (value: import("dayjs").Dayjs) => void;
6
+ disabledDate?: (date: import("dayjs").Dayjs) => boolean;
6
7
  } & React.RefAttributes<CalendarRef>>;
7
8
  export default Calendar;
@@ -34,6 +34,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref, ref) {
34
34
  var className = _ref.className,
35
35
  style = _ref.style,
36
36
  value = _ref.value,
37
+ disabledDate = _ref.disabledDate,
37
38
  _onClick = _ref.onClick;
38
39
  var classNames = useClassNames(CLASS_NAMES);
39
40
  var _useValue = useValue({
@@ -55,6 +56,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (_ref, ref) {
55
56
  timespan: timespan,
56
57
  focusedAt: focusedAt,
57
58
  onClick: onClick,
59
+ disabledDate: disabledDate,
58
60
  classNames: classNames
59
61
  });
60
62
  var headCells = useHeadCells({
@@ -80,6 +80,7 @@ var useDateCells = function useDateCells(_ref2) {
80
80
  var timespan = _ref2.timespan,
81
81
  focusedAt = _ref2.focusedAt,
82
82
  _onClick = _ref2.onClick,
83
+ disabledDate = _ref2.disabledDate,
83
84
  classNames = _ref2.classNames;
84
85
  var _themeColorVars = useThemeColorVars.useThemeColorVars(["secondary-container"]);
85
86
  return React.useMemo(function () {
@@ -96,10 +97,11 @@ var useDateCells = function useDateCells(_ref2) {
96
97
  var isFrom = timespan.isFrom(currentAt);
97
98
  var isTo = timespan.isTo(currentAt);
98
99
  var isBetween = timespan.isBetween(currentAt);
99
- var isDisabled = currentAt.isBefore(start, "d") || currentAt.isAfter(end, "d");
100
+ var isHidden = currentAt.isBefore(start, "d") || currentAt.isAfter(end, "d");
101
+ var isDisabled = isHidden || !!(disabledDate !== null && disabledDate !== void 0 && disabledDate(currentAt));
100
102
  var isSelected = isFrom || isTo;
101
103
  var styled = {
102
- cell: stylex.props(styles.cell, styles.date, isDisabled && styles.hidden, isBetween && styles.range, isFrom && timespan.isRange && styles.from, isTo && timespan.isRange && styles.to, theme.$body.large),
104
+ cell: stylex.props(styles.cell, styles.date, isHidden && styles.hidden, isBetween && styles.range, isFrom && timespan.isRange && styles.from, isTo && timespan.isRange && styles.to, theme.$body.large),
103
105
  trigger: {
104
106
  className: "musaex-zzs3sa"
105
107
  }
@@ -110,11 +112,12 @@ var useDateCells = function useDateCells(_ref2) {
110
112
  className: className.stringify(classNames.dateCell, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, classNames.dateCellSelected, isSelected), classNames.dateCellInRange, !!timespan.isRange && isBetween), classNames.dateCellRangeFrom, !!timespan.isRange && isFrom), classNames.dateCellRangeTo, !!timespan.isRange && isTo), styled.cell.className),
111
113
  style: _objectSpread(_objectSpread({}, styled.cell.style), _themeColorVars),
112
114
  "aria-selected": isSelected,
113
- "aria-hidden": isDisabled
115
+ "aria-hidden": isHidden
114
116
  }, /*#__PURE__*/React.createElement(iconButton.default, {
115
117
  variant: isSelected ? "filled" : "text",
116
118
  size: "small",
117
119
  color: isSelected ? "primary" : "secondary",
120
+ disabled: isDisabled,
118
121
  className: className.stringify(classNames.date, styled.trigger.className),
119
122
  style: styled.trigger.style,
120
123
  onClick: function onClick() {
@@ -128,7 +131,7 @@ var useDateCells = function useDateCells(_ref2) {
128
131
  key: index
129
132
  }, cells);
130
133
  });
131
- }, [focusedAt, timespan, classNames, _onClick, _themeColorVars]);
134
+ }, [focusedAt, timespan, classNames, _onClick, disabledDate, _themeColorVars]);
132
135
  };
133
136
  /**
134
137
  * @description
@@ -15,10 +15,11 @@ export declare const useHeadCells: ({ classNames }: {
15
15
  * @description
16
16
  * dates
17
17
  */
18
- export declare const useDateCells: ({ timespan, focusedAt, onClick, classNames, }: {
18
+ export declare const useDateCells: ({ timespan, focusedAt, onClick, disabledDate, classNames, }: {
19
19
  timespan: Timespan;
20
20
  focusedAt: Dayjs;
21
21
  onClick: Required<CalendarProps>["onClick"];
22
+ disabledDate?: CalendarProps["disabledDate"];
22
23
  classNames: typeof CLASS_NAMES;
23
24
  }) => React.JSX.Element[];
24
25
  /**
@@ -78,6 +78,7 @@ var useDateCells = function useDateCells(_ref2) {
78
78
  var timespan = _ref2.timespan,
79
79
  focusedAt = _ref2.focusedAt,
80
80
  _onClick = _ref2.onClick,
81
+ disabledDate = _ref2.disabledDate,
81
82
  classNames = _ref2.classNames;
82
83
  var _themeColorVars = useThemeColorVars(["secondary-container"]);
83
84
  return useMemo(function () {
@@ -94,10 +95,11 @@ var useDateCells = function useDateCells(_ref2) {
94
95
  var isFrom = timespan.isFrom(currentAt);
95
96
  var isTo = timespan.isTo(currentAt);
96
97
  var isBetween = timespan.isBetween(currentAt);
97
- var isDisabled = currentAt.isBefore(start, "d") || currentAt.isAfter(end, "d");
98
+ var isHidden = currentAt.isBefore(start, "d") || currentAt.isAfter(end, "d");
99
+ var isDisabled = isHidden || !!(disabledDate !== null && disabledDate !== void 0 && disabledDate(currentAt));
98
100
  var isSelected = isFrom || isTo;
99
101
  var styled = {
100
- cell: props(styles.cell, styles.date, isDisabled && styles.hidden, isBetween && styles.range, isFrom && timespan.isRange && styles.from, isTo && timespan.isRange && styles.to, $body.large),
102
+ cell: props(styles.cell, styles.date, isHidden && styles.hidden, isBetween && styles.range, isFrom && timespan.isRange && styles.from, isTo && timespan.isRange && styles.to, $body.large),
101
103
  trigger: {
102
104
  className: "musaex-zzs3sa"
103
105
  }
@@ -108,11 +110,12 @@ var useDateCells = function useDateCells(_ref2) {
108
110
  className: stringify(classNames.dateCell, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, classNames.dateCellSelected, isSelected), classNames.dateCellInRange, !!timespan.isRange && isBetween), classNames.dateCellRangeFrom, !!timespan.isRange && isFrom), classNames.dateCellRangeTo, !!timespan.isRange && isTo), styled.cell.className),
109
111
  style: _objectSpread(_objectSpread({}, styled.cell.style), _themeColorVars),
110
112
  "aria-selected": isSelected,
111
- "aria-hidden": isDisabled
113
+ "aria-hidden": isHidden
112
114
  }, /*#__PURE__*/React.createElement(IconButton, {
113
115
  variant: isSelected ? "filled" : "text",
114
116
  size: "small",
115
117
  color: isSelected ? "primary" : "secondary",
118
+ disabled: isDisabled,
116
119
  className: stringify(classNames.date, styled.trigger.className),
117
120
  style: styled.trigger.style,
118
121
  onClick: function onClick() {
@@ -126,7 +129,7 @@ var useDateCells = function useDateCells(_ref2) {
126
129
  key: index
127
130
  }, cells);
128
131
  });
129
- }, [focusedAt, timespan, classNames, _onClick, _themeColorVars]);
132
+ }, [focusedAt, timespan, classNames, _onClick, disabledDate, _themeColorVars]);
130
133
  };
131
134
  /**
132
135
  * @description
@@ -13,23 +13,19 @@ var Tab = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
13
13
  onClick = _ref.onClick,
14
14
  label = _ref.label;
15
15
  var _useTabsContext = useTabsContext.useTabsContext(),
16
- activeKey = _useTabsContext.activeKey,
17
16
  classNames = _useTabsContext.classNames,
18
17
  size = _useTabsContext.size;
19
- var isActive = activeKey === value;
20
18
  var click = relax.useEvent(function () {
21
19
  onClick(value);
22
20
  });
23
21
  var styled = {
24
- className: "musaex-1c9xf0i"
22
+ className: "musaex-101nlry"
25
23
  };
26
24
  return /*#__PURE__*/React.createElement(button.Button, {
27
25
  variant: "text",
28
- color: isActive ? "primary" : "secondary",
29
26
  ref: ref,
30
27
  onClick: click,
31
28
  className: className.stringify(classNames.tab, styled.className),
32
- ripple: false,
33
29
  style: styled.style,
34
30
  size: size
35
31
  }, label);
@@ -9,23 +9,19 @@ var Tab = /*#__PURE__*/forwardRef(function (_ref, ref) {
9
9
  onClick = _ref.onClick,
10
10
  label = _ref.label;
11
11
  var _useTabsContext = useTabsContext(),
12
- activeKey = _useTabsContext.activeKey,
13
12
  classNames = _useTabsContext.classNames,
14
13
  size = _useTabsContext.size;
15
- var isActive = activeKey === value;
16
14
  var click = useEvent(function () {
17
15
  onClick(value);
18
16
  });
19
17
  var styled = {
20
- className: "musaex-1c9xf0i"
18
+ className: "musaex-101nlry"
21
19
  };
22
20
  return /*#__PURE__*/React.createElement(Button, {
23
21
  variant: "text",
24
- color: isActive ? "primary" : "secondary",
25
22
  ref: ref,
26
23
  onClick: click,
27
24
  className: stringify(classNames.tab, styled.className),
28
- ripple: false,
29
25
  style: styled.style,
30
26
  size: size
31
27
  }, label);
package/dist/styles.css CHANGED
@@ -488,8 +488,8 @@
488
488
  transition: transform .3s;
489
489
  }
490
490
 
491
- .musaex-1c9xf0i:not(#\#) {
492
- border-radius: 10% 10% 0 0;
491
+ .musaex-101nlry:not(#\#) {
492
+ border-radius: 0;
493
493
  }
494
494
 
495
495
  .musaex-3e2p9r:not(#\#) {
@@ -2,69 +2,77 @@ import type { Dayjs } from "dayjs";
2
2
  import type { Partialable } from "@aiszlab/relax/types";
3
3
  import type { ComponentProps } from "./element";
4
4
  /**
5
- * @description
6
5
  * calendar props
6
+ * @zh 日历组件属性
7
7
  */
8
8
  export type CalendarProps = ComponentProps & {
9
9
  /**
10
- * @description
11
10
  * value
11
+ * @zh 选中值
12
12
  * @default void 0
13
13
  */
14
14
  value?: Dayjs | [Partialable<Dayjs>, Partialable<Dayjs>];
15
15
  /**
16
- * @description
17
16
  * click date handler
17
+ * @zh 日期点击回调
18
18
  * @default void 0
19
19
  */
20
20
  onClick?: (value: Dayjs) => void;
21
+ /**
22
+ * specify the date that cannot be selected
23
+ * @zh 指定不可选择的日期
24
+ * @default void 0
25
+ */
26
+ disabledDate?: (date: Dayjs) => boolean;
21
27
  };
22
28
  export type Contribution = {
23
29
  /**
24
- * @description
25
30
  * contributedAt
31
+ * @zh 贡献日期
26
32
  */
27
33
  contributedAt: Dayjs;
28
34
  /**
29
- * @description
30
35
  * count
36
+ * @zh 贡献次数
31
37
  */
32
38
  count: number;
33
39
  };
34
40
  /**
35
- * @description
36
41
  * contribution calendar props
42
+ * @zh 贡献日历组件属性
37
43
  */
38
44
  export type ContributionCalendarProps = {
39
45
  /**
40
- * @description
41
46
  * year
47
+ * @zh 年份
42
48
  */
43
49
  year: number;
44
50
  /**
45
- * @description
46
51
  * contributions
52
+ * @zh 贡献数据
47
53
  */
48
54
  contributions?: Contribution[];
49
55
  /**
50
- * @description
51
56
  * gap
57
+ * @zh 间距
52
58
  * @default 5
53
59
  */
54
60
  gap?: number;
55
61
  /**
56
- * @description
57
62
  * levels
63
+ * @zh 等级数量
58
64
  * @default 5
59
65
  */
60
66
  levels?: number;
61
67
  };
62
68
  /**
63
- * @description calendar ref
69
+ * calendar ref
70
+ * @zh 日历组件 ref
64
71
  */
65
72
  export interface CalendarRef {
66
73
  /**
67
- * @description reset
74
+ * reset
75
+ * @zh 重置
68
76
  */
69
77
  reset: () => void;
70
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musae",
3
- "version": "1.0.27-beta.22",
3
+ "version": "1.0.27-beta.24",
4
4
  "description": "musae-ui",
5
5
  "author": "tutu@fantufantu.com",
6
6
  "license": "MIT",