@modul/mbui 0.0.13-beta-pv-53036-7c290859 → 0.0.13-beta-pv-53036-df9af308
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.
|
@@ -5,37 +5,39 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const React = (0, tslib_1.__importStar)(require("react"));
|
|
6
6
|
const react_day_picker_1 = require("react-day-picker");
|
|
7
7
|
const utils_1 = require("../@/lib/utils");
|
|
8
|
-
const
|
|
8
|
+
const locale_1 = require("date-fns/locale");
|
|
9
|
+
const daySelectedClasses = 'bg-btn-primary text-btn-primary rounded-sm';
|
|
10
|
+
const dayTodayClasses = 'bg-btn-secondary text-btn-secondary rounded-sm';
|
|
11
|
+
const rangeMiddleClasses = 'date-range-middle aria-selected:bg-btn-primary/50 aria-selected:text-white';
|
|
12
|
+
const btnNavClasses = 'opacity-50 hover:opacity-100 ring-offset-2 focus-visible:opacity-100 focus-visible:outline-primary border-input border rounded-sm shadow-sm';
|
|
9
13
|
function Calendar({ className, classNames, showOutsideDays = true, ...props }) {
|
|
10
|
-
return (React.createElement(react_day_picker_1.DayPicker, { showOutsideDays: showOutsideDays, className: (0, utils_1.cn)('
|
|
11
|
-
months: '
|
|
12
|
-
month: 'space-y-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
? '[&:has(>.day-range-end)]:rounded-r-
|
|
25
|
-
: '[&:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
day_hidden: 'invisible',
|
|
14
|
+
return (React.createElement(react_day_picker_1.DayPicker, { locale: locale_1.ru, showOutsideDays: showOutsideDays, className: (0, utils_1.cn)('inline-flex', className), classNames: {
|
|
15
|
+
months: 'relative',
|
|
16
|
+
month: 'flex flex-col space-y-[16px] items-center',
|
|
17
|
+
month_grid: 'w-full border-collapse',
|
|
18
|
+
month_caption: 'inline m-x-auto',
|
|
19
|
+
caption_label: 'text-sm font-medium capitalize',
|
|
20
|
+
nav: 'flex justify-between absolute start-0 end-0',
|
|
21
|
+
button_previous: btnNavClasses,
|
|
22
|
+
button_next: btnNavClasses,
|
|
23
|
+
weekdays: 'flex',
|
|
24
|
+
weekday: 'text-light w-[32px] font-normal text-[14px]',
|
|
25
|
+
week: 'flex w-full mt-2',
|
|
26
|
+
day_button: 'w-[32px] h-[32px] p-0',
|
|
27
|
+
day: (0, utils_1.cn)('aria-selected:opacity-100 text-[14px] leading-[1]', props.mode === 'range'
|
|
28
|
+
? '[&:(.day-range-middle)]:rounded-0 [&:has(>.day-range-end)]:rounded-r-sm [&:has(>.day-range-start)]:rounded-l-sm first:[&:has([aria-selected])]:rounded-l-sm last:[&:has([aria-selected])]:rounded-r-sm'
|
|
29
|
+
: '[&:([aria-selected])]:rounded-sm'),
|
|
30
|
+
range_start: 'day-range-start',
|
|
31
|
+
range_end: 'day-range-end',
|
|
32
|
+
range_middle: rangeMiddleClasses,
|
|
33
|
+
selected: daySelectedClasses,
|
|
34
|
+
today: dayTodayClasses,
|
|
35
|
+
outside: 'day-outside opacity-50 aria-selected:bg-primary aria-selected:text-[white] aria-selected:opacity-30',
|
|
36
|
+
disabled: 'text-light opacity-50',
|
|
37
|
+
hidden: 'invisible',
|
|
35
38
|
...classNames,
|
|
36
39
|
}, components: {
|
|
37
|
-
//
|
|
38
|
-
// IconRight: ({ ...props }) => <Right className="w-4 h-4" />,
|
|
40
|
+
// Chevron: () => <Left className="w-4 h-4" />,
|
|
39
41
|
}, ...props }));
|
|
40
42
|
}
|
|
41
43
|
exports.Calendar = Calendar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","sourceRoot":"","sources":["../../src/Calendar/Calendar.tsx"],"names":[],"mappings":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YACtG,QAAQ,EAAE,uBAAuB;YACjC,MAAM,EAAE,WAAW;YACnB,GAAG,UAAU;SACb,EACD,UAAU,EACT;QACC,+CAA+C;SAC/C,KAEE,KAAK,GACR,CACF,CAAA;AACF,CAAC;AAIQ,4BAAQ;AAFjB,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,59 +1,61 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { DayPicker } from 'react-day-picker'
|
|
3
3
|
import { cn } from '../@/lib/utils'
|
|
4
|
-
import {
|
|
5
|
-
import { Left, Right } from '../Icon'
|
|
4
|
+
import { ru } from 'date-fns/locale'
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
const daySelectedClasses = 'bg-btn-primary text-btn-primary rounded-sm'
|
|
7
|
+
const dayTodayClasses = 'bg-btn-secondary text-btn-secondary rounded-sm'
|
|
8
|
+
const rangeMiddleClasses = 'date-range-middle aria-selected:bg-btn-primary/50 aria-selected:text-white'
|
|
9
|
+
const btnNavClasses =
|
|
10
|
+
'opacity-50 hover:opacity-100 ring-offset-2 focus-visible:opacity-100 focus-visible:outline-primary border-input border rounded-sm shadow-sm'
|
|
8
11
|
|
|
12
|
+
export type CalendarProps = React.ComponentProps<typeof DayPicker>
|
|
9
13
|
function Calendar({ className, classNames, showOutsideDays = true, ...props }: CalendarProps) {
|
|
10
14
|
return (
|
|
11
15
|
<DayPicker
|
|
16
|
+
locale={ru}
|
|
12
17
|
showOutsideDays={showOutsideDays}
|
|
13
|
-
className={cn('
|
|
18
|
+
className={cn('inline-flex', className)}
|
|
14
19
|
classNames={{
|
|
15
|
-
months: '
|
|
16
|
-
month: 'space-y-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
row: 'flex w-full mt-2',
|
|
30
|
-
cell: cn(
|
|
31
|
-
'relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md',
|
|
20
|
+
months: 'relative',
|
|
21
|
+
month: 'flex flex-col space-y-[16px] items-center',
|
|
22
|
+
month_grid: 'w-full border-collapse',
|
|
23
|
+
month_caption: 'inline m-x-auto',
|
|
24
|
+
caption_label: 'text-sm font-medium capitalize',
|
|
25
|
+
nav: 'flex justify-between absolute start-0 end-0',
|
|
26
|
+
button_previous: btnNavClasses,
|
|
27
|
+
button_next: btnNavClasses,
|
|
28
|
+
weekdays: 'flex',
|
|
29
|
+
weekday: 'text-light w-[32px] font-normal text-[14px]',
|
|
30
|
+
week: 'flex w-full mt-2',
|
|
31
|
+
day_button: 'w-[32px] h-[32px] p-0',
|
|
32
|
+
day: cn(
|
|
33
|
+
'aria-selected:opacity-100 text-[14px] leading-[1]',
|
|
32
34
|
props.mode === 'range'
|
|
33
|
-
? '[&:has(>.day-range-end)]:rounded-r-
|
|
34
|
-
: '[&:
|
|
35
|
+
? '[&:(.day-range-middle)]:rounded-0 [&:has(>.day-range-end)]:rounded-r-sm [&:has(>.day-range-start)]:rounded-l-sm first:[&:has([aria-selected])]:rounded-l-sm last:[&:has([aria-selected])]:rounded-r-sm'
|
|
36
|
+
: '[&:([aria-selected])]:rounded-sm'
|
|
35
37
|
),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
day_range_middle: 'aria-selected:bg-accent aria-selected:text-accent-foreground',
|
|
46
|
-
day_hidden: 'invisible',
|
|
38
|
+
range_start: 'day-range-start',
|
|
39
|
+
range_end: 'day-range-end',
|
|
40
|
+
range_middle: rangeMiddleClasses,
|
|
41
|
+
selected: daySelectedClasses,
|
|
42
|
+
today: dayTodayClasses,
|
|
43
|
+
outside:
|
|
44
|
+
'day-outside opacity-50 aria-selected:bg-primary aria-selected:text-[white] aria-selected:opacity-30',
|
|
45
|
+
disabled: 'text-light opacity-50',
|
|
46
|
+
hidden: 'invisible',
|
|
47
47
|
...classNames,
|
|
48
48
|
}}
|
|
49
|
-
components={
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
components={
|
|
50
|
+
{
|
|
51
|
+
// Chevron: () => <Left className="w-4 h-4" />,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
53
54
|
{...props}
|
|
54
55
|
/>
|
|
55
56
|
)
|
|
56
57
|
}
|
|
58
|
+
|
|
57
59
|
Calendar.displayName = 'Calendar'
|
|
58
60
|
|
|
59
61
|
export { Calendar }
|
|
@@ -1,41 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { format } from 'date-fns'
|
|
3
|
+
import { cn } from '../@/lib/utils'
|
|
4
|
+
import { Calendar } from '../Calendar'
|
|
5
|
+
import { Calendar as CalendarIcon } from '../Icon'
|
|
6
|
+
import { Popover } from '../Popover'
|
|
7
|
+
import { ru } from 'date-fns/locale'
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
const trigegrClasses = 'inline-flex items-center border-input border h-[44px] rounded-sm px-[16px]'
|
|
4
10
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Popover,
|
|
12
|
-
} from "../Popover"
|
|
11
|
+
interface IProps {
|
|
12
|
+
placeholder?: string,
|
|
13
|
+
date: Date,
|
|
14
|
+
classTrigger?: string,
|
|
15
|
+
triggerDisabled: boolean,
|
|
16
|
+
}
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
const [date, setDate] = React.useState<Date>()
|
|
18
|
+
const DatePicker: React.FC<IProps> = ({placeholder, triggerDisabled, date, classTrigger, ...props}) => {
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
mode="single"
|
|
34
|
-
// selected={date}
|
|
35
|
-
// onSelect={setDate}
|
|
36
|
-
// initialFocus
|
|
37
|
-
/>
|
|
38
|
-
</Popover.Content>
|
|
39
|
-
</Popover>
|
|
40
|
-
)
|
|
20
|
+
return (
|
|
21
|
+
<Popover>
|
|
22
|
+
<Popover.Trigger asChild>
|
|
23
|
+
<button className={cn(trigegrClasses, {'bg-light text-light':triggerDisabled}, classTrigger)} disabled={triggerDisabled}>
|
|
24
|
+
{date ? <span className='truncate'>{format(date ,'PPP', {locale: ru})}</span> : <span className='text-light truncate'>{placeholder}</span>}
|
|
25
|
+
<CalendarIcon width={18} height={18} className="ml-[8px] text-light shrink-0" />
|
|
26
|
+
</button>
|
|
27
|
+
</Popover.Trigger>
|
|
28
|
+
<Popover.Content
|
|
29
|
+
className="p-0 w-auto"
|
|
30
|
+
align="center"
|
|
31
|
+
>
|
|
32
|
+
<Calendar {...props}/>
|
|
33
|
+
</Popover.Content>
|
|
34
|
+
</Popover>
|
|
35
|
+
)
|
|
41
36
|
}
|
|
37
|
+
|
|
38
|
+
export { DatePicker }
|
package/src/Datepicker/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DatePicker } from './DatePicker'
|
|
File without changes
|