@krpkg/ui 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -653,57 +653,27 @@ var TerminalWindow = forwardRef12(
653
653
  TerminalWindow.displayName = "TerminalWindow";
654
654
 
655
655
  // src/components/Tooltip.tsx
656
- import { useState as useState3, useRef } from "react";
657
656
  import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
658
657
  var Tooltip = ({
659
658
  content,
660
659
  children,
661
660
  position = "top",
662
661
  coord,
662
+ shortcut,
663
663
  className = ""
664
664
  }) => {
665
- const [isVisible, setIsVisible] = useState3(false);
666
- const timeoutRef = useRef(null);
667
- const show = () => {
668
- if (timeoutRef.current) clearTimeout(timeoutRef.current);
669
- setIsVisible(true);
670
- };
671
- const hide = () => {
672
- timeoutRef.current = setTimeout(() => {
673
- setIsVisible(false);
674
- }, 100);
675
- };
676
- return /* @__PURE__ */ jsxs11(
677
- "div",
678
- {
679
- className: "kz-tooltip-wrapper",
680
- onMouseEnter: show,
681
- onMouseLeave: hide,
682
- onFocus: show,
683
- onBlur: hide,
684
- children: [
685
- children,
686
- isVisible && /* @__PURE__ */ jsxs11(
687
- "div",
688
- {
689
- role: "tooltip",
690
- className: `kz-tooltip-box kz-tooltip-${position} ${className}`,
691
- children: [
692
- coord && /* @__PURE__ */ jsxs11("span", { className: "kz-tooltip-coord", children: [
693
- "[",
694
- coord,
695
- "]"
696
- ] }),
697
- /* @__PURE__ */ jsx15("div", { className: "kz-tooltip-content", children: content }),
698
- /* @__PURE__ */ jsx15("div", { className: "kz-tooltip-arrow" })
699
- ]
700
- }
701
- )
702
- ]
703
- }
704
- );
665
+ return /* @__PURE__ */ jsxs11("div", { className: `kz-tooltip-wrapper ${className}`, children: [
666
+ children,
667
+ /* @__PURE__ */ jsxs11("div", { className: `kz-tooltip-bubble kz-tooltip-${position}`, children: [
668
+ /* @__PURE__ */ jsxs11("div", { className: "kz-tooltip-content", children: [
669
+ coord && /* @__PURE__ */ jsx15("span", { className: "kz-tooltip-coord", children: coord }),
670
+ /* @__PURE__ */ jsx15("span", { className: "kz-tooltip-text", children: content }),
671
+ shortcut && /* @__PURE__ */ jsx15("kbd", { className: "kz-tooltip-shortcut", children: shortcut })
672
+ ] }),
673
+ /* @__PURE__ */ jsx15("div", { className: "kz-tooltip-arrow" })
674
+ ] })
675
+ ] });
705
676
  };
706
- Tooltip.displayName = "Tooltip";
707
677
 
708
678
  // src/components/SegmentedControl.tsx
709
679
  import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
@@ -957,7 +927,7 @@ function TacticalDrawer({
957
927
  }
958
928
 
959
929
  // src/components/HudToast.tsx
960
- import { useEffect as useEffect3, useState as useState4 } from "react";
930
+ import { useEffect as useEffect3, useState as useState3 } from "react";
961
931
  import { jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
962
932
  function HudToast({
963
933
  isOpen,
@@ -969,7 +939,7 @@ function HudToast({
969
939
  coord = "HUD // NOTIFY",
970
940
  className = ""
971
941
  }) {
972
- const [progress, setProgress] = useState4(100);
942
+ const [progress, setProgress] = useState3(100);
973
943
  useEffect3(() => {
974
944
  if (!isOpen || duration <= 0) return;
975
945
  setProgress(100);
@@ -1074,21 +1044,399 @@ function BottomBar({
1074
1044
  }
1075
1045
  );
1076
1046
  }
1047
+
1048
+ // src/components/Slider.tsx
1049
+ import { forwardRef as forwardRef13 } from "react";
1050
+ import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
1051
+ var Slider = forwardRef13(
1052
+ ({
1053
+ className = "",
1054
+ label,
1055
+ sublabel,
1056
+ coord,
1057
+ showValue = true,
1058
+ valueFormatter,
1059
+ sliderSize = "md",
1060
+ variant = "accent",
1061
+ fullWidth = true,
1062
+ min = 0,
1063
+ max = 100,
1064
+ value,
1065
+ defaultValue,
1066
+ disabled,
1067
+ ...props
1068
+ }, ref) => {
1069
+ const currentVal = Number(value !== void 0 ? value : defaultValue !== void 0 ? defaultValue : min);
1070
+ const minVal = Number(min);
1071
+ const maxVal = Number(max);
1072
+ const pct = Math.max(0, Math.min(100, (currentVal - minVal) / (maxVal - minVal || 1) * 100));
1073
+ return /* @__PURE__ */ jsxs19(
1074
+ "div",
1075
+ {
1076
+ className: [
1077
+ "kz-slider-wrapper",
1078
+ `kz-slider-${sliderSize}`,
1079
+ `kz-slider-${variant}`,
1080
+ fullWidth ? "kz-slider-full" : "",
1081
+ disabled ? "kz-slider-disabled" : "",
1082
+ className
1083
+ ].filter(Boolean).join(" "),
1084
+ children: [
1085
+ (label || sublabel || showValue || coord) && /* @__PURE__ */ jsxs19("div", { className: "kz-slider-header", children: [
1086
+ /* @__PURE__ */ jsxs19("div", { className: "kz-slider-label-group", children: [
1087
+ label && /* @__PURE__ */ jsx23("label", { className: "kz-slider-label", children: label }),
1088
+ sublabel && /* @__PURE__ */ jsx23("span", { className: "kz-slider-sublabel", children: sublabel }),
1089
+ coord && /* @__PURE__ */ jsx23("span", { className: "kz-slider-coord", children: coord })
1090
+ ] }),
1091
+ showValue && /* @__PURE__ */ jsx23("span", { className: "kz-slider-value", children: valueFormatter ? valueFormatter(currentVal) : currentVal })
1092
+ ] }),
1093
+ /* @__PURE__ */ jsx23("div", { className: "kz-slider-track-container", children: /* @__PURE__ */ jsx23(
1094
+ "input",
1095
+ {
1096
+ ref,
1097
+ type: "range",
1098
+ min,
1099
+ max,
1100
+ value,
1101
+ defaultValue,
1102
+ disabled,
1103
+ className: "kz-slider-input",
1104
+ style: { "--kz-slider-pct": `${pct}%` },
1105
+ ...props
1106
+ }
1107
+ ) })
1108
+ ]
1109
+ }
1110
+ );
1111
+ }
1112
+ );
1113
+ Slider.displayName = "Slider";
1114
+
1115
+ // src/components/ColorPicker.tsx
1116
+ import { forwardRef as forwardRef14, useState as useState4, useRef, useEffect as useEffect4 } from "react";
1117
+ import { jsx as jsx24, jsxs as jsxs20 } from "react/jsx-runtime";
1118
+ var ColorPicker = forwardRef14(
1119
+ ({
1120
+ value,
1121
+ onChange,
1122
+ presets = [
1123
+ "#000000",
1124
+ "#ffffff",
1125
+ "#c49368",
1126
+ "#6a9e9e",
1127
+ "#a855f7",
1128
+ "#3b82f6",
1129
+ "#22c55e",
1130
+ "#ef4444",
1131
+ "#eab308",
1132
+ "#ec4899",
1133
+ "#64748b",
1134
+ "#1e293b"
1135
+ ],
1136
+ label,
1137
+ sublabel,
1138
+ coord,
1139
+ showHexInput = true,
1140
+ disabled = false,
1141
+ size = "md",
1142
+ className = ""
1143
+ }, ref) => {
1144
+ const [isOpen, setIsOpen] = useState4(false);
1145
+ const containerRef = useRef(null);
1146
+ useEffect4(() => {
1147
+ const handleOutsideClick = (e) => {
1148
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
1149
+ setIsOpen(false);
1150
+ }
1151
+ };
1152
+ if (isOpen) {
1153
+ document.addEventListener("mousedown", handleOutsideClick);
1154
+ }
1155
+ return () => {
1156
+ document.removeEventListener("mousedown", handleOutsideClick);
1157
+ };
1158
+ }, [isOpen]);
1159
+ return /* @__PURE__ */ jsxs20(
1160
+ "div",
1161
+ {
1162
+ ref: containerRef,
1163
+ className: [
1164
+ "kz-color-picker",
1165
+ `kz-color-picker-${size}`,
1166
+ disabled ? "kz-color-picker-disabled" : "",
1167
+ className
1168
+ ].filter(Boolean).join(" "),
1169
+ children: [
1170
+ (label || sublabel || coord) && /* @__PURE__ */ jsxs20("div", { className: "kz-color-picker-header", children: [
1171
+ /* @__PURE__ */ jsxs20("div", { className: "kz-color-picker-label-group", children: [
1172
+ label && /* @__PURE__ */ jsx24("label", { className: "kz-color-picker-label", children: label }),
1173
+ sublabel && /* @__PURE__ */ jsx24("span", { className: "kz-color-picker-sublabel", children: sublabel }),
1174
+ coord && /* @__PURE__ */ jsx24("span", { className: "kz-color-picker-coord", children: coord })
1175
+ ] }),
1176
+ /* @__PURE__ */ jsx24("span", { className: "kz-color-picker-hex", children: value.toUpperCase() })
1177
+ ] }),
1178
+ /* @__PURE__ */ jsx24("div", { className: "kz-color-picker-trigger-row", ref, children: /* @__PURE__ */ jsxs20(
1179
+ "button",
1180
+ {
1181
+ type: "button",
1182
+ disabled,
1183
+ className: "kz-color-picker-swatch-trigger",
1184
+ onClick: () => !disabled && setIsOpen(!isOpen),
1185
+ "aria-label": label || "Select color",
1186
+ children: [
1187
+ /* @__PURE__ */ jsx24("span", { className: "kz-color-picker-swatch-preview", style: { backgroundColor: value } }),
1188
+ /* @__PURE__ */ jsx24("span", { className: "kz-color-picker-swatch-val", children: value }),
1189
+ /* @__PURE__ */ jsx24("span", { className: "kz-color-picker-caret", children: "\u25BC" })
1190
+ ]
1191
+ }
1192
+ ) }),
1193
+ isOpen && /* @__PURE__ */ jsxs20("div", { className: "kz-color-picker-popover", children: [
1194
+ /* @__PURE__ */ jsx24("div", { className: "kz-color-picker-palette", children: presets.map((color) => /* @__PURE__ */ jsx24(
1195
+ "button",
1196
+ {
1197
+ type: "button",
1198
+ className: [
1199
+ "kz-color-picker-palette-btn",
1200
+ value.toLowerCase() === color.toLowerCase() ? "active" : ""
1201
+ ].filter(Boolean).join(" "),
1202
+ style: { backgroundColor: color },
1203
+ onClick: () => {
1204
+ onChange(color);
1205
+ },
1206
+ title: color
1207
+ },
1208
+ color
1209
+ )) }),
1210
+ showHexInput && /* @__PURE__ */ jsxs20("div", { className: "kz-color-picker-custom-input", children: [
1211
+ /* @__PURE__ */ jsx24(
1212
+ "input",
1213
+ {
1214
+ type: "color",
1215
+ value: value.startsWith("#") && value.length === 7 ? value : "#000000",
1216
+ onChange: (e) => onChange(e.target.value),
1217
+ className: "kz-color-picker-native-input"
1218
+ }
1219
+ ),
1220
+ /* @__PURE__ */ jsx24(
1221
+ "input",
1222
+ {
1223
+ type: "text",
1224
+ value,
1225
+ onChange: (e) => onChange(e.target.value),
1226
+ placeholder: "#000000",
1227
+ className: "kz-color-picker-text-input"
1228
+ }
1229
+ )
1230
+ ] })
1231
+ ] })
1232
+ ]
1233
+ }
1234
+ );
1235
+ }
1236
+ );
1237
+ ColorPicker.displayName = "ColorPicker";
1238
+
1239
+ // src/components/DropdownMenu.tsx
1240
+ import { forwardRef as forwardRef15, useState as useState5, useRef as useRef2, useEffect as useEffect5 } from "react";
1241
+ import { jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
1242
+ var DropdownMenu = forwardRef15(
1243
+ ({
1244
+ trigger,
1245
+ items,
1246
+ title,
1247
+ coord,
1248
+ align = "left",
1249
+ className = "",
1250
+ disabled = false
1251
+ }, ref) => {
1252
+ const [isOpen, setIsOpen] = useState5(false);
1253
+ const containerRef = useRef2(null);
1254
+ useEffect5(() => {
1255
+ const handleOutsideClick = (e) => {
1256
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
1257
+ setIsOpen(false);
1258
+ }
1259
+ };
1260
+ if (isOpen) {
1261
+ document.addEventListener("mousedown", handleOutsideClick);
1262
+ }
1263
+ return () => {
1264
+ document.removeEventListener("mousedown", handleOutsideClick);
1265
+ };
1266
+ }, [isOpen]);
1267
+ return /* @__PURE__ */ jsxs21(
1268
+ "div",
1269
+ {
1270
+ ref: containerRef,
1271
+ className: ["kz-dropdown-container", className].filter(Boolean).join(" "),
1272
+ children: [
1273
+ /* @__PURE__ */ jsx25(
1274
+ "div",
1275
+ {
1276
+ ref,
1277
+ className: "kz-dropdown-trigger-wrapper",
1278
+ onClick: () => !disabled && setIsOpen(!isOpen),
1279
+ children: trigger
1280
+ }
1281
+ ),
1282
+ isOpen && /* @__PURE__ */ jsxs21(
1283
+ "div",
1284
+ {
1285
+ className: [
1286
+ "kz-dropdown-menu",
1287
+ `align-${align}`
1288
+ ].filter(Boolean).join(" "),
1289
+ children: [
1290
+ (title || coord) && /* @__PURE__ */ jsxs21("div", { className: "kz-dropdown-header", children: [
1291
+ title && /* @__PURE__ */ jsx25("span", { className: "kz-dropdown-title", children: title }),
1292
+ coord && /* @__PURE__ */ jsx25("span", { className: "kz-dropdown-coord", children: coord })
1293
+ ] }),
1294
+ /* @__PURE__ */ jsx25("div", { className: "kz-dropdown-list", children: items.map((item) => /* @__PURE__ */ jsxs21(
1295
+ "button",
1296
+ {
1297
+ type: "button",
1298
+ disabled: item.disabled,
1299
+ className: [
1300
+ "kz-dropdown-item",
1301
+ item.danger ? "danger" : "",
1302
+ item.disabled ? "disabled" : ""
1303
+ ].filter(Boolean).join(" "),
1304
+ onClick: () => {
1305
+ if (item.disabled) return;
1306
+ item.onClick?.();
1307
+ setIsOpen(false);
1308
+ },
1309
+ children: [
1310
+ /* @__PURE__ */ jsxs21("div", { className: "kz-dropdown-item-left", children: [
1311
+ item.icon && /* @__PURE__ */ jsx25("span", { className: "kz-dropdown-item-icon", children: item.icon }),
1312
+ /* @__PURE__ */ jsxs21("div", { className: "kz-dropdown-item-text", children: [
1313
+ /* @__PURE__ */ jsx25("span", { className: "kz-dropdown-item-label", children: item.label }),
1314
+ item.sublabel && /* @__PURE__ */ jsx25("span", { className: "kz-dropdown-item-sublabel", children: item.sublabel })
1315
+ ] })
1316
+ ] }),
1317
+ /* @__PURE__ */ jsxs21("div", { className: "kz-dropdown-item-right", children: [
1318
+ item.shortcut && /* @__PURE__ */ jsx25("span", { className: "kz-dropdown-item-shortcut", children: item.shortcut }),
1319
+ item.badge !== void 0 && /* @__PURE__ */ jsx25("span", { className: "kz-dropdown-item-badge", children: item.badge })
1320
+ ] })
1321
+ ]
1322
+ },
1323
+ item.id
1324
+ )) })
1325
+ ]
1326
+ }
1327
+ )
1328
+ ]
1329
+ }
1330
+ );
1331
+ }
1332
+ );
1333
+ DropdownMenu.displayName = "DropdownMenu";
1334
+
1335
+ // src/components/Popover.tsx
1336
+ import { forwardRef as forwardRef16, useState as useState6, useRef as useRef3, useEffect as useEffect6 } from "react";
1337
+ import { jsx as jsx26, jsxs as jsxs22 } from "react/jsx-runtime";
1338
+ var Popover = forwardRef16(
1339
+ ({
1340
+ trigger,
1341
+ children,
1342
+ title,
1343
+ coord,
1344
+ align = "center",
1345
+ position = "bottom",
1346
+ className = "",
1347
+ isOpen: controlledOpen,
1348
+ defaultOpen = false,
1349
+ onOpenChange,
1350
+ disabled = false
1351
+ }, ref) => {
1352
+ const [internalOpen, setInternalOpen] = useState6(defaultOpen);
1353
+ const isControlled = controlledOpen !== void 0;
1354
+ const open = isControlled ? controlledOpen : internalOpen;
1355
+ const containerRef = useRef3(null);
1356
+ const toggleOpen = () => {
1357
+ if (disabled) return;
1358
+ const next = !open;
1359
+ if (!isControlled) {
1360
+ setInternalOpen(next);
1361
+ }
1362
+ onOpenChange?.(next);
1363
+ };
1364
+ const handleClose = () => {
1365
+ if (!isControlled) {
1366
+ setInternalOpen(false);
1367
+ }
1368
+ onOpenChange?.(false);
1369
+ };
1370
+ useEffect6(() => {
1371
+ const handleOutsideClick = (e) => {
1372
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
1373
+ handleClose();
1374
+ }
1375
+ };
1376
+ if (open) {
1377
+ document.addEventListener("mousedown", handleOutsideClick);
1378
+ }
1379
+ return () => {
1380
+ document.removeEventListener("mousedown", handleOutsideClick);
1381
+ };
1382
+ }, [open]);
1383
+ return /* @__PURE__ */ jsxs22(
1384
+ "div",
1385
+ {
1386
+ ref: containerRef,
1387
+ className: ["kz-popover-container", className].filter(Boolean).join(" "),
1388
+ children: [
1389
+ /* @__PURE__ */ jsx26(
1390
+ "div",
1391
+ {
1392
+ ref,
1393
+ className: "kz-popover-trigger-wrapper",
1394
+ onClick: toggleOpen,
1395
+ children: trigger
1396
+ }
1397
+ ),
1398
+ open && /* @__PURE__ */ jsxs22(
1399
+ "div",
1400
+ {
1401
+ className: [
1402
+ "kz-popover-content",
1403
+ `pos-${position}`,
1404
+ `align-${align}`
1405
+ ].filter(Boolean).join(" "),
1406
+ children: [
1407
+ (title || coord) && /* @__PURE__ */ jsxs22("div", { className: "kz-popover-header", children: [
1408
+ title && /* @__PURE__ */ jsx26("span", { className: "kz-popover-title", children: title }),
1409
+ coord && /* @__PURE__ */ jsx26("span", { className: "kz-popover-coord", children: coord })
1410
+ ] }),
1411
+ /* @__PURE__ */ jsx26("div", { className: "kz-popover-body", children })
1412
+ ]
1413
+ }
1414
+ )
1415
+ ]
1416
+ }
1417
+ );
1418
+ }
1419
+ );
1420
+ Popover.displayName = "Popover";
1077
1421
  export {
1078
1422
  Badge,
1079
1423
  BottomBar,
1080
1424
  BracketCard,
1081
1425
  Breadcrumbs,
1082
1426
  Button,
1427
+ ColorPicker,
1083
1428
  CornerFrame,
1084
1429
  CyberSwitch,
1085
1430
  Dot,
1431
+ DropdownMenu,
1086
1432
  HudModal,
1087
1433
  HudToast,
1088
1434
  Input,
1089
1435
  KeyValGrid,
1090
1436
  Logo,
1437
+ Popover,
1091
1438
  SegmentedControl,
1439
+ Slider,
1092
1440
  SpoilerGate,
1093
1441
  StickyNote,
1094
1442
  TacticalDrawer,