@hellboy/ds 0.1.2 → 0.2.7
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/README.md +568 -71
- package/{src/style/components/badge → dist/components}/badge.css +9 -25
- package/dist/components/badge.d.mts +12 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +42 -0
- package/dist/components/badge.mjs +15 -0
- package/dist/components/banner.css +280 -0
- package/dist/components/banner.d.mts +12 -0
- package/dist/components/banner.d.ts +12 -0
- package/dist/components/banner.js +184 -0
- package/dist/components/banner.mjs +147 -0
- package/dist/components/button-group.css +289 -0
- package/dist/components/button-group.d.mts +81 -0
- package/dist/components/button-group.d.ts +81 -0
- package/dist/components/button-group.js +180 -0
- package/dist/components/button-group.mjs +143 -0
- package/{src/style/components/button → dist/components}/button.css +59 -62
- package/dist/components/button.d.mts +57 -0
- package/dist/components/button.d.ts +57 -0
- package/dist/components/button.js +129 -0
- package/dist/components/button.mjs +92 -0
- package/{src/style/components/card → dist/components}/card.css +9 -30
- package/dist/components/card.d.mts +31 -0
- package/dist/components/card.d.ts +31 -0
- package/dist/components/card.js +59 -0
- package/dist/components/card.mjs +32 -0
- package/{src/style → dist}/components/checkbox.css +51 -43
- package/dist/components/checkbox.d.mts +31 -0
- package/dist/components/checkbox.d.ts +31 -0
- package/dist/components/checkbox.js +130 -0
- package/dist/components/checkbox.mjs +93 -0
- package/{src/style/components/code-block → dist/components}/code-block.css +3 -7
- package/dist/components/code-block.d.mts +24 -0
- package/dist/components/code-block.d.ts +24 -0
- package/dist/components/code-block.js +43 -0
- package/dist/components/code-block.mjs +16 -0
- package/dist/components/color-control.css +285 -0
- package/dist/components/color-control.d.mts +5 -0
- package/dist/components/color-control.d.ts +5 -0
- package/dist/components/color-control.js +534 -0
- package/dist/components/color-control.mjs +497 -0
- package/dist/components/dialog.css +930 -0
- package/dist/components/dialog.d.mts +32 -0
- package/dist/components/dialog.d.ts +32 -0
- package/dist/components/dialog.js +1111 -0
- package/dist/components/dialog.mjs +1074 -0
- package/dist/components/divider.css +356 -0
- package/dist/components/divider.d.mts +32 -0
- package/dist/components/divider.d.ts +32 -0
- package/dist/components/divider.js +344 -0
- package/dist/components/divider.mjs +307 -0
- package/{src/style/components/drag-handle → dist/components}/drag-handle.css +3 -18
- package/dist/components/drag-handle.d.mts +11 -0
- package/dist/components/drag-handle.d.ts +11 -0
- package/dist/components/drag-handle.js +103 -0
- package/dist/components/drag-handle.mjs +66 -0
- package/dist/components/drawer.css +1027 -0
- package/dist/components/drawer.d.mts +14 -0
- package/dist/components/drawer.d.ts +14 -0
- package/dist/components/drawer.js +1072 -0
- package/dist/components/drawer.mjs +1035 -0
- package/dist/components/floating-bar.css +17 -0
- package/dist/components/floating-bar.d.mts +25 -0
- package/dist/components/floating-bar.d.ts +25 -0
- package/dist/components/floating-bar.js +52 -0
- package/dist/components/floating-bar.mjs +25 -0
- package/dist/components/footer.css +40 -0
- package/dist/components/footer.d.mts +8 -0
- package/dist/components/footer.d.ts +8 -0
- package/dist/components/footer.js +44 -0
- package/dist/components/footer.mjs +17 -0
- package/dist/components/grid.css +47 -0
- package/dist/components/grid.d.mts +27 -0
- package/dist/components/grid.d.ts +27 -0
- package/dist/components/grid.js +52 -0
- package/dist/components/grid.mjs +25 -0
- package/dist/components/header.css +1075 -0
- package/dist/components/header.d.mts +35 -0
- package/dist/components/header.d.ts +35 -0
- package/dist/components/header.js +1402 -0
- package/dist/components/header.mjs +1365 -0
- package/dist/components/hero.css +121 -0
- package/dist/components/hero.d.mts +111 -0
- package/dist/components/hero.d.ts +111 -0
- package/dist/components/hero.js +285 -0
- package/dist/components/hero.mjs +248 -0
- package/{src/style/components/icons → dist/components}/icons.css +14 -15
- package/dist/components/icons.d.mts +104 -0
- package/dist/components/icons.d.ts +104 -0
- package/dist/components/icons.js +239 -0
- package/dist/components/icons.mjs +203 -0
- package/{src/style/components/input → dist/components}/input.css +189 -102
- package/dist/components/input.d.mts +114 -0
- package/dist/components/input.d.ts +114 -0
- package/dist/components/input.js +926 -0
- package/dist/components/input.mjs +879 -0
- package/dist/components/layout.css +551 -0
- package/dist/components/layout.d.mts +16 -0
- package/dist/components/layout.d.ts +16 -0
- package/dist/components/layout.js +387 -0
- package/dist/components/layout.mjs +352 -0
- package/{src/style/components/list → dist/components}/list.css +47 -41
- package/dist/components/list.d.mts +46 -0
- package/dist/components/list.d.ts +46 -0
- package/dist/components/list.js +124 -0
- package/dist/components/list.mjs +96 -0
- package/dist/components/navbar.css +706 -0
- package/dist/components/navbar.d.mts +56 -0
- package/dist/components/navbar.d.ts +56 -0
- package/dist/components/navbar.js +994 -0
- package/dist/components/navbar.mjs +952 -0
- package/{src/style/components/page-index → dist/components}/page-index.css +2 -47
- package/dist/components/page-index.d.mts +25 -0
- package/dist/components/page-index.d.ts +25 -0
- package/dist/components/page-index.js +239 -0
- package/dist/components/page-index.mjs +202 -0
- package/{src/style/components/page → dist/components}/page.css +4 -15
- package/dist/components/page.d.mts +30 -0
- package/dist/components/page.d.ts +30 -0
- package/dist/components/page.js +40 -0
- package/dist/components/page.mjs +13 -0
- package/dist/components/popover.css +87 -0
- package/dist/components/popover.d.mts +22 -0
- package/dist/components/popover.d.ts +22 -0
- package/dist/components/popover.js +243 -0
- package/dist/components/popover.mjs +206 -0
- package/{src/style → dist}/components/radio.css +8 -51
- package/dist/components/radio.d.mts +59 -0
- package/dist/components/radio.d.ts +59 -0
- package/dist/components/radio.js +133 -0
- package/dist/components/radio.mjs +95 -0
- package/dist/components/section.css +993 -0
- package/dist/components/section.d.mts +33 -0
- package/dist/components/section.d.ts +33 -0
- package/dist/components/section.js +1401 -0
- package/dist/components/section.mjs +1364 -0
- package/dist/components/select.css +391 -0
- package/dist/components/select.d.mts +63 -0
- package/dist/components/select.d.ts +63 -0
- package/dist/components/select.js +452 -0
- package/dist/components/select.mjs +415 -0
- package/{src/style/components/slider → dist/components}/slider.css +55 -33
- package/dist/components/slider.d.mts +69 -0
- package/dist/components/slider.d.ts +69 -0
- package/dist/components/slider.js +254 -0
- package/dist/components/slider.mjs +217 -0
- package/dist/components/switch.css +1081 -0
- package/dist/components/switch.d.mts +33 -0
- package/dist/components/switch.d.ts +33 -0
- package/dist/components/switch.js +1092 -0
- package/dist/components/switch.mjs +1055 -0
- package/{src/style/components/table → dist/components}/table.css +3 -28
- package/dist/components/table.d.mts +42 -0
- package/dist/components/table.d.ts +42 -0
- package/dist/components/table.js +108 -0
- package/dist/components/table.mjs +76 -0
- package/dist/components/tag.css +97 -0
- package/dist/components/tag.d.mts +12 -0
- package/dist/components/tag.d.ts +12 -0
- package/dist/components/tag.js +42 -0
- package/dist/components/tag.mjs +15 -0
- package/dist/components/textarea.css +1359 -0
- package/dist/components/textarea.d.mts +84 -0
- package/dist/components/textarea.d.ts +84 -0
- package/dist/components/textarea.js +1962 -0
- package/dist/components/textarea.mjs +1924 -0
- package/{src/style/components/theme-control → dist/components}/theme-control.css +3 -7
- package/dist/components/theme-control.d.mts +9 -0
- package/dist/components/theme-control.d.ts +9 -0
- package/dist/components/theme-control.js +235 -0
- package/dist/components/theme-control.mjs +200 -0
- package/{src/style/components/tooltip → dist/components}/tooltip.css +5 -13
- package/dist/components/tooltip.d.mts +12 -0
- package/dist/components/tooltip.d.ts +12 -0
- package/dist/components/tooltip.js +200 -0
- package/dist/components/tooltip.mjs +163 -0
- package/dist/icons-Czahnf-r.d.mts +15 -0
- package/dist/icons-Czahnf-r.d.ts +15 -0
- package/dist/index.css +2915 -2068
- package/dist/index.d.mts +144 -721
- package/dist/index.d.ts +144 -721
- package/dist/index.js +4076 -2282
- package/dist/index.mjs +4132 -2366
- package/dist/theme.css +34 -34
- package/package.json +27 -8
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/hellboy-ds-0.1.2.tgz +0 -0
- package/src/components/badge/Badge.tsx +0 -29
- package/src/components/badge/index.ts +0 -1
- package/src/components/banner/Banner.tsx +0 -48
- package/src/components/banner/banner.css +0 -44
- package/src/components/banner/index.ts +0 -1
- package/src/components/button/button.tsx +0 -127
- package/src/components/button/index.ts +0 -1
- package/src/components/card/card.tsx +0 -57
- package/src/components/card/index.ts +0 -1
- package/src/components/checkbox/Checkbox.tsx +0 -98
- package/src/components/checkbox/index.ts +0 -1
- package/src/components/code-block/code-block.tsx +0 -44
- package/src/components/code-block/index.ts +0 -1
- package/src/components/color-control/color-control.tsx +0 -322
- package/src/components/color-control/index.ts +0 -1
- package/src/components/drag-handle/DragHandle.tsx +0 -78
- package/src/components/drag-handle/index.ts +0 -1
- package/src/components/drawer/drawer.tsx +0 -82
- package/src/components/drawer/index.ts +0 -1
- package/src/components/floating-bar/floating-bar.tsx +0 -52
- package/src/components/floating-bar/index.ts +0 -2
- package/src/components/footer/footer.tsx +0 -28
- package/src/components/footer/index.ts +0 -1
- package/src/components/grid/Grid.tsx +0 -53
- package/src/components/grid/index.ts +0 -1
- package/src/components/header/header.tsx +0 -57
- package/src/components/header/index.ts +0 -1
- package/src/components/icons/icons.tsx +0 -44
- package/src/components/icons/index.ts +0 -1
- package/src/components/index.ts +0 -29
- package/src/components/input/DatePicker.tsx +0 -133
- package/src/components/input/Input.tsx +0 -220
- package/src/components/input/InputDate.tsx +0 -10
- package/src/components/input/InputDateTime.tsx +0 -10
- package/src/components/input/InputEmail.tsx +0 -10
- package/src/components/input/InputField.tsx +0 -137
- package/src/components/input/InputNumber.tsx +0 -10
- package/src/components/input/InputPassword.tsx +0 -10
- package/src/components/input/InputSearch.tsx +0 -10
- package/src/components/input/InputTel.tsx +0 -10
- package/src/components/input/InputText.tsx +0 -10
- package/src/components/input/InputTime.tsx +0 -10
- package/src/components/input/InputUrl.tsx +0 -10
- package/src/components/input/TimePicker.tsx +0 -151
- package/src/components/input/index.ts +0 -11
- package/src/components/layout/Layout.tsx +0 -244
- package/src/components/layout/index.ts +0 -1
- package/src/components/list/List.tsx +0 -159
- package/src/components/list/index.ts +0 -1
- package/src/components/navbar/MenuCategory.tsx +0 -20
- package/src/components/navbar/MenuGroup.tsx +0 -288
- package/src/components/navbar/MenuItem.tsx +0 -65
- package/src/components/navbar/Navbar.tsx +0 -23
- package/src/components/navbar/index.ts +0 -4
- package/src/components/page/index.ts +0 -1
- package/src/components/page/page.tsx +0 -46
- package/src/components/page-index/PageIndex.tsx +0 -275
- package/src/components/page-index/index.ts +0 -1
- package/src/components/popover/index.ts +0 -1
- package/src/components/popover/popover.tsx +0 -199
- package/src/components/radio/Radio.tsx +0 -176
- package/src/components/radio/index.ts +0 -1
- package/src/components/section/index.ts +0 -1
- package/src/components/section/section.tsx +0 -66
- package/src/components/select/Select.tsx +0 -212
- package/src/components/select/index.ts +0 -1
- package/src/components/slider/Slider.tsx +0 -267
- package/src/components/slider/index.ts +0 -1
- package/src/components/switch/index.ts +0 -1
- package/src/components/switch/switch.tsx +0 -99
- package/src/components/table/Table.tsx +0 -147
- package/src/components/table/index.ts +0 -1
- package/src/components/theme-control/index.ts +0 -1
- package/src/components/theme-control/theme-control.tsx +0 -78
- package/src/components/tooltip/index.ts +0 -1
- package/src/components/tooltip/tooltip.tsx +0 -207
- package/src/contexts/NavbarTooltipContext.tsx +0 -48
- package/src/contexts/index.ts +0 -1
- package/src/foundations/motion.md +0 -136
- package/src/index.ts +0 -40
- package/src/style/_shared/field.css +0 -69
- package/src/style/components/color-control/color-control.css +0 -126
- package/src/style/components/drawer/drawer.css +0 -210
- package/src/style/components/floating-bar/floating-bar.css +0 -39
- package/src/style/components/footer/footer.css +0 -108
- package/src/style/components/grid/grid.css +0 -33
- package/src/style/components/header/header.css +0 -44
- package/src/style/components/layout/layout.css +0 -205
- package/src/style/components/navbar/navbar.css +0 -342
- package/src/style/components/popover/popover.css +0 -44
- package/src/style/components/section/section.css +0 -67
- package/src/style/components/select/select.css +0 -143
- package/src/style/components/switch/switch.css +0 -267
- package/src/style/foundations/global.css +0 -316
- package/src/style/foundations/motion.css +0 -164
- package/src/style/foundations/spacing.css +0 -51
- package/src/style/foundations/typography.css +0 -39
- package/src/style/foundations/z-index.css +0 -81
- package/src/style/modes/dark.css +0 -146
- package/src/style/modes/light.css +0 -147
- package/src/style/semantic.css +0 -52
- package/src/style/styles.css +0 -51
- package/src/style/themes/theme.json +0 -37
- package/src/utils/README.md +0 -305
- package/src/utils/USER_PREFERENCES.md +0 -558
- package/src/utils/theme.ts +0 -127
- package/src/utils/user-preferences.ts +0 -577
- package/tsconfig.json +0 -25
- package/tsup.config.ts +0 -52
|
@@ -0,0 +1,1962 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/components/textarea/index.ts
|
|
31
|
+
var textarea_exports = {};
|
|
32
|
+
__export(textarea_exports, {
|
|
33
|
+
RichTextarea: () => RichTextarea,
|
|
34
|
+
Textarea: () => Textarea
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(textarea_exports);
|
|
37
|
+
|
|
38
|
+
// src/components/textarea/RichTextarea.tsx
|
|
39
|
+
var React22 = __toESM(require("react"));
|
|
40
|
+
var import_dompurify = __toESM(require("dompurify"));
|
|
41
|
+
|
|
42
|
+
// src/components/floating-bar/floating-bar.tsx
|
|
43
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
+
var FloatingBar = ({
|
|
45
|
+
position = "bottom",
|
|
46
|
+
children,
|
|
47
|
+
className = "",
|
|
48
|
+
...props
|
|
49
|
+
}) => {
|
|
50
|
+
const classes = [
|
|
51
|
+
"floating-bar",
|
|
52
|
+
`floating-bar--${position}`,
|
|
53
|
+
className
|
|
54
|
+
].filter(Boolean).join(" ");
|
|
55
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
className: classes,
|
|
59
|
+
...props,
|
|
60
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "floating-bar__content", children })
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// src/components/select/Select.tsx
|
|
66
|
+
var React2 = __toESM(require("react"));
|
|
67
|
+
|
|
68
|
+
// src/components/icons/icons.tsx
|
|
69
|
+
var import_react = require("@iconify/react");
|
|
70
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
71
|
+
var Icon = ({ name, size = 24, className, loading = false, ...rest }) => {
|
|
72
|
+
const iconName = name.includes(":") ? name : `heroicons:${name}`;
|
|
73
|
+
const classes = ["icon", className].filter(Boolean).join(" ");
|
|
74
|
+
if (loading) {
|
|
75
|
+
const style = { width: size, height: size };
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
77
|
+
"span",
|
|
78
|
+
{
|
|
79
|
+
className: `${classes} icon--skeleton`,
|
|
80
|
+
style,
|
|
81
|
+
"aria-hidden": rest["aria-label"] ? "false" : "true",
|
|
82
|
+
...rest["aria-label"] ? { "aria-label": rest["aria-label"] } : {}
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
87
|
+
import_react.Icon,
|
|
88
|
+
{
|
|
89
|
+
icon: iconName,
|
|
90
|
+
width: size,
|
|
91
|
+
height: size,
|
|
92
|
+
className: classes,
|
|
93
|
+
...rest
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// src/components/popover/popover.tsx
|
|
99
|
+
var React = __toESM(require("react"));
|
|
100
|
+
var ReactDOM = __toESM(require("react-dom"));
|
|
101
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
102
|
+
var Popover = ({
|
|
103
|
+
trigger,
|
|
104
|
+
children,
|
|
105
|
+
isOpen,
|
|
106
|
+
onToggle,
|
|
107
|
+
placement = "bottom",
|
|
108
|
+
align = "start",
|
|
109
|
+
offset = 8,
|
|
110
|
+
flip = true,
|
|
111
|
+
closeOnEscape = true,
|
|
112
|
+
closeOnClickOutside = true
|
|
113
|
+
}) => {
|
|
114
|
+
const [internalOpen, setInternalOpen] = React.useState(false);
|
|
115
|
+
const triggerRef = React.useRef(null);
|
|
116
|
+
const popoverRef = React.useRef(null);
|
|
117
|
+
const [popoverStyle, setPopoverStyle] = React.useState({});
|
|
118
|
+
const [resolvedPlacement, setResolvedPlacement] = React.useState(placement);
|
|
119
|
+
const isControlled = isOpen !== void 0;
|
|
120
|
+
const open = isControlled ? isOpen : internalOpen;
|
|
121
|
+
const toggle = React.useCallback(() => {
|
|
122
|
+
if (isControlled) {
|
|
123
|
+
onToggle?.();
|
|
124
|
+
} else {
|
|
125
|
+
setInternalOpen((prev) => !prev);
|
|
126
|
+
}
|
|
127
|
+
}, [isControlled, onToggle]);
|
|
128
|
+
React.useEffect(() => {
|
|
129
|
+
const handleClickOutside = (event) => {
|
|
130
|
+
if (closeOnClickOutside && triggerRef.current && !triggerRef.current.contains(event.target) && popoverRef.current && !popoverRef.current.contains(event.target)) {
|
|
131
|
+
toggle();
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
if (open) {
|
|
135
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
136
|
+
}
|
|
137
|
+
return () => {
|
|
138
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
139
|
+
};
|
|
140
|
+
}, [open, toggle, closeOnClickOutside]);
|
|
141
|
+
React.useEffect(() => {
|
|
142
|
+
const handleEscapeKey = (event) => {
|
|
143
|
+
if (closeOnEscape && event.key === "Escape" && open) {
|
|
144
|
+
toggle();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
if (open) {
|
|
148
|
+
document.addEventListener("keydown", handleEscapeKey);
|
|
149
|
+
}
|
|
150
|
+
return () => {
|
|
151
|
+
document.removeEventListener("keydown", handleEscapeKey);
|
|
152
|
+
};
|
|
153
|
+
}, [open, toggle, closeOnEscape]);
|
|
154
|
+
React.useEffect(() => {
|
|
155
|
+
if (!open || !triggerRef.current || !popoverRef.current) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const updatePosition = () => {
|
|
159
|
+
if (!triggerRef.current || !popoverRef.current) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
163
|
+
const popoverRect = popoverRef.current.getBoundingClientRect();
|
|
164
|
+
const viewportWidth = window.innerWidth;
|
|
165
|
+
const viewportHeight = window.innerHeight;
|
|
166
|
+
const spaceTop = triggerRect.top;
|
|
167
|
+
const spaceBottom = viewportHeight - triggerRect.bottom;
|
|
168
|
+
const spaceLeft = triggerRect.left;
|
|
169
|
+
const spaceRight = viewportWidth - triggerRect.right;
|
|
170
|
+
let finalPlacement = placement;
|
|
171
|
+
if (flip) {
|
|
172
|
+
if (placement === "right" && spaceRight < popoverRect.width + offset) {
|
|
173
|
+
finalPlacement = spaceLeft >= popoverRect.width + offset ? "left" : "bottom";
|
|
174
|
+
} else if (placement === "left" && spaceLeft < popoverRect.width + offset) {
|
|
175
|
+
finalPlacement = spaceRight >= popoverRect.width + offset ? "right" : "bottom";
|
|
176
|
+
} else if (placement === "bottom" && spaceBottom < popoverRect.height + offset) {
|
|
177
|
+
finalPlacement = spaceTop >= popoverRect.height + offset ? "top" : "bottom";
|
|
178
|
+
} else if (placement === "top" && spaceTop < popoverRect.height + offset) {
|
|
179
|
+
finalPlacement = spaceBottom >= popoverRect.height + offset ? "bottom" : "top";
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
setResolvedPlacement(finalPlacement);
|
|
183
|
+
const newStyle = {
|
|
184
|
+
position: "fixed",
|
|
185
|
+
zIndex: "var(--z-popover)",
|
|
186
|
+
opacity: 1,
|
|
187
|
+
visibility: "visible",
|
|
188
|
+
pointerEvents: "auto"
|
|
189
|
+
};
|
|
190
|
+
const getAlignmentOffset = () => {
|
|
191
|
+
let alignmentOffset = 0;
|
|
192
|
+
if (finalPlacement === "left" || finalPlacement === "right") {
|
|
193
|
+
switch (align) {
|
|
194
|
+
case "center":
|
|
195
|
+
alignmentOffset = (triggerRect.height - popoverRect.height) / 2;
|
|
196
|
+
break;
|
|
197
|
+
case "end":
|
|
198
|
+
alignmentOffset = triggerRect.height - popoverRect.height;
|
|
199
|
+
break;
|
|
200
|
+
case "start":
|
|
201
|
+
default:
|
|
202
|
+
alignmentOffset = 0;
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
switch (align) {
|
|
206
|
+
case "center":
|
|
207
|
+
alignmentOffset = (triggerRect.width - popoverRect.width) / 2;
|
|
208
|
+
break;
|
|
209
|
+
case "end":
|
|
210
|
+
alignmentOffset = triggerRect.width - popoverRect.width;
|
|
211
|
+
break;
|
|
212
|
+
case "start":
|
|
213
|
+
default:
|
|
214
|
+
alignmentOffset = 0;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return alignmentOffset;
|
|
218
|
+
};
|
|
219
|
+
switch (finalPlacement) {
|
|
220
|
+
case "right":
|
|
221
|
+
newStyle.top = triggerRect.top + getAlignmentOffset();
|
|
222
|
+
newStyle.left = triggerRect.right + offset;
|
|
223
|
+
break;
|
|
224
|
+
case "left":
|
|
225
|
+
newStyle.top = triggerRect.top + getAlignmentOffset();
|
|
226
|
+
newStyle.left = triggerRect.left - popoverRect.width - offset;
|
|
227
|
+
break;
|
|
228
|
+
case "top":
|
|
229
|
+
newStyle.top = triggerRect.top - popoverRect.height - offset;
|
|
230
|
+
newStyle.left = triggerRect.left + getAlignmentOffset();
|
|
231
|
+
break;
|
|
232
|
+
case "bottom":
|
|
233
|
+
default:
|
|
234
|
+
newStyle.top = triggerRect.bottom + offset;
|
|
235
|
+
newStyle.left = triggerRect.left + getAlignmentOffset();
|
|
236
|
+
}
|
|
237
|
+
if (typeof newStyle.left === "number") {
|
|
238
|
+
if (newStyle.left + popoverRect.width > viewportWidth - offset) {
|
|
239
|
+
newStyle.left = viewportWidth - popoverRect.width - offset;
|
|
240
|
+
}
|
|
241
|
+
if (newStyle.left < offset) {
|
|
242
|
+
newStyle.left = offset;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (typeof newStyle.top === "number") {
|
|
246
|
+
if (newStyle.top + popoverRect.height > viewportHeight - offset) {
|
|
247
|
+
newStyle.top = viewportHeight - popoverRect.height - offset;
|
|
248
|
+
}
|
|
249
|
+
if (newStyle.top < offset) {
|
|
250
|
+
newStyle.top = offset;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
setPopoverStyle(newStyle);
|
|
254
|
+
};
|
|
255
|
+
requestAnimationFrame(updatePosition);
|
|
256
|
+
window.addEventListener("resize", updatePosition);
|
|
257
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
258
|
+
return () => {
|
|
259
|
+
window.removeEventListener("resize", updatePosition);
|
|
260
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
261
|
+
};
|
|
262
|
+
}, [open, placement, align, offset, flip]);
|
|
263
|
+
const handleTriggerClick = React.useCallback(() => {
|
|
264
|
+
toggle();
|
|
265
|
+
}, [toggle]);
|
|
266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
268
|
+
"div",
|
|
269
|
+
{
|
|
270
|
+
ref: triggerRef,
|
|
271
|
+
onClick: handleTriggerClick,
|
|
272
|
+
style: { display: "inline-block", position: "relative" },
|
|
273
|
+
children: React.isValidElement(trigger) ? React.cloneElement(trigger, {
|
|
274
|
+
onClick: (e) => {
|
|
275
|
+
e.stopPropagation();
|
|
276
|
+
handleTriggerClick();
|
|
277
|
+
trigger.props?.onClick?.(e);
|
|
278
|
+
}
|
|
279
|
+
}) : trigger
|
|
280
|
+
}
|
|
281
|
+
),
|
|
282
|
+
open && ReactDOM.createPortal(
|
|
283
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
284
|
+
"div",
|
|
285
|
+
{
|
|
286
|
+
ref: popoverRef,
|
|
287
|
+
className: `popover popover--${resolvedPlacement}`,
|
|
288
|
+
style: {
|
|
289
|
+
...popoverStyle,
|
|
290
|
+
// Start with opacity 0 and visibility hidden to prevent initial flash
|
|
291
|
+
opacity: popoverStyle.top !== void 0 ? 1 : 0,
|
|
292
|
+
visibility: popoverStyle.top !== void 0 ? "visible" : "hidden"
|
|
293
|
+
},
|
|
294
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "popover__content", children })
|
|
295
|
+
}
|
|
296
|
+
),
|
|
297
|
+
document.body
|
|
298
|
+
)
|
|
299
|
+
] });
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
// src/components/icons/iconConstants.ts
|
|
303
|
+
var INPUT_TYPE_ICONS = {
|
|
304
|
+
// Standard HTML input types
|
|
305
|
+
email: "envelope-solid",
|
|
306
|
+
password: "lock-closed-solid",
|
|
307
|
+
search: "magnifying-glass-solid",
|
|
308
|
+
date: "calendar-days-solid",
|
|
309
|
+
time: "clock-solid",
|
|
310
|
+
"datetime-local": "calendar-days-solid",
|
|
311
|
+
tel: "phone-solid",
|
|
312
|
+
url: "link-solid",
|
|
313
|
+
number: "hashtag-solid",
|
|
314
|
+
// Additional semantic types
|
|
315
|
+
username: "user-solid",
|
|
316
|
+
name: "user-solid",
|
|
317
|
+
firstname: "user-solid",
|
|
318
|
+
lastname: "user-solid",
|
|
319
|
+
address: "map-pin-solid",
|
|
320
|
+
city: "building-solid",
|
|
321
|
+
state: "map-solid",
|
|
322
|
+
zip: "map-pin-solid",
|
|
323
|
+
"zip-code": "map-pin-solid",
|
|
324
|
+
country: "globe-americas-solid",
|
|
325
|
+
creditcard: "credit-card-solid",
|
|
326
|
+
card: "credit-card-solid",
|
|
327
|
+
cvv: "lock-closed-solid",
|
|
328
|
+
expiry: "calendar-days-solid",
|
|
329
|
+
"expiration-date": "calendar-days-solid",
|
|
330
|
+
// File and media types
|
|
331
|
+
file: "document-solid",
|
|
332
|
+
image: "photo-solid",
|
|
333
|
+
video: "video-camera-solid",
|
|
334
|
+
audio: "microphone-solid",
|
|
335
|
+
// Communication
|
|
336
|
+
message: "chat-bubble-left-solid",
|
|
337
|
+
comment: "chat-bubble-left-solid",
|
|
338
|
+
feedback: "chat-bubble-left-solid",
|
|
339
|
+
// Actions and states
|
|
340
|
+
submit: "paper-airplane-solid",
|
|
341
|
+
send: "paper-airplane-solid",
|
|
342
|
+
save: "floppy-disk-solid",
|
|
343
|
+
edit: "pencil-solid",
|
|
344
|
+
delete: "trash-solid",
|
|
345
|
+
remove: "x-mark-solid",
|
|
346
|
+
add: "plus-solid",
|
|
347
|
+
create: "plus-solid",
|
|
348
|
+
upload: "arrow-up-tray-solid",
|
|
349
|
+
download: "arrow-down-tray-solid",
|
|
350
|
+
refresh: "arrow-path-solid",
|
|
351
|
+
reload: "arrow-path-solid",
|
|
352
|
+
settings: "cog-solid",
|
|
353
|
+
config: "cog-solid",
|
|
354
|
+
filter: "funnel-solid",
|
|
355
|
+
sort: "bars-arrow-up-solid"
|
|
356
|
+
};
|
|
357
|
+
var ACTION_ICONS = {
|
|
358
|
+
close: "x-mark-solid",
|
|
359
|
+
back: "arrow-left-solid",
|
|
360
|
+
forward: "arrow-right-solid",
|
|
361
|
+
up: "arrow-up-solid",
|
|
362
|
+
down: "arrow-down-solid",
|
|
363
|
+
expand: "chevron-down-solid",
|
|
364
|
+
collapse: "chevron-up-solid",
|
|
365
|
+
menu: "bars-3-solid",
|
|
366
|
+
more: "ellipsis-horizontal-solid",
|
|
367
|
+
check: "check-solid",
|
|
368
|
+
cross: "x-mark-solid",
|
|
369
|
+
plus: "plus-solid",
|
|
370
|
+
minus: "minus-solid",
|
|
371
|
+
search: "magnifying-glass-solid",
|
|
372
|
+
clear: "x-mark-solid",
|
|
373
|
+
loading: "arrow-path-solid",
|
|
374
|
+
error: "exclamation-triangle-solid",
|
|
375
|
+
warning: "exclamation-triangle-solid",
|
|
376
|
+
info: "information-circle-solid",
|
|
377
|
+
success: "check-circle-solid"
|
|
378
|
+
};
|
|
379
|
+
var LIST_ICONS = {
|
|
380
|
+
selected: "check-solid",
|
|
381
|
+
unselected: "circle-solid"
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
// src/components/list/List.tsx
|
|
385
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
386
|
+
var ListItem = ({
|
|
387
|
+
children,
|
|
388
|
+
icon,
|
|
389
|
+
selected = false,
|
|
390
|
+
disabled = false,
|
|
391
|
+
onClick,
|
|
392
|
+
category,
|
|
393
|
+
className = "",
|
|
394
|
+
...props
|
|
395
|
+
}) => {
|
|
396
|
+
const classes = [
|
|
397
|
+
"list-item",
|
|
398
|
+
selected && "list-item--selected",
|
|
399
|
+
disabled && "list-item--disabled",
|
|
400
|
+
onClick && !disabled && "list-item--interactive",
|
|
401
|
+
className
|
|
402
|
+
].filter(Boolean).join(" ");
|
|
403
|
+
const handleClick = () => {
|
|
404
|
+
if (!disabled && onClick) {
|
|
405
|
+
onClick();
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
const handleKeyDown = (e) => {
|
|
409
|
+
if (!disabled && onClick && (e.key === "Enter" || e.key === " ")) {
|
|
410
|
+
e.preventDefault();
|
|
411
|
+
onClick();
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
415
|
+
"div",
|
|
416
|
+
{
|
|
417
|
+
className: classes,
|
|
418
|
+
onClick: handleClick,
|
|
419
|
+
onKeyDown: handleKeyDown,
|
|
420
|
+
role: onClick ? "button" : void 0,
|
|
421
|
+
tabIndex: onClick && !disabled ? 0 : void 0,
|
|
422
|
+
"aria-selected": selected,
|
|
423
|
+
"aria-disabled": disabled,
|
|
424
|
+
...props,
|
|
425
|
+
children: [
|
|
426
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "list-item__icon", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: icon, size: 20 }) }),
|
|
427
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "list-item__content", children: [
|
|
428
|
+
category && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "list-item__category", children: category }),
|
|
429
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children })
|
|
430
|
+
] }),
|
|
431
|
+
selected && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "list-item__indicator", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: LIST_ICONS.selected, size: 16 }) })
|
|
432
|
+
]
|
|
433
|
+
}
|
|
434
|
+
);
|
|
435
|
+
};
|
|
436
|
+
var List = ({ children, className = "", ...props }) => {
|
|
437
|
+
const classes = ["list", className].filter(Boolean).join(" ");
|
|
438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: classes, role: "list", ...props, children });
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
// src/components/select/Select.tsx
|
|
442
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
443
|
+
var Select = ({
|
|
444
|
+
options,
|
|
445
|
+
value,
|
|
446
|
+
onChange,
|
|
447
|
+
label,
|
|
448
|
+
placeholder = "Select an option",
|
|
449
|
+
helperText,
|
|
450
|
+
error,
|
|
451
|
+
disabled = false,
|
|
452
|
+
fullWidth = false,
|
|
453
|
+
size = "md",
|
|
454
|
+
className = "",
|
|
455
|
+
id
|
|
456
|
+
}) => {
|
|
457
|
+
const [isOpen, setIsOpen] = React2.useState(false);
|
|
458
|
+
const selectId = id || `select-${React2.useId()}`;
|
|
459
|
+
const selectedOption = options.find((opt) => opt.value === value);
|
|
460
|
+
const handleSelect = (optionValue) => {
|
|
461
|
+
onChange?.(optionValue);
|
|
462
|
+
setIsOpen(false);
|
|
463
|
+
};
|
|
464
|
+
const handleKeyDown = (e) => {
|
|
465
|
+
if (disabled) return;
|
|
466
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
467
|
+
e.preventDefault();
|
|
468
|
+
setIsOpen(!isOpen);
|
|
469
|
+
} else if (e.key === "Escape") {
|
|
470
|
+
setIsOpen(false);
|
|
471
|
+
} else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
472
|
+
e.preventDefault();
|
|
473
|
+
if (!isOpen) {
|
|
474
|
+
setIsOpen(true);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
const containerClasses = [
|
|
479
|
+
"select-container",
|
|
480
|
+
fullWidth && "select-container--full-width",
|
|
481
|
+
className
|
|
482
|
+
].filter(Boolean).join(" ");
|
|
483
|
+
const triggerClasses = [
|
|
484
|
+
"select__trigger",
|
|
485
|
+
`select__trigger--${size}`,
|
|
486
|
+
error && "select__trigger--error",
|
|
487
|
+
disabled && "select__trigger--disabled",
|
|
488
|
+
isOpen && "select__trigger--open"
|
|
489
|
+
].filter(Boolean).join(" ");
|
|
490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: containerClasses, children: [
|
|
491
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { htmlFor: selectId, className: "select__label", children: label }),
|
|
492
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
493
|
+
Popover,
|
|
494
|
+
{
|
|
495
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
496
|
+
"button",
|
|
497
|
+
{
|
|
498
|
+
id: selectId,
|
|
499
|
+
type: "button",
|
|
500
|
+
className: triggerClasses,
|
|
501
|
+
onClick: () => !disabled && setIsOpen(!isOpen),
|
|
502
|
+
onKeyDown: handleKeyDown,
|
|
503
|
+
disabled,
|
|
504
|
+
"aria-haspopup": "listbox",
|
|
505
|
+
"aria-expanded": isOpen,
|
|
506
|
+
"aria-labelledby": label ? `${selectId}-label` : void 0,
|
|
507
|
+
"aria-describedby": error ? `${selectId}-error` : helperText ? `${selectId}-helper` : void 0,
|
|
508
|
+
"aria-invalid": error ? "true" : "false",
|
|
509
|
+
children: [
|
|
510
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "select__trigger-content", children: [
|
|
511
|
+
selectedOption?.icon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
512
|
+
Icon,
|
|
513
|
+
{
|
|
514
|
+
name: selectedOption.icon,
|
|
515
|
+
size: size === "sm" ? 16 : size === "lg" ? 24 : 20
|
|
516
|
+
}
|
|
517
|
+
),
|
|
518
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "select__trigger-text", children: selectedOption ? selectedOption.label : placeholder })
|
|
519
|
+
] }),
|
|
520
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
521
|
+
Icon,
|
|
522
|
+
{
|
|
523
|
+
name: "flowbite:chevron-down-outline",
|
|
524
|
+
size: size === "sm" ? 16 : size === "lg" ? 24 : 20,
|
|
525
|
+
className: "select__trigger-icon"
|
|
526
|
+
}
|
|
527
|
+
)
|
|
528
|
+
]
|
|
529
|
+
}
|
|
530
|
+
),
|
|
531
|
+
isOpen,
|
|
532
|
+
onToggle: () => !disabled && setIsOpen(!isOpen),
|
|
533
|
+
placement: "bottom",
|
|
534
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "select__dropdown scrollable", role: "listbox", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(List, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
535
|
+
ListItem,
|
|
536
|
+
{
|
|
537
|
+
icon: option.icon,
|
|
538
|
+
selected: option.value === value,
|
|
539
|
+
disabled: option.disabled,
|
|
540
|
+
onClick: () => !option.disabled && handleSelect(option.value),
|
|
541
|
+
role: "option",
|
|
542
|
+
"aria-selected": option.value === value,
|
|
543
|
+
children: option.label
|
|
544
|
+
},
|
|
545
|
+
option.value
|
|
546
|
+
)) }) })
|
|
547
|
+
}
|
|
548
|
+
),
|
|
549
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { id: `${selectId}-error`, className: "select__message select__message--error", children: error }),
|
|
550
|
+
helperText && !error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { id: `${selectId}-helper`, className: "select__message", children: helperText })
|
|
551
|
+
] });
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
// src/components/button/button.tsx
|
|
555
|
+
var import_react2 = __toESM(require("react"));
|
|
556
|
+
var import_react3 = require("@ariakit/react");
|
|
557
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
558
|
+
var Button = import_react2.default.forwardRef(
|
|
559
|
+
({
|
|
560
|
+
variant = "primary",
|
|
561
|
+
size = "md",
|
|
562
|
+
children,
|
|
563
|
+
isLoading = false,
|
|
564
|
+
disabled = false,
|
|
565
|
+
fullWidth = false,
|
|
566
|
+
startIcon,
|
|
567
|
+
endIcon,
|
|
568
|
+
iconOnly = false,
|
|
569
|
+
href,
|
|
570
|
+
active = false,
|
|
571
|
+
className,
|
|
572
|
+
onClick,
|
|
573
|
+
...props
|
|
574
|
+
}, ref) => {
|
|
575
|
+
const buttonClasses = [
|
|
576
|
+
"btn",
|
|
577
|
+
`btn--${variant}`,
|
|
578
|
+
`btn--${size}`,
|
|
579
|
+
fullWidth && "btn--full-width",
|
|
580
|
+
iconOnly && "btn--icon-only",
|
|
581
|
+
active && "btn--active",
|
|
582
|
+
className
|
|
583
|
+
].filter(Boolean).join(" ");
|
|
584
|
+
const iconSize = size === "xs" ? 14 : size === "sm" ? 16 : size === "lg" ? 24 : 20;
|
|
585
|
+
const buttonContent = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
586
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "btn__spinner" }),
|
|
587
|
+
startIcon && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "btn__icon-placeholder", style: { width: iconSize, height: iconSize } }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: startIcon, size: iconSize, className: "btn__icon" })),
|
|
588
|
+
!iconOnly && children,
|
|
589
|
+
endIcon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: endIcon, size: iconSize, className: "btn__icon" })
|
|
590
|
+
] });
|
|
591
|
+
const handleClick = (e) => {
|
|
592
|
+
if (href && !isLoading && !disabled) {
|
|
593
|
+
window.location.href = href;
|
|
594
|
+
}
|
|
595
|
+
onClick?.(e);
|
|
596
|
+
};
|
|
597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
598
|
+
import_react3.Button,
|
|
599
|
+
{
|
|
600
|
+
ref,
|
|
601
|
+
disabled: disabled || isLoading,
|
|
602
|
+
className: buttonClasses,
|
|
603
|
+
onClick: handleClick,
|
|
604
|
+
...props,
|
|
605
|
+
children: buttonContent
|
|
606
|
+
}
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
);
|
|
610
|
+
Button.displayName = "Button";
|
|
611
|
+
|
|
612
|
+
// src/components/dialog/Dialog.tsx
|
|
613
|
+
var React21 = __toESM(require("react"));
|
|
614
|
+
var import_react_dom = require("react-dom");
|
|
615
|
+
|
|
616
|
+
// src/components/_shared/Backdrop.tsx
|
|
617
|
+
var React4 = __toESM(require("react"));
|
|
618
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
619
|
+
var Backdrop = React4.forwardRef(
|
|
620
|
+
({ className = "", blur = true, style, ...props }, ref) => {
|
|
621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
622
|
+
"div",
|
|
623
|
+
{
|
|
624
|
+
ref,
|
|
625
|
+
className: `backdrop ${blur ? "backdrop--blur" : ""} ${className}`,
|
|
626
|
+
style,
|
|
627
|
+
"aria-hidden": "true",
|
|
628
|
+
...props
|
|
629
|
+
}
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
);
|
|
633
|
+
Backdrop.displayName = "Backdrop";
|
|
634
|
+
|
|
635
|
+
// src/components/_shared/Thumb.tsx
|
|
636
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
637
|
+
|
|
638
|
+
// src/components/_shared/HeadingAnchor.tsx
|
|
639
|
+
var import_react14 = require("react");
|
|
640
|
+
|
|
641
|
+
// src/components/input/InputText.tsx
|
|
642
|
+
var import_react4 = __toESM(require("react"));
|
|
643
|
+
|
|
644
|
+
// src/components/input/Input.tsx
|
|
645
|
+
var React8 = __toESM(require("react"));
|
|
646
|
+
|
|
647
|
+
// src/components/input/InputField.tsx
|
|
648
|
+
var React5 = __toESM(require("react"));
|
|
649
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
650
|
+
var InputField = React5.forwardRef(
|
|
651
|
+
({
|
|
652
|
+
type = "text",
|
|
653
|
+
label,
|
|
654
|
+
helperText,
|
|
655
|
+
error,
|
|
656
|
+
icon,
|
|
657
|
+
iconRight,
|
|
658
|
+
fullWidth = false,
|
|
659
|
+
size = "md",
|
|
660
|
+
className = "",
|
|
661
|
+
disabled,
|
|
662
|
+
id,
|
|
663
|
+
onRightIconClick,
|
|
664
|
+
...props
|
|
665
|
+
}, ref) => {
|
|
666
|
+
const inputId = id || `input-${React5.useId()}`;
|
|
667
|
+
const containerClasses = [
|
|
668
|
+
"input-container",
|
|
669
|
+
fullWidth && "input-container--full-width",
|
|
670
|
+
className
|
|
671
|
+
].filter(Boolean).join(" ");
|
|
672
|
+
const inputClasses = [
|
|
673
|
+
"input",
|
|
674
|
+
`input--${size}`,
|
|
675
|
+
error && "input--error",
|
|
676
|
+
disabled && "input--disabled",
|
|
677
|
+
icon && "input--has-icon-left",
|
|
678
|
+
iconRight && "input--has-icon-right"
|
|
679
|
+
].filter(Boolean).join(" ");
|
|
680
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: containerClasses, children: [
|
|
681
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: inputId, className: "input__label", children: label }),
|
|
682
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "input__wrapper", children: [
|
|
683
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "input__icon input__icon--left", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: icon, size: 16 }) }),
|
|
684
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
685
|
+
"input",
|
|
686
|
+
{
|
|
687
|
+
ref,
|
|
688
|
+
type,
|
|
689
|
+
id: inputId,
|
|
690
|
+
className: inputClasses,
|
|
691
|
+
disabled,
|
|
692
|
+
...props
|
|
693
|
+
}
|
|
694
|
+
),
|
|
695
|
+
iconRight && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
696
|
+
"button",
|
|
697
|
+
{
|
|
698
|
+
type: "button",
|
|
699
|
+
className: "input__icon input__icon--right",
|
|
700
|
+
onClick: onRightIconClick,
|
|
701
|
+
tabIndex: -1,
|
|
702
|
+
"aria-label": "Icon action",
|
|
703
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: iconRight, size: 16 })
|
|
704
|
+
}
|
|
705
|
+
)
|
|
706
|
+
] }),
|
|
707
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "input__message input__message--error", children: error }),
|
|
708
|
+
helperText && !error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "input__message", children: helperText })
|
|
709
|
+
] });
|
|
710
|
+
}
|
|
711
|
+
);
|
|
712
|
+
|
|
713
|
+
// src/components/input/DatePicker.tsx
|
|
714
|
+
var React6 = __toESM(require("react"));
|
|
715
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
716
|
+
var MONTHS = [
|
|
717
|
+
"January",
|
|
718
|
+
"February",
|
|
719
|
+
"March",
|
|
720
|
+
"April",
|
|
721
|
+
"May",
|
|
722
|
+
"June",
|
|
723
|
+
"July",
|
|
724
|
+
"August",
|
|
725
|
+
"September",
|
|
726
|
+
"October",
|
|
727
|
+
"November",
|
|
728
|
+
"December"
|
|
729
|
+
];
|
|
730
|
+
var DAYS_OF_WEEK = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
731
|
+
var DatePicker = ({ value, onChange, disabled }) => {
|
|
732
|
+
const parseDate = (dateStr) => {
|
|
733
|
+
if (!dateStr) {
|
|
734
|
+
const today = /* @__PURE__ */ new Date();
|
|
735
|
+
return { year: today.getFullYear(), month: today.getMonth(), day: today.getDate() };
|
|
736
|
+
}
|
|
737
|
+
const [year, month, day] = dateStr.split("-").map(Number);
|
|
738
|
+
return { year, month: month - 1, day };
|
|
739
|
+
};
|
|
740
|
+
const { year: initialYear, month: initialMonth, day: selectedDay } = parseDate(value);
|
|
741
|
+
const [currentYear, setCurrentYear] = React6.useState(initialYear);
|
|
742
|
+
const [currentMonth, setCurrentMonth] = React6.useState(initialMonth);
|
|
743
|
+
const getDaysInMonth = (year, month) => {
|
|
744
|
+
return new Date(year, month + 1, 0).getDate();
|
|
745
|
+
};
|
|
746
|
+
const getFirstDayOfMonth = (year, month) => {
|
|
747
|
+
return new Date(year, month, 1).getDay();
|
|
748
|
+
};
|
|
749
|
+
const handleDateSelect = (day) => {
|
|
750
|
+
if (disabled) return;
|
|
751
|
+
const formattedDate = `${currentYear}-${String(currentMonth + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
|
|
752
|
+
onChange(formattedDate);
|
|
753
|
+
};
|
|
754
|
+
const handlePrevMonth = () => {
|
|
755
|
+
if (currentMonth === 0) {
|
|
756
|
+
setCurrentMonth(11);
|
|
757
|
+
setCurrentYear(currentYear - 1);
|
|
758
|
+
} else {
|
|
759
|
+
setCurrentMonth(currentMonth - 1);
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
const handleNextMonth = () => {
|
|
763
|
+
if (currentMonth === 11) {
|
|
764
|
+
setCurrentMonth(0);
|
|
765
|
+
setCurrentYear(currentYear + 1);
|
|
766
|
+
} else {
|
|
767
|
+
setCurrentMonth(currentMonth + 1);
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
const daysInMonth = getDaysInMonth(currentYear, currentMonth);
|
|
771
|
+
const firstDay = getFirstDayOfMonth(currentYear, currentMonth);
|
|
772
|
+
const days = [
|
|
773
|
+
...Array(firstDay).fill(null),
|
|
774
|
+
...Array.from({ length: daysInMonth }, (_, i) => i + 1)
|
|
775
|
+
];
|
|
776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "date-picker", children: [
|
|
777
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "date-picker__header", children: [
|
|
778
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
779
|
+
"button",
|
|
780
|
+
{
|
|
781
|
+
type: "button",
|
|
782
|
+
className: "date-picker__nav",
|
|
783
|
+
onClick: handlePrevMonth,
|
|
784
|
+
disabled,
|
|
785
|
+
"aria-label": "Previous month",
|
|
786
|
+
children: "\u2039"
|
|
787
|
+
}
|
|
788
|
+
),
|
|
789
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "date-picker__title", children: [
|
|
790
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
791
|
+
"select",
|
|
792
|
+
{
|
|
793
|
+
className: "date-picker__select",
|
|
794
|
+
value: currentMonth,
|
|
795
|
+
onChange: (e) => setCurrentMonth(Number(e.target.value)),
|
|
796
|
+
disabled,
|
|
797
|
+
children: MONTHS.map((month, idx) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: idx, children: month }, month))
|
|
798
|
+
}
|
|
799
|
+
),
|
|
800
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
801
|
+
"select",
|
|
802
|
+
{
|
|
803
|
+
className: "date-picker__select",
|
|
804
|
+
value: currentYear,
|
|
805
|
+
onChange: (e) => setCurrentYear(Number(e.target.value)),
|
|
806
|
+
disabled,
|
|
807
|
+
children: Array.from({ length: 100 }, (_, i) => currentYear - 50 + i).map((year) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: year, children: year }, year))
|
|
808
|
+
}
|
|
809
|
+
)
|
|
810
|
+
] }),
|
|
811
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
812
|
+
"button",
|
|
813
|
+
{
|
|
814
|
+
type: "button",
|
|
815
|
+
className: "date-picker__nav",
|
|
816
|
+
onClick: handleNextMonth,
|
|
817
|
+
disabled,
|
|
818
|
+
"aria-label": "Next month",
|
|
819
|
+
children: "\u203A"
|
|
820
|
+
}
|
|
821
|
+
)
|
|
822
|
+
] }),
|
|
823
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "date-picker__weekdays", children: DAYS_OF_WEEK.map((day) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "date-picker__weekday", children: day }, day)) }),
|
|
824
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "date-picker__days", children: days.map((day, idx) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
825
|
+
"button",
|
|
826
|
+
{
|
|
827
|
+
type: "button",
|
|
828
|
+
className: `date-picker__day ${day === selectedDay ? "date-picker__day--selected" : ""} ${!day ? "date-picker__day--empty" : ""}`,
|
|
829
|
+
onClick: () => day && handleDateSelect(day),
|
|
830
|
+
disabled: !day || disabled,
|
|
831
|
+
children: day || ""
|
|
832
|
+
},
|
|
833
|
+
idx
|
|
834
|
+
)) })
|
|
835
|
+
] });
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
// src/components/input/TimePicker.tsx
|
|
839
|
+
var React7 = __toESM(require("react"));
|
|
840
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
841
|
+
var parseTime = (timeStr) => {
|
|
842
|
+
if (!timeStr) return { hours: 0, minutes: 0, seconds: 0, milliseconds: 0 };
|
|
843
|
+
const parts = timeStr.split(":");
|
|
844
|
+
const hours = parseInt(parts[0] || "0", 10);
|
|
845
|
+
const minutes = parseInt(parts[1] || "0", 10);
|
|
846
|
+
const secondsParts = (parts[2] || "0").split(".");
|
|
847
|
+
const seconds = parseInt(secondsParts[0] || "0", 10);
|
|
848
|
+
const milliseconds = parseInt(secondsParts[1] || "0", 10);
|
|
849
|
+
return { hours, minutes, seconds, milliseconds };
|
|
850
|
+
};
|
|
851
|
+
var TimeColumn = ({
|
|
852
|
+
label,
|
|
853
|
+
value,
|
|
854
|
+
max,
|
|
855
|
+
field,
|
|
856
|
+
step,
|
|
857
|
+
disabled,
|
|
858
|
+
onChange
|
|
859
|
+
}) => {
|
|
860
|
+
const items = Array.from({ length: Math.floor(max / step) + 1 }, (_, i) => i * step);
|
|
861
|
+
const columnRef = React7.useRef(null);
|
|
862
|
+
React7.useEffect(() => {
|
|
863
|
+
if (columnRef.current) {
|
|
864
|
+
const selected = columnRef.current.querySelector(".time-picker__item--selected");
|
|
865
|
+
if (selected) {
|
|
866
|
+
selected.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}, [value]);
|
|
870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "time-picker__column", children: [
|
|
871
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "time-picker__label", children: label }),
|
|
872
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "time-picker__scroll scrollable", ref: columnRef, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
873
|
+
"button",
|
|
874
|
+
{
|
|
875
|
+
type: "button",
|
|
876
|
+
className: `time-picker__item ${item === value ? "time-picker__item--selected" : ""}`,
|
|
877
|
+
onClick: () => onChange(field, item),
|
|
878
|
+
disabled,
|
|
879
|
+
children: String(item).padStart(field === "milliseconds" ? 3 : 2, "0")
|
|
880
|
+
},
|
|
881
|
+
item
|
|
882
|
+
)) })
|
|
883
|
+
] });
|
|
884
|
+
};
|
|
885
|
+
var TimePicker = ({
|
|
886
|
+
value,
|
|
887
|
+
onChange,
|
|
888
|
+
disabled,
|
|
889
|
+
showMilliseconds = false,
|
|
890
|
+
minuteStep = 1
|
|
891
|
+
}) => {
|
|
892
|
+
const [internalTime, setInternalTime] = React7.useState(value);
|
|
893
|
+
React7.useEffect(() => {
|
|
894
|
+
setInternalTime(value);
|
|
895
|
+
}, [value]);
|
|
896
|
+
const { hours, minutes, seconds, milliseconds } = parseTime(internalTime);
|
|
897
|
+
const handleChange = (field, newValue) => {
|
|
898
|
+
if (disabled) return;
|
|
899
|
+
const currentParsed = parseTime(internalTime);
|
|
900
|
+
const updated = { ...currentParsed, [field]: newValue };
|
|
901
|
+
let formattedTime = `${String(updated.hours).padStart(2, "0")}:${String(updated.minutes).padStart(2, "0")}:${String(updated.seconds).padStart(2, "0")}`;
|
|
902
|
+
if (showMilliseconds && updated.milliseconds > 0) {
|
|
903
|
+
formattedTime += `.${String(updated.milliseconds).padStart(3, "0")}`;
|
|
904
|
+
}
|
|
905
|
+
setInternalTime(formattedTime);
|
|
906
|
+
onChange(formattedTime);
|
|
907
|
+
};
|
|
908
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "time-picker", children: [
|
|
909
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
910
|
+
TimeColumn,
|
|
911
|
+
{
|
|
912
|
+
label: "Hours",
|
|
913
|
+
value: hours,
|
|
914
|
+
max: 23,
|
|
915
|
+
field: "hours",
|
|
916
|
+
step: 1,
|
|
917
|
+
disabled,
|
|
918
|
+
onChange: handleChange
|
|
919
|
+
}
|
|
920
|
+
),
|
|
921
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
922
|
+
TimeColumn,
|
|
923
|
+
{
|
|
924
|
+
label: "Minutes",
|
|
925
|
+
value: minutes,
|
|
926
|
+
max: 59,
|
|
927
|
+
field: "minutes",
|
|
928
|
+
step: minuteStep,
|
|
929
|
+
disabled,
|
|
930
|
+
onChange: handleChange
|
|
931
|
+
}
|
|
932
|
+
),
|
|
933
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
934
|
+
TimeColumn,
|
|
935
|
+
{
|
|
936
|
+
label: "Seconds",
|
|
937
|
+
value: seconds,
|
|
938
|
+
max: 59,
|
|
939
|
+
field: "seconds",
|
|
940
|
+
step: 1,
|
|
941
|
+
disabled,
|
|
942
|
+
onChange: handleChange
|
|
943
|
+
}
|
|
944
|
+
),
|
|
945
|
+
showMilliseconds && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
946
|
+
TimeColumn,
|
|
947
|
+
{
|
|
948
|
+
label: "ms",
|
|
949
|
+
value: milliseconds,
|
|
950
|
+
max: 999,
|
|
951
|
+
field: "milliseconds",
|
|
952
|
+
step: 1,
|
|
953
|
+
disabled,
|
|
954
|
+
onChange: handleChange
|
|
955
|
+
}
|
|
956
|
+
)
|
|
957
|
+
] });
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
// src/components/input/Input.tsx
|
|
961
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
962
|
+
var TYPE_ICON_MAP = INPUT_TYPE_ICONS;
|
|
963
|
+
var formatDisplayValue = (val, inputType) => {
|
|
964
|
+
if (!val) return "";
|
|
965
|
+
if (inputType === "date") {
|
|
966
|
+
const [year, month, day] = val.split("-");
|
|
967
|
+
return `${day}/${month}/${year}`;
|
|
968
|
+
}
|
|
969
|
+
if (inputType === "time") {
|
|
970
|
+
return val;
|
|
971
|
+
}
|
|
972
|
+
if (inputType === "datetime-local") {
|
|
973
|
+
const [datePart, timePart] = val.split("T");
|
|
974
|
+
if (datePart && timePart) {
|
|
975
|
+
const [year, month, day] = datePart.split("-");
|
|
976
|
+
return `${day}/${month}/${year} ${timePart}`;
|
|
977
|
+
}
|
|
978
|
+
return val;
|
|
979
|
+
}
|
|
980
|
+
return val;
|
|
981
|
+
};
|
|
982
|
+
var Input = React8.forwardRef(
|
|
983
|
+
({
|
|
984
|
+
type = "text",
|
|
985
|
+
label,
|
|
986
|
+
helperText,
|
|
987
|
+
error,
|
|
988
|
+
icon,
|
|
989
|
+
fullWidth = false,
|
|
990
|
+
size = "md",
|
|
991
|
+
className = "",
|
|
992
|
+
disabled,
|
|
993
|
+
id,
|
|
994
|
+
showMilliseconds = false,
|
|
995
|
+
minuteStep = 1,
|
|
996
|
+
showClear = true,
|
|
997
|
+
...props
|
|
998
|
+
}, ref) => {
|
|
999
|
+
const [showPassword, setShowPassword] = React8.useState(false);
|
|
1000
|
+
const [showDateTimePicker, setShowDateTimePicker] = React8.useState(false);
|
|
1001
|
+
const inputRef = React8.useRef(null);
|
|
1002
|
+
const leftIcon = icon || TYPE_ICON_MAP[type];
|
|
1003
|
+
const isPasswordType = type === "password";
|
|
1004
|
+
const actualType = isPasswordType && showPassword ? "text" : type !== "date" && type !== "time" && type !== "datetime-local" ? type : "text";
|
|
1005
|
+
const isDateTimeType = type === "date" || type === "time" || type === "datetime-local";
|
|
1006
|
+
const isSearchType = type === "search";
|
|
1007
|
+
const hasValue = props.value && String(props.value).length > 0;
|
|
1008
|
+
const rightIconName = isPasswordType ? showPassword ? "heroicons:eye-slash-solid" : "heroicons:eye-solid" : isDateTimeType ? "heroicons:chevron-down-solid" : isSearchType && hasValue && showClear ? ACTION_ICONS.clear : void 0;
|
|
1009
|
+
const handleRightIconClick = () => {
|
|
1010
|
+
if (isPasswordType) {
|
|
1011
|
+
setShowPassword(!showPassword);
|
|
1012
|
+
} else if (isDateTimeType) {
|
|
1013
|
+
setShowDateTimePicker(!showDateTimePicker);
|
|
1014
|
+
} else if (isSearchType && hasValue && showClear) {
|
|
1015
|
+
if (props.onChange) {
|
|
1016
|
+
props.onChange({ target: { value: "" } });
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
const handleDateTimeChange = (newValue) => {
|
|
1021
|
+
if (props.onChange) {
|
|
1022
|
+
props.onChange({ target: { value: newValue } });
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
if (!isDateTimeType) {
|
|
1026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1027
|
+
InputField,
|
|
1028
|
+
{
|
|
1029
|
+
ref: ref || inputRef,
|
|
1030
|
+
type: actualType,
|
|
1031
|
+
label,
|
|
1032
|
+
helperText,
|
|
1033
|
+
error,
|
|
1034
|
+
icon: leftIcon,
|
|
1035
|
+
iconRight: rightIconName,
|
|
1036
|
+
onRightIconClick: handleRightIconClick,
|
|
1037
|
+
fullWidth,
|
|
1038
|
+
size,
|
|
1039
|
+
className,
|
|
1040
|
+
disabled,
|
|
1041
|
+
id,
|
|
1042
|
+
...props
|
|
1043
|
+
}
|
|
1044
|
+
);
|
|
1045
|
+
}
|
|
1046
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `input-container ${fullWidth ? "input-container--full-width" : ""} ${className}`.trim(), children: [
|
|
1047
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { htmlFor: id, className: "input__label", children: label }),
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1049
|
+
Popover,
|
|
1050
|
+
{
|
|
1051
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1052
|
+
InputField,
|
|
1053
|
+
{
|
|
1054
|
+
ref: ref || inputRef,
|
|
1055
|
+
type: "text",
|
|
1056
|
+
icon: leftIcon,
|
|
1057
|
+
iconRight: rightIconName,
|
|
1058
|
+
onRightIconClick: () => setShowDateTimePicker(!showDateTimePicker),
|
|
1059
|
+
fullWidth,
|
|
1060
|
+
size,
|
|
1061
|
+
disabled,
|
|
1062
|
+
id,
|
|
1063
|
+
value: formatDisplayValue(String(props.value || ""), type),
|
|
1064
|
+
placeholder: props.placeholder,
|
|
1065
|
+
readOnly: true
|
|
1066
|
+
}
|
|
1067
|
+
),
|
|
1068
|
+
isOpen: showDateTimePicker,
|
|
1069
|
+
onToggle: () => setShowDateTimePicker(!showDateTimePicker),
|
|
1070
|
+
placement: "bottom",
|
|
1071
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: { padding: "1rem" }, children: [
|
|
1072
|
+
(type === "date" || type === "datetime-local") && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1073
|
+
DatePicker,
|
|
1074
|
+
{
|
|
1075
|
+
value: String(props.value || "").split("T")[0],
|
|
1076
|
+
onChange: (newDate) => {
|
|
1077
|
+
if (type === "datetime-local") {
|
|
1078
|
+
const time = String(props.value || "").split("T")[1] || "00:00:00";
|
|
1079
|
+
handleDateTimeChange(`${newDate}T${time}`);
|
|
1080
|
+
} else {
|
|
1081
|
+
handleDateTimeChange(newDate);
|
|
1082
|
+
setShowDateTimePicker(false);
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
disabled
|
|
1086
|
+
}
|
|
1087
|
+
),
|
|
1088
|
+
(type === "time" || type === "datetime-local") && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1089
|
+
TimePicker,
|
|
1090
|
+
{
|
|
1091
|
+
value: String(props.value || "").split("T")[1] || "00:00:00",
|
|
1092
|
+
onChange: (newTime) => {
|
|
1093
|
+
if (type === "datetime-local") {
|
|
1094
|
+
const date = String(props.value || "").split("T")[0] || (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
1095
|
+
handleDateTimeChange(`${date}T${newTime}`);
|
|
1096
|
+
} else {
|
|
1097
|
+
handleDateTimeChange(newTime);
|
|
1098
|
+
}
|
|
1099
|
+
},
|
|
1100
|
+
disabled,
|
|
1101
|
+
showMilliseconds,
|
|
1102
|
+
minuteStep
|
|
1103
|
+
}
|
|
1104
|
+
)
|
|
1105
|
+
] })
|
|
1106
|
+
}
|
|
1107
|
+
),
|
|
1108
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "input__message input__message--error", children: error }),
|
|
1109
|
+
helperText && !error && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "input__message", children: helperText })
|
|
1110
|
+
] });
|
|
1111
|
+
}
|
|
1112
|
+
);
|
|
1113
|
+
Input.displayName = "Input";
|
|
1114
|
+
|
|
1115
|
+
// src/components/input/InputText.tsx
|
|
1116
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1117
|
+
var InputText = import_react4.default.forwardRef((props, ref) => {
|
|
1118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Input, { ref, ...props, type: "text" });
|
|
1119
|
+
});
|
|
1120
|
+
InputText.displayName = "InputText";
|
|
1121
|
+
|
|
1122
|
+
// src/components/input/InputEmail.tsx
|
|
1123
|
+
var import_react5 = __toESM(require("react"));
|
|
1124
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1125
|
+
var InputEmail = import_react5.default.forwardRef((props, ref) => {
|
|
1126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Input, { ref, ...props, type: "email" });
|
|
1127
|
+
});
|
|
1128
|
+
InputEmail.displayName = "InputEmail";
|
|
1129
|
+
|
|
1130
|
+
// src/components/input/InputPassword.tsx
|
|
1131
|
+
var import_react6 = __toESM(require("react"));
|
|
1132
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1133
|
+
var InputPassword = import_react6.default.forwardRef((props, ref) => {
|
|
1134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Input, { ref, ...props, type: "password" });
|
|
1135
|
+
});
|
|
1136
|
+
InputPassword.displayName = "InputPassword";
|
|
1137
|
+
|
|
1138
|
+
// src/components/input/InputSearch.tsx
|
|
1139
|
+
var import_react7 = __toESM(require("react"));
|
|
1140
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1141
|
+
var InputSearch = import_react7.default.forwardRef((props, ref) => {
|
|
1142
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Input, { ref, ...props, type: "search" });
|
|
1143
|
+
});
|
|
1144
|
+
InputSearch.displayName = "InputSearch";
|
|
1145
|
+
|
|
1146
|
+
// src/components/input/InputTel.tsx
|
|
1147
|
+
var import_react8 = __toESM(require("react"));
|
|
1148
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1149
|
+
var InputTel = import_react8.default.forwardRef((props, ref) => {
|
|
1150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Input, { ref, ...props, type: "tel" });
|
|
1151
|
+
});
|
|
1152
|
+
InputTel.displayName = "InputTel";
|
|
1153
|
+
|
|
1154
|
+
// src/components/input/InputUrl.tsx
|
|
1155
|
+
var import_react9 = __toESM(require("react"));
|
|
1156
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1157
|
+
var InputUrl = import_react9.default.forwardRef((props, ref) => {
|
|
1158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Input, { ref, ...props, type: "url" });
|
|
1159
|
+
});
|
|
1160
|
+
InputUrl.displayName = "InputUrl";
|
|
1161
|
+
|
|
1162
|
+
// src/components/input/InputNumber.tsx
|
|
1163
|
+
var import_react10 = __toESM(require("react"));
|
|
1164
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1165
|
+
var InputNumber = import_react10.default.forwardRef((props, ref) => {
|
|
1166
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Input, { ref, ...props, type: "number" });
|
|
1167
|
+
});
|
|
1168
|
+
InputNumber.displayName = "InputNumber";
|
|
1169
|
+
|
|
1170
|
+
// src/components/input/InputDate.tsx
|
|
1171
|
+
var import_react11 = __toESM(require("react"));
|
|
1172
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1173
|
+
var InputDate = import_react11.default.forwardRef((props, ref) => {
|
|
1174
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Input, { ref, ...props, type: "date" });
|
|
1175
|
+
});
|
|
1176
|
+
InputDate.displayName = "InputDate";
|
|
1177
|
+
|
|
1178
|
+
// src/components/input/InputTime.tsx
|
|
1179
|
+
var import_react12 = __toESM(require("react"));
|
|
1180
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1181
|
+
var InputTime = import_react12.default.forwardRef((props, ref) => {
|
|
1182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Input, { ref, ...props, type: "time" });
|
|
1183
|
+
});
|
|
1184
|
+
InputTime.displayName = "InputTime";
|
|
1185
|
+
|
|
1186
|
+
// src/components/input/InputDateTime.tsx
|
|
1187
|
+
var import_react13 = __toESM(require("react"));
|
|
1188
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1189
|
+
var InputDateTime = import_react13.default.forwardRef((props, ref) => {
|
|
1190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Input, { ref, ...props, type: "datetime-local" });
|
|
1191
|
+
});
|
|
1192
|
+
InputDateTime.displayName = "InputDateTime";
|
|
1193
|
+
|
|
1194
|
+
// src/components/tooltip/tooltip.tsx
|
|
1195
|
+
var React19 = __toESM(require("react"));
|
|
1196
|
+
var ReactDOM2 = __toESM(require("react-dom"));
|
|
1197
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1198
|
+
|
|
1199
|
+
// src/components/_shared/HeadingAnchor.tsx
|
|
1200
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1201
|
+
|
|
1202
|
+
// src/components/dialog/Dialog.tsx
|
|
1203
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1204
|
+
var Dialog = ({
|
|
1205
|
+
open,
|
|
1206
|
+
onClose,
|
|
1207
|
+
title,
|
|
1208
|
+
children,
|
|
1209
|
+
size = "md",
|
|
1210
|
+
footer,
|
|
1211
|
+
showCloseButton = true,
|
|
1212
|
+
closeOnBackdropClick = true,
|
|
1213
|
+
closeOnEscape = true,
|
|
1214
|
+
className = "",
|
|
1215
|
+
ariaLabel,
|
|
1216
|
+
ariaDescribedBy
|
|
1217
|
+
}) => {
|
|
1218
|
+
const dialogRef = React21.useRef(null);
|
|
1219
|
+
React21.useEffect(() => {
|
|
1220
|
+
if (!open || !closeOnEscape) return;
|
|
1221
|
+
const handleEscape = (e) => {
|
|
1222
|
+
if (e.key === "Escape") {
|
|
1223
|
+
onClose();
|
|
1224
|
+
}
|
|
1225
|
+
};
|
|
1226
|
+
document.addEventListener("keydown", handleEscape);
|
|
1227
|
+
return () => document.removeEventListener("keydown", handleEscape);
|
|
1228
|
+
}, [open, closeOnEscape, onClose]);
|
|
1229
|
+
React21.useEffect(() => {
|
|
1230
|
+
if (open) {
|
|
1231
|
+
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
1232
|
+
document.body.style.overflow = "hidden";
|
|
1233
|
+
document.body.style.paddingRight = `${scrollbarWidth}px`;
|
|
1234
|
+
} else {
|
|
1235
|
+
document.body.style.overflow = "";
|
|
1236
|
+
document.body.style.paddingRight = "";
|
|
1237
|
+
}
|
|
1238
|
+
return () => {
|
|
1239
|
+
document.body.style.overflow = "";
|
|
1240
|
+
document.body.style.paddingRight = "";
|
|
1241
|
+
};
|
|
1242
|
+
}, [open]);
|
|
1243
|
+
React21.useEffect(() => {
|
|
1244
|
+
if (!open || !dialogRef.current) return;
|
|
1245
|
+
const dialog = dialogRef.current;
|
|
1246
|
+
const focusableElements = dialog.querySelectorAll(
|
|
1247
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
1248
|
+
);
|
|
1249
|
+
const firstElement = focusableElements[0];
|
|
1250
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
1251
|
+
const handleTab = (e) => {
|
|
1252
|
+
if (e.key !== "Tab") return;
|
|
1253
|
+
if (e.shiftKey) {
|
|
1254
|
+
if (document.activeElement === firstElement) {
|
|
1255
|
+
e.preventDefault();
|
|
1256
|
+
lastElement?.focus();
|
|
1257
|
+
}
|
|
1258
|
+
} else {
|
|
1259
|
+
if (document.activeElement === lastElement) {
|
|
1260
|
+
e.preventDefault();
|
|
1261
|
+
firstElement?.focus();
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
dialog.addEventListener("keydown", handleTab);
|
|
1266
|
+
firstElement?.focus();
|
|
1267
|
+
return () => {
|
|
1268
|
+
dialog.removeEventListener("keydown", handleTab);
|
|
1269
|
+
};
|
|
1270
|
+
}, [open]);
|
|
1271
|
+
const handleBackdropClick = (e) => {
|
|
1272
|
+
if (closeOnBackdropClick && e.target === e.currentTarget) {
|
|
1273
|
+
onClose();
|
|
1274
|
+
}
|
|
1275
|
+
};
|
|
1276
|
+
if (!open) return null;
|
|
1277
|
+
const dialogContent = /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "dialog__portal", children: [
|
|
1278
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Backdrop, { onClick: handleBackdropClick, "data-enter": "" }),
|
|
1279
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
1280
|
+
"div",
|
|
1281
|
+
{
|
|
1282
|
+
ref: dialogRef,
|
|
1283
|
+
className: `dialog dialog--${size} ${className}`,
|
|
1284
|
+
role: "dialog",
|
|
1285
|
+
"aria-modal": "true",
|
|
1286
|
+
"aria-label": ariaLabel || title,
|
|
1287
|
+
"aria-describedby": ariaDescribedBy,
|
|
1288
|
+
children: [
|
|
1289
|
+
(title || showCloseButton) && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "dialog__header", children: [
|
|
1290
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h2", { className: "dialog__title", children: title }),
|
|
1291
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1292
|
+
Button,
|
|
1293
|
+
{
|
|
1294
|
+
variant: "ghost",
|
|
1295
|
+
className: "dialog__close",
|
|
1296
|
+
startIcon: ACTION_ICONS.close,
|
|
1297
|
+
iconOnly: true,
|
|
1298
|
+
onClick: onClose,
|
|
1299
|
+
"aria-label": "Close dialog"
|
|
1300
|
+
}
|
|
1301
|
+
)
|
|
1302
|
+
] }),
|
|
1303
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "dialog__content scrollable", children }),
|
|
1304
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "dialog__footer", children: footer })
|
|
1305
|
+
]
|
|
1306
|
+
}
|
|
1307
|
+
)
|
|
1308
|
+
] });
|
|
1309
|
+
return (0, import_react_dom.createPortal)(dialogContent, document.body);
|
|
1310
|
+
};
|
|
1311
|
+
|
|
1312
|
+
// src/components/textarea/RichTextarea.tsx
|
|
1313
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1314
|
+
var defaultToolbarOptions = [
|
|
1315
|
+
"bold",
|
|
1316
|
+
"italic",
|
|
1317
|
+
"underline",
|
|
1318
|
+
"link",
|
|
1319
|
+
"unorderedList",
|
|
1320
|
+
"orderedList"
|
|
1321
|
+
];
|
|
1322
|
+
var iconMap = {
|
|
1323
|
+
bold: "bold",
|
|
1324
|
+
italic: "italic",
|
|
1325
|
+
underline: "underline",
|
|
1326
|
+
strikethrough: "strikethrough",
|
|
1327
|
+
link: "link",
|
|
1328
|
+
unlink: "link-slash",
|
|
1329
|
+
orderedList: "numbered-list",
|
|
1330
|
+
unorderedList: "list-bullet",
|
|
1331
|
+
code: "code-bracket",
|
|
1332
|
+
blockquote: "quote",
|
|
1333
|
+
h1: "h1",
|
|
1334
|
+
h2: "h2",
|
|
1335
|
+
h3: "h3"
|
|
1336
|
+
};
|
|
1337
|
+
var headingOptions = [
|
|
1338
|
+
{ value: "p", label: "Normal" },
|
|
1339
|
+
{ value: "h1", label: "Heading 1" },
|
|
1340
|
+
{ value: "h2", label: "Heading 2" },
|
|
1341
|
+
{ value: "h3", label: "Heading 3" }
|
|
1342
|
+
];
|
|
1343
|
+
var defaultSanitizer = (html) => {
|
|
1344
|
+
return import_dompurify.default.sanitize(html, {
|
|
1345
|
+
ALLOWED_TAGS: [
|
|
1346
|
+
"b",
|
|
1347
|
+
"i",
|
|
1348
|
+
"u",
|
|
1349
|
+
"s",
|
|
1350
|
+
"strong",
|
|
1351
|
+
"em",
|
|
1352
|
+
"a",
|
|
1353
|
+
"ul",
|
|
1354
|
+
"ol",
|
|
1355
|
+
"li",
|
|
1356
|
+
"p",
|
|
1357
|
+
"br",
|
|
1358
|
+
"code",
|
|
1359
|
+
"pre",
|
|
1360
|
+
"blockquote",
|
|
1361
|
+
"h1",
|
|
1362
|
+
"h2",
|
|
1363
|
+
"h3"
|
|
1364
|
+
],
|
|
1365
|
+
ALLOWED_ATTR: ["href", "target", "rel"]
|
|
1366
|
+
});
|
|
1367
|
+
};
|
|
1368
|
+
var RichTextarea = React22.forwardRef(
|
|
1369
|
+
({
|
|
1370
|
+
value,
|
|
1371
|
+
defaultValue,
|
|
1372
|
+
onChange,
|
|
1373
|
+
onSelectionChange,
|
|
1374
|
+
placeholder = "Enter text...",
|
|
1375
|
+
toolbarOptions = defaultToolbarOptions,
|
|
1376
|
+
showTopToolbar = false,
|
|
1377
|
+
readOnly = false,
|
|
1378
|
+
disabled = false,
|
|
1379
|
+
sanitizeHTML = defaultSanitizer,
|
|
1380
|
+
onPaste,
|
|
1381
|
+
ariaLabel,
|
|
1382
|
+
ariaDescribedBy,
|
|
1383
|
+
maxLines,
|
|
1384
|
+
className = "",
|
|
1385
|
+
style,
|
|
1386
|
+
onBlur,
|
|
1387
|
+
onFocus
|
|
1388
|
+
}, ref) => {
|
|
1389
|
+
const editorRef = React22.useRef(null);
|
|
1390
|
+
const [internalHTML, setInternalHTML] = React22.useState(
|
|
1391
|
+
sanitizeHTML(defaultValue || "")
|
|
1392
|
+
);
|
|
1393
|
+
const [showToolbar, setShowToolbar] = React22.useState(false);
|
|
1394
|
+
const [toolbarPosition, setToolbarPosition] = React22.useState({
|
|
1395
|
+
top: 0,
|
|
1396
|
+
left: 0
|
|
1397
|
+
});
|
|
1398
|
+
const [activeFormats, setActiveFormats] = React22.useState(/* @__PURE__ */ new Set());
|
|
1399
|
+
const [currentHeading, setCurrentHeading] = React22.useState("p");
|
|
1400
|
+
const [showLinkDialog, setShowLinkDialog] = React22.useState(false);
|
|
1401
|
+
const [linkUrl, setLinkUrl] = React22.useState("");
|
|
1402
|
+
const [savedRange, setSavedRange] = React22.useState(null);
|
|
1403
|
+
const [showLinkTooltip, setShowLinkTooltip] = React22.useState(false);
|
|
1404
|
+
const [tooltipPosition, setTooltipPosition] = React22.useState({ x: 0, y: 0 });
|
|
1405
|
+
const [isHoldingCtrl, setIsHoldingCtrl] = React22.useState(false);
|
|
1406
|
+
const [shouldScroll, setShouldScroll] = React22.useState(false);
|
|
1407
|
+
const isControlled = value !== void 0;
|
|
1408
|
+
const currentHTML = isControlled ? value : internalHTML;
|
|
1409
|
+
React22.useImperativeHandle(ref, () => editorRef.current);
|
|
1410
|
+
React22.useEffect(() => {
|
|
1411
|
+
if (isControlled && editorRef.current) {
|
|
1412
|
+
const sanitized = sanitizeHTML(value || "");
|
|
1413
|
+
if (editorRef.current.innerHTML !== sanitized) {
|
|
1414
|
+
editorRef.current.innerHTML = sanitized;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}, [value, isControlled, sanitizeHTML]);
|
|
1418
|
+
React22.useEffect(() => {
|
|
1419
|
+
if (!isControlled && editorRef.current && defaultValue) {
|
|
1420
|
+
editorRef.current.innerHTML = sanitizeHTML(defaultValue);
|
|
1421
|
+
}
|
|
1422
|
+
}, []);
|
|
1423
|
+
React22.useEffect(() => {
|
|
1424
|
+
const handleGlobalKeyDown = (event) => {
|
|
1425
|
+
const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
|
|
1426
|
+
const modKey = isMac ? event.metaKey : event.ctrlKey;
|
|
1427
|
+
if (modKey && !isHoldingCtrl) {
|
|
1428
|
+
setIsHoldingCtrl(true);
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
const handleGlobalKeyUp = (event) => {
|
|
1432
|
+
const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
|
|
1433
|
+
const modKey = isMac ? event.metaKey : event.ctrlKey;
|
|
1434
|
+
if (!modKey && isHoldingCtrl) {
|
|
1435
|
+
setIsHoldingCtrl(false);
|
|
1436
|
+
}
|
|
1437
|
+
};
|
|
1438
|
+
document.addEventListener("keydown", handleGlobalKeyDown);
|
|
1439
|
+
document.addEventListener("keyup", handleGlobalKeyUp);
|
|
1440
|
+
return () => {
|
|
1441
|
+
document.removeEventListener("keydown", handleGlobalKeyDown);
|
|
1442
|
+
document.removeEventListener("keyup", handleGlobalKeyUp);
|
|
1443
|
+
};
|
|
1444
|
+
}, [isHoldingCtrl]);
|
|
1445
|
+
React22.useEffect(() => {
|
|
1446
|
+
if (!maxLines || !editorRef.current) return;
|
|
1447
|
+
const calculateHeight = () => {
|
|
1448
|
+
const editor = editorRef.current;
|
|
1449
|
+
if (!editor) return;
|
|
1450
|
+
const computedStyle = window.getComputedStyle(editor);
|
|
1451
|
+
const lineHeight = parseFloat(computedStyle.lineHeight) || 1.2 * parseFloat(computedStyle.fontSize);
|
|
1452
|
+
const maxHeight = maxLines * lineHeight;
|
|
1453
|
+
const contentHeight = editor.scrollHeight;
|
|
1454
|
+
setShouldScroll(contentHeight > maxHeight);
|
|
1455
|
+
if (maxLines) {
|
|
1456
|
+
editor.style.maxHeight = `${maxHeight}px`;
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1459
|
+
calculateHeight();
|
|
1460
|
+
const handleResize = () => calculateHeight();
|
|
1461
|
+
window.addEventListener("resize", handleResize);
|
|
1462
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
1463
|
+
}, [maxLines, currentHTML]);
|
|
1464
|
+
const execCommand = (command, value2 = null) => {
|
|
1465
|
+
document.execCommand(command, false, value2 || void 0);
|
|
1466
|
+
editorRef.current?.focus();
|
|
1467
|
+
updateActiveFormats();
|
|
1468
|
+
handleContentChange();
|
|
1469
|
+
};
|
|
1470
|
+
const applyHeading = (headingTag) => {
|
|
1471
|
+
if (headingTag === "p") {
|
|
1472
|
+
execCommand("formatBlock", "<p>");
|
|
1473
|
+
} else {
|
|
1474
|
+
execCommand("formatBlock", `<${headingTag}>`);
|
|
1475
|
+
}
|
|
1476
|
+
setCurrentHeading(headingTag);
|
|
1477
|
+
};
|
|
1478
|
+
const handleInput = () => {
|
|
1479
|
+
handleContentChange();
|
|
1480
|
+
};
|
|
1481
|
+
const handleContentChange = () => {
|
|
1482
|
+
if (!editorRef.current) return;
|
|
1483
|
+
const html = editorRef.current.innerHTML;
|
|
1484
|
+
const sanitized = sanitizeHTML(html);
|
|
1485
|
+
if (isControlled) {
|
|
1486
|
+
onChange?.(sanitized);
|
|
1487
|
+
} else {
|
|
1488
|
+
setInternalHTML(sanitized);
|
|
1489
|
+
onChange?.(sanitized);
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1492
|
+
const handlePaste = (event) => {
|
|
1493
|
+
if (onPaste && onPaste(event)) {
|
|
1494
|
+
return;
|
|
1495
|
+
}
|
|
1496
|
+
event.preventDefault();
|
|
1497
|
+
const text = event.clipboardData.getData("text/html") || event.clipboardData.getData("text/plain");
|
|
1498
|
+
const sanitized = sanitizeHTML(text);
|
|
1499
|
+
document.execCommand("insertHTML", false, sanitized);
|
|
1500
|
+
handleContentChange();
|
|
1501
|
+
};
|
|
1502
|
+
const handleKeyDown = (event) => {
|
|
1503
|
+
const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
|
|
1504
|
+
const modKey = isMac ? event.metaKey : event.ctrlKey;
|
|
1505
|
+
if (modKey) {
|
|
1506
|
+
switch (event.key.toLowerCase()) {
|
|
1507
|
+
case "b":
|
|
1508
|
+
event.preventDefault();
|
|
1509
|
+
execCommand("bold");
|
|
1510
|
+
break;
|
|
1511
|
+
case "i":
|
|
1512
|
+
event.preventDefault();
|
|
1513
|
+
execCommand("italic");
|
|
1514
|
+
break;
|
|
1515
|
+
case "u":
|
|
1516
|
+
event.preventDefault();
|
|
1517
|
+
execCommand("underline");
|
|
1518
|
+
break;
|
|
1519
|
+
case "k":
|
|
1520
|
+
event.preventDefault();
|
|
1521
|
+
handleLinkCommand();
|
|
1522
|
+
break;
|
|
1523
|
+
default:
|
|
1524
|
+
break;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
if (event.key === "Escape") {
|
|
1528
|
+
setShowToolbar(false);
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
const handleLinkCommand = () => {
|
|
1532
|
+
const selection = window.getSelection();
|
|
1533
|
+
if (selection && selection.rangeCount > 0) {
|
|
1534
|
+
setSavedRange(selection.getRangeAt(0).cloneRange());
|
|
1535
|
+
} else {
|
|
1536
|
+
setSavedRange(null);
|
|
1537
|
+
}
|
|
1538
|
+
setShowLinkDialog(true);
|
|
1539
|
+
};
|
|
1540
|
+
const handleLinkSubmit = () => {
|
|
1541
|
+
if (linkUrl) {
|
|
1542
|
+
const selection = window.getSelection();
|
|
1543
|
+
if (selection && savedRange) {
|
|
1544
|
+
try {
|
|
1545
|
+
selection.removeAllRanges();
|
|
1546
|
+
selection.addRange(savedRange);
|
|
1547
|
+
} catch (e) {
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
const currentSelection = window.getSelection();
|
|
1551
|
+
if (currentSelection && !currentSelection.isCollapsed) {
|
|
1552
|
+
execCommand("createLink", linkUrl);
|
|
1553
|
+
} else {
|
|
1554
|
+
execCommand("insertHTML", `<a href="${linkUrl.replace(/"/g, """)}" target="_blank" rel="noopener noreferrer">${linkUrl}</a>`);
|
|
1555
|
+
}
|
|
1556
|
+
setLinkUrl("");
|
|
1557
|
+
setSavedRange(null);
|
|
1558
|
+
}
|
|
1559
|
+
setShowLinkDialog(false);
|
|
1560
|
+
};
|
|
1561
|
+
const handleLinkCancel = () => {
|
|
1562
|
+
setLinkUrl("");
|
|
1563
|
+
setSavedRange(null);
|
|
1564
|
+
setShowLinkDialog(false);
|
|
1565
|
+
};
|
|
1566
|
+
const handleSelectionChange = () => {
|
|
1567
|
+
const selection = window.getSelection();
|
|
1568
|
+
onSelectionChange?.(selection);
|
|
1569
|
+
if (!selection || selection.isCollapsed) {
|
|
1570
|
+
setShowToolbar(false);
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
const range = selection.getRangeAt(0);
|
|
1574
|
+
if (!editorRef.current?.contains(range.commonAncestorContainer)) {
|
|
1575
|
+
setShowToolbar(false);
|
|
1576
|
+
return;
|
|
1577
|
+
}
|
|
1578
|
+
updateActiveFormats();
|
|
1579
|
+
updateToolbarPosition(range);
|
|
1580
|
+
setShowToolbar(true);
|
|
1581
|
+
};
|
|
1582
|
+
const updateToolbarPosition = (range) => {
|
|
1583
|
+
const rect = range.getBoundingClientRect();
|
|
1584
|
+
const editorRect = editorRef.current?.getBoundingClientRect();
|
|
1585
|
+
if (!editorRect) return;
|
|
1586
|
+
setToolbarPosition({
|
|
1587
|
+
top: rect.top - editorRect.top - 48,
|
|
1588
|
+
// 48px above selection
|
|
1589
|
+
left: rect.left - editorRect.left + rect.width / 2
|
|
1590
|
+
});
|
|
1591
|
+
};
|
|
1592
|
+
const updateActiveFormats = () => {
|
|
1593
|
+
const formats = /* @__PURE__ */ new Set();
|
|
1594
|
+
if (document.queryCommandState("bold")) formats.add("bold");
|
|
1595
|
+
if (document.queryCommandState("italic")) formats.add("italic");
|
|
1596
|
+
if (document.queryCommandState("underline")) formats.add("underline");
|
|
1597
|
+
if (document.queryCommandState("strikeThrough"))
|
|
1598
|
+
formats.add("strikethrough");
|
|
1599
|
+
if (document.queryCommandState("insertOrderedList"))
|
|
1600
|
+
formats.add("orderedList");
|
|
1601
|
+
if (document.queryCommandState("insertUnorderedList"))
|
|
1602
|
+
formats.add("unorderedList");
|
|
1603
|
+
setActiveFormats(formats);
|
|
1604
|
+
};
|
|
1605
|
+
const handleEditorFocus = (event) => {
|
|
1606
|
+
onFocus?.(event);
|
|
1607
|
+
document.addEventListener("selectionchange", handleSelectionChange);
|
|
1608
|
+
};
|
|
1609
|
+
const handleEditorBlur = (event) => {
|
|
1610
|
+
setTimeout(() => {
|
|
1611
|
+
const activeElement = document.activeElement;
|
|
1612
|
+
const isToolbarClick = activeElement?.closest(".rich-textarea__toolbar");
|
|
1613
|
+
if (!isToolbarClick) {
|
|
1614
|
+
setShowToolbar(false);
|
|
1615
|
+
document.removeEventListener(
|
|
1616
|
+
"selectionchange",
|
|
1617
|
+
handleSelectionChange
|
|
1618
|
+
);
|
|
1619
|
+
}
|
|
1620
|
+
}, 150);
|
|
1621
|
+
onBlur?.(event);
|
|
1622
|
+
};
|
|
1623
|
+
const handleEditorClick = (event) => {
|
|
1624
|
+
const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
|
|
1625
|
+
const modKey = isMac ? event.metaKey : event.ctrlKey;
|
|
1626
|
+
if (modKey) {
|
|
1627
|
+
const target = event.target;
|
|
1628
|
+
let linkElement = null;
|
|
1629
|
+
if (target.tagName === "A") {
|
|
1630
|
+
linkElement = target;
|
|
1631
|
+
} else {
|
|
1632
|
+
linkElement = target.closest("a");
|
|
1633
|
+
}
|
|
1634
|
+
if (linkElement && linkElement.href) {
|
|
1635
|
+
event.preventDefault();
|
|
1636
|
+
window.open(linkElement.href, "_blank", "noopener,noreferrer");
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
};
|
|
1640
|
+
const handleEditorMouseMove = (event) => {
|
|
1641
|
+
const target = event.target;
|
|
1642
|
+
let linkElement = null;
|
|
1643
|
+
if (target.tagName === "A") {
|
|
1644
|
+
linkElement = target;
|
|
1645
|
+
} else {
|
|
1646
|
+
linkElement = target.closest("a");
|
|
1647
|
+
}
|
|
1648
|
+
if (linkElement && linkElement.href) {
|
|
1649
|
+
const rect = linkElement.getBoundingClientRect();
|
|
1650
|
+
const editorRect = editorRef.current?.getBoundingClientRect();
|
|
1651
|
+
if (editorRect) {
|
|
1652
|
+
setTooltipPosition({
|
|
1653
|
+
x: rect.left - editorRect.left,
|
|
1654
|
+
y: rect.top - editorRect.top + 32
|
|
1655
|
+
});
|
|
1656
|
+
setShowLinkTooltip(true);
|
|
1657
|
+
}
|
|
1658
|
+
} else {
|
|
1659
|
+
setShowLinkTooltip(false);
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
const handleEditorMouseLeave = () => {
|
|
1663
|
+
setShowLinkTooltip(false);
|
|
1664
|
+
};
|
|
1665
|
+
const renderToolbarButton = (option) => {
|
|
1666
|
+
const isActive = activeFormats.has(option);
|
|
1667
|
+
const handleClick = () => {
|
|
1668
|
+
switch (option) {
|
|
1669
|
+
case "bold":
|
|
1670
|
+
execCommand("bold");
|
|
1671
|
+
break;
|
|
1672
|
+
case "italic":
|
|
1673
|
+
execCommand("italic");
|
|
1674
|
+
break;
|
|
1675
|
+
case "underline":
|
|
1676
|
+
execCommand("underline");
|
|
1677
|
+
break;
|
|
1678
|
+
case "strikethrough":
|
|
1679
|
+
execCommand("strikeThrough");
|
|
1680
|
+
break;
|
|
1681
|
+
case "link":
|
|
1682
|
+
handleLinkCommand();
|
|
1683
|
+
break;
|
|
1684
|
+
case "unlink":
|
|
1685
|
+
execCommand("unlink");
|
|
1686
|
+
break;
|
|
1687
|
+
case "orderedList":
|
|
1688
|
+
execCommand("insertOrderedList");
|
|
1689
|
+
break;
|
|
1690
|
+
case "unorderedList":
|
|
1691
|
+
execCommand("insertUnorderedList");
|
|
1692
|
+
break;
|
|
1693
|
+
case "code":
|
|
1694
|
+
execCommand("formatBlock", "<pre>");
|
|
1695
|
+
break;
|
|
1696
|
+
case "blockquote":
|
|
1697
|
+
execCommand("formatBlock", "<blockquote>");
|
|
1698
|
+
break;
|
|
1699
|
+
case "h1":
|
|
1700
|
+
execCommand("formatBlock", "<h1>");
|
|
1701
|
+
break;
|
|
1702
|
+
case "h2":
|
|
1703
|
+
execCommand("formatBlock", "<h2>");
|
|
1704
|
+
break;
|
|
1705
|
+
case "h3":
|
|
1706
|
+
execCommand("formatBlock", "<h3>");
|
|
1707
|
+
break;
|
|
1708
|
+
default:
|
|
1709
|
+
break;
|
|
1710
|
+
}
|
|
1711
|
+
};
|
|
1712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1713
|
+
"button",
|
|
1714
|
+
{
|
|
1715
|
+
type: "button",
|
|
1716
|
+
className: `rich-textarea__toolbar-button ${isActive ? "rich-textarea__toolbar-button--active" : ""}`,
|
|
1717
|
+
onClick: handleClick,
|
|
1718
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
1719
|
+
"aria-label": option,
|
|
1720
|
+
"aria-pressed": isActive,
|
|
1721
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Icon, { name: `${iconMap[option]}`, size: 16 })
|
|
1722
|
+
},
|
|
1723
|
+
option
|
|
1724
|
+
);
|
|
1725
|
+
};
|
|
1726
|
+
const editorClasses = [
|
|
1727
|
+
"rich-textarea",
|
|
1728
|
+
shouldScroll && "scrollable",
|
|
1729
|
+
disabled && "rich-textarea--disabled",
|
|
1730
|
+
readOnly && "rich-textarea--readonly",
|
|
1731
|
+
className
|
|
1732
|
+
].filter(Boolean).join(" ");
|
|
1733
|
+
const isEmpty = !currentHTML || currentHTML === "<br>";
|
|
1734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: `rich-textarea-container ${showTopToolbar ? "rich-textarea-container--with-top-toolbar" : ""} ${isHoldingCtrl ? "rich-textarea-container--holding-ctrl" : ""}`, style, children: [
|
|
1735
|
+
showTopToolbar && !readOnly && !disabled && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(FloatingBar, { position: "top", className: "rich-textarea__top-toolbar", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "rich-textarea__top-toolbar-content", children: [
|
|
1736
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1737
|
+
Select,
|
|
1738
|
+
{
|
|
1739
|
+
options: headingOptions,
|
|
1740
|
+
value: currentHeading,
|
|
1741
|
+
onChange: (value2) => applyHeading(value2),
|
|
1742
|
+
placeholder: "Format",
|
|
1743
|
+
className: "rich-textarea__heading-select"
|
|
1744
|
+
}
|
|
1745
|
+
),
|
|
1746
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "rich-textarea__top-toolbar-buttons", children: toolbarOptions.map((option) => {
|
|
1747
|
+
const isActive = activeFormats.has(option);
|
|
1748
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1749
|
+
Button,
|
|
1750
|
+
{
|
|
1751
|
+
variant: isActive ? "primary" : "ghost",
|
|
1752
|
+
size: "sm",
|
|
1753
|
+
onClick: () => {
|
|
1754
|
+
switch (option) {
|
|
1755
|
+
case "bold":
|
|
1756
|
+
execCommand("bold");
|
|
1757
|
+
break;
|
|
1758
|
+
case "italic":
|
|
1759
|
+
execCommand("italic");
|
|
1760
|
+
break;
|
|
1761
|
+
case "underline":
|
|
1762
|
+
execCommand("underline");
|
|
1763
|
+
break;
|
|
1764
|
+
case "strikethrough":
|
|
1765
|
+
execCommand("strikeThrough");
|
|
1766
|
+
break;
|
|
1767
|
+
case "link":
|
|
1768
|
+
handleLinkCommand();
|
|
1769
|
+
break;
|
|
1770
|
+
case "unlink":
|
|
1771
|
+
execCommand("unlink");
|
|
1772
|
+
break;
|
|
1773
|
+
case "orderedList":
|
|
1774
|
+
execCommand("insertOrderedList");
|
|
1775
|
+
break;
|
|
1776
|
+
case "unorderedList":
|
|
1777
|
+
execCommand("insertUnorderedList");
|
|
1778
|
+
break;
|
|
1779
|
+
case "code":
|
|
1780
|
+
execCommand("formatBlock", "<pre>");
|
|
1781
|
+
break;
|
|
1782
|
+
case "blockquote":
|
|
1783
|
+
execCommand("formatBlock", "<blockquote>");
|
|
1784
|
+
break;
|
|
1785
|
+
case "h1":
|
|
1786
|
+
applyHeading("h1");
|
|
1787
|
+
break;
|
|
1788
|
+
case "h2":
|
|
1789
|
+
applyHeading("h2");
|
|
1790
|
+
break;
|
|
1791
|
+
case "h3":
|
|
1792
|
+
applyHeading("h3");
|
|
1793
|
+
break;
|
|
1794
|
+
default:
|
|
1795
|
+
break;
|
|
1796
|
+
}
|
|
1797
|
+
},
|
|
1798
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
1799
|
+
"aria-label": option,
|
|
1800
|
+
"aria-pressed": isActive,
|
|
1801
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Icon, { name: `${iconMap[option]}`, size: 16 })
|
|
1802
|
+
},
|
|
1803
|
+
option
|
|
1804
|
+
);
|
|
1805
|
+
}) })
|
|
1806
|
+
] }) }),
|
|
1807
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1808
|
+
"div",
|
|
1809
|
+
{
|
|
1810
|
+
ref: editorRef,
|
|
1811
|
+
className: editorClasses,
|
|
1812
|
+
contentEditable: !disabled && !readOnly,
|
|
1813
|
+
role: "textbox",
|
|
1814
|
+
"aria-label": ariaLabel,
|
|
1815
|
+
"aria-describedby": ariaDescribedBy,
|
|
1816
|
+
"aria-multiline": "true",
|
|
1817
|
+
"aria-readonly": readOnly,
|
|
1818
|
+
"aria-disabled": disabled,
|
|
1819
|
+
onInput: handleInput,
|
|
1820
|
+
onPaste: handlePaste,
|
|
1821
|
+
onKeyDown: handleKeyDown,
|
|
1822
|
+
onClick: handleEditorClick,
|
|
1823
|
+
onMouseMove: handleEditorMouseMove,
|
|
1824
|
+
onMouseLeave: handleEditorMouseLeave,
|
|
1825
|
+
onFocus: handleEditorFocus,
|
|
1826
|
+
onBlur: handleEditorBlur,
|
|
1827
|
+
"data-placeholder": isEmpty ? placeholder : void 0,
|
|
1828
|
+
suppressContentEditableWarning: true
|
|
1829
|
+
}
|
|
1830
|
+
),
|
|
1831
|
+
showToolbar && !readOnly && !disabled && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1832
|
+
"div",
|
|
1833
|
+
{
|
|
1834
|
+
className: "rich-textarea__toolbar",
|
|
1835
|
+
style: {
|
|
1836
|
+
top: `${toolbarPosition.top}px`,
|
|
1837
|
+
left: `${toolbarPosition.left}px`
|
|
1838
|
+
},
|
|
1839
|
+
role: "toolbar",
|
|
1840
|
+
"aria-label": "Text formatting",
|
|
1841
|
+
children: toolbarOptions.map(renderToolbarButton)
|
|
1842
|
+
}
|
|
1843
|
+
),
|
|
1844
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1845
|
+
Dialog,
|
|
1846
|
+
{
|
|
1847
|
+
open: showLinkDialog,
|
|
1848
|
+
onClose: handleLinkCancel,
|
|
1849
|
+
title: "Insert Link",
|
|
1850
|
+
size: "sm",
|
|
1851
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
1852
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button, { variant: "ghost", onClick: handleLinkCancel, children: "Cancel" }),
|
|
1853
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button, { variant: "primary", onClick: handleLinkSubmit, children: "Insert" })
|
|
1854
|
+
] }),
|
|
1855
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1856
|
+
InputText,
|
|
1857
|
+
{
|
|
1858
|
+
label: "URL",
|
|
1859
|
+
value: linkUrl,
|
|
1860
|
+
onChange: (e) => setLinkUrl(e.target.value),
|
|
1861
|
+
placeholder: "https://example.com",
|
|
1862
|
+
autoFocus: true,
|
|
1863
|
+
onKeyDown: (e) => {
|
|
1864
|
+
if (e.key === "Enter") {
|
|
1865
|
+
e.preventDefault();
|
|
1866
|
+
handleLinkSubmit();
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
)
|
|
1871
|
+
}
|
|
1872
|
+
),
|
|
1873
|
+
showLinkTooltip && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
1874
|
+
"div",
|
|
1875
|
+
{
|
|
1876
|
+
className: "rich-textarea__link-tooltip",
|
|
1877
|
+
style: {
|
|
1878
|
+
position: "absolute",
|
|
1879
|
+
top: `${tooltipPosition.y}px`,
|
|
1880
|
+
left: `${tooltipPosition.x}px`,
|
|
1881
|
+
backgroundColor: "var(--color-bg-1)",
|
|
1882
|
+
color: "var(--color-foreground-1)",
|
|
1883
|
+
padding: "4px 8px",
|
|
1884
|
+
borderRadius: "4px",
|
|
1885
|
+
fontSize: "12px",
|
|
1886
|
+
whiteSpace: "nowrap",
|
|
1887
|
+
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
|
|
1888
|
+
zIndex: 1e3,
|
|
1889
|
+
pointerEvents: "none",
|
|
1890
|
+
border: "1px solid var(--color-border-1)"
|
|
1891
|
+
},
|
|
1892
|
+
children: [
|
|
1893
|
+
navigator.platform.toUpperCase().indexOf("MAC") >= 0 ? "CMD" : "CTRL",
|
|
1894
|
+
" + Click to access URL"
|
|
1895
|
+
]
|
|
1896
|
+
}
|
|
1897
|
+
)
|
|
1898
|
+
] });
|
|
1899
|
+
}
|
|
1900
|
+
);
|
|
1901
|
+
RichTextarea.displayName = "RichTextarea";
|
|
1902
|
+
|
|
1903
|
+
// src/components/textarea/Textarea.tsx
|
|
1904
|
+
var React23 = __toESM(require("react"));
|
|
1905
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1906
|
+
var Textarea = React23.forwardRef(
|
|
1907
|
+
({
|
|
1908
|
+
label,
|
|
1909
|
+
helperText,
|
|
1910
|
+
error,
|
|
1911
|
+
fullWidth = false,
|
|
1912
|
+
size = "md",
|
|
1913
|
+
className = "",
|
|
1914
|
+
rows = 3,
|
|
1915
|
+
resize = "vertical",
|
|
1916
|
+
style,
|
|
1917
|
+
...props
|
|
1918
|
+
}, ref) => {
|
|
1919
|
+
const textareaId = React23.useId();
|
|
1920
|
+
const errorId = React23.useId();
|
|
1921
|
+
const helperId = React23.useId();
|
|
1922
|
+
const textareaClasses = [
|
|
1923
|
+
"input-field",
|
|
1924
|
+
"input-field--textarea",
|
|
1925
|
+
`input-field--${size}`,
|
|
1926
|
+
fullWidth && "input-field--full-width",
|
|
1927
|
+
error && "input-field--error",
|
|
1928
|
+
className
|
|
1929
|
+
].filter(Boolean).join(" ");
|
|
1930
|
+
const containerClasses = [
|
|
1931
|
+
"input-container",
|
|
1932
|
+
fullWidth && "input-container--full-width"
|
|
1933
|
+
].filter(Boolean).join(" ");
|
|
1934
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: containerClasses, children: [
|
|
1935
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("label", { htmlFor: textareaId, className: "input-label", children: label }),
|
|
1936
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "input-field-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1937
|
+
"textarea",
|
|
1938
|
+
{
|
|
1939
|
+
...props,
|
|
1940
|
+
ref,
|
|
1941
|
+
id: textareaId,
|
|
1942
|
+
rows,
|
|
1943
|
+
className: textareaClasses,
|
|
1944
|
+
style: {
|
|
1945
|
+
resize,
|
|
1946
|
+
...style
|
|
1947
|
+
},
|
|
1948
|
+
"aria-invalid": !!error,
|
|
1949
|
+
"aria-describedby": [error && errorId, helperText && helperId].filter(Boolean).join(" ") || void 0
|
|
1950
|
+
}
|
|
1951
|
+
) }),
|
|
1952
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { id: errorId, className: "input-error", role: "alert", children: error }),
|
|
1953
|
+
helperText && !error && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { id: helperId, className: "input-helper", children: helperText })
|
|
1954
|
+
] });
|
|
1955
|
+
}
|
|
1956
|
+
);
|
|
1957
|
+
Textarea.displayName = "Textarea";
|
|
1958
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1959
|
+
0 && (module.exports = {
|
|
1960
|
+
RichTextarea,
|
|
1961
|
+
Textarea
|
|
1962
|
+
});
|