pixelize-design-library 2.4.2-beta.24 → 2.4.2-beta.26
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/Components/Accordion/Accordion.js +3 -1
- package/dist/Components/Button/Button.js +2 -1
- package/dist/Components/Button/Button.styles.js +7 -7
- package/dist/Components/Card/PaymentCard/PaymentCard.js +7 -7
- package/dist/Components/Checkbox/Checkbox.styles.js +10 -7
- package/dist/Components/CopyButton/CopyButton.js +5 -1
- package/dist/Components/Dropdown/DropDown.js +4 -2
- package/dist/Components/EmptyState/EmptyState.js +2 -1
- package/dist/Components/FileUpload/FileUpload.js +4 -4
- package/dist/Components/FileUpload/FileUploadProps.d.ts +1 -0
- package/dist/Components/FilterSidebar/filterHoverStyle.d.ts +0 -9
- package/dist/Components/FilterSidebar/filterHoverStyle.js +4 -10
- package/dist/Components/Header/components/mobileMenu.js +12 -3
- package/dist/Components/Loading/Loading.js +15 -14
- package/dist/Components/NoteTextArea/NoteTextArea.js +5 -2
- package/dist/Components/NumberInput/NumberInput.js +3 -1
- package/dist/Components/PdfViewer/PdfViewer.js +6 -1
- package/dist/Components/ProductCard/ProductReview.js +6 -1
- package/dist/Components/ProductCard/ProductTags.js +1 -1
- package/dist/Components/RadioButton/RadioButton.js +2 -1
- package/dist/Components/ScrollToTop/ScrollToTop.js +2 -0
- package/dist/Components/Search/Search.js +2 -2
- package/dist/Components/SearchSelect/SearchSelect.js +10 -6
- package/dist/Components/SegmentedControl/SegmentedControl.d.ts +2 -0
- package/dist/Components/SegmentedControl/SegmentedControl.js +58 -0
- package/dist/Components/SegmentedControl/SegmentedControlProps.d.ts +16 -0
- package/dist/Components/SegmentedControl/SegmentedControlProps.js +2 -0
- package/dist/Components/Select/Select.d.ts +1 -1
- package/dist/Components/Select/Select.js +4 -2
- package/dist/Components/Select/SelectProps.d.ts +3 -0
- package/dist/Components/SelectSearch/SelectSearch.js +4 -1
- package/dist/Components/SelectV2/SelectV2.js +5 -3
- package/dist/Components/SideBar/SideBar.js +1 -1
- package/dist/Components/SideBar/components/MenuPopoverContent.js +2 -2
- package/dist/Components/Slider/Slider.js +8 -1
- package/dist/Components/StageProgress/StepperStage.js +2 -2
- package/dist/Components/Table/components/Pagination.js +1 -1
- package/dist/Components/Table/settings/ManageColumns.js +2 -1
- package/dist/Components/Tag/Tag.styles.js +3 -4
- package/dist/Components/Toggle/TableToggle.js +11 -7
- package/dist/Components/ToggleSwitch/ToggleSwitch.d.ts +2 -0
- package/dist/Components/ToggleSwitch/ToggleSwitch.js +18 -0
- package/dist/Components/ToggleSwitch/ToggleSwitchProps.d.ts +11 -0
- package/dist/Components/ToggleSwitch/ToggleSwitchProps.js +2 -0
- package/dist/Components/ToolTip/ToolTip.js +6 -6
- package/dist/Components/ToolTip/ToolTipProps.d.ts +3 -1
- package/dist/esm/Components/Accordion/Accordion.js +3 -1
- package/dist/esm/Components/Button/Button.js +2 -1
- package/dist/esm/Components/Button/Button.styles.js +7 -7
- package/dist/esm/Components/Card/PaymentCard/PaymentCard.js +7 -7
- package/dist/esm/Components/Checkbox/Checkbox.styles.js +11 -8
- package/dist/esm/Components/CopyButton/CopyButton.js +6 -2
- package/dist/esm/Components/Dropdown/DropDown.js +4 -2
- package/dist/esm/Components/EmptyState/EmptyState.js +2 -1
- package/dist/esm/Components/FileUpload/FileUpload.js +4 -4
- package/dist/esm/Components/FilterSidebar/filterHoverStyle.js +4 -10
- package/dist/esm/Components/Header/components/mobileMenu.js +12 -3
- package/dist/esm/Components/Loading/Loading.js +12 -11
- package/dist/esm/Components/NoteTextArea/NoteTextArea.js +5 -2
- package/dist/esm/Components/NumberInput/NumberInput.js +4 -2
- package/dist/esm/Components/PdfViewer/PdfViewer.js +6 -1
- package/dist/esm/Components/ProductCard/ProductReview.js +6 -1
- package/dist/esm/Components/ProductCard/ProductTags.js +1 -1
- package/dist/esm/Components/RadioButton/RadioButton.js +2 -1
- package/dist/esm/Components/ScrollToTop/ScrollToTop.js +2 -0
- package/dist/esm/Components/Search/Search.js +2 -2
- package/dist/esm/Components/SearchSelect/SearchSelect.js +10 -6
- package/dist/esm/Components/SegmentedControl/SegmentedControl.js +55 -0
- package/dist/esm/Components/SegmentedControl/SegmentedControlProps.js +1 -0
- package/dist/esm/Components/Select/Select.js +5 -3
- package/dist/esm/Components/SelectSearch/SelectSearch.js +4 -1
- package/dist/esm/Components/SelectV2/SelectV2.js +5 -3
- package/dist/esm/Components/SideBar/SideBar.js +1 -1
- package/dist/esm/Components/SideBar/components/MenuPopoverContent.js +2 -2
- package/dist/esm/Components/Slider/Slider.js +8 -1
- package/dist/esm/Components/StageProgress/StepperStage.js +2 -2
- package/dist/esm/Components/Table/components/Pagination.js +1 -1
- package/dist/esm/Components/Table/settings/ManageColumns.js +2 -1
- package/dist/esm/Components/Tag/Tag.styles.js +3 -4
- package/dist/esm/Components/Toggle/TableToggle.js +11 -7
- package/dist/esm/Components/ToggleSwitch/ToggleSwitch.js +15 -0
- package/dist/esm/Components/ToggleSwitch/ToggleSwitchProps.js +1 -0
- package/dist/esm/Components/ToolTip/ToolTip.js +6 -6
- package/dist/esm/index.js +3 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +7 -3
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ const lucide_react_1 = require("lucide-react");
|
|
|
10
10
|
const useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
11
11
|
const ToolTip_1 = __importDefault(require("../ToolTip/ToolTip"));
|
|
12
12
|
const rafThrottle_1 = require("../../Utils/rafThrottle");
|
|
13
|
+
const accentText_1 = require("../../Theme/tokens/builders/accentText");
|
|
13
14
|
const ScrollToTop = ({ children, tooltipLabel = "Scroll to top", threshold = 300, duration = 600, useWindow = false, bottom = "2rem", right = "2rem", }) => {
|
|
14
15
|
const [visible, setVisible] = (0, react_1.useState)(false);
|
|
15
16
|
const anchorRef = (0, react_1.useRef)(null);
|
|
@@ -64,6 +65,7 @@ const ScrollToTop = ({ children, tooltipLabel = "Scroll to top", threshold = 300
|
|
|
64
65
|
}, [useWindow, threshold]);
|
|
65
66
|
return ((0, jsx_runtime_1.jsxs)(react_2.Box, { ref: anchorRef, position: "relative", children: [children, (0, jsx_runtime_1.jsx)(ToolTip_1.default, { label: tooltipLabel, placement: "left", children: (0, jsx_runtime_1.jsx)(react_2.Box, { as: "button", type: "button", onClick: scrollToTop, "aria-label": tooltipLabel, border: "none", position: "fixed", bottom: bottom, right: right, zIndex: 1000, display: "flex", alignItems: "center", justifyContent: "center", boxSize: "44px", borderRadius: "full", cursor: "pointer", bg: theme.colors.primary[500], color: theme.colors.onPrimary, boxShadow: "md", opacity: visible ? 1 : 0, transform: visible ? "translateY(0) scale(1)" : "translateY(16px) scale(0.85)", pointerEvents: visible ? "auto" : "none", transition: "all 0.25s cubic-bezier(0.16, 1, 0.3, 1)", _hover: {
|
|
66
67
|
bg: theme.colors.primary[600],
|
|
68
|
+
color: (0, accentText_1.onFilled)(theme.colors.primary[600], theme.colors.white, theme.colors.black),
|
|
67
69
|
transform: "translateY(-2px) scale(1.05)",
|
|
68
70
|
boxShadow: "lg",
|
|
69
71
|
}, _active: { transform: "scale(0.95)" }, children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronUp, { size: 24, strokeWidth: 2.5 }) }) })] }));
|
|
@@ -30,6 +30,6 @@ function Search({ placeholder = "Search...", onSearch, onclose, shortcut = "Ctrl
|
|
|
30
30
|
window.removeEventListener("keydown", handleKeyDown);
|
|
31
31
|
};
|
|
32
32
|
}, [shortcut]);
|
|
33
|
-
return ((0, jsx_runtime_1.jsxs)(react_2.FormControl, { id: id, isInvalid: !!error, children: [label && ((0, jsx_runtime_1.jsx)(FormLabel_1.TextLabel, { label: label, id: id, isInformation: isInformation, informationMessage: informationMessage, isRequired: isRequired })), (0, jsx_runtime_1.jsxs)(react_2.InputGroup, { w: "100%", children: [(0, jsx_runtime_1.jsx)(react_2.InputLeftElement, { pointerEvents: "none", children: (0, jsx_runtime_1.jsx)(react_2.Icon, { as: lucide_react_1.Search, color: theme.colors.
|
|
34
|
-
, gap: "2", children: [query && ((0, jsx_runtime_1.jsx)(react_2.Icon, { as: lucide_react_1.X, color: theme.colors.
|
|
33
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.FormControl, { id: id, isInvalid: !!error, children: [label && ((0, jsx_runtime_1.jsx)(FormLabel_1.TextLabel, { label: label, id: id, isInformation: isInformation, informationMessage: informationMessage, isRequired: isRequired })), (0, jsx_runtime_1.jsxs)(react_2.InputGroup, { w: "100%", children: [(0, jsx_runtime_1.jsx)(react_2.InputLeftElement, { pointerEvents: "none", children: (0, jsx_runtime_1.jsx)(react_2.Icon, { as: lucide_react_1.Search, color: theme.colors.textMuted }) }), (0, jsx_runtime_1.jsx)(react_2.Input, { ref: inputRef, type: "text", value: query, onChange: onSearch, placeholder: placeholder, variant: "outline", isInvalid: error }), (0, jsx_runtime_1.jsxs)(react_2.InputRightElement, { w: "auto", pr: "3", display: "flex", alignItems: "center" // ✅ centers vertically
|
|
34
|
+
, gap: "2", children: [query && ((0, jsx_runtime_1.jsx)(react_2.Icon, { as: lucide_react_1.X, color: theme.colors.textMuted, boxSize: 5, cursor: "pointer", onClick: onclose })), shortcut && ((0, jsx_runtime_1.jsx)(react_2.Text, { fontSize: "sm", color: theme.colors.textMuted, px: "2", py: "0.5", borderRadius: "md", bg: theme.colors.backgroundColor.subtle, children: shortcut }))] })] }), error && (0, jsx_runtime_1.jsx)(ErrorMessage_1.default, { errorMessage: errorMessage }), helperText && !error && (0, jsx_runtime_1.jsx)(HelperText_1.default, { helperText: helperText })] }));
|
|
35
35
|
}
|
|
@@ -44,6 +44,7 @@ const FormLabel_1 = require("../Common/FormLabel");
|
|
|
44
44
|
const Tag_1 = __importDefault(require("../Tag/Tag"));
|
|
45
45
|
const useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
46
46
|
const placeholderInk_1 = require("../../Theme/tokens/builders/placeholderInk");
|
|
47
|
+
const outlineRung_1 = require("../../Theme/tokens/builders/outlineRung");
|
|
47
48
|
const ErrorMessage_1 = __importDefault(require("../Common/ErrorMessage"));
|
|
48
49
|
const HelperText_1 = __importDefault(require("../Common/HelperText"));
|
|
49
50
|
const ToolTip_1 = __importDefault(require("../ToolTip/ToolTip"));
|
|
@@ -88,6 +89,9 @@ const SearchSelect = ({ id, label, options, onSelect, onSearch, isOptionLoading
|
|
|
88
89
|
width: 0,
|
|
89
90
|
});
|
|
90
91
|
const theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
92
|
+
const customSelectActiveTint = (0, react_1.useMemo)(() => (0, outlineRung_1.resolveHoverTint)(theme.colors.primary[500], theme.colors.background[400]), [theme.colors.primary, theme.colors.background]);
|
|
93
|
+
const dropdownActiveTint = (0, react_1.useMemo)(() => (0, outlineRung_1.resolveHoverTint)(theme.colors.primary[500], theme.colors.background[50]), [theme.colors.primary, theme.colors.background]);
|
|
94
|
+
const dropdownHoverTint = (0, react_1.useMemo)(() => (0, outlineRung_1.resolveHoverTint)(theme.colors.gray[50], theme.colors.background[50]), [theme.colors.gray, theme.colors.background]);
|
|
91
95
|
// `searchselect-dropdown-portal` is also the DOM id an existing outside-click check and
|
|
92
96
|
// several tests look up directly — kept as a literal constant, not derived from `baseId`,
|
|
93
97
|
// so those keep working unchanged.
|
|
@@ -489,7 +493,7 @@ const SearchSelect = ({ id, label, options, onSelect, onSearch, isOptionLoading
|
|
|
489
493
|
const insideLabel = (_a = insideSelect.value) === null || _a === void 0 ? void 0 : _a.label;
|
|
490
494
|
const insidePlaceholder = (_b = insideSelect.placeholder) !== null && _b !== void 0 ? _b : "Select";
|
|
491
495
|
return ((0, jsx_runtime_1.jsxs)(react_2.Box, { position: "relative", ref: customSelectRef, flexShrink: 0, ml: s.insideSelectMarginLeft, h: "-webkit-fill-available", borderRight: "0.063rem solid", borderColor: theme.colors.boxborder[200], bg: customSelectOpen
|
|
492
|
-
?
|
|
496
|
+
? customSelectActiveTint
|
|
493
497
|
: theme.colors.background[400], borderLeftRadius: "md", borderRightRadius: 0, transition: "background 0.15s ease, box-shadow 0.15s ease", boxShadow: customSelectOpen
|
|
494
498
|
? `inset 0 0 0 0.063rem ${theme.colors.primary[500]}`
|
|
495
499
|
: "none", onClick: (e) => {
|
|
@@ -502,11 +506,11 @@ const SearchSelect = ({ id, label, options, onSelect, onSearch, isOptionLoading
|
|
|
502
506
|
return ((0, jsx_runtime_1.jsxs)(react_2.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 2, minH: s.optionRowMinH, py: s.optionRowPy, px: "0.75rem", fontSize: s.dropdownTextFontSize, fontWeight: selected ? 600 : 500, color: selected
|
|
503
507
|
? theme.colors.accentText
|
|
504
508
|
: theme.colors.text[700], bg: selected
|
|
505
|
-
?
|
|
509
|
+
? dropdownActiveTint
|
|
506
510
|
: "transparent", _hover: {
|
|
507
511
|
bg: selected
|
|
508
|
-
?
|
|
509
|
-
:
|
|
512
|
+
? dropdownActiveTint
|
|
513
|
+
: dropdownHoverTint,
|
|
510
514
|
}, cursor: "pointer", onClick: (e) => {
|
|
511
515
|
e.stopPropagation();
|
|
512
516
|
handleCustomSelect(item);
|
|
@@ -546,9 +550,9 @@ const SearchSelect = ({ id, label, options, onSelect, onSearch, isOptionLoading
|
|
|
546
550
|
return !prev;
|
|
547
551
|
});
|
|
548
552
|
}, "aria-label": "toggle-dropdown", display: "flex", alignItems: "center", children: isOpen ? ((0, jsx_runtime_1.jsx)(lucide_react_1.ChevronUp, { size: s.chevronSize })) : ((0, jsx_runtime_1.jsx)(lucide_react_1.ChevronDown, { size: s.chevronSize })) }))] })] }) }), isOpen && ((0, jsx_runtime_1.jsx)(react_2.Portal, { children: (0, jsx_runtime_1.jsxs)(react_2.Box, { ref: setDropdownMenuRef, id: listboxId, role: "listbox", "aria-multiselectable": isMultiple || undefined, position: "fixed", top: `${dropdownPos.top}px`, left: `${dropdownPos.left}px`, width: `${dropdownPos.width}px`, zIndex: 1500, maxH: "20rem", borderWidth: 1, borderColor: theme.colors.boxborder[200], borderRadius: "sm", bg: theme.colors.background[50], boxShadow: "md", display: "flex", flexDirection: "column", children: [isMultiple && isSelectAll && ((0, jsx_runtime_1.jsxs)(react_2.Box, { py: s.optionRowPy, px: 3, cursor: "pointer", onClick: handleSelectAll, display: "flex", alignItems: "center", gap: 2, borderBottom: `0.063rem solid ${theme.colors.boxborder[200]}`, children: [(0, jsx_runtime_1.jsx)(Checkbox_1.default, { isChecked: allFilteredSelected, sx: { pointerEvents: "none" }, size: s.checkboxSize }), (0, jsx_runtime_1.jsx)(react_2.Text, { fontSize: s.dropdownTextFontSize, children: allFilteredSelected ? "Unselect All" : "Select All" })] })), (0, jsx_runtime_1.jsx)(react_2.Box, { flex: "1", overflowY: "auto", onScroll: handleScroll, maxH: "15rem", borderBottom: "0.063rem solid", borderColor: theme.colors.boxborder[200], children: isOptionLoading && filteredOptions.length === 0 ? ((0, jsx_runtime_1.jsxs)(react_2.Box, { py: s.optionRowPy, px: 3, display: "flex", alignItems: "center", gap: 2, minH: s.optionRowMinH, children: [(0, jsx_runtime_1.jsx)(react_2.Spinner, { size: s.spinnerSize }), (0, jsx_runtime_1.jsx)(react_2.Text, { fontSize: s.dropdownTextFontSize, children: loadingText })] })) : !isOptionLoading && filteredOptions.length === 0 ? ((0, jsx_runtime_1.jsx)(react_2.Text, { p: 3, fontSize: s.dropdownTextFontSize, color: theme.colors.textMuted, children: "No results found" })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [filteredOptions.map((option, index) => ((0, jsx_runtime_1.jsxs)(react_2.Box, { id: getOptionId(index), role: "option", "aria-selected": isSelected(option.id), py: s.optionRowPy, px: 3, minH: s.optionRowMinH, cursor: "pointer", bg: index === activeIndex
|
|
549
|
-
?
|
|
553
|
+
? dropdownActiveTint
|
|
550
554
|
: isSelected(option.id)
|
|
551
555
|
? theme.colors.gray[100]
|
|
552
|
-
: "transparent", _hover: { bg:
|
|
556
|
+
: "transparent", _hover: { bg: dropdownHoverTint }, onClick: () => handleSelect(option), onMouseEnter: () => setActiveIndex(index), display: "flex", alignItems: "center", gap: 2, borderBottom: `0.063rem solid ${theme.colors.boxborder[200]}`, children: [isMultiple && ((0, jsx_runtime_1.jsx)(Checkbox_1.default, { isChecked: isSelected(option.id), sx: { pointerEvents: "none" }, size: s.checkboxSize })), option.view ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: option.view })) : ((0, jsx_runtime_1.jsx)(react_2.Text, { fontSize: s.dropdownTextFontSize, children: option.label }))] }, option.id))), ((pagination === null || pagination === void 0 ? void 0 : pagination.scrollLoading) || (isOptionLoading && filteredOptions.length > 0)) && ((0, jsx_runtime_1.jsxs)(react_2.Box, { py: s.optionRowPy, px: 3, display: "flex", alignItems: "center", justifyContent: "center", gap: 2, minH: s.optionRowMinH, children: [(0, jsx_runtime_1.jsx)(react_2.Spinner, { size: s.spinnerSize }), (0, jsx_runtime_1.jsx)(react_2.Text, { fontSize: s.dropdownTextFontSize, children: loadingText })] }))] })) }), (addNew === null || addNew === void 0 ? void 0 : addNew.enabled) && ((0, jsx_runtime_1.jsxs)(react_2.Box, { py: s.optionRowPy, px: 3, borderTop: "0.063rem solid", borderColor: theme.colors.boxborder[200], bg: theme.colors.background[50], display: "flex", alignItems: "center", gap: 2, minH: s.optionRowMinH, cursor: "pointer", onClick: addNew.onClick, _hover: { bg: dropdownHoverTint }, children: [addNew.icon || (0, jsx_runtime_1.jsx)(lucide_react_1.Plus, { size: s.addNewIconSize }), (0, jsx_runtime_1.jsx)(react_2.Text, { fontSize: s.dropdownTextFontSize, children: addNew.text || "Add New" })] }))] }) })), helperText && !error && (0, jsx_runtime_1.jsx)(HelperText_1.default, { helperText: helperText }), error && (0, jsx_runtime_1.jsx)(ErrorMessage_1.default, { errorMessage: errorMessage })] }));
|
|
553
557
|
};
|
|
554
558
|
exports.default = SearchSelect;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = SegmentedControl;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_2 = require("@chakra-ui/react");
|
|
7
|
+
const useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
8
|
+
const SIZES = {
|
|
9
|
+
sm: { h: "1.625rem", px: "0.625rem", fontSize: "0.75rem" },
|
|
10
|
+
md: { h: "2rem", px: "0.875rem", fontSize: "0.8125rem" },
|
|
11
|
+
};
|
|
12
|
+
function SegmentedControl({ options, value, onChange, size = "md", isFullWidth = false, "aria-label": ariaLabel, }) {
|
|
13
|
+
const { colors } = (0, useCustomTheme_1.useCustomTheme)();
|
|
14
|
+
const dims = SIZES[size];
|
|
15
|
+
const refs = (0, react_1.useRef)([]);
|
|
16
|
+
const selectedIndex = options.findIndex((o) => o.value === value);
|
|
17
|
+
const enabled = options.reduce((acc, o, i) => (o.isDisabled ? acc : [...acc, i]), []);
|
|
18
|
+
// WAI-APG: with nothing selected, the first enabled segment owns the tab stop.
|
|
19
|
+
const tabIndex = selectedIndex >= 0 ? selectedIndex : enabled[0];
|
|
20
|
+
const selectAt = (index) => {
|
|
21
|
+
var _a;
|
|
22
|
+
(_a = refs.current[index]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
23
|
+
onChange(options[index].value);
|
|
24
|
+
};
|
|
25
|
+
const handleKeyDown = (event) => {
|
|
26
|
+
if (enabled.length === 0)
|
|
27
|
+
return;
|
|
28
|
+
const step = (delta) => {
|
|
29
|
+
const position = enabled.indexOf(tabIndex);
|
|
30
|
+
selectAt(enabled[(position + delta + enabled.length) % enabled.length]);
|
|
31
|
+
};
|
|
32
|
+
if (event.key === "ArrowRight" || event.key === "ArrowDown") {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
step(1);
|
|
35
|
+
}
|
|
36
|
+
else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
step(-1);
|
|
39
|
+
}
|
|
40
|
+
else if (event.key === "Home") {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
selectAt(enabled[0]);
|
|
43
|
+
}
|
|
44
|
+
else if (event.key === "End") {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
selectAt(enabled[enabled.length - 1]);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return ((0, jsx_runtime_1.jsx)(react_2.Flex, { role: "radiogroup", "aria-label": ariaLabel, onKeyDown: handleKeyDown, display: "inline-flex", align: "center", gap: "0.125rem", p: "0.125rem", borderRadius: "md", bg: colors.background[600], w: isFullWidth ? "100%" : "fit-content", children: options.map((option, index) => {
|
|
50
|
+
const isSelected = option.value === value;
|
|
51
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.Box, { as: "button", type: "button", ref: (node) => {
|
|
52
|
+
refs.current[index] = node;
|
|
53
|
+
}, role: "radio", "aria-checked": isSelected, disabled: option.isDisabled, tabIndex: index === tabIndex ? 0 : -1, onClick: () => onChange(option.value), display: "inline-flex", alignItems: "center", justifyContent: "center", gap: "0.375rem", flex: isFullWidth ? "1" : undefined, h: dims.h, px: dims.px, borderRadius: "base", borderWidth: "1px", borderStyle: "solid", borderColor: isSelected ? colors.background[400] : "transparent", bg: isSelected ? colors.background[50] : "transparent", boxShadow: isSelected ? "sm" : "none", color: isSelected ? colors.text[900] : colors.text[600], fontSize: dims.fontSize, fontWeight: isSelected ? 600 : 500, whiteSpace: "nowrap", opacity: option.isDisabled ? 0.5 : 1, cursor: option.isDisabled ? "not-allowed" : "pointer", transition: "background-color 0.2s ease, color 0.2s ease", _hover: option.isDisabled || isSelected ? undefined : { color: colors.text[900] }, _focusVisible: {
|
|
54
|
+
outline: "none",
|
|
55
|
+
boxShadow: `0 0 0 2px ${colors.primary[300]}`,
|
|
56
|
+
}, children: [option.icon, option.label] }, option.value));
|
|
57
|
+
}) }));
|
|
58
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type SegmentedControlSize = "sm" | "md";
|
|
2
|
+
export type SegmentedControlOption<T extends string = string> = {
|
|
3
|
+
value: T;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: JSX.Element;
|
|
6
|
+
isDisabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type SegmentedControlProps<T extends string = string> = {
|
|
9
|
+
/** Two to five mutually exclusive options. Beyond five, use a Select. */
|
|
10
|
+
options: SegmentedControlOption<T>[];
|
|
11
|
+
value: T;
|
|
12
|
+
onChange: (value: T) => void;
|
|
13
|
+
size?: SegmentedControlSize;
|
|
14
|
+
isFullWidth?: boolean;
|
|
15
|
+
"aria-label": string;
|
|
16
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { chakraSelectProps } from "./SelectProps";
|
|
2
|
-
export default function Select({ placeholder, size, variant, icon, onChange, onBlur, onFocus, errorBorderColor, isDisabled, isReadOnly, isRequired, value, colorScheme, label, error, errorMessage, helperText, options, height, formControlStyle, isInformation, informationMessage, selectStyle, }: chakraSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export default function Select({ placeholder, size, variant, icon, onChange, onBlur, onFocus, errorBorderColor, isDisabled, isReadOnly, isRequired, value, colorScheme, label, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, error, errorMessage, helperText, options, height, formControlStyle, isInformation, informationMessage, selectStyle, }: chakraSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,9 +11,11 @@ const textInputIconSize_1 = require("../Input/textInputIconSize");
|
|
|
11
11
|
const FormLabel_1 = require("../Common/FormLabel");
|
|
12
12
|
const ErrorMessage_1 = __importDefault(require("../Common/ErrorMessage"));
|
|
13
13
|
const HelperText_1 = __importDefault(require("../Common/HelperText"));
|
|
14
|
-
function Select({ placeholder = "Select Option", size = "md", variant = "outline", icon, onChange, onBlur, onFocus, errorBorderColor, isDisabled, isReadOnly, isRequired = false, value = "", colorScheme, label, error, errorMessage, helperText, options = [], height, formControlStyle, isInformation = false, informationMessage, selectStyle, }) {
|
|
14
|
+
function Select({ placeholder = "Select Option", size = "md", variant = "outline", icon, onChange, onBlur, onFocus, errorBorderColor, isDisabled, isReadOnly, isRequired = false, value = "", colorScheme, label, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, error, errorMessage, helperText, options = [], height, formControlStyle, isInformation = false, informationMessage, selectStyle, }) {
|
|
15
15
|
const sizeKey = typeof size === "string" ? size : "md";
|
|
16
16
|
const iconSizePx = (0, textInputIconSize_1.getTextInputIconSizePx)(sizeKey);
|
|
17
|
+
const generatedId = (0, react_1.useId)();
|
|
18
|
+
const selectId = id !== null && id !== void 0 ? id : (label ? generatedId : undefined);
|
|
17
19
|
const getOptionsList = (0, react_1.useCallback)(() => {
|
|
18
20
|
if (!options.length)
|
|
19
21
|
return (0, jsx_runtime_1.jsx)("option", { value: "", children: "No Options" });
|
|
@@ -26,5 +28,5 @@ function Select({ placeholder = "Select Option", size = "md", variant = "outline
|
|
|
26
28
|
onChange(selectedOption);
|
|
27
29
|
}
|
|
28
30
|
};
|
|
29
|
-
return ((0, jsx_runtime_1.jsxs)(react_2.FormControl, { isInvalid: error, style: formControlStyle, size: size, children: [label && ((0, jsx_runtime_1.jsx)(FormLabel_1.TextLabel, { label: label, isRequired: isRequired, isInformation: isInformation, informationMessage: informationMessage })), (0, jsx_runtime_1.jsx)(react_2.Select, { placeholder: placeholder, size: size, variant: variant, icon: icon, iconSize: `${iconSizePx}px`, isInvalid: error, value: value, onChange: handleOnChange, onBlur: onBlur, onFocus: onFocus, isDisabled: isDisabled, isReadOnly: isReadOnly, colorScheme: colorScheme, errorBorderColor: errorBorderColor, style: selectStyle, ...(height != null && height !== "" ? { minH: height, h: height } : {}), children: getOptionsList() }), error && (0, jsx_runtime_1.jsx)(ErrorMessage_1.default, { errorMessage: errorMessage }), helperText && !error && (0, jsx_runtime_1.jsx)(HelperText_1.default, { helperText: helperText })] }));
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.FormControl, { isInvalid: error, style: formControlStyle, size: size, children: [label && ((0, jsx_runtime_1.jsx)(FormLabel_1.TextLabel, { label: label, id: selectId, isRequired: isRequired, isInformation: isInformation, informationMessage: informationMessage })), (0, jsx_runtime_1.jsx)(react_2.Select, { id: selectId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, placeholder: placeholder, size: size, variant: variant, icon: icon, iconSize: `${iconSizePx}px`, isInvalid: error, value: value, onChange: handleOnChange, onBlur: onBlur, onFocus: onFocus, isDisabled: isDisabled, isReadOnly: isReadOnly, colorScheme: colorScheme, errorBorderColor: errorBorderColor, style: selectStyle, ...(height != null && height !== "" ? { minH: height, h: height } : {}), children: getOptionsList() }), error && (0, jsx_runtime_1.jsx)(ErrorMessage_1.default, { errorMessage: errorMessage }), helperText && !error && (0, jsx_runtime_1.jsx)(HelperText_1.default, { helperText: helperText })] }));
|
|
30
32
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { SelectProps } from "@chakra-ui/react";
|
|
2
2
|
export type chakraSelectProps = Pick<SelectProps, "placeholder" | "size" | "variant" | "icon" | "bg" | "borderColor" | "color" | "onBlur" | "onFocus" | "errorBorderColor" | "isDisabled" | "isReadOnly" | "isRequired" | "value" | "colorScheme"> & {
|
|
3
3
|
label?: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
"aria-label"?: string;
|
|
6
|
+
"aria-labelledby"?: string;
|
|
4
7
|
error?: boolean;
|
|
5
8
|
errorMessage?: string;
|
|
6
9
|
helperText?: string;
|
|
@@ -10,6 +10,7 @@ const react_2 = require("@chakra-ui/react");
|
|
|
10
10
|
const FormLabel_1 = require("../Common/FormLabel");
|
|
11
11
|
const fieldStyles_1 = require("../Common/fieldStyles");
|
|
12
12
|
const useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
13
|
+
const outlineRung_1 = require("../../Theme/tokens/builders/outlineRung");
|
|
13
14
|
const lucide_react_1 = require("lucide-react");
|
|
14
15
|
const ErrorMessage_1 = __importDefault(require("../Common/ErrorMessage"));
|
|
15
16
|
const RenderOptions = ({ isOptionLoading, filteredOptions, loadingText, handleOptionClick, isProfile, isColorOptions, isOptionSelected, activeIndex, optionRefs, }) => {
|
|
@@ -20,7 +21,9 @@ const RenderOptions = ({ isOptionLoading, filteredOptions, loadingText, handleOp
|
|
|
20
21
|
if (filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.length) {
|
|
21
22
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: filteredOptions.map((option, index) => ((0, jsx_runtime_1.jsxs)(react_2.Box, { as: "button", type: "button", ref: (el) => {
|
|
22
23
|
optionRefs.current[index] = el;
|
|
23
|
-
}, role: "option", "aria-selected": isOptionSelected(option), tabIndex: index === activeIndex ? 0 : -1, w: "100%", textAlign: "left", border: "none", fontFamily: "inherit", bg: "transparent", px: 4, py: 2, cursor: "pointer", _hover: {
|
|
24
|
+
}, role: "option", "aria-selected": isOptionSelected(option), tabIndex: index === activeIndex ? 0 : -1, w: "100%", textAlign: "left", border: "none", fontFamily: "inherit", bg: "transparent", px: 4, py: 2, cursor: "pointer", _hover: {
|
|
25
|
+
backgroundColor: (0, outlineRung_1.resolveHoverTint)(theme.colors.primary[500], theme.colors.background[50]),
|
|
26
|
+
}, onClick: () => handleOptionClick(option), onKeyDown: (e) => {
|
|
24
27
|
if (e.key === "Enter" || e.key === " ") {
|
|
25
28
|
e.preventDefault();
|
|
26
29
|
handleOptionClick(option);
|
|
@@ -43,6 +43,7 @@ const react_2 = require("@chakra-ui/react");
|
|
|
43
43
|
const lucide_react_1 = require("lucide-react");
|
|
44
44
|
const useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
45
45
|
const placeholderInk_1 = require("../../Theme/tokens/builders/placeholderInk");
|
|
46
|
+
const outlineRung_1 = require("../../Theme/tokens/builders/outlineRung");
|
|
46
47
|
const scrollbar_1 = require("../../Theme/tokens/builders/scrollbar");
|
|
47
48
|
const fieldStyles_1 = require("../Common/fieldStyles");
|
|
48
49
|
const FormLabel_1 = require("../Common/FormLabel");
|
|
@@ -57,10 +58,10 @@ const SIZE_MAP = {
|
|
|
57
58
|
const asIdSet = (values) => new Set((values !== null && values !== void 0 ? values : []).map((v) => v.toString()));
|
|
58
59
|
// Derived from the option's own id (not its index) so it stays stable across filtering/reordering.
|
|
59
60
|
const optionDomId = (listboxId, id) => `${listboxId}-option-${id.toString().replace(/[^a-zA-Z0-9_-]/g, "-")}`;
|
|
60
|
-
const OptionRow = react_1.default.memo(function OptionRow({ option, index, listboxId, isSelected, isActive, isMulti, theme, renderOption, onSelect, onActivate, }) {
|
|
61
|
+
const OptionRow = react_1.default.memo(function OptionRow({ option, index, listboxId, isSelected, isActive, isMulti, theme, activeBg, renderOption, onSelect, onActivate, }) {
|
|
61
62
|
return ((0, jsx_runtime_1.jsxs)(react_2.Box, { id: optionDomId(listboxId, option.id), "data-index": index, role: "option", "aria-selected": isSelected, "aria-disabled": option.isDisabled, onMouseEnter: () => onActivate(index), onClick: () => onSelect(option), mx: 1.5, px: 2.5, py: 1.5, borderRadius: "md", cursor: option.isDisabled ? "not-allowed" : "pointer", opacity: option.isDisabled ? 0.4 : 1, display: "flex", alignItems: "center", gap: 2, fontSize: "0.8125rem", fontWeight: isSelected && !isMulti ? 600 : 500, color: isSelected && !isMulti
|
|
62
63
|
? theme.colors.accentText
|
|
63
|
-
: theme.colors.text[700], bg: isActive ?
|
|
64
|
+
: theme.colors.text[700], bg: isActive ? activeBg : "transparent", transition: "background 0.12s ease, color 0.12s ease", children: [isMulti ? ((0, jsx_runtime_1.jsx)(react_2.Checkbox, { isChecked: isSelected, isDisabled: option.isDisabled, pointerEvents: "none", tabIndex: -1 })) : null, renderOption ? ((0, jsx_runtime_1.jsx)(react_2.Box, { flex: 1, minW: 0, children: renderOption(option, { isSelected, isActive }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [option.icon ? ((0, jsx_runtime_1.jsx)(react_2.Box, { as: "span", display: "inline-flex", flexShrink: 0, children: option.icon })) : null, (0, jsx_runtime_1.jsxs)(react_2.Box, { flex: 1, minW: 0, isTruncated: true, children: [(0, jsx_runtime_1.jsx)(react_2.Box, { as: "span", isTruncated: true, children: option.label }), option.description ? ((0, jsx_runtime_1.jsx)(react_2.Box, { as: "span", display: "block", fontSize: "0.75rem", fontWeight: 400, color: theme.colors.textMuted, isTruncated: true, children: option.description })) : null] })] }))] }));
|
|
64
65
|
});
|
|
65
66
|
function SelectV2(props) {
|
|
66
67
|
var _a, _b;
|
|
@@ -234,6 +235,7 @@ function SelectV2(props) {
|
|
|
234
235
|
const activeOption = filteredOptions[activeIndex];
|
|
235
236
|
const activeDescendantId = activeOption ? optionDomId(listboxId, activeOption.id) : undefined;
|
|
236
237
|
const listScrollStyles = (0, react_1.useMemo)(() => (0, scrollbar_1.scrollbarStyles)(theme.colors, "overlay"), [theme]);
|
|
238
|
+
const activeOptionBg = (0, react_1.useMemo)(() => (0, outlineRung_1.resolveHoverTint)(theme.colors.primary[500], theme.colors.backgroundColor.light), [theme]);
|
|
237
239
|
const defaultTriggerContent = () => {
|
|
238
240
|
var _a;
|
|
239
241
|
if (props.isMulti) {
|
|
@@ -253,6 +255,6 @@ function SelectV2(props) {
|
|
|
253
255
|
setActiveIndex(0);
|
|
254
256
|
}, "aria-activedescendant": activeDescendantId, "aria-label": "Filter options" }) })), (0, jsx_runtime_1.jsxs)(react_2.Box, { id: listboxId, ref: listRef, role: "listbox", "aria-multiselectable": props.isMulti || undefined, maxH: maxMenuHeight, overflowY: "auto", py: 1, sx: listScrollStyles, children: [filteredOptions.length === 0 && ((0, jsx_runtime_1.jsx)(react_2.Box, { px: 3, py: 2, fontSize: "0.8125rem", color: theme.colors.textMuted, children: "No Options" })), filteredOptions.map((option, index) => {
|
|
255
257
|
var _a;
|
|
256
|
-
return ((0, jsx_runtime_1.jsx)(OptionRow, { option: option, index: index, listboxId: listboxId, isSelected: selectedIds.has(option.id.toString()), isActive: index === activeIndex, isMulti: (_a = props.isMulti) !== null && _a !== void 0 ? _a : false, theme: theme, renderOption: renderOption, onSelect: handleSelect, onActivate: setActiveIndex }, option.id));
|
|
258
|
+
return ((0, jsx_runtime_1.jsx)(OptionRow, { option: option, index: index, listboxId: listboxId, isSelected: selectedIds.has(option.id.toString()), isActive: index === activeIndex, isMulti: (_a = props.isMulti) !== null && _a !== void 0 ? _a : false, theme: theme, activeBg: activeOptionBg, renderOption: renderOption, onSelect: handleSelect, onActivate: setActiveIndex }, option.id));
|
|
257
259
|
})] })] }) })] }), error && (0, jsx_runtime_1.jsx)(ErrorMessage_1.default, { errorMessage: errorMessage }), helperText && !error && (0, jsx_runtime_1.jsx)(HelperText_1.default, { helperText: helperText })] }));
|
|
258
260
|
}
|
|
@@ -81,7 +81,7 @@ const FooterControls = ({ toggle, overlay, mobileNav, onToggleCollapse, onToggle
|
|
|
81
81
|
return null;
|
|
82
82
|
return shell((0, jsx_runtime_1.jsx)(ControlCell, { onClick: onToggleMobileNav, label: "Show", accent: true, children: (0, jsx_runtime_1.jsx)(lucide_react_1.PanelLeft, { size: 14, color: activeAccent.icon }) }));
|
|
83
83
|
}
|
|
84
|
-
return shell((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ControlCell, { onClick: onToggleCollapse, ariaLabel: toggle ? "Expand sidebar" : undefined, label: toggle ? undefined : "Collapse", children: toggle ? ((0, jsx_runtime_1.jsx)(lucide_react_1.ArrowRightToLine, { size: 14, color: iconColor })) : ((0, jsx_runtime_1.jsx)(lucide_react_1.ArrowLeftToLine, { size: 14, color: iconColor })) }), onToggleMobileNav && ((0, jsx_runtime_1.jsx)(ControlCell, { onClick: onToggleMobileNav, label: toggle ? undefined : "Hide", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Maximize2, { size: 14, color: iconColor }) }))] }));
|
|
84
|
+
return shell((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ControlCell, { onClick: onToggleCollapse, ariaLabel: toggle ? "Expand sidebar" : undefined, label: toggle ? undefined : "Collapse", children: toggle ? ((0, jsx_runtime_1.jsx)(lucide_react_1.ArrowRightToLine, { size: 14, color: iconColor })) : ((0, jsx_runtime_1.jsx)(lucide_react_1.ArrowLeftToLine, { size: 14, color: iconColor })) }), onToggleMobileNav && ((0, jsx_runtime_1.jsx)(ControlCell, { onClick: onToggleMobileNav, ariaLabel: toggle ? "Show sidebar in overlay mode" : undefined, label: toggle ? undefined : "Hide", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Maximize2, { size: 14, color: iconColor }) }))] }));
|
|
85
85
|
};
|
|
86
86
|
// --- Main Sidebar component ---
|
|
87
87
|
function Sidebar({ menus, activeMenu, handleMenuClick, handleSecondaryNavClick, toggle, changeToggle, logo, companyName, companySubtitle, user, isDisableAddNew = false, onAddNewClick, selectedSubMenu, selectedSecondaryItem, isLoading, loadingLines, open = true, otherApps, mobileOpen = false, onMobileClose, mobileNav = false, onToggleMobileNav, peekOpen = false, onPeekEnd, }) {
|
|
@@ -16,7 +16,7 @@ const MenuPopoverContent = ({ menu, handleMenuClick, activeMenu, }) => {
|
|
|
16
16
|
const { title, icon, subMenu, badge, locked } = menu;
|
|
17
17
|
const hasSubMenu = !!(subMenu === null || subMenu === void 0 ? void 0 : subMenu.length);
|
|
18
18
|
const isParentActive = activeMenu === menu.id;
|
|
19
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_1.Flex, { as: (hasSubMenu ? "div" : "a"), href: hasSubMenu ? undefined : (_a = menu.url) !== null && _a !== void 0 ? _a : "#", "aria-current": !hasSubMenu && isParentActive ? "page" : undefined, textDecoration: "none", align: "center", gap: "8px", px: "8px", py: hasSubMenu ? "6px" : "8px", mb: hasSubMenu ? "4px" : 0, borderBottom: hasSubMenu ? "1px solid" : undefined, borderColor: hasSubMenu ? "whiteAlpha.100" : undefined, borderRadius: hasSubMenu ? "none" : "md", bg: !hasSubMenu && isParentActive ?
|
|
19
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_1.Flex, { as: (hasSubMenu ? "div" : "a"), href: hasSubMenu ? undefined : (_a = menu.url) !== null && _a !== void 0 ? _a : "#", "aria-current": !hasSubMenu && isParentActive ? "page" : undefined, textDecoration: "none", align: "center", gap: "8px", px: "8px", py: hasSubMenu ? "6px" : "8px", mb: hasSubMenu ? "4px" : 0, borderBottom: hasSubMenu ? "1px solid" : undefined, borderColor: hasSubMenu ? "whiteAlpha.100" : undefined, borderRadius: hasSubMenu ? "none" : "md", bg: !hasSubMenu && isParentActive ? "whiteAlpha.300" : "transparent", _hover: !hasSubMenu ? { bg: "whiteAlpha.100" } : undefined, onClick: (e) => {
|
|
20
20
|
if (!hasSubMenu) {
|
|
21
21
|
e.preventDefault();
|
|
22
22
|
handleMenuClick === null || handleMenuClick === void 0 ? void 0 : handleMenuClick(menu);
|
|
@@ -38,7 +38,7 @@ const MenuPopoverContent = ({ menu, handleMenuClick, activeMenu, }) => {
|
|
|
38
38
|
e.preventDefault();
|
|
39
39
|
if (!sub.disabled)
|
|
40
40
|
handleMenuClick === null || handleMenuClick === void 0 ? void 0 : handleMenuClick(sub);
|
|
41
|
-
}, px: "8px", py: "7px", mb: "2px", borderRadius: "md", align: "center", justify: "space-between", gap: "8px", borderLeft: "2px solid", borderLeftColor: isSubActive ? theme.colors.sidebar.activeIcon : "transparent", bg: isSubActive ?
|
|
41
|
+
}, px: "8px", py: "7px", mb: "2px", borderRadius: "md", align: "center", justify: "space-between", gap: "8px", borderLeft: "2px solid", borderLeftColor: isSubActive ? theme.colors.sidebar.activeIcon : "transparent", bg: isSubActive ? "whiteAlpha.300" : "transparent", _hover: {
|
|
42
42
|
bg: !sub.disabled ? "whiteAlpha.100" : "transparent",
|
|
43
43
|
cursor: !sub.disabled ? "pointer" : "not-allowed",
|
|
44
44
|
}, opacity: sub.disabled ? 0.5 : 1, pointerEvents: sub.disabled ? "none" : "auto", transition: "background 0.12s", children: [(0, jsx_runtime_1.jsxs)(react_1.Flex, { align: "center", gap: "9px", overflow: "hidden", flex: "1", children: [(0, jsx_runtime_1.jsx)(react_1.Icon, { as: sub.icon, fontSize: "0.95rem", flexShrink: 0, color: isSubActive ? activeAccent.icon : "whiteAlpha.800", _groupHover: isSubActive ? undefined : { color: "white" }, transition: "color 0.12s" }), (0, jsx_runtime_1.jsx)(TextTruncation_1.default, { fontSize: "12.5px", fontWeight: isSubActive ? 600 : 500, flex: 1, color: isSubActive ? activeAccent.label : theme.colors.white, _groupHover: isSubActive ? undefined : { color: "white" }, children: sub.title })] }), sub.locked ? ((0, jsx_runtime_1.jsx)(react_1.Icon, { as: lucide_react_1.LockKeyhole, fontSize: "1rem", color: theme.colors.sidebar.mutedIcon })) : (() => {
|
|
@@ -5,6 +5,8 @@ const react_1 = require("react");
|
|
|
5
5
|
const react_2 = require("@chakra-ui/react");
|
|
6
6
|
const lucide_react_1 = require("lucide-react");
|
|
7
7
|
const useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
8
|
+
const accentText_1 = require("../../Theme/tokens/builders/accentText");
|
|
9
|
+
const outlineRung_1 = require("../../Theme/tokens/builders/outlineRung");
|
|
8
10
|
const Slider = ({ images, interval = 5000, isArrow = false, mobileImages, }) => {
|
|
9
11
|
var _a, _b;
|
|
10
12
|
const { colors } = (0, useCustomTheme_1.useCustomTheme)();
|
|
@@ -34,10 +36,15 @@ const Slider = ({ images, interval = 5000, isArrow = false, mobileImages, }) =>
|
|
|
34
36
|
// eslint-disable-next-line
|
|
35
37
|
}, [slides.length]);
|
|
36
38
|
const ratio = (_b = (0, react_2.useBreakpointValue)({ base: 16 / 9, md: 21 / 9, lg: 21 / 9 })) !== null && _b !== void 0 ? _b : 16 / 9;
|
|
39
|
+
const chipBg = colors.background[50];
|
|
40
|
+
const chipInk = (0, accentText_1.onFilled)(chipBg, colors.white, colors.black);
|
|
41
|
+
const chipHoverBg = (0, outlineRung_1.resolveHoverTint)(colors.gray[200], chipBg);
|
|
42
|
+
const chipHoverInk = (0, accentText_1.onFilled)(chipHoverBg, colors.white, colors.black);
|
|
43
|
+
const dotInactiveInk = (0, outlineRung_1.liftToContrast)(colors.gray[400], chipBg, outlineRung_1.AA_NON_TEXT);
|
|
37
44
|
return ((0, jsx_runtime_1.jsxs)(react_2.Box, { position: "relative", w: "100%", h: "auto", overflow: "hidden", children: [(0, jsx_runtime_1.jsx)(react_2.Flex, { w: `${slides.length * 100}%`, transform: `translateX(-${(currentIndex * 100) / slides.length}%)`, transition: "transform 0.5s ease", children: [...slides]
|
|
38
45
|
.sort((a, b) => a.order - b.order)
|
|
39
46
|
.map((image, idx) => ((0, jsx_runtime_1.jsx)(react_2.Box, { w: `${100 / slides.length}%`, h: "auto", flexShrink: 0, display: "flex", justifyContent: "center", alignItems: "center", children: (0, jsx_runtime_1.jsx)(react_2.AspectRatio, { ratio: ratio, w: "100%", children: (0, jsx_runtime_1.jsx)(react_2.Image, { src: isMobile && image.mobilePreviewUrl
|
|
40
47
|
? image.mobilePreviewUrl
|
|
41
|
-
: image.previewUrl, alt: `Slide ${idx + 1}`, objectFit: "cover", w: "100%", h: "100%", loading: "lazy" }) }) }, image.id))) }), isArrow && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_2.IconButton, { icon: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, {
|
|
48
|
+
: image.previewUrl, alt: `Slide ${idx + 1}`, objectFit: "cover", w: "100%", h: "100%", loading: "lazy" }) }) }, image.id))) }), isArrow && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_2.IconButton, { icon: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, {}), "aria-label": "Previous Slide", onClick: prevSlide, position: "absolute", top: "50%", left: "1rem", transform: "translateY(-50%)", zIndex: 2, variant: "ghost", borderRadius: "full", bg: chipBg, color: chipInk, _hover: { bg: chipHoverBg, color: chipHoverInk } }), (0, jsx_runtime_1.jsx)(react_2.IconButton, { icon: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, {}), "aria-label": "Next Slide", onClick: nextSlide, position: "absolute", top: "50%", right: "1rem", transform: "translateY(-50%)", zIndex: 2, variant: "ghost", borderRadius: "full", bg: chipBg, color: chipInk, _hover: { bg: chipHoverBg, color: chipHoverInk } })] })), slides.length > 1 && ((0, jsx_runtime_1.jsx)(react_2.Flex, { position: "absolute", bottom: "1rem", left: "50%", transform: "translateX(-50%)", gap: "0.5rem", zIndex: 2, bg: chipBg, px: "0.6rem", py: "0.4rem", borderRadius: "full", children: slides.map((_, idx) => ((0, jsx_runtime_1.jsx)(react_2.Box, { as: "button", type: "button", w: { base: "0.5rem", md: "0.8rem" }, h: { base: "0.5rem", md: "0.8rem" }, border: "none", p: 0, bg: idx === currentIndex ? chipInk : dotInactiveInk, borderRadius: "full", cursor: "pointer", onClick: () => setCurrentIndex(idx), "aria-label": `Go to slide ${idx + 1}`, "aria-current": idx === currentIndex, transition: "all 0.3s", _focusVisible: { outline: `2px solid ${chipInk}`, outlineOffset: "2px" } }, idx))) }))] }));
|
|
42
49
|
};
|
|
43
50
|
exports.default = Slider;
|
|
@@ -34,7 +34,7 @@ const StepperStage = ({ label, number, state, size = "md", colorScheme = "primar
|
|
|
34
34
|
return ((0, jsx_runtime_1.jsxs)(react_2.Flex, { ref: ref, direction: "column", align: "center", flex: "1", minWidth: s.minW, flexShrink: 0, as: (interactive ? "button" : "div"), type: interactive ? "button" : undefined, "data-group": "", border: "none", bg: "transparent", cursor: interactive ? "pointer" : "default", opacity: disabled ? 0.55 : 1, onClick: interactive ? onClick : undefined, children: [(0, jsx_runtime_1.jsxs)(react_2.Flex, { align: "center", width: "100%", children: [line(leftDone, isFirst), (0, jsx_runtime_1.jsx)(react_2.Flex, { align: "center", justify: "center", boxSize: s.circle, borderRadius: "full", flexShrink: 0, bg: circleBg, color: circleColor, border: "2px solid", borderColor: circleBorder, fontSize: s.font, fontWeight: 600, transition: "all 0.18s ease", "aria-current": state === "active" ? "step" : undefined, sx: state === "active"
|
|
35
35
|
? { boxShadow: `0 0 0 4px ${palette.soft}` }
|
|
36
36
|
: undefined, _groupHover: interactive
|
|
37
|
-
? { borderColor: palette.strong,
|
|
38
|
-
: undefined, children: showCheck && state === "completed" ? (0, jsx_runtime_1.jsx)(lucide_react_1.Check, { size: s.icon }) : number }), line(rightDone, isLast)] }), (0, jsx_runtime_1.jsx)(react_2.Text, { mt: 2, px: 1, fontSize: s.label, fontWeight: state === "active" ? 600 : 500, color: state === "upcoming" ? palette.mutedText : palette.softText, textAlign: "center", noOfLines: 2, _groupHover: interactive ? {
|
|
37
|
+
? { borderColor: palette.strong, bg: palette.strong, color: palette.onStrong }
|
|
38
|
+
: undefined, children: showCheck && state === "completed" ? (0, jsx_runtime_1.jsx)(lucide_react_1.Check, { size: s.icon }) : number }), line(rightDone, isLast)] }), (0, jsx_runtime_1.jsx)(react_2.Text, { mt: 2, px: 1, borderRadius: "sm", fontSize: s.label, fontWeight: state === "active" ? 600 : 500, color: state === "upcoming" ? palette.mutedText : palette.softText, textAlign: "center", noOfLines: 2, transition: "background 0.18s ease, color 0.18s ease", _groupHover: interactive ? { bg: palette.strong, color: palette.onStrong } : undefined, children: label })] }));
|
|
39
39
|
};
|
|
40
40
|
exports.default = StepperStage;
|
|
@@ -52,6 +52,6 @@ const Pagination = react_1.default.memo(({ paginationText, handlePageSizeChange,
|
|
|
52
52
|
// const isRightDisabled = currentPage >= pages - 1;
|
|
53
53
|
const isLeftDisabled = dataLength === 0 || currentPage === 0;
|
|
54
54
|
const isRightDisabled = dataLength === 0 || currentPage >= pages - 1;
|
|
55
|
-
return ((0, jsx_runtime_1.jsxs)(react_2.Flex, { justify: "flex-end", align: "center", flexWrap: "nowrap", children: [(!isServerPagination || paginationSelectOptions) && ((0, jsx_runtime_1.jsxs)(react_2.Select, { onChange: handlePageSizeChange, value: rowsPerPage, size: "xs", borderRadius: "base", width: "auto", minW: "4.5rem", isDisabled: dataLength === 0, children: [!paginationSelectOptions && dataLength < 100 ? (0, jsx_runtime_1.jsx)("option", { value: 0 }) : null, computedOptions.map((size, index) => ((0, jsx_runtime_1.jsx)("option", { value: String(size), children: String(size) }, index)))] })), dataLength > 0 && ((0, jsx_runtime_1.jsxs)(react_2.Flex, { w: "100%", children: [(0, jsx_runtime_1.jsx)(ToolTip_1.default, { label: "First", placement: "top", children: (0, jsx_runtime_1.jsx)(react_2.IconButton, { "aria-label": "first-page", color: isLeftDisabled ? theme.colors.textMuted : theme.colors.text[500], rounded: "full", variant: isLeftDisabled ? "plain" : "ghost", onClick: () => setCurrentPage(0), _hover: !isLeftDisabled ? { color: theme.colors.accentText } : {}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsLeft, {}) }) }), (0, jsx_runtime_1.jsx)(ToolTip_1.default, { label: "Previous", placement: "top", children: (0, jsx_runtime_1.jsx)(react_2.IconButton, { "aria-label": "previous-page", color: isLeftDisabled ? theme.colors.textMuted : theme.colors.text[500], rounded: "full", variant: isLeftDisabled ? "plain" : "ghost", onClick: () => currentPage > 0 && setCurrentPage(currentPage - 1), _hover: !isLeftDisabled ? { color: theme.colors.accentText } : {}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, {}) }) }), (0, jsx_runtime_1.jsx)(react_2.Text, { mt: 3, fontSize: 12, whiteSpace: "nowrap", color: theme.colors.text[500], children: paginationText }), (0, jsx_runtime_1.jsx)(ToolTip_1.default, { label: "Next", placement: "top", children: (0, jsx_runtime_1.jsx)(react_2.IconButton, { "aria-label": "next-page", color: isRightDisabled ? theme.colors.textMuted : theme.colors.text[500], rounded: "full", variant: isRightDisabled ? "plain" : "ghost", onClick: () => currentPage < pages - 1 && setCurrentPage(currentPage + 1), _hover: !isRightDisabled ? { color: theme.colors.accentText } : {}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, {}) }) }), (0, jsx_runtime_1.jsx)(ToolTip_1.default, { label: "Last", placement: "top", children: (0, jsx_runtime_1.jsx)(react_2.IconButton, { "aria-label": "last-page", color: isRightDisabled ? theme.colors.textMuted : theme.colors.text[500], rounded: "full", variant: isRightDisabled ? "plain" : "ghost", onClick: () => setCurrentPage(pages - 1), _hover: !isRightDisabled ? { color: theme.colors.accentText } : {}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsRight, {}) }) })] }))] }));
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.Flex, { justify: "flex-end", align: "center", flexWrap: "nowrap", children: [(!isServerPagination || paginationSelectOptions) && ((0, jsx_runtime_1.jsxs)(react_2.Select, { "aria-label": "Rows per page", onChange: handlePageSizeChange, value: rowsPerPage, size: "xs", borderRadius: "base", width: "auto", minW: "4.5rem", isDisabled: dataLength === 0, children: [!paginationSelectOptions && dataLength < 100 ? (0, jsx_runtime_1.jsx)("option", { value: 0 }) : null, computedOptions.map((size, index) => ((0, jsx_runtime_1.jsx)("option", { value: String(size), children: String(size) }, index)))] })), dataLength > 0 && ((0, jsx_runtime_1.jsxs)(react_2.Flex, { w: "100%", children: [(0, jsx_runtime_1.jsx)(ToolTip_1.default, { label: "First", placement: "top", children: (0, jsx_runtime_1.jsx)(react_2.IconButton, { "aria-label": "first-page", color: isLeftDisabled ? theme.colors.textMuted : theme.colors.text[500], rounded: "full", variant: isLeftDisabled ? "plain" : "ghost", onClick: () => setCurrentPage(0), _hover: !isLeftDisabled ? { color: theme.colors.accentText } : {}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsLeft, {}) }) }), (0, jsx_runtime_1.jsx)(ToolTip_1.default, { label: "Previous", placement: "top", children: (0, jsx_runtime_1.jsx)(react_2.IconButton, { "aria-label": "previous-page", color: isLeftDisabled ? theme.colors.textMuted : theme.colors.text[500], rounded: "full", variant: isLeftDisabled ? "plain" : "ghost", onClick: () => currentPage > 0 && setCurrentPage(currentPage - 1), _hover: !isLeftDisabled ? { color: theme.colors.accentText } : {}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, {}) }) }), (0, jsx_runtime_1.jsx)(react_2.Text, { mt: 3, fontSize: 12, whiteSpace: "nowrap", color: theme.colors.text[500], children: paginationText }), (0, jsx_runtime_1.jsx)(ToolTip_1.default, { label: "Next", placement: "top", children: (0, jsx_runtime_1.jsx)(react_2.IconButton, { "aria-label": "next-page", color: isRightDisabled ? theme.colors.textMuted : theme.colors.text[500], rounded: "full", variant: isRightDisabled ? "plain" : "ghost", onClick: () => currentPage < pages - 1 && setCurrentPage(currentPage + 1), _hover: !isRightDisabled ? { color: theme.colors.accentText } : {}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, {}) }) }), (0, jsx_runtime_1.jsx)(ToolTip_1.default, { label: "Last", placement: "top", children: (0, jsx_runtime_1.jsx)(react_2.IconButton, { "aria-label": "last-page", color: isRightDisabled ? theme.colors.textMuted : theme.colors.text[500], rounded: "full", variant: isRightDisabled ? "plain" : "ghost", onClick: () => setCurrentPage(pages - 1), _hover: !isRightDisabled ? { color: theme.colors.accentText } : {}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsRight, {}) }) })] }))] }));
|
|
56
56
|
});
|
|
57
57
|
exports.default = Pagination;
|
|
@@ -9,6 +9,7 @@ const react_2 = require("@chakra-ui/react");
|
|
|
9
9
|
const Checkbox_1 = __importDefault(require("../../Checkbox/Checkbox"));
|
|
10
10
|
const useCustomTheme_1 = require("../../../Theme/useCustomTheme");
|
|
11
11
|
const scrollbar_1 = require("../../../Theme/tokens/builders/scrollbar");
|
|
12
|
+
const accentText_1 = require("../../../Theme/tokens/builders/accentText");
|
|
12
13
|
const lucide_react_1 = require("lucide-react");
|
|
13
14
|
const ManageColumns = ({ columns, items, setItems, childInputMethodsRef, }) => {
|
|
14
15
|
const theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
@@ -75,7 +76,7 @@ const ManageColumns = ({ columns, items, setItems, childInputMethodsRef, }) => {
|
|
|
75
76
|
setError(null);
|
|
76
77
|
}
|
|
77
78
|
};
|
|
78
|
-
return ((0, jsx_runtime_1.jsxs)(react_2.Box, { mt: 2, children: [error && ((0, jsx_runtime_1.jsx)(react_2.Box, { mb: 2, px: 3, py: 2, bg: theme.colors.red[50], borderRadius: "md", border: "1px solid", borderColor: theme.colors.red[200], children: (0, jsx_runtime_1.jsx)(react_2.Text, { color: theme.colors.red[
|
|
79
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.Box, { mt: 2, children: [error && ((0, jsx_runtime_1.jsx)(react_2.Box, { mb: 2, px: 3, py: 2, bg: theme.colors.red[50], borderRadius: "md", border: "1px solid", borderColor: theme.colors.red[200], children: (0, jsx_runtime_1.jsx)(react_2.Text, { color: (0, accentText_1.accentTextOnCanvas)(theme.colors.red, theme.colors.red[50]), fontSize: "xs", fontWeight: 500, children: error }) })), (0, jsx_runtime_1.jsx)(react_2.Input, { placeholder: "Search columns...", mb: 2, value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), size: "sm", borderRadius: "md" }), !searchTerm.length && ((0, jsx_runtime_1.jsx)(react_2.Flex, { align: "center", mb: 1, bg: theme.colors.gray[100], px: 2, py: 1, borderRadius: "md", children: (0, jsx_runtime_1.jsx)(Checkbox_1.default, { label: "Show all columns", isChecked: allChecked, isIndeterminate: someChecked, onChange: handleSelectAll }) })), (0, jsx_runtime_1.jsx)(react_2.List, { spacing: 0, maxH: "300px", overflowY: "auto", sx: (0, scrollbar_1.scrollbarStyles)(theme.colors), children: filteredItems.length > 0 ? (filteredItems.map((item, index) => {
|
|
79
80
|
const isDraggingThisItem = draggedItemIndex === index;
|
|
80
81
|
const isDropZone = draggedItemIndex !== null && draggedItemIndex !== index;
|
|
81
82
|
const realIndex = items.findIndex((i) => i.id === item.id);
|
|
@@ -74,13 +74,12 @@ exports.Tag = {
|
|
|
74
74
|
outline: ({ theme, colorScheme = "primary" }) => {
|
|
75
75
|
const c = swatch(theme, colorScheme);
|
|
76
76
|
const canvas = theme.colors.backgroundColor.main;
|
|
77
|
+
const ink = (0, accentText_1.accentTextOnCanvas)(c, canvas);
|
|
77
78
|
return {
|
|
78
79
|
container: {
|
|
79
80
|
border: "0.094rem solid",
|
|
80
|
-
borderColor:
|
|
81
|
-
|
|
82
|
-
// hues (orange 2.51, green 2.94, red 4.09); use the canvas-text helper instead.
|
|
83
|
-
color: (0, accentText_1.accentTextOnCanvas)(c, canvas),
|
|
81
|
+
borderColor: ink,
|
|
82
|
+
color: ink,
|
|
84
83
|
bg: "transparent",
|
|
85
84
|
_hover: { bg: c[50] },
|
|
86
85
|
_active: { bg: c[100] },
|
|
@@ -7,14 +7,18 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
7
7
|
const react_1 = require("@chakra-ui/react");
|
|
8
8
|
const lucide_react_1 = require("lucide-react");
|
|
9
9
|
const useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
10
|
+
const outlineRung_1 = require("../../Theme/tokens/builders/outlineRung");
|
|
10
11
|
const ToolTip_1 = __importDefault(require("../ToolTip/ToolTip"));
|
|
11
12
|
const TableToggle = ({ value, onChange }) => {
|
|
12
13
|
const theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
14
|
+
const { colors } = theme;
|
|
15
|
+
const restInk = (0, outlineRung_1.liftToContrast)(colors.background[800], colors.background[600], outlineRung_1.AA_NON_TEXT);
|
|
16
|
+
const hoverInk = (0, outlineRung_1.liftToContrast)(colors.background[900], colors.background[400], outlineRung_1.AA_NON_TEXT);
|
|
13
17
|
const styles = {
|
|
14
18
|
container: {
|
|
15
19
|
display: "flex",
|
|
16
20
|
alignItems: "center",
|
|
17
|
-
bg:
|
|
21
|
+
bg: colors.background[600],
|
|
18
22
|
p: "0.125rem",
|
|
19
23
|
borderRadius: "md",
|
|
20
24
|
height: "2rem",
|
|
@@ -22,19 +26,19 @@ const TableToggle = ({ value, onChange }) => {
|
|
|
22
26
|
width: "6.3rem",
|
|
23
27
|
},
|
|
24
28
|
button: (mode) => ({
|
|
25
|
-
bg: value === mode ?
|
|
29
|
+
bg: value === mode ? colors.background[50] : "transparent",
|
|
26
30
|
boxShadow: value === mode ? "md" : "none",
|
|
27
|
-
color: value === mode ?
|
|
31
|
+
color: value === mode ? colors.text[900] : restInk,
|
|
28
32
|
borderRadius: "base",
|
|
29
33
|
height: "1.75rem",
|
|
30
34
|
border: "0.031rem solid",
|
|
31
|
-
borderColor: value === mode ?
|
|
35
|
+
borderColor: value === mode ? colors.background[400] : "transparent",
|
|
32
36
|
padding: "0.313rem 0.813rem",
|
|
33
37
|
_hover: {
|
|
34
38
|
bg: value === mode
|
|
35
|
-
?
|
|
36
|
-
:
|
|
37
|
-
color: value === mode ?
|
|
39
|
+
? colors.background[50]
|
|
40
|
+
: colors.background[400],
|
|
41
|
+
color: value === mode ? colors.text[900] : hoverInk,
|
|
38
42
|
},
|
|
39
43
|
transition: "all 0.3s ease-in-out",
|
|
40
44
|
}),
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ToggleSwitch;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
7
|
+
const SIZES = {
|
|
8
|
+
sm: { w: "2rem", h: "1.125rem", knob: "0.875rem", travel: "0.75rem" },
|
|
9
|
+
md: { w: "2.375rem", h: "1.375rem", knob: "1.125rem", travel: "0.875rem" },
|
|
10
|
+
};
|
|
11
|
+
function ToggleSwitch({ isChecked, onChange, isDisabled = false, size = "md", id, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, }) {
|
|
12
|
+
const { colors } = (0, useCustomTheme_1.useCustomTheme)();
|
|
13
|
+
const dims = SIZES[size];
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Box, { as: "button", type: "button", id: id, role: "switch", "aria-checked": isChecked, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, disabled: isDisabled, onClick: () => onChange(!isChecked), position: "relative", display: "inline-flex", alignItems: "center", flexShrink: 0, w: dims.w, h: dims.h, p: 0, borderRadius: "full", borderWidth: "1px", borderStyle: "solid", borderColor: isChecked ? colors.primary[500] : colors.boxborder[500], bg: isChecked ? colors.primary[500] : colors.background[600], opacity: isDisabled ? 0.5 : 1, cursor: isDisabled ? "not-allowed" : "pointer", transition: "background-color 0.2s ease, border-color 0.2s ease", _focusVisible: {
|
|
15
|
+
outline: "none",
|
|
16
|
+
boxShadow: `0 0 0 2px ${colors.primary[300]}`,
|
|
17
|
+
}, children: (0, jsx_runtime_1.jsx)(react_1.Box, { "aria-hidden": "true", position: "absolute", left: "0.125rem", w: dims.knob, h: dims.knob, borderRadius: "full", bg: colors.background[50], boxShadow: "sm", transition: "transform 0.2s ease", transform: isChecked ? `translateX(${dims.travel})` : "translateX(0)" }) }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ToggleSwitchSize = "sm" | "md";
|
|
2
|
+
export type ToggleSwitchProps = {
|
|
3
|
+
isChecked: boolean;
|
|
4
|
+
onChange: (checked: boolean) => void;
|
|
5
|
+
isDisabled?: boolean;
|
|
6
|
+
size?: ToggleSwitchSize;
|
|
7
|
+
id?: string;
|
|
8
|
+
/** The control carries no visible text, so it has no other way to be named. */
|
|
9
|
+
"aria-label": string;
|
|
10
|
+
"aria-describedby"?: string;
|
|
11
|
+
};
|
|
@@ -7,18 +7,18 @@ const react_2 = require("@chakra-ui/react");
|
|
|
7
7
|
const useIsTruncated_1 = require("../../Hooks/useIsTruncated");
|
|
8
8
|
const mergeRefs_1 = require("../../Utils/mergeRefs");
|
|
9
9
|
const useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
10
|
-
|
|
10
|
+
const accentText_1 = require("../../Theme/tokens/builders/accentText");
|
|
11
|
+
function ToolTip({ placement = "top", label, children, hasArrow = true, fontSize = "14px", bg, color, isDisabled, overflowOnly = false, isOpen, defaultIsOpen, openDelay = 0, closeDelay = 0, arrowSize = 10, closeOnClick = false, size, width, height, arrowPadding, arrowShadowColor, direction, gutter = 8, onClose, modifiers, closeOnPointerDown, styles, }) {
|
|
11
12
|
// Measure the child for `overflowOnly`. The hook is always called (Rules of
|
|
12
13
|
// Hooks) but is fully inert unless `overflowOnly` is set — no layout reads,
|
|
13
14
|
// no ResizeObserver, no re-renders for ordinary tooltips. Measurement never
|
|
14
15
|
// runs on hover/scroll, so showing the tooltip stays as cheap as before.
|
|
15
16
|
const { ref, isTruncated } = (0, useIsTruncated_1.useIsTruncated)(label, overflowOnly && (0, react_1.isValidElement)(children));
|
|
16
|
-
//
|
|
17
|
-
// label. `sidebar.background` is the only ramp `buildDarkPalette` deliberately leaves
|
|
18
|
-
// un-inverted, so it stays near-black in dark mode and the white label stays legible —
|
|
19
|
-
// every other surface ramp flips light and would render the label invisible.
|
|
17
|
+
// `sidebar.background` stays near-black in both modes; ink is computed via `onFilled`.
|
|
20
18
|
const theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
21
19
|
const surface = theme.colors.sidebar.background[500];
|
|
20
|
+
const resolvedBg = bg !== null && bg !== void 0 ? bg : surface;
|
|
21
|
+
const resolvedColor = color !== null && color !== void 0 ? color : (0, accentText_1.onFilled)(resolvedBg, theme.colors.white, theme.colors.black);
|
|
22
22
|
let content = children;
|
|
23
23
|
let effectiveDisabled = isDisabled;
|
|
24
24
|
if (overflowOnly && (0, react_1.isValidElement)(children)) {
|
|
@@ -29,5 +29,5 @@ function ToolTip({ placement = "top", label, children, hasArrow = true, fontSize
|
|
|
29
29
|
});
|
|
30
30
|
effectiveDisabled = Boolean(isDisabled) || !isTruncated;
|
|
31
31
|
}
|
|
32
|
-
return ((0, jsx_runtime_1.jsx)(react_2.Tooltip, { label: label, placement: placement, hasArrow: hasArrow, fontSize: fontSize, bg:
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)(react_2.Tooltip, { label: label, placement: placement, hasArrow: hasArrow, fontSize: fontSize, bg: resolvedBg, color: resolvedColor, isDisabled: effectiveDisabled, isOpen: isOpen, defaultIsOpen: defaultIsOpen, openDelay: openDelay, closeDelay: closeDelay, arrowSize: arrowSize, closeOnClick: closeOnClick, size: size, width: width, height: height, arrowPadding: arrowPadding, arrowShadowColor: arrowShadowColor, direction: direction, gutter: gutter, onClose: onClose, modifiers: modifiers, closeOnPointerDown: closeOnPointerDown, style: styles, px: 3, py: 2, borderRadius: "lg", fontWeight: "400", lineHeight: "1.5", maxW: "300px", children: content }));
|
|
33
33
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { TooltipProps as ChakraTooltip } from "@chakra-ui/react";
|
|
2
|
-
export type ToolTipProps = Pick<ChakraTooltip, "placement" | "label" | "hasArrow" | "fontSize" | "
|
|
2
|
+
export type ToolTipProps = Pick<ChakraTooltip, "placement" | "label" | "hasArrow" | "fontSize" | "isDisabled" | "isOpen" | "defaultIsOpen" | "openDelay" | "closeDelay" | "arrowSize" | "closeOnClick" | "size" | "width" | "height" | "arrowPadding" | "arrowShadowColor" | "direction" | "gutter" | "onClose" | "modifiers" | "closeOnPointerDown"> & {
|
|
3
|
+
bg?: string;
|
|
4
|
+
color?: string;
|
|
3
5
|
children: React.ReactNode;
|
|
4
6
|
styles?: React.CSSProperties;
|
|
5
7
|
/**
|