@tecsinapse/cortex-react 1.3.0-beta.2 → 1.3.0-beta.21
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/Divider.js +10 -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/Mask.js +53 -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 +23 -0
- package/dist/cjs/components/Masonry.js +49 -0
- package/dist/cjs/components/Menubar/Categories.js +10 -0
- package/dist/cjs/components/Menubar/Category.js +11 -0
- package/dist/cjs/components/Menubar/Dropdown.js +23 -0
- package/dist/cjs/components/Menubar/DropdownRoot.js +38 -0
- package/dist/cjs/components/Menubar/Header.js +25 -0
- package/dist/cjs/components/Menubar/IconControlSubItem.js +19 -0
- package/dist/cjs/components/Menubar/Item.js +22 -0
- package/dist/cjs/components/Menubar/ItemLink.js +18 -0
- package/dist/cjs/components/Menubar/Left.js +11 -0
- package/dist/cjs/components/Menubar/MostUsed.js +11 -0
- package/dist/cjs/components/Menubar/MostUsedItem.js +31 -0
- package/dist/cjs/components/Menubar/MostUsedList.js +63 -0
- package/dist/cjs/components/Menubar/Right.js +11 -0
- package/dist/cjs/components/Menubar/Root.js +11 -0
- package/dist/cjs/components/Menubar/Search.js +21 -0
- package/dist/cjs/components/Menubar/SubItem.js +20 -0
- package/dist/cjs/components/Menubar/index.js +33 -0
- package/dist/cjs/components/Popover/Content.js +31 -0
- package/dist/cjs/components/Popover/Context.js +15 -0
- package/dist/cjs/components/Popover/Provider.js +19 -0
- package/dist/cjs/components/Popover/Root.js +14 -0
- package/dist/cjs/components/Popover/Trigger.js +11 -0
- package/dist/cjs/components/Popover/index.js +15 -0
- package/dist/cjs/components/RadioButton.js +22 -0
- package/dist/cjs/components/RangeCalendar.js +1 -0
- package/dist/cjs/components/Select/Content.js +21 -0
- package/dist/cjs/components/Select/GroupedOptions.js +7 -4
- package/dist/cjs/components/Select/MultiCheckAllOptions.js +47 -0
- package/dist/cjs/components/Select/MultiGroupedOptions.js +44 -0
- package/dist/cjs/components/Select/MultiOption.js +43 -0
- package/dist/cjs/components/Select/MultiOptions.js +26 -0
- package/dist/cjs/components/Select/Option.js +4 -2
- package/dist/cjs/components/Select/Options.js +7 -3
- package/dist/cjs/components/Select/Popover.js +2 -5
- package/dist/cjs/components/Select/Root.js +3 -17
- package/dist/cjs/components/Select/Trigger.js +10 -8
- package/dist/cjs/components/Select/context.js +4 -0
- package/dist/cjs/components/Select/index.js +9 -1
- package/dist/cjs/components/Select/utils.js +16 -0
- package/dist/cjs/components/TimeFieldInput.js +2 -2
- package/dist/cjs/components/Tooltip.js +55 -0
- package/dist/cjs/components/utils.js +5 -0
- package/dist/cjs/hooks/useFloatingLogic.js +53 -0
- package/dist/cjs/index.js +30 -27
- package/dist/cjs/provider/MenubarProvider.js +22 -0
- package/dist/cjs/provider/SnackbarProvider.js +56 -0
- package/dist/cjs/service/SnackbarSonner.js +25 -5
- package/dist/cjs/styles/menubar.js +70 -0
- 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/Divider.js +8 -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/Mask.js +49 -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 +21 -0
- package/dist/esm/components/Masonry.js +47 -0
- package/dist/esm/components/Menubar/Categories.js +8 -0
- package/dist/esm/components/Menubar/Category.js +9 -0
- package/dist/esm/components/Menubar/Dropdown.js +21 -0
- package/dist/esm/components/Menubar/DropdownRoot.js +36 -0
- package/dist/esm/components/Menubar/Header.js +23 -0
- package/dist/esm/components/Menubar/IconControlSubItem.js +17 -0
- package/dist/esm/components/Menubar/Item.js +20 -0
- package/dist/esm/components/Menubar/ItemLink.js +16 -0
- package/dist/esm/components/Menubar/Left.js +9 -0
- package/dist/esm/components/Menubar/MostUsed.js +9 -0
- package/dist/esm/components/Menubar/MostUsedItem.js +29 -0
- package/dist/esm/components/Menubar/MostUsedList.js +61 -0
- package/dist/esm/components/Menubar/Right.js +9 -0
- package/dist/esm/components/Menubar/Root.js +9 -0
- package/dist/esm/components/Menubar/Search.js +19 -0
- package/dist/esm/components/Menubar/SubItem.js +18 -0
- package/dist/esm/components/Menubar/index.js +31 -0
- package/dist/esm/components/Popover/Content.js +29 -0
- package/dist/esm/components/Popover/Context.js +12 -0
- package/dist/esm/components/Popover/Provider.js +17 -0
- package/dist/esm/components/Popover/Root.js +12 -0
- package/dist/esm/components/Popover/Trigger.js +9 -0
- package/dist/esm/components/Popover/index.js +13 -0
- package/dist/esm/components/RadioButton.js +20 -0
- package/dist/esm/components/RangeCalendar.js +1 -0
- package/dist/esm/components/Select/Content.js +19 -0
- package/dist/esm/components/Select/GroupedOptions.js +7 -4
- package/dist/esm/components/Select/MultiCheckAllOptions.js +45 -0
- package/dist/esm/components/Select/MultiGroupedOptions.js +42 -0
- package/dist/esm/components/Select/MultiOption.js +41 -0
- package/dist/esm/components/Select/MultiOptions.js +24 -0
- package/dist/esm/components/Select/Option.js +4 -2
- package/dist/esm/components/Select/Options.js +7 -3
- package/dist/esm/components/Select/Popover.js +3 -6
- package/dist/esm/components/Select/Root.js +4 -18
- package/dist/esm/components/Select/Trigger.js +10 -8
- package/dist/esm/components/Select/context.js +4 -1
- package/dist/esm/components/Select/index.js +9 -1
- package/dist/esm/components/Select/utils.js +14 -0
- package/dist/esm/components/TimeFieldInput.js +1 -1
- package/dist/esm/components/Tooltip.js +50 -0
- package/dist/esm/components/utils.js +5 -1
- package/dist/esm/hooks/useFloatingLogic.js +51 -0
- package/dist/esm/index.js +14 -12
- package/dist/esm/provider/MenubarProvider.js +19 -0
- package/dist/esm/provider/SnackbarProvider.js +54 -0
- package/dist/esm/service/SnackbarSonner.js +25 -5
- package/dist/esm/styles/menubar.js +62 -0
- package/dist/types/components/Card.d.ts +3 -4
- package/dist/types/components/Divider.d.ts +5 -0
- package/dist/types/components/Drawer.d.ts +1 -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/Mask.d.ts +5 -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 +12 -0
- package/dist/types/components/Input/types.d.ts +27 -0
- package/dist/types/components/Masonry.d.ts +7 -0
- package/dist/types/components/Menubar/Categories.d.ts +3 -0
- package/dist/types/components/Menubar/Category.d.ts +8 -0
- package/dist/types/components/Menubar/Dropdown.d.ts +3 -0
- package/dist/types/components/Menubar/DropdownRoot.d.ts +17 -0
- package/dist/types/components/Menubar/Header.d.ts +6 -0
- package/dist/types/components/Menubar/IconControlSubItem.d.ts +6 -0
- package/dist/types/components/Menubar/Item.d.ts +10 -0
- package/dist/types/components/Menubar/ItemLink.d.ts +8 -0
- package/dist/types/components/Menubar/Left.d.ts +3 -0
- package/dist/types/components/Menubar/MostUsed.d.ts +8 -0
- package/dist/types/components/Menubar/MostUsedItem.d.ts +8 -0
- package/dist/types/components/Menubar/MostUsedList.d.ts +3 -0
- package/dist/types/components/Menubar/Right.d.ts +3 -0
- package/dist/types/components/Menubar/Root.d.ts +6 -0
- package/dist/types/components/Menubar/Search.d.ts +3 -0
- package/dist/types/components/Menubar/SubItem.d.ts +6 -0
- package/dist/types/components/Menubar/index.d.ts +15 -0
- package/dist/types/components/Menubar/interface.d.ts +4 -0
- package/dist/types/components/Popover/Content.d.ts +6 -0
- package/dist/types/components/Popover/Context.d.ts +18 -0
- package/dist/types/components/Popover/Provider.d.ts +8 -0
- package/dist/types/components/Popover/Root.d.ts +8 -0
- package/dist/types/components/Popover/Trigger.d.ts +5 -0
- package/dist/types/components/Popover/index.d.ts +6 -0
- package/dist/types/components/RadioButton.d.ts +6 -0
- package/dist/types/components/SearchInput.d.ts +0 -11
- package/dist/types/components/Select/Content.d.ts +6 -0
- package/dist/types/components/Select/MultiCheckAllOptions.d.ts +4 -0
- package/dist/types/components/Select/MultiGroupedOptions.d.ts +8 -0
- package/dist/types/components/Select/MultiOption.d.ts +6 -0
- package/dist/types/components/Select/MultiOptions.d.ts +7 -0
- package/dist/types/components/Select/Option.d.ts +2 -1
- package/dist/types/components/Select/Root.d.ts +1 -1
- package/dist/types/components/Select/context.d.ts +6 -4
- package/dist/types/components/Select/index.d.ts +5 -1
- package/dist/types/components/Select/utils.d.ts +1 -0
- package/dist/types/components/Tooltip.d.ts +13 -0
- package/dist/types/components/index.d.ts +5 -1
- package/dist/types/components/utils.d.ts +2 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useFloatingLogic.d.ts +46 -0
- package/dist/types/provider/MenubarProvider.d.ts +8 -0
- package/dist/types/provider/index.d.ts +2 -0
- package/dist/types/styles/menubar.d.ts +350 -0
- package/dist/types/tests/Input/Face.test.d.ts +1 -0
- package/dist/types/tests/Input/Left.test.d.ts +1 -0
- package/dist/types/tests/Input/Mask.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/Menubar/Categories.test.d.ts +1 -0
- package/dist/types/tests/Menubar/Category.test.d.ts +1 -0
- package/dist/types/tests/Menubar/Dropdown.test.d.ts +1 -0
- package/dist/types/tests/Menubar/DropdownRoot.test.d.ts +1 -0
- package/dist/types/tests/Menubar/Header.test.d.ts +1 -0
- package/dist/types/tests/Menubar/HeaderLeft.test.d.ts +1 -0
- package/dist/types/tests/Menubar/HeaderRigth.test.d.ts +1 -0
- package/dist/types/tests/Menubar/Item.test.d.ts +1 -0
- package/dist/types/tests/Menubar/MostUsed.test.d.ts +1 -0
- package/dist/types/tests/Menubar/MostUsedItem.test.d.ts +1 -0
- package/dist/types/tests/Menubar/MostUsedList.test.d.ts +1 -0
- package/dist/types/tests/Menubar/Root.test.d.ts +1 -0
- package/dist/types/tests/Menubar/SubItem.test.d.ts +1 -0
- package/dist/types/tests/Popover.test.d.ts +1 -0
- package/dist/types/tests/RadioButton.test.d.ts +1 -0
- package/dist/types/tests/Tooltip.test.d.ts +1 -0
- package/package.json +5 -3
- package/dist/cjs/components/Input.js +0 -81
- package/dist/esm/components/Input.js +0 -74
- package/dist/types/components/Input.d.ts +0 -34
- /package/dist/types/tests/{Input.test.d.ts → Divider.test.d.ts} +0 -0
- /package/dist/types/tests/{SearchInput.test.d.ts → Input/Box.test.d.ts} +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { option, checkbox } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { useContext, useMemo, useCallback } from 'react';
|
|
3
|
+
import { SelectContext, SelectMultiOptionsContext } from './context.js';
|
|
4
|
+
|
|
5
|
+
const SelectMultiCheckAllOptions = ({
|
|
6
|
+
checkAllLabel = "Select all"
|
|
7
|
+
}) => {
|
|
8
|
+
const { keyExtractor, value: currentValue = [] } = useContext(SelectContext);
|
|
9
|
+
const { options, onSelect } = useContext(SelectMultiOptionsContext);
|
|
10
|
+
const isChecked = useMemo(
|
|
11
|
+
() => (options ?? []).filter(
|
|
12
|
+
(it) => currentValue.find((value) => keyExtractor(value) === keyExtractor(it))
|
|
13
|
+
).length == (options ?? []).length,
|
|
14
|
+
[keyExtractor, currentValue, options]
|
|
15
|
+
);
|
|
16
|
+
const checkAll = useCallback(() => {
|
|
17
|
+
{
|
|
18
|
+
let updateSelected = [...currentValue];
|
|
19
|
+
if (!isChecked) {
|
|
20
|
+
updateSelected = [
|
|
21
|
+
.../* @__PURE__ */ new Set([...updateSelected, ...options ?? []])
|
|
22
|
+
];
|
|
23
|
+
} else {
|
|
24
|
+
const optionKeys = new Set(
|
|
25
|
+
options?.map((option2) => keyExtractor(option2))
|
|
26
|
+
);
|
|
27
|
+
updateSelected = updateSelected.filter(
|
|
28
|
+
(item) => !optionKeys.has(keyExtractor(item))
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
onSelect(updateSelected);
|
|
32
|
+
}
|
|
33
|
+
}, [options, onSelect]);
|
|
34
|
+
return options?.length ? /* @__PURE__ */ React.createElement("div", { className: option(), onClick: checkAll }, /* @__PURE__ */ React.createElement(
|
|
35
|
+
"input",
|
|
36
|
+
{
|
|
37
|
+
type: "checkbox",
|
|
38
|
+
className: checkbox(),
|
|
39
|
+
onChange: checkAll,
|
|
40
|
+
checked: isChecked
|
|
41
|
+
}
|
|
42
|
+
), /* @__PURE__ */ React.createElement("span", null, checkAllLabel)) : /* @__PURE__ */ React.createElement(React.Fragment, null);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { SelectMultiCheckAllOptions };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { selectVariants } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { useContext, useMemo } from 'react';
|
|
3
|
+
import { Select } from './index.js';
|
|
4
|
+
import { SelectContext, SelectMultiOptionsContext } from './context.js';
|
|
5
|
+
import { handleSelectMulti } from './utils.js';
|
|
6
|
+
|
|
7
|
+
const { groupedTitle, list } = selectVariants();
|
|
8
|
+
const SelectMultiGroupedOptions = ({
|
|
9
|
+
onSelect,
|
|
10
|
+
groupedLabelExtractor,
|
|
11
|
+
options,
|
|
12
|
+
children
|
|
13
|
+
}) => {
|
|
14
|
+
const { value: currentValue = [], keyExtractor } = useContext(SelectContext);
|
|
15
|
+
const flattenMap = useMemo(
|
|
16
|
+
() => options ? Array.from(options?.values()).flatMap((value) => value) : [],
|
|
17
|
+
[options]
|
|
18
|
+
);
|
|
19
|
+
return /* @__PURE__ */ React.createElement("ul", { role: "select", className: list() }, /* @__PURE__ */ React.createElement(
|
|
20
|
+
SelectMultiOptionsContext.Provider,
|
|
21
|
+
{
|
|
22
|
+
value: { onSelect, options: flattenMap }
|
|
23
|
+
},
|
|
24
|
+
children,
|
|
25
|
+
[...options ?? []].map(([key, value]) => /* @__PURE__ */ React.createElement("div", { key }, /* @__PURE__ */ React.createElement("span", { className: groupedTitle() }, groupedLabelExtractor?.(key)), value.map((option) => /* @__PURE__ */ React.createElement(
|
|
26
|
+
Select.MultiOption,
|
|
27
|
+
{
|
|
28
|
+
grouped: true,
|
|
29
|
+
option,
|
|
30
|
+
key: keyExtractor(option),
|
|
31
|
+
onSelectOption: (option2) => handleSelectMulti(
|
|
32
|
+
option2,
|
|
33
|
+
currentValue,
|
|
34
|
+
onSelect,
|
|
35
|
+
keyExtractor
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
))))
|
|
39
|
+
));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { SelectMultiGroupedOptions };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { option, checkbox } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { useContext, useRef, useMemo, useCallback } from 'react';
|
|
3
|
+
import { SelectContext } from './context.js';
|
|
4
|
+
|
|
5
|
+
const SelectMultiOption = ({
|
|
6
|
+
onSelectOption,
|
|
7
|
+
option: option$1,
|
|
8
|
+
grouped = false
|
|
9
|
+
}) => {
|
|
10
|
+
const { keyExtractor, labelExtractor, value } = useContext(SelectContext);
|
|
11
|
+
const inputRef = useRef(null);
|
|
12
|
+
const isChecked = useMemo(
|
|
13
|
+
() => value?.length > 0 && value.find((it) => keyExtractor(it) === keyExtractor(option$1)) !== void 0,
|
|
14
|
+
[value, option$1]
|
|
15
|
+
);
|
|
16
|
+
const onClickOption = useCallback(() => {
|
|
17
|
+
onSelectOption(option$1);
|
|
18
|
+
inputRef.current?.click();
|
|
19
|
+
}, [onSelectOption, inputRef]);
|
|
20
|
+
return /* @__PURE__ */ React.createElement(
|
|
21
|
+
"li",
|
|
22
|
+
{
|
|
23
|
+
onClick: onClickOption,
|
|
24
|
+
className: option({ grouped }),
|
|
25
|
+
role: "option"
|
|
26
|
+
},
|
|
27
|
+
/* @__PURE__ */ React.createElement(
|
|
28
|
+
"input",
|
|
29
|
+
{
|
|
30
|
+
type: "checkbox",
|
|
31
|
+
checked: isChecked,
|
|
32
|
+
className: checkbox({ className: "pointer-events-none" }),
|
|
33
|
+
onChange: () => false,
|
|
34
|
+
ref: inputRef
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
labelExtractor(option$1)
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { SelectMultiOption };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { selectVariants } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { Select } from './index.js';
|
|
4
|
+
import { SelectContext, SelectMultiOptionsContext } from './context.js';
|
|
5
|
+
import { handleSelectMulti } from './utils.js';
|
|
6
|
+
|
|
7
|
+
const { list } = selectVariants();
|
|
8
|
+
const SelectMultiOptions = ({
|
|
9
|
+
onSelect,
|
|
10
|
+
options,
|
|
11
|
+
children
|
|
12
|
+
}) => {
|
|
13
|
+
const { keyExtractor, value: currentValue = [] } = useContext(SelectContext);
|
|
14
|
+
return /* @__PURE__ */ React.createElement(SelectMultiOptionsContext.Provider, { value: { onSelect, options } }, /* @__PURE__ */ React.createElement("ul", { role: "select", className: list() }, children, (options ?? []).map((option) => /* @__PURE__ */ React.createElement(
|
|
15
|
+
Select.MultiOption,
|
|
16
|
+
{
|
|
17
|
+
option,
|
|
18
|
+
key: keyExtractor(option),
|
|
19
|
+
onSelectOption: (option2) => handleSelectMulti(option2, currentValue, onSelect, keyExtractor)
|
|
20
|
+
}
|
|
21
|
+
))));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { SelectMultiOptions };
|
|
@@ -4,7 +4,8 @@ import { SelectContext } from './context.js';
|
|
|
4
4
|
|
|
5
5
|
const SelectOption = ({
|
|
6
6
|
onSelectOption,
|
|
7
|
-
option: option$1
|
|
7
|
+
option: option$1,
|
|
8
|
+
grouped = false
|
|
8
9
|
}) => {
|
|
9
10
|
const { keyExtractor, labelExtractor, value } = useContext(SelectContext);
|
|
10
11
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -12,7 +13,8 @@ const SelectOption = ({
|
|
|
12
13
|
{
|
|
13
14
|
onClick: () => onSelectOption(option$1),
|
|
14
15
|
className: option({
|
|
15
|
-
selected: value && keyExtractor(value) === keyExtractor(option$1)
|
|
16
|
+
selected: value && keyExtractor(value) === keyExtractor(option$1),
|
|
17
|
+
grouped
|
|
16
18
|
}),
|
|
17
19
|
role: "option"
|
|
18
20
|
},
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
import { selectVariants } from '@tecsinapse/cortex-core';
|
|
1
2
|
import React, { useContext, useCallback } from 'react';
|
|
2
3
|
import { Select } from './index.js';
|
|
4
|
+
import { usePopoverContext } from '../Popover/Context.js';
|
|
3
5
|
import { SelectContext } from './context.js';
|
|
4
6
|
|
|
7
|
+
const { list } = selectVariants();
|
|
5
8
|
const SelectOptions = ({
|
|
6
9
|
onSelect,
|
|
7
10
|
options
|
|
8
11
|
}) => {
|
|
9
|
-
const {
|
|
12
|
+
const { keyExtractor } = useContext(SelectContext);
|
|
13
|
+
const { setIsOpen } = usePopoverContext();
|
|
10
14
|
const handleSelect = useCallback(
|
|
11
15
|
(option) => {
|
|
12
16
|
onSelect(option);
|
|
13
|
-
|
|
17
|
+
setIsOpen?.(false);
|
|
14
18
|
},
|
|
15
19
|
[onSelect]
|
|
16
20
|
);
|
|
17
|
-
return /* @__PURE__ */ React.createElement("ul", { role: "select" }, (options ?? []).map((option) => /* @__PURE__ */ React.createElement(
|
|
21
|
+
return /* @__PURE__ */ React.createElement("ul", { role: "select", className: list() }, (options ?? []).map((option) => /* @__PURE__ */ React.createElement(
|
|
18
22
|
Select.Option,
|
|
19
23
|
{
|
|
20
24
|
option,
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { SelectContext } from './context.js';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover } from '../Popover/index.js';
|
|
4
3
|
|
|
5
|
-
const { dropdown } = selectVariants();
|
|
6
4
|
const SelectPopover = ({ children }) => {
|
|
7
|
-
|
|
8
|
-
return /* @__PURE__ */ React.createElement("div", { className: dropdown({ open }), "data-testid": "select-popover" }, children);
|
|
5
|
+
return /* @__PURE__ */ React.createElement(Popover.Content, { className: "bg-white max-h-[30vh] w-full overflow-y-scroll gap-y-mili flex flex-col p-0" }, children);
|
|
9
6
|
};
|
|
10
7
|
|
|
11
8
|
export { SelectPopover };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
4
|
-
import 'react-stately';
|
|
5
|
-
import { useOutsideClickListener } from '../../hooks/useOutsideClickListener.js';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover } from '../Popover/index.js';
|
|
3
|
+
import { Content } from './Content.js';
|
|
6
4
|
import { SelectContext } from './context.js';
|
|
7
5
|
|
|
8
6
|
const SelectRoot = ({
|
|
@@ -11,19 +9,7 @@ const SelectRoot = ({
|
|
|
11
9
|
keyExtractor,
|
|
12
10
|
labelExtractor
|
|
13
11
|
}) => {
|
|
14
|
-
|
|
15
|
-
const ref = useRef(null);
|
|
16
|
-
useOutsideClickListener({
|
|
17
|
-
ref,
|
|
18
|
-
onClickOutside: () => setOpen?.(false)
|
|
19
|
-
});
|
|
20
|
-
return /* @__PURE__ */ React.createElement(
|
|
21
|
-
SelectContext.Provider,
|
|
22
|
-
{
|
|
23
|
-
value: { value, open, setOpen, keyExtractor, labelExtractor }
|
|
24
|
-
},
|
|
25
|
-
/* @__PURE__ */ React.createElement("div", { className: "w-full relative bg-white", ref }, children)
|
|
26
|
-
);
|
|
12
|
+
return /* @__PURE__ */ React.createElement(Popover.Provider, null, /* @__PURE__ */ React.createElement(Popover.Root, { placement: "bottom", trigger: "click" }, /* @__PURE__ */ React.createElement(SelectContext.Provider, { value: { value, keyExtractor, labelExtractor } }, /* @__PURE__ */ React.createElement(Content, null, children))));
|
|
27
13
|
};
|
|
28
14
|
|
|
29
15
|
export { SelectRoot };
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import { selectVariants } from '@tecsinapse/cortex-core';
|
|
2
2
|
import React, { useContext, useMemo } from 'react';
|
|
3
3
|
import { IoChevronDownOutline } from 'react-icons/io5';
|
|
4
|
+
import { Popover } from '../Popover/index.js';
|
|
4
5
|
import { SelectContext } from './context.js';
|
|
5
6
|
|
|
6
7
|
const { button } = selectVariants();
|
|
7
8
|
const SelectTrigger = ({ label, disabled }) => {
|
|
8
|
-
const { value,
|
|
9
|
-
const placeholder = useMemo(
|
|
10
|
-
(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const { value, labelExtractor } = useContext(SelectContext);
|
|
10
|
+
const placeholder = useMemo(() => {
|
|
11
|
+
if (value?.length === 0 || !value) return label;
|
|
12
|
+
if (value?.length === 1) return labelExtractor(value[0]);
|
|
13
|
+
if (value?.length > 1) return `${value.length} items selected`;
|
|
14
|
+
return labelExtractor(value);
|
|
15
|
+
}, [label, value]);
|
|
16
|
+
return /* @__PURE__ */ React.createElement(Popover.Trigger, null, /* @__PURE__ */ React.createElement(
|
|
14
17
|
"button",
|
|
15
18
|
{
|
|
16
19
|
className: button({ disabled }),
|
|
17
|
-
onClick: () => setOpen?.(!open),
|
|
18
20
|
disabled,
|
|
19
21
|
role: "button"
|
|
20
22
|
},
|
|
21
23
|
/* @__PURE__ */ React.createElement("span", { "data-testid": "select-placeholder" }, placeholder),
|
|
22
24
|
/* @__PURE__ */ React.createElement(IoChevronDownOutline, null)
|
|
23
|
-
);
|
|
25
|
+
));
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
export { SelectTrigger };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { SelectGroupedOptions } from './GroupedOptions.js';
|
|
2
|
+
import { SelectMultiCheckAllOptions } from './MultiCheckAllOptions.js';
|
|
3
|
+
import { SelectMultiGroupedOptions } from './MultiGroupedOptions.js';
|
|
4
|
+
import { SelectMultiOption } from './MultiOption.js';
|
|
5
|
+
import { SelectMultiOptions } from './MultiOptions.js';
|
|
2
6
|
import { SelectOption } from './Option.js';
|
|
3
7
|
import { SelectOptions } from './Options.js';
|
|
4
8
|
import { SelectPopover } from './Popover.js';
|
|
@@ -11,7 +15,11 @@ const Select = {
|
|
|
11
15
|
Popover: SelectPopover,
|
|
12
16
|
Options: SelectOptions,
|
|
13
17
|
GroupedOptions: SelectGroupedOptions,
|
|
14
|
-
Option: SelectOption
|
|
18
|
+
Option: SelectOption,
|
|
19
|
+
MultiOptions: SelectMultiOptions,
|
|
20
|
+
MultiGroupedOptions: SelectMultiGroupedOptions,
|
|
21
|
+
MultiOption: SelectMultiOption,
|
|
22
|
+
MultiCheckAllOptions: SelectMultiCheckAllOptions
|
|
15
23
|
};
|
|
16
24
|
|
|
17
25
|
export { Select };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const handleSelectMulti = (option, value, onSelect, keyExtractor) => {
|
|
2
|
+
const current = Array.from(value ?? []);
|
|
3
|
+
const indexOf = current.findIndex(
|
|
4
|
+
(it) => keyExtractor(it) === keyExtractor(option)
|
|
5
|
+
);
|
|
6
|
+
if (indexOf === -1) {
|
|
7
|
+
current.push(option);
|
|
8
|
+
} else {
|
|
9
|
+
current.splice(indexOf, 1);
|
|
10
|
+
}
|
|
11
|
+
onSelect(current);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { handleSelectMulti };
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { cloneWithProps } from './utils.js';
|
|
7
|
+
import { useFloatingLogic } from '../hooks/useFloatingLogic.js';
|
|
8
|
+
|
|
9
|
+
const Tooltip = forwardRef(
|
|
10
|
+
(props, ref) => {
|
|
11
|
+
const {
|
|
12
|
+
children,
|
|
13
|
+
text,
|
|
14
|
+
trigger = "hover",
|
|
15
|
+
placement = "top",
|
|
16
|
+
width,
|
|
17
|
+
height
|
|
18
|
+
} = props;
|
|
19
|
+
const arrowRef = useRef(null);
|
|
20
|
+
const {
|
|
21
|
+
isOpen,
|
|
22
|
+
triggerProps,
|
|
23
|
+
x,
|
|
24
|
+
y,
|
|
25
|
+
strategy,
|
|
26
|
+
refs,
|
|
27
|
+
context,
|
|
28
|
+
floatingStyles
|
|
29
|
+
} = useFloatingLogic({ placement, arrowRef, trigger });
|
|
30
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, cloneWithProps(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(FloatingArrow, { ref: arrowRef, context, fill: "black" })
|
|
46
|
+
) : /* @__PURE__ */ React.createElement(React.Fragment, null));
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export { Tooltip, Tooltip as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CalendarDate, getLocalTimeZone } from '@internationalized/date';
|
|
2
|
+
import React from 'react';
|
|
2
3
|
|
|
3
4
|
const getNameInitials = (name) => {
|
|
4
5
|
const nameSplit = name.split(" ");
|
|
@@ -18,5 +19,8 @@ const dateToCalendarDate = (value) => {
|
|
|
18
19
|
const calendarDateToDate = (value) => {
|
|
19
20
|
return value.toDate(getLocalTimeZone());
|
|
20
21
|
};
|
|
22
|
+
function cloneWithProps(children, triggerProps) {
|
|
23
|
+
return React.cloneElement(/* @__PURE__ */ React.createElement("div", null, children), triggerProps);
|
|
24
|
+
}
|
|
21
25
|
|
|
22
|
-
export { calendarDateToDate, dateToCalendarDate, getNameInitials };
|
|
26
|
+
export { calendarDateToDate, cloneWithProps, dateToCalendarDate, getNameInitials };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useFloating, autoUpdate, offset, flip, shift, arrow } from '@floating-ui/react';
|
|
3
|
+
|
|
4
|
+
const useFloatingLogic = ({
|
|
5
|
+
placement,
|
|
6
|
+
trigger,
|
|
7
|
+
arrowRef
|
|
8
|
+
}) => {
|
|
9
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
10
|
+
const { x, y, strategy, refs, update, context, floatingStyles } = useFloating(
|
|
11
|
+
{
|
|
12
|
+
placement,
|
|
13
|
+
whileElementsMounted: autoUpdate,
|
|
14
|
+
middleware: [
|
|
15
|
+
offset(10),
|
|
16
|
+
flip({
|
|
17
|
+
flipAlignment: true,
|
|
18
|
+
fallbackPlacements: ["right", "bottom", "left", "top"]
|
|
19
|
+
}),
|
|
20
|
+
shift(),
|
|
21
|
+
...arrowRef ? [arrow({ element: arrowRef })] : []
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (isOpen) update();
|
|
27
|
+
}, [isOpen, update]);
|
|
28
|
+
const triggerProps = {
|
|
29
|
+
ref: refs.setReference,
|
|
30
|
+
...trigger === "hover" && {
|
|
31
|
+
onMouseEnter: () => setIsOpen(true),
|
|
32
|
+
onMouseLeave: () => setIsOpen(false)
|
|
33
|
+
},
|
|
34
|
+
...trigger === "click" && {
|
|
35
|
+
onClick: () => setIsOpen((prev) => !prev)
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
isOpen,
|
|
40
|
+
setIsOpen,
|
|
41
|
+
x,
|
|
42
|
+
y,
|
|
43
|
+
strategy,
|
|
44
|
+
refs,
|
|
45
|
+
context,
|
|
46
|
+
floatingStyles,
|
|
47
|
+
triggerProps
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { useFloatingLogic };
|
package/dist/esm/index.js
CHANGED
|
@@ -8,17 +8,25 @@ export { Card } from './components/Card.js';
|
|
|
8
8
|
export { DatePickerInput } from './components/DatePickerInput.js';
|
|
9
9
|
export { DateRangePickerInput } from './components/DateRangePickerInput.js';
|
|
10
10
|
export { DefaultSnack } from './components/DefaultSnack.js';
|
|
11
|
+
export { Divider } from './components/Divider.js';
|
|
11
12
|
export { Drawer } from './components/Drawer.js';
|
|
12
13
|
export { GroupButton } from './components/GroupButton.js';
|
|
13
14
|
export { Hint } from './components/Hint.js';
|
|
14
|
-
export { Input
|
|
15
|
+
export { Input } from './components/Input/index.js';
|
|
16
|
+
export { Menubar } from './components/Menubar/index.js';
|
|
15
17
|
export { Modal } from './components/Modal.js';
|
|
18
|
+
export { Popover } from './components/Popover/index.js';
|
|
16
19
|
export { ProgressBar } from './components/ProgressBar.js';
|
|
20
|
+
export { RadioButton } from './components/RadioButton.js';
|
|
17
21
|
export { RangeCalendar } from './components/RangeCalendar.js';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
export { Select } from './components/Select/index.js';
|
|
23
|
+
export { Skeleton } from './components/Skeleton.js';
|
|
24
|
+
export { TCell, TFoot, THead, THeadCell, TRow, TRowHeader, Table, Td } from './components/Table.js';
|
|
25
|
+
export { Tag } from './components/Tag.js';
|
|
26
|
+
export { TextArea } from './components/TextArea.js';
|
|
27
|
+
export { TimeFieldInput } from './components/TimeFieldInput.js';
|
|
28
|
+
export { Toggle } from './components/Toggle.js';
|
|
29
|
+
export { Tooltip } from './components/Tooltip.js';
|
|
22
30
|
export { useCalendar } from './hooks/useCalendar.js';
|
|
23
31
|
export { useCalendarCell } from './hooks/useCalendarCell.js';
|
|
24
32
|
export { useCalendarGrid } from './hooks/useCalendarGrid.js';
|
|
@@ -27,11 +35,5 @@ export { useDateRangePickerInput } from './hooks/useDateRangePickerInput.js';
|
|
|
27
35
|
export { useDebouncedState } from './hooks/useDebouncedState.js';
|
|
28
36
|
export { useOutsideClickListener } from './hooks/useOutsideClickListener.js';
|
|
29
37
|
export { useRangeCalendar } from './hooks/useRangeCalendar.js';
|
|
30
|
-
export {
|
|
31
|
-
export { Skeleton } from './components/Skeleton.js';
|
|
32
|
-
export { TCell, TFoot, THead, THeadCell, TRow, TRowHeader, Table, Td } from './components/Table.js';
|
|
33
|
-
export { Tag } from './components/Tag.js';
|
|
34
|
-
export { TextArea } from './components/TextArea.js';
|
|
35
|
-
export { TimeFieldInput } from './components/TimeFieldInput.js';
|
|
36
|
-
export { Toggle } from './components/Toggle.js';
|
|
38
|
+
export { useFloatingLogic } from './hooks/useFloatingLogic.js';
|
|
37
39
|
export { SnackbarSonner } from './service/SnackbarSonner.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const MenubarContext = createContext({
|
|
4
|
+
show: false,
|
|
5
|
+
setShow: () => void 0
|
|
6
|
+
});
|
|
7
|
+
const MenubarProvider = ({ children }) => {
|
|
8
|
+
const [show, setShow] = React.useState(false);
|
|
9
|
+
return /* @__PURE__ */ React.createElement(MenubarContext.Provider, { value: { show, setShow } }, children);
|
|
10
|
+
};
|
|
11
|
+
const useMenubar = () => {
|
|
12
|
+
const context = useContext(MenubarContext);
|
|
13
|
+
if (!context) {
|
|
14
|
+
throw new Error("useSnackbar must be used within a SnackbarProvider");
|
|
15
|
+
}
|
|
16
|
+
return [context.show, context.setShow];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { MenubarProvider, useMenubar };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import 'sonner';
|
|
3
|
+
import 'clsx';
|
|
4
|
+
import '@internationalized/date';
|
|
5
|
+
import '../components/Badge.js';
|
|
6
|
+
import '../components/BaseSnackbar.js';
|
|
7
|
+
import 'react-icons/md';
|
|
8
|
+
import '../components/Card.js';
|
|
9
|
+
import '../components/Button.js';
|
|
10
|
+
import 'react-aria';
|
|
11
|
+
import 'react-stately';
|
|
12
|
+
import '@floating-ui/react';
|
|
13
|
+
import '../components/CalendarCell.js';
|
|
14
|
+
import '@tecsinapse/cortex-core';
|
|
15
|
+
import 'react-icons/fa';
|
|
16
|
+
import 'react-icons/lia';
|
|
17
|
+
import '../components/Input/Box.js';
|
|
18
|
+
import '../components/Input/Face.js';
|
|
19
|
+
import '../components/Input/Left.js';
|
|
20
|
+
import '../components/Input/Mask.js';
|
|
21
|
+
import '../components/Input/Right.js';
|
|
22
|
+
import '../components/Input/Root.js';
|
|
23
|
+
import '../components/Input/Search.js';
|
|
24
|
+
import 'react-icons/io';
|
|
25
|
+
import '../components/GroupButton.js';
|
|
26
|
+
import '../components/Hint.js';
|
|
27
|
+
import './MenubarProvider.js';
|
|
28
|
+
import '../components/Menubar/Left.js';
|
|
29
|
+
import '../styles/menubar.js';
|
|
30
|
+
import '../components/Menubar/Right.js';
|
|
31
|
+
import '../components/Menubar/Dropdown.js';
|
|
32
|
+
import '../components/Menubar/MostUsed.js';
|
|
33
|
+
import '../components/Menubar/MostUsedItem.js';
|
|
34
|
+
import '../components/Menubar/Header.js';
|
|
35
|
+
import '../components/Menubar/Item.js';
|
|
36
|
+
import '../components/Menubar/SubItem.js';
|
|
37
|
+
import '../components/Modal.js';
|
|
38
|
+
import '../components/Popover/Context.js';
|
|
39
|
+
import '../styles/calendar-cell.js';
|
|
40
|
+
import '../styles/groupButton.js';
|
|
41
|
+
import '../styles/progressBar.js';
|
|
42
|
+
import '../components/RadioButton.js';
|
|
43
|
+
import '../components/Select/GroupedOptions.js';
|
|
44
|
+
import '../components/Select/context.js';
|
|
45
|
+
import '../components/Select/MultiGroupedOptions.js';
|
|
46
|
+
import '../components/Select/MultiOptions.js';
|
|
47
|
+
import '../components/Select/Options.js';
|
|
48
|
+
import '../components/Select/Trigger.js';
|
|
49
|
+
import '../components/Tag.js';
|
|
50
|
+
import '../components/TextArea.js';
|
|
51
|
+
import '../components/Toggle.js';
|
|
52
|
+
import '../components/Tooltip.js';
|
|
53
|
+
|
|
54
|
+
createContext(null);
|
|
@@ -9,28 +9,48 @@ import '../components/Card.js';
|
|
|
9
9
|
import '../components/Button.js';
|
|
10
10
|
import 'react-aria';
|
|
11
11
|
import 'react-stately';
|
|
12
|
+
import '@floating-ui/react';
|
|
12
13
|
import '../components/CalendarCell.js';
|
|
13
14
|
import '@tecsinapse/cortex-core';
|
|
14
15
|
import 'react-icons/fa';
|
|
15
16
|
import 'react-icons/lia';
|
|
16
|
-
import '../components/Input.js';
|
|
17
|
+
import '../components/Input/Box.js';
|
|
18
|
+
import '../components/Input/Face.js';
|
|
19
|
+
import '../components/Input/Left.js';
|
|
20
|
+
import '../components/Input/Mask.js';
|
|
21
|
+
import '../components/Input/Right.js';
|
|
22
|
+
import '../components/Input/Root.js';
|
|
23
|
+
import '../components/Input/Search.js';
|
|
17
24
|
import { DefaultSnack } from '../components/DefaultSnack.js';
|
|
18
25
|
import '../components/GroupButton.js';
|
|
19
26
|
import '../components/Hint.js';
|
|
27
|
+
import '../provider/MenubarProvider.js';
|
|
28
|
+
import '../provider/SnackbarProvider.js';
|
|
29
|
+
import '../components/Menubar/Left.js';
|
|
30
|
+
import '../styles/menubar.js';
|
|
31
|
+
import '../components/Menubar/Right.js';
|
|
32
|
+
import '../components/Menubar/Dropdown.js';
|
|
33
|
+
import '../components/Menubar/MostUsed.js';
|
|
34
|
+
import '../components/Menubar/MostUsedItem.js';
|
|
35
|
+
import '../components/Menubar/Header.js';
|
|
36
|
+
import '../components/Menubar/Item.js';
|
|
37
|
+
import '../components/Menubar/SubItem.js';
|
|
20
38
|
import '../components/Modal.js';
|
|
39
|
+
import '../components/Popover/Context.js';
|
|
21
40
|
import '../styles/calendar-cell.js';
|
|
22
41
|
import '../styles/groupButton.js';
|
|
23
42
|
import '../styles/progressBar.js';
|
|
24
|
-
import '
|
|
25
|
-
import 'react-icons/io5';
|
|
26
|
-
import 'tailwind-merge';
|
|
43
|
+
import '../components/RadioButton.js';
|
|
27
44
|
import '../components/Select/GroupedOptions.js';
|
|
28
45
|
import '../components/Select/context.js';
|
|
29
|
-
import '../components/Select/
|
|
46
|
+
import '../components/Select/MultiGroupedOptions.js';
|
|
47
|
+
import '../components/Select/MultiOptions.js';
|
|
48
|
+
import '../components/Select/Options.js';
|
|
30
49
|
import '../components/Select/Trigger.js';
|
|
31
50
|
import '../components/Tag.js';
|
|
32
51
|
import '../components/TextArea.js';
|
|
33
52
|
import '../components/Toggle.js';
|
|
53
|
+
import '../components/Tooltip.js';
|
|
34
54
|
|
|
35
55
|
class SnackbarSonner {
|
|
36
56
|
custom(Component, options) {
|