@baishuyun/ai-design 2.0.37 → 2.1.0-alpha.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/.storybook/main.ts +31 -31
- package/.storybook/preview.ts +16 -16
- package/CHANGELOG.md +512 -492
- package/components.json +22 -22
- package/package.json +9 -6
- package/scripts/strip-layers.cjs +41 -41
- package/src/components/abs-fullscreen-gradient-bg.tsx +35 -35
- package/src/components/agent-helper/agent-category-select-menu/index.tsx +57 -57
- package/src/components/agent-helper/agent-entry-card/index.tsx +94 -94
- package/src/components/agent-helper/agent-helper-card/index.tsx +179 -179
- package/src/components/agent-helper/agent-helper-card-list/index.tsx +59 -59
- package/src/components/agent-helper/agent-helper-main-layout/index.tsx +60 -60
- package/src/components/agent-helper/agent-sort-select/index.tsx +89 -89
- package/src/components/agent-helper/agent-tag/index.tsx +29 -29
- package/src/components/agent-helper/app-select/index.tsx +559 -559
- package/src/components/agent-helper/condition-group/index.tsx +75 -75
- package/src/components/agent-helper/condition-input/index.tsx +233 -233
- package/src/components/agent-helper/condition-item/index.tsx +237 -237
- package/src/components/agent-helper/condition-quantifier-select/index.tsx +142 -142
- package/src/components/agent-helper/condition-trigger-description/index.tsx +49 -49
- package/src/components/agent-helper/date-picker/calendar-panel.tsx +164 -164
- package/src/components/agent-helper/date-picker/date-input.tsx +91 -91
- package/src/components/agent-helper/date-picker/date-picker.tsx +327 -327
- package/src/components/agent-helper/date-picker/footer-panel.tsx +44 -44
- package/src/components/agent-helper/date-picker/index.ts +3 -3
- package/src/components/agent-helper/date-picker/month-panel.tsx +82 -82
- package/src/components/agent-helper/date-picker/time-panel.tsx +146 -146
- package/src/components/agent-helper/date-picker/types.ts +37 -37
- package/src/components/agent-helper/date-picker/utils.ts +121 -121
- package/src/components/agent-helper/date-picker/year-panel.tsx +86 -86
- package/src/components/agent-helper/exec-log-filter/index.tsx +232 -232
- package/src/components/agent-helper/field-edit-preference-select/index.tsx +291 -291
- package/src/components/agent-helper/field-select/index.tsx +466 -466
- package/src/components/agent-helper/field-value-input/china-address-data.ts +4117 -4117
- package/src/components/agent-helper/field-value-input/display.tsx +71 -71
- package/src/components/agent-helper/field-value-input/icons.tsx +38 -38
- package/src/components/agent-helper/field-value-input/index.tsx +144 -144
- package/src/components/agent-helper/field-value-input/inputs.tsx +247 -247
- package/src/components/agent-helper/field-value-input/picker-inputs.tsx +1141 -1141
- package/src/components/agent-helper/flow-node-action-trigger-select/index.tsx +57 -57
- package/src/components/agent-helper/form-action-trigger-select/index.tsx +60 -60
- package/src/components/agent-helper/form-divider/index.tsx +44 -44
- package/src/components/agent-helper/form-select/index.tsx +732 -732
- package/src/components/agent-helper/monthdays-select/index.tsx +378 -378
- package/src/components/agent-helper/offset-preference-select/index.tsx +268 -268
- package/src/components/agent-helper/offset-type-select/index.tsx +66 -66
- package/src/components/agent-helper/offset-unit-select/index.tsx +54 -54
- package/src/components/agent-helper/placeholder-card/index.tsx +75 -75
- package/src/components/agent-helper/prompt-input/index.tsx +646 -640
- package/src/components/agent-helper/relational-operator-select/index.tsx +179 -179
- package/src/components/agent-helper/repeat-by-type-select/index.tsx +53 -53
- package/src/components/agent-helper/repeat-preference-select/index.tsx +162 -162
- package/src/components/agent-helper/repeat-preference-type-select/index.tsx +58 -58
- package/src/components/agent-helper/search-input/index.tsx +35 -35
- package/src/components/agent-helper/table/index.tsx +114 -114
- package/src/components/agent-helper/trigger-select/index.tsx +121 -121
- package/src/components/agent-helper/trigger-time-preference-select/index.tsx +189 -189
- package/src/components/agent-helper/trigger-time-source-type-select/index.tsx +53 -53
- package/src/components/agent-helper/weekdays-select/index.tsx +230 -230
- package/src/components/agent-scroll-selector.tsx +193 -193
- package/src/components/agent-select.tsx +154 -154
- package/src/components/attachment-part-group.tsx +35 -35
- package/src/components/attachment-part.tsx +296 -296
- package/src/components/attachments-previewer.tsx +272 -272
- package/src/components/base-button.tsx +49 -49
- package/src/components/border-animation.tsx +107 -107
- package/src/components/border-color-animation.tsx +66 -66
- package/src/components/bot-avatar-name.tsx +36 -36
- package/src/components/bot-icon.tsx +23 -23
- package/src/components/bs-entry-select/app-group-folder.tsx +61 -61
- package/src/components/bs-entry-select/bs-entry-select.tsx +296 -296
- package/src/components/bs-entry-select/build-tree.ts +265 -265
- package/src/components/bs-entry-select/entry-item.tsx +45 -45
- package/src/components/bs-entry-select/entry-popover.tsx +99 -99
- package/src/components/bs-entry-select/index.ts +7 -7
- package/src/components/bs-entry-select/other-app-section.tsx +96 -96
- package/src/components/bs-entry-select/scroll-slider.tsx +872 -872
- package/src/components/bs-entry-select/search-input.tsx +4 -4
- package/src/components/bs-entry-select/tree-item-node.tsx +84 -84
- package/src/components/bs-entry-select/types.ts +46 -46
- package/src/components/bs-icons.tsx +1362 -1362
- package/src/components/card-field.tsx +23 -23
- package/src/components/card.tsx +36 -36
- package/src/components/chat-area-header.tsx +65 -65
- package/src/components/check-card.tsx +77 -77
- package/src/components/circle-checker.tsx +66 -66
- package/src/components/collapsible-txt-msg.tsx +75 -75
- package/src/components/collapsible.tsx +9 -9
- package/src/components/confirm-dialog.tsx +139 -139
- package/src/components/date-range-picker.tsx +91 -91
- package/src/components/fake-bot-msg.tsx +51 -51
- package/src/components/field-checker-list-msg.tsx +146 -146
- package/src/components/field-checker.tsx +185 -185
- package/src/components/field-icon.tsx +13 -13
- package/src/components/field-value-checker.tsx +116 -116
- package/src/components/fields-design-info-table.tsx +160 -160
- package/src/components/fields-generating-indicator.tsx +95 -95
- package/src/components/fields-portal.tsx +18 -18
- package/src/components/fields-previewer.tsx +216 -216
- package/src/components/font-icon.tsx +65 -65
- package/src/components/form-info-editor.tsx +263 -263
- package/src/components/formula-tag.tsx +32 -32
- package/src/components/generate-animation.tsx +56 -56
- package/src/components/icon-btn.tsx +43 -43
- package/src/components/icon-card.tsx +67 -67
- package/src/components/icons/calendar-icon.tsx +5 -5
- package/src/components/icons/clear-all-icon.tsx +5 -5
- package/src/components/icons/empty-agent-icon.tsx +93 -93
- package/src/components/icons/empty-table-icon.tsx +104 -104
- package/src/components/icons/grids-icon.tsx +5 -5
- package/src/components/img-part.tsx +27 -27
- package/src/components/legacy-slot.tsx +110 -110
- package/src/components/line-checker.tsx +168 -168
- package/src/components/linear-gradient-border-btn.tsx +48 -48
- package/src/components/linear-gradient-color-bg-animation.tsx +103 -103
- package/src/components/memoized-markdown.tsx +32 -32
- package/src/components/message-content.tsx +21 -21
- package/src/components/number-part.tsx +46 -46
- package/src/components/office-container.tsx +289 -265
- package/src/components/option-item.tsx +27 -27
- package/src/components/output-config-editor.tsx +478 -478
- package/src/components/previewer-header.tsx +270 -270
- package/src/components/primary-confirm-btn.tsx +58 -58
- package/src/components/primary-entry-btn.tsx +48 -48
- package/src/components/radio-card.tsx +63 -63
- package/src/components/scroll-to-bottom-btn.tsx +28 -28
- package/src/components/split-line.tsx +9 -9
- package/src/components/square-checker.tsx +87 -87
- package/src/components/subform-fields-value-checker.tsx +184 -184
- package/src/components/tab-radio-group.tsx +83 -83
- package/src/components/tooltip.tsx +53 -53
- package/src/components/ui/button.tsx +51 -51
- package/src/components/ui/calendar.tsx +57 -57
- package/src/components/ui/dialog.tsx +104 -104
- package/src/components/ui/drawer.tsx +279 -279
- package/src/components/ui/form.tsx +202 -202
- package/src/components/ui/icons.tsx +1267 -1267
- package/src/components/ui/input.tsx +28 -28
- package/src/components/ui/label.tsx +30 -30
- package/src/components/ui/popover.tsx +85 -85
- package/src/components/ui/select.tsx +236 -236
- package/src/components/ui/spinner.tsx +17 -17
- package/src/components/ui/switch.tsx +33 -33
- package/src/components/ui/tabs.tsx +62 -62
- package/src/components/ui/textarea.tsx +28 -28
- package/src/components/ui/tooltip.tsx +53 -53
- package/src/components/user-txt-msg-bubble.tsx +47 -47
- package/src/components/warning-msg.tsx +27 -27
- package/src/const/ui.ts +119 -119
- package/src/css.d.ts +4 -4
- package/src/hooks/use-column-appear.ts +78 -78
- package/src/hooks/use-portal-container.ts +27 -27
- package/src/hooks/use-resizable-width.ts +129 -129
- package/src/hooks/use-select-popover-position.ts +74 -74
- package/src/hooks/use-shadow.ts +127 -127
- package/src/index.ts +226 -226
- package/src/lib/utils.ts +138 -138
- package/src/stories/AbsFullscreenGradientBg.stories.tsx +36 -36
- package/src/stories/AgentCategorySelectMenu.stories.tsx +33 -33
- package/src/stories/AgentEntryCard.stories.tsx +90 -90
- package/src/stories/AgentHelperCard.stories.tsx +105 -105
- package/src/stories/AgentHelperCardList.stories.tsx +120 -120
- package/src/stories/AgentHelperMainLayout.stories.tsx +71 -71
- package/src/stories/AgentScrollSelector.stories.tsx +95 -95
- package/src/stories/AgentSelect.stories.tsx +134 -134
- package/src/stories/AgentTag.stories.tsx +44 -44
- package/src/stories/AppSelect.stories.tsx +250 -250
- package/src/stories/AttachmentPart.stories.tsx +122 -122
- package/src/stories/AttachmentPartGroup.stories.tsx +152 -152
- package/src/stories/AttachmentsPreviewer.stories.tsx +306 -306
- package/src/stories/BaseButton.stories.tsx +33 -33
- package/src/stories/BorderAnimation.stories.tsx +116 -116
- package/src/stories/BorderColorAnimation.stories.tsx +63 -63
- package/src/stories/BotAvatarAndName.stories.ts +24 -24
- package/src/stories/BotIcon.stories.ts +22 -22
- package/src/stories/BsConditionInput.stories.tsx +460 -460
- package/src/stories/BsEntrySelect.stories.tsx +343 -343
- package/src/stories/BsTooltip.stories.tsx +32 -32
- package/src/stories/Card.stories.tsx +28 -28
- package/src/stories/CardField.stories.tsx +87 -87
- package/src/stories/ChatAreaHeader.stories.ts +26 -26
- package/src/stories/CheckCard.stories.tsx +114 -114
- package/src/stories/CircleChecker.stories.tsx +89 -89
- package/src/stories/CollapsibleTextMsg.stories.ts +44 -44
- package/src/stories/ConditionGroup.stories.tsx +216 -216
- package/src/stories/ConditionInput.stories.tsx +502 -502
- package/src/stories/ConditionItem.stories.tsx +163 -163
- package/src/stories/ConditonQuantifierSelect.stories.tsx +54 -54
- package/src/stories/ConditonTriggerDescription.stories.tsx +61 -61
- package/src/stories/ConfirmDialog.stories.tsx +123 -123
- package/src/stories/DataTable.stories.tsx +191 -191
- package/src/stories/DatePicker.stories.tsx +174 -174
- package/src/stories/ExecLogFilter.stories.tsx +145 -145
- package/src/stories/FakeBotMsg.stories.tsx +36 -36
- package/src/stories/FieldEditPreferenceSelect.stories.tsx +161 -161
- package/src/stories/FieldSelect.stories.tsx +228 -228
- package/src/stories/FieldValueInput.stories.tsx +442 -442
- package/src/stories/FlowNodeActionTriggerSelect.stories.tsx +80 -80
- package/src/stories/Form.stories.tsx +302 -302
- package/src/stories/FormActionTriggerSelect.stories.tsx +80 -80
- package/src/stories/FormDivider.stories.tsx +31 -31
- package/src/stories/FormInfoEditor.stories.tsx +173 -173
- package/src/stories/FormSelect.stories.tsx +222 -222
- package/src/stories/FormulaTag.stories.tsx +68 -68
- package/src/stories/GenerateAnimation.stories.ts +20 -20
- package/src/stories/IconBtn.stories.tsx +32 -32
- package/src/stories/IconCard.stories.tsx +35 -35
- package/src/stories/IconLib.tsx +45 -45
- package/src/stories/Icons.stories.ts +22 -22
- package/src/stories/ImgMsgPart.stories.tsx +42 -42
- package/src/stories/Input.stories.tsx +102 -102
- package/src/stories/Label.stories.tsx +66 -66
- package/src/stories/LegacySlot.stories.tsx +56 -56
- package/src/stories/LineChecker.stories.tsx +133 -133
- package/src/stories/LinearGradientBorderBtn.stories.tsx +86 -86
- package/src/stories/LinearGradientColorBgAnimation.stories.tsx +60 -60
- package/src/stories/MemoizedMarkdown.stories.tsx +102 -102
- package/src/stories/MessageContent.stories.tsx +36 -36
- package/src/stories/MonthdaysSelect.stories.tsx +78 -78
- package/src/stories/NumbersMsgPart.stories.tsx +42 -42
- package/src/stories/OfficeContainer.stories.tsx +287 -287
- package/src/stories/OffsetPreferenceSelect.stories.tsx +118 -118
- package/src/stories/OffsetTypeSelect.stories.tsx +75 -75
- package/src/stories/OffsetUnitSelect.stories.tsx +61 -61
- package/src/stories/OptionItem.stories.tsx +77 -77
- package/src/stories/OutputConfigEditor.stories.tsx +96 -96
- package/src/stories/PlaceholderCard.stories.tsx +35 -35
- package/src/stories/PreviewerHeader.stories.tsx +91 -91
- package/src/stories/PrimaryConfirmBtn.stories.tsx +60 -60
- package/src/stories/PrimaryEntryBtn.stories.tsx +74 -74
- package/src/stories/PromptInput.stories.tsx +228 -228
- package/src/stories/RadioCard.stories.tsx +103 -103
- package/src/stories/RelationalOperatorSelect.stories.tsx +61 -61
- package/src/stories/RepeatByTypeSelect.stories.tsx +58 -58
- package/src/stories/RepeatPreferenceSelect.stories.tsx +107 -107
- package/src/stories/RepeatPreferenceTypeSelect.stories.tsx +58 -58
- package/src/stories/ScrollToBottom.stories.tsx +24 -24
- package/src/stories/SearchInput.stories.tsx +50 -50
- package/src/stories/Select.stories.tsx +128 -128
- package/src/stories/SplitLine.stories.tsx +40 -40
- package/src/stories/SquareChecker.stories.tsx +96 -96
- package/src/stories/TabRadioGroup.stories.tsx +84 -84
- package/src/stories/Textarea.stories.tsx +67 -67
- package/src/stories/TriggerSelect.stories.tsx +48 -48
- package/src/stories/TriggerTimePreferenceSelect.stories.tsx +106 -106
- package/src/stories/TriggerTimeSourceTypeSelect.stories.tsx +68 -68
- package/src/stories/UserTextMsgBubble.stories.ts +24 -24
- package/src/stories/WarningMessage.stories.tsx +23 -23
- package/src/stories/WeekdaysSelect.stories.tsx +66 -66
- package/src/stories/assets/demo.css +539 -539
- package/src/stories/assets/demo_index.html +7988 -7988
- package/src/stories/assets/iconfont.css +1377 -1377
- package/src/stories/assets/iconfont.json +2382 -2382
- package/src/stories/assets/iconfont.svg +697 -697
- package/src/stories/collapsible.stories.tsx +47 -47
- package/src/stories/drawer.stories.tsx +196 -196
- package/src/stories/field-checker-list-msg.stories.tsx +95 -95
- package/src/stories/field-checker.stories.tsx +117 -117
- package/src/stories/field-icon.stories.tsx +70 -70
- package/src/stories/field-value-checker.stories.tsx +113 -113
- package/src/stories/fields-design-info-table.stories.tsx +203 -203
- package/src/stories/fields-generating.stories.tsx +41 -41
- package/src/stories/fields-previewer.stories.tsx +77 -77
- package/src/stories/subform-fields-value-checker.stories.tsx +98 -98
- package/src/style.css +226 -226
- package/src/types.ts +8 -8
- package/style.css +3652 -3652
- package/tsconfig.json +13 -13
- package/vite.config.ts +44 -44
|
@@ -1,378 +1,378 @@
|
|
|
1
|
-
import { useState, useCallback, useMemo } from 'react';
|
|
2
|
-
import type { repeatByMonthDetail } from '@baishuyun/types';
|
|
3
|
-
import { cn } from '../../../lib/utils';
|
|
4
|
-
import { transCls } from '../../../const/ui';
|
|
5
|
-
import { Popover, PopoverTrigger, PopoverContent } from '../../ui/popover';
|
|
6
|
-
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../../ui/tabs';
|
|
7
|
-
import { SquareChecker } from '../../square-checker';
|
|
8
|
-
import { ClearAllIcon } from '../../icons/clear-all-icon';
|
|
9
|
-
import { usePortalContainer } from '../../../hooks/use-portal-container';
|
|
10
|
-
|
|
11
|
-
export interface MonthdaysOption {
|
|
12
|
-
value: repeatByMonthDetail;
|
|
13
|
-
label: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const MonthdaysOptions: MonthdaysOption[] = [
|
|
17
|
-
{ value: 1, label: '1' },
|
|
18
|
-
{ value: 2, label: '2' },
|
|
19
|
-
{ value: 3, label: '3' },
|
|
20
|
-
{ value: 4, label: '4' },
|
|
21
|
-
{ value: 5, label: '5' },
|
|
22
|
-
{ value: 6, label: '6' },
|
|
23
|
-
{ value: 7, label: '7' },
|
|
24
|
-
{ value: 8, label: '8' },
|
|
25
|
-
{ value: 9, label: '9' },
|
|
26
|
-
{ value: 10, label: '10' },
|
|
27
|
-
{ value: 11, label: '11' },
|
|
28
|
-
{ value: 12, label: '12' },
|
|
29
|
-
{ value: 13, label: '13' },
|
|
30
|
-
{ value: 14, label: '14' },
|
|
31
|
-
{ value: 15, label: '15' },
|
|
32
|
-
{ value: 16, label: '16' },
|
|
33
|
-
{ value: 17, label: '17' },
|
|
34
|
-
{ value: 18, label: '18' },
|
|
35
|
-
{ value: 19, label: '19' },
|
|
36
|
-
{ value: 20, label: '20' },
|
|
37
|
-
{ value: 21, label: '21' },
|
|
38
|
-
{ value: 22, label: '22' },
|
|
39
|
-
{ value: 23, label: '23' },
|
|
40
|
-
{ value: 24, label: '24' },
|
|
41
|
-
{ value: 25, label: '25' },
|
|
42
|
-
{ value: 26, label: '26' },
|
|
43
|
-
{ value: 27, label: '27' },
|
|
44
|
-
{ value: 28, label: '28' },
|
|
45
|
-
{ value: 29, label: '29' },
|
|
46
|
-
{ value: 30, label: '30' },
|
|
47
|
-
{ value: 31, label: '31' },
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
const LAST_DAY_OPTION: MonthdaysOption = { value: 'last', label: '最后一个自然日' };
|
|
51
|
-
|
|
52
|
-
const DAYS_PER_ROW = 7;
|
|
53
|
-
|
|
54
|
-
export interface MonthdaysSelectProps {
|
|
55
|
-
value?: repeatByMonthDetail[];
|
|
56
|
-
onChange?: (value: repeatByMonthDetail[]) => void;
|
|
57
|
-
placeholder?: string;
|
|
58
|
-
disabled?: boolean;
|
|
59
|
-
className?: string;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const CloseIcon = () => (
|
|
63
|
-
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" className="shrink-0">
|
|
64
|
-
<path d="M3 3L9 9M9 3L3 9" stroke="#999999" strokeWidth="1.2" strokeLinecap="round" />
|
|
65
|
-
</svg>
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
const DropdownChevron = ({ open }: { open: boolean }) => (
|
|
69
|
-
<svg
|
|
70
|
-
width="16" height="16" viewBox="0 0 16 16" fill="none"
|
|
71
|
-
className={cn('shrink-0', transCls)}
|
|
72
|
-
style={{ transform: open ? 'rotate(180deg)' : 'rotate(0deg)' }}
|
|
73
|
-
>
|
|
74
|
-
<path d="M4 6L8 10L12 6" stroke="#666666" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" />
|
|
75
|
-
</svg>
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
export const MonthdaysSelect = ({
|
|
79
|
-
value = [],
|
|
80
|
-
onChange,
|
|
81
|
-
placeholder = '请选择日期',
|
|
82
|
-
disabled = false,
|
|
83
|
-
className,
|
|
84
|
-
}: MonthdaysSelectProps) => {
|
|
85
|
-
const [open, setOpen] = useState(false);
|
|
86
|
-
const [isHovering, setIsHovering] = useState(false);
|
|
87
|
-
const [draftValue, setDraftValue] = useState<repeatByMonthDetail[]>(value);
|
|
88
|
-
const { portalContainer, setTriggerRef } = usePortalContainer('data-bs-weekdays-select-portal');
|
|
89
|
-
|
|
90
|
-
const displayValue = open ? draftValue : value;
|
|
91
|
-
|
|
92
|
-
const numericSelected = useMemo(
|
|
93
|
-
() => displayValue.filter((v) => v !== 'last') as number[],
|
|
94
|
-
[displayValue]
|
|
95
|
-
);
|
|
96
|
-
const hasLast = useMemo(
|
|
97
|
-
() => displayValue.includes('last'),
|
|
98
|
-
[displayValue]
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const allDaysSelected = numericSelected.length === 31;
|
|
102
|
-
|
|
103
|
-
const handleToggleDay = useCallback(
|
|
104
|
-
(day: repeatByMonthDetail) => {
|
|
105
|
-
setDraftValue((prev) =>
|
|
106
|
-
prev.includes(day) ? prev.filter((v) => v !== day) : [...prev, day]
|
|
107
|
-
);
|
|
108
|
-
},
|
|
109
|
-
[]
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
const handleSelectAllDays = useCallback(() => {
|
|
113
|
-
setDraftValue((prev) => {
|
|
114
|
-
const prevNumeric = prev.filter((v) => v !== 'last') as number[];
|
|
115
|
-
if (prevNumeric.length === 31) {
|
|
116
|
-
return prev.filter((v) => v === 'last');
|
|
117
|
-
}
|
|
118
|
-
const allDays = MonthdaysOptions.map((o) => o.value);
|
|
119
|
-
const lastPart = prev.includes('last') ? (['last'] as const) : [];
|
|
120
|
-
return [...allDays, ...lastPart];
|
|
121
|
-
});
|
|
122
|
-
}, []);
|
|
123
|
-
|
|
124
|
-
const handleSelectToday = useCallback(() => {
|
|
125
|
-
const today = new Date().getDate();
|
|
126
|
-
setDraftValue((prev) => {
|
|
127
|
-
if (prev.includes(today as repeatByMonthDetail)) return prev;
|
|
128
|
-
return [...prev, today as repeatByMonthDetail];
|
|
129
|
-
});
|
|
130
|
-
}, []);
|
|
131
|
-
|
|
132
|
-
const handleToggleLast = useCallback(() => {
|
|
133
|
-
setDraftValue((prev) =>
|
|
134
|
-
prev.includes('last') ? prev.filter((v) => v !== 'last') : [...prev, 'last']
|
|
135
|
-
);
|
|
136
|
-
}, []);
|
|
137
|
-
|
|
138
|
-
const handleConfirm = useCallback(() => {
|
|
139
|
-
onChange?.(draftValue);
|
|
140
|
-
setOpen(false);
|
|
141
|
-
}, [draftValue, onChange]);
|
|
142
|
-
|
|
143
|
-
const handleOpenChange = useCallback(
|
|
144
|
-
(nextOpen: boolean) => {
|
|
145
|
-
if (disabled) return;
|
|
146
|
-
if (nextOpen) {
|
|
147
|
-
setDraftValue([...value]);
|
|
148
|
-
}
|
|
149
|
-
setOpen(nextOpen);
|
|
150
|
-
},
|
|
151
|
-
[disabled, value]
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
const handleClearAll = useCallback(
|
|
155
|
-
(e: React.MouseEvent) => {
|
|
156
|
-
e.stopPropagation();
|
|
157
|
-
onChange?.([]);
|
|
158
|
-
},
|
|
159
|
-
[onChange]
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
const handleRemove = useCallback(
|
|
163
|
-
(day: repeatByMonthDetail, e: React.MouseEvent) => {
|
|
164
|
-
e.stopPropagation();
|
|
165
|
-
onChange?.(value.filter((v) => v !== day));
|
|
166
|
-
},
|
|
167
|
-
[value, onChange]
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
const hasSelection = value.length > 0;
|
|
171
|
-
const showClear = hasSelection && isHovering;
|
|
172
|
-
|
|
173
|
-
const displayLabel = useCallback((v: repeatByMonthDetail) => {
|
|
174
|
-
if (v === 'last') return '最后一天';
|
|
175
|
-
return `${v}日`;
|
|
176
|
-
}, []);
|
|
177
|
-
|
|
178
|
-
const dayRows = useMemo(() => {
|
|
179
|
-
const rows: MonthdaysOption[][] = [];
|
|
180
|
-
for (let i = 0; i < MonthdaysOptions.length; i += DAYS_PER_ROW) {
|
|
181
|
-
rows.push(MonthdaysOptions.slice(i, i + DAYS_PER_ROW));
|
|
182
|
-
}
|
|
183
|
-
return rows;
|
|
184
|
-
}, []);
|
|
185
|
-
|
|
186
|
-
return (
|
|
187
|
-
<div className={cn('relative', className)}>
|
|
188
|
-
<Popover open={open} onOpenChange={handleOpenChange}>
|
|
189
|
-
<PopoverTrigger asChild>
|
|
190
|
-
<button
|
|
191
|
-
type="button"
|
|
192
|
-
ref={setTriggerRef}
|
|
193
|
-
disabled={disabled}
|
|
194
|
-
onMouseEnter={() => setIsHovering(true)}
|
|
195
|
-
onMouseLeave={() => setIsHovering(false)}
|
|
196
|
-
className={cn(
|
|
197
|
-
'flex items-center justify-between w-full h-[34px] gap-2.5',
|
|
198
|
-
'bg-white border border-[#E0E0E0] rounded-[4px]',
|
|
199
|
-
'py-[7px]',
|
|
200
|
-
hasSelection ? 'pl-[4px] pr-[10px]' : 'px-[10px]',
|
|
201
|
-
'text-left cursor-pointer',
|
|
202
|
-
'hover:border-[#0265FF]',
|
|
203
|
-
disabled && 'opacity-50 cursor-not-allowed hover:border-[#E0E0E0]',
|
|
204
|
-
open && 'border-[#0265FF]',
|
|
205
|
-
transCls
|
|
206
|
-
)}
|
|
207
|
-
>
|
|
208
|
-
{hasSelection ? (
|
|
209
|
-
<>
|
|
210
|
-
<div className="flex items-center gap-[4px] min-w-0 flex-1 overflow-x-auto scrollbar-hide">
|
|
211
|
-
{value.map((day) => (
|
|
212
|
-
<span
|
|
213
|
-
key={day}
|
|
214
|
-
className="flex items-center gap-[4px] bg-[#EEEEEE] rounded-[2px] h-[26px] px-[6px] shrink-0"
|
|
215
|
-
>
|
|
216
|
-
<span className="text-[14px] text-[#030303] leading-[normal]">
|
|
217
|
-
{displayLabel(day)}
|
|
218
|
-
</span>
|
|
219
|
-
<span
|
|
220
|
-
className="cursor-pointer flex items-center shrink-0"
|
|
221
|
-
onClick={(e) => handleRemove(day, e)}
|
|
222
|
-
>
|
|
223
|
-
<CloseIcon />
|
|
224
|
-
</span>
|
|
225
|
-
</span>
|
|
226
|
-
))}
|
|
227
|
-
</div>
|
|
228
|
-
{showClear ? (
|
|
229
|
-
<span
|
|
230
|
-
className="cursor-pointer flex items-center shrink-0"
|
|
231
|
-
onClick={handleClearAll}
|
|
232
|
-
>
|
|
233
|
-
<ClearAllIcon />
|
|
234
|
-
</span>
|
|
235
|
-
) : (
|
|
236
|
-
<DropdownChevron open={open} />
|
|
237
|
-
)}
|
|
238
|
-
</>
|
|
239
|
-
) : (
|
|
240
|
-
<>
|
|
241
|
-
<span className="text-[14px] text-[#999999] leading-[normal] truncate">
|
|
242
|
-
{placeholder}
|
|
243
|
-
</span>
|
|
244
|
-
<DropdownChevron open={open} />
|
|
245
|
-
</>
|
|
246
|
-
)}
|
|
247
|
-
</button>
|
|
248
|
-
</PopoverTrigger>
|
|
249
|
-
<PopoverContent
|
|
250
|
-
align="start"
|
|
251
|
-
sideOffset={4}
|
|
252
|
-
portalContainer={portalContainer}
|
|
253
|
-
className="!border-0 rounded-[8px] shadow-[0px_6px_16px_rgba(0,0,0,0.06)] p-0"
|
|
254
|
-
style={{ width: '310px' }}
|
|
255
|
-
>
|
|
256
|
-
<Tabs defaultValue="specific">
|
|
257
|
-
<div className="px-[4px] pt-[4px] flex justify-center">
|
|
258
|
-
<TabsList>
|
|
259
|
-
<TabsTrigger value="specific">指定日期</TabsTrigger>
|
|
260
|
-
<TabsTrigger value="relative">相对日期</TabsTrigger>
|
|
261
|
-
</TabsList>
|
|
262
|
-
</div>
|
|
263
|
-
|
|
264
|
-
<TabsContent value="specific" className="mt-0">
|
|
265
|
-
<div className="px-[8px] pt-[8px] pb-[4px]">
|
|
266
|
-
<button
|
|
267
|
-
type="button"
|
|
268
|
-
onClick={handleSelectAllDays}
|
|
269
|
-
className={cn(
|
|
270
|
-
'flex items-center gap-[6px] w-full h-[34px] px-[10px] py-[7px] rounded-[4px] text-left mb-[4px]',
|
|
271
|
-
'hover:bg-[#EFF0F6]',
|
|
272
|
-
transCls
|
|
273
|
-
)}
|
|
274
|
-
>
|
|
275
|
-
<SquareChecker
|
|
276
|
-
checked={allDaysSelected}
|
|
277
|
-
intermediate={numericSelected.length > 0 && !allDaysSelected}
|
|
278
|
-
onCheckedChange={handleSelectAllDays}
|
|
279
|
-
className="shrink-0"
|
|
280
|
-
/>
|
|
281
|
-
<span className="text-[14px] font-bold text-[#0265FF] leading-[normal]">
|
|
282
|
-
全选
|
|
283
|
-
</span>
|
|
284
|
-
</button>
|
|
285
|
-
<div className="flex flex-col gap-[2px]">
|
|
286
|
-
{dayRows.map((row, rowIdx) => (
|
|
287
|
-
<div key={rowIdx} className="flex gap-[4px]">
|
|
288
|
-
{row.map((option) => {
|
|
289
|
-
const isSelected = numericSelected.includes(option.value as number);
|
|
290
|
-
return (
|
|
291
|
-
<button
|
|
292
|
-
key={option.value}
|
|
293
|
-
type="button"
|
|
294
|
-
onClick={() => handleToggleDay(option.value)}
|
|
295
|
-
className={cn(
|
|
296
|
-
'flex items-center justify-center w-[36px] h-[30px] rounded-[4px]',
|
|
297
|
-
'text-[14px] leading-[normal]',
|
|
298
|
-
'transition-all duration-200 ease-out',
|
|
299
|
-
isSelected
|
|
300
|
-
? 'bg-[#0265FF] text-white'
|
|
301
|
-
: 'text-[#030303] hover:bg-[#EFF0F6]'
|
|
302
|
-
)}
|
|
303
|
-
>
|
|
304
|
-
{option.label}
|
|
305
|
-
</button>
|
|
306
|
-
);
|
|
307
|
-
})}
|
|
308
|
-
</div>
|
|
309
|
-
))}
|
|
310
|
-
</div>
|
|
311
|
-
</div>
|
|
312
|
-
<div className="flex items-center justify-between px-[12px] py-[8px] border-t border-[#E0E0E0] mt-[4px]">
|
|
313
|
-
<button
|
|
314
|
-
type="button"
|
|
315
|
-
onClick={handleSelectToday}
|
|
316
|
-
className={cn(
|
|
317
|
-
'h-[28px] px-[12px] rounded-[4px] text-[14px]',
|
|
318
|
-
'text-[#0265FF] hover:bg-[#EFF0F6]',
|
|
319
|
-
transCls
|
|
320
|
-
)}
|
|
321
|
-
>
|
|
322
|
-
今天
|
|
323
|
-
</button>
|
|
324
|
-
<button
|
|
325
|
-
type="button"
|
|
326
|
-
onClick={handleConfirm}
|
|
327
|
-
className={cn(
|
|
328
|
-
'h-[28px] px-[16px] rounded-[4px] text-[14px]',
|
|
329
|
-
'bg-[#0265FF] text-white hover:bg-[#0255DD]',
|
|
330
|
-
transCls
|
|
331
|
-
)}
|
|
332
|
-
>
|
|
333
|
-
确认
|
|
334
|
-
</button>
|
|
335
|
-
</div>
|
|
336
|
-
</TabsContent>
|
|
337
|
-
|
|
338
|
-
<TabsContent value="relative" className="mt-0">
|
|
339
|
-
<div className="px-[8px] pt-[8px] pb-[4px]">
|
|
340
|
-
<button
|
|
341
|
-
type="button"
|
|
342
|
-
onClick={handleToggleLast}
|
|
343
|
-
className={cn(
|
|
344
|
-
'flex items-center gap-[6px] w-full h-[34px] px-[10px] py-[7px] rounded-[4px] text-left',
|
|
345
|
-
'hover:bg-[#EFF0F6]',
|
|
346
|
-
transCls
|
|
347
|
-
)}
|
|
348
|
-
>
|
|
349
|
-
<SquareChecker
|
|
350
|
-
checked={hasLast}
|
|
351
|
-
onCheckedChange={handleToggleLast}
|
|
352
|
-
className="shrink-0"
|
|
353
|
-
/>
|
|
354
|
-
<span className="text-[14px] text-[#030303] leading-[normal]">
|
|
355
|
-
{LAST_DAY_OPTION.label}
|
|
356
|
-
</span>
|
|
357
|
-
</button>
|
|
358
|
-
</div>
|
|
359
|
-
<div className="flex items-center justify-center px-[12px] py-[8px] border-t border-[#E0E0E0] mt-[4px]">
|
|
360
|
-
<button
|
|
361
|
-
type="button"
|
|
362
|
-
onClick={handleConfirm}
|
|
363
|
-
className={cn(
|
|
364
|
-
'h-[28px] px-[16px] rounded-[4px] text-[14px]',
|
|
365
|
-
'bg-[#0265FF] text-white hover:bg-[#0255DD]',
|
|
366
|
-
transCls
|
|
367
|
-
)}
|
|
368
|
-
>
|
|
369
|
-
确认
|
|
370
|
-
</button>
|
|
371
|
-
</div>
|
|
372
|
-
</TabsContent>
|
|
373
|
-
</Tabs>
|
|
374
|
-
</PopoverContent>
|
|
375
|
-
</Popover>
|
|
376
|
-
</div>
|
|
377
|
-
);
|
|
378
|
-
};
|
|
1
|
+
import { useState, useCallback, useMemo } from 'react';
|
|
2
|
+
import type { repeatByMonthDetail } from '@baishuyun/types';
|
|
3
|
+
import { cn } from '../../../lib/utils';
|
|
4
|
+
import { transCls } from '../../../const/ui';
|
|
5
|
+
import { Popover, PopoverTrigger, PopoverContent } from '../../ui/popover';
|
|
6
|
+
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../../ui/tabs';
|
|
7
|
+
import { SquareChecker } from '../../square-checker';
|
|
8
|
+
import { ClearAllIcon } from '../../icons/clear-all-icon';
|
|
9
|
+
import { usePortalContainer } from '../../../hooks/use-portal-container';
|
|
10
|
+
|
|
11
|
+
export interface MonthdaysOption {
|
|
12
|
+
value: repeatByMonthDetail;
|
|
13
|
+
label: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const MonthdaysOptions: MonthdaysOption[] = [
|
|
17
|
+
{ value: 1, label: '1' },
|
|
18
|
+
{ value: 2, label: '2' },
|
|
19
|
+
{ value: 3, label: '3' },
|
|
20
|
+
{ value: 4, label: '4' },
|
|
21
|
+
{ value: 5, label: '5' },
|
|
22
|
+
{ value: 6, label: '6' },
|
|
23
|
+
{ value: 7, label: '7' },
|
|
24
|
+
{ value: 8, label: '8' },
|
|
25
|
+
{ value: 9, label: '9' },
|
|
26
|
+
{ value: 10, label: '10' },
|
|
27
|
+
{ value: 11, label: '11' },
|
|
28
|
+
{ value: 12, label: '12' },
|
|
29
|
+
{ value: 13, label: '13' },
|
|
30
|
+
{ value: 14, label: '14' },
|
|
31
|
+
{ value: 15, label: '15' },
|
|
32
|
+
{ value: 16, label: '16' },
|
|
33
|
+
{ value: 17, label: '17' },
|
|
34
|
+
{ value: 18, label: '18' },
|
|
35
|
+
{ value: 19, label: '19' },
|
|
36
|
+
{ value: 20, label: '20' },
|
|
37
|
+
{ value: 21, label: '21' },
|
|
38
|
+
{ value: 22, label: '22' },
|
|
39
|
+
{ value: 23, label: '23' },
|
|
40
|
+
{ value: 24, label: '24' },
|
|
41
|
+
{ value: 25, label: '25' },
|
|
42
|
+
{ value: 26, label: '26' },
|
|
43
|
+
{ value: 27, label: '27' },
|
|
44
|
+
{ value: 28, label: '28' },
|
|
45
|
+
{ value: 29, label: '29' },
|
|
46
|
+
{ value: 30, label: '30' },
|
|
47
|
+
{ value: 31, label: '31' },
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const LAST_DAY_OPTION: MonthdaysOption = { value: 'last', label: '最后一个自然日' };
|
|
51
|
+
|
|
52
|
+
const DAYS_PER_ROW = 7;
|
|
53
|
+
|
|
54
|
+
export interface MonthdaysSelectProps {
|
|
55
|
+
value?: repeatByMonthDetail[];
|
|
56
|
+
onChange?: (value: repeatByMonthDetail[]) => void;
|
|
57
|
+
placeholder?: string;
|
|
58
|
+
disabled?: boolean;
|
|
59
|
+
className?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const CloseIcon = () => (
|
|
63
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" className="shrink-0">
|
|
64
|
+
<path d="M3 3L9 9M9 3L3 9" stroke="#999999" strokeWidth="1.2" strokeLinecap="round" />
|
|
65
|
+
</svg>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const DropdownChevron = ({ open }: { open: boolean }) => (
|
|
69
|
+
<svg
|
|
70
|
+
width="16" height="16" viewBox="0 0 16 16" fill="none"
|
|
71
|
+
className={cn('shrink-0', transCls)}
|
|
72
|
+
style={{ transform: open ? 'rotate(180deg)' : 'rotate(0deg)' }}
|
|
73
|
+
>
|
|
74
|
+
<path d="M4 6L8 10L12 6" stroke="#666666" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" />
|
|
75
|
+
</svg>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
export const MonthdaysSelect = ({
|
|
79
|
+
value = [],
|
|
80
|
+
onChange,
|
|
81
|
+
placeholder = '请选择日期',
|
|
82
|
+
disabled = false,
|
|
83
|
+
className,
|
|
84
|
+
}: MonthdaysSelectProps) => {
|
|
85
|
+
const [open, setOpen] = useState(false);
|
|
86
|
+
const [isHovering, setIsHovering] = useState(false);
|
|
87
|
+
const [draftValue, setDraftValue] = useState<repeatByMonthDetail[]>(value);
|
|
88
|
+
const { portalContainer, setTriggerRef } = usePortalContainer('data-bs-weekdays-select-portal');
|
|
89
|
+
|
|
90
|
+
const displayValue = open ? draftValue : value;
|
|
91
|
+
|
|
92
|
+
const numericSelected = useMemo(
|
|
93
|
+
() => displayValue.filter((v) => v !== 'last') as number[],
|
|
94
|
+
[displayValue]
|
|
95
|
+
);
|
|
96
|
+
const hasLast = useMemo(
|
|
97
|
+
() => displayValue.includes('last'),
|
|
98
|
+
[displayValue]
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const allDaysSelected = numericSelected.length === 31;
|
|
102
|
+
|
|
103
|
+
const handleToggleDay = useCallback(
|
|
104
|
+
(day: repeatByMonthDetail) => {
|
|
105
|
+
setDraftValue((prev) =>
|
|
106
|
+
prev.includes(day) ? prev.filter((v) => v !== day) : [...prev, day]
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
[]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const handleSelectAllDays = useCallback(() => {
|
|
113
|
+
setDraftValue((prev) => {
|
|
114
|
+
const prevNumeric = prev.filter((v) => v !== 'last') as number[];
|
|
115
|
+
if (prevNumeric.length === 31) {
|
|
116
|
+
return prev.filter((v) => v === 'last');
|
|
117
|
+
}
|
|
118
|
+
const allDays = MonthdaysOptions.map((o) => o.value);
|
|
119
|
+
const lastPart = prev.includes('last') ? (['last'] as const) : [];
|
|
120
|
+
return [...allDays, ...lastPart];
|
|
121
|
+
});
|
|
122
|
+
}, []);
|
|
123
|
+
|
|
124
|
+
const handleSelectToday = useCallback(() => {
|
|
125
|
+
const today = new Date().getDate();
|
|
126
|
+
setDraftValue((prev) => {
|
|
127
|
+
if (prev.includes(today as repeatByMonthDetail)) return prev;
|
|
128
|
+
return [...prev, today as repeatByMonthDetail];
|
|
129
|
+
});
|
|
130
|
+
}, []);
|
|
131
|
+
|
|
132
|
+
const handleToggleLast = useCallback(() => {
|
|
133
|
+
setDraftValue((prev) =>
|
|
134
|
+
prev.includes('last') ? prev.filter((v) => v !== 'last') : [...prev, 'last']
|
|
135
|
+
);
|
|
136
|
+
}, []);
|
|
137
|
+
|
|
138
|
+
const handleConfirm = useCallback(() => {
|
|
139
|
+
onChange?.(draftValue);
|
|
140
|
+
setOpen(false);
|
|
141
|
+
}, [draftValue, onChange]);
|
|
142
|
+
|
|
143
|
+
const handleOpenChange = useCallback(
|
|
144
|
+
(nextOpen: boolean) => {
|
|
145
|
+
if (disabled) return;
|
|
146
|
+
if (nextOpen) {
|
|
147
|
+
setDraftValue([...value]);
|
|
148
|
+
}
|
|
149
|
+
setOpen(nextOpen);
|
|
150
|
+
},
|
|
151
|
+
[disabled, value]
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const handleClearAll = useCallback(
|
|
155
|
+
(e: React.MouseEvent) => {
|
|
156
|
+
e.stopPropagation();
|
|
157
|
+
onChange?.([]);
|
|
158
|
+
},
|
|
159
|
+
[onChange]
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const handleRemove = useCallback(
|
|
163
|
+
(day: repeatByMonthDetail, e: React.MouseEvent) => {
|
|
164
|
+
e.stopPropagation();
|
|
165
|
+
onChange?.(value.filter((v) => v !== day));
|
|
166
|
+
},
|
|
167
|
+
[value, onChange]
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const hasSelection = value.length > 0;
|
|
171
|
+
const showClear = hasSelection && isHovering;
|
|
172
|
+
|
|
173
|
+
const displayLabel = useCallback((v: repeatByMonthDetail) => {
|
|
174
|
+
if (v === 'last') return '最后一天';
|
|
175
|
+
return `${v}日`;
|
|
176
|
+
}, []);
|
|
177
|
+
|
|
178
|
+
const dayRows = useMemo(() => {
|
|
179
|
+
const rows: MonthdaysOption[][] = [];
|
|
180
|
+
for (let i = 0; i < MonthdaysOptions.length; i += DAYS_PER_ROW) {
|
|
181
|
+
rows.push(MonthdaysOptions.slice(i, i + DAYS_PER_ROW));
|
|
182
|
+
}
|
|
183
|
+
return rows;
|
|
184
|
+
}, []);
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<div className={cn('relative', className)}>
|
|
188
|
+
<Popover open={open} onOpenChange={handleOpenChange}>
|
|
189
|
+
<PopoverTrigger asChild>
|
|
190
|
+
<button
|
|
191
|
+
type="button"
|
|
192
|
+
ref={setTriggerRef}
|
|
193
|
+
disabled={disabled}
|
|
194
|
+
onMouseEnter={() => setIsHovering(true)}
|
|
195
|
+
onMouseLeave={() => setIsHovering(false)}
|
|
196
|
+
className={cn(
|
|
197
|
+
'flex items-center justify-between w-full h-[34px] gap-2.5',
|
|
198
|
+
'bg-white border border-[#E0E0E0] rounded-[4px]',
|
|
199
|
+
'py-[7px]',
|
|
200
|
+
hasSelection ? 'pl-[4px] pr-[10px]' : 'px-[10px]',
|
|
201
|
+
'text-left cursor-pointer',
|
|
202
|
+
'hover:border-[#0265FF]',
|
|
203
|
+
disabled && 'opacity-50 cursor-not-allowed hover:border-[#E0E0E0]',
|
|
204
|
+
open && 'border-[#0265FF]',
|
|
205
|
+
transCls
|
|
206
|
+
)}
|
|
207
|
+
>
|
|
208
|
+
{hasSelection ? (
|
|
209
|
+
<>
|
|
210
|
+
<div className="flex items-center gap-[4px] min-w-0 flex-1 overflow-x-auto scrollbar-hide">
|
|
211
|
+
{value.map((day) => (
|
|
212
|
+
<span
|
|
213
|
+
key={day}
|
|
214
|
+
className="flex items-center gap-[4px] bg-[#EEEEEE] rounded-[2px] h-[26px] px-[6px] shrink-0"
|
|
215
|
+
>
|
|
216
|
+
<span className="text-[14px] text-[#030303] leading-[normal]">
|
|
217
|
+
{displayLabel(day)}
|
|
218
|
+
</span>
|
|
219
|
+
<span
|
|
220
|
+
className="cursor-pointer flex items-center shrink-0"
|
|
221
|
+
onClick={(e) => handleRemove(day, e)}
|
|
222
|
+
>
|
|
223
|
+
<CloseIcon />
|
|
224
|
+
</span>
|
|
225
|
+
</span>
|
|
226
|
+
))}
|
|
227
|
+
</div>
|
|
228
|
+
{showClear ? (
|
|
229
|
+
<span
|
|
230
|
+
className="cursor-pointer flex items-center shrink-0"
|
|
231
|
+
onClick={handleClearAll}
|
|
232
|
+
>
|
|
233
|
+
<ClearAllIcon />
|
|
234
|
+
</span>
|
|
235
|
+
) : (
|
|
236
|
+
<DropdownChevron open={open} />
|
|
237
|
+
)}
|
|
238
|
+
</>
|
|
239
|
+
) : (
|
|
240
|
+
<>
|
|
241
|
+
<span className="text-[14px] text-[#999999] leading-[normal] truncate">
|
|
242
|
+
{placeholder}
|
|
243
|
+
</span>
|
|
244
|
+
<DropdownChevron open={open} />
|
|
245
|
+
</>
|
|
246
|
+
)}
|
|
247
|
+
</button>
|
|
248
|
+
</PopoverTrigger>
|
|
249
|
+
<PopoverContent
|
|
250
|
+
align="start"
|
|
251
|
+
sideOffset={4}
|
|
252
|
+
portalContainer={portalContainer}
|
|
253
|
+
className="!border-0 rounded-[8px] shadow-[0px_6px_16px_rgba(0,0,0,0.06)] p-0"
|
|
254
|
+
style={{ width: '310px' }}
|
|
255
|
+
>
|
|
256
|
+
<Tabs defaultValue="specific">
|
|
257
|
+
<div className="px-[4px] pt-[4px] flex justify-center">
|
|
258
|
+
<TabsList>
|
|
259
|
+
<TabsTrigger value="specific">指定日期</TabsTrigger>
|
|
260
|
+
<TabsTrigger value="relative">相对日期</TabsTrigger>
|
|
261
|
+
</TabsList>
|
|
262
|
+
</div>
|
|
263
|
+
|
|
264
|
+
<TabsContent value="specific" className="mt-0">
|
|
265
|
+
<div className="px-[8px] pt-[8px] pb-[4px]">
|
|
266
|
+
<button
|
|
267
|
+
type="button"
|
|
268
|
+
onClick={handleSelectAllDays}
|
|
269
|
+
className={cn(
|
|
270
|
+
'flex items-center gap-[6px] w-full h-[34px] px-[10px] py-[7px] rounded-[4px] text-left mb-[4px]',
|
|
271
|
+
'hover:bg-[#EFF0F6]',
|
|
272
|
+
transCls
|
|
273
|
+
)}
|
|
274
|
+
>
|
|
275
|
+
<SquareChecker
|
|
276
|
+
checked={allDaysSelected}
|
|
277
|
+
intermediate={numericSelected.length > 0 && !allDaysSelected}
|
|
278
|
+
onCheckedChange={handleSelectAllDays}
|
|
279
|
+
className="shrink-0"
|
|
280
|
+
/>
|
|
281
|
+
<span className="text-[14px] font-bold text-[#0265FF] leading-[normal]">
|
|
282
|
+
全选
|
|
283
|
+
</span>
|
|
284
|
+
</button>
|
|
285
|
+
<div className="flex flex-col gap-[2px]">
|
|
286
|
+
{dayRows.map((row, rowIdx) => (
|
|
287
|
+
<div key={rowIdx} className="flex gap-[4px]">
|
|
288
|
+
{row.map((option) => {
|
|
289
|
+
const isSelected = numericSelected.includes(option.value as number);
|
|
290
|
+
return (
|
|
291
|
+
<button
|
|
292
|
+
key={option.value}
|
|
293
|
+
type="button"
|
|
294
|
+
onClick={() => handleToggleDay(option.value)}
|
|
295
|
+
className={cn(
|
|
296
|
+
'flex items-center justify-center w-[36px] h-[30px] rounded-[4px]',
|
|
297
|
+
'text-[14px] leading-[normal]',
|
|
298
|
+
'transition-all duration-200 ease-out',
|
|
299
|
+
isSelected
|
|
300
|
+
? 'bg-[#0265FF] text-white'
|
|
301
|
+
: 'text-[#030303] hover:bg-[#EFF0F6]'
|
|
302
|
+
)}
|
|
303
|
+
>
|
|
304
|
+
{option.label}
|
|
305
|
+
</button>
|
|
306
|
+
);
|
|
307
|
+
})}
|
|
308
|
+
</div>
|
|
309
|
+
))}
|
|
310
|
+
</div>
|
|
311
|
+
</div>
|
|
312
|
+
<div className="flex items-center justify-between px-[12px] py-[8px] border-t border-[#E0E0E0] mt-[4px]">
|
|
313
|
+
<button
|
|
314
|
+
type="button"
|
|
315
|
+
onClick={handleSelectToday}
|
|
316
|
+
className={cn(
|
|
317
|
+
'h-[28px] px-[12px] rounded-[4px] text-[14px]',
|
|
318
|
+
'text-[#0265FF] hover:bg-[#EFF0F6]',
|
|
319
|
+
transCls
|
|
320
|
+
)}
|
|
321
|
+
>
|
|
322
|
+
今天
|
|
323
|
+
</button>
|
|
324
|
+
<button
|
|
325
|
+
type="button"
|
|
326
|
+
onClick={handleConfirm}
|
|
327
|
+
className={cn(
|
|
328
|
+
'h-[28px] px-[16px] rounded-[4px] text-[14px]',
|
|
329
|
+
'bg-[#0265FF] text-white hover:bg-[#0255DD]',
|
|
330
|
+
transCls
|
|
331
|
+
)}
|
|
332
|
+
>
|
|
333
|
+
确认
|
|
334
|
+
</button>
|
|
335
|
+
</div>
|
|
336
|
+
</TabsContent>
|
|
337
|
+
|
|
338
|
+
<TabsContent value="relative" className="mt-0">
|
|
339
|
+
<div className="px-[8px] pt-[8px] pb-[4px]">
|
|
340
|
+
<button
|
|
341
|
+
type="button"
|
|
342
|
+
onClick={handleToggleLast}
|
|
343
|
+
className={cn(
|
|
344
|
+
'flex items-center gap-[6px] w-full h-[34px] px-[10px] py-[7px] rounded-[4px] text-left',
|
|
345
|
+
'hover:bg-[#EFF0F6]',
|
|
346
|
+
transCls
|
|
347
|
+
)}
|
|
348
|
+
>
|
|
349
|
+
<SquareChecker
|
|
350
|
+
checked={hasLast}
|
|
351
|
+
onCheckedChange={handleToggleLast}
|
|
352
|
+
className="shrink-0"
|
|
353
|
+
/>
|
|
354
|
+
<span className="text-[14px] text-[#030303] leading-[normal]">
|
|
355
|
+
{LAST_DAY_OPTION.label}
|
|
356
|
+
</span>
|
|
357
|
+
</button>
|
|
358
|
+
</div>
|
|
359
|
+
<div className="flex items-center justify-center px-[12px] py-[8px] border-t border-[#E0E0E0] mt-[4px]">
|
|
360
|
+
<button
|
|
361
|
+
type="button"
|
|
362
|
+
onClick={handleConfirm}
|
|
363
|
+
className={cn(
|
|
364
|
+
'h-[28px] px-[16px] rounded-[4px] text-[14px]',
|
|
365
|
+
'bg-[#0265FF] text-white hover:bg-[#0255DD]',
|
|
366
|
+
transCls
|
|
367
|
+
)}
|
|
368
|
+
>
|
|
369
|
+
确认
|
|
370
|
+
</button>
|
|
371
|
+
</div>
|
|
372
|
+
</TabsContent>
|
|
373
|
+
</Tabs>
|
|
374
|
+
</PopoverContent>
|
|
375
|
+
</Popover>
|
|
376
|
+
</div>
|
|
377
|
+
);
|
|
378
|
+
};
|