@tecsinapse/cortex-react 1.3.0-beta.0 → 1.3.0-beta.2
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/Calendar.js +1 -0
- package/dist/cjs/components/DateField.js +25 -0
- package/dist/cjs/components/DatePickerInput.js +48 -0
- package/dist/cjs/components/DatePickerInputBase.js +24 -0
- package/dist/cjs/components/DateRangePickerInput.js +62 -0
- package/dist/cjs/components/DateSegment.js +9 -1
- package/dist/cjs/components/Input.js +16 -16
- package/dist/cjs/components/RangeCalendar.js +24 -32
- package/dist/cjs/components/Select/GroupedOptions.js +32 -0
- package/dist/cjs/components/Select/Option.js +25 -0
- package/dist/cjs/components/Select/Options.js +29 -0
- package/dist/cjs/components/Select/Popover.js +13 -0
- package/dist/cjs/components/Select/Root.js +31 -0
- package/dist/cjs/components/Select/Trigger.js +28 -0
- package/dist/cjs/components/Select/context.js +10 -0
- package/dist/cjs/components/Select/index.js +19 -0
- package/dist/cjs/components/Table.js +2 -2
- package/dist/cjs/components/utils.js +14 -0
- package/dist/cjs/hooks/useCalendar.js +3 -6
- package/dist/cjs/hooks/useDatePickerInput.js +31 -0
- package/dist/cjs/hooks/useDateRangePickerInput.js +33 -0
- package/dist/cjs/hooks/useOutsideClickListener.js +22 -0
- package/dist/cjs/hooks/useRangeCalendar.js +36 -0
- package/dist/cjs/index.js +33 -17
- package/dist/cjs/service/SnackbarSonner.js +10 -3
- package/dist/cjs/styles/calendar-cell.js +3 -3
- package/dist/esm/components/Calendar.js +1 -0
- package/dist/esm/components/DateField.js +23 -0
- package/dist/esm/components/DatePickerInput.js +46 -0
- package/dist/esm/components/DatePickerInputBase.js +22 -0
- package/dist/esm/components/DateRangePickerInput.js +60 -0
- package/dist/esm/components/DateSegment.js +9 -1
- package/dist/esm/components/Input.js +12 -12
- package/dist/esm/components/RangeCalendar.js +24 -32
- package/dist/esm/components/Select/GroupedOptions.js +30 -0
- package/dist/esm/components/Select/Option.js +23 -0
- package/dist/esm/components/Select/Options.js +27 -0
- package/dist/esm/components/Select/Popover.js +11 -0
- package/dist/esm/components/Select/Root.js +29 -0
- package/dist/esm/components/Select/Trigger.js +26 -0
- package/dist/esm/components/Select/context.js +8 -0
- package/dist/esm/components/Select/index.js +17 -0
- package/dist/esm/components/Table.js +2 -2
- package/dist/esm/components/utils.js +13 -1
- package/dist/esm/hooks/useCalendar.js +4 -7
- package/dist/esm/hooks/useDatePickerInput.js +29 -0
- package/dist/esm/hooks/useDateRangePickerInput.js +31 -0
- package/dist/esm/hooks/useOutsideClickListener.js +20 -0
- package/dist/esm/hooks/useRangeCalendar.js +34 -0
- package/dist/esm/index.js +17 -7
- package/dist/esm/service/SnackbarSonner.js +10 -3
- package/dist/esm/styles/calendar-cell.js +3 -3
- package/dist/types/components/Calendar.d.ts +1 -1
- package/dist/types/components/DateField.d.ts +5 -0
- package/dist/types/components/DatePickerInput.d.ts +6 -0
- package/dist/types/components/DatePickerInputBase.d.ts +8 -0
- package/dist/types/components/DateRangePickerInput.d.ts +7 -0
- package/dist/types/components/Input.d.ts +5 -5
- package/dist/types/components/RangeCalendar.d.ts +1 -1
- package/dist/types/components/SearchInput.d.ts +3 -2
- package/dist/types/components/Select/GroupedOptions.d.ts +6 -0
- package/dist/types/components/Select/Option.d.ts +5 -0
- package/dist/types/components/Select/Options.d.ts +5 -0
- package/dist/types/components/Select/Popover.d.ts +5 -0
- package/dist/types/components/Select/Root.d.ts +8 -0
- package/dist/types/components/Select/Trigger.d.ts +5 -0
- package/dist/types/components/Select/context.d.ts +10 -0
- package/dist/types/components/Select/index.d.ts +8 -0
- package/dist/types/components/index.d.ts +5 -2
- package/dist/types/components/utils.d.ts +3 -0
- package/dist/types/hooks/index.d.ts +4 -0
- package/dist/types/hooks/useCalendar.d.ts +1 -1
- package/dist/types/hooks/useDatePickerInput.d.ts +10 -0
- package/dist/types/hooks/useDateRangePickerInput.d.ts +12 -0
- package/dist/types/hooks/useOutsideClickListener.d.ts +7 -0
- package/dist/types/hooks/useRangeCalendar.d.ts +12 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/tests/DateField.test.d.ts +1 -0
- package/dist/types/tests/DatePickerInput.test.d.ts +1 -0
- package/dist/types/tests/DatePickerInputBase.test.d.ts +1 -0
- package/dist/types/tests/DateRangePickerInput.test.d.ts +1 -0
- package/dist/types/tests/RangeCalendar.test.d.ts +1 -0
- package/dist/types/tests/useOutsideClickListener.test.d.ts +1 -0
- package/package.json +6 -4
- package/dist/cjs/components/SearchInput.js +0 -82
- package/dist/cjs/components/Select.js +0 -101
- package/dist/esm/components/SearchInput.js +0 -80
- package/dist/esm/components/Select.js +0 -96
- package/dist/types/components/Select.d.ts +0 -27
|
@@ -4,6 +4,7 @@ var React = require('react');
|
|
|
4
4
|
var useCalendar = require('../hooks/useCalendar.js');
|
|
5
5
|
require('@internationalized/date');
|
|
6
6
|
require('react-aria');
|
|
7
|
+
require('react-stately');
|
|
7
8
|
var CalendarGrid = require('./CalendarGrid.js');
|
|
8
9
|
var CalendarHeader = require('./CalendarHeader.js');
|
|
9
10
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var date = require('@internationalized/date');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactAria = require('react-aria');
|
|
6
|
+
var reactStately = require('react-stately');
|
|
7
|
+
var DateSegment = require('./DateSegment.js');
|
|
8
|
+
|
|
9
|
+
const DateField = (props) => {
|
|
10
|
+
const { locale } = reactAria.useLocale();
|
|
11
|
+
const state = reactStately.useDateFieldState({
|
|
12
|
+
...props,
|
|
13
|
+
createCalendar: date.createCalendar,
|
|
14
|
+
locale
|
|
15
|
+
});
|
|
16
|
+
const ref = React.useRef(null);
|
|
17
|
+
const { fieldProps } = reactAria.useDateField(
|
|
18
|
+
{ "aria-label": "date-field" },
|
|
19
|
+
state,
|
|
20
|
+
ref
|
|
21
|
+
);
|
|
22
|
+
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 })));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.DateField = DateField;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
require('@internationalized/date');
|
|
5
|
+
require('react-aria');
|
|
6
|
+
require('react-stately');
|
|
7
|
+
var utils = require('./utils.js');
|
|
8
|
+
var useDatePickerInput = require('../hooks/useDatePickerInput.js');
|
|
9
|
+
var Calendar = require('./Calendar.js');
|
|
10
|
+
var DateField = require('./DateField.js');
|
|
11
|
+
var DatePickerInputBase = require('./DatePickerInputBase.js');
|
|
12
|
+
|
|
13
|
+
const DatePickerInput = (props) => {
|
|
14
|
+
const { onChange, value, label, variants } = props;
|
|
15
|
+
const { fieldProps, state, ref } = useDatePickerInput.useDatePickerInput({ value, onChange });
|
|
16
|
+
return /* @__PURE__ */ React.createElement("div", { "data-testid": "date-picker-input" }, /* @__PURE__ */ React.createElement(
|
|
17
|
+
DatePickerInputBase.DatePickerInputBase,
|
|
18
|
+
{
|
|
19
|
+
onClickCalendar: () => state.isOpen ? state.close() : state.open(),
|
|
20
|
+
variants: {
|
|
21
|
+
...variants,
|
|
22
|
+
intent: state.isInvalid ? "error" : variants?.intent
|
|
23
|
+
},
|
|
24
|
+
label
|
|
25
|
+
},
|
|
26
|
+
/* @__PURE__ */ React.createElement("div", { ref }, /* @__PURE__ */ React.createElement(
|
|
27
|
+
DateField.DateField,
|
|
28
|
+
{
|
|
29
|
+
...fieldProps,
|
|
30
|
+
onChange: (value2) => {
|
|
31
|
+
state.setDateValue(value2);
|
|
32
|
+
state.close();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
))
|
|
36
|
+
), state.isOpen ? /* @__PURE__ */ React.createElement("div", { className: "absolute" }, /* @__PURE__ */ React.createElement(
|
|
37
|
+
Calendar.Calendar,
|
|
38
|
+
{
|
|
39
|
+
value,
|
|
40
|
+
onChange: (value2) => {
|
|
41
|
+
state.setDateValue(utils.dateToCalendarDate(value2));
|
|
42
|
+
state.close();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
)) : /* @__PURE__ */ React.createElement(React.Fragment, null));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.DatePickerInput = DatePickerInput;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var lia = require('react-icons/lia');
|
|
6
|
+
var Input = require('./Input.js');
|
|
7
|
+
|
|
8
|
+
const DatePickerInputBase = ({
|
|
9
|
+
children,
|
|
10
|
+
variants,
|
|
11
|
+
label,
|
|
12
|
+
onClickCalendar
|
|
13
|
+
}) => {
|
|
14
|
+
return /* @__PURE__ */ React.createElement(Input.Input.Face, { variants, "data-testid": "date-picker-input-base" }, /* @__PURE__ */ React.createElement("span", { className: cortexCore.labelStyle({}) }, label), /* @__PURE__ */ React.createElement("div", { className: cortexCore.inputBox("", label) }, children), /* @__PURE__ */ React.createElement(Input.Input.Right, { className: "" }, /* @__PURE__ */ React.createElement(
|
|
15
|
+
lia.LiaCalendar,
|
|
16
|
+
{
|
|
17
|
+
className: "cursor-pointer mt-centi",
|
|
18
|
+
onClick: onClickCalendar,
|
|
19
|
+
"data-testid": "date-picker-input-base-calendar"
|
|
20
|
+
}
|
|
21
|
+
)));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.DatePickerInputBase = DatePickerInputBase;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
require('@internationalized/date');
|
|
5
|
+
require('react-aria');
|
|
6
|
+
require('react-stately');
|
|
7
|
+
var utils = require('./utils.js');
|
|
8
|
+
var useDateRangePickerInput = require('../hooks/useDateRangePickerInput.js');
|
|
9
|
+
var DateField = require('./DateField.js');
|
|
10
|
+
var DatePickerInputBase = require('./DatePickerInputBase.js');
|
|
11
|
+
var RangeCalendar = require('./RangeCalendar.js');
|
|
12
|
+
|
|
13
|
+
const DateRangePickerInput = (props) => {
|
|
14
|
+
const { onChange, value, label, variants } = props;
|
|
15
|
+
const { endFieldProps, startFieldProps, ref, state } = useDateRangePickerInput.useDateRangePickerInput({ value, onChange });
|
|
16
|
+
return /* @__PURE__ */ React.createElement("div", { "data-testid": "date-range-picker-input" }, /* @__PURE__ */ React.createElement(
|
|
17
|
+
DatePickerInputBase.DatePickerInputBase,
|
|
18
|
+
{
|
|
19
|
+
onClickCalendar: () => state.isOpen ? state.close() : state.open(),
|
|
20
|
+
variants: {
|
|
21
|
+
...variants,
|
|
22
|
+
intent: state.isInvalid ? "error" : variants?.intent
|
|
23
|
+
},
|
|
24
|
+
label
|
|
25
|
+
},
|
|
26
|
+
/* @__PURE__ */ React.createElement("div", { ref, className: "flex flex-row gap-x-micro items-center" }, /* @__PURE__ */ React.createElement(
|
|
27
|
+
DateField.DateField,
|
|
28
|
+
{
|
|
29
|
+
...startFieldProps,
|
|
30
|
+
value: utils.dateToCalendarDate(value?.start),
|
|
31
|
+
onChange: (value2) => {
|
|
32
|
+
state.setDate("start", value2);
|
|
33
|
+
state.close();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
), /* @__PURE__ */ React.createElement("span", null, "-"), /* @__PURE__ */ React.createElement(
|
|
37
|
+
DateField.DateField,
|
|
38
|
+
{
|
|
39
|
+
...endFieldProps,
|
|
40
|
+
value: utils.dateToCalendarDate(value?.end),
|
|
41
|
+
onChange: (value2) => {
|
|
42
|
+
state.setDate("end", value2);
|
|
43
|
+
state.close();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
))
|
|
47
|
+
), state.isOpen ? /* @__PURE__ */ React.createElement("div", { className: "absolute" }, /* @__PURE__ */ React.createElement(
|
|
48
|
+
RangeCalendar.RangeCalendar,
|
|
49
|
+
{
|
|
50
|
+
value,
|
|
51
|
+
onChange: (value2) => {
|
|
52
|
+
state.setDateRange({
|
|
53
|
+
start: utils.dateToCalendarDate(value2.start),
|
|
54
|
+
end: utils.dateToCalendarDate(value2.end)
|
|
55
|
+
});
|
|
56
|
+
state.close();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
)) : /* @__PURE__ */ React.createElement(React.Fragment, null));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
exports.DateRangePickerInput = DateRangePickerInput;
|
|
@@ -6,7 +6,15 @@ var reactAria = require('react-aria');
|
|
|
6
6
|
const DateSegment = ({ segment, state }) => {
|
|
7
7
|
const ref = React.useRef(null);
|
|
8
8
|
const { segmentProps } = reactAria.useDateSegment(segment, state, ref);
|
|
9
|
-
return /* @__PURE__ */ React.createElement(
|
|
9
|
+
return /* @__PURE__ */ React.createElement(
|
|
10
|
+
"div",
|
|
11
|
+
{
|
|
12
|
+
...segmentProps,
|
|
13
|
+
ref,
|
|
14
|
+
className: "focus:outline-none focus:bg-secondary-light"
|
|
15
|
+
},
|
|
16
|
+
segment.text
|
|
17
|
+
);
|
|
10
18
|
};
|
|
11
19
|
|
|
12
20
|
exports.DateSegment = DateSegment;
|
|
@@ -9,7 +9,7 @@ const getValidChildren = (children) => {
|
|
|
9
9
|
(el) => React.isValidElement(el)
|
|
10
10
|
);
|
|
11
11
|
};
|
|
12
|
-
const
|
|
12
|
+
const InputBox = React.forwardRef(
|
|
13
13
|
({ id, name, variants, label, placeholder, className, ...rest }, ref) => {
|
|
14
14
|
return /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-col" }, /* @__PURE__ */ React.createElement(
|
|
15
15
|
"input",
|
|
@@ -33,7 +33,7 @@ const Box = React.forwardRef(
|
|
|
33
33
|
));
|
|
34
34
|
}
|
|
35
35
|
);
|
|
36
|
-
const
|
|
36
|
+
const InputFace = React.forwardRef(
|
|
37
37
|
({ children, variants, className, ...rest }, ref) => {
|
|
38
38
|
const clones = getValidChildren(children).map((el) => {
|
|
39
39
|
return React.cloneElement(el, { ...el.props, variants });
|
|
@@ -50,32 +50,32 @@ const Face = React.forwardRef(
|
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
);
|
|
53
|
-
const
|
|
53
|
+
const InputRoot = React.forwardRef(
|
|
54
54
|
({ variants, className, ...rest }, ref) => {
|
|
55
|
-
return /* @__PURE__ */ React.createElement(
|
|
55
|
+
return /* @__PURE__ */ React.createElement(InputFace, { variants, className }, /* @__PURE__ */ React.createElement(InputBox, { ...rest, ref }));
|
|
56
56
|
}
|
|
57
57
|
);
|
|
58
|
-
const
|
|
58
|
+
const InputLeft = React.forwardRef(
|
|
59
59
|
({ children, className, ...rest }, ref) => {
|
|
60
60
|
return /* @__PURE__ */ React.createElement("div", { className: clsx.clsx(className, "mr-2.5"), ...rest, ref }, children);
|
|
61
61
|
}
|
|
62
62
|
);
|
|
63
|
-
const
|
|
63
|
+
const InputRight = React.forwardRef(
|
|
64
64
|
({ children, className, ...rest }, ref) => {
|
|
65
65
|
return /* @__PURE__ */ React.createElement("div", { className: clsx.clsx(className, "ml-2.5"), ...rest, ref }, children);
|
|
66
66
|
}
|
|
67
67
|
);
|
|
68
68
|
const Input = {
|
|
69
|
-
Root,
|
|
70
|
-
Face,
|
|
71
|
-
Box,
|
|
72
|
-
Left,
|
|
73
|
-
Right
|
|
69
|
+
Root: InputRoot,
|
|
70
|
+
Face: InputFace,
|
|
71
|
+
Box: InputBox,
|
|
72
|
+
Left: InputLeft,
|
|
73
|
+
Right: InputRight
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
exports.Box = Box;
|
|
77
|
-
exports.Face = Face;
|
|
78
76
|
exports.Input = Input;
|
|
79
|
-
exports.
|
|
80
|
-
exports.
|
|
81
|
-
exports.
|
|
77
|
+
exports.InputBox = InputBox;
|
|
78
|
+
exports.InputFace = InputFace;
|
|
79
|
+
exports.InputLeft = InputLeft;
|
|
80
|
+
exports.InputRight = InputRight;
|
|
81
|
+
exports.InputRoot = InputRoot;
|
|
@@ -1,44 +1,36 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var date = require('@internationalized/date');
|
|
4
3
|
var React = require('react');
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
require('@internationalized/date');
|
|
5
|
+
require('react-aria');
|
|
6
|
+
require('react-stately');
|
|
7
|
+
var useRangeCalendar = require('../hooks/useRangeCalendar.js');
|
|
7
8
|
var CalendarGrid = require('./CalendarGrid.js');
|
|
8
9
|
var CalendarHeader = require('./CalendarHeader.js');
|
|
9
10
|
|
|
10
11
|
const RangeCalendar = ({ value, onChange }) => {
|
|
11
|
-
const {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
createCalendar: date.createCalendar,
|
|
15
|
-
defaultValue: {
|
|
16
|
-
start: new date.CalendarDate(
|
|
17
|
-
value.start.getFullYear(),
|
|
18
|
-
value.start.getMonth(),
|
|
19
|
-
value.start.getDate()
|
|
20
|
-
),
|
|
21
|
-
end: new date.CalendarDate(
|
|
22
|
-
value.end.getFullYear(),
|
|
23
|
-
value.end.getMonth(),
|
|
24
|
-
value.end.getDate()
|
|
25
|
-
)
|
|
26
|
-
},
|
|
27
|
-
onChange: (value2) => onChange({
|
|
28
|
-
start: value2.start.toDate(date.getLocalTimeZone()),
|
|
29
|
-
end: value2.end.toDate(date.getLocalTimeZone())
|
|
30
|
-
})
|
|
12
|
+
const { calendarProps, state, title, ref } = useRangeCalendar.useRangeCalendar({
|
|
13
|
+
value,
|
|
14
|
+
onChange
|
|
31
15
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return /* @__PURE__ */ React.createElement("div", { ...calendarProps, className: "calendar", ref }, /* @__PURE__ */ React.createElement(
|
|
35
|
-
CalendarHeader.CalendarHeader,
|
|
16
|
+
return /* @__PURE__ */ React.createElement(
|
|
17
|
+
"div",
|
|
36
18
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
19
|
+
...calendarProps,
|
|
20
|
+
className: "calendar",
|
|
21
|
+
ref,
|
|
22
|
+
"data-testid": "calendar-range-div"
|
|
23
|
+
},
|
|
24
|
+
/* @__PURE__ */ React.createElement(
|
|
25
|
+
CalendarHeader.CalendarHeader,
|
|
26
|
+
{
|
|
27
|
+
onClickPrevButton: () => state.focusPreviousPage(),
|
|
28
|
+
onClickNextButton: () => state.focusNextPage(),
|
|
29
|
+
title
|
|
30
|
+
}
|
|
31
|
+
),
|
|
32
|
+
/* @__PURE__ */ React.createElement(CalendarGrid.CalendarGrid, { state })
|
|
33
|
+
);
|
|
42
34
|
};
|
|
43
35
|
|
|
44
36
|
exports.RangeCalendar = RangeCalendar;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var index = require('./index.js');
|
|
6
|
+
var context = require('./context.js');
|
|
7
|
+
|
|
8
|
+
const { groupedTitle, containerGrouped } = cortexCore.selectVariants();
|
|
9
|
+
const SelectGroupedOptions = ({
|
|
10
|
+
onSelect,
|
|
11
|
+
groupedLabelExtractor,
|
|
12
|
+
options
|
|
13
|
+
}) => {
|
|
14
|
+
const { setOpen, keyExtractor } = React.useContext(context.SelectContext);
|
|
15
|
+
const handleSelect = React.useCallback(
|
|
16
|
+
(option) => {
|
|
17
|
+
onSelect(option);
|
|
18
|
+
setOpen?.(false);
|
|
19
|
+
},
|
|
20
|
+
[onSelect]
|
|
21
|
+
);
|
|
22
|
+
return /* @__PURE__ */ React.createElement("ul", { role: "select", className: containerGrouped() }, [...options ?? []].map(([key, value]) => /* @__PURE__ */ React.createElement("div", { key }, /* @__PURE__ */ React.createElement("span", { className: groupedTitle() }, groupedLabelExtractor?.(key)), value.map((option) => /* @__PURE__ */ React.createElement(
|
|
23
|
+
index.Select.Option,
|
|
24
|
+
{
|
|
25
|
+
option,
|
|
26
|
+
key: keyExtractor(option),
|
|
27
|
+
onSelectOption: handleSelect
|
|
28
|
+
}
|
|
29
|
+
)))));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.SelectGroupedOptions = SelectGroupedOptions;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var context = require('./context.js');
|
|
6
|
+
|
|
7
|
+
const SelectOption = ({
|
|
8
|
+
onSelectOption,
|
|
9
|
+
option
|
|
10
|
+
}) => {
|
|
11
|
+
const { keyExtractor, labelExtractor, value } = React.useContext(context.SelectContext);
|
|
12
|
+
return /* @__PURE__ */ React.createElement(
|
|
13
|
+
"li",
|
|
14
|
+
{
|
|
15
|
+
onClick: () => onSelectOption(option),
|
|
16
|
+
className: cortexCore.option({
|
|
17
|
+
selected: value && keyExtractor(value) === keyExtractor(option)
|
|
18
|
+
}),
|
|
19
|
+
role: "option"
|
|
20
|
+
},
|
|
21
|
+
labelExtractor(option)
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.SelectOption = SelectOption;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var index = require('./index.js');
|
|
5
|
+
var context = require('./context.js');
|
|
6
|
+
|
|
7
|
+
const SelectOptions = ({
|
|
8
|
+
onSelect,
|
|
9
|
+
options
|
|
10
|
+
}) => {
|
|
11
|
+
const { setOpen, keyExtractor } = React.useContext(context.SelectContext);
|
|
12
|
+
const handleSelect = React.useCallback(
|
|
13
|
+
(option) => {
|
|
14
|
+
onSelect(option);
|
|
15
|
+
setOpen?.(false);
|
|
16
|
+
},
|
|
17
|
+
[onSelect]
|
|
18
|
+
);
|
|
19
|
+
return /* @__PURE__ */ React.createElement("ul", { role: "select" }, (options ?? []).map((option) => /* @__PURE__ */ React.createElement(
|
|
20
|
+
index.Select.Option,
|
|
21
|
+
{
|
|
22
|
+
option,
|
|
23
|
+
key: keyExtractor(option),
|
|
24
|
+
onSelectOption: handleSelect
|
|
25
|
+
}
|
|
26
|
+
)));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.SelectOptions = SelectOptions;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var context = require('./context.js');
|
|
6
|
+
|
|
7
|
+
const { dropdown } = cortexCore.selectVariants();
|
|
8
|
+
const SelectPopover = ({ children }) => {
|
|
9
|
+
const { open } = React.useContext(context.SelectContext);
|
|
10
|
+
return /* @__PURE__ */ React.createElement("div", { className: dropdown({ open }), "data-testid": "select-popover" }, children);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.SelectPopover = SelectPopover;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
require('@internationalized/date');
|
|
5
|
+
require('react-aria');
|
|
6
|
+
require('react-stately');
|
|
7
|
+
var useOutsideClickListener = require('../../hooks/useOutsideClickListener.js');
|
|
8
|
+
var context = require('./context.js');
|
|
9
|
+
|
|
10
|
+
const SelectRoot = ({
|
|
11
|
+
children,
|
|
12
|
+
value,
|
|
13
|
+
keyExtractor,
|
|
14
|
+
labelExtractor
|
|
15
|
+
}) => {
|
|
16
|
+
const [open, setOpen] = React.useState(false);
|
|
17
|
+
const ref = React.useRef(null);
|
|
18
|
+
useOutsideClickListener.useOutsideClickListener({
|
|
19
|
+
ref,
|
|
20
|
+
onClickOutside: () => setOpen?.(false)
|
|
21
|
+
});
|
|
22
|
+
return /* @__PURE__ */ React.createElement(
|
|
23
|
+
context.SelectContext.Provider,
|
|
24
|
+
{
|
|
25
|
+
value: { value, open, setOpen, keyExtractor, labelExtractor }
|
|
26
|
+
},
|
|
27
|
+
/* @__PURE__ */ React.createElement("div", { className: "w-full relative bg-white", ref }, children)
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.SelectRoot = SelectRoot;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var io5 = require('react-icons/io5');
|
|
6
|
+
var context = require('./context.js');
|
|
7
|
+
|
|
8
|
+
const { button } = cortexCore.selectVariants();
|
|
9
|
+
const SelectTrigger = ({ label, disabled }) => {
|
|
10
|
+
const { value, setOpen, labelExtractor, open } = React.useContext(context.SelectContext);
|
|
11
|
+
const placeholder = React.useMemo(
|
|
12
|
+
() => value ? labelExtractor(value) : label,
|
|
13
|
+
[label, value]
|
|
14
|
+
);
|
|
15
|
+
return /* @__PURE__ */ React.createElement(
|
|
16
|
+
"button",
|
|
17
|
+
{
|
|
18
|
+
className: button({ disabled }),
|
|
19
|
+
onClick: () => setOpen?.(!open),
|
|
20
|
+
disabled,
|
|
21
|
+
role: "button"
|
|
22
|
+
},
|
|
23
|
+
/* @__PURE__ */ React.createElement("span", { "data-testid": "select-placeholder" }, placeholder),
|
|
24
|
+
/* @__PURE__ */ React.createElement(io5.IoChevronDownOutline, null)
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.SelectTrigger = SelectTrigger;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var GroupedOptions = require('./GroupedOptions.js');
|
|
4
|
+
var Option = require('./Option.js');
|
|
5
|
+
var Options = require('./Options.js');
|
|
6
|
+
var Popover = require('./Popover.js');
|
|
7
|
+
var Root = require('./Root.js');
|
|
8
|
+
var Trigger = require('./Trigger.js');
|
|
9
|
+
|
|
10
|
+
const Select = {
|
|
11
|
+
Root: Root.SelectRoot,
|
|
12
|
+
Trigger: Trigger.SelectTrigger,
|
|
13
|
+
Popover: Popover.SelectPopover,
|
|
14
|
+
Options: Options.SelectOptions,
|
|
15
|
+
GroupedOptions: GroupedOptions.SelectGroupedOptions,
|
|
16
|
+
Option: Option.SelectOption
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.Select = Select;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var React = require('react');
|
|
4
3
|
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
|
+
var React = require('react');
|
|
5
5
|
|
|
6
6
|
const THead = ({
|
|
7
7
|
children,
|
|
@@ -39,7 +39,7 @@ const Table = ({
|
|
|
39
39
|
const Td = ({
|
|
40
40
|
children,
|
|
41
41
|
...rest
|
|
42
|
-
}) => /* @__PURE__ */ React.createElement("td", {
|
|
42
|
+
}) => /* @__PURE__ */ React.createElement("td", { "data-testid": "td", ...rest }, children);
|
|
43
43
|
|
|
44
44
|
exports.TCell = TCell;
|
|
45
45
|
exports.TFoot = TFoot;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var date = require('@internationalized/date');
|
|
4
|
+
|
|
3
5
|
const getNameInitials = (name) => {
|
|
4
6
|
const nameSplit = name.split(" ");
|
|
5
7
|
const length = nameSplit.length;
|
|
@@ -8,5 +10,17 @@ const getNameInitials = (name) => {
|
|
|
8
10
|
}
|
|
9
11
|
return name[0];
|
|
10
12
|
};
|
|
13
|
+
const dateToCalendarDate = (value) => {
|
|
14
|
+
return new date.CalendarDate(
|
|
15
|
+
value?.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear(),
|
|
16
|
+
value?.getMonth() ? value.getMonth() + 1 : (/* @__PURE__ */ new Date()).getMonth() + 1,
|
|
17
|
+
value?.getDate() ?? (/* @__PURE__ */ new Date()).getDate()
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
const calendarDateToDate = (value) => {
|
|
21
|
+
return value.toDate(date.getLocalTimeZone());
|
|
22
|
+
};
|
|
11
23
|
|
|
24
|
+
exports.calendarDateToDate = calendarDateToDate;
|
|
25
|
+
exports.dateToCalendarDate = dateToCalendarDate;
|
|
12
26
|
exports.getNameInitials = getNameInitials;
|
|
@@ -3,18 +3,15 @@
|
|
|
3
3
|
var date = require('@internationalized/date');
|
|
4
4
|
var reactAria = require('react-aria');
|
|
5
5
|
var reactStately = require('react-stately');
|
|
6
|
+
var utils = require('../components/utils.js');
|
|
6
7
|
|
|
7
8
|
const useCalendar = ({ value, onChange }) => {
|
|
8
9
|
const { locale } = reactAria.useLocale();
|
|
9
10
|
const state = reactStately.useCalendarState({
|
|
10
11
|
locale,
|
|
11
12
|
createCalendar: date.createCalendar,
|
|
12
|
-
defaultValue:
|
|
13
|
-
|
|
14
|
-
value.getMonth(),
|
|
15
|
-
value.getDate()
|
|
16
|
-
),
|
|
17
|
-
onChange: (value2) => onChange(value2.toDate(date.getLocalTimeZone()))
|
|
13
|
+
defaultValue: utils.dateToCalendarDate(value),
|
|
14
|
+
onChange: (value2) => onChange(utils.calendarDateToDate(value2))
|
|
18
15
|
});
|
|
19
16
|
const { calendarProps, title } = reactAria.useCalendar({}, state);
|
|
20
17
|
return {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactAria = require('react-aria');
|
|
5
|
+
var reactStately = require('react-stately');
|
|
6
|
+
var utils = require('../components/utils.js');
|
|
7
|
+
|
|
8
|
+
const useDatePickerInput = ({
|
|
9
|
+
value,
|
|
10
|
+
onChange
|
|
11
|
+
}) => {
|
|
12
|
+
const state = reactStately.useDatePickerState({
|
|
13
|
+
defaultValue: utils.dateToCalendarDate(value),
|
|
14
|
+
onChange: (value2) => {
|
|
15
|
+
onChange(utils.calendarDateToDate(value2));
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const ref = React.useRef(null);
|
|
19
|
+
const { fieldProps } = reactAria.useDatePicker(
|
|
20
|
+
{ "aria-label": "date-picker-field" },
|
|
21
|
+
state,
|
|
22
|
+
ref
|
|
23
|
+
);
|
|
24
|
+
return {
|
|
25
|
+
fieldProps,
|
|
26
|
+
state,
|
|
27
|
+
ref
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.useDatePickerInput = useDatePickerInput;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactAria = require('react-aria');
|
|
5
|
+
var reactStately = require('react-stately');
|
|
6
|
+
var utils = require('../components/utils.js');
|
|
7
|
+
|
|
8
|
+
const useDateRangePickerInput = ({
|
|
9
|
+
value,
|
|
10
|
+
onChange
|
|
11
|
+
}) => {
|
|
12
|
+
const state = reactStately.useDateRangePickerState({
|
|
13
|
+
defaultValue: {
|
|
14
|
+
start: utils.dateToCalendarDate(value?.start),
|
|
15
|
+
end: utils.dateToCalendarDate(value?.end)
|
|
16
|
+
},
|
|
17
|
+
onChange: (value2) => {
|
|
18
|
+
onChange({
|
|
19
|
+
start: utils.calendarDateToDate(value2.start),
|
|
20
|
+
end: utils.calendarDateToDate(value2.end)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const ref = React.useRef(null);
|
|
25
|
+
const { startFieldProps, endFieldProps } = reactAria.useDateRangePicker(
|
|
26
|
+
{ "aria-label": "date-range-picker-field" },
|
|
27
|
+
state,
|
|
28
|
+
ref
|
|
29
|
+
);
|
|
30
|
+
return { startFieldProps, endFieldProps, state, ref };
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.useDateRangePickerInput = useDateRangePickerInput;
|