@spaced-out/ui-design-system 0.2.2-beta.0 → 0.2.3
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/CHANGELOG.md +19 -0
- package/lib/components/Button/Button.js +2 -1
- package/lib/components/Button/Button.js.flow +3 -1
- package/lib/components/TruncatedTextWithTooltip/TruncatedTextWithTooltip.js +3 -1
- package/lib/components/TruncatedTextWithTooltip/TruncatedTextWithTooltip.js.flow +17 -12
- package/lib/components/WeekdayPicker/WeekdayPicker.js +146 -0
- package/lib/components/WeekdayPicker/WeekdayPicker.js.flow +217 -0
- package/lib/components/WeekdayPicker/WeekdayPicker.module.css +97 -0
- package/lib/components/WeekdayPicker/index.js +16 -0
- package/lib/components/WeekdayPicker/index.js.flow +3 -0
- package/lib/components/index.js +11 -0
- package/lib/components/index.js.flow +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.2.3](https://github.com/spaced-out/ui-design-system/compare/v0.2.2...v0.2.3) (2024-10-10)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* new weekday-picker component ([#274](https://github.com/spaced-out/ui-design-system/issues/274)) ([5e3d8bc](https://github.com/spaced-out/ui-design-system/commit/5e3d8bc230581890f9f41389c4c699eb3f57817b))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* sets totalbars to 5 in simple scorebar story ([#269](https://github.com/spaced-out/ui-design-system/issues/269)) ([ef1754a](https://github.com/spaced-out/ui-design-system/commit/ef1754ae4193705595a4582c91069a799b0ff29e))
|
|
16
|
+
|
|
17
|
+
### [0.2.2](https://github.com/spaced-out/ui-design-system/compare/v0.2.2-beta.0...v0.2.2) (2024-10-04)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* issue with tooltip for multiple events in a span of time ([#273](https://github.com/spaced-out/ui-design-system/issues/273)) ([b97df70](https://github.com/spaced-out/ui-design-system/commit/b97df70e37369886a71134c8b27dd66aeb49802e))
|
|
23
|
+
|
|
5
24
|
### [0.2.2-beta.0](https://github.com/spaced-out/ui-design-system/compare/v0.2.1...v0.2.2-beta.0) (2024-09-30)
|
|
6
25
|
|
|
7
26
|
|
|
@@ -68,6 +68,7 @@ const UnstyledButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
68
68
|
actionType,
|
|
69
69
|
tabIndex = 0,
|
|
70
70
|
isLoading,
|
|
71
|
+
role = 'button',
|
|
71
72
|
...props
|
|
72
73
|
} = _ref;
|
|
73
74
|
return /*#__PURE__*/React.createElement("button", _extends({}, props, ariaLabel ? {
|
|
@@ -75,7 +76,7 @@ const UnstyledButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
75
76
|
} : {}, {
|
|
76
77
|
className: className,
|
|
77
78
|
ref: ref,
|
|
78
|
-
role:
|
|
79
|
+
role: role,
|
|
79
80
|
disabled: disabled,
|
|
80
81
|
tabIndex: disabled ? -1 : tabIndex,
|
|
81
82
|
type: actionType,
|
|
@@ -54,6 +54,7 @@ export type BaseButtonProps = {
|
|
|
54
54
|
ariaLabel?: string,
|
|
55
55
|
tabIndex?: number,
|
|
56
56
|
isLoading?: boolean,
|
|
57
|
+
role?: string,
|
|
57
58
|
...
|
|
58
59
|
};
|
|
59
60
|
|
|
@@ -107,6 +108,7 @@ export const UnstyledButton: React$AbstractComponent<
|
|
|
107
108
|
actionType,
|
|
108
109
|
tabIndex = 0,
|
|
109
110
|
isLoading,
|
|
111
|
+
role = 'button',
|
|
110
112
|
...props
|
|
111
113
|
}: UnstyledButtonProps,
|
|
112
114
|
ref,
|
|
@@ -116,7 +118,7 @@ export const UnstyledButton: React$AbstractComponent<
|
|
|
116
118
|
{...(ariaLabel ? {'aria-label': ariaLabel} : {})}
|
|
117
119
|
className={className}
|
|
118
120
|
ref={ref}
|
|
119
|
-
role=
|
|
121
|
+
role={role}
|
|
120
122
|
disabled={disabled}
|
|
121
123
|
tabIndex={disabled ? -1 : tabIndex}
|
|
122
124
|
type={actionType}
|
|
@@ -39,18 +39,23 @@ export const TruncatedTextWithTooltip = ({
|
|
|
39
39
|
|
|
40
40
|
const checkIfTextOverflowing = React.useMemo(
|
|
41
41
|
() =>
|
|
42
|
-
debounce(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
debounce(
|
|
43
|
+
() => {
|
|
44
|
+
if (
|
|
45
|
+
!wrapText &&
|
|
46
|
+
truncatedRef &&
|
|
47
|
+
truncatedRef.current &&
|
|
48
|
+
truncatedRef.current.scrollHeight >
|
|
49
|
+
truncatedRef.current.clientHeight
|
|
50
|
+
) {
|
|
51
|
+
setShowMouseTip(true);
|
|
52
|
+
} else {
|
|
53
|
+
setShowMouseTip(false);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
200,
|
|
57
|
+
{leading: true},
|
|
58
|
+
),
|
|
54
59
|
[],
|
|
55
60
|
);
|
|
56
61
|
React.useEffect(() => {
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WeekdayPicker = exports.WEEKDAY_PICKER_SIZE = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
9
|
+
var _Button = require("../Button");
|
|
10
|
+
var _WeekdayPickerModule = _interopRequireDefault(require("./WeekdayPicker.module.css"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
|
|
15
|
+
const DEFAULT_WEEKDAYS = [{
|
|
16
|
+
key: 'sun',
|
|
17
|
+
label: 'S'
|
|
18
|
+
}, {
|
|
19
|
+
key: 'mon',
|
|
20
|
+
label: 'M'
|
|
21
|
+
}, {
|
|
22
|
+
key: 'tue',
|
|
23
|
+
label: 'T'
|
|
24
|
+
}, {
|
|
25
|
+
key: 'wed',
|
|
26
|
+
label: 'W'
|
|
27
|
+
}, {
|
|
28
|
+
key: 'thu',
|
|
29
|
+
label: 'T'
|
|
30
|
+
}, {
|
|
31
|
+
key: 'fri',
|
|
32
|
+
label: 'F'
|
|
33
|
+
}, {
|
|
34
|
+
key: 'sat',
|
|
35
|
+
label: 'S'
|
|
36
|
+
}];
|
|
37
|
+
const WEEKEND_KEYS = ['sat', 'sun'];
|
|
38
|
+
const WEEKDAY_PICKER_SIZE = Object.freeze({
|
|
39
|
+
small: 'small',
|
|
40
|
+
medium: 'medium'
|
|
41
|
+
});
|
|
42
|
+
exports.WEEKDAY_PICKER_SIZE = WEEKDAY_PICKER_SIZE;
|
|
43
|
+
const DayButton = _ref => {
|
|
44
|
+
let {
|
|
45
|
+
day,
|
|
46
|
+
isSelected,
|
|
47
|
+
isDisabled,
|
|
48
|
+
onClick,
|
|
49
|
+
className,
|
|
50
|
+
size,
|
|
51
|
+
readOnly
|
|
52
|
+
} = _ref;
|
|
53
|
+
return /*#__PURE__*/React.createElement(_Button.UnstyledButton, {
|
|
54
|
+
key: day.key,
|
|
55
|
+
className: (0, _classify.default)(_WeekdayPickerModule.default.weekdayButton, {
|
|
56
|
+
[_WeekdayPickerModule.default.weekdayButtonMedium]: size === WEEKDAY_PICKER_SIZE.medium,
|
|
57
|
+
[_WeekdayPickerModule.default.weekdayButtonSmall]: size === WEEKDAY_PICKER_SIZE.small,
|
|
58
|
+
[_WeekdayPickerModule.default.weekdayButtonSelected]: isSelected,
|
|
59
|
+
[_WeekdayPickerModule.default.weekdayButtonDisabled]: isDisabled
|
|
60
|
+
}, className),
|
|
61
|
+
onClick: onClick,
|
|
62
|
+
disabled: isDisabled,
|
|
63
|
+
"aria-label": `Select ${day.label}`,
|
|
64
|
+
tabIndex: isDisabled || readOnly ? -1 : 0,
|
|
65
|
+
role: "checkbox"
|
|
66
|
+
}, day.label);
|
|
67
|
+
};
|
|
68
|
+
const WeekdayPicker = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
69
|
+
let {
|
|
70
|
+
size = 'medium',
|
|
71
|
+
selectedWeekDays = [],
|
|
72
|
+
disabledWeekDays = [],
|
|
73
|
+
hiddenWeekDays = [],
|
|
74
|
+
customDayLabels = DEFAULT_WEEKDAYS,
|
|
75
|
+
onChange,
|
|
76
|
+
readOnly = false,
|
|
77
|
+
classNames = {},
|
|
78
|
+
showWeekends = true,
|
|
79
|
+
ariaLabel = 'Select weekdays',
|
|
80
|
+
label,
|
|
81
|
+
helperText,
|
|
82
|
+
disableMultiSelect = false
|
|
83
|
+
} = _ref2;
|
|
84
|
+
const [selectedDays, setSelectedDays] = React.useState(selectedWeekDays);
|
|
85
|
+
const handleDayToggle = (day, event) => {
|
|
86
|
+
if (readOnly || disabledWeekDays.includes(day.key)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
let updatedSelectedDays = selectedDays;
|
|
90
|
+
if (disableMultiSelect) {
|
|
91
|
+
if (selectedDays.some(selected => selected.key === day.key)) {
|
|
92
|
+
updatedSelectedDays = [];
|
|
93
|
+
} else {
|
|
94
|
+
updatedSelectedDays = [day];
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
const isSelected = selectedDays.some(selected => selected.key === day.key);
|
|
98
|
+
if (isSelected) {
|
|
99
|
+
updatedSelectedDays = selectedDays.filter(selected => selected.key !== day.key);
|
|
100
|
+
} else {
|
|
101
|
+
updatedSelectedDays = [...selectedDays, day];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
setSelectedDays(updatedSelectedDays);
|
|
105
|
+
onChange?.(updatedSelectedDays, event);
|
|
106
|
+
};
|
|
107
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
108
|
+
"data-testid": "Weekday-Picker",
|
|
109
|
+
ref: ref,
|
|
110
|
+
className: (0, _classify.default)(_WeekdayPickerModule.default.weekdayPickerContainer, classNames.wrapper, {
|
|
111
|
+
[_WeekdayPickerModule.default.weekdayReadOnly]: readOnly
|
|
112
|
+
}),
|
|
113
|
+
"aria-label": ariaLabel
|
|
114
|
+
}, !!label && /*#__PURE__*/React.createElement("div", {
|
|
115
|
+
className: (0, _classify.default)(_WeekdayPickerModule.default.weekdayLabel, classNames.label)
|
|
116
|
+
}, label), /*#__PURE__*/React.createElement("div", {
|
|
117
|
+
className: _WeekdayPickerModule.default.weekdayPickerDays
|
|
118
|
+
}, customDayLabels.map(day => {
|
|
119
|
+
const isWeekend = WEEKEND_KEYS.includes(day.key);
|
|
120
|
+
const isHidden = hiddenWeekDays.includes(day.key);
|
|
121
|
+
if (!showWeekends && isWeekend || isHidden) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const isSelected = selectedDays.some(selected => selected.key === day.key);
|
|
125
|
+
const isDisabled = disabledWeekDays.includes(day.key);
|
|
126
|
+
return /*#__PURE__*/React.createElement(DayButton, {
|
|
127
|
+
key: day.key,
|
|
128
|
+
day: day,
|
|
129
|
+
isSelected: isSelected,
|
|
130
|
+
isDisabled: isDisabled,
|
|
131
|
+
onClick: event => {
|
|
132
|
+
if (isDisabled) {
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
} else {
|
|
135
|
+
handleDayToggle(day, event);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
className: classNames.button,
|
|
139
|
+
size: size,
|
|
140
|
+
readOnly: readOnly
|
|
141
|
+
});
|
|
142
|
+
})), !!helperText && /*#__PURE__*/React.createElement("div", {
|
|
143
|
+
className: (0, _classify.default)(_WeekdayPickerModule.default.weekdayHelperText, classNames.helperText)
|
|
144
|
+
}, helperText));
|
|
145
|
+
});
|
|
146
|
+
exports.WeekdayPicker = WeekdayPicker;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import classify from '../../utils/classify';
|
|
6
|
+
import {UnstyledButton} from '../Button';
|
|
7
|
+
|
|
8
|
+
import css from './WeekdayPicker.module.css';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const DEFAULT_WEEKDAYS = [
|
|
12
|
+
{key: 'sun', label: 'S'},
|
|
13
|
+
{key: 'mon', label: 'M'},
|
|
14
|
+
{key: 'tue', label: 'T'},
|
|
15
|
+
{key: 'wed', label: 'W'},
|
|
16
|
+
{key: 'thu', label: 'T'},
|
|
17
|
+
{key: 'fri', label: 'F'},
|
|
18
|
+
{key: 'sat', label: 'S'},
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const WEEKEND_KEYS = ['sat', 'sun'];
|
|
22
|
+
|
|
23
|
+
export const WEEKDAY_PICKER_SIZE = Object.freeze({
|
|
24
|
+
small: 'small',
|
|
25
|
+
medium: 'medium',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
type ClassNames = $ReadOnly<{
|
|
29
|
+
wrapper?: string,
|
|
30
|
+
button?: string,
|
|
31
|
+
label?: string,
|
|
32
|
+
helperText?: string,
|
|
33
|
+
}>;
|
|
34
|
+
type WeekdayPickerSize = $Values<typeof WEEKDAY_PICKER_SIZE>;
|
|
35
|
+
|
|
36
|
+
type Weekday = {
|
|
37
|
+
key: string,
|
|
38
|
+
label: string,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type WeekdayPickerProps = {
|
|
42
|
+
size?: WeekdayPickerSize,
|
|
43
|
+
selectedWeekDays?: Array<Weekday>,
|
|
44
|
+
hiddenWeekDays?: Array<string>,
|
|
45
|
+
disabledWeekDays?: Array<string>,
|
|
46
|
+
customDayLabels?: Array<Weekday>,
|
|
47
|
+
onChange?: (
|
|
48
|
+
selectedDays: Array<Weekday>,
|
|
49
|
+
?SyntheticEvent<HTMLElement>,
|
|
50
|
+
) => mixed,
|
|
51
|
+
readOnly?: boolean,
|
|
52
|
+
classNames?: ClassNames,
|
|
53
|
+
showWeekends?: boolean,
|
|
54
|
+
ariaLabel?: string,
|
|
55
|
+
label?: React.Node,
|
|
56
|
+
helperText?: React.Node,
|
|
57
|
+
disableMultiSelect?: boolean,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type DayButtonProps = {
|
|
61
|
+
day: Weekday,
|
|
62
|
+
isSelected: boolean,
|
|
63
|
+
isDisabled: boolean,
|
|
64
|
+
onClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
|
|
65
|
+
className?: string,
|
|
66
|
+
size: WeekdayPickerSize,
|
|
67
|
+
readOnly?: boolean,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const DayButton = ({
|
|
71
|
+
day,
|
|
72
|
+
isSelected,
|
|
73
|
+
isDisabled,
|
|
74
|
+
onClick,
|
|
75
|
+
className,
|
|
76
|
+
size,
|
|
77
|
+
readOnly,
|
|
78
|
+
}: DayButtonProps) => (
|
|
79
|
+
<UnstyledButton
|
|
80
|
+
key={day.key}
|
|
81
|
+
className={classify(
|
|
82
|
+
css.weekdayButton,
|
|
83
|
+
{
|
|
84
|
+
[css.weekdayButtonMedium]: size === WEEKDAY_PICKER_SIZE.medium,
|
|
85
|
+
[css.weekdayButtonSmall]: size === WEEKDAY_PICKER_SIZE.small,
|
|
86
|
+
[css.weekdayButtonSelected]: isSelected,
|
|
87
|
+
[css.weekdayButtonDisabled]: isDisabled,
|
|
88
|
+
},
|
|
89
|
+
className,
|
|
90
|
+
)}
|
|
91
|
+
onClick={onClick}
|
|
92
|
+
disabled={isDisabled}
|
|
93
|
+
aria-label={`Select ${day.label}`}
|
|
94
|
+
tabIndex={isDisabled || readOnly ? -1 : 0}
|
|
95
|
+
role="checkbox"
|
|
96
|
+
>
|
|
97
|
+
{day.label}
|
|
98
|
+
</UnstyledButton>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
export const WeekdayPicker: React$AbstractComponent<
|
|
102
|
+
WeekdayPickerProps,
|
|
103
|
+
HTMLDivElement,
|
|
104
|
+
> = React.forwardRef<WeekdayPickerProps, HTMLDivElement>(
|
|
105
|
+
(
|
|
106
|
+
{
|
|
107
|
+
size = 'medium',
|
|
108
|
+
selectedWeekDays = [],
|
|
109
|
+
disabledWeekDays = [],
|
|
110
|
+
hiddenWeekDays = [],
|
|
111
|
+
customDayLabels = DEFAULT_WEEKDAYS,
|
|
112
|
+
onChange,
|
|
113
|
+
readOnly = false,
|
|
114
|
+
classNames = {},
|
|
115
|
+
showWeekends = true,
|
|
116
|
+
ariaLabel = 'Select weekdays',
|
|
117
|
+
label,
|
|
118
|
+
helperText,
|
|
119
|
+
disableMultiSelect = false,
|
|
120
|
+
}: WeekdayPickerProps,
|
|
121
|
+
ref,
|
|
122
|
+
) => {
|
|
123
|
+
const [selectedDays, setSelectedDays] =
|
|
124
|
+
React.useState<Array<Weekday>>(selectedWeekDays);
|
|
125
|
+
|
|
126
|
+
const handleDayToggle = (
|
|
127
|
+
day: Weekday,
|
|
128
|
+
event: SyntheticEvent<HTMLElement>,
|
|
129
|
+
) => {
|
|
130
|
+
if (readOnly || disabledWeekDays.includes(day.key)) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
let updatedSelectedDays = selectedDays;
|
|
135
|
+
|
|
136
|
+
if (disableMultiSelect) {
|
|
137
|
+
if (selectedDays.some((selected) => selected.key === day.key)) {
|
|
138
|
+
updatedSelectedDays = [];
|
|
139
|
+
} else {
|
|
140
|
+
updatedSelectedDays = [day];
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
const isSelected = selectedDays.some(
|
|
144
|
+
(selected) => selected.key === day.key,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
if (isSelected) {
|
|
148
|
+
updatedSelectedDays = selectedDays.filter(
|
|
149
|
+
(selected) => selected.key !== day.key,
|
|
150
|
+
);
|
|
151
|
+
} else {
|
|
152
|
+
updatedSelectedDays = [...selectedDays, day];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
setSelectedDays(updatedSelectedDays);
|
|
157
|
+
onChange?.(updatedSelectedDays, event);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<div
|
|
162
|
+
data-testid="Weekday-Picker"
|
|
163
|
+
ref={ref}
|
|
164
|
+
className={classify(css.weekdayPickerContainer, classNames.wrapper, {
|
|
165
|
+
[css.weekdayReadOnly]: readOnly,
|
|
166
|
+
})}
|
|
167
|
+
aria-label={ariaLabel}
|
|
168
|
+
>
|
|
169
|
+
{!!label && (
|
|
170
|
+
<div className={classify(css.weekdayLabel, classNames.label)}>
|
|
171
|
+
{label}
|
|
172
|
+
</div>
|
|
173
|
+
)}
|
|
174
|
+
<div className={css.weekdayPickerDays}>
|
|
175
|
+
{customDayLabels.map((day) => {
|
|
176
|
+
const isWeekend = WEEKEND_KEYS.includes(day.key);
|
|
177
|
+
const isHidden = hiddenWeekDays.includes(day.key);
|
|
178
|
+
if ((!showWeekends && isWeekend) || isHidden) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const isSelected = selectedDays.some(
|
|
183
|
+
(selected) => selected.key === day.key,
|
|
184
|
+
);
|
|
185
|
+
const isDisabled = disabledWeekDays.includes(day.key);
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<DayButton
|
|
189
|
+
key={day.key}
|
|
190
|
+
day={day}
|
|
191
|
+
isSelected={isSelected}
|
|
192
|
+
isDisabled={isDisabled}
|
|
193
|
+
onClick={(event) => {
|
|
194
|
+
if (isDisabled) {
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
} else {
|
|
197
|
+
handleDayToggle(day, event);
|
|
198
|
+
}
|
|
199
|
+
}}
|
|
200
|
+
className={classNames.button}
|
|
201
|
+
size={size}
|
|
202
|
+
readOnly={readOnly}
|
|
203
|
+
/>
|
|
204
|
+
);
|
|
205
|
+
})}
|
|
206
|
+
</div>
|
|
207
|
+
{!!helperText && (
|
|
208
|
+
<div
|
|
209
|
+
className={classify(css.weekdayHelperText, classNames.helperText)}
|
|
210
|
+
>
|
|
211
|
+
{helperText}
|
|
212
|
+
</div>
|
|
213
|
+
)}
|
|
214
|
+
</div>
|
|
215
|
+
);
|
|
216
|
+
},
|
|
217
|
+
);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
@value (
|
|
2
|
+
colorTextSecondary,
|
|
3
|
+
colorFillSecondary,
|
|
4
|
+
colorButtonFillTertiaryHovered,
|
|
5
|
+
colorTextPrimary,
|
|
6
|
+
colorButtonFillPrimaryEnabled,
|
|
7
|
+
colorTextInversePrimary,
|
|
8
|
+
colorButtonFillPrimaryHovered,
|
|
9
|
+
colorTextDisabled,
|
|
10
|
+
colorFillDisabled,
|
|
11
|
+
colorFocusPrimary
|
|
12
|
+
) from ' ../../styles/variables/_color.css';
|
|
13
|
+
|
|
14
|
+
@value (spaceXXSmall,spaceXSmall,spaceSmall) from '../../styles/variables/_space.css';
|
|
15
|
+
@value (size42,size34) from '../../styles/variables/_size.css';
|
|
16
|
+
|
|
17
|
+
@value (borderRadiusSmall,borderWidthNone,borderWidthTertiary) from '../../styles/variables/_border.css';
|
|
18
|
+
|
|
19
|
+
.weekdayPickerContainer {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
gap: spaceXXSmall;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.weekdayPickerDays {
|
|
26
|
+
display: flex;
|
|
27
|
+
gap: spaceSmall;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.weekdayButton {
|
|
31
|
+
composes: formLabelSmall from '../../styles/typography.module.css';
|
|
32
|
+
composes: motionEaseInEaseOut from '../../styles/animation.module.css';
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
background-color: colorFillSecondary;
|
|
37
|
+
color: colorTextSecondary;
|
|
38
|
+
padding: spaceXSmall spaceSmall;
|
|
39
|
+
border-radius: borderRadiusSmall;
|
|
40
|
+
|
|
41
|
+
&:hover,
|
|
42
|
+
&:focus-visible {
|
|
43
|
+
background-color: colorButtonFillTertiaryHovered;
|
|
44
|
+
color: colorTextPrimary;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&:focus-visible {
|
|
49
|
+
box-shadow: borderWidthNone borderWidthNone borderWidthNone
|
|
50
|
+
borderWidthTertiary colorFocusPrimary;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.weekdayButtonMedium {
|
|
55
|
+
composes: buttonTextMedium from '../../styles/typography.module.css';
|
|
56
|
+
height: size42;
|
|
57
|
+
width: size42;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.weekdayButtonSmall {
|
|
61
|
+
composes: buttonTextSmall from '../../styles/typography.module.css';
|
|
62
|
+
height: size34;
|
|
63
|
+
width: size34;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.weekdayButtonSelected {
|
|
67
|
+
background-color: colorButtonFillPrimaryEnabled;
|
|
68
|
+
color: colorTextInversePrimary;
|
|
69
|
+
|
|
70
|
+
&:hover,
|
|
71
|
+
&:focus-visible {
|
|
72
|
+
background-color: colorButtonFillPrimaryHovered;
|
|
73
|
+
color: colorTextInversePrimary;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.weekdayButtonDisabled {
|
|
78
|
+
background-color: colorFillDisabled;
|
|
79
|
+
color: colorTextDisabled;
|
|
80
|
+
pointer-events: none;
|
|
81
|
+
cursor: not-allowed;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.weekdayLabel {
|
|
85
|
+
composes: formLabelSmall from '../../styles/typography.module.css';
|
|
86
|
+
color: colorTextSecondary;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.weekdayHelperText {
|
|
90
|
+
composes: bodySmall from '../../styles/typography.module.css';
|
|
91
|
+
color: colorTextSecondary;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.weekdayReadOnly {
|
|
95
|
+
pointer-events: none;
|
|
96
|
+
cursor: not-allowed;
|
|
97
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _WeekdayPicker = require("./WeekdayPicker");
|
|
7
|
+
Object.keys(_WeekdayPicker).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _WeekdayPicker[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _WeekdayPicker[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
package/lib/components/index.js
CHANGED
|
@@ -651,4 +651,15 @@ Object.keys(_Typeahead).forEach(function (key) {
|
|
|
651
651
|
return _Typeahead[key];
|
|
652
652
|
}
|
|
653
653
|
});
|
|
654
|
+
});
|
|
655
|
+
var _WeekdayPicker = require("./WeekdayPicker");
|
|
656
|
+
Object.keys(_WeekdayPicker).forEach(function (key) {
|
|
657
|
+
if (key === "default" || key === "__esModule") return;
|
|
658
|
+
if (key in exports && exports[key] === _WeekdayPicker[key]) return;
|
|
659
|
+
Object.defineProperty(exports, key, {
|
|
660
|
+
enumerable: true,
|
|
661
|
+
get: function () {
|
|
662
|
+
return _WeekdayPicker[key];
|
|
663
|
+
}
|
|
664
|
+
});
|
|
654
665
|
});
|