@expcat/tigercat-react 0.0.65 → 0.0.67
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/styles/index.css +4 -0
- package/dist/styles/index.d.mts +2 -0
- package/package.json +12 -9
- package/dist/chunk-2DOPHSZP.js +0 -32
- package/dist/chunk-2TS6X5RA.js +0 -73
- package/dist/chunk-2Y327ZU4.js +0 -493
- package/dist/chunk-3OF7XPIQ.js +0 -90
- package/dist/chunk-3WPKVV4N.js +0 -140
- package/dist/chunk-5FRENLDC.js +0 -194
- package/dist/chunk-5QKMQRCW.js +0 -89
- package/dist/chunk-5ZVSFIZD.js +0 -50
- package/dist/chunk-6MGEGOYJ.js +0 -108
- package/dist/chunk-6PUSRC6S.js +0 -68
- package/dist/chunk-72ZRDBXN.js +0 -25
- package/dist/chunk-77D7VQMG.js +0 -43
- package/dist/chunk-7P6PHSFM.js +0 -548
- package/dist/chunk-AG6GVQ5O.js +0 -271
- package/dist/chunk-AQ6DHCP6.js +0 -53
- package/dist/chunk-AQQRWISY.js +0 -184
- package/dist/chunk-C5EFBJBR.js +0 -540
- package/dist/chunk-D3I2SY7X.js +0 -301
- package/dist/chunk-DZJUFU55.js +0 -300
- package/dist/chunk-EI2GHMQS.js +0 -37
- package/dist/chunk-ENR3RIMM.js +0 -205
- package/dist/chunk-EQWQXURG.js +0 -18
- package/dist/chunk-EUHWE7MN.js +0 -267
- package/dist/chunk-FAKTU64M.js +0 -67
- package/dist/chunk-FQ6UHRAO.js +0 -499
- package/dist/chunk-GX74TC62.js +0 -54
- package/dist/chunk-HDDBBZQH.js +0 -321
- package/dist/chunk-IFY46RWU.js +0 -25
- package/dist/chunk-IQINYCU6.js +0 -99
- package/dist/chunk-IY4LEJYF.js +0 -78
- package/dist/chunk-JW64IJP2.js +0 -210
- package/dist/chunk-KUCFT2OA.js +0 -43
- package/dist/chunk-LNKI6HQ3.js +0 -152
- package/dist/chunk-LXA2YBAO.js +0 -38
- package/dist/chunk-MKWXJZ3T.js +0 -74
- package/dist/chunk-NEULKOYJ.js +0 -48
- package/dist/chunk-NI2WNZRT.js +0 -38
- package/dist/chunk-OFCKGWTS.js +0 -12
- package/dist/chunk-OTRGVENC.js +0 -305
- package/dist/chunk-P273E6XE.js +0 -219
- package/dist/chunk-Q3DPJHNM.js +0 -407
- package/dist/chunk-QFVE7GKD.js +0 -109
- package/dist/chunk-QL6OBKEN.js +0 -84
- package/dist/chunk-QL6UEG3U.js +0 -27
- package/dist/chunk-QORSSZX4.js +0 -144
- package/dist/chunk-R4JSBXGG.js +0 -12
- package/dist/chunk-R5BQHZWB.js +0 -698
- package/dist/chunk-R7MS42PL.js +0 -90
- package/dist/chunk-TB2UHDOZ.js +0 -19
- package/dist/chunk-TBIEWDY5.js +0 -175
- package/dist/chunk-TJFS44SH.js +0 -48
- package/dist/chunk-TZ26HQAW.js +0 -85
- package/dist/chunk-U4ZVEPYD.js +0 -71
- package/dist/chunk-UFAXJVMD.js +0 -120
- package/dist/chunk-VJJ76I7U.js +0 -19
- package/dist/chunk-VO4WDK4K.js +0 -37
- package/dist/chunk-VSF4DF7N.js +0 -84
- package/dist/chunk-VVO4V4IK.js +0 -56
- package/dist/chunk-WK5HN4OH.js +0 -113
- package/dist/chunk-XZDJ5FRB.js +0 -333
- package/dist/chunk-YE2M2HNM.js +0 -168
- package/dist/chunk-YYGTJKP5.js +0 -39
- package/dist/chunk-ZREFCRX3.js +0 -52
- package/dist/components/Alert.d.ts +0 -24
- package/dist/components/Alert.js +0 -10
- package/dist/components/Avatar.d.ts +0 -12
- package/dist/components/Avatar.js +0 -10
- package/dist/components/Badge.d.ts +0 -12
- package/dist/components/Badge.js +0 -10
- package/dist/components/Breadcrumb.d.ts +0 -13
- package/dist/components/Breadcrumb.js +0 -14
- package/dist/components/BreadcrumbItem.d.ts +0 -21
- package/dist/components/BreadcrumbItem.js +0 -11
- package/dist/components/Button.d.ts +0 -8
- package/dist/components/Button.js +0 -10
- package/dist/components/Card.d.ts +0 -33
- package/dist/components/Card.js +0 -10
- package/dist/components/Checkbox.d.ts +0 -48
- package/dist/components/Checkbox.js +0 -11
- package/dist/components/CheckboxGroup.d.ts +0 -39
- package/dist/components/CheckboxGroup.js +0 -14
- package/dist/components/Code.d.ts +0 -9
- package/dist/components/Code.js +0 -16
- package/dist/components/Col.d.ts +0 -7
- package/dist/components/Col.js +0 -11
- package/dist/components/ConfigProvider.d.ts +0 -14
- package/dist/components/ConfigProvider.js +0 -14
- package/dist/components/Container.d.ts +0 -13
- package/dist/components/Container.js +0 -10
- package/dist/components/Content.d.ts +0 -9
- package/dist/components/Content.js +0 -10
- package/dist/components/DatePicker.d.ts +0 -24
- package/dist/components/DatePicker.js +0 -10
- package/dist/components/Descriptions.d.ts +0 -53
- package/dist/components/Descriptions.js +0 -16
- package/dist/components/Divider.d.ts +0 -12
- package/dist/components/Divider.js +0 -10
- package/dist/components/Drawer.d.ts +0 -19
- package/dist/components/Drawer.js +0 -11
- package/dist/components/Dropdown.d.ts +0 -22
- package/dist/components/Dropdown.js +0 -16
- package/dist/components/DropdownItem.d.ts +0 -17
- package/dist/components/DropdownItem.js +0 -13
- package/dist/components/DropdownMenu.d.ts +0 -13
- package/dist/components/DropdownMenu.js +0 -10
- package/dist/components/Footer.d.ts +0 -9
- package/dist/components/Footer.js +0 -10
- package/dist/components/Form.d.ts +0 -56
- package/dist/components/Form.js +0 -14
- package/dist/components/FormItem.d.ts +0 -16
- package/dist/components/FormItem.js +0 -11
- package/dist/components/Header.d.ts +0 -9
- package/dist/components/Header.js +0 -10
- package/dist/components/Icon.d.ts +0 -9
- package/dist/components/Icon.js +0 -10
- package/dist/components/Input.d.ts +0 -28
- package/dist/components/Input.js +0 -10
- package/dist/components/Layout.d.ts +0 -9
- package/dist/components/Layout.js +0 -10
- package/dist/components/Link.d.ts +0 -10
- package/dist/components/Link.js +0 -10
- package/dist/components/List.d.ts +0 -94
- package/dist/components/List.js +0 -12
- package/dist/components/Loading.d.ts +0 -8
- package/dist/components/Loading.js +0 -10
- package/dist/components/Menu.d.ts +0 -35
- package/dist/components/Menu.js +0 -14
- package/dist/components/MenuItem.d.ts +0 -20
- package/dist/components/MenuItem.js +0 -11
- package/dist/components/MenuItemGroup.d.ts +0 -16
- package/dist/components/MenuItemGroup.js +0 -12
- package/dist/components/Message.d.ts +0 -44
- package/dist/components/Message.js +0 -20
- package/dist/components/Modal.d.ts +0 -41
- package/dist/components/Modal.js +0 -11
- package/dist/components/Notification.d.ts +0 -40
- package/dist/components/Notification.js +0 -20
- package/dist/components/Pagination.d.ts +0 -11
- package/dist/components/Pagination.js +0 -16
- package/dist/components/Popconfirm.d.ts +0 -34
- package/dist/components/Popconfirm.js +0 -10
- package/dist/components/Popover.d.ts +0 -14
- package/dist/components/Popover.js +0 -10
- package/dist/components/Progress.d.ts +0 -8
- package/dist/components/Progress.js +0 -10
- package/dist/components/Radio.d.ts +0 -20
- package/dist/components/Radio.js +0 -11
- package/dist/components/RadioGroup.d.ts +0 -28
- package/dist/components/RadioGroup.js +0 -14
- package/dist/components/Row.d.ts +0 -11
- package/dist/components/Row.js +0 -14
- package/dist/components/Select.d.ts +0 -23
- package/dist/components/Select.js +0 -10
- package/dist/components/Sidebar.d.ts +0 -9
- package/dist/components/Sidebar.js +0 -10
- package/dist/components/Skeleton.d.ts +0 -7
- package/dist/components/Skeleton.js +0 -10
- package/dist/components/Slider.d.ts +0 -12
- package/dist/components/Slider.js +0 -10
- package/dist/components/Space.d.ts +0 -11
- package/dist/components/Space.js +0 -10
- package/dist/components/Steps.d.ts +0 -31
- package/dist/components/Steps.js +0 -14
- package/dist/components/StepsItem.d.ts +0 -36
- package/dist/components/StepsItem.js +0 -10
- package/dist/components/SubMenu.d.ts +0 -20
- package/dist/components/SubMenu.js +0 -13
- package/dist/components/Switch.d.ts +0 -12
- package/dist/components/Switch.js +0 -10
- package/dist/components/TabPane.d.ts +0 -42
- package/dist/components/TabPane.js +0 -10
- package/dist/components/Table.d.ts +0 -46
- package/dist/components/Table.js +0 -10
- package/dist/components/Tabs.d.ts +0 -43
- package/dist/components/Tabs.js +0 -14
- package/dist/components/Tag.d.ts +0 -16
- package/dist/components/Tag.js +0 -10
- package/dist/components/Text.d.ts +0 -9
- package/dist/components/Text.js +0 -10
- package/dist/components/Textarea.d.ts +0 -13
- package/dist/components/Textarea.js +0 -10
- package/dist/components/TimePicker.d.ts +0 -28
- package/dist/components/TimePicker.js +0 -10
- package/dist/components/Timeline.d.ts +0 -47
- package/dist/components/Timeline.js +0 -10
- package/dist/components/Tooltip.d.ts +0 -15
- package/dist/components/Tooltip.js +0 -10
- package/dist/components/Tree.d.ts +0 -154
- package/dist/components/Tree.js +0 -16
- package/dist/components/Upload.d.ts +0 -16
- package/dist/components/Upload.js +0 -11
- package/dist/index.d.ts +0 -77
- package/dist/index.js +0 -364
package/dist/chunk-VSF4DF7N.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var tigercatCore = require('@expcat/tigercat-core');
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
|
|
7
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
-
|
|
9
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
10
|
-
|
|
11
|
-
// src/components/RadioGroup.tsx
|
|
12
|
-
var RadioGroupContext = React__default.default.createContext(null);
|
|
13
|
-
var RadioGroup = ({
|
|
14
|
-
value,
|
|
15
|
-
defaultValue,
|
|
16
|
-
name,
|
|
17
|
-
disabled = false,
|
|
18
|
-
size = "md",
|
|
19
|
-
onChange,
|
|
20
|
-
children,
|
|
21
|
-
className,
|
|
22
|
-
...props
|
|
23
|
-
}) => {
|
|
24
|
-
const [internalValue, setInternalValue] = React.useState(defaultValue);
|
|
25
|
-
const isControlled = value !== void 0;
|
|
26
|
-
const currentValue = isControlled ? value : internalValue;
|
|
27
|
-
const generatedNameRef = React.useRef(
|
|
28
|
-
`tiger-radio-group-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
29
|
-
);
|
|
30
|
-
const groupName = name || generatedNameRef.current;
|
|
31
|
-
const handleChange = (newValue) => {
|
|
32
|
-
if (disabled) return;
|
|
33
|
-
if (!isControlled) {
|
|
34
|
-
setInternalValue(newValue);
|
|
35
|
-
}
|
|
36
|
-
onChange?.(newValue);
|
|
37
|
-
};
|
|
38
|
-
const handleKeyDown = (event) => {
|
|
39
|
-
if (disabled) return;
|
|
40
|
-
if (event.key !== "ArrowDown" && event.key !== "ArrowRight" && event.key !== "ArrowUp" && event.key !== "ArrowLeft") {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const target = event.target;
|
|
44
|
-
const currentInput = target.closest('input[type="radio"]');
|
|
45
|
-
if (!currentInput) return;
|
|
46
|
-
const container = event.currentTarget;
|
|
47
|
-
const inputs = Array.from(
|
|
48
|
-
container.querySelectorAll('input[type="radio"]')
|
|
49
|
-
);
|
|
50
|
-
const enabledInputs = inputs.filter((input) => !input.disabled);
|
|
51
|
-
if (enabledInputs.length === 0) return;
|
|
52
|
-
const currentIndex = enabledInputs.indexOf(currentInput);
|
|
53
|
-
if (currentIndex === -1) return;
|
|
54
|
-
event.preventDefault();
|
|
55
|
-
const direction = event.key === "ArrowDown" || event.key === "ArrowRight" ? 1 : -1;
|
|
56
|
-
const nextIndex = (currentIndex + direction + enabledInputs.length) % enabledInputs.length;
|
|
57
|
-
const nextInput = enabledInputs[nextIndex];
|
|
58
|
-
nextInput.focus();
|
|
59
|
-
nextInput.click();
|
|
60
|
-
};
|
|
61
|
-
const contextValue = {
|
|
62
|
-
value: currentValue,
|
|
63
|
-
name: groupName,
|
|
64
|
-
disabled,
|
|
65
|
-
size,
|
|
66
|
-
onChange: handleChange
|
|
67
|
-
};
|
|
68
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RadioGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
69
|
-
"div",
|
|
70
|
-
{
|
|
71
|
-
className: tigercatCore.getRadioGroupClasses({
|
|
72
|
-
className,
|
|
73
|
-
hasCustomClass: !!className
|
|
74
|
-
}),
|
|
75
|
-
role: "radiogroup",
|
|
76
|
-
onKeyDown: handleKeyDown,
|
|
77
|
-
...props,
|
|
78
|
-
children
|
|
79
|
-
}
|
|
80
|
-
) });
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
exports.RadioGroup = RadioGroup;
|
|
84
|
-
exports.RadioGroupContext = RadioGroupContext;
|
package/dist/chunk-VVO4V4IK.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var tigercatCore = require('@expcat/tigercat-core');
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
|
|
6
|
-
// src/components/Switch.tsx
|
|
7
|
-
var Switch = ({
|
|
8
|
-
checked = false,
|
|
9
|
-
disabled = false,
|
|
10
|
-
size = "md",
|
|
11
|
-
onChange,
|
|
12
|
-
className,
|
|
13
|
-
onClick,
|
|
14
|
-
onKeyDown,
|
|
15
|
-
tabIndex,
|
|
16
|
-
...props
|
|
17
|
-
}) => {
|
|
18
|
-
const switchClasses = tigercatCore.classNames(tigercatCore.getSwitchClasses(size, checked, disabled), className);
|
|
19
|
-
const thumbClasses = tigercatCore.getSwitchThumbClasses(size, checked);
|
|
20
|
-
const toggle = () => {
|
|
21
|
-
if (disabled) return;
|
|
22
|
-
onChange?.(!checked);
|
|
23
|
-
};
|
|
24
|
-
const handleClick = (event) => {
|
|
25
|
-
onClick?.(event);
|
|
26
|
-
if (event.defaultPrevented) return;
|
|
27
|
-
toggle();
|
|
28
|
-
};
|
|
29
|
-
const handleKeyDown = (event) => {
|
|
30
|
-
onKeyDown?.(event);
|
|
31
|
-
if (event.defaultPrevented) return;
|
|
32
|
-
if (disabled) return;
|
|
33
|
-
if (event.key === " " || event.key === "Enter") {
|
|
34
|
-
event.preventDefault();
|
|
35
|
-
toggle();
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
39
|
-
"button",
|
|
40
|
-
{
|
|
41
|
-
...props,
|
|
42
|
-
type: "button",
|
|
43
|
-
role: "switch",
|
|
44
|
-
"aria-checked": checked,
|
|
45
|
-
className: switchClasses,
|
|
46
|
-
disabled,
|
|
47
|
-
onClick: handleClick,
|
|
48
|
-
onKeyDown: handleKeyDown,
|
|
49
|
-
"aria-disabled": disabled || void 0,
|
|
50
|
-
tabIndex: disabled ? -1 : tabIndex,
|
|
51
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: thumbClasses, "aria-hidden": "true" })
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
exports.Switch = Switch;
|
package/dist/chunk-WK5HN4OH.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
var tigercatCore = require('@expcat/tigercat-core');
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
|
|
7
|
-
// src/components/Tooltip.tsx
|
|
8
|
-
var tooltipIdCounter = 0;
|
|
9
|
-
var createTooltipId = () => `tiger-tooltip-${++tooltipIdCounter}`;
|
|
10
|
-
var Tooltip = ({
|
|
11
|
-
visible,
|
|
12
|
-
defaultVisible = false,
|
|
13
|
-
content,
|
|
14
|
-
trigger = "hover",
|
|
15
|
-
placement = "top",
|
|
16
|
-
disabled = false,
|
|
17
|
-
className,
|
|
18
|
-
style,
|
|
19
|
-
children,
|
|
20
|
-
contentContent,
|
|
21
|
-
onVisibleChange,
|
|
22
|
-
...divProps
|
|
23
|
-
}) => {
|
|
24
|
-
const isControlled = visible !== void 0;
|
|
25
|
-
const [internalVisible, setInternalVisible] = react.useState(defaultVisible);
|
|
26
|
-
const currentVisible = isControlled ? visible : internalVisible;
|
|
27
|
-
const containerRef = react.useRef(null);
|
|
28
|
-
const tooltipIdRef = react.useRef(null);
|
|
29
|
-
if (!tooltipIdRef.current) {
|
|
30
|
-
tooltipIdRef.current = createTooltipId();
|
|
31
|
-
}
|
|
32
|
-
const tooltipId = tooltipIdRef.current;
|
|
33
|
-
const tooltipContent = contentContent ?? content;
|
|
34
|
-
const describedBy = tooltipContent != null ? tooltipId : void 0;
|
|
35
|
-
const setVisible = react.useCallback(
|
|
36
|
-
(newVisible) => {
|
|
37
|
-
if (disabled && newVisible) return;
|
|
38
|
-
if (!isControlled) {
|
|
39
|
-
setInternalVisible(newVisible);
|
|
40
|
-
}
|
|
41
|
-
onVisibleChange?.(newVisible);
|
|
42
|
-
},
|
|
43
|
-
[disabled, isControlled, onVisibleChange]
|
|
44
|
-
);
|
|
45
|
-
const handleTriggerClick = () => {
|
|
46
|
-
if (disabled || trigger !== "click") return;
|
|
47
|
-
setVisible(!currentVisible);
|
|
48
|
-
};
|
|
49
|
-
const handleTriggerMouseEnter = () => {
|
|
50
|
-
if (disabled || trigger !== "hover") return;
|
|
51
|
-
setVisible(true);
|
|
52
|
-
};
|
|
53
|
-
const handleTriggerMouseLeave = () => {
|
|
54
|
-
if (disabled || trigger !== "hover") return;
|
|
55
|
-
setVisible(false);
|
|
56
|
-
};
|
|
57
|
-
const handleTriggerFocus = () => {
|
|
58
|
-
if (disabled || trigger !== "focus") return;
|
|
59
|
-
setVisible(true);
|
|
60
|
-
};
|
|
61
|
-
const handleTriggerBlur = () => {
|
|
62
|
-
if (disabled || trigger !== "focus") return;
|
|
63
|
-
setVisible(false);
|
|
64
|
-
};
|
|
65
|
-
react.useEffect(() => {
|
|
66
|
-
if (!currentVisible || trigger !== "click") return;
|
|
67
|
-
const handleClickOutside = (event) => {
|
|
68
|
-
const target = event.target;
|
|
69
|
-
if (!target) return;
|
|
70
|
-
if (containerRef.current?.contains(target)) return;
|
|
71
|
-
setVisible(false);
|
|
72
|
-
};
|
|
73
|
-
const timeoutId = setTimeout(() => {
|
|
74
|
-
document.addEventListener("click", handleClickOutside);
|
|
75
|
-
}, 0);
|
|
76
|
-
return () => {
|
|
77
|
-
clearTimeout(timeoutId);
|
|
78
|
-
document.removeEventListener("click", handleClickOutside);
|
|
79
|
-
};
|
|
80
|
-
}, [currentVisible, trigger, setVisible]);
|
|
81
|
-
react.useEffect(() => {
|
|
82
|
-
if (!currentVisible) return;
|
|
83
|
-
const handleKeyDown = (event) => {
|
|
84
|
-
if (event.key !== "Escape") return;
|
|
85
|
-
setVisible(false);
|
|
86
|
-
};
|
|
87
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
88
|
-
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
89
|
-
}, [currentVisible, setVisible]);
|
|
90
|
-
const containerClasses = tigercatCore.classNames(tigercatCore.getTooltipContainerClasses(), className);
|
|
91
|
-
const triggerClasses = tigercatCore.getTooltipTriggerClasses(disabled);
|
|
92
|
-
const contentWrapperClasses = tigercatCore.getDropdownMenuWrapperClasses(currentVisible, placement);
|
|
93
|
-
const contentClasses = tigercatCore.getTooltipContentClasses();
|
|
94
|
-
const triggerHandlers = {};
|
|
95
|
-
if (trigger === "click") {
|
|
96
|
-
triggerHandlers.onClick = handleTriggerClick;
|
|
97
|
-
} else if (trigger === "hover") {
|
|
98
|
-
triggerHandlers.onMouseEnter = handleTriggerMouseEnter;
|
|
99
|
-
triggerHandlers.onMouseLeave = handleTriggerMouseLeave;
|
|
100
|
-
} else if (trigger === "focus") {
|
|
101
|
-
triggerHandlers.onFocus = handleTriggerFocus;
|
|
102
|
-
triggerHandlers.onBlur = handleTriggerBlur;
|
|
103
|
-
}
|
|
104
|
-
if (!children) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: containerClasses, style, ...divProps, children: [
|
|
108
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: triggerClasses, "aria-describedby": describedBy, ...triggerHandlers, children }),
|
|
109
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: contentWrapperClasses, hidden: !currentVisible, "aria-hidden": !currentVisible, children: /* @__PURE__ */ jsxRuntime.jsx("div", { id: tooltipId, role: "tooltip", className: contentClasses, children: tooltipContent }) })
|
|
110
|
-
] });
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
exports.Tooltip = Tooltip;
|
package/dist/chunk-XZDJ5FRB.js
DELETED
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
var tigercatCore = require('@expcat/tigercat-core');
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
|
|
7
|
-
// src/components/Slider.tsx
|
|
8
|
-
var Thumb = react.memo(
|
|
9
|
-
({
|
|
10
|
-
value,
|
|
11
|
-
thumbType = null,
|
|
12
|
-
disabled,
|
|
13
|
-
tooltip,
|
|
14
|
-
showTooltip,
|
|
15
|
-
activeThumb,
|
|
16
|
-
isDragging,
|
|
17
|
-
min,
|
|
18
|
-
max,
|
|
19
|
-
ariaLabel,
|
|
20
|
-
ariaLabelledby,
|
|
21
|
-
ariaDescribedby,
|
|
22
|
-
thumbClassesCombined,
|
|
23
|
-
tooltipClassesCombined,
|
|
24
|
-
setShowTooltip,
|
|
25
|
-
handleStart,
|
|
26
|
-
handleKeyDown,
|
|
27
|
-
getPercentage
|
|
28
|
-
}) => {
|
|
29
|
-
const left = getPercentage(value);
|
|
30
|
-
const showThumbTooltip = showTooltip && (thumbType === activeThumb || thumbType === null);
|
|
31
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
32
|
-
"div",
|
|
33
|
-
{
|
|
34
|
-
className: thumbClassesCombined,
|
|
35
|
-
style: { left: `${left}%` },
|
|
36
|
-
tabIndex: disabled ? -1 : 0,
|
|
37
|
-
role: "slider",
|
|
38
|
-
"aria-valuenow": value,
|
|
39
|
-
"aria-valuemin": min,
|
|
40
|
-
"aria-valuemax": max,
|
|
41
|
-
"aria-orientation": "horizontal",
|
|
42
|
-
"aria-disabled": disabled,
|
|
43
|
-
"aria-label": ariaLabel,
|
|
44
|
-
"aria-labelledby": ariaLabelledby,
|
|
45
|
-
"aria-describedby": ariaDescribedby,
|
|
46
|
-
onMouseDown: (e) => handleStart(e, thumbType),
|
|
47
|
-
onTouchStart: (e) => handleStart(e, thumbType),
|
|
48
|
-
onMouseEnter: () => {
|
|
49
|
-
if (tooltip) setShowTooltip(true);
|
|
50
|
-
},
|
|
51
|
-
onMouseLeave: () => {
|
|
52
|
-
if (!isDragging) setShowTooltip(false);
|
|
53
|
-
},
|
|
54
|
-
onKeyDown: (e) => handleKeyDown(e, value, thumbType),
|
|
55
|
-
children: showThumbTooltip && tooltip && /* @__PURE__ */ jsxRuntime.jsx("div", { className: tooltipClassesCombined, children: value })
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
var Slider = ({
|
|
61
|
-
value: controlledValue,
|
|
62
|
-
defaultValue,
|
|
63
|
-
min = 0,
|
|
64
|
-
max = 100,
|
|
65
|
-
step = 1,
|
|
66
|
-
disabled = false,
|
|
67
|
-
marks = false,
|
|
68
|
-
tooltip = true,
|
|
69
|
-
size = "md",
|
|
70
|
-
range = false,
|
|
71
|
-
onChange,
|
|
72
|
-
className,
|
|
73
|
-
...props
|
|
74
|
-
}) => {
|
|
75
|
-
const {
|
|
76
|
-
"aria-label": ariaLabel,
|
|
77
|
-
"aria-labelledby": ariaLabelledby,
|
|
78
|
-
"aria-describedby": ariaDescribedby,
|
|
79
|
-
...divProps
|
|
80
|
-
} = props;
|
|
81
|
-
const getInitialValue = () => {
|
|
82
|
-
if (controlledValue !== void 0) return controlledValue;
|
|
83
|
-
if (defaultValue !== void 0) return defaultValue;
|
|
84
|
-
return range ? [min, max] : min;
|
|
85
|
-
};
|
|
86
|
-
const [internalValue, setInternalValue] = react.useState(getInitialValue());
|
|
87
|
-
const [isDragging, setIsDragging] = react.useState(false);
|
|
88
|
-
const [activeThumb, setActiveThumb] = react.useState(null);
|
|
89
|
-
const [showTooltip, setShowTooltip] = react.useState(false);
|
|
90
|
-
const trackRef = react.useRef(null);
|
|
91
|
-
react.useEffect(() => {
|
|
92
|
-
if (controlledValue !== void 0) {
|
|
93
|
-
setInternalValue(controlledValue);
|
|
94
|
-
}
|
|
95
|
-
}, [controlledValue]);
|
|
96
|
-
const normalizeValue = react.useCallback(
|
|
97
|
-
(val) => {
|
|
98
|
-
const steps = Math.round((val - min) / step);
|
|
99
|
-
return Math.min(Math.max(min + steps * step, min), max);
|
|
100
|
-
},
|
|
101
|
-
[min, max, step]
|
|
102
|
-
);
|
|
103
|
-
const getPercentage = react.useCallback(
|
|
104
|
-
(val) => {
|
|
105
|
-
return (val - min) / (max - min) * 100;
|
|
106
|
-
},
|
|
107
|
-
[min, max]
|
|
108
|
-
);
|
|
109
|
-
const getValueFromPosition = react.useCallback(
|
|
110
|
-
(clientX) => {
|
|
111
|
-
if (!trackRef.current) return min;
|
|
112
|
-
const rect = trackRef.current.getBoundingClientRect();
|
|
113
|
-
const percentage = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
|
|
114
|
-
const rawValue = min + percentage * (max - min);
|
|
115
|
-
return normalizeValue(rawValue);
|
|
116
|
-
},
|
|
117
|
-
[min, max, normalizeValue]
|
|
118
|
-
);
|
|
119
|
-
const updateValue = react.useCallback(
|
|
120
|
-
(newValue) => {
|
|
121
|
-
setInternalValue(newValue);
|
|
122
|
-
onChange?.(newValue);
|
|
123
|
-
},
|
|
124
|
-
[onChange]
|
|
125
|
-
);
|
|
126
|
-
const handleMove = react.useCallback(
|
|
127
|
-
(event) => {
|
|
128
|
-
if (disabled || !isDragging) return;
|
|
129
|
-
const clientX = "touches" in event ? event.touches[0].clientX : event.clientX;
|
|
130
|
-
const newValue = getValueFromPosition(clientX);
|
|
131
|
-
if (range && Array.isArray(internalValue)) {
|
|
132
|
-
const [minVal, maxVal] = internalValue;
|
|
133
|
-
if (activeThumb === "min") {
|
|
134
|
-
updateValue([Math.min(newValue, maxVal), maxVal]);
|
|
135
|
-
} else if (activeThumb === "max") {
|
|
136
|
-
updateValue([minVal, Math.max(newValue, minVal)]);
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
updateValue(newValue);
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
[disabled, isDragging, activeThumb, range, internalValue, getValueFromPosition, updateValue]
|
|
143
|
-
);
|
|
144
|
-
const handleEnd = react.useCallback(() => {
|
|
145
|
-
setIsDragging(false);
|
|
146
|
-
setActiveThumb(null);
|
|
147
|
-
setShowTooltip(false);
|
|
148
|
-
}, []);
|
|
149
|
-
react.useEffect(() => {
|
|
150
|
-
if (isDragging) {
|
|
151
|
-
const handleMouseMove = (e) => handleMove(e);
|
|
152
|
-
const handleTouchMove = (e) => handleMove(e);
|
|
153
|
-
document.addEventListener("mousemove", handleMouseMove);
|
|
154
|
-
document.addEventListener("mouseup", handleEnd);
|
|
155
|
-
document.addEventListener("touchmove", handleTouchMove);
|
|
156
|
-
document.addEventListener("touchend", handleEnd);
|
|
157
|
-
return () => {
|
|
158
|
-
document.removeEventListener("mousemove", handleMouseMove);
|
|
159
|
-
document.removeEventListener("mouseup", handleEnd);
|
|
160
|
-
document.removeEventListener("touchmove", handleTouchMove);
|
|
161
|
-
document.removeEventListener("touchend", handleEnd);
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
}, [isDragging, handleMove, handleEnd]);
|
|
165
|
-
const handleStart = (event, thumb) => {
|
|
166
|
-
if (disabled) return;
|
|
167
|
-
event.preventDefault();
|
|
168
|
-
setIsDragging(true);
|
|
169
|
-
setActiveThumb(thumb);
|
|
170
|
-
if (tooltip) setShowTooltip(true);
|
|
171
|
-
};
|
|
172
|
-
const handleTrackClick = (e) => {
|
|
173
|
-
if (disabled) return;
|
|
174
|
-
const newValue = getValueFromPosition(e.clientX);
|
|
175
|
-
if (range && Array.isArray(internalValue)) {
|
|
176
|
-
const [minVal, maxVal] = internalValue;
|
|
177
|
-
const distToMin = Math.abs(newValue - minVal);
|
|
178
|
-
const distToMax = Math.abs(newValue - maxVal);
|
|
179
|
-
if (distToMin < distToMax) {
|
|
180
|
-
updateValue([newValue, maxVal]);
|
|
181
|
-
} else {
|
|
182
|
-
updateValue([minVal, newValue]);
|
|
183
|
-
}
|
|
184
|
-
} else {
|
|
185
|
-
updateValue(newValue);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
const handleKeyDown = (e, value, thumbType) => {
|
|
189
|
-
if (disabled) return;
|
|
190
|
-
let newValue = value;
|
|
191
|
-
if (e.key === "ArrowRight" || e.key === "ArrowUp") {
|
|
192
|
-
e.preventDefault();
|
|
193
|
-
newValue = normalizeValue(value + step);
|
|
194
|
-
} else if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
|
|
195
|
-
e.preventDefault();
|
|
196
|
-
newValue = normalizeValue(value - step);
|
|
197
|
-
} else if (e.key === "Home") {
|
|
198
|
-
e.preventDefault();
|
|
199
|
-
newValue = min;
|
|
200
|
-
} else if (e.key === "End") {
|
|
201
|
-
e.preventDefault();
|
|
202
|
-
newValue = max;
|
|
203
|
-
} else {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (range && Array.isArray(internalValue)) {
|
|
207
|
-
const [minVal, maxVal] = internalValue;
|
|
208
|
-
if (thumbType === "min") {
|
|
209
|
-
updateValue([Math.min(newValue, maxVal), maxVal]);
|
|
210
|
-
} else if (thumbType === "max") {
|
|
211
|
-
updateValue([minVal, Math.max(newValue, minVal)]);
|
|
212
|
-
}
|
|
213
|
-
} else {
|
|
214
|
-
updateValue(newValue);
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
const trackStyles = tigercatCore.getSliderTrackClasses(size, disabled);
|
|
218
|
-
const rangeStyles = range && Array.isArray(internalValue) ? {
|
|
219
|
-
left: `${getPercentage(internalValue[0])}%`,
|
|
220
|
-
width: `${getPercentage(internalValue[1]) - getPercentage(internalValue[0])}%`
|
|
221
|
-
} : {
|
|
222
|
-
left: "0%",
|
|
223
|
-
width: `${getPercentage(
|
|
224
|
-
typeof internalValue === "number" ? internalValue : internalValue[0]
|
|
225
|
-
)}%`
|
|
226
|
-
};
|
|
227
|
-
const thumbClassesCombined = tigercatCore.getSliderThumbClasses(size, disabled);
|
|
228
|
-
const tooltipClassesCombined = tigercatCore.getSliderTooltipClasses(size);
|
|
229
|
-
const renderMarks = () => {
|
|
230
|
-
if (!marks) return null;
|
|
231
|
-
const marksObj = typeof marks === "boolean" ? {} : marks;
|
|
232
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute w-full top-full mt-2", children: Object.entries(marksObj).map(([key, label]) => {
|
|
233
|
-
const value = Number(key);
|
|
234
|
-
const left = getPercentage(value);
|
|
235
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
236
|
-
"div",
|
|
237
|
-
{
|
|
238
|
-
className: "absolute text-xs text-[var(--tiger-text-muted,#6b7280)]",
|
|
239
|
-
style: { left: `${left}%`, transform: "translateX(-50%)" },
|
|
240
|
-
children: label
|
|
241
|
-
},
|
|
242
|
-
key
|
|
243
|
-
);
|
|
244
|
-
}) });
|
|
245
|
-
};
|
|
246
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
247
|
-
"div",
|
|
248
|
-
{
|
|
249
|
-
className: tigercatCore.classNames(tigercatCore.sliderBaseClasses, disabled && "cursor-not-allowed", className),
|
|
250
|
-
...divProps,
|
|
251
|
-
children: [
|
|
252
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { ref: trackRef, className: trackStyles, onClick: handleTrackClick, children: [
|
|
253
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.sliderRangeClasses, style: rangeStyles }),
|
|
254
|
-
range && Array.isArray(internalValue) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
255
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
256
|
-
Thumb,
|
|
257
|
-
{
|
|
258
|
-
value: internalValue[0],
|
|
259
|
-
thumbType: "min",
|
|
260
|
-
disabled,
|
|
261
|
-
tooltip,
|
|
262
|
-
showTooltip,
|
|
263
|
-
activeThumb,
|
|
264
|
-
isDragging,
|
|
265
|
-
size,
|
|
266
|
-
min,
|
|
267
|
-
max,
|
|
268
|
-
ariaLabel: ariaLabel ? `${ariaLabel} (min)` : "Minimum value",
|
|
269
|
-
ariaLabelledby,
|
|
270
|
-
ariaDescribedby,
|
|
271
|
-
thumbClassesCombined,
|
|
272
|
-
tooltipClassesCombined,
|
|
273
|
-
setShowTooltip,
|
|
274
|
-
handleStart,
|
|
275
|
-
handleKeyDown,
|
|
276
|
-
getPercentage
|
|
277
|
-
}
|
|
278
|
-
),
|
|
279
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
280
|
-
Thumb,
|
|
281
|
-
{
|
|
282
|
-
value: internalValue[1],
|
|
283
|
-
thumbType: "max",
|
|
284
|
-
disabled,
|
|
285
|
-
tooltip,
|
|
286
|
-
showTooltip,
|
|
287
|
-
activeThumb,
|
|
288
|
-
isDragging,
|
|
289
|
-
size,
|
|
290
|
-
min,
|
|
291
|
-
max,
|
|
292
|
-
ariaLabel: ariaLabel ? `${ariaLabel} (max)` : "Maximum value",
|
|
293
|
-
ariaLabelledby,
|
|
294
|
-
ariaDescribedby,
|
|
295
|
-
thumbClassesCombined,
|
|
296
|
-
tooltipClassesCombined,
|
|
297
|
-
setShowTooltip,
|
|
298
|
-
handleStart,
|
|
299
|
-
handleKeyDown,
|
|
300
|
-
getPercentage
|
|
301
|
-
}
|
|
302
|
-
)
|
|
303
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
304
|
-
Thumb,
|
|
305
|
-
{
|
|
306
|
-
value: typeof internalValue === "number" ? internalValue : internalValue[0],
|
|
307
|
-
disabled,
|
|
308
|
-
tooltip,
|
|
309
|
-
showTooltip,
|
|
310
|
-
activeThumb,
|
|
311
|
-
isDragging,
|
|
312
|
-
size,
|
|
313
|
-
min,
|
|
314
|
-
max,
|
|
315
|
-
ariaLabel,
|
|
316
|
-
ariaLabelledby,
|
|
317
|
-
ariaDescribedby,
|
|
318
|
-
thumbClassesCombined,
|
|
319
|
-
tooltipClassesCombined,
|
|
320
|
-
setShowTooltip,
|
|
321
|
-
handleStart,
|
|
322
|
-
handleKeyDown,
|
|
323
|
-
getPercentage
|
|
324
|
-
}
|
|
325
|
-
)
|
|
326
|
-
] }),
|
|
327
|
-
renderMarks()
|
|
328
|
-
]
|
|
329
|
-
}
|
|
330
|
-
);
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
exports.Slider = Slider;
|