@tecsinapse/cortex-react 1.13.0 → 1.13.1-beta.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/dist/cjs/components/DatePicker/DatePickerInput.js +3 -2
- package/dist/cjs/components/DatePicker/DateRangePickerInput.js +3 -2
- package/dist/cjs/components/ScrollableDigitSelector.js +57 -0
- package/dist/cjs/components/Select/CustomMultiOption.js +38 -0
- package/dist/cjs/components/Select/CustomOption.js +31 -0
- package/dist/cjs/components/Select/MultiCheckAllOptions.js +1 -1
- package/dist/cjs/components/Select/MultiGroupedOptions.js +2 -8
- package/dist/cjs/components/Select/MultiOption.js +3 -12
- package/dist/cjs/components/Select/MultiOptions.js +2 -3
- package/dist/cjs/components/Select/Options.js +15 -10
- package/dist/cjs/components/Select/index.js +5 -1
- package/dist/cjs/components/Select/useMultiSelectOption.js +29 -0
- package/dist/cjs/components/Select/utils.js +2 -2
- package/dist/cjs/components/TimePicker/TimeField.js +48 -0
- package/dist/cjs/components/TimePicker/TimeFieldInput.js +82 -0
- package/dist/cjs/components/TimePicker/TimePickerInput.js +78 -0
- package/dist/cjs/components/TimePicker/TimePickerSelector.js +118 -0
- package/dist/cjs/hooks/useTimePickerInput.js +45 -0
- package/dist/cjs/index.js +8 -2
- package/dist/cjs/styles/time-field-input.js +18 -0
- package/dist/cjs/utils/date.js +0 -5
- package/dist/esm/components/DatePicker/DatePickerInput.js +3 -2
- package/dist/esm/components/DatePicker/DateRangePickerInput.js +3 -2
- package/dist/esm/components/ScrollableDigitSelector.js +55 -0
- package/dist/esm/components/Select/CustomMultiOption.js +36 -0
- package/dist/esm/components/Select/CustomOption.js +29 -0
- package/dist/esm/components/Select/MultiCheckAllOptions.js +1 -1
- package/dist/esm/components/Select/MultiGroupedOptions.js +2 -8
- package/dist/esm/components/Select/MultiOption.js +4 -13
- package/dist/esm/components/Select/MultiOptions.js +2 -3
- package/dist/esm/components/Select/Options.js +16 -11
- package/dist/esm/components/Select/index.js +5 -1
- package/dist/esm/components/Select/useMultiSelectOption.js +27 -0
- package/dist/esm/components/Select/utils.js +2 -2
- package/dist/esm/components/TimePicker/TimeField.js +46 -0
- package/dist/esm/components/TimePicker/TimeFieldInput.js +80 -0
- package/dist/esm/components/TimePicker/TimePickerInput.js +76 -0
- package/dist/esm/components/TimePicker/TimePickerSelector.js +116 -0
- package/dist/esm/hooks/useTimePickerInput.js +43 -0
- package/dist/esm/index.js +5 -2
- package/dist/esm/styles/time-field-input.js +16 -0
- package/dist/esm/utils/date.js +2 -6
- package/dist/types/components/ScrollableDigitSelector.d.ts +10 -0
- package/dist/types/components/Select/CustomMultiOption.d.ts +3 -0
- package/dist/types/components/Select/CustomOption.d.ts +3 -0
- package/dist/types/components/Select/MultiOption.d.ts +1 -1
- package/dist/types/components/Select/Options.d.ts +1 -1
- package/dist/types/components/Select/context.d.ts +1 -1
- package/dist/types/components/Select/index.d.ts +4 -2
- package/dist/types/components/Select/types.d.ts +10 -3
- package/dist/types/components/Select/useMultiSelectOption.d.ts +8 -0
- package/dist/types/components/Select/utils.d.ts +1 -1
- package/dist/types/components/{TimeField → TimePicker}/TimeField.d.ts +2 -1
- package/dist/types/components/TimePicker/TimeFieldInput.d.ts +14 -0
- package/dist/types/components/TimePicker/TimePickerInput.d.ts +15 -0
- package/dist/types/components/TimePicker/TimePickerSelector.d.ts +14 -0
- package/dist/types/components/TimePicker/index.d.ts +4 -0
- package/dist/types/components/index.d.ts +1 -1
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useTimePickerInput.d.ts +14 -0
- package/dist/types/styles/time-field-input.d.ts +25 -0
- package/package.json +2 -2
- package/dist/cjs/components/TimeField/TimeField.js +0 -24
- package/dist/cjs/components/TimeField/TimeFieldInput.js +0 -42
- package/dist/esm/components/TimeField/TimeField.js +0 -22
- package/dist/esm/components/TimeField/TimeFieldInput.js +0 -40
- package/dist/types/components/TimeField/TimeFieldInput.d.ts +0 -11
- package/dist/types/components/TimeField/index.d.ts +0 -2
- /package/dist/cjs/components/{DatePicker/Content.js → Content.js} +0 -0
- /package/dist/esm/components/{DatePicker/Content.js → Content.js} +0 -0
- /package/dist/types/components/{DatePicker/Content.d.ts → Content.d.ts} +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { labelStyle, inputBox } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React__default, { useMemo } from 'react';
|
|
3
|
+
import { Input } from '../Input/index.js';
|
|
4
|
+
import { LiaClock } from 'react-icons/lia';
|
|
5
|
+
import { timePickerInputBase } from '../../styles/time-field-input.js';
|
|
6
|
+
import { IoMdClose } from 'react-icons/io';
|
|
7
|
+
import { TimeField } from './TimeField.js';
|
|
8
|
+
|
|
9
|
+
const { icon } = timePickerInputBase();
|
|
10
|
+
const TimeFieldInput = ({
|
|
11
|
+
variants,
|
|
12
|
+
label,
|
|
13
|
+
disabled = false,
|
|
14
|
+
value,
|
|
15
|
+
onChange,
|
|
16
|
+
onToggle,
|
|
17
|
+
onClean,
|
|
18
|
+
hourCycle,
|
|
19
|
+
granularity
|
|
20
|
+
}) => {
|
|
21
|
+
const showCloseIcon = useMemo(() => {
|
|
22
|
+
const hasTime = value != void 0;
|
|
23
|
+
return hasTime;
|
|
24
|
+
}, [value]);
|
|
25
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
26
|
+
Input.Face,
|
|
27
|
+
{
|
|
28
|
+
variants,
|
|
29
|
+
className: "flex flex-row justify-between",
|
|
30
|
+
"data-testid": "time-field-input"
|
|
31
|
+
},
|
|
32
|
+
/* @__PURE__ */ React__default.createElement("span", { className: labelStyle({}) }, label),
|
|
33
|
+
/* @__PURE__ */ React__default.createElement("div", { className: inputBox("", label) }, /* @__PURE__ */ React__default.createElement(
|
|
34
|
+
TimeField,
|
|
35
|
+
{
|
|
36
|
+
onClickTime: onToggle,
|
|
37
|
+
disabled,
|
|
38
|
+
value,
|
|
39
|
+
onChange,
|
|
40
|
+
hourCycle,
|
|
41
|
+
granularity
|
|
42
|
+
}
|
|
43
|
+
)),
|
|
44
|
+
/* @__PURE__ */ React__default.createElement(Input.Right, { className: "h-full justify-center" }, showCloseIcon ? /* @__PURE__ */ React__default.createElement(
|
|
45
|
+
"button",
|
|
46
|
+
{
|
|
47
|
+
className: "flex bg-transparent items-center",
|
|
48
|
+
onClick: onClean,
|
|
49
|
+
disabled,
|
|
50
|
+
"data-testid": "time-picker-input-base-clean-button",
|
|
51
|
+
type: "button"
|
|
52
|
+
},
|
|
53
|
+
/* @__PURE__ */ React__default.createElement(
|
|
54
|
+
IoMdClose,
|
|
55
|
+
{
|
|
56
|
+
className: icon({ disabled }),
|
|
57
|
+
"data-testid": "time-picker-input-base-clean-icon"
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
) : /* @__PURE__ */ React__default.createElement(
|
|
61
|
+
"button",
|
|
62
|
+
{
|
|
63
|
+
className: "flex bg-transparent items-center",
|
|
64
|
+
onClick: onToggle,
|
|
65
|
+
disabled,
|
|
66
|
+
"data-testid": "time-picker-input-base-calendar-button",
|
|
67
|
+
type: "button"
|
|
68
|
+
},
|
|
69
|
+
/* @__PURE__ */ React__default.createElement(
|
|
70
|
+
LiaClock,
|
|
71
|
+
{
|
|
72
|
+
className: icon({ disabled }),
|
|
73
|
+
"data-testid": "time-picker-input-base-calendar-icon"
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
))
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export { TimeFieldInput };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import '@internationalized/date';
|
|
3
|
+
import 'react-aria';
|
|
4
|
+
import 'react-stately';
|
|
5
|
+
import '../Popover/Context.js';
|
|
6
|
+
import 'react-dropzone';
|
|
7
|
+
import 'uuid';
|
|
8
|
+
import '@floating-ui/react';
|
|
9
|
+
import 'currency.js';
|
|
10
|
+
import { useTimePickerInput } from '../../hooks/useTimePickerInput.js';
|
|
11
|
+
import { Popover } from '../Popover/index.js';
|
|
12
|
+
import { Content } from '../Content.js';
|
|
13
|
+
import { TimeFieldInput } from './TimeFieldInput.js';
|
|
14
|
+
import { TimePickerSelector } from './TimePickerSelector.js';
|
|
15
|
+
|
|
16
|
+
const TimePickerInputWithPopover = (props) => {
|
|
17
|
+
const {
|
|
18
|
+
onChange,
|
|
19
|
+
value,
|
|
20
|
+
label,
|
|
21
|
+
variants,
|
|
22
|
+
hourCycle = 24,
|
|
23
|
+
disabled = false,
|
|
24
|
+
granularity = "minute",
|
|
25
|
+
minuteInterval = 1,
|
|
26
|
+
hourLabel,
|
|
27
|
+
minuteLabel,
|
|
28
|
+
dayPeriodLabel
|
|
29
|
+
} = props;
|
|
30
|
+
const {
|
|
31
|
+
handleTogglePopover,
|
|
32
|
+
handleTimeFieldChange,
|
|
33
|
+
handleChangeTimeOnSelector,
|
|
34
|
+
popoverTime
|
|
35
|
+
} = useTimePickerInput({
|
|
36
|
+
value,
|
|
37
|
+
onChange,
|
|
38
|
+
minuteInterval
|
|
39
|
+
});
|
|
40
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(Popover.Trigger, { disabled: true }, /* @__PURE__ */ React__default.createElement(
|
|
41
|
+
TimeFieldInput,
|
|
42
|
+
{
|
|
43
|
+
variants,
|
|
44
|
+
label,
|
|
45
|
+
disabled,
|
|
46
|
+
value,
|
|
47
|
+
onChange: handleTimeFieldChange,
|
|
48
|
+
onClean: () => handleTimeFieldChange(null),
|
|
49
|
+
onToggle: handleTogglePopover,
|
|
50
|
+
hourCycle,
|
|
51
|
+
granularity
|
|
52
|
+
}
|
|
53
|
+
)), /* @__PURE__ */ React__default.createElement(
|
|
54
|
+
Popover.Content,
|
|
55
|
+
{
|
|
56
|
+
className: "bg-white shadow-lg border-none p-deca flex flex-col",
|
|
57
|
+
initialFocus: -1
|
|
58
|
+
},
|
|
59
|
+
/* @__PURE__ */ React__default.createElement(
|
|
60
|
+
TimePickerSelector,
|
|
61
|
+
{
|
|
62
|
+
onChangeTime: handleChangeTimeOnSelector,
|
|
63
|
+
value: popoverTime,
|
|
64
|
+
hourCycle,
|
|
65
|
+
minuteInterval,
|
|
66
|
+
onPressOkButton: handleTogglePopover,
|
|
67
|
+
hourLabel,
|
|
68
|
+
minuteLabel,
|
|
69
|
+
dayPeriodLabel
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
));
|
|
73
|
+
};
|
|
74
|
+
const TimePickerInput = (props) => /* @__PURE__ */ React__default.createElement(Popover.Root, { placement: "bottom-start", trigger: "click" }, /* @__PURE__ */ React__default.createElement(Content, null, /* @__PURE__ */ React__default.createElement(TimePickerInputWithPopover, { ...props })));
|
|
75
|
+
|
|
76
|
+
export { TimePickerInput };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Time } from '@internationalized/date';
|
|
2
|
+
import React__default, { useMemo } from 'react';
|
|
3
|
+
import { ScrollableDigitSelector } from '../ScrollableDigitSelector.js';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { Button } from '../Button.js';
|
|
6
|
+
import { MdClose } from 'react-icons/md';
|
|
7
|
+
|
|
8
|
+
const dayPeriodStyle = "p-micro rounded-micro border-1 border-transparent hover:bg-primary-light hover:border-primary cursor-pointer";
|
|
9
|
+
const TimePickerSelector = ({
|
|
10
|
+
value,
|
|
11
|
+
hourCycle,
|
|
12
|
+
minuteInterval,
|
|
13
|
+
onPressOkButton,
|
|
14
|
+
onChangeTime,
|
|
15
|
+
hourLabel = "Hour",
|
|
16
|
+
minuteLabel = "Minute",
|
|
17
|
+
dayPeriodLabel = "Day Period"
|
|
18
|
+
}) => {
|
|
19
|
+
const handleHourChange = (hour) => {
|
|
20
|
+
let newHour = hour;
|
|
21
|
+
if (hourCycle === 12) {
|
|
22
|
+
if (isPM && newHour < 12) {
|
|
23
|
+
newHour += 12;
|
|
24
|
+
} else if (!isPM && newHour >= 12) {
|
|
25
|
+
newHour -= 12;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const newTime = new Time(newHour, value.minute, value.second);
|
|
29
|
+
onChangeTime(newTime);
|
|
30
|
+
};
|
|
31
|
+
const handleMinuteChange = (minute) => {
|
|
32
|
+
const newTime = new Time(value.hour, minute, value.second);
|
|
33
|
+
onChangeTime(newTime);
|
|
34
|
+
};
|
|
35
|
+
const handlePeriodChange = (isPM2) => {
|
|
36
|
+
if (value === void 0) return;
|
|
37
|
+
let newHour = value.hour;
|
|
38
|
+
if (hourCycle === 12) {
|
|
39
|
+
if (isPM2 && newHour < 12) {
|
|
40
|
+
newHour += 12;
|
|
41
|
+
} else if (!isPM2 && newHour >= 12) {
|
|
42
|
+
newHour -= 12;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const newTime = new Time(newHour, value.minute, value.second);
|
|
46
|
+
onChangeTime(newTime);
|
|
47
|
+
};
|
|
48
|
+
const isPM = value && value?.hour >= 12;
|
|
49
|
+
const displayHour = useMemo(() => {
|
|
50
|
+
if (value === void 0) return 0;
|
|
51
|
+
return hourCycle === 12 ? value.hour === 0 ? 12 : value.hour > 12 ? value.hour - 12 : value.hour : value.hour;
|
|
52
|
+
}, [value, hourCycle]);
|
|
53
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: "flex justify-end" }, /* @__PURE__ */ React__default.createElement(
|
|
54
|
+
Button,
|
|
55
|
+
{
|
|
56
|
+
className: "p-micro",
|
|
57
|
+
variants: {
|
|
58
|
+
size: "circle",
|
|
59
|
+
variant: "outline"
|
|
60
|
+
},
|
|
61
|
+
onClick: onPressOkButton
|
|
62
|
+
},
|
|
63
|
+
/* @__PURE__ */ React__default.createElement(MdClose, null)
|
|
64
|
+
)), /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-row gap-x-deca max-h-[300px] overflow-hidden" }, /* @__PURE__ */ React__default.createElement("div", { className: "min-w-7 flex flex-col gap-y-micro p-micro" }, /* @__PURE__ */ React__default.createElement("span", { className: "text-base font-bold text-center" }, hourLabel), /* @__PURE__ */ React__default.createElement(
|
|
65
|
+
ScrollableDigitSelector,
|
|
66
|
+
{
|
|
67
|
+
value: displayHour,
|
|
68
|
+
onChange: handleHourChange,
|
|
69
|
+
min: hourCycle === 12 ? 1 : 0,
|
|
70
|
+
max: hourCycle === 12 ? 12 : 23
|
|
71
|
+
}
|
|
72
|
+
)), /* @__PURE__ */ React__default.createElement("div", { className: "min-w-7 flex flex-col gap-y-micro p-micro" }, /* @__PURE__ */ React__default.createElement("span", { className: "text-base font-bold text-center" }, minuteLabel), /* @__PURE__ */ React__default.createElement(
|
|
73
|
+
ScrollableDigitSelector,
|
|
74
|
+
{
|
|
75
|
+
value: value?.minute ?? 0,
|
|
76
|
+
onChange: handleMinuteChange,
|
|
77
|
+
min: 0,
|
|
78
|
+
max: 59,
|
|
79
|
+
step: minuteInterval
|
|
80
|
+
}
|
|
81
|
+
)), hourCycle === 12 && /* @__PURE__ */ React__default.createElement("div", { className: "min-w-7 flex flex-col gap-y-micro p-micro" }, /* @__PURE__ */ React__default.createElement("span", { className: "text-base font-bold text-center" }, dayPeriodLabel), /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col gap-y-micro p-micro overflow-auto" }, /* @__PURE__ */ React__default.createElement(
|
|
82
|
+
"div",
|
|
83
|
+
{
|
|
84
|
+
onClick: () => handlePeriodChange(false),
|
|
85
|
+
className: "flex justify-center"
|
|
86
|
+
},
|
|
87
|
+
/* @__PURE__ */ React__default.createElement(
|
|
88
|
+
"span",
|
|
89
|
+
{
|
|
90
|
+
className: clsx(
|
|
91
|
+
dayPeriodStyle,
|
|
92
|
+
!isPM && "bg-primary-medium text-white"
|
|
93
|
+
)
|
|
94
|
+
},
|
|
95
|
+
"AM"
|
|
96
|
+
)
|
|
97
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
98
|
+
"div",
|
|
99
|
+
{
|
|
100
|
+
onClick: () => handlePeriodChange(true),
|
|
101
|
+
className: "flex justify-center"
|
|
102
|
+
},
|
|
103
|
+
/* @__PURE__ */ React__default.createElement(
|
|
104
|
+
"span",
|
|
105
|
+
{
|
|
106
|
+
className: clsx(
|
|
107
|
+
dayPeriodStyle,
|
|
108
|
+
isPM && "bg-primary-medium text-white"
|
|
109
|
+
)
|
|
110
|
+
},
|
|
111
|
+
"PM"
|
|
112
|
+
)
|
|
113
|
+
)))));
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export { TimePickerSelector };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { usePopoverContext } from '../components/Popover/Context.js';
|
|
3
|
+
import { Time } from '@internationalized/date';
|
|
4
|
+
|
|
5
|
+
const useTimePickerInput = ({
|
|
6
|
+
value,
|
|
7
|
+
onChange,
|
|
8
|
+
minuteInterval
|
|
9
|
+
}) => {
|
|
10
|
+
const { setIsOpen } = usePopoverContext();
|
|
11
|
+
const [popoverTime, setPopoverTime] = useState(value ?? new Time(0, 0));
|
|
12
|
+
const handleTimeFieldChange = (newValue) => {
|
|
13
|
+
if (newValue && minuteInterval > 1) {
|
|
14
|
+
const time = newValue;
|
|
15
|
+
const adjustedMinute = Math.round(time.minute / minuteInterval) * minuteInterval % 60;
|
|
16
|
+
const adjustedTime = time.set({ minute: adjustedMinute });
|
|
17
|
+
onChange?.(adjustedTime);
|
|
18
|
+
setPopoverTime(adjustedTime);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const newTime = newValue ? new Time(newValue.hour, newValue.minute, newValue.second) : void 0;
|
|
22
|
+
onChange?.(newTime);
|
|
23
|
+
setPopoverTime(newTime ?? new Time(0, 0));
|
|
24
|
+
};
|
|
25
|
+
const handleTogglePopover = useCallback(() => {
|
|
26
|
+
setIsOpen((open) => !open);
|
|
27
|
+
}, []);
|
|
28
|
+
const handleChangeTimeOnSelector = useCallback(
|
|
29
|
+
(time) => {
|
|
30
|
+
setPopoverTime(time);
|
|
31
|
+
handleTimeFieldChange(time);
|
|
32
|
+
},
|
|
33
|
+
[handleTimeFieldChange]
|
|
34
|
+
);
|
|
35
|
+
return {
|
|
36
|
+
handleTogglePopover,
|
|
37
|
+
handleTimeFieldChange,
|
|
38
|
+
handleChangeTimeOnSelector,
|
|
39
|
+
popoverTime
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { useTimePickerInput };
|
package/dist/esm/index.js
CHANGED
|
@@ -35,8 +35,10 @@ export { Stepper } from './components/Stepper/index.js';
|
|
|
35
35
|
export { TCell, TFoot, THead, THeadCell, TRow, TRowHeader, Table, Td } from './components/Table.js';
|
|
36
36
|
export { Tag } from './components/Tag.js';
|
|
37
37
|
export { TextArea } from './components/TextArea/index.js';
|
|
38
|
-
export { TimeField } from './components/
|
|
39
|
-
export {
|
|
38
|
+
export { TimeField } from './components/TimePicker/TimeField.js';
|
|
39
|
+
export { TimePickerInput } from './components/TimePicker/TimePickerInput.js';
|
|
40
|
+
export { TimePickerSelector } from './components/TimePicker/TimePickerSelector.js';
|
|
41
|
+
export { TimeFieldInput } from './components/TimePicker/TimeFieldInput.js';
|
|
40
42
|
export { Toggle } from './components/Toggle.js';
|
|
41
43
|
export { Tooltip } from './components/Tooltip.js';
|
|
42
44
|
export { Uploader } from './components/Uploader/index.js';
|
|
@@ -56,6 +58,7 @@ export { useRangeCalendar } from './hooks/useRangeCalendar.js';
|
|
|
56
58
|
export { useSelectGroupedOptions } from './hooks/useSelectGroupedOptions.js';
|
|
57
59
|
export { useSelectOptions } from './hooks/useSelectOptions.js';
|
|
58
60
|
export { applyStringMask, getMask, mergeMask, useStringMask } from './hooks/useStringMask.js';
|
|
61
|
+
export { useTimePickerInput } from './hooks/useTimePickerInput.js';
|
|
59
62
|
export { SnackbarSonner } from './service/SnackbarSonner.js';
|
|
60
63
|
export { MenubarProvider } from './provider/MenubarProvider.js';
|
|
61
64
|
export { SnackbarProvider, useSnackbar } from './provider/SnackbarProvider.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
|
|
3
|
+
const timePickerInputBase = tv({
|
|
4
|
+
slots: {
|
|
5
|
+
icon: "cursor-pointer text-deca"
|
|
6
|
+
},
|
|
7
|
+
variants: {
|
|
8
|
+
disabled: {
|
|
9
|
+
true: {
|
|
10
|
+
icon: "text-secondary-light cursor-default"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { timePickerInputBase };
|
package/dist/esm/utils/date.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CalendarDateTime, getLocalTimeZone
|
|
1
|
+
import { CalendarDateTime, getLocalTimeZone } from '@internationalized/date';
|
|
2
2
|
|
|
3
3
|
const dateToCalendarDateTime = (value) => {
|
|
4
4
|
return new CalendarDateTime(
|
|
@@ -14,9 +14,5 @@ const calendarDateToDate = (value) => {
|
|
|
14
14
|
if (!value) return void 0;
|
|
15
15
|
return value.toDate(getLocalTimeZone());
|
|
16
16
|
};
|
|
17
|
-
const timeFromTimeValue = (value) => {
|
|
18
|
-
if (!value) return void 0;
|
|
19
|
-
return new Time(value.hour, value.minute, value.second, value.millisecond);
|
|
20
|
-
};
|
|
21
17
|
|
|
22
|
-
export { calendarDateToDate, dateToCalendarDateTime
|
|
18
|
+
export { calendarDateToDate, dateToCalendarDateTime };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ScrollableDigitSelectorProps {
|
|
3
|
+
value: number;
|
|
4
|
+
onChange: (value: number) => void;
|
|
5
|
+
min: number;
|
|
6
|
+
max: number;
|
|
7
|
+
step?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const ScrollableDigitSelector: ({ value, onChange, min, max, step, }: ScrollableDigitSelectorProps) => React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SelectMultiOptionProps } from './types';
|
|
3
|
-
export declare const SelectMultiOption: <T>({
|
|
3
|
+
export declare const SelectMultiOption: <T>({ onSelect, option, grouped, }: SelectMultiOptionProps<T>) => React.JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SelectOptionsProps } from './types';
|
|
3
|
-
export declare const SelectOptions: <T>({ onSelect, options, }: SelectOptionsProps<T>) => React.JSX.Element;
|
|
3
|
+
export declare const SelectOptions: <T>({ onSelect, options, children, }: SelectOptionsProps<T>) => React.JSX.Element;
|
|
@@ -8,7 +8,7 @@ interface SelectContextProps<T> {
|
|
|
8
8
|
export declare const SelectContext: import("react").Context<SelectContextProps<any>>;
|
|
9
9
|
interface SelectMultiOptionsContextProps<T> {
|
|
10
10
|
options?: T[];
|
|
11
|
-
onSelect
|
|
11
|
+
onSelect?: (value: T[]) => void;
|
|
12
12
|
}
|
|
13
13
|
export declare const SelectMultiOptionsContext: import("react").Context<SelectMultiOptionsContextProps<any>>;
|
|
14
14
|
export {};
|
|
@@ -2,12 +2,14 @@ export declare const Select: {
|
|
|
2
2
|
Root: <T>({ children, value, keyExtractor, labelExtractor, className, }: import("./types").SelectRootProps<T>) => import("react").JSX.Element;
|
|
3
3
|
Trigger: ({ label, placeholder, disabled, multiLabelSelected, ...rest }: import("./types").SelectTriggerProps) => import("react").JSX.Element;
|
|
4
4
|
Popover: ({ children }: import("./types").SelectPopoverProps) => import("react").JSX.Element;
|
|
5
|
-
Options: <T>({ onSelect, options, }: import("./types").SelectOptionsProps<T>) => import("react").JSX.Element;
|
|
5
|
+
Options: <T>({ onSelect, options, children, }: import("./types").SelectOptionsProps<T>) => import("react").JSX.Element;
|
|
6
6
|
GroupedOptions: <T>({ onSelect, groupedLabelExtractor, options, }: import("./types").SelectGroupedOptionsProps<T>) => import("react").JSX.Element;
|
|
7
7
|
Option: <T>({ onSelectOption, option, grouped, }: import("./types").SelectOptionProps<T>) => import("react").JSX.Element;
|
|
8
8
|
MultiOptions: <T>({ onSelect, options, children, }: import("./types").SelectMultiOptionsProps<T>) => import("react").JSX.Element;
|
|
9
9
|
MultiGroupedOptions: <T>({ onSelect, groupedLabelExtractor, options, children, }: import("./types").SelectMultiGroupedOptionsProps<T>) => import("react").JSX.Element;
|
|
10
|
-
MultiOption: <T>({
|
|
10
|
+
MultiOption: <T>({ onSelect, option, grouped, }: import("./types").SelectMultiOptionProps<T>) => import("react").JSX.Element;
|
|
11
11
|
MultiCheckAllOptions: <T>({ checkAllLabel, }: import("./types").SelectMultiCheckAllOptionsProps) => import("react").JSX.Element;
|
|
12
|
+
CustomOption: <T>({ option, onSelectOption, grouped, children, }: import("./types").CustomOptionProps<T>) => import("react").JSX.Element;
|
|
13
|
+
CustomMultiOption: <T>({ onSelect, option, grouped, children, }: import("./types").CustomMultiOptionProps<T>) => import("react").JSX.Element;
|
|
12
14
|
};
|
|
13
15
|
export * from './types';
|
|
@@ -19,12 +19,15 @@ export interface SelectMultiGroupedOptionsProps<T> {
|
|
|
19
19
|
}
|
|
20
20
|
export interface SelectMultiOptionProps<T> {
|
|
21
21
|
option: T;
|
|
22
|
-
|
|
22
|
+
onSelect?: (option: T[]) => void;
|
|
23
23
|
grouped?: boolean;
|
|
24
24
|
}
|
|
25
|
+
export interface CustomMultiOptionProps<T> extends SelectMultiOptionProps<T> {
|
|
26
|
+
children?: ReactNode;
|
|
27
|
+
}
|
|
25
28
|
export interface SelectMultiOptionsProps<T> {
|
|
26
29
|
options?: T[] | (() => Promise<T[]>);
|
|
27
|
-
onSelect
|
|
30
|
+
onSelect?: (value: T[]) => void;
|
|
28
31
|
children?: React.ReactNode;
|
|
29
32
|
}
|
|
30
33
|
export interface SelectOptionProps<T> {
|
|
@@ -32,9 +35,13 @@ export interface SelectOptionProps<T> {
|
|
|
32
35
|
onSelectOption: (option: T) => void;
|
|
33
36
|
grouped?: boolean;
|
|
34
37
|
}
|
|
38
|
+
export interface CustomOptionProps<T> extends SelectOptionProps<T> {
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
}
|
|
35
41
|
export interface SelectOptionsProps<T> {
|
|
36
42
|
options?: T[] | (() => Promise<T[]>);
|
|
37
|
-
onSelect
|
|
43
|
+
onSelect?: (value: T) => void;
|
|
44
|
+
children?: ReactNode;
|
|
38
45
|
}
|
|
39
46
|
export interface SelectPopoverProps {
|
|
40
47
|
children: ReactNode;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const useMultiSelectOption: <T>(option: T, onSelect?: (option: T[]) => void) => {
|
|
2
|
+
keyExtractor: (value: any) => string;
|
|
3
|
+
value: any;
|
|
4
|
+
isChecked: boolean;
|
|
5
|
+
onClickOption: () => void;
|
|
6
|
+
inputRef: import("react").RefObject<HTMLInputElement>;
|
|
7
|
+
labelExtractor: (value: any) => string;
|
|
8
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const handleSelectMulti: <T>(option: T, value: T[],
|
|
1
|
+
export declare const handleSelectMulti: <T>(option: T, value: T[], keyExtractor: (value: T) => string, onSelect?: (value: T[]) => void) => void;
|
|
@@ -2,5 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { AriaTimeFieldProps, TimeValue } from 'react-aria';
|
|
3
3
|
export interface TimeFieldProps extends AriaTimeFieldProps<TimeValue> {
|
|
4
4
|
disabled?: boolean;
|
|
5
|
+
onClickTime?: () => void;
|
|
5
6
|
}
|
|
6
|
-
export declare const TimeField: ({
|
|
7
|
+
export declare const TimeField: ({ onClickTime, ...props }: TimeFieldProps) => React.JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputProps } from '../Input';
|
|
3
|
+
import { TimeValue } from 'react-aria';
|
|
4
|
+
interface TimePickerInputBaseProps extends Omit<InputProps, 'value' | 'onChange'> {
|
|
5
|
+
value?: TimeValue;
|
|
6
|
+
onChange: (value: TimeValue | null) => void;
|
|
7
|
+
onClean?: () => void;
|
|
8
|
+
onToggle?: () => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
hourCycle?: 12 | 24;
|
|
11
|
+
granularity?: 'hour' | 'minute' | 'second';
|
|
12
|
+
}
|
|
13
|
+
export declare const TimeFieldInput: ({ variants, label, disabled, value, onChange, onToggle, onClean, hourCycle, granularity, }: TimePickerInputBaseProps) => React.JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Time } from '@internationalized/date';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { InputProps } from '../Input';
|
|
4
|
+
export interface TimePickerInputProps extends Omit<InputProps, 'value' | 'onChange'> {
|
|
5
|
+
value?: Time;
|
|
6
|
+
onChange: (value?: Time) => void;
|
|
7
|
+
hourCycle?: 12 | 24;
|
|
8
|
+
granularity?: 'hour' | 'minute' | 'second';
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
minuteInterval?: number;
|
|
11
|
+
hourLabel?: string;
|
|
12
|
+
minuteLabel?: string;
|
|
13
|
+
dayPeriodLabel?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const TimePickerInput: (props: TimePickerInputProps) => React.JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Time } from '@internationalized/date';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface TimePickerSelectorProps {
|
|
4
|
+
value: Time;
|
|
5
|
+
hourCycle: 12 | 24;
|
|
6
|
+
minuteInterval: number;
|
|
7
|
+
onPressOkButton: () => void;
|
|
8
|
+
onChangeTime: (time: Time) => void;
|
|
9
|
+
hourLabel?: string;
|
|
10
|
+
minuteLabel?: string;
|
|
11
|
+
dayPeriodLabel?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const TimePickerSelector: ({ value, hourCycle, minuteInterval, onPressOkButton, onChangeTime, hourLabel, minuteLabel, dayPeriodLabel, }: TimePickerSelectorProps) => React.JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -28,7 +28,7 @@ export * from './Stepper';
|
|
|
28
28
|
export * from './Table';
|
|
29
29
|
export * from './Tag';
|
|
30
30
|
export * from './TextArea';
|
|
31
|
-
export * from './
|
|
31
|
+
export * from './TimePicker';
|
|
32
32
|
export * from './Toggle';
|
|
33
33
|
export * from './Tooltip';
|
|
34
34
|
export * from './Uploader';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Time } from '@internationalized/date';
|
|
2
|
+
import { TimeValue } from 'react-aria';
|
|
3
|
+
interface useTimePickerInputProps {
|
|
4
|
+
value?: Time;
|
|
5
|
+
onChange?: (value?: Time) => void;
|
|
6
|
+
minuteInterval: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const useTimePickerInput: ({ value, onChange, minuteInterval, }: useTimePickerInputProps) => {
|
|
9
|
+
handleTogglePopover: () => void;
|
|
10
|
+
handleTimeFieldChange: (newValue: TimeValue | null) => void;
|
|
11
|
+
handleChangeTimeOnSelector: (time: Time) => void;
|
|
12
|
+
popoverTime: Time;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const timePickerInputBase: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
disabled: {
|
|
3
|
+
true: {
|
|
4
|
+
icon: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
}, {
|
|
8
|
+
icon: string;
|
|
9
|
+
}, undefined, {
|
|
10
|
+
disabled: {
|
|
11
|
+
true: {
|
|
12
|
+
icon: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}, {
|
|
16
|
+
icon: string;
|
|
17
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
18
|
+
disabled: {
|
|
19
|
+
true: {
|
|
20
|
+
icon: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}, {
|
|
24
|
+
icon: string;
|
|
25
|
+
}, undefined, unknown, unknown, undefined>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.1-beta.1",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"react-icons": ">=5.2.0",
|
|
48
48
|
"tailwind": ">=3.3.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "7481b077fea291e92cdf8389d7fd5c7a8ef703be"
|
|
51
51
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var reactAria = require('react-aria');
|
|
5
|
-
var reactStately = require('react-stately');
|
|
6
|
-
var DateSegment = require('../DatePicker/DateSegment.js');
|
|
7
|
-
|
|
8
|
-
const TimeField = ({ disabled, ...props }) => {
|
|
9
|
-
const { locale } = reactAria.useLocale();
|
|
10
|
-
const state = reactStately.useTimeFieldState({
|
|
11
|
-
...props,
|
|
12
|
-
locale,
|
|
13
|
-
isDisabled: disabled
|
|
14
|
-
});
|
|
15
|
-
const ref = React.useRef(null);
|
|
16
|
-
const { fieldProps } = reactAria.useTimeField(
|
|
17
|
-
{ "aria-label": "time-field" },
|
|
18
|
-
state,
|
|
19
|
-
ref
|
|
20
|
-
);
|
|
21
|
-
return /* @__PURE__ */ React.createElement("div", { ...fieldProps, ref, className: "flex flex-row" }, state.segments.map((segment, i) => /* @__PURE__ */ React.createElement(DateSegment.DateSegment, { key: i, segment, state })));
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
exports.TimeField = TimeField;
|