@fibery/ui-kit 1.36.2 → 1.38.0
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 +20 -0
- package/package.json +8 -5
- package/src/action-badge.tsx +5 -4
- package/src/actions-menu/actions-menu-confirmation.tsx +1 -12
- package/src/actions-menu/actions-menu-item.tsx +19 -7
- package/src/actions-menu/actions-menu-props.tsx +4 -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 +24 -8
- package/src/actions-panel.tsx +12 -2
- package/src/antd/ant-modal.tsx +17 -2
- package/src/antd/input.tsx +4 -3
- package/src/app-icon-with-fallback.tsx +5 -8
- package/src/app-icon-wrapper.tsx +4 -4
- package/src/appIcons.json +20 -0
- package/src/axis-header.tsx +136 -76
- package/src/badge.tsx +14 -7
- package/src/beta-badge.tsx +12 -8
- package/src/box.tsx +1 -1
- package/src/breadcrumb.tsx +78 -0
- package/src/button/actions-button-compact.tsx +5 -2
- package/src/button/base-button.tsx +7 -4
- package/src/button/button-group.tsx +1 -1
- package/src/button/button.tsx +120 -2
- package/src/button/icon-button.tsx +13 -2
- package/src/button/select-button.tsx +27 -8
- package/src/card-container.tsx +36 -69
- package/src/card-hidden-link.tsx +52 -0
- package/src/collapsible-section.tsx +13 -3
- package/src/color-picker/index.js +65 -60
- package/src/color-picker/swatch.tsx +29 -14
- package/src/command-menu/index.tsx +5 -5
- package/src/context-menu/index.tsx +10 -1
- package/src/count-badge.tsx +57 -0
- package/src/date-picker/date-range-input.tsx +1 -1
- package/src/date-picker/date-range-picker.tsx +6 -3
- package/src/date-picker/fake-date-input.tsx +1 -1
- package/src/date-picker/relative-date-picker.tsx +7 -3
- package/src/date-picker/single-date-input.tsx +1 -1
- package/src/date-picker/single-date-picker.tsx +8 -5
- package/src/date-picker/styles.ts +32 -26
- package/src/date-picker/types.ts +3 -1
- package/src/date-picker/utils.ts +9 -2
- 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 +91 -51
- package/src/dropdown-menu/index.tsx +8 -1
- package/src/emoji-picker/app-icon-picker.tsx +6 -4
- package/src/emoji-picker/emoji-picker-content-with-color.tsx +3 -9
- package/src/emoji-picker/emoji-picker-preview-footer.tsx +1 -1
- package/src/emoji-picker/emoji-picker.tsx +3 -0
- package/src/emoji-picker/emoji.tsx +2 -1
- package/src/emoji-picker/icon-emoji-picker.tsx +83 -68
- package/src/emoji-picker/primitives/footer.tsx +0 -1
- package/src/emoji-picker/primitives/header.tsx +1 -0
- package/src/emoji-picker/primitives/search.tsx +12 -13
- package/src/emoji-picker/primitives/skin-tone.tsx +1 -0
- 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/error-alert/error-alert.tsx +19 -7
- package/src/field-app-icon.tsx +29 -0
- package/src/field-container.tsx +4 -2
- package/src/field-icon.tsx +29 -0
- package/src/field-type-icon.tsx +82 -0
- package/src/file-item.tsx +164 -47
- package/src/guide-link.tsx +4 -3
- package/src/hint.tsx +10 -1
- package/src/html-styles.ts +23 -13
- package/src/icons/ast/ActivityFilled.ts +8 -0
- package/src/icons/ast/AiAssistantFilled.ts +8 -0
- package/src/icons/ast/AiFiberyBuild.ts +8 -0
- package/src/icons/ast/Anthropic.ts +1 -1
- package/src/icons/ast/Apple.ts +8 -0
- package/src/icons/ast/ArrowBottom.ts +1 -1
- package/src/icons/ast/ArrowForward.ts +1 -1
- package/src/icons/ast/ArrowLeft.ts +1 -1
- package/src/icons/ast/ArrowRight.ts +1 -1
- package/src/icons/ast/ArrowTop.ts +1 -1
- package/src/icons/ast/CollapseAllHorizontal.ts +8 -0
- package/src/icons/ast/Crosshair.ts +8 -0
- package/src/icons/ast/DateRange.ts +1 -1
- package/src/icons/ast/Document.ts +8 -0
- package/src/icons/ast/EntityCreate.ts +8 -0
- package/src/icons/ast/EntityCreateFilled.ts +8 -0
- package/src/icons/ast/ExpandAll.ts +8 -0
- package/src/icons/ast/ExpandAllHorizontal.ts +8 -0
- package/src/icons/ast/FiberyDesktopApp.ts +8 -0
- package/src/icons/ast/FileDownload.ts +8 -0
- package/src/icons/ast/GlobeUnpublish.ts +8 -0
- package/src/icons/ast/GraduationCapFilled.ts +8 -0
- package/src/icons/ast/Home.ts +1 -1
- package/src/icons/ast/HomeFilled.ts +8 -0
- package/src/icons/ast/ImportFilled.ts +8 -0
- package/src/icons/ast/IntegrationsFilled.ts +8 -0
- package/src/icons/ast/KeyboardHideDown.ts +8 -0
- package/src/icons/ast/LayoutMultiple.ts +8 -0
- package/src/icons/ast/LocationEdit.ts +8 -0
- package/src/icons/ast/MessagePlus.ts +8 -0
- package/src/icons/ast/OpenAi.ts +1 -1
- package/src/icons/ast/RicheditorHistoryRedo.ts +1 -1
- package/src/icons/ast/RicheditorHistoryUndo.ts +1 -1
- package/src/icons/ast/RicheditorMarkHighlight.ts +8 -0
- package/src/icons/ast/RicheditorMarkStrike.ts +1 -1
- package/src/icons/ast/RicheditorMarkUnderline.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/SpaceApp.ts +8 -0
- package/src/icons/ast/SpaceGenerate.ts +8 -0
- package/src/icons/ast/SpaceScratch.ts +8 -0
- package/src/icons/ast/SpaceTemplate.ts +8 -0
- package/src/icons/ast/TableLayout.ts +8 -0
- package/src/icons/ast/TemplatesFilled.ts +8 -0
- package/src/icons/ast/ThumbsDown.ts +8 -0
- package/src/icons/ast/ThumbsUp.ts +8 -0
- package/src/icons/ast/TypeDate.ts +1 -1
- package/src/icons/ast/ViewDashboard.ts +8 -0
- package/src/icons/ast/WarningTriangleFilled.ts +8 -0
- package/src/icons/ast/Windows.ts +8 -0
- package/src/icons/ast/index.tsx +37 -0
- package/src/icons/react/ActivityFilled.tsx +13 -0
- package/src/icons/react/AiAssistantFilled.tsx +13 -0
- package/src/icons/react/AiFiberyBuild.tsx +13 -0
- package/src/icons/react/Apple.tsx +13 -0
- package/src/icons/react/CollapseAllHorizontal.tsx +13 -0
- package/src/icons/react/Crosshair.tsx +13 -0
- package/src/icons/react/Document.tsx +13 -0
- package/src/icons/react/EntityCreate.tsx +13 -0
- package/src/icons/react/EntityCreateFilled.tsx +13 -0
- package/src/icons/react/ExpandAll.tsx +13 -0
- package/src/icons/react/ExpandAllHorizontal.tsx +13 -0
- package/src/icons/react/FiberyDesktopApp.tsx +13 -0
- package/src/icons/react/FileDownload.tsx +13 -0
- package/src/icons/react/GlobeUnpublish.tsx +13 -0
- package/src/icons/react/GraduationCapFilled.tsx +13 -0
- package/src/icons/react/HomeFilled.tsx +13 -0
- package/src/icons/react/ImportFilled.tsx +13 -0
- package/src/icons/react/IntegrationsFilled.tsx +13 -0
- package/src/icons/react/KeyboardHideDown.tsx +13 -0
- package/src/icons/react/LayoutMultiple.tsx +13 -0
- package/src/icons/react/LocationEdit.tsx +13 -0
- package/src/icons/react/MessagePlus.tsx +13 -0
- package/src/icons/react/RicheditorMarkHighlight.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/SpaceApp.tsx +13 -0
- package/src/icons/react/SpaceGenerate.tsx +13 -0
- package/src/icons/react/SpaceScratch.tsx +13 -0
- package/src/icons/react/SpaceTemplate.tsx +13 -0
- package/src/icons/react/TableLayout.tsx +13 -0
- package/src/icons/react/TemplatesFilled.tsx +13 -0
- package/src/icons/react/ThumbsDown.tsx +13 -0
- package/src/icons/react/ThumbsUp.tsx +13 -0
- package/src/icons/react/ViewDashboard.tsx +13 -0
- package/src/icons/react/WarningTriangleFilled.tsx +13 -0
- package/src/icons/react/Windows.tsx +13 -0
- package/src/icons/react/index.tsx +37 -0
- package/src/icons/svg/activity-filled.svg +4 -0
- package/src/icons/svg/ai-assistant-filled.svg +3 -0
- package/src/icons/svg/ai-fibery-build.svg +24 -0
- package/src/icons/svg/anthropic.svg +2 -14
- package/src/icons/svg/apple.svg +4 -0
- package/src/icons/svg/arrow-bottom.svg +1 -1
- package/src/icons/svg/arrow-forward.svg +1 -1
- package/src/icons/svg/arrow-left.svg +1 -1
- package/src/icons/svg/arrow-right.svg +1 -1
- package/src/icons/svg/arrow-top.svg +1 -1
- package/src/icons/svg/collapse-all-horizontal.svg +3 -0
- package/src/icons/svg/crosshair.svg +4 -0
- package/src/icons/svg/date-range.svg +3 -3
- package/src/icons/svg/document.svg +4 -0
- package/src/icons/svg/entity-create-filled.svg +4 -0
- package/src/icons/svg/entity-create.svg +3 -0
- package/src/icons/svg/expand-all-horizontal.svg +3 -0
- package/src/icons/svg/expand-all.svg +3 -0
- package/src/icons/svg/fibery-desktop-app.svg +101 -0
- package/src/icons/svg/file-download.svg +4 -0
- package/src/icons/svg/globe-unpublish.svg +4 -0
- package/src/icons/svg/go-to.svg +1 -3
- package/src/icons/svg/graduation-cap-filled.svg +4 -0
- package/src/icons/svg/home-filled.svg +3 -0
- package/src/icons/svg/home.svg +4 -2
- package/src/icons/svg/import-filled.svg +4 -0
- package/src/icons/svg/integrations-filled.svg +4 -0
- package/src/icons/svg/keyboard-hide-down.svg +1 -0
- package/src/icons/svg/layout-multiple.svg +3 -0
- package/src/icons/svg/location-edit.svg +13 -0
- package/src/icons/svg/message-plus.svg +4 -0
- package/src/icons/svg/open-ai.svg +2 -7
- package/src/icons/svg/open-as-page.svg +2 -3
- package/src/icons/svg/richeditor/history/redo.svg +3 -2
- package/src/icons/svg/richeditor/history/undo.svg +3 -2
- package/src/icons/svg/richeditor/mark/code.svg +4 -5
- package/src/icons/svg/richeditor/mark/em.svg +3 -2
- package/src/icons/svg/richeditor/mark/highlight.svg +3 -0
- package/src/icons/svg/richeditor/mark/strike.svg +3 -2
- package/src/icons/svg/richeditor/mark/strong.svg +3 -2
- package/src/icons/svg/richeditor/mark/underline.svg +4 -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/space-app.svg +3 -0
- package/src/icons/svg/space-generate.svg +3 -0
- package/src/icons/svg/space-scratch.svg +3 -0
- package/src/icons/svg/space-template.svg +3 -0
- package/src/icons/svg/table-layout.svg +3 -0
- package/src/icons/svg/templates-filled.svg +6 -0
- package/src/icons/svg/thumbs-down.svg +3 -0
- package/src/icons/svg/thumbs-up.svg +3 -0
- package/src/icons/svg/type/date.svg +3 -2
- package/src/icons/svg/view-dashboard.svg +5 -0
- package/src/icons/svg/warning-triangle-filled.svg +3 -0
- package/src/icons/svg/windows.svg +15 -0
- package/src/images-gallery/images-gallery.tsx +254 -0
- package/src/images-gallery/zoom.tsx +112 -0
- package/src/integration-compact-info-button.tsx +3 -1
- package/src/is-in-popup.ts +1 -1
- package/src/layout-styles.ts +43 -0
- package/src/lists/actions-menu-row-surface.tsx +3 -1
- package/src/lists/list-row-surface.tsx +9 -2
- package/src/loaders.tsx +6 -6
- package/src/logo.tsx +16 -9
- package/src/mobile-keyboard-aware-popup.tsx +87 -0
- package/src/mobile-styles.ts +10 -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 +37 -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 +37 -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/new-badge.tsx +4 -7
- package/src/number-input/text-area-auto-sized.tsx +47 -0
- package/src/number-input/text-input-auto-sized.tsx +49 -0
- package/src/online-users.tsx +3 -3
- package/src/palette.ts +50 -50
- package/src/popover/index.tsx +687 -0
- package/src/popover/mobile-popup-context.tsx +29 -0
- package/src/{popup → popover}/modifiers.tsx +0 -7
- package/src/{popup → popover}/popup-modifiers-context.ts +3 -3
- package/src/reactions/reaction-button.tsx +30 -45
- package/src/reactions/reaction-picker.tsx +39 -45
- package/src/rich-text-embed-error.tsx +2 -2
- package/src/select/{custom-select-partials → components}/menu.tsx +13 -7
- package/src/select/{custom-select-partials → components}/no-option-message.tsx +0 -1
- package/src/select/constants.ts +1 -0
- package/src/select/index.tsx +143 -148
- package/src/select/select-in-popover.tsx +119 -138
- package/src/select/styles.ts +60 -24
- package/src/shortcut-badge.tsx +1 -0
- package/src/tab-nav/tab-nav.tsx +47 -28
- package/src/theme-provider.tsx +9 -1
- 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 +3 -3
- package/src/tooltip-if-overflown.tsx +9 -3
- package/src/tooltip.tsx +2 -2
- package/src/unit/index.tsx +9 -1
- package/src/unit/loading-unit-value.tsx +1 -0
- package/src/unit/maybe-unit-value.tsx +3 -3
- package/src/unit/primitive.tsx +58 -42
- package/src/unit/styles.ts +10 -14
- package/src/unit/types.ts +4 -2
- package/src/unit/unit-button-group.tsx +6 -11
- package/src/unit/unit-content.tsx +13 -5
- package/src/unit/unit-with-title.tsx +6 -1
- package/src/unit/unit-with-tooltip.tsx +24 -9
- package/src/use-is-phone.tsx +37 -0
- 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 +17 -23
- package/src/number-input/text-area-with-autosize.tsx +0 -91
- package/src/number-input/text-inline-input-with-autosize.tsx +0 -60
- package/src/popup/index.tsx +0 -382
- package/src/use-is-phone.ts +0 -5
- /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
- /package/src/select/{custom-select-partials → components}/clear-indicator.tsx +0 -0
- /package/src/select/{custom-select-partials → components}/drop-down-indicator.tsx +0 -0
- /package/src/select/{custom-select-partials → components}/group-heading.tsx +0 -0
- /package/src/select/{custom-select-partials → components}/menu-list-virtualized.tsx +0 -0
- /package/src/select/{custom-select-partials → components}/option.tsx +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {fontWeight, space, themeVars} from "./design-system";
|
|
2
|
+
import {css} from "@linaria/core";
|
|
3
|
+
import cx from "classnames";
|
|
4
|
+
import {ReactNode} from "react";
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
className?: string;
|
|
8
|
+
count: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const countStyle = css`
|
|
12
|
+
display: inline-block;
|
|
13
|
+
padding: 0 ${space.s6}px 0 ${space.s6}px;
|
|
14
|
+
border-radius: ${space.s8}px;
|
|
15
|
+
font-size: 11px;
|
|
16
|
+
line-height: 16px;
|
|
17
|
+
font-weight: ${fontWeight.regular};
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
const countMinWidth = css`
|
|
21
|
+
min-width: 1.5ch;
|
|
22
|
+
text-align: center;
|
|
23
|
+
box-sizing: content-box;
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
const countBadgeStyle = css`
|
|
27
|
+
background: ${themeVars.badgeBgColor};
|
|
28
|
+
color: ${themeVars.textColor};
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const warningStyle = css`
|
|
32
|
+
background: ${themeVars.warning};
|
|
33
|
+
color: ${themeVars.textColor};
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
export function CountBadge({className, count}: Props) {
|
|
37
|
+
return <span className={cx(countStyle, countBadgeStyle, className)}>{count <= 99 ? count : "99+"}</span>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function CountBadgeWithNoLimits({count, warning}: {count: number | string; warning?: boolean}) {
|
|
41
|
+
return <span className={cx(countStyle, countBadgeStyle, countMinWidth, warning && warningStyle)}>{count}</span>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const ContentWithBadge = ({badge, children}: {badge: ReactNode; children: ReactNode}) => {
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
className={css`
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
gap: ${space.s6}px;
|
|
51
|
+
`}
|
|
52
|
+
>
|
|
53
|
+
{children}
|
|
54
|
+
{badge}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -219,7 +219,7 @@ export const DateRangeInput = forwardRef<
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
const [result] = getLocaleSpecificChrono().parse(inputValue.replace(datesSeparator, " - "));
|
|
222
|
+
const [result] = getLocaleSpecificChrono(dateFormat).parse(inputValue.replace(datesSeparator, " - "));
|
|
223
223
|
let start;
|
|
224
224
|
let end;
|
|
225
225
|
if (result && result.start && result.end) {
|
|
@@ -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
|
});
|
|
@@ -33,7 +33,7 @@ export const FakeDateInputWrapper = forwardRef<HTMLDivElement, Props>(function F
|
|
|
33
33
|
>
|
|
34
34
|
<div>{children}</div>
|
|
35
35
|
<div className={cn(expanderStyle, isPickerOpen && expanderExpandedStyle)}>
|
|
36
|
-
<ArrowCollapseVertical color={themeVars.disabledTextColor} />
|
|
36
|
+
{disabled ? null : <ArrowCollapseVertical color={themeVars.disabledTextColor} />}
|
|
37
37
|
</div>
|
|
38
38
|
</div>
|
|
39
39
|
);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
2
|
import {space, textStyles, themeVars} from "../design-system";
|
|
3
3
|
import {SingleRowSelect as SingleRowReactSelect, SingleValue} from "../select";
|
|
4
|
-
import {AlwaysVisibleDropdownIndicator} from "../select/
|
|
4
|
+
import {AlwaysVisibleDropdownIndicator} from "../select/components/drop-down-indicator";
|
|
5
5
|
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
|
);
|
|
@@ -143,7 +143,7 @@ export const SingleDateInput = forwardRef<
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
const [result] = getLocaleSpecificChrono().parse(inputValue);
|
|
146
|
+
const [result] = getLocaleSpecificChrono(dateFormat).parse(inputValue);
|
|
147
147
|
if (result && result.start) {
|
|
148
148
|
const newValue = result.start.date();
|
|
149
149
|
onChange(newValue);
|
|
@@ -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;
|
|
@@ -150,6 +177,11 @@ export const datePickerStylesOverrideClassName = css`
|
|
|
150
177
|
border: none !important;
|
|
151
178
|
}
|
|
152
179
|
|
|
180
|
+
${mobileRootSelector} & .${dayContentClassName} {
|
|
181
|
+
width: auto;
|
|
182
|
+
max-width: unset;
|
|
183
|
+
}
|
|
184
|
+
|
|
153
185
|
.rdp-day.${startRangeClassName}.${endRangeClassName} {
|
|
154
186
|
border-radius: ${border.radius12}px !important;
|
|
155
187
|
}
|
|
@@ -234,29 +266,3 @@ export const datePickerStylesOverrideClassName = css`
|
|
|
234
266
|
}
|
|
235
267
|
}
|
|
236
268
|
`;
|
|
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;
|
package/src/date-picker/utils.ts
CHANGED
|
@@ -7,9 +7,16 @@ import {
|
|
|
7
7
|
dateTimeFormat as defaultDateTimeFormat,
|
|
8
8
|
} from "../design-system";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const isMonthBeforeDay = (format: string) => {
|
|
11
|
+
// Hacky way to get rid of ddd specifier, which does not matter for us here
|
|
12
|
+
const sanitizedFormat = format.replace("ddd", "").toLowerCase();
|
|
13
|
+
return sanitizedFormat.indexOf("m") < sanitizedFormat.indexOf("d");
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const getLocaleSpecificChrono = (dateFormat: string | undefined) => {
|
|
17
|
+
const weirdFormat = dateFormat && isMonthBeforeDay(dateFormat);
|
|
11
18
|
// We use a single exception here - to support US date order, like m/d/y
|
|
12
|
-
if (
|
|
19
|
+
if (weirdFormat) {
|
|
13
20
|
return chrono.en;
|
|
14
21
|
}
|
|
15
22
|
// Otherwise, use european-style d/m/y
|
|
@@ -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
|
}
|