@tecsinapse/cortex-react 1.3.0-beta.1 → 1.3.0-beta.3
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/CalendarCell.js +1 -0
- package/dist/cjs/components/CalendarGrid.js +1 -0
- package/dist/cjs/components/DatePickerInput.js +1 -0
- package/dist/cjs/components/DatePickerInputBase.js +2 -2
- package/dist/cjs/components/DateRangePickerInput.js +1 -0
- package/dist/cjs/components/Input/Box.js +32 -0
- package/dist/cjs/components/Input/Face.js +30 -0
- package/dist/cjs/components/Input/Left.js +12 -0
- package/dist/cjs/components/Input/Right.js +12 -0
- package/dist/cjs/components/Input/Root.js +13 -0
- package/dist/cjs/components/Input/Search.js +25 -0
- package/dist/cjs/components/Input/index.js +19 -0
- package/dist/cjs/components/Popover/Popover.js +13 -0
- package/dist/cjs/components/Popover/PopoverContent.js +28 -0
- package/dist/cjs/components/Popover/PopoverContext.js +29 -0
- package/dist/cjs/components/Popover/PopoverRoot.js +10 -0
- package/dist/cjs/components/Popover/PopoverTrigger.js +11 -0
- package/dist/cjs/components/RangeCalendar.js +1 -0
- 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 +32 -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/TimeFieldInput.js +2 -2
- package/dist/cjs/components/Tooltip.js +47 -0
- package/dist/cjs/hooks/useFloatingLogic.js +53 -0
- package/dist/cjs/hooks/useOutsideClickListener.js +22 -0
- package/dist/cjs/index.js +11 -9
- package/dist/cjs/service/SnackbarSonner.js +13 -2
- package/dist/esm/components/Calendar.js +1 -0
- package/dist/esm/components/CalendarCell.js +1 -0
- package/dist/esm/components/CalendarGrid.js +1 -0
- package/dist/esm/components/DatePickerInput.js +1 -0
- package/dist/esm/components/DatePickerInputBase.js +1 -1
- package/dist/esm/components/DateRangePickerInput.js +1 -0
- package/dist/esm/components/Input/Box.js +30 -0
- package/dist/esm/components/Input/Face.js +28 -0
- package/dist/esm/components/Input/Left.js +10 -0
- package/dist/esm/components/Input/Right.js +10 -0
- package/dist/esm/components/Input/Root.js +11 -0
- package/dist/esm/components/Input/Search.js +23 -0
- package/dist/esm/components/Input/index.js +17 -0
- package/dist/esm/components/Popover/Popover.js +11 -0
- package/dist/esm/components/Popover/PopoverContent.js +26 -0
- package/dist/esm/components/Popover/PopoverContext.js +26 -0
- package/dist/esm/components/Popover/PopoverRoot.js +8 -0
- package/dist/esm/components/Popover/PopoverTrigger.js +9 -0
- package/dist/esm/components/RangeCalendar.js +1 -0
- 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 +30 -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/TimeFieldInput.js +1 -1
- package/dist/esm/components/Tooltip.js +45 -0
- package/dist/esm/hooks/useFloatingLogic.js +51 -0
- package/dist/esm/hooks/useOutsideClickListener.js +20 -0
- package/dist/esm/index.js +6 -2
- package/dist/esm/service/SnackbarSonner.js +13 -2
- package/dist/types/components/Input/Box.d.ts +3 -0
- package/dist/types/components/Input/Face.d.ts +3 -0
- package/dist/types/components/Input/Left.d.ts +3 -0
- package/dist/types/components/Input/Right.d.ts +3 -0
- package/dist/types/components/Input/Root.d.ts +3 -0
- package/dist/types/components/Input/Search.d.ts +3 -0
- package/dist/types/components/Input/index.d.ts +9 -0
- package/dist/types/components/Input/types.d.ts +20 -0
- package/dist/types/components/Popover/Popover.d.ts +5 -0
- package/dist/types/components/Popover/PopoverContent.d.ts +7 -0
- package/dist/types/components/Popover/PopoverContext.d.ts +22 -0
- package/dist/types/components/Popover/PopoverRoot.d.ts +9 -0
- package/dist/types/components/Popover/PopoverTrigger.d.ts +6 -0
- package/dist/types/components/Popover/index.d.ts +3 -0
- 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/Tooltip.d.ts +13 -0
- package/dist/types/components/index.d.ts +10 -1
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/useFloatingLogic.d.ts +46 -0
- package/dist/types/hooks/useOutsideClickListener.d.ts +7 -0
- package/dist/types/tests/Input/Left.test.d.ts +1 -0
- package/dist/types/tests/Input/Right.test.d.ts +1 -0
- package/dist/types/tests/Input/Root.test.d.ts +1 -0
- package/dist/types/tests/Input/Search.test.d.ts +1 -0
- package/dist/types/tests/Popover.test.d.ts +1 -0
- package/dist/types/tests/Tooltip.test.d.ts +1 -0
- package/dist/types/tests/useOutsideClickListener.test.d.ts +1 -0
- package/package.json +7 -4
- package/dist/cjs/components/Input.js +0 -81
- package/dist/cjs/components/SearchInput.js +0 -83
- package/dist/cjs/components/Select.js +0 -101
- package/dist/esm/components/Input.js +0 -74
- package/dist/esm/components/SearchInput.js +0 -81
- package/dist/esm/components/Select.js +0 -96
- package/dist/types/components/Input.d.ts +0 -34
- package/dist/types/components/SearchInput.d.ts +0 -10
- package/dist/types/components/Select.d.ts +0 -27
- /package/dist/types/tests/{Input.test.d.ts → Input/Box.test.d.ts} +0 -0
- /package/dist/types/tests/{SearchInput.test.d.ts → Input/Face.test.d.ts} +0 -0
|
@@ -5,6 +5,7 @@ var useCalendar = require('../hooks/useCalendar.js');
|
|
|
5
5
|
require('@internationalized/date');
|
|
6
6
|
require('react-aria');
|
|
7
7
|
require('react-stately');
|
|
8
|
+
require('@floating-ui/react');
|
|
8
9
|
var CalendarGrid = require('./CalendarGrid.js');
|
|
9
10
|
var CalendarHeader = require('./CalendarHeader.js');
|
|
10
11
|
|
|
@@ -5,6 +5,7 @@ require('@internationalized/date');
|
|
|
5
5
|
require('react-aria');
|
|
6
6
|
require('react-stately');
|
|
7
7
|
var useCalendarCell = require('../hooks/useCalendarCell.js');
|
|
8
|
+
require('@floating-ui/react');
|
|
8
9
|
var calendarCell = require('../styles/calendar-cell.js');
|
|
9
10
|
require('../styles/groupButton.js');
|
|
10
11
|
require('../styles/progressBar.js');
|
|
@@ -5,6 +5,7 @@ require('@internationalized/date');
|
|
|
5
5
|
require('react-aria');
|
|
6
6
|
require('react-stately');
|
|
7
7
|
var useCalendarGrid = require('../hooks/useCalendarGrid.js');
|
|
8
|
+
require('@floating-ui/react');
|
|
8
9
|
var CalendarGridBodyRows = require('./CalendarGridBodyRows.js');
|
|
9
10
|
var CalendarGridHeaderRow = require('./CalendarGridHeaderRow.js');
|
|
10
11
|
|
|
@@ -6,6 +6,7 @@ require('react-aria');
|
|
|
6
6
|
require('react-stately');
|
|
7
7
|
var utils = require('./utils.js');
|
|
8
8
|
var useDatePickerInput = require('../hooks/useDatePickerInput.js');
|
|
9
|
+
require('@floating-ui/react');
|
|
9
10
|
var Calendar = require('./Calendar.js');
|
|
10
11
|
var DateField = require('./DateField.js');
|
|
11
12
|
var DatePickerInputBase = require('./DatePickerInputBase.js');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var lia = require('react-icons/lia');
|
|
6
|
-
var
|
|
6
|
+
var index = require('./Input/index.js');
|
|
7
7
|
|
|
8
8
|
const DatePickerInputBase = ({
|
|
9
9
|
children,
|
|
@@ -11,7 +11,7 @@ const DatePickerInputBase = ({
|
|
|
11
11
|
label,
|
|
12
12
|
onClickCalendar
|
|
13
13
|
}) => {
|
|
14
|
-
return /* @__PURE__ */ React.createElement(
|
|
14
|
+
return /* @__PURE__ */ React.createElement(index.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(index.Input.Right, { className: "" }, /* @__PURE__ */ React.createElement(
|
|
15
15
|
lia.LiaCalendar,
|
|
16
16
|
{
|
|
17
17
|
className: "cursor-pointer mt-centi",
|
|
@@ -6,6 +6,7 @@ require('react-aria');
|
|
|
6
6
|
require('react-stately');
|
|
7
7
|
var utils = require('./utils.js');
|
|
8
8
|
var useDateRangePickerInput = require('../hooks/useDateRangePickerInput.js');
|
|
9
|
+
require('@floating-ui/react');
|
|
9
10
|
var DateField = require('./DateField.js');
|
|
10
11
|
var DatePickerInputBase = require('./DatePickerInputBase.js');
|
|
11
12
|
var RangeCalendar = require('./RangeCalendar.js');
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
|
+
var clsx = require('clsx');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
const InputBox = React.forwardRef(
|
|
8
|
+
({ id, name, variants, label, placeholder, className, ...rest }, ref) => {
|
|
9
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-col" }, /* @__PURE__ */ React.createElement(
|
|
10
|
+
"input",
|
|
11
|
+
{
|
|
12
|
+
id: id ?? name,
|
|
13
|
+
name,
|
|
14
|
+
placeholder: placeholder ?? " ",
|
|
15
|
+
className: clsx(cortexCore.inputBox(placeholder, label, className)),
|
|
16
|
+
...rest,
|
|
17
|
+
ref,
|
|
18
|
+
"data-testid": "input-box"
|
|
19
|
+
}
|
|
20
|
+
), /* @__PURE__ */ React.createElement(
|
|
21
|
+
"label",
|
|
22
|
+
{
|
|
23
|
+
htmlFor: id ?? name,
|
|
24
|
+
className: cortexCore.labelStyle({ intent: variants?.intent, placeholder }),
|
|
25
|
+
"data-testid": "input-label"
|
|
26
|
+
},
|
|
27
|
+
label
|
|
28
|
+
));
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
exports.InputBox = InputBox;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
|
+
var clsx = require('clsx');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
const getValidChildren = (children) => {
|
|
8
|
+
return React.Children.toArray(children).filter(
|
|
9
|
+
(el) => React.isValidElement(el)
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
const InputFace = React.forwardRef(
|
|
13
|
+
({ children, variants, className, ...rest }, ref) => {
|
|
14
|
+
const clones = getValidChildren(children).map((el) => {
|
|
15
|
+
return React.cloneElement(el, { ...el.props, variants });
|
|
16
|
+
});
|
|
17
|
+
return /* @__PURE__ */ React.createElement(
|
|
18
|
+
"div",
|
|
19
|
+
{
|
|
20
|
+
"data-testid": "input-face",
|
|
21
|
+
...rest,
|
|
22
|
+
className: clsx(cortexCore.input(variants), className),
|
|
23
|
+
ref
|
|
24
|
+
},
|
|
25
|
+
clones
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
exports.InputFace = InputFace;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var clsx = require('clsx');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
const InputLeft = React.forwardRef(
|
|
7
|
+
({ children, className, ...rest }, ref) => {
|
|
8
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx(className, "mr-2.5"), ...rest, ref }, children);
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
exports.InputLeft = InputLeft;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var clsx = require('clsx');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
const InputRight = React.forwardRef(
|
|
7
|
+
({ children, className, ...rest }, ref) => {
|
|
8
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx(className, "ml-2.5"), ...rest, ref }, children);
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
exports.InputRight = InputRight;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var Box = require('./Box.js');
|
|
5
|
+
var Face = require('./Face.js');
|
|
6
|
+
|
|
7
|
+
const InputRoot = React.forwardRef(
|
|
8
|
+
({ variants, className, ...rest }, ref) => {
|
|
9
|
+
return /* @__PURE__ */ React.createElement(Face.InputFace, { variants, className }, /* @__PURE__ */ React.createElement(Box.InputBox, { ...rest, ref }));
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
exports.InputRoot = InputRoot;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var io5 = require('react-icons/io5');
|
|
5
|
+
var index = require('./index.js');
|
|
6
|
+
require('@internationalized/date');
|
|
7
|
+
require('react-aria');
|
|
8
|
+
require('react-stately');
|
|
9
|
+
var useDebouncedState = require('../../hooks/useDebouncedState.js');
|
|
10
|
+
require('@floating-ui/react');
|
|
11
|
+
|
|
12
|
+
const InputSearch = React.forwardRef(
|
|
13
|
+
({ bounceTimeout = 1e3, variants, className, onChange, ...rest }, ref) => {
|
|
14
|
+
const [bouncedTextEvent, setBouncedTextEvent] = React.useState();
|
|
15
|
+
const [searchInputEvent, setSearchInputEvent] = useDebouncedState.useDebouncedState(void 0, setBouncedTextEvent, bounceTimeout);
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
if (onChange && searchInputEvent) {
|
|
18
|
+
onChange(searchInputEvent);
|
|
19
|
+
}
|
|
20
|
+
}, [bouncedTextEvent]);
|
|
21
|
+
return /* @__PURE__ */ React.createElement(index.Input.Face, { variants, className }, /* @__PURE__ */ React.createElement(index.Input.Left, null, /* @__PURE__ */ React.createElement(io5.IoSearchOutline, { "data-testid": "icon-search-left" })), /* @__PURE__ */ React.createElement(index.Input.Box, { ...rest, ref, onChange: (e) => setSearchInputEvent(e) }));
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
exports.InputSearch = InputSearch;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Box = require('./Box.js');
|
|
4
|
+
var Face = require('./Face.js');
|
|
5
|
+
var Left = require('./Left.js');
|
|
6
|
+
var Right = require('./Right.js');
|
|
7
|
+
var Root = require('./Root.js');
|
|
8
|
+
var Search = require('./Search.js');
|
|
9
|
+
|
|
10
|
+
const Input = {
|
|
11
|
+
Root: Root.InputRoot,
|
|
12
|
+
Face: Face.InputFace,
|
|
13
|
+
Box: Box.InputBox,
|
|
14
|
+
Left: Left.InputLeft,
|
|
15
|
+
Right: Right.InputRight,
|
|
16
|
+
Search: Search.InputSearch
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.Input = Input;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var PopoverRoot = require('./PopoverRoot.js');
|
|
4
|
+
var PopoverTrigger = require('./PopoverTrigger.js');
|
|
5
|
+
var PopoverContent = require('./PopoverContent.js');
|
|
6
|
+
|
|
7
|
+
const Popover = {
|
|
8
|
+
Root: PopoverRoot,
|
|
9
|
+
Trigger: PopoverTrigger,
|
|
10
|
+
Content: PopoverContent
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.Popover = Popover;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var clsx = require('clsx');
|
|
5
|
+
var PopoverContext = require('./PopoverContext.js');
|
|
6
|
+
|
|
7
|
+
const PopoverContent = ({ children, className }) => {
|
|
8
|
+
const { isOpen, x, y, strategy, floatingStyles, refs } = PopoverContext.usePopoverContext();
|
|
9
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, isOpen ? /* @__PURE__ */ React.createElement(
|
|
10
|
+
"div",
|
|
11
|
+
{
|
|
12
|
+
ref: refs.setFloating,
|
|
13
|
+
className: clsx(
|
|
14
|
+
"border border-gray-200 bg-black text-white p-4 rounded-md shadow-lg z-50",
|
|
15
|
+
className
|
|
16
|
+
),
|
|
17
|
+
style: {
|
|
18
|
+
position: strategy,
|
|
19
|
+
top: y ?? 0,
|
|
20
|
+
left: x ?? 0,
|
|
21
|
+
...floatingStyles
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
children
|
|
25
|
+
) : /* @__PURE__ */ React.createElement(React.Fragment, null));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = PopoverContent;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
require('@internationalized/date');
|
|
5
|
+
require('react-aria');
|
|
6
|
+
require('react-stately');
|
|
7
|
+
var useFloatingLogic = require('../../hooks/useFloatingLogic.js');
|
|
8
|
+
|
|
9
|
+
const PopoverContext = React.createContext(
|
|
10
|
+
void 0
|
|
11
|
+
);
|
|
12
|
+
const usePopoverContext = () => {
|
|
13
|
+
const context = React.useContext(PopoverContext);
|
|
14
|
+
if (!context) {
|
|
15
|
+
throw new Error("usePopoverContext must be used within a PopoverProvider");
|
|
16
|
+
}
|
|
17
|
+
return context;
|
|
18
|
+
};
|
|
19
|
+
const PopoverProvider = ({
|
|
20
|
+
children,
|
|
21
|
+
placement,
|
|
22
|
+
trigger
|
|
23
|
+
}) => {
|
|
24
|
+
const floatingLogic = useFloatingLogic.useFloatingLogic({ placement, trigger });
|
|
25
|
+
return /* @__PURE__ */ React.createElement(PopoverContext.Provider, { value: { ...floatingLogic } }, children);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.PopoverProvider = PopoverProvider;
|
|
29
|
+
exports.usePopoverContext = usePopoverContext;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var PopoverContext = require('./PopoverContext.js');
|
|
5
|
+
|
|
6
|
+
const PopoverRoot = ({ children, placement, trigger }) => {
|
|
7
|
+
return /* @__PURE__ */ React.createElement(PopoverContext.PopoverProvider, { placement, trigger }, children);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
module.exports = PopoverRoot;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var PopoverContext = require('./PopoverContext.js');
|
|
5
|
+
|
|
6
|
+
const PopoverTrigger = ({ children }) => {
|
|
7
|
+
const { triggerProps } = PopoverContext.usePopoverContext();
|
|
8
|
+
return React.cloneElement(children, triggerProps);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
module.exports = PopoverTrigger;
|
|
@@ -5,6 +5,7 @@ require('@internationalized/date');
|
|
|
5
5
|
require('react-aria');
|
|
6
6
|
require('react-stately');
|
|
7
7
|
var useRangeCalendar = require('../hooks/useRangeCalendar.js');
|
|
8
|
+
require('@floating-ui/react');
|
|
8
9
|
var CalendarGrid = require('./CalendarGrid.js');
|
|
9
10
|
var CalendarHeader = require('./CalendarHeader.js');
|
|
10
11
|
|
|
@@ -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,32 @@
|
|
|
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
|
+
require('@floating-ui/react');
|
|
9
|
+
var context = require('./context.js');
|
|
10
|
+
|
|
11
|
+
const SelectRoot = ({
|
|
12
|
+
children,
|
|
13
|
+
value,
|
|
14
|
+
keyExtractor,
|
|
15
|
+
labelExtractor
|
|
16
|
+
}) => {
|
|
17
|
+
const [open, setOpen] = React.useState(false);
|
|
18
|
+
const ref = React.useRef(null);
|
|
19
|
+
useOutsideClickListener.useOutsideClickListener({
|
|
20
|
+
ref,
|
|
21
|
+
onClickOutside: () => setOpen?.(false)
|
|
22
|
+
});
|
|
23
|
+
return /* @__PURE__ */ React.createElement(
|
|
24
|
+
context.SelectContext.Provider,
|
|
25
|
+
{
|
|
26
|
+
value: { value, open, setOpen, keyExtractor, labelExtractor }
|
|
27
|
+
},
|
|
28
|
+
/* @__PURE__ */ React.createElement("div", { className: "w-full relative bg-white", ref }, children)
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
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,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var
|
|
4
|
+
var index = require('./Input/index.js');
|
|
5
5
|
var cortexCore = require('@tecsinapse/cortex-core');
|
|
6
6
|
var TimeField = require('./TimeField.js');
|
|
7
7
|
|
|
8
8
|
const TimeFieldInput = (props) => {
|
|
9
9
|
const { onChange, value, label, variants } = props;
|
|
10
10
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
11
|
-
|
|
11
|
+
index.Input.Face,
|
|
12
12
|
{
|
|
13
13
|
variants,
|
|
14
14
|
className: "flex flex-row",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var react = require('@floating-ui/react');
|
|
5
|
+
require('@internationalized/date');
|
|
6
|
+
require('react-aria');
|
|
7
|
+
require('react-stately');
|
|
8
|
+
var useFloatingLogic = require('../hooks/useFloatingLogic.js');
|
|
9
|
+
|
|
10
|
+
React.forwardRef((props, ref) => {
|
|
11
|
+
const {
|
|
12
|
+
children,
|
|
13
|
+
text,
|
|
14
|
+
trigger = "hover",
|
|
15
|
+
placement = "top",
|
|
16
|
+
width,
|
|
17
|
+
height
|
|
18
|
+
} = props;
|
|
19
|
+
const arrowRef = React.useRef(null);
|
|
20
|
+
const {
|
|
21
|
+
isOpen,
|
|
22
|
+
triggerProps,
|
|
23
|
+
x,
|
|
24
|
+
y,
|
|
25
|
+
strategy,
|
|
26
|
+
refs,
|
|
27
|
+
context,
|
|
28
|
+
floatingStyles
|
|
29
|
+
} = useFloatingLogic.useFloatingLogic({ placement, arrowRef, trigger });
|
|
30
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, React.cloneElement(children, triggerProps), isOpen ? /* @__PURE__ */ React.createElement(
|
|
31
|
+
"div",
|
|
32
|
+
{
|
|
33
|
+
ref: ref || refs.setFloating,
|
|
34
|
+
className: "bg-black text-white p-2 rounded z-50 shadow-md text-justify",
|
|
35
|
+
style: {
|
|
36
|
+
position: strategy,
|
|
37
|
+
top: y ?? 0,
|
|
38
|
+
left: x ?? 0,
|
|
39
|
+
width,
|
|
40
|
+
height,
|
|
41
|
+
...floatingStyles
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
text,
|
|
45
|
+
/* @__PURE__ */ React.createElement(react.FloatingArrow, { ref: arrowRef, context, fill: "black" })
|
|
46
|
+
) : /* @__PURE__ */ React.createElement(React.Fragment, null));
|
|
47
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var react = require('@floating-ui/react');
|
|
5
|
+
|
|
6
|
+
const useFloatingLogic = ({
|
|
7
|
+
placement,
|
|
8
|
+
trigger,
|
|
9
|
+
arrowRef
|
|
10
|
+
}) => {
|
|
11
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
12
|
+
const { x, y, strategy, refs, update, context, floatingStyles } = react.useFloating(
|
|
13
|
+
{
|
|
14
|
+
placement,
|
|
15
|
+
whileElementsMounted: react.autoUpdate,
|
|
16
|
+
middleware: [
|
|
17
|
+
react.offset(10),
|
|
18
|
+
react.flip({
|
|
19
|
+
flipAlignment: true,
|
|
20
|
+
fallbackPlacements: ["right", "bottom", "left", "top"]
|
|
21
|
+
}),
|
|
22
|
+
react.shift(),
|
|
23
|
+
...arrowRef ? [react.arrow({ element: arrowRef })] : []
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
if (isOpen) update();
|
|
29
|
+
}, [isOpen, update]);
|
|
30
|
+
const triggerProps = {
|
|
31
|
+
ref: refs.setReference,
|
|
32
|
+
...trigger === "hover" && {
|
|
33
|
+
onMouseEnter: () => setIsOpen(true),
|
|
34
|
+
onMouseLeave: () => setIsOpen(false)
|
|
35
|
+
},
|
|
36
|
+
...trigger === "click" && {
|
|
37
|
+
onClick: () => setIsOpen((prev) => !prev)
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
isOpen,
|
|
42
|
+
setIsOpen,
|
|
43
|
+
x,
|
|
44
|
+
y,
|
|
45
|
+
strategy,
|
|
46
|
+
refs,
|
|
47
|
+
context,
|
|
48
|
+
floatingStyles,
|
|
49
|
+
triggerProps
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
exports.useFloatingLogic = useFloatingLogic;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
const useOutsideClickListener = ({
|
|
6
|
+
ref,
|
|
7
|
+
onClickOutside
|
|
8
|
+
}) => {
|
|
9
|
+
const handleClickOutside = React.useCallback((event) => {
|
|
10
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
11
|
+
onClickOutside?.();
|
|
12
|
+
}
|
|
13
|
+
}, []);
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
document.addEventListener("click", handleClickOutside, true);
|
|
16
|
+
return () => {
|
|
17
|
+
document.removeEventListener("click", handleClickOutside, true);
|
|
18
|
+
};
|
|
19
|
+
}, [handleClickOutside]);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.useOutsideClickListener = useOutsideClickListener;
|