@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
package/dist/cjs/index.js
CHANGED
|
@@ -13,24 +13,28 @@ var DefaultSnack = require('./components/DefaultSnack.js');
|
|
|
13
13
|
var Drawer = require('./components/Drawer.js');
|
|
14
14
|
var GroupButton = require('./components/GroupButton.js');
|
|
15
15
|
var Hint = require('./components/Hint.js');
|
|
16
|
-
var
|
|
16
|
+
var index = require('./components/Input/index.js');
|
|
17
17
|
var Modal = require('./components/Modal.js');
|
|
18
18
|
var ProgressBar = require('./components/ProgressBar.js');
|
|
19
19
|
var RangeCalendar = require('./components/RangeCalendar.js');
|
|
20
|
-
var
|
|
20
|
+
var index$1 = require('./components/Select/index.js');
|
|
21
21
|
var Skeleton = require('./components/Skeleton.js');
|
|
22
22
|
var Table = require('./components/Table.js');
|
|
23
23
|
var Tag = require('./components/Tag.js');
|
|
24
24
|
var TextArea = require('./components/TextArea.js');
|
|
25
25
|
var TimeFieldInput = require('./components/TimeFieldInput.js');
|
|
26
26
|
var Toggle = require('./components/Toggle.js');
|
|
27
|
+
require('./components/Tooltip.js');
|
|
28
|
+
var Popover = require('./components/Popover/Popover.js');
|
|
27
29
|
var useCalendar = require('./hooks/useCalendar.js');
|
|
28
30
|
var useCalendarCell = require('./hooks/useCalendarCell.js');
|
|
29
31
|
var useCalendarGrid = require('./hooks/useCalendarGrid.js');
|
|
30
32
|
var useDatePickerInput = require('./hooks/useDatePickerInput.js');
|
|
31
33
|
var useDateRangePickerInput = require('./hooks/useDateRangePickerInput.js');
|
|
32
34
|
var useDebouncedState = require('./hooks/useDebouncedState.js');
|
|
35
|
+
var useOutsideClickListener = require('./hooks/useOutsideClickListener.js');
|
|
33
36
|
var useRangeCalendar = require('./hooks/useRangeCalendar.js');
|
|
37
|
+
var useFloatingLogic = require('./hooks/useFloatingLogic.js');
|
|
34
38
|
var SnackbarSonner = require('./service/SnackbarSonner.js');
|
|
35
39
|
|
|
36
40
|
|
|
@@ -49,16 +53,11 @@ exports.DefaultSnack = DefaultSnack.DefaultSnack;
|
|
|
49
53
|
exports.Drawer = Drawer.Drawer;
|
|
50
54
|
exports.GroupButton = GroupButton.GroupButton;
|
|
51
55
|
exports.Hint = Hint.Hint;
|
|
52
|
-
exports.
|
|
53
|
-
exports.Face = Input.Face;
|
|
54
|
-
exports.Input = Input.Input;
|
|
55
|
-
exports.Left = Input.Left;
|
|
56
|
-
exports.Right = Input.Right;
|
|
57
|
-
exports.Root = Input.Root;
|
|
56
|
+
exports.Input = index.Input;
|
|
58
57
|
exports.Modal = Modal.Modal;
|
|
59
58
|
exports.ProgressBar = ProgressBar.ProgressBar;
|
|
60
59
|
exports.RangeCalendar = RangeCalendar.RangeCalendar;
|
|
61
|
-
exports.Select =
|
|
60
|
+
exports.Select = index$1.Select;
|
|
62
61
|
exports.Skeleton = Skeleton.Skeleton;
|
|
63
62
|
exports.TCell = Table.TCell;
|
|
64
63
|
exports.TFoot = Table.TFoot;
|
|
@@ -72,11 +71,14 @@ exports.Tag = Tag.Tag;
|
|
|
72
71
|
exports.TextArea = TextArea.TextArea;
|
|
73
72
|
exports.TimeFieldInput = TimeFieldInput.TimeFieldInput;
|
|
74
73
|
exports.Toggle = Toggle.Toggle;
|
|
74
|
+
exports.Popover = Popover.Popover;
|
|
75
75
|
exports.useCalendar = useCalendar.useCalendar;
|
|
76
76
|
exports.useCalendarCell = useCalendarCell.useCalendarCell;
|
|
77
77
|
exports.useCalendarGrid = useCalendarGrid.useCalendarGrid;
|
|
78
78
|
exports.useDatePickerInput = useDatePickerInput.useDatePickerInput;
|
|
79
79
|
exports.useDateRangePickerInput = useDateRangePickerInput.useDateRangePickerInput;
|
|
80
80
|
exports.useDebouncedState = useDebouncedState.useDebouncedState;
|
|
81
|
+
exports.useOutsideClickListener = useOutsideClickListener.useOutsideClickListener;
|
|
81
82
|
exports.useRangeCalendar = useRangeCalendar.useRangeCalendar;
|
|
83
|
+
exports.useFloatingLogic = useFloatingLogic.useFloatingLogic;
|
|
82
84
|
exports.SnackbarSonner = SnackbarSonner.SnackbarSonner;
|
|
@@ -11,11 +11,17 @@ require('../components/Card.js');
|
|
|
11
11
|
require('../components/Button.js');
|
|
12
12
|
require('react-aria');
|
|
13
13
|
require('react-stately');
|
|
14
|
+
require('@floating-ui/react');
|
|
14
15
|
require('../components/CalendarCell.js');
|
|
15
16
|
require('@tecsinapse/cortex-core');
|
|
16
17
|
require('react-icons/fa');
|
|
17
18
|
require('react-icons/lia');
|
|
18
|
-
require('../components/Input.js');
|
|
19
|
+
require('../components/Input/Box.js');
|
|
20
|
+
require('../components/Input/Face.js');
|
|
21
|
+
require('../components/Input/Left.js');
|
|
22
|
+
require('../components/Input/Right.js');
|
|
23
|
+
require('../components/Input/Root.js');
|
|
24
|
+
require('../components/Input/Search.js');
|
|
19
25
|
var DefaultSnack = require('../components/DefaultSnack.js');
|
|
20
26
|
require('../components/GroupButton.js');
|
|
21
27
|
require('../components/Hint.js');
|
|
@@ -23,10 +29,15 @@ require('../components/Modal.js');
|
|
|
23
29
|
require('../styles/calendar-cell.js');
|
|
24
30
|
require('../styles/groupButton.js');
|
|
25
31
|
require('../styles/progressBar.js');
|
|
26
|
-
require('../components/Select.js');
|
|
32
|
+
require('../components/Select/GroupedOptions.js');
|
|
33
|
+
require('../components/Select/context.js');
|
|
34
|
+
require('../components/Select/Popover.js');
|
|
35
|
+
require('../components/Select/Trigger.js');
|
|
27
36
|
require('../components/Tag.js');
|
|
28
37
|
require('../components/TextArea.js');
|
|
29
38
|
require('../components/Toggle.js');
|
|
39
|
+
require('../components/Tooltip.js');
|
|
40
|
+
require('../components/Popover/PopoverContext.js');
|
|
30
41
|
|
|
31
42
|
class SnackbarSonner {
|
|
32
43
|
custom(Component, options) {
|
|
@@ -3,6 +3,7 @@ import { useCalendar } from '../hooks/useCalendar.js';
|
|
|
3
3
|
import '@internationalized/date';
|
|
4
4
|
import 'react-aria';
|
|
5
5
|
import 'react-stately';
|
|
6
|
+
import '@floating-ui/react';
|
|
6
7
|
import { CalendarGrid } from './CalendarGrid.js';
|
|
7
8
|
import { CalendarHeader } from './CalendarHeader.js';
|
|
8
9
|
|
|
@@ -3,6 +3,7 @@ import '@internationalized/date';
|
|
|
3
3
|
import 'react-aria';
|
|
4
4
|
import 'react-stately';
|
|
5
5
|
import { useCalendarCell } from '../hooks/useCalendarCell.js';
|
|
6
|
+
import '@floating-ui/react';
|
|
6
7
|
import { calendarCell } from '../styles/calendar-cell.js';
|
|
7
8
|
import '../styles/groupButton.js';
|
|
8
9
|
import '../styles/progressBar.js';
|
|
@@ -3,6 +3,7 @@ import '@internationalized/date';
|
|
|
3
3
|
import 'react-aria';
|
|
4
4
|
import 'react-stately';
|
|
5
5
|
import { useCalendarGrid } from '../hooks/useCalendarGrid.js';
|
|
6
|
+
import '@floating-ui/react';
|
|
6
7
|
import { CalendarGridBodyRows } from './CalendarGridBodyRows.js';
|
|
7
8
|
import { CalendarGridHeaderRow } from './CalendarGridHeaderRow.js';
|
|
8
9
|
|
|
@@ -4,6 +4,7 @@ import 'react-aria';
|
|
|
4
4
|
import 'react-stately';
|
|
5
5
|
import { dateToCalendarDate } from './utils.js';
|
|
6
6
|
import { useDatePickerInput } from '../hooks/useDatePickerInput.js';
|
|
7
|
+
import '@floating-ui/react';
|
|
7
8
|
import { Calendar } from './Calendar.js';
|
|
8
9
|
import { DateField } from './DateField.js';
|
|
9
10
|
import { DatePickerInputBase } from './DatePickerInputBase.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { labelStyle, inputBox } from '@tecsinapse/cortex-core';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { LiaCalendar } from 'react-icons/lia';
|
|
4
|
-
import { Input } from './Input.js';
|
|
4
|
+
import { Input } from './Input/index.js';
|
|
5
5
|
|
|
6
6
|
const DatePickerInputBase = ({
|
|
7
7
|
children,
|
|
@@ -4,6 +4,7 @@ import 'react-aria';
|
|
|
4
4
|
import 'react-stately';
|
|
5
5
|
import { dateToCalendarDate } from './utils.js';
|
|
6
6
|
import { useDateRangePickerInput } from '../hooks/useDateRangePickerInput.js';
|
|
7
|
+
import '@floating-ui/react';
|
|
7
8
|
import { DateField } from './DateField.js';
|
|
8
9
|
import { DatePickerInputBase } from './DatePickerInputBase.js';
|
|
9
10
|
import { RangeCalendar } from './RangeCalendar.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { inputBox, labelStyle } from '@tecsinapse/cortex-core';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
const InputBox = React.forwardRef(
|
|
6
|
+
({ id, name, variants, label, placeholder, className, ...rest }, ref) => {
|
|
7
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-col" }, /* @__PURE__ */ React.createElement(
|
|
8
|
+
"input",
|
|
9
|
+
{
|
|
10
|
+
id: id ?? name,
|
|
11
|
+
name,
|
|
12
|
+
placeholder: placeholder ?? " ",
|
|
13
|
+
className: clsx(inputBox(placeholder, label, className)),
|
|
14
|
+
...rest,
|
|
15
|
+
ref,
|
|
16
|
+
"data-testid": "input-box"
|
|
17
|
+
}
|
|
18
|
+
), /* @__PURE__ */ React.createElement(
|
|
19
|
+
"label",
|
|
20
|
+
{
|
|
21
|
+
htmlFor: id ?? name,
|
|
22
|
+
className: labelStyle({ intent: variants?.intent, placeholder }),
|
|
23
|
+
"data-testid": "input-label"
|
|
24
|
+
},
|
|
25
|
+
label
|
|
26
|
+
));
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export { InputBox };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { input } from '@tecsinapse/cortex-core';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
const getValidChildren = (children) => {
|
|
6
|
+
return React.Children.toArray(children).filter(
|
|
7
|
+
(el) => React.isValidElement(el)
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
const InputFace = React.forwardRef(
|
|
11
|
+
({ children, variants, className, ...rest }, ref) => {
|
|
12
|
+
const clones = getValidChildren(children).map((el) => {
|
|
13
|
+
return React.cloneElement(el, { ...el.props, variants });
|
|
14
|
+
});
|
|
15
|
+
return /* @__PURE__ */ React.createElement(
|
|
16
|
+
"div",
|
|
17
|
+
{
|
|
18
|
+
"data-testid": "input-face",
|
|
19
|
+
...rest,
|
|
20
|
+
className: clsx(input(variants), className),
|
|
21
|
+
ref
|
|
22
|
+
},
|
|
23
|
+
clones
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export { InputFace };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const InputLeft = React.forwardRef(
|
|
5
|
+
({ children, className, ...rest }, ref) => {
|
|
6
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx(className, "mr-2.5"), ...rest, ref }, children);
|
|
7
|
+
}
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export { InputLeft };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const InputRight = React.forwardRef(
|
|
5
|
+
({ children, className, ...rest }, ref) => {
|
|
6
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx(className, "ml-2.5"), ...rest, ref }, children);
|
|
7
|
+
}
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export { InputRight };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputBox } from './Box.js';
|
|
3
|
+
import { InputFace } from './Face.js';
|
|
4
|
+
|
|
5
|
+
const InputRoot = React.forwardRef(
|
|
6
|
+
({ variants, className, ...rest }, ref) => {
|
|
7
|
+
return /* @__PURE__ */ React.createElement(InputFace, { variants, className }, /* @__PURE__ */ React.createElement(InputBox, { ...rest, ref }));
|
|
8
|
+
}
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export { InputRoot };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { IoSearchOutline } from 'react-icons/io5';
|
|
3
|
+
import { Input } from './index.js';
|
|
4
|
+
import '@internationalized/date';
|
|
5
|
+
import 'react-aria';
|
|
6
|
+
import 'react-stately';
|
|
7
|
+
import { useDebouncedState } from '../../hooks/useDebouncedState.js';
|
|
8
|
+
import '@floating-ui/react';
|
|
9
|
+
|
|
10
|
+
const InputSearch = React.forwardRef(
|
|
11
|
+
({ bounceTimeout = 1e3, variants, className, onChange, ...rest }, ref) => {
|
|
12
|
+
const [bouncedTextEvent, setBouncedTextEvent] = useState();
|
|
13
|
+
const [searchInputEvent, setSearchInputEvent] = useDebouncedState(void 0, setBouncedTextEvent, bounceTimeout);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (onChange && searchInputEvent) {
|
|
16
|
+
onChange(searchInputEvent);
|
|
17
|
+
}
|
|
18
|
+
}, [bouncedTextEvent]);
|
|
19
|
+
return /* @__PURE__ */ React.createElement(Input.Face, { variants, className }, /* @__PURE__ */ React.createElement(Input.Left, null, /* @__PURE__ */ React.createElement(IoSearchOutline, { "data-testid": "icon-search-left" })), /* @__PURE__ */ React.createElement(Input.Box, { ...rest, ref, onChange: (e) => setSearchInputEvent(e) }));
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export { InputSearch };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InputBox } from './Box.js';
|
|
2
|
+
import { InputFace } from './Face.js';
|
|
3
|
+
import { InputLeft } from './Left.js';
|
|
4
|
+
import { InputRight } from './Right.js';
|
|
5
|
+
import { InputRoot } from './Root.js';
|
|
6
|
+
import { InputSearch } from './Search.js';
|
|
7
|
+
|
|
8
|
+
const Input = {
|
|
9
|
+
Root: InputRoot,
|
|
10
|
+
Face: InputFace,
|
|
11
|
+
Box: InputBox,
|
|
12
|
+
Left: InputLeft,
|
|
13
|
+
Right: InputRight,
|
|
14
|
+
Search: InputSearch
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { Input };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import PopoverRoot from './PopoverRoot.js';
|
|
2
|
+
import PopoverTrigger from './PopoverTrigger.js';
|
|
3
|
+
import PopoverContent from './PopoverContent.js';
|
|
4
|
+
|
|
5
|
+
const Popover = {
|
|
6
|
+
Root: PopoverRoot,
|
|
7
|
+
Trigger: PopoverTrigger,
|
|
8
|
+
Content: PopoverContent
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { Popover };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { usePopoverContext } from './PopoverContext.js';
|
|
4
|
+
|
|
5
|
+
const PopoverContent = ({ children, className }) => {
|
|
6
|
+
const { isOpen, x, y, strategy, floatingStyles, refs } = usePopoverContext();
|
|
7
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, isOpen ? /* @__PURE__ */ React.createElement(
|
|
8
|
+
"div",
|
|
9
|
+
{
|
|
10
|
+
ref: refs.setFloating,
|
|
11
|
+
className: clsx(
|
|
12
|
+
"border border-gray-200 bg-black text-white p-4 rounded-md shadow-lg z-50",
|
|
13
|
+
className
|
|
14
|
+
),
|
|
15
|
+
style: {
|
|
16
|
+
position: strategy,
|
|
17
|
+
top: y ?? 0,
|
|
18
|
+
left: x ?? 0,
|
|
19
|
+
...floatingStyles
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
children
|
|
23
|
+
) : /* @__PURE__ */ React.createElement(React.Fragment, null));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { PopoverContent as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
|
+
import '@internationalized/date';
|
|
3
|
+
import 'react-aria';
|
|
4
|
+
import 'react-stately';
|
|
5
|
+
import { useFloatingLogic } from '../../hooks/useFloatingLogic.js';
|
|
6
|
+
|
|
7
|
+
const PopoverContext = createContext(
|
|
8
|
+
void 0
|
|
9
|
+
);
|
|
10
|
+
const usePopoverContext = () => {
|
|
11
|
+
const context = useContext(PopoverContext);
|
|
12
|
+
if (!context) {
|
|
13
|
+
throw new Error("usePopoverContext must be used within a PopoverProvider");
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
16
|
+
};
|
|
17
|
+
const PopoverProvider = ({
|
|
18
|
+
children,
|
|
19
|
+
placement,
|
|
20
|
+
trigger
|
|
21
|
+
}) => {
|
|
22
|
+
const floatingLogic = useFloatingLogic({ placement, trigger });
|
|
23
|
+
return /* @__PURE__ */ React.createElement(PopoverContext.Provider, { value: { ...floatingLogic } }, children);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { PopoverProvider, usePopoverContext };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PopoverProvider } from './PopoverContext.js';
|
|
3
|
+
|
|
4
|
+
const PopoverRoot = ({ children, placement, trigger }) => {
|
|
5
|
+
return /* @__PURE__ */ React.createElement(PopoverProvider, { placement, trigger }, children);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { PopoverRoot as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { usePopoverContext } from './PopoverContext.js';
|
|
3
|
+
|
|
4
|
+
const PopoverTrigger = ({ children }) => {
|
|
5
|
+
const { triggerProps } = usePopoverContext();
|
|
6
|
+
return React.cloneElement(children, triggerProps);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { PopoverTrigger as default };
|
|
@@ -3,6 +3,7 @@ import '@internationalized/date';
|
|
|
3
3
|
import 'react-aria';
|
|
4
4
|
import 'react-stately';
|
|
5
5
|
import { useRangeCalendar } from '../hooks/useRangeCalendar.js';
|
|
6
|
+
import '@floating-ui/react';
|
|
6
7
|
import { CalendarGrid } from './CalendarGrid.js';
|
|
7
8
|
import { CalendarHeader } from './CalendarHeader.js';
|
|
8
9
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { selectVariants } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { useContext, useCallback } from 'react';
|
|
3
|
+
import { Select } from './index.js';
|
|
4
|
+
import { SelectContext } from './context.js';
|
|
5
|
+
|
|
6
|
+
const { groupedTitle, containerGrouped } = selectVariants();
|
|
7
|
+
const SelectGroupedOptions = ({
|
|
8
|
+
onSelect,
|
|
9
|
+
groupedLabelExtractor,
|
|
10
|
+
options
|
|
11
|
+
}) => {
|
|
12
|
+
const { setOpen, keyExtractor } = useContext(SelectContext);
|
|
13
|
+
const handleSelect = useCallback(
|
|
14
|
+
(option) => {
|
|
15
|
+
onSelect(option);
|
|
16
|
+
setOpen?.(false);
|
|
17
|
+
},
|
|
18
|
+
[onSelect]
|
|
19
|
+
);
|
|
20
|
+
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(
|
|
21
|
+
Select.Option,
|
|
22
|
+
{
|
|
23
|
+
option,
|
|
24
|
+
key: keyExtractor(option),
|
|
25
|
+
onSelectOption: handleSelect
|
|
26
|
+
}
|
|
27
|
+
)))));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { SelectGroupedOptions };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { option } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { SelectContext } from './context.js';
|
|
4
|
+
|
|
5
|
+
const SelectOption = ({
|
|
6
|
+
onSelectOption,
|
|
7
|
+
option: option$1
|
|
8
|
+
}) => {
|
|
9
|
+
const { keyExtractor, labelExtractor, value } = useContext(SelectContext);
|
|
10
|
+
return /* @__PURE__ */ React.createElement(
|
|
11
|
+
"li",
|
|
12
|
+
{
|
|
13
|
+
onClick: () => onSelectOption(option$1),
|
|
14
|
+
className: option({
|
|
15
|
+
selected: value && keyExtractor(value) === keyExtractor(option$1)
|
|
16
|
+
}),
|
|
17
|
+
role: "option"
|
|
18
|
+
},
|
|
19
|
+
labelExtractor(option$1)
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { SelectOption };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { useContext, useCallback } from 'react';
|
|
2
|
+
import { Select } from './index.js';
|
|
3
|
+
import { SelectContext } from './context.js';
|
|
4
|
+
|
|
5
|
+
const SelectOptions = ({
|
|
6
|
+
onSelect,
|
|
7
|
+
options
|
|
8
|
+
}) => {
|
|
9
|
+
const { setOpen, keyExtractor } = useContext(SelectContext);
|
|
10
|
+
const handleSelect = useCallback(
|
|
11
|
+
(option) => {
|
|
12
|
+
onSelect(option);
|
|
13
|
+
setOpen?.(false);
|
|
14
|
+
},
|
|
15
|
+
[onSelect]
|
|
16
|
+
);
|
|
17
|
+
return /* @__PURE__ */ React.createElement("ul", { role: "select" }, (options ?? []).map((option) => /* @__PURE__ */ React.createElement(
|
|
18
|
+
Select.Option,
|
|
19
|
+
{
|
|
20
|
+
option,
|
|
21
|
+
key: keyExtractor(option),
|
|
22
|
+
onSelectOption: handleSelect
|
|
23
|
+
}
|
|
24
|
+
)));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { SelectOptions };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { selectVariants } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { SelectContext } from './context.js';
|
|
4
|
+
|
|
5
|
+
const { dropdown } = selectVariants();
|
|
6
|
+
const SelectPopover = ({ children }) => {
|
|
7
|
+
const { open } = useContext(SelectContext);
|
|
8
|
+
return /* @__PURE__ */ React.createElement("div", { className: dropdown({ open }), "data-testid": "select-popover" }, children);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { SelectPopover };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
|
+
import '@internationalized/date';
|
|
3
|
+
import 'react-aria';
|
|
4
|
+
import 'react-stately';
|
|
5
|
+
import { useOutsideClickListener } from '../../hooks/useOutsideClickListener.js';
|
|
6
|
+
import '@floating-ui/react';
|
|
7
|
+
import { SelectContext } from './context.js';
|
|
8
|
+
|
|
9
|
+
const SelectRoot = ({
|
|
10
|
+
children,
|
|
11
|
+
value,
|
|
12
|
+
keyExtractor,
|
|
13
|
+
labelExtractor
|
|
14
|
+
}) => {
|
|
15
|
+
const [open, setOpen] = useState(false);
|
|
16
|
+
const ref = useRef(null);
|
|
17
|
+
useOutsideClickListener({
|
|
18
|
+
ref,
|
|
19
|
+
onClickOutside: () => setOpen?.(false)
|
|
20
|
+
});
|
|
21
|
+
return /* @__PURE__ */ React.createElement(
|
|
22
|
+
SelectContext.Provider,
|
|
23
|
+
{
|
|
24
|
+
value: { value, open, setOpen, keyExtractor, labelExtractor }
|
|
25
|
+
},
|
|
26
|
+
/* @__PURE__ */ React.createElement("div", { className: "w-full relative bg-white", ref }, children)
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { SelectRoot };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { selectVariants } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { useContext, useMemo } from 'react';
|
|
3
|
+
import { IoChevronDownOutline } from 'react-icons/io5';
|
|
4
|
+
import { SelectContext } from './context.js';
|
|
5
|
+
|
|
6
|
+
const { button } = selectVariants();
|
|
7
|
+
const SelectTrigger = ({ label, disabled }) => {
|
|
8
|
+
const { value, setOpen, labelExtractor, open } = useContext(SelectContext);
|
|
9
|
+
const placeholder = useMemo(
|
|
10
|
+
() => value ? labelExtractor(value) : label,
|
|
11
|
+
[label, value]
|
|
12
|
+
);
|
|
13
|
+
return /* @__PURE__ */ React.createElement(
|
|
14
|
+
"button",
|
|
15
|
+
{
|
|
16
|
+
className: button({ disabled }),
|
|
17
|
+
onClick: () => setOpen?.(!open),
|
|
18
|
+
disabled,
|
|
19
|
+
role: "button"
|
|
20
|
+
},
|
|
21
|
+
/* @__PURE__ */ React.createElement("span", { "data-testid": "select-placeholder" }, placeholder),
|
|
22
|
+
/* @__PURE__ */ React.createElement(IoChevronDownOutline, null)
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { SelectTrigger };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SelectGroupedOptions } from './GroupedOptions.js';
|
|
2
|
+
import { SelectOption } from './Option.js';
|
|
3
|
+
import { SelectOptions } from './Options.js';
|
|
4
|
+
import { SelectPopover } from './Popover.js';
|
|
5
|
+
import { SelectRoot } from './Root.js';
|
|
6
|
+
import { SelectTrigger } from './Trigger.js';
|
|
7
|
+
|
|
8
|
+
const Select = {
|
|
9
|
+
Root: SelectRoot,
|
|
10
|
+
Trigger: SelectTrigger,
|
|
11
|
+
Popover: SelectPopover,
|
|
12
|
+
Options: SelectOptions,
|
|
13
|
+
GroupedOptions: SelectGroupedOptions,
|
|
14
|
+
Option: SelectOption
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { Select };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { forwardRef, useRef } from 'react';
|
|
2
|
+
import { FloatingArrow } from '@floating-ui/react';
|
|
3
|
+
import '@internationalized/date';
|
|
4
|
+
import 'react-aria';
|
|
5
|
+
import 'react-stately';
|
|
6
|
+
import { useFloatingLogic } from '../hooks/useFloatingLogic.js';
|
|
7
|
+
|
|
8
|
+
forwardRef((props, ref) => {
|
|
9
|
+
const {
|
|
10
|
+
children,
|
|
11
|
+
text,
|
|
12
|
+
trigger = "hover",
|
|
13
|
+
placement = "top",
|
|
14
|
+
width,
|
|
15
|
+
height
|
|
16
|
+
} = props;
|
|
17
|
+
const arrowRef = useRef(null);
|
|
18
|
+
const {
|
|
19
|
+
isOpen,
|
|
20
|
+
triggerProps,
|
|
21
|
+
x,
|
|
22
|
+
y,
|
|
23
|
+
strategy,
|
|
24
|
+
refs,
|
|
25
|
+
context,
|
|
26
|
+
floatingStyles
|
|
27
|
+
} = useFloatingLogic({ placement, arrowRef, trigger });
|
|
28
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, React.cloneElement(children, triggerProps), isOpen ? /* @__PURE__ */ React.createElement(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
ref: ref || refs.setFloating,
|
|
32
|
+
className: "bg-black text-white p-2 rounded z-50 shadow-md text-justify",
|
|
33
|
+
style: {
|
|
34
|
+
position: strategy,
|
|
35
|
+
top: y ?? 0,
|
|
36
|
+
left: x ?? 0,
|
|
37
|
+
width,
|
|
38
|
+
height,
|
|
39
|
+
...floatingStyles
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
text,
|
|
43
|
+
/* @__PURE__ */ React.createElement(FloatingArrow, { ref: arrowRef, context, fill: "black" })
|
|
44
|
+
) : /* @__PURE__ */ React.createElement(React.Fragment, null));
|
|
45
|
+
});
|