@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,1111 @@
|
|
|
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/dialog/index.ts
|
|
31
|
+
var dialog_exports = {};
|
|
32
|
+
__export(dialog_exports, {
|
|
33
|
+
Dialog: () => Dialog
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(dialog_exports);
|
|
36
|
+
|
|
37
|
+
// src/components/dialog/Dialog.tsx
|
|
38
|
+
var React20 = __toESM(require("react"));
|
|
39
|
+
var import_react_dom = require("react-dom");
|
|
40
|
+
|
|
41
|
+
// src/components/button/button.tsx
|
|
42
|
+
var import_react2 = __toESM(require("react"));
|
|
43
|
+
var import_react3 = require("@ariakit/react");
|
|
44
|
+
|
|
45
|
+
// src/components/icons/icons.tsx
|
|
46
|
+
var import_react = require("@iconify/react");
|
|
47
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
|
+
var Icon = ({ name, size = 24, className, loading = false, ...rest }) => {
|
|
49
|
+
const iconName = name.includes(":") ? name : `heroicons:${name}`;
|
|
50
|
+
const classes = ["icon", className].filter(Boolean).join(" ");
|
|
51
|
+
if (loading) {
|
|
52
|
+
const style = { width: size, height: size };
|
|
53
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
54
|
+
"span",
|
|
55
|
+
{
|
|
56
|
+
className: `${classes} icon--skeleton`,
|
|
57
|
+
style,
|
|
58
|
+
"aria-hidden": rest["aria-label"] ? "false" : "true",
|
|
59
|
+
...rest["aria-label"] ? { "aria-label": rest["aria-label"] } : {}
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
|
+
import_react.Icon,
|
|
65
|
+
{
|
|
66
|
+
icon: iconName,
|
|
67
|
+
width: size,
|
|
68
|
+
height: size,
|
|
69
|
+
className: classes,
|
|
70
|
+
...rest
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// src/components/icons/iconConstants.ts
|
|
76
|
+
var INPUT_TYPE_ICONS = {
|
|
77
|
+
// Standard HTML input types
|
|
78
|
+
email: "envelope-solid",
|
|
79
|
+
password: "lock-closed-solid",
|
|
80
|
+
search: "magnifying-glass-solid",
|
|
81
|
+
date: "calendar-days-solid",
|
|
82
|
+
time: "clock-solid",
|
|
83
|
+
"datetime-local": "calendar-days-solid",
|
|
84
|
+
tel: "phone-solid",
|
|
85
|
+
url: "link-solid",
|
|
86
|
+
number: "hashtag-solid",
|
|
87
|
+
// Additional semantic types
|
|
88
|
+
username: "user-solid",
|
|
89
|
+
name: "user-solid",
|
|
90
|
+
firstname: "user-solid",
|
|
91
|
+
lastname: "user-solid",
|
|
92
|
+
address: "map-pin-solid",
|
|
93
|
+
city: "building-solid",
|
|
94
|
+
state: "map-solid",
|
|
95
|
+
zip: "map-pin-solid",
|
|
96
|
+
"zip-code": "map-pin-solid",
|
|
97
|
+
country: "globe-americas-solid",
|
|
98
|
+
creditcard: "credit-card-solid",
|
|
99
|
+
card: "credit-card-solid",
|
|
100
|
+
cvv: "lock-closed-solid",
|
|
101
|
+
expiry: "calendar-days-solid",
|
|
102
|
+
"expiration-date": "calendar-days-solid",
|
|
103
|
+
// File and media types
|
|
104
|
+
file: "document-solid",
|
|
105
|
+
image: "photo-solid",
|
|
106
|
+
video: "video-camera-solid",
|
|
107
|
+
audio: "microphone-solid",
|
|
108
|
+
// Communication
|
|
109
|
+
message: "chat-bubble-left-solid",
|
|
110
|
+
comment: "chat-bubble-left-solid",
|
|
111
|
+
feedback: "chat-bubble-left-solid",
|
|
112
|
+
// Actions and states
|
|
113
|
+
submit: "paper-airplane-solid",
|
|
114
|
+
send: "paper-airplane-solid",
|
|
115
|
+
save: "floppy-disk-solid",
|
|
116
|
+
edit: "pencil-solid",
|
|
117
|
+
delete: "trash-solid",
|
|
118
|
+
remove: "x-mark-solid",
|
|
119
|
+
add: "plus-solid",
|
|
120
|
+
create: "plus-solid",
|
|
121
|
+
upload: "arrow-up-tray-solid",
|
|
122
|
+
download: "arrow-down-tray-solid",
|
|
123
|
+
refresh: "arrow-path-solid",
|
|
124
|
+
reload: "arrow-path-solid",
|
|
125
|
+
settings: "cog-solid",
|
|
126
|
+
config: "cog-solid",
|
|
127
|
+
filter: "funnel-solid",
|
|
128
|
+
sort: "bars-arrow-up-solid"
|
|
129
|
+
};
|
|
130
|
+
var ACTION_ICONS = {
|
|
131
|
+
close: "x-mark-solid",
|
|
132
|
+
back: "arrow-left-solid",
|
|
133
|
+
forward: "arrow-right-solid",
|
|
134
|
+
up: "arrow-up-solid",
|
|
135
|
+
down: "arrow-down-solid",
|
|
136
|
+
expand: "chevron-down-solid",
|
|
137
|
+
collapse: "chevron-up-solid",
|
|
138
|
+
menu: "bars-3-solid",
|
|
139
|
+
more: "ellipsis-horizontal-solid",
|
|
140
|
+
check: "check-solid",
|
|
141
|
+
cross: "x-mark-solid",
|
|
142
|
+
plus: "plus-solid",
|
|
143
|
+
minus: "minus-solid",
|
|
144
|
+
search: "magnifying-glass-solid",
|
|
145
|
+
clear: "x-mark-solid",
|
|
146
|
+
loading: "arrow-path-solid",
|
|
147
|
+
error: "exclamation-triangle-solid",
|
|
148
|
+
warning: "exclamation-triangle-solid",
|
|
149
|
+
info: "information-circle-solid",
|
|
150
|
+
success: "check-circle-solid"
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// src/components/button/button.tsx
|
|
154
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
155
|
+
var Button = import_react2.default.forwardRef(
|
|
156
|
+
({
|
|
157
|
+
variant = "primary",
|
|
158
|
+
size = "md",
|
|
159
|
+
children,
|
|
160
|
+
isLoading = false,
|
|
161
|
+
disabled = false,
|
|
162
|
+
fullWidth = false,
|
|
163
|
+
startIcon,
|
|
164
|
+
endIcon,
|
|
165
|
+
iconOnly = false,
|
|
166
|
+
href,
|
|
167
|
+
active = false,
|
|
168
|
+
className,
|
|
169
|
+
onClick,
|
|
170
|
+
...props
|
|
171
|
+
}, ref) => {
|
|
172
|
+
const buttonClasses = [
|
|
173
|
+
"btn",
|
|
174
|
+
`btn--${variant}`,
|
|
175
|
+
`btn--${size}`,
|
|
176
|
+
fullWidth && "btn--full-width",
|
|
177
|
+
iconOnly && "btn--icon-only",
|
|
178
|
+
active && "btn--active",
|
|
179
|
+
className
|
|
180
|
+
].filter(Boolean).join(" ");
|
|
181
|
+
const iconSize = size === "xs" ? 14 : size === "sm" ? 16 : size === "lg" ? 24 : 20;
|
|
182
|
+
const buttonContent = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
183
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "btn__spinner" }),
|
|
184
|
+
startIcon && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "btn__icon-placeholder", style: { width: iconSize, height: iconSize } }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: startIcon, size: iconSize, className: "btn__icon" })),
|
|
185
|
+
!iconOnly && children,
|
|
186
|
+
endIcon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: endIcon, size: iconSize, className: "btn__icon" })
|
|
187
|
+
] });
|
|
188
|
+
const handleClick = (e) => {
|
|
189
|
+
if (href && !isLoading && !disabled) {
|
|
190
|
+
window.location.href = href;
|
|
191
|
+
}
|
|
192
|
+
onClick?.(e);
|
|
193
|
+
};
|
|
194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
195
|
+
import_react3.Button,
|
|
196
|
+
{
|
|
197
|
+
ref,
|
|
198
|
+
disabled: disabled || isLoading,
|
|
199
|
+
className: buttonClasses,
|
|
200
|
+
onClick: handleClick,
|
|
201
|
+
...props,
|
|
202
|
+
children: buttonContent
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
Button.displayName = "Button";
|
|
208
|
+
|
|
209
|
+
// src/components/_shared/Backdrop.tsx
|
|
210
|
+
var React2 = __toESM(require("react"));
|
|
211
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
212
|
+
var Backdrop = React2.forwardRef(
|
|
213
|
+
({ className = "", blur = true, style, ...props }, ref) => {
|
|
214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
215
|
+
"div",
|
|
216
|
+
{
|
|
217
|
+
ref,
|
|
218
|
+
className: `backdrop ${blur ? "backdrop--blur" : ""} ${className}`,
|
|
219
|
+
style,
|
|
220
|
+
"aria-hidden": "true",
|
|
221
|
+
...props
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
Backdrop.displayName = "Backdrop";
|
|
227
|
+
|
|
228
|
+
// src/components/_shared/Thumb.tsx
|
|
229
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
230
|
+
|
|
231
|
+
// src/components/_shared/HeadingAnchor.tsx
|
|
232
|
+
var import_react14 = require("react");
|
|
233
|
+
|
|
234
|
+
// src/components/input/InputText.tsx
|
|
235
|
+
var import_react4 = __toESM(require("react"));
|
|
236
|
+
|
|
237
|
+
// src/components/input/Input.tsx
|
|
238
|
+
var React7 = __toESM(require("react"));
|
|
239
|
+
|
|
240
|
+
// src/components/input/InputField.tsx
|
|
241
|
+
var React3 = __toESM(require("react"));
|
|
242
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
243
|
+
var InputField = React3.forwardRef(
|
|
244
|
+
({
|
|
245
|
+
type = "text",
|
|
246
|
+
label,
|
|
247
|
+
helperText,
|
|
248
|
+
error,
|
|
249
|
+
icon,
|
|
250
|
+
iconRight,
|
|
251
|
+
fullWidth = false,
|
|
252
|
+
size = "md",
|
|
253
|
+
className = "",
|
|
254
|
+
disabled,
|
|
255
|
+
id,
|
|
256
|
+
onRightIconClick,
|
|
257
|
+
...props
|
|
258
|
+
}, ref) => {
|
|
259
|
+
const inputId = id || `input-${React3.useId()}`;
|
|
260
|
+
const containerClasses = [
|
|
261
|
+
"input-container",
|
|
262
|
+
fullWidth && "input-container--full-width",
|
|
263
|
+
className
|
|
264
|
+
].filter(Boolean).join(" ");
|
|
265
|
+
const inputClasses = [
|
|
266
|
+
"input",
|
|
267
|
+
`input--${size}`,
|
|
268
|
+
error && "input--error",
|
|
269
|
+
disabled && "input--disabled",
|
|
270
|
+
icon && "input--has-icon-left",
|
|
271
|
+
iconRight && "input--has-icon-right"
|
|
272
|
+
].filter(Boolean).join(" ");
|
|
273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: containerClasses, children: [
|
|
274
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { htmlFor: inputId, className: "input__label", children: label }),
|
|
275
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "input__wrapper", children: [
|
|
276
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "input__icon input__icon--left", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { name: icon, size: 16 }) }),
|
|
277
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
278
|
+
"input",
|
|
279
|
+
{
|
|
280
|
+
ref,
|
|
281
|
+
type,
|
|
282
|
+
id: inputId,
|
|
283
|
+
className: inputClasses,
|
|
284
|
+
disabled,
|
|
285
|
+
...props
|
|
286
|
+
}
|
|
287
|
+
),
|
|
288
|
+
iconRight && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
289
|
+
"button",
|
|
290
|
+
{
|
|
291
|
+
type: "button",
|
|
292
|
+
className: "input__icon input__icon--right",
|
|
293
|
+
onClick: onRightIconClick,
|
|
294
|
+
tabIndex: -1,
|
|
295
|
+
"aria-label": "Icon action",
|
|
296
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { name: iconRight, size: 16 })
|
|
297
|
+
}
|
|
298
|
+
)
|
|
299
|
+
] }),
|
|
300
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "input__message input__message--error", children: error }),
|
|
301
|
+
helperText && !error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "input__message", children: helperText })
|
|
302
|
+
] });
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
// src/components/popover/popover.tsx
|
|
307
|
+
var React4 = __toESM(require("react"));
|
|
308
|
+
var ReactDOM = __toESM(require("react-dom"));
|
|
309
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
310
|
+
var Popover = ({
|
|
311
|
+
trigger,
|
|
312
|
+
children,
|
|
313
|
+
isOpen,
|
|
314
|
+
onToggle,
|
|
315
|
+
placement = "bottom",
|
|
316
|
+
align = "start",
|
|
317
|
+
offset = 8,
|
|
318
|
+
flip = true,
|
|
319
|
+
closeOnEscape = true,
|
|
320
|
+
closeOnClickOutside = true
|
|
321
|
+
}) => {
|
|
322
|
+
const [internalOpen, setInternalOpen] = React4.useState(false);
|
|
323
|
+
const triggerRef = React4.useRef(null);
|
|
324
|
+
const popoverRef = React4.useRef(null);
|
|
325
|
+
const [popoverStyle, setPopoverStyle] = React4.useState({});
|
|
326
|
+
const [resolvedPlacement, setResolvedPlacement] = React4.useState(placement);
|
|
327
|
+
const isControlled = isOpen !== void 0;
|
|
328
|
+
const open = isControlled ? isOpen : internalOpen;
|
|
329
|
+
const toggle = React4.useCallback(() => {
|
|
330
|
+
if (isControlled) {
|
|
331
|
+
onToggle?.();
|
|
332
|
+
} else {
|
|
333
|
+
setInternalOpen((prev) => !prev);
|
|
334
|
+
}
|
|
335
|
+
}, [isControlled, onToggle]);
|
|
336
|
+
React4.useEffect(() => {
|
|
337
|
+
const handleClickOutside = (event) => {
|
|
338
|
+
if (closeOnClickOutside && triggerRef.current && !triggerRef.current.contains(event.target) && popoverRef.current && !popoverRef.current.contains(event.target)) {
|
|
339
|
+
toggle();
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
if (open) {
|
|
343
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
344
|
+
}
|
|
345
|
+
return () => {
|
|
346
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
347
|
+
};
|
|
348
|
+
}, [open, toggle, closeOnClickOutside]);
|
|
349
|
+
React4.useEffect(() => {
|
|
350
|
+
const handleEscapeKey = (event) => {
|
|
351
|
+
if (closeOnEscape && event.key === "Escape" && open) {
|
|
352
|
+
toggle();
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
if (open) {
|
|
356
|
+
document.addEventListener("keydown", handleEscapeKey);
|
|
357
|
+
}
|
|
358
|
+
return () => {
|
|
359
|
+
document.removeEventListener("keydown", handleEscapeKey);
|
|
360
|
+
};
|
|
361
|
+
}, [open, toggle, closeOnEscape]);
|
|
362
|
+
React4.useEffect(() => {
|
|
363
|
+
if (!open || !triggerRef.current || !popoverRef.current) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const updatePosition = () => {
|
|
367
|
+
if (!triggerRef.current || !popoverRef.current) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
371
|
+
const popoverRect = popoverRef.current.getBoundingClientRect();
|
|
372
|
+
const viewportWidth = window.innerWidth;
|
|
373
|
+
const viewportHeight = window.innerHeight;
|
|
374
|
+
const spaceTop = triggerRect.top;
|
|
375
|
+
const spaceBottom = viewportHeight - triggerRect.bottom;
|
|
376
|
+
const spaceLeft = triggerRect.left;
|
|
377
|
+
const spaceRight = viewportWidth - triggerRect.right;
|
|
378
|
+
let finalPlacement = placement;
|
|
379
|
+
if (flip) {
|
|
380
|
+
if (placement === "right" && spaceRight < popoverRect.width + offset) {
|
|
381
|
+
finalPlacement = spaceLeft >= popoverRect.width + offset ? "left" : "bottom";
|
|
382
|
+
} else if (placement === "left" && spaceLeft < popoverRect.width + offset) {
|
|
383
|
+
finalPlacement = spaceRight >= popoverRect.width + offset ? "right" : "bottom";
|
|
384
|
+
} else if (placement === "bottom" && spaceBottom < popoverRect.height + offset) {
|
|
385
|
+
finalPlacement = spaceTop >= popoverRect.height + offset ? "top" : "bottom";
|
|
386
|
+
} else if (placement === "top" && spaceTop < popoverRect.height + offset) {
|
|
387
|
+
finalPlacement = spaceBottom >= popoverRect.height + offset ? "bottom" : "top";
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
setResolvedPlacement(finalPlacement);
|
|
391
|
+
const newStyle = {
|
|
392
|
+
position: "fixed",
|
|
393
|
+
zIndex: "var(--z-popover)",
|
|
394
|
+
opacity: 1,
|
|
395
|
+
visibility: "visible",
|
|
396
|
+
pointerEvents: "auto"
|
|
397
|
+
};
|
|
398
|
+
const getAlignmentOffset = () => {
|
|
399
|
+
let alignmentOffset = 0;
|
|
400
|
+
if (finalPlacement === "left" || finalPlacement === "right") {
|
|
401
|
+
switch (align) {
|
|
402
|
+
case "center":
|
|
403
|
+
alignmentOffset = (triggerRect.height - popoverRect.height) / 2;
|
|
404
|
+
break;
|
|
405
|
+
case "end":
|
|
406
|
+
alignmentOffset = triggerRect.height - popoverRect.height;
|
|
407
|
+
break;
|
|
408
|
+
case "start":
|
|
409
|
+
default:
|
|
410
|
+
alignmentOffset = 0;
|
|
411
|
+
}
|
|
412
|
+
} else {
|
|
413
|
+
switch (align) {
|
|
414
|
+
case "center":
|
|
415
|
+
alignmentOffset = (triggerRect.width - popoverRect.width) / 2;
|
|
416
|
+
break;
|
|
417
|
+
case "end":
|
|
418
|
+
alignmentOffset = triggerRect.width - popoverRect.width;
|
|
419
|
+
break;
|
|
420
|
+
case "start":
|
|
421
|
+
default:
|
|
422
|
+
alignmentOffset = 0;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return alignmentOffset;
|
|
426
|
+
};
|
|
427
|
+
switch (finalPlacement) {
|
|
428
|
+
case "right":
|
|
429
|
+
newStyle.top = triggerRect.top + getAlignmentOffset();
|
|
430
|
+
newStyle.left = triggerRect.right + offset;
|
|
431
|
+
break;
|
|
432
|
+
case "left":
|
|
433
|
+
newStyle.top = triggerRect.top + getAlignmentOffset();
|
|
434
|
+
newStyle.left = triggerRect.left - popoverRect.width - offset;
|
|
435
|
+
break;
|
|
436
|
+
case "top":
|
|
437
|
+
newStyle.top = triggerRect.top - popoverRect.height - offset;
|
|
438
|
+
newStyle.left = triggerRect.left + getAlignmentOffset();
|
|
439
|
+
break;
|
|
440
|
+
case "bottom":
|
|
441
|
+
default:
|
|
442
|
+
newStyle.top = triggerRect.bottom + offset;
|
|
443
|
+
newStyle.left = triggerRect.left + getAlignmentOffset();
|
|
444
|
+
}
|
|
445
|
+
if (typeof newStyle.left === "number") {
|
|
446
|
+
if (newStyle.left + popoverRect.width > viewportWidth - offset) {
|
|
447
|
+
newStyle.left = viewportWidth - popoverRect.width - offset;
|
|
448
|
+
}
|
|
449
|
+
if (newStyle.left < offset) {
|
|
450
|
+
newStyle.left = offset;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
if (typeof newStyle.top === "number") {
|
|
454
|
+
if (newStyle.top + popoverRect.height > viewportHeight - offset) {
|
|
455
|
+
newStyle.top = viewportHeight - popoverRect.height - offset;
|
|
456
|
+
}
|
|
457
|
+
if (newStyle.top < offset) {
|
|
458
|
+
newStyle.top = offset;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
setPopoverStyle(newStyle);
|
|
462
|
+
};
|
|
463
|
+
requestAnimationFrame(updatePosition);
|
|
464
|
+
window.addEventListener("resize", updatePosition);
|
|
465
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
466
|
+
return () => {
|
|
467
|
+
window.removeEventListener("resize", updatePosition);
|
|
468
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
469
|
+
};
|
|
470
|
+
}, [open, placement, align, offset, flip]);
|
|
471
|
+
const handleTriggerClick = React4.useCallback(() => {
|
|
472
|
+
toggle();
|
|
473
|
+
}, [toggle]);
|
|
474
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
475
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
476
|
+
"div",
|
|
477
|
+
{
|
|
478
|
+
ref: triggerRef,
|
|
479
|
+
onClick: handleTriggerClick,
|
|
480
|
+
style: { display: "inline-block", position: "relative" },
|
|
481
|
+
children: React4.isValidElement(trigger) ? React4.cloneElement(trigger, {
|
|
482
|
+
onClick: (e) => {
|
|
483
|
+
e.stopPropagation();
|
|
484
|
+
handleTriggerClick();
|
|
485
|
+
trigger.props?.onClick?.(e);
|
|
486
|
+
}
|
|
487
|
+
}) : trigger
|
|
488
|
+
}
|
|
489
|
+
),
|
|
490
|
+
open && ReactDOM.createPortal(
|
|
491
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
492
|
+
"div",
|
|
493
|
+
{
|
|
494
|
+
ref: popoverRef,
|
|
495
|
+
className: `popover popover--${resolvedPlacement}`,
|
|
496
|
+
style: {
|
|
497
|
+
...popoverStyle,
|
|
498
|
+
// Start with opacity 0 and visibility hidden to prevent initial flash
|
|
499
|
+
opacity: popoverStyle.top !== void 0 ? 1 : 0,
|
|
500
|
+
visibility: popoverStyle.top !== void 0 ? "visible" : "hidden"
|
|
501
|
+
},
|
|
502
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "popover__content", children })
|
|
503
|
+
}
|
|
504
|
+
),
|
|
505
|
+
document.body
|
|
506
|
+
)
|
|
507
|
+
] });
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// src/components/input/DatePicker.tsx
|
|
511
|
+
var React5 = __toESM(require("react"));
|
|
512
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
513
|
+
var MONTHS = [
|
|
514
|
+
"January",
|
|
515
|
+
"February",
|
|
516
|
+
"March",
|
|
517
|
+
"April",
|
|
518
|
+
"May",
|
|
519
|
+
"June",
|
|
520
|
+
"July",
|
|
521
|
+
"August",
|
|
522
|
+
"September",
|
|
523
|
+
"October",
|
|
524
|
+
"November",
|
|
525
|
+
"December"
|
|
526
|
+
];
|
|
527
|
+
var DAYS_OF_WEEK = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
528
|
+
var DatePicker = ({ value, onChange, disabled }) => {
|
|
529
|
+
const parseDate = (dateStr) => {
|
|
530
|
+
if (!dateStr) {
|
|
531
|
+
const today = /* @__PURE__ */ new Date();
|
|
532
|
+
return { year: today.getFullYear(), month: today.getMonth(), day: today.getDate() };
|
|
533
|
+
}
|
|
534
|
+
const [year, month, day] = dateStr.split("-").map(Number);
|
|
535
|
+
return { year, month: month - 1, day };
|
|
536
|
+
};
|
|
537
|
+
const { year: initialYear, month: initialMonth, day: selectedDay } = parseDate(value);
|
|
538
|
+
const [currentYear, setCurrentYear] = React5.useState(initialYear);
|
|
539
|
+
const [currentMonth, setCurrentMonth] = React5.useState(initialMonth);
|
|
540
|
+
const getDaysInMonth = (year, month) => {
|
|
541
|
+
return new Date(year, month + 1, 0).getDate();
|
|
542
|
+
};
|
|
543
|
+
const getFirstDayOfMonth = (year, month) => {
|
|
544
|
+
return new Date(year, month, 1).getDay();
|
|
545
|
+
};
|
|
546
|
+
const handleDateSelect = (day) => {
|
|
547
|
+
if (disabled) return;
|
|
548
|
+
const formattedDate = `${currentYear}-${String(currentMonth + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
|
|
549
|
+
onChange(formattedDate);
|
|
550
|
+
};
|
|
551
|
+
const handlePrevMonth = () => {
|
|
552
|
+
if (currentMonth === 0) {
|
|
553
|
+
setCurrentMonth(11);
|
|
554
|
+
setCurrentYear(currentYear - 1);
|
|
555
|
+
} else {
|
|
556
|
+
setCurrentMonth(currentMonth - 1);
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
const handleNextMonth = () => {
|
|
560
|
+
if (currentMonth === 11) {
|
|
561
|
+
setCurrentMonth(0);
|
|
562
|
+
setCurrentYear(currentYear + 1);
|
|
563
|
+
} else {
|
|
564
|
+
setCurrentMonth(currentMonth + 1);
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
const daysInMonth = getDaysInMonth(currentYear, currentMonth);
|
|
568
|
+
const firstDay = getFirstDayOfMonth(currentYear, currentMonth);
|
|
569
|
+
const days = [
|
|
570
|
+
...Array(firstDay).fill(null),
|
|
571
|
+
...Array.from({ length: daysInMonth }, (_, i) => i + 1)
|
|
572
|
+
];
|
|
573
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "date-picker", children: [
|
|
574
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "date-picker__header", children: [
|
|
575
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
576
|
+
"button",
|
|
577
|
+
{
|
|
578
|
+
type: "button",
|
|
579
|
+
className: "date-picker__nav",
|
|
580
|
+
onClick: handlePrevMonth,
|
|
581
|
+
disabled,
|
|
582
|
+
"aria-label": "Previous month",
|
|
583
|
+
children: "\u2039"
|
|
584
|
+
}
|
|
585
|
+
),
|
|
586
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "date-picker__title", children: [
|
|
587
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
588
|
+
"select",
|
|
589
|
+
{
|
|
590
|
+
className: "date-picker__select",
|
|
591
|
+
value: currentMonth,
|
|
592
|
+
onChange: (e) => setCurrentMonth(Number(e.target.value)),
|
|
593
|
+
disabled,
|
|
594
|
+
children: MONTHS.map((month, idx) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: idx, children: month }, month))
|
|
595
|
+
}
|
|
596
|
+
),
|
|
597
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
598
|
+
"select",
|
|
599
|
+
{
|
|
600
|
+
className: "date-picker__select",
|
|
601
|
+
value: currentYear,
|
|
602
|
+
onChange: (e) => setCurrentYear(Number(e.target.value)),
|
|
603
|
+
disabled,
|
|
604
|
+
children: Array.from({ length: 100 }, (_, i) => currentYear - 50 + i).map((year) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: year, children: year }, year))
|
|
605
|
+
}
|
|
606
|
+
)
|
|
607
|
+
] }),
|
|
608
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
609
|
+
"button",
|
|
610
|
+
{
|
|
611
|
+
type: "button",
|
|
612
|
+
className: "date-picker__nav",
|
|
613
|
+
onClick: handleNextMonth,
|
|
614
|
+
disabled,
|
|
615
|
+
"aria-label": "Next month",
|
|
616
|
+
children: "\u203A"
|
|
617
|
+
}
|
|
618
|
+
)
|
|
619
|
+
] }),
|
|
620
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "date-picker__weekdays", children: DAYS_OF_WEEK.map((day) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "date-picker__weekday", children: day }, day)) }),
|
|
621
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "date-picker__days", children: days.map((day, idx) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
622
|
+
"button",
|
|
623
|
+
{
|
|
624
|
+
type: "button",
|
|
625
|
+
className: `date-picker__day ${day === selectedDay ? "date-picker__day--selected" : ""} ${!day ? "date-picker__day--empty" : ""}`,
|
|
626
|
+
onClick: () => day && handleDateSelect(day),
|
|
627
|
+
disabled: !day || disabled,
|
|
628
|
+
children: day || ""
|
|
629
|
+
},
|
|
630
|
+
idx
|
|
631
|
+
)) })
|
|
632
|
+
] });
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
// src/components/input/TimePicker.tsx
|
|
636
|
+
var React6 = __toESM(require("react"));
|
|
637
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
638
|
+
var parseTime = (timeStr) => {
|
|
639
|
+
if (!timeStr) return { hours: 0, minutes: 0, seconds: 0, milliseconds: 0 };
|
|
640
|
+
const parts = timeStr.split(":");
|
|
641
|
+
const hours = parseInt(parts[0] || "0", 10);
|
|
642
|
+
const minutes = parseInt(parts[1] || "0", 10);
|
|
643
|
+
const secondsParts = (parts[2] || "0").split(".");
|
|
644
|
+
const seconds = parseInt(secondsParts[0] || "0", 10);
|
|
645
|
+
const milliseconds = parseInt(secondsParts[1] || "0", 10);
|
|
646
|
+
return { hours, minutes, seconds, milliseconds };
|
|
647
|
+
};
|
|
648
|
+
var TimeColumn = ({
|
|
649
|
+
label,
|
|
650
|
+
value,
|
|
651
|
+
max,
|
|
652
|
+
field,
|
|
653
|
+
step,
|
|
654
|
+
disabled,
|
|
655
|
+
onChange
|
|
656
|
+
}) => {
|
|
657
|
+
const items = Array.from({ length: Math.floor(max / step) + 1 }, (_, i) => i * step);
|
|
658
|
+
const columnRef = React6.useRef(null);
|
|
659
|
+
React6.useEffect(() => {
|
|
660
|
+
if (columnRef.current) {
|
|
661
|
+
const selected = columnRef.current.querySelector(".time-picker__item--selected");
|
|
662
|
+
if (selected) {
|
|
663
|
+
selected.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}, [value]);
|
|
667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "time-picker__column", children: [
|
|
668
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "time-picker__label", children: label }),
|
|
669
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "time-picker__scroll scrollable", ref: columnRef, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
670
|
+
"button",
|
|
671
|
+
{
|
|
672
|
+
type: "button",
|
|
673
|
+
className: `time-picker__item ${item === value ? "time-picker__item--selected" : ""}`,
|
|
674
|
+
onClick: () => onChange(field, item),
|
|
675
|
+
disabled,
|
|
676
|
+
children: String(item).padStart(field === "milliseconds" ? 3 : 2, "0")
|
|
677
|
+
},
|
|
678
|
+
item
|
|
679
|
+
)) })
|
|
680
|
+
] });
|
|
681
|
+
};
|
|
682
|
+
var TimePicker = ({
|
|
683
|
+
value,
|
|
684
|
+
onChange,
|
|
685
|
+
disabled,
|
|
686
|
+
showMilliseconds = false,
|
|
687
|
+
minuteStep = 1
|
|
688
|
+
}) => {
|
|
689
|
+
const [internalTime, setInternalTime] = React6.useState(value);
|
|
690
|
+
React6.useEffect(() => {
|
|
691
|
+
setInternalTime(value);
|
|
692
|
+
}, [value]);
|
|
693
|
+
const { hours, minutes, seconds, milliseconds } = parseTime(internalTime);
|
|
694
|
+
const handleChange = (field, newValue) => {
|
|
695
|
+
if (disabled) return;
|
|
696
|
+
const currentParsed = parseTime(internalTime);
|
|
697
|
+
const updated = { ...currentParsed, [field]: newValue };
|
|
698
|
+
let formattedTime = `${String(updated.hours).padStart(2, "0")}:${String(updated.minutes).padStart(2, "0")}:${String(updated.seconds).padStart(2, "0")}`;
|
|
699
|
+
if (showMilliseconds && updated.milliseconds > 0) {
|
|
700
|
+
formattedTime += `.${String(updated.milliseconds).padStart(3, "0")}`;
|
|
701
|
+
}
|
|
702
|
+
setInternalTime(formattedTime);
|
|
703
|
+
onChange(formattedTime);
|
|
704
|
+
};
|
|
705
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "time-picker", children: [
|
|
706
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
707
|
+
TimeColumn,
|
|
708
|
+
{
|
|
709
|
+
label: "Hours",
|
|
710
|
+
value: hours,
|
|
711
|
+
max: 23,
|
|
712
|
+
field: "hours",
|
|
713
|
+
step: 1,
|
|
714
|
+
disabled,
|
|
715
|
+
onChange: handleChange
|
|
716
|
+
}
|
|
717
|
+
),
|
|
718
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
719
|
+
TimeColumn,
|
|
720
|
+
{
|
|
721
|
+
label: "Minutes",
|
|
722
|
+
value: minutes,
|
|
723
|
+
max: 59,
|
|
724
|
+
field: "minutes",
|
|
725
|
+
step: minuteStep,
|
|
726
|
+
disabled,
|
|
727
|
+
onChange: handleChange
|
|
728
|
+
}
|
|
729
|
+
),
|
|
730
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
731
|
+
TimeColumn,
|
|
732
|
+
{
|
|
733
|
+
label: "Seconds",
|
|
734
|
+
value: seconds,
|
|
735
|
+
max: 59,
|
|
736
|
+
field: "seconds",
|
|
737
|
+
step: 1,
|
|
738
|
+
disabled,
|
|
739
|
+
onChange: handleChange
|
|
740
|
+
}
|
|
741
|
+
),
|
|
742
|
+
showMilliseconds && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
743
|
+
TimeColumn,
|
|
744
|
+
{
|
|
745
|
+
label: "ms",
|
|
746
|
+
value: milliseconds,
|
|
747
|
+
max: 999,
|
|
748
|
+
field: "milliseconds",
|
|
749
|
+
step: 1,
|
|
750
|
+
disabled,
|
|
751
|
+
onChange: handleChange
|
|
752
|
+
}
|
|
753
|
+
)
|
|
754
|
+
] });
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
// src/components/input/Input.tsx
|
|
758
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
759
|
+
var TYPE_ICON_MAP = INPUT_TYPE_ICONS;
|
|
760
|
+
var formatDisplayValue = (val, inputType) => {
|
|
761
|
+
if (!val) return "";
|
|
762
|
+
if (inputType === "date") {
|
|
763
|
+
const [year, month, day] = val.split("-");
|
|
764
|
+
return `${day}/${month}/${year}`;
|
|
765
|
+
}
|
|
766
|
+
if (inputType === "time") {
|
|
767
|
+
return val;
|
|
768
|
+
}
|
|
769
|
+
if (inputType === "datetime-local") {
|
|
770
|
+
const [datePart, timePart] = val.split("T");
|
|
771
|
+
if (datePart && timePart) {
|
|
772
|
+
const [year, month, day] = datePart.split("-");
|
|
773
|
+
return `${day}/${month}/${year} ${timePart}`;
|
|
774
|
+
}
|
|
775
|
+
return val;
|
|
776
|
+
}
|
|
777
|
+
return val;
|
|
778
|
+
};
|
|
779
|
+
var Input = React7.forwardRef(
|
|
780
|
+
({
|
|
781
|
+
type = "text",
|
|
782
|
+
label,
|
|
783
|
+
helperText,
|
|
784
|
+
error,
|
|
785
|
+
icon,
|
|
786
|
+
fullWidth = false,
|
|
787
|
+
size = "md",
|
|
788
|
+
className = "",
|
|
789
|
+
disabled,
|
|
790
|
+
id,
|
|
791
|
+
showMilliseconds = false,
|
|
792
|
+
minuteStep = 1,
|
|
793
|
+
showClear = true,
|
|
794
|
+
...props
|
|
795
|
+
}, ref) => {
|
|
796
|
+
const [showPassword, setShowPassword] = React7.useState(false);
|
|
797
|
+
const [showDateTimePicker, setShowDateTimePicker] = React7.useState(false);
|
|
798
|
+
const inputRef = React7.useRef(null);
|
|
799
|
+
const leftIcon = icon || TYPE_ICON_MAP[type];
|
|
800
|
+
const isPasswordType = type === "password";
|
|
801
|
+
const actualType = isPasswordType && showPassword ? "text" : type !== "date" && type !== "time" && type !== "datetime-local" ? type : "text";
|
|
802
|
+
const isDateTimeType = type === "date" || type === "time" || type === "datetime-local";
|
|
803
|
+
const isSearchType = type === "search";
|
|
804
|
+
const hasValue = props.value && String(props.value).length > 0;
|
|
805
|
+
const rightIconName = isPasswordType ? showPassword ? "heroicons:eye-slash-solid" : "heroicons:eye-solid" : isDateTimeType ? "heroicons:chevron-down-solid" : isSearchType && hasValue && showClear ? ACTION_ICONS.clear : void 0;
|
|
806
|
+
const handleRightIconClick = () => {
|
|
807
|
+
if (isPasswordType) {
|
|
808
|
+
setShowPassword(!showPassword);
|
|
809
|
+
} else if (isDateTimeType) {
|
|
810
|
+
setShowDateTimePicker(!showDateTimePicker);
|
|
811
|
+
} else if (isSearchType && hasValue && showClear) {
|
|
812
|
+
if (props.onChange) {
|
|
813
|
+
props.onChange({ target: { value: "" } });
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
const handleDateTimeChange = (newValue) => {
|
|
818
|
+
if (props.onChange) {
|
|
819
|
+
props.onChange({ target: { value: newValue } });
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
if (!isDateTimeType) {
|
|
823
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
824
|
+
InputField,
|
|
825
|
+
{
|
|
826
|
+
ref: ref || inputRef,
|
|
827
|
+
type: actualType,
|
|
828
|
+
label,
|
|
829
|
+
helperText,
|
|
830
|
+
error,
|
|
831
|
+
icon: leftIcon,
|
|
832
|
+
iconRight: rightIconName,
|
|
833
|
+
onRightIconClick: handleRightIconClick,
|
|
834
|
+
fullWidth,
|
|
835
|
+
size,
|
|
836
|
+
className,
|
|
837
|
+
disabled,
|
|
838
|
+
id,
|
|
839
|
+
...props
|
|
840
|
+
}
|
|
841
|
+
);
|
|
842
|
+
}
|
|
843
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `input-container ${fullWidth ? "input-container--full-width" : ""} ${className}`.trim(), children: [
|
|
844
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: id, className: "input__label", children: label }),
|
|
845
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
846
|
+
Popover,
|
|
847
|
+
{
|
|
848
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
849
|
+
InputField,
|
|
850
|
+
{
|
|
851
|
+
ref: ref || inputRef,
|
|
852
|
+
type: "text",
|
|
853
|
+
icon: leftIcon,
|
|
854
|
+
iconRight: rightIconName,
|
|
855
|
+
onRightIconClick: () => setShowDateTimePicker(!showDateTimePicker),
|
|
856
|
+
fullWidth,
|
|
857
|
+
size,
|
|
858
|
+
disabled,
|
|
859
|
+
id,
|
|
860
|
+
value: formatDisplayValue(String(props.value || ""), type),
|
|
861
|
+
placeholder: props.placeholder,
|
|
862
|
+
readOnly: true
|
|
863
|
+
}
|
|
864
|
+
),
|
|
865
|
+
isOpen: showDateTimePicker,
|
|
866
|
+
onToggle: () => setShowDateTimePicker(!showDateTimePicker),
|
|
867
|
+
placement: "bottom",
|
|
868
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { padding: "1rem" }, children: [
|
|
869
|
+
(type === "date" || type === "datetime-local") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
870
|
+
DatePicker,
|
|
871
|
+
{
|
|
872
|
+
value: String(props.value || "").split("T")[0],
|
|
873
|
+
onChange: (newDate) => {
|
|
874
|
+
if (type === "datetime-local") {
|
|
875
|
+
const time = String(props.value || "").split("T")[1] || "00:00:00";
|
|
876
|
+
handleDateTimeChange(`${newDate}T${time}`);
|
|
877
|
+
} else {
|
|
878
|
+
handleDateTimeChange(newDate);
|
|
879
|
+
setShowDateTimePicker(false);
|
|
880
|
+
}
|
|
881
|
+
},
|
|
882
|
+
disabled
|
|
883
|
+
}
|
|
884
|
+
),
|
|
885
|
+
(type === "time" || type === "datetime-local") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
886
|
+
TimePicker,
|
|
887
|
+
{
|
|
888
|
+
value: String(props.value || "").split("T")[1] || "00:00:00",
|
|
889
|
+
onChange: (newTime) => {
|
|
890
|
+
if (type === "datetime-local") {
|
|
891
|
+
const date = String(props.value || "").split("T")[0] || (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
892
|
+
handleDateTimeChange(`${date}T${newTime}`);
|
|
893
|
+
} else {
|
|
894
|
+
handleDateTimeChange(newTime);
|
|
895
|
+
}
|
|
896
|
+
},
|
|
897
|
+
disabled,
|
|
898
|
+
showMilliseconds,
|
|
899
|
+
minuteStep
|
|
900
|
+
}
|
|
901
|
+
)
|
|
902
|
+
] })
|
|
903
|
+
}
|
|
904
|
+
),
|
|
905
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "input__message input__message--error", children: error }),
|
|
906
|
+
helperText && !error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "input__message", children: helperText })
|
|
907
|
+
] });
|
|
908
|
+
}
|
|
909
|
+
);
|
|
910
|
+
Input.displayName = "Input";
|
|
911
|
+
|
|
912
|
+
// src/components/input/InputText.tsx
|
|
913
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
914
|
+
var InputText = import_react4.default.forwardRef((props, ref) => {
|
|
915
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Input, { ref, ...props, type: "text" });
|
|
916
|
+
});
|
|
917
|
+
InputText.displayName = "InputText";
|
|
918
|
+
|
|
919
|
+
// src/components/input/InputEmail.tsx
|
|
920
|
+
var import_react5 = __toESM(require("react"));
|
|
921
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
922
|
+
var InputEmail = import_react5.default.forwardRef((props, ref) => {
|
|
923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Input, { ref, ...props, type: "email" });
|
|
924
|
+
});
|
|
925
|
+
InputEmail.displayName = "InputEmail";
|
|
926
|
+
|
|
927
|
+
// src/components/input/InputPassword.tsx
|
|
928
|
+
var import_react6 = __toESM(require("react"));
|
|
929
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
930
|
+
var InputPassword = import_react6.default.forwardRef((props, ref) => {
|
|
931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input, { ref, ...props, type: "password" });
|
|
932
|
+
});
|
|
933
|
+
InputPassword.displayName = "InputPassword";
|
|
934
|
+
|
|
935
|
+
// src/components/input/InputSearch.tsx
|
|
936
|
+
var import_react7 = __toESM(require("react"));
|
|
937
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
938
|
+
var InputSearch = import_react7.default.forwardRef((props, ref) => {
|
|
939
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Input, { ref, ...props, type: "search" });
|
|
940
|
+
});
|
|
941
|
+
InputSearch.displayName = "InputSearch";
|
|
942
|
+
|
|
943
|
+
// src/components/input/InputTel.tsx
|
|
944
|
+
var import_react8 = __toESM(require("react"));
|
|
945
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
946
|
+
var InputTel = import_react8.default.forwardRef((props, ref) => {
|
|
947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Input, { ref, ...props, type: "tel" });
|
|
948
|
+
});
|
|
949
|
+
InputTel.displayName = "InputTel";
|
|
950
|
+
|
|
951
|
+
// src/components/input/InputUrl.tsx
|
|
952
|
+
var import_react9 = __toESM(require("react"));
|
|
953
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
954
|
+
var InputUrl = import_react9.default.forwardRef((props, ref) => {
|
|
955
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Input, { ref, ...props, type: "url" });
|
|
956
|
+
});
|
|
957
|
+
InputUrl.displayName = "InputUrl";
|
|
958
|
+
|
|
959
|
+
// src/components/input/InputNumber.tsx
|
|
960
|
+
var import_react10 = __toESM(require("react"));
|
|
961
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
962
|
+
var InputNumber = import_react10.default.forwardRef((props, ref) => {
|
|
963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Input, { ref, ...props, type: "number" });
|
|
964
|
+
});
|
|
965
|
+
InputNumber.displayName = "InputNumber";
|
|
966
|
+
|
|
967
|
+
// src/components/input/InputDate.tsx
|
|
968
|
+
var import_react11 = __toESM(require("react"));
|
|
969
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
970
|
+
var InputDate = import_react11.default.forwardRef((props, ref) => {
|
|
971
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Input, { ref, ...props, type: "date" });
|
|
972
|
+
});
|
|
973
|
+
InputDate.displayName = "InputDate";
|
|
974
|
+
|
|
975
|
+
// src/components/input/InputTime.tsx
|
|
976
|
+
var import_react12 = __toESM(require("react"));
|
|
977
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
978
|
+
var InputTime = import_react12.default.forwardRef((props, ref) => {
|
|
979
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Input, { ref, ...props, type: "time" });
|
|
980
|
+
});
|
|
981
|
+
InputTime.displayName = "InputTime";
|
|
982
|
+
|
|
983
|
+
// src/components/input/InputDateTime.tsx
|
|
984
|
+
var import_react13 = __toESM(require("react"));
|
|
985
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
986
|
+
var InputDateTime = import_react13.default.forwardRef((props, ref) => {
|
|
987
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Input, { ref, ...props, type: "datetime-local" });
|
|
988
|
+
});
|
|
989
|
+
InputDateTime.displayName = "InputDateTime";
|
|
990
|
+
|
|
991
|
+
// src/components/tooltip/tooltip.tsx
|
|
992
|
+
var React18 = __toESM(require("react"));
|
|
993
|
+
var ReactDOM2 = __toESM(require("react-dom"));
|
|
994
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
995
|
+
|
|
996
|
+
// src/components/_shared/HeadingAnchor.tsx
|
|
997
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
998
|
+
|
|
999
|
+
// src/components/dialog/Dialog.tsx
|
|
1000
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1001
|
+
var Dialog = ({
|
|
1002
|
+
open,
|
|
1003
|
+
onClose,
|
|
1004
|
+
title,
|
|
1005
|
+
children,
|
|
1006
|
+
size = "md",
|
|
1007
|
+
footer,
|
|
1008
|
+
showCloseButton = true,
|
|
1009
|
+
closeOnBackdropClick = true,
|
|
1010
|
+
closeOnEscape = true,
|
|
1011
|
+
className = "",
|
|
1012
|
+
ariaLabel,
|
|
1013
|
+
ariaDescribedBy
|
|
1014
|
+
}) => {
|
|
1015
|
+
const dialogRef = React20.useRef(null);
|
|
1016
|
+
React20.useEffect(() => {
|
|
1017
|
+
if (!open || !closeOnEscape) return;
|
|
1018
|
+
const handleEscape = (e) => {
|
|
1019
|
+
if (e.key === "Escape") {
|
|
1020
|
+
onClose();
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
document.addEventListener("keydown", handleEscape);
|
|
1024
|
+
return () => document.removeEventListener("keydown", handleEscape);
|
|
1025
|
+
}, [open, closeOnEscape, onClose]);
|
|
1026
|
+
React20.useEffect(() => {
|
|
1027
|
+
if (open) {
|
|
1028
|
+
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
1029
|
+
document.body.style.overflow = "hidden";
|
|
1030
|
+
document.body.style.paddingRight = `${scrollbarWidth}px`;
|
|
1031
|
+
} else {
|
|
1032
|
+
document.body.style.overflow = "";
|
|
1033
|
+
document.body.style.paddingRight = "";
|
|
1034
|
+
}
|
|
1035
|
+
return () => {
|
|
1036
|
+
document.body.style.overflow = "";
|
|
1037
|
+
document.body.style.paddingRight = "";
|
|
1038
|
+
};
|
|
1039
|
+
}, [open]);
|
|
1040
|
+
React20.useEffect(() => {
|
|
1041
|
+
if (!open || !dialogRef.current) return;
|
|
1042
|
+
const dialog = dialogRef.current;
|
|
1043
|
+
const focusableElements = dialog.querySelectorAll(
|
|
1044
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
1045
|
+
);
|
|
1046
|
+
const firstElement = focusableElements[0];
|
|
1047
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
1048
|
+
const handleTab = (e) => {
|
|
1049
|
+
if (e.key !== "Tab") return;
|
|
1050
|
+
if (e.shiftKey) {
|
|
1051
|
+
if (document.activeElement === firstElement) {
|
|
1052
|
+
e.preventDefault();
|
|
1053
|
+
lastElement?.focus();
|
|
1054
|
+
}
|
|
1055
|
+
} else {
|
|
1056
|
+
if (document.activeElement === lastElement) {
|
|
1057
|
+
e.preventDefault();
|
|
1058
|
+
firstElement?.focus();
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
dialog.addEventListener("keydown", handleTab);
|
|
1063
|
+
firstElement?.focus();
|
|
1064
|
+
return () => {
|
|
1065
|
+
dialog.removeEventListener("keydown", handleTab);
|
|
1066
|
+
};
|
|
1067
|
+
}, [open]);
|
|
1068
|
+
const handleBackdropClick = (e) => {
|
|
1069
|
+
if (closeOnBackdropClick && e.target === e.currentTarget) {
|
|
1070
|
+
onClose();
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
if (!open) return null;
|
|
1074
|
+
const dialogContent = /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "dialog__portal", children: [
|
|
1075
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Backdrop, { onClick: handleBackdropClick, "data-enter": "" }),
|
|
1076
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
1077
|
+
"div",
|
|
1078
|
+
{
|
|
1079
|
+
ref: dialogRef,
|
|
1080
|
+
className: `dialog dialog--${size} ${className}`,
|
|
1081
|
+
role: "dialog",
|
|
1082
|
+
"aria-modal": "true",
|
|
1083
|
+
"aria-label": ariaLabel || title,
|
|
1084
|
+
"aria-describedby": ariaDescribedBy,
|
|
1085
|
+
children: [
|
|
1086
|
+
(title || showCloseButton) && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "dialog__header", children: [
|
|
1087
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h2", { className: "dialog__title", children: title }),
|
|
1088
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1089
|
+
Button,
|
|
1090
|
+
{
|
|
1091
|
+
variant: "ghost",
|
|
1092
|
+
className: "dialog__close",
|
|
1093
|
+
startIcon: ACTION_ICONS.close,
|
|
1094
|
+
iconOnly: true,
|
|
1095
|
+
onClick: onClose,
|
|
1096
|
+
"aria-label": "Close dialog"
|
|
1097
|
+
}
|
|
1098
|
+
)
|
|
1099
|
+
] }),
|
|
1100
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "dialog__content scrollable", children }),
|
|
1101
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "dialog__footer", children: footer })
|
|
1102
|
+
]
|
|
1103
|
+
}
|
|
1104
|
+
)
|
|
1105
|
+
] });
|
|
1106
|
+
return (0, import_react_dom.createPortal)(dialogContent, document.body);
|
|
1107
|
+
};
|
|
1108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1109
|
+
0 && (module.exports = {
|
|
1110
|
+
Dialog
|
|
1111
|
+
});
|