@fibery/ui-kit 1.37.0 → 1.38.1
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 +25 -0
- package/config/jest/testFrameworkSetup.js +1 -1
- package/package.json +20 -16
- package/src/abbreviate-name.ts +42 -0
- package/src/actions-menu/actions-menu-item.tsx +32 -11
- package/src/actions-menu/actions-menu-props.tsx +5 -0
- package/src/actions-menu/actions-menu-sub-command-menu.tsx +7 -4
- package/src/actions-menu/actions-menu-sub-menu.tsx +9 -3
- package/src/actions-menu/actions-menu.tsx +28 -9
- package/src/actions-menu/context-actions-menu.tsx +22 -0
- package/src/actions-panel.tsx +12 -2
- package/src/animated-height-container.tsx +24 -5
- package/src/antd/ant-upload.tsx +1 -1
- package/src/antd/input.tsx +4 -0
- package/src/avatar.tsx +1 -27
- package/src/axis-header.tsx +136 -76
- package/src/box.tsx +1 -1
- package/src/breadcrumb.tsx +78 -0
- package/src/button/actions-button-compact.tsx +4 -1
- package/src/button/base-button.tsx +7 -3
- package/src/button/button-group.tsx +1 -1
- package/src/button/button.tsx +33 -1
- package/src/button/icon-button.tsx +10 -1
- package/src/button/select-button.tsx +4 -0
- package/src/card-container.tsx +10 -6
- package/src/checkbox.tsx +17 -0
- package/src/collapsible-section.tsx +3 -1
- package/src/color-picker/swatch.tsx +1 -0
- package/src/command-menu/index.tsx +3 -3
- package/src/context-menu/index.tsx +10 -1
- package/src/date-picker/autocomplete.tsx +11 -5
- package/src/date-picker/date-range-input.tsx +5 -1
- package/src/date-picker/date-range-picker-popup-content.tsx +31 -13
- package/src/date-picker/date-range-picker.tsx +6 -3
- package/src/date-picker/relative-date-picker.tsx +6 -2
- package/src/date-picker/single-date-input.tsx +5 -1
- package/src/date-picker/single-date-picker.tsx +8 -5
- package/src/date-picker/styles.ts +52 -26
- package/src/date-picker/types.ts +3 -1
- package/src/day-select/day-select.tsx +21 -75
- package/src/day-select/iso-week-day-select.tsx +1 -1
- package/src/day-select/mount-day-select.tsx +2 -2
- package/src/day-select/week-day-select.tsx +1 -5
- package/src/design-system.ts +45 -12
- package/src/dropdown-menu/index.tsx +19 -2
- package/src/emoji-picker/app-icon-picker.tsx +6 -4
- package/src/emoji-picker/emoji-picker-preview-footer.tsx +5 -1
- package/src/emoji-picker/emoji-picker.tsx +3 -0
- package/src/emoji-picker/emoji.tsx +5 -3
- package/src/emoji-picker/icon-emoji-picker.tsx +10 -1
- package/src/emoji-picker/primitives/emoji.tsx +49 -51
- package/src/emoji-picker/primitives/footer.tsx +5 -0
- package/src/emoji-picker/primitives/search.tsx +8 -0
- package/src/emoji-picker/primitives/skin-tone.tsx +12 -1
- package/src/emoji-picker/use-responsive-emoji-size.ts +11 -0
- package/src/emoji-picker/utils/emoji-set.ts +2 -1
- package/src/empty-state/empty-state.tsx +6 -0
- package/src/fibermoji-placeholder.tsx +1 -27
- package/src/field-icon.tsx +4 -1
- package/src/file-item-2.tsx +408 -0
- package/src/file-item.tsx +215 -47
- package/src/header-layout.tsx +11 -0
- package/src/html-styles.ts +21 -4
- package/src/icons/ast/ActivityFilled.ts +8 -0
- package/src/icons/ast/AiAssistantFilled.ts +8 -0
- package/src/icons/ast/Back.ts +1 -1
- package/src/icons/ast/CollapseAllHorizontal.ts +8 -0
- package/src/icons/ast/DateRange.ts +1 -1
- package/src/icons/ast/EntityCreateFilled.ts +8 -0
- package/src/icons/ast/ExpandAllHorizontal.ts +8 -0
- package/src/icons/ast/ExtensionFiles.ts +1 -1
- package/src/icons/ast/FileUpload.ts +1 -1
- package/src/icons/ast/GlobeUnpublish.ts +8 -0
- package/src/icons/ast/HomeFilled.ts +8 -0
- package/src/icons/ast/KeyboardHideDown.ts +8 -0
- package/src/icons/ast/LayoutMultiple.ts +8 -0
- package/src/icons/ast/RicheditorHistoryRedo.ts +1 -1
- package/src/icons/ast/RicheditorHistoryUndo.ts +1 -1
- package/src/icons/ast/SearchFilled.ts +8 -0
- package/src/icons/ast/SettingsFilled.ts +8 -0
- package/src/icons/ast/SlideMenuFilled.ts +8 -0
- package/src/icons/ast/SwitchToMention.ts +8 -0
- package/src/icons/ast/SwitchToText.ts +8 -0
- package/src/icons/ast/SwitchToWidget.ts +8 -0
- package/src/icons/ast/TypeDate.ts +1 -1
- package/src/icons/ast/ViewGallery.ts +8 -0
- package/src/icons/ast/index.tsx +16 -0
- package/src/icons/react/ActivityFilled.tsx +13 -0
- package/src/icons/react/AiAssistantFilled.tsx +13 -0
- package/src/icons/react/CollapseAllHorizontal.tsx +13 -0
- package/src/icons/react/EntityCreateFilled.tsx +13 -0
- package/src/icons/react/ExpandAllHorizontal.tsx +13 -0
- package/src/icons/react/GlobeUnpublish.tsx +13 -0
- package/src/icons/react/HomeFilled.tsx +13 -0
- package/src/icons/react/KeyboardHideDown.tsx +13 -0
- package/src/icons/react/LayoutMultiple.tsx +13 -0
- package/src/icons/react/SearchFilled.tsx +13 -0
- package/src/icons/react/SettingsFilled.tsx +13 -0
- package/src/icons/react/SlideMenuFilled.tsx +13 -0
- package/src/icons/react/SwitchToMention.tsx +13 -0
- package/src/icons/react/SwitchToText.tsx +13 -0
- package/src/icons/react/SwitchToWidget.tsx +13 -0
- package/src/icons/react/ViewGallery.tsx +13 -0
- package/src/icons/react/index.tsx +16 -0
- package/src/icons/svg/activity-filled.svg +4 -0
- package/src/icons/svg/ai-assistant-filled.svg +3 -0
- package/src/icons/svg/back.svg +3 -1
- package/src/icons/svg/collapse-all-horizontal.svg +3 -0
- package/src/icons/svg/date-range.svg +3 -3
- package/src/icons/svg/entity-create-filled.svg +4 -0
- package/src/icons/svg/expand-all-horizontal.svg +3 -0
- package/src/icons/svg/extension/files.svg +3 -1
- package/src/icons/svg/file-upload.svg +3 -6
- package/src/icons/svg/globe-unpublish.svg +4 -0
- package/src/icons/svg/home-filled.svg +3 -0
- package/src/icons/svg/keyboard-hide-down.svg +1 -0
- package/src/icons/svg/layout-multiple.svg +3 -0
- package/src/icons/svg/richeditor/history/redo.svg +3 -2
- package/src/icons/svg/richeditor/history/undo.svg +3 -2
- package/src/icons/svg/search-filled.svg +3 -0
- package/src/icons/svg/settings-filled.svg +3 -0
- package/src/icons/svg/slide-menu-filled.svg +1 -0
- package/src/icons/svg/switch-to-mention.svg +3 -0
- package/src/icons/svg/switch-to-text.svg +4 -0
- package/src/icons/svg/switch-to-widget.svg +4 -0
- package/src/icons/svg/type/date.svg +3 -2
- package/src/icons/svg/view-gallery.svg +4 -0
- package/src/images-gallery/images-gallery-fall-through-provider.tsx +11 -0
- package/src/images-gallery/images-gallery.tsx +257 -0
- package/src/images-gallery/zoom.tsx +123 -0
- package/src/images-gallery-2/images-gallery-2.tsx +442 -0
- package/src/images-gallery-2/slide-buttons.tsx +230 -0
- package/src/images-gallery-2/zoom.tsx +35 -0
- package/src/is-in-popup.ts +1 -1
- package/src/kbd.tsx +46 -0
- package/src/layout-styles.ts +21 -1
- package/src/lists/actions-menu-row-surface.tsx +3 -1
- package/src/lists/list-row-surface.tsx +7 -1
- package/src/mobile-keyboard-aware-popup.tsx +87 -0
- package/src/mobile-styles.ts +8 -0
- package/src/modal-menu/contexts/modal-menu-context.tsx +22 -0
- package/src/modal-menu/contexts/modal-submenu-context.tsx +16 -0
- package/src/modal-menu/index.tsx +14 -0
- package/src/modal-menu/modal-menu-content.tsx +68 -0
- package/src/modal-menu/modal-menu-group.tsx +10 -0
- package/src/modal-menu/modal-menu-item.tsx +45 -0
- package/src/modal-menu/modal-menu-label.tsx +24 -0
- package/src/modal-menu/modal-menu-root.tsx +57 -0
- package/src/modal-menu/modal-menu-separator.tsx +14 -0
- package/src/modal-menu/modal-menu-trigger.tsx +54 -0
- package/src/modal-menu/modal-submenu-content.tsx +49 -0
- package/src/modal-menu/modal-submenu-trigger.tsx +34 -0
- package/src/modal-menu/modal-submenu.tsx +17 -0
- package/src/notification-dot.tsx +16 -7
- package/src/online-users.tsx +3 -3
- package/src/palette.ts +1 -1
- package/src/platform-symbols.ts +9 -0
- package/src/platform.ts +2 -0
- package/src/popover/index.tsx +710 -0
- package/src/popover/mobile-popup-context.tsx +29 -0
- package/src/{popup → popover}/modifiers.tsx +25 -25
- package/src/{popup → popover}/popup-modifiers-context.ts +3 -3
- package/src/reactions/reaction-button.tsx +342 -135
- package/src/reactions/reaction-picker.tsx +51 -44
- package/src/reactions/reactions.tsx +11 -1
- package/src/reactions/tootltip.tsx +55 -0
- package/src/rich-text-embed-error.tsx +2 -1
- package/src/select/components/group-heading.tsx +8 -0
- package/src/select/components/menu-list-virtualized.tsx +6 -2
- package/src/select/components/option.tsx +4 -0
- package/src/select/index.tsx +8 -4
- package/src/select/select-control-settings-context.tsx +11 -2
- package/src/select/select-in-popover.tsx +30 -39
- package/src/select/styles.ts +21 -1
- package/src/tab-nav/tab-nav.tsx +36 -10
- package/src/toast/primitives.tsx +8 -1
- package/src/toggle-button/round-toggle-button.tsx +23 -0
- package/src/toggle-button/toggle-button-group.tsx +34 -0
- package/src/toggle-button/toggle-button.tsx +164 -0
- package/src/toggle.tsx +11 -3
- package/src/tooltip.tsx +29 -20
- package/src/type-badge.tsx +5 -2
- package/src/unit/styles.ts +2 -2
- package/src/unit/unit-with-tooltip.tsx +1 -1
- package/src/use-is-phone.tsx +50 -4
- package/src/use-is-support-hover.ts +1 -1
- package/src/use-on-screen-keyboard-data.tsx +66 -0
- package/src/workflow-progress-icon.tsx +16 -22
- package/src/popup/index.tsx +0 -383
- package/src/shortcut-badge.tsx +0 -29
- /package/src/{popup → popover}/popup-stack-context.tsx +0 -0
- /package/src/{popup → popover}/reference.ts +0 -0
- /package/src/{popup → popover}/styles.ts +0 -0
- /package/src/{popup → popover}/use-click-outside.ts +0 -0
|
@@ -4,7 +4,7 @@ import {css, cx} from "@linaria/core";
|
|
|
4
4
|
import {styled} from "@linaria/react";
|
|
5
5
|
import {CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandRoot, CommandSeparator} from "cmdk";
|
|
6
6
|
import {forwardRef, useRef, useState} from "react";
|
|
7
|
-
import {border, layout, space, textStyles, themeVars} from "../design-system";
|
|
7
|
+
import {border, layout, layoutVars, space, textStyles, themeVars} from "../design-system";
|
|
8
8
|
import ClearInputFilled from "../icons/react/ClearInputFilled";
|
|
9
9
|
import Search from "../icons/react/Search";
|
|
10
10
|
|
|
@@ -92,7 +92,7 @@ export const CommandMenuEmpty = styled(CommandEmpty)`
|
|
|
92
92
|
display: flex;
|
|
93
93
|
align-items: center;
|
|
94
94
|
padding: 0 ${space.s12}px;
|
|
95
|
-
min-height: ${
|
|
95
|
+
min-height: ${layoutVars.menuItemHeight};
|
|
96
96
|
color: ${themeVars.accentTextColor};
|
|
97
97
|
`;
|
|
98
98
|
|
|
@@ -119,7 +119,7 @@ export const commandItemCss = css`
|
|
|
119
119
|
gap: ${space.s6}px;
|
|
120
120
|
padding: 0 ${space.s8}px;
|
|
121
121
|
cursor: pointer;
|
|
122
|
-
min-height: ${
|
|
122
|
+
min-height: ${layoutVars.menuItemHeight};
|
|
123
123
|
margin: 0 ${space.s4}px;
|
|
124
124
|
border-radius: ${border.radius6}px;
|
|
125
125
|
|
|
@@ -3,6 +3,7 @@ import {styled} from "@linaria/react";
|
|
|
3
3
|
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
|
4
4
|
import {forwardRef} from "react";
|
|
5
5
|
import {border, layout, space, textStyles, themeVars} from "../design-system";
|
|
6
|
+
import {mobileRootSelector} from "../mobile-styles";
|
|
6
7
|
|
|
7
8
|
export const Root = (contextMenuProps: ContextMenuPrimitive.ContextMenuProps) => (
|
|
8
9
|
<ContextMenuPrimitive.Root dir="ltr" {...contextMenuProps} />
|
|
@@ -22,7 +23,7 @@ export const rowItemStyles = {
|
|
|
22
23
|
margin: `0px ${space.s4}px`,
|
|
23
24
|
cursor: "pointer",
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
'&:hover,&[data-highlighted],&[aria-expanded="true"]': {
|
|
26
27
|
inset: "10px 4px",
|
|
27
28
|
marginLeft: 4,
|
|
28
29
|
marginRight: 4,
|
|
@@ -34,11 +35,19 @@ export const rowItemStyles = {
|
|
|
34
35
|
cursor: "default",
|
|
35
36
|
color: themeVars.disabledTextColor,
|
|
36
37
|
|
|
38
|
+
"--actions-menu-item-icon-color": themeVars.disabledTextColor,
|
|
39
|
+
|
|
37
40
|
"&:hover": {
|
|
38
41
|
color: themeVars.disabledTextColor,
|
|
39
42
|
backgroundColor: themeVars.transparent,
|
|
40
43
|
},
|
|
41
44
|
},
|
|
45
|
+
|
|
46
|
+
[`${mobileRootSelector} &`]: {
|
|
47
|
+
...textStyles.big,
|
|
48
|
+
minHeight: layout.mobileMenuItemHeight,
|
|
49
|
+
padding: `0px ${space.s12}px`,
|
|
50
|
+
},
|
|
42
51
|
};
|
|
43
52
|
|
|
44
53
|
const dropdownMenuContentStyles = css`
|
|
@@ -2,7 +2,8 @@ import moment from "moment";
|
|
|
2
2
|
import {useMemo} from "react";
|
|
3
3
|
import {Select} from "../select";
|
|
4
4
|
import {SelectControlSettingsProvider} from "../select/select-control-settings-context";
|
|
5
|
-
import {timeFormat as defaultTimeFormat} from "../design-system";
|
|
5
|
+
import {timeFormat as defaultTimeFormat, space} from "../design-system";
|
|
6
|
+
import {useIsPhone} from "../use-is-phone";
|
|
6
7
|
|
|
7
8
|
const step = 30;
|
|
8
9
|
|
|
@@ -26,6 +27,8 @@ export const AutoComplete = ({
|
|
|
26
27
|
menuIsOpen: boolean;
|
|
27
28
|
position: number;
|
|
28
29
|
}) => {
|
|
30
|
+
const isPhone = useIsPhone();
|
|
31
|
+
|
|
29
32
|
const options = useMemo(
|
|
30
33
|
() =>
|
|
31
34
|
Array.from({length: (24 * 60) / step}, (value, index) => {
|
|
@@ -61,12 +64,15 @@ export const AutoComplete = ({
|
|
|
61
64
|
...props,
|
|
62
65
|
zIndex: 1000000,
|
|
63
66
|
position: "absolute",
|
|
64
|
-
width: "auto",
|
|
65
|
-
top: position,
|
|
67
|
+
width: isPhone ? `calc(100vw - ${2 * space.s12}px)` : "auto",
|
|
68
|
+
top: isPhone ? space.s18 : position,
|
|
66
69
|
margin: 0,
|
|
67
|
-
left: 100,
|
|
70
|
+
left: isPhone ? -space.s12 : 100,
|
|
71
|
+
}),
|
|
72
|
+
menuList: (props) => ({
|
|
73
|
+
...props,
|
|
74
|
+
width: isPhone ? "auto" : 100,
|
|
68
75
|
}),
|
|
69
|
-
menuList: (props) => ({...props, width: 100}),
|
|
70
76
|
}}
|
|
71
77
|
/>
|
|
72
78
|
</SelectControlSettingsProvider>
|
|
@@ -2,6 +2,7 @@ import {css} from "@linaria/core";
|
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState} from "react";
|
|
4
4
|
import {MonthChangeEventHandler} from "react-day-picker";
|
|
5
|
+
import {mobileRootSelector} from "../mobile-styles";
|
|
5
6
|
import {AntTransparentInput} from "../antd/input";
|
|
6
7
|
import {AntTransparentTextArea} from "../antd/input";
|
|
7
8
|
import {inputOverrides} from "../antd/styles";
|
|
@@ -292,6 +293,9 @@ export const DateRangeInput = forwardRef<
|
|
|
292
293
|
display: flex;
|
|
293
294
|
margin-bottom: ${space.s12 + space.s6}px;
|
|
294
295
|
padding-right: ${space.s12 - 2}px;
|
|
296
|
+
${mobileRootSelector} & {
|
|
297
|
+
min-height: ${space.s44}px;
|
|
298
|
+
}
|
|
295
299
|
`,
|
|
296
300
|
{[selectedStyle]: selected, [disabledStyle]: disabled}
|
|
297
301
|
)}
|
|
@@ -335,7 +339,7 @@ export const DateRangeInput = forwardRef<
|
|
|
335
339
|
/>
|
|
336
340
|
</div>
|
|
337
341
|
{allowClear && inputValue !== "" && (
|
|
338
|
-
<IconButton onClick={onClear} size={"tiny"}>
|
|
342
|
+
<IconButton onClick={onClear} size={"tiny"} supportMobile>
|
|
339
343
|
<RemoveIcon />
|
|
340
344
|
</IconButton>
|
|
341
345
|
)}
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
weekendClassName,
|
|
20
20
|
} from "./styles";
|
|
21
21
|
import {getWeekendsForMonth} from "./get-weekends-for-month";
|
|
22
|
+
import {mobileRootSelector} from "../mobile-styles";
|
|
22
23
|
|
|
23
24
|
export const sortDates = ({from, to}: {from: Date; to: Date}) => {
|
|
24
25
|
const [sortedFrom, sortedTo] = [from, to].sort((a, b) => a.getTime() - b.getTime());
|
|
@@ -108,19 +109,36 @@ export const DateRangePickerPopupContent = forwardRef<
|
|
|
108
109
|
: null;
|
|
109
110
|
|
|
110
111
|
const footer = duration ? (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
112
|
+
<>
|
|
113
|
+
<hr
|
|
114
|
+
className={css`
|
|
115
|
+
display: none;
|
|
116
|
+
margin: 0 ${-space.s12}px;
|
|
117
|
+
border: none;
|
|
118
|
+
border-bottom: ${themeVars.separators.opacity5};
|
|
119
|
+
${mobileRootSelector} & {
|
|
120
|
+
display: block;
|
|
121
|
+
}
|
|
122
|
+
`}
|
|
123
|
+
/>
|
|
124
|
+
<div
|
|
125
|
+
className={css`
|
|
126
|
+
background-color: ${themeVars.inputDisabledBgColor};
|
|
127
|
+
border-radius: ${border.radius6}px;
|
|
128
|
+
padding: ${space.s4}px ${space.s8}px;
|
|
129
|
+
${textStyles.small}
|
|
130
|
+
text-align: center;
|
|
131
|
+
color: ${themeVars.disabledTextColor};
|
|
132
|
+
margin-top: ${space.s12}px;
|
|
133
|
+
${mobileRootSelector} & {
|
|
134
|
+
${textStyles.big}
|
|
135
|
+
color: ${themeVars.disabledTextColor};
|
|
136
|
+
}
|
|
137
|
+
`}
|
|
138
|
+
>
|
|
139
|
+
{duration}
|
|
140
|
+
</div>
|
|
141
|
+
</>
|
|
124
142
|
) : null;
|
|
125
143
|
|
|
126
144
|
const placeholder = useRef<string>(`e.g. ${getRandomPlaceholder(showTime, true)}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {ControlledDatePickerProps, DatePickerCommonProps, MomentDateRangeProps} from "./types";
|
|
2
|
-
import {
|
|
2
|
+
import {PopoverOld} from "../popover";
|
|
3
3
|
import {space} from "../design-system";
|
|
4
4
|
import {withPopupControl} from "./with-popup-control";
|
|
5
5
|
import {DateRangePickerPopupContent} from "./date-range-picker-popup-content";
|
|
@@ -19,6 +19,7 @@ export const DateRangePicker = forwardRef<
|
|
|
19
19
|
DatePickerCommonProps & ControlledDatePickerProps & MomentDateRangeProps
|
|
20
20
|
>((props, ref) => {
|
|
21
21
|
const {
|
|
22
|
+
title,
|
|
22
23
|
open,
|
|
23
24
|
onOpen,
|
|
24
25
|
onClose,
|
|
@@ -90,13 +91,15 @@ export const DateRangePicker = forwardRef<
|
|
|
90
91
|
|
|
91
92
|
return (
|
|
92
93
|
<div ref={bypassedRef}>
|
|
93
|
-
<
|
|
94
|
+
<PopoverOld
|
|
95
|
+
title={title}
|
|
94
96
|
offset={[0, space.s6]}
|
|
95
97
|
trigger={
|
|
96
98
|
<div ref={fakeWrapperRef} onClick={stopPropagation}>
|
|
97
99
|
{pickerValue}
|
|
98
100
|
</div>
|
|
99
101
|
}
|
|
102
|
+
supportMobile
|
|
100
103
|
placement="bottom-start"
|
|
101
104
|
open={open}
|
|
102
105
|
onOpen={onOpen}
|
|
@@ -116,7 +119,7 @@ export const DateRangePicker = forwardRef<
|
|
|
116
119
|
value={dateValue}
|
|
117
120
|
onKeyDown={onDatePickerKeyDown}
|
|
118
121
|
/>
|
|
119
|
-
</
|
|
122
|
+
</PopoverOld>
|
|
120
123
|
</div>
|
|
121
124
|
);
|
|
122
125
|
});
|
|
@@ -6,6 +6,7 @@ import {RelativeDateValue} from "./types";
|
|
|
6
6
|
import {useCallback, useMemo, useState} from "react";
|
|
7
7
|
import {$TSFixMe} from "../tsfixme";
|
|
8
8
|
import {AntInputNumber} from "../antd/input-number";
|
|
9
|
+
import {unitOfTime} from "moment";
|
|
9
10
|
|
|
10
11
|
type RelativeDatePickerProps = {
|
|
11
12
|
value: RelativeDateValue | null;
|
|
@@ -29,11 +30,14 @@ const isBeforeNowOptions = [
|
|
|
29
30
|
export const RelativeDatePicker = (props: RelativeDatePickerProps) => {
|
|
30
31
|
const {value, onChange, relativeDateToExactDate} = props;
|
|
31
32
|
|
|
32
|
-
const valueWithDefault = useMemo(
|
|
33
|
+
const valueWithDefault = useMemo(
|
|
34
|
+
() => value ?? {unit: "day" as unitOfTime.DurationConstructor, isBeforeNow: true, amount: 0},
|
|
35
|
+
[value]
|
|
36
|
+
);
|
|
33
37
|
|
|
34
38
|
const onUnitChange = useCallback(
|
|
35
39
|
(newUnit: SingleValue<{value: string}>) => {
|
|
36
|
-
onChange({...valueWithDefault, unit: newUnit!.value});
|
|
40
|
+
onChange({...valueWithDefault, unit: newUnit!.value as unitOfTime.DurationConstructor});
|
|
37
41
|
},
|
|
38
42
|
[valueWithDefault, onChange]
|
|
39
43
|
);
|
|
@@ -6,6 +6,7 @@ import {AntTransparentInput} from "../antd/input";
|
|
|
6
6
|
import {inputOverrides} from "../antd/styles";
|
|
7
7
|
import {space} from "../design-system";
|
|
8
8
|
import {IconButton} from "../button/icon-button";
|
|
9
|
+
import {mobileRootSelector} from "../mobile-styles";
|
|
9
10
|
import RemoveIcon from "../icons/react/Remove";
|
|
10
11
|
import {AutoComplete, OnChangeArgs} from "./autocomplete";
|
|
11
12
|
import {InputRef} from "./rc-input-types";
|
|
@@ -192,6 +193,9 @@ export const SingleDateInput = forwardRef<
|
|
|
192
193
|
display: flex;
|
|
193
194
|
margin-bottom: ${space.s12 + space.s6}px;
|
|
194
195
|
padding-right: ${space.s12 - 2}px;
|
|
196
|
+
${mobileRootSelector} & {
|
|
197
|
+
min-height: ${space.s44}px;
|
|
198
|
+
}
|
|
195
199
|
`,
|
|
196
200
|
{[selectedStyle]: selected, [disabledStyle]: disabled}
|
|
197
201
|
)}
|
|
@@ -228,7 +232,7 @@ export const SingleDateInput = forwardRef<
|
|
|
228
232
|
/>
|
|
229
233
|
</div>
|
|
230
234
|
{allowClear && inputValue !== "" && (
|
|
231
|
-
<IconButton onClick={onClear} size={"tiny"}>
|
|
235
|
+
<IconButton onClick={onClear} size={"tiny"} supportMobile>
|
|
232
236
|
<RemoveIcon />
|
|
233
237
|
</IconButton>
|
|
234
238
|
)}
|
|
@@ -11,7 +11,7 @@ import moment, {Moment} from "moment";
|
|
|
11
11
|
import _ from "lodash";
|
|
12
12
|
import {EmptyValue} from "../empty-value";
|
|
13
13
|
import {formatDateInputValue} from "./utils";
|
|
14
|
-
import {
|
|
14
|
+
import {PopoverOld} from "../popover";
|
|
15
15
|
import {focusable} from "tabbable";
|
|
16
16
|
import {TabNavLink, TabNavList, TabNavRoot} from "../tab-nav/tab-nav";
|
|
17
17
|
import {RelativeDatePicker} from "./relative-date-picker";
|
|
@@ -29,7 +29,7 @@ const tabNavLinkClassName = css`
|
|
|
29
29
|
justify-content: center;
|
|
30
30
|
`;
|
|
31
31
|
|
|
32
|
-
const isRelativeDatePlaceholder = (value: $TSFixMe) => {
|
|
32
|
+
export const isRelativeDatePlaceholder = (value: $TSFixMe) => {
|
|
33
33
|
return (
|
|
34
34
|
value !== null &&
|
|
35
35
|
Object.hasOwn(value, "isBeforeNow") &&
|
|
@@ -38,7 +38,7 @@ const isRelativeDatePlaceholder = (value: $TSFixMe) => {
|
|
|
38
38
|
);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
const formatRelativeDate = (value: RelativeDateValue) => {
|
|
41
|
+
export const formatRelativeDate = (value: RelativeDateValue) => {
|
|
42
42
|
if (value.amount === 0) {
|
|
43
43
|
return "today";
|
|
44
44
|
} else if (value.amount === 1 && value.unit === "day" && !value.isBeforeNow) {
|
|
@@ -76,6 +76,7 @@ export const SingleDatePicker: SingleDatePickerWithForwardRefType = forwardRef<
|
|
|
76
76
|
SingleDatePickerProps<boolean>
|
|
77
77
|
>((props, ref) => {
|
|
78
78
|
const {
|
|
79
|
+
title,
|
|
79
80
|
open,
|
|
80
81
|
onOpen,
|
|
81
82
|
onClose,
|
|
@@ -156,7 +157,8 @@ export const SingleDatePicker: SingleDatePickerWithForwardRefType = forwardRef<
|
|
|
156
157
|
|
|
157
158
|
return (
|
|
158
159
|
<div ref={bypassedRef}>
|
|
159
|
-
<
|
|
160
|
+
<PopoverOld
|
|
161
|
+
title={title}
|
|
160
162
|
offset={[0, space.s6]}
|
|
161
163
|
trigger={
|
|
162
164
|
<div ref={fakeWrapperRef} onClick={stopPropagation}>
|
|
@@ -167,6 +169,7 @@ export const SingleDatePicker: SingleDatePickerWithForwardRefType = forwardRef<
|
|
|
167
169
|
open={open}
|
|
168
170
|
onOpen={onOpen}
|
|
169
171
|
onClose={onClose}
|
|
172
|
+
supportMobile
|
|
170
173
|
popupContainerClassName={css`
|
|
171
174
|
z-index: 10001;
|
|
172
175
|
`}
|
|
@@ -234,7 +237,7 @@ export const SingleDatePicker: SingleDatePickerWithForwardRefType = forwardRef<
|
|
|
234
237
|
/>
|
|
235
238
|
)}
|
|
236
239
|
</div>
|
|
237
|
-
</
|
|
240
|
+
</PopoverOld>
|
|
238
241
|
</div>
|
|
239
242
|
);
|
|
240
243
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
2
|
import {inputOverrides} from "../antd/styles";
|
|
3
3
|
import {border, fontWeight, space, textStyles, themeVars} from "../design-system";
|
|
4
|
+
import {mobileRootSelector} from "../mobile-styles";
|
|
4
5
|
|
|
5
6
|
export const selectedStyle = css`
|
|
6
7
|
${inputOverrides.focus}
|
|
@@ -113,6 +114,32 @@ export const endButtonClassName = css`
|
|
|
113
114
|
background: linear-gradient(90deg, ${focusGradient}) !important;
|
|
114
115
|
}
|
|
115
116
|
`;
|
|
117
|
+
export const dayWrapper = css`
|
|
118
|
+
display: flex;
|
|
119
|
+
height: 100%;
|
|
120
|
+
position: relative;
|
|
121
|
+
`;
|
|
122
|
+
export const dayContentClassName = css`
|
|
123
|
+
pointer-events: none;
|
|
124
|
+
position: absolute;
|
|
125
|
+
top: 0;
|
|
126
|
+
bottom: 0;
|
|
127
|
+
left: 0;
|
|
128
|
+
right: 0;
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
`;
|
|
133
|
+
export const dayButtonsContainerClassName = css`
|
|
134
|
+
position: absolute;
|
|
135
|
+
top: 0;
|
|
136
|
+
left: 0;
|
|
137
|
+
bottom: 0;
|
|
138
|
+
right: 0;
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: stretch;
|
|
141
|
+
justify-content: stretch;
|
|
142
|
+
`;
|
|
116
143
|
export const datePickerStylesOverrideClassName = css`
|
|
117
144
|
.rdp {
|
|
118
145
|
--rdp-cell-size: 36px;
|
|
@@ -129,6 +156,10 @@ export const datePickerStylesOverrideClassName = css`
|
|
|
129
156
|
position: relative;
|
|
130
157
|
|
|
131
158
|
margin: 0;
|
|
159
|
+
|
|
160
|
+
${mobileRootSelector} & {
|
|
161
|
+
--rdp-cell-size: 44px;
|
|
162
|
+
}
|
|
132
163
|
}
|
|
133
164
|
|
|
134
165
|
padding: ${space.s12}px;
|
|
@@ -144,12 +175,20 @@ export const datePickerStylesOverrideClassName = css`
|
|
|
144
175
|
border: none;
|
|
145
176
|
color: ${themeVars.textColor};
|
|
146
177
|
border-radius: 0;
|
|
178
|
+
${mobileRootSelector} & {
|
|
179
|
+
${textStyles.big}
|
|
180
|
+
}
|
|
147
181
|
}
|
|
148
182
|
|
|
149
183
|
.rdp-day:focus {
|
|
150
184
|
border: none !important;
|
|
151
185
|
}
|
|
152
186
|
|
|
187
|
+
${mobileRootSelector} & .${dayContentClassName} {
|
|
188
|
+
width: auto;
|
|
189
|
+
max-width: unset;
|
|
190
|
+
}
|
|
191
|
+
|
|
153
192
|
.rdp-day.${startRangeClassName}.${endRangeClassName} {
|
|
154
193
|
border-radius: ${border.radius12}px !important;
|
|
155
194
|
}
|
|
@@ -205,6 +244,14 @@ export const datePickerStylesOverrideClassName = css`
|
|
|
205
244
|
.rdp-head th {
|
|
206
245
|
${textStyles.small};
|
|
207
246
|
color: ${themeVars.disabledTextColor};
|
|
247
|
+
${mobileRootSelector} & {
|
|
248
|
+
${textStyles.regular}
|
|
249
|
+
color: ${themeVars.accentTextColor};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
${mobileRootSelector} & .rdp-caption {
|
|
254
|
+
margin: ${space.s8}px 0;
|
|
208
255
|
}
|
|
209
256
|
|
|
210
257
|
.rdp-caption_label {
|
|
@@ -220,6 +267,11 @@ export const datePickerStylesOverrideClassName = css`
|
|
|
220
267
|
padding: ${space.s6}px !important;
|
|
221
268
|
}
|
|
222
269
|
|
|
270
|
+
${mobileRootSelector} & .rdp-nav_button {
|
|
271
|
+
width: ${space.s44}px;
|
|
272
|
+
height: ${space.s44}px;
|
|
273
|
+
}
|
|
274
|
+
|
|
223
275
|
.rdp-nav_icon {
|
|
224
276
|
color: ${themeVars.textColor};
|
|
225
277
|
}
|
|
@@ -234,29 +286,3 @@ export const datePickerStylesOverrideClassName = css`
|
|
|
234
286
|
}
|
|
235
287
|
}
|
|
236
288
|
`;
|
|
237
|
-
export const dayWrapper = css`
|
|
238
|
-
display: flex;
|
|
239
|
-
height: 100%;
|
|
240
|
-
position: relative;
|
|
241
|
-
`;
|
|
242
|
-
export const dayContentClassName = css`
|
|
243
|
-
pointer-events: none;
|
|
244
|
-
position: absolute;
|
|
245
|
-
top: 0;
|
|
246
|
-
bottom: 0;
|
|
247
|
-
left: 0;
|
|
248
|
-
right: 0;
|
|
249
|
-
display: flex;
|
|
250
|
-
align-items: center;
|
|
251
|
-
justify-content: center;
|
|
252
|
-
`;
|
|
253
|
-
export const dayButtonsContainerClassName = css`
|
|
254
|
-
position: absolute;
|
|
255
|
-
top: 0;
|
|
256
|
-
left: 0;
|
|
257
|
-
bottom: 0;
|
|
258
|
-
right: 0;
|
|
259
|
-
display: flex;
|
|
260
|
-
align-items: stretch;
|
|
261
|
-
justify-content: stretch;
|
|
262
|
-
`;
|
package/src/date-picker/types.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {Moment} from "moment";
|
|
2
2
|
import {$TSFixMe} from "../tsfixme";
|
|
3
3
|
import {ReactNode} from "react";
|
|
4
|
+
import {unitOfTime} from "moment";
|
|
4
5
|
|
|
5
|
-
export type RelativeDateValue = {isBeforeNow: boolean; unit:
|
|
6
|
+
export type RelativeDateValue = {isBeforeNow: boolean; unit: unitOfTime.DurationConstructor; amount: number};
|
|
6
7
|
|
|
7
8
|
export type MomentSingleDateProps<AllowRelativeDate extends boolean = false> = {
|
|
8
9
|
value: AllowRelativeDate extends true ? Moment | RelativeDateValue | null : Moment | null;
|
|
@@ -17,6 +18,7 @@ export type NativeSingleDatePickerProps = {
|
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export type DatePickerCommonProps = {
|
|
21
|
+
title?: string;
|
|
20
22
|
showTime?: boolean;
|
|
21
23
|
showToday?: boolean;
|
|
22
24
|
showInput?: boolean;
|
|
@@ -1,71 +1,27 @@
|
|
|
1
|
-
import {ChangeEvent} from "react";
|
|
2
1
|
import {css} from "@linaria/core";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import {RoundToggleButton} from "../toggle-button/round-toggle-button";
|
|
3
|
+
import {ToggleButtonGroup, ToggleButtonGroupItem} from "../toggle-button/toggle-button-group";
|
|
5
4
|
|
|
6
|
-
export type Props
|
|
7
|
-
value: Array<
|
|
8
|
-
onChange: (v: Array<
|
|
9
|
-
days: Array<{key: string; title: string; value:
|
|
5
|
+
export type Props = {
|
|
6
|
+
value: Array<number>;
|
|
7
|
+
onChange: (v: Array<number>) => void;
|
|
8
|
+
days: Array<{key: string; title: string; value: number}>;
|
|
10
9
|
allowEmpty?: boolean;
|
|
11
10
|
};
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
export function DaySelect({value = [], onChange, days, allowEmpty = false}: Props): JSX.Element {
|
|
13
|
+
const stringifiedValue = value.map((v) => v.toString());
|
|
14
14
|
|
|
15
|
-
const checkboxInput = css`
|
|
16
|
-
position: absolute;
|
|
17
|
-
appearance: none;
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
const checkbox = css`
|
|
21
|
-
position: absolute;
|
|
22
|
-
border-radius: 50%;
|
|
23
|
-
font-size: 14px;
|
|
24
|
-
width: ${daySize};
|
|
25
|
-
height: ${daySize};
|
|
26
|
-
display: flex;
|
|
27
|
-
align-items: center;
|
|
28
|
-
justify-content: center;
|
|
29
|
-
color: ${themeVars.accentTextColor};
|
|
30
|
-
background-color: ${themeVars.unitBg};
|
|
31
|
-
.${checkboxInput}:checked + & {
|
|
32
|
-
color: ${colors.inversedTextColor};
|
|
33
|
-
background-color: ${themeVars.primary};
|
|
34
|
-
}
|
|
35
|
-
.${checkboxInput}:focus-visible + & {
|
|
36
|
-
${inputOverrides.focus}
|
|
37
|
-
}
|
|
38
|
-
`;
|
|
39
|
-
|
|
40
|
-
function Day<T extends number>({
|
|
41
|
-
value,
|
|
42
|
-
onChange,
|
|
43
|
-
checked,
|
|
44
|
-
title,
|
|
45
|
-
}: {
|
|
46
|
-
value: T;
|
|
47
|
-
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
48
|
-
checked: boolean;
|
|
49
|
-
title: string;
|
|
50
|
-
}): JSX.Element {
|
|
51
|
-
return (
|
|
52
|
-
<label
|
|
53
|
-
className={css`
|
|
54
|
-
cursor: pointer;
|
|
55
|
-
position: relative;
|
|
56
|
-
width: ${daySize};
|
|
57
|
-
height: ${daySize};
|
|
58
|
-
`}
|
|
59
|
-
>
|
|
60
|
-
<input className={checkboxInput} onChange={onChange} checked={checked} type="checkbox" value={value} />
|
|
61
|
-
<div className={checkbox}>{title}</div>
|
|
62
|
-
</label>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function DaySelect<T extends number>({value = [], onChange, days, allowEmpty = false}: Props<T>): JSX.Element {
|
|
67
15
|
return (
|
|
68
|
-
<
|
|
16
|
+
<ToggleButtonGroup
|
|
17
|
+
type="multiple"
|
|
18
|
+
value={stringifiedValue}
|
|
19
|
+
onValueChange={(v) => {
|
|
20
|
+
if (v.length === 0 && !allowEmpty) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
onChange(v.map(Number));
|
|
24
|
+
}}
|
|
69
25
|
className={css`
|
|
70
26
|
grid-template-columns: repeat(7, min-content);
|
|
71
27
|
gap: 4px;
|
|
@@ -74,21 +30,11 @@ export function DaySelect<T extends number>({value = [], onChange, days, allowEm
|
|
|
74
30
|
>
|
|
75
31
|
{days.map(({key, value: v, title}) => {
|
|
76
32
|
return (
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (checked) {
|
|
81
|
-
onChange(value.concat(v));
|
|
82
|
-
} else if (allowEmpty || value.length > 1) {
|
|
83
|
-
onChange(value.filter((val) => val !== v));
|
|
84
|
-
}
|
|
85
|
-
}}
|
|
86
|
-
key={key}
|
|
87
|
-
title={title}
|
|
88
|
-
value={v}
|
|
89
|
-
/>
|
|
33
|
+
<ToggleButtonGroupItem key={key} asChild value={v.toString()}>
|
|
34
|
+
<RoundToggleButton>{title}</RoundToggleButton>
|
|
35
|
+
</ToggleButtonGroupItem>
|
|
90
36
|
);
|
|
91
37
|
})}
|
|
92
|
-
</
|
|
38
|
+
</ToggleButtonGroup>
|
|
93
39
|
);
|
|
94
40
|
}
|
|
@@ -10,6 +10,6 @@ const isoWeekDays = _.range(1, 8).map((day) => {
|
|
|
10
10
|
};
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
export function IsoWeekdaySelect({value, onChange, allowEmpty}: Omit<Props
|
|
13
|
+
export function IsoWeekdaySelect({value, onChange, allowEmpty}: Omit<Props, "days">): JSX.Element {
|
|
14
14
|
return <DaySelect value={value} onChange={onChange} days={isoWeekDays} allowEmpty={allowEmpty} />;
|
|
15
15
|
}
|
|
@@ -3,9 +3,9 @@ import {DaySelect, Props} from "./day-select";
|
|
|
3
3
|
const days = Array.from({length: 28}).map((_, index) => {
|
|
4
4
|
const value = index + 1;
|
|
5
5
|
const key = String(value);
|
|
6
|
-
return {key: String(value), title: key, value};
|
|
6
|
+
return {key: String(value), title: key, value: value};
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
export function MonthdaySelect({value = [], onChange}: Omit<Props
|
|
9
|
+
export function MonthdaySelect({value = [], onChange}: Omit<Props, "days">): JSX.Element {
|
|
10
10
|
return <DaySelect value={value} onChange={onChange} days={days} />;
|
|
11
11
|
}
|
|
@@ -32,11 +32,7 @@ export const getDays = _.memoize((firstDay) => {
|
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
export function WeekdaySelect({
|
|
36
|
-
value = [],
|
|
37
|
-
onChange,
|
|
38
|
-
firstDay,
|
|
39
|
-
}: Omit<Props<Days>, "days"> & {firstDay: number}): JSX.Element {
|
|
35
|
+
export function WeekdaySelect({value = [], onChange, firstDay}: Omit<Props, "days"> & {firstDay: number}): JSX.Element {
|
|
40
36
|
const days = getDays(firstDay);
|
|
41
37
|
return <DaySelect value={value} onChange={onChange} days={days} />;
|
|
42
38
|
}
|