dialkit 0.2.0 → 0.2.1
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.cjs +35 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -56
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -398,8 +398,6 @@ function Folder({ title, children, defaultOpen = true, isRoot = false, onOpenCha
|
|
|
398
398
|
const [isCollapsed, setIsCollapsed] = (0, import_react2.useState)(!defaultOpen);
|
|
399
399
|
const contentRef = (0, import_react2.useRef)(null);
|
|
400
400
|
const [contentHeight, setContentHeight] = (0, import_react2.useState)(void 0);
|
|
401
|
-
const iconTransition = { type: "spring", visualDuration: 0.4, bounce: 0.1 };
|
|
402
|
-
const panelTransition = { type: "spring", visualDuration: 0.4, bounce: 0.2 };
|
|
403
401
|
(0, import_react2.useEffect)(() => {
|
|
404
402
|
const el = contentRef.current;
|
|
405
403
|
if (!el) return;
|
|
@@ -412,25 +410,20 @@ function Folder({ title, children, defaultOpen = true, isRoot = false, onOpenCha
|
|
|
412
410
|
ro.observe(el);
|
|
413
411
|
return () => ro.disconnect();
|
|
414
412
|
}, [isOpen]);
|
|
413
|
+
const handleToggle = () => {
|
|
414
|
+
const next = !isOpen;
|
|
415
|
+
setIsOpen(next);
|
|
416
|
+
if (next) {
|
|
417
|
+
setIsCollapsed(false);
|
|
418
|
+
} else {
|
|
419
|
+
setIsCollapsed(true);
|
|
420
|
+
}
|
|
421
|
+
onOpenChange?.(next);
|
|
422
|
+
};
|
|
415
423
|
const folderContent = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: isRoot ? contentRef : void 0, className: `dialkit-folder ${isRoot ? "dialkit-folder-root" : ""}`, children: [
|
|
416
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `dialkit-folder-header ${isRoot ? "dialkit-panel-header" : ""}`, onClick:
|
|
417
|
-
const next = !isOpen;
|
|
418
|
-
setIsOpen(next);
|
|
419
|
-
if (next) setIsCollapsed(false);
|
|
420
|
-
onOpenChange?.(next);
|
|
421
|
-
}, children: [
|
|
424
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `dialkit-folder-header ${isRoot ? "dialkit-panel-header" : ""}`, onClick: handleToggle, children: [
|
|
422
425
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dialkit-folder-header-top", children: [
|
|
423
|
-
isRoot ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
424
|
-
import_react3.motion.div,
|
|
425
|
-
{
|
|
426
|
-
className: "dialkit-folder-title-row",
|
|
427
|
-
initial: { opacity: 1 },
|
|
428
|
-
animate: { opacity: 1 },
|
|
429
|
-
exit: { opacity: 0 },
|
|
430
|
-
transition: { duration: 0.15 },
|
|
431
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dialkit-folder-title dialkit-folder-title-root", children: title })
|
|
432
|
-
}
|
|
433
|
-
) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dialkit-folder-title-row", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dialkit-folder-title", children: title }) }),
|
|
426
|
+
isRoot ? isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dialkit-folder-title-row", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dialkit-folder-title dialkit-folder-title-root", children: title }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dialkit-folder-title-row", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dialkit-folder-title", children: title }) }),
|
|
434
427
|
isRoot ? (
|
|
435
428
|
// Root panel icon — fixed position, container morphs around it
|
|
436
429
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
@@ -467,53 +460,32 @@ function Folder({ title, children, defaultOpen = true, isRoot = false, onOpenCha
|
|
|
467
460
|
)
|
|
468
461
|
)
|
|
469
462
|
] }),
|
|
470
|
-
isRoot && toolbar && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
471
|
-
import_react3.motion.div,
|
|
472
|
-
{
|
|
473
|
-
initial: { opacity: 1 },
|
|
474
|
-
animate: { opacity: 1 },
|
|
475
|
-
exit: { opacity: 0 },
|
|
476
|
-
transition: { duration: 0.15 },
|
|
477
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dialkit-panel-toolbar", onClick: (e) => e.stopPropagation(), children: toolbar })
|
|
478
|
-
}
|
|
479
|
-
) })
|
|
463
|
+
isRoot && toolbar && isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dialkit-panel-toolbar", onClick: (e) => e.stopPropagation(), children: toolbar })
|
|
480
464
|
] }),
|
|
481
465
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react3.AnimatePresence, { initial: false, children: isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
482
466
|
import_react3.motion.div,
|
|
483
467
|
{
|
|
484
468
|
className: "dialkit-folder-content",
|
|
485
|
-
initial: isRoot ?
|
|
486
|
-
animate: isRoot ?
|
|
487
|
-
exit: isRoot ?
|
|
488
|
-
transition: isRoot ?
|
|
489
|
-
style: isRoot ? void 0 : {
|
|
469
|
+
initial: isRoot ? void 0 : { height: 0, opacity: 0 },
|
|
470
|
+
animate: isRoot ? void 0 : { height: "auto", opacity: 1 },
|
|
471
|
+
exit: isRoot ? void 0 : { height: 0, opacity: 0 },
|
|
472
|
+
transition: isRoot ? void 0 : { type: "spring", visualDuration: 0.35, bounce: 0.1 },
|
|
473
|
+
style: isRoot ? void 0 : { clipPath: "inset(0 -20px)" },
|
|
490
474
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dialkit-folder-inner", children })
|
|
491
475
|
}
|
|
492
476
|
) })
|
|
493
477
|
] });
|
|
494
478
|
if (isRoot) {
|
|
479
|
+
const panelStyle = isOpen ? { width: 280, height: contentHeight !== void 0 ? contentHeight + 24 : "auto", borderRadius: 14, boxShadow: "0 8px 32px rgba(0, 0, 0, 0.5)", cursor: void 0 } : { width: 42, height: 42, borderRadius: 21, boxShadow: "0 4px 16px rgba(0, 0, 0, 0.25)", overflow: "hidden", cursor: "pointer" };
|
|
495
480
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
496
481
|
import_react3.motion.div,
|
|
497
482
|
{
|
|
498
483
|
className: "dialkit-panel-inner",
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
width: isOpen ? 280 : 42,
|
|
502
|
-
height: isOpen ? contentHeight !== void 0 ? contentHeight + 24 : "auto" : 42,
|
|
503
|
-
borderRadius: isOpen ? 14 : 21,
|
|
504
|
-
boxShadow: isOpen ? "0 8px 32px rgba(0, 0, 0, 0.5)" : "0 4px 16px rgba(0, 0, 0, 0.25)"
|
|
505
|
-
},
|
|
506
|
-
transition: panelTransition,
|
|
507
|
-
style: { overflow: isOpen ? void 0 : "hidden", cursor: isOpen ? void 0 : "pointer" },
|
|
508
|
-
onClick: !isOpen ? () => {
|
|
509
|
-
setIsOpen(true);
|
|
510
|
-
setIsCollapsed(false);
|
|
511
|
-
onOpenChange?.(true);
|
|
512
|
-
} : void 0,
|
|
513
|
-
onAnimationComplete: () => {
|
|
514
|
-
if (!isOpen) setIsCollapsed(true);
|
|
515
|
-
},
|
|
484
|
+
style: panelStyle,
|
|
485
|
+
onClick: !isOpen ? handleToggle : void 0,
|
|
516
486
|
"data-collapsed": isCollapsed,
|
|
487
|
+
whileTap: !isOpen ? { scale: 0.9 } : void 0,
|
|
488
|
+
transition: { type: "spring", visualDuration: 0.15, bounce: 0.3 },
|
|
517
489
|
children: folderContent
|
|
518
490
|
}
|
|
519
491
|
);
|
|
@@ -1184,9 +1156,12 @@ function TextControl({ label, value, onChange, placeholder }) {
|
|
|
1184
1156
|
var import_react9 = require("react");
|
|
1185
1157
|
var import_react10 = require("motion/react");
|
|
1186
1158
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1159
|
+
function toTitleCase(s) {
|
|
1160
|
+
return s.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
1161
|
+
}
|
|
1187
1162
|
function normalizeOptions(options) {
|
|
1188
1163
|
return options.map(
|
|
1189
|
-
(opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
|
|
1164
|
+
(opt) => typeof opt === "string" ? { value: opt, label: toTitleCase(opt) } : opt
|
|
1190
1165
|
);
|
|
1191
1166
|
}
|
|
1192
1167
|
function SelectControl({ label, value, options, onChange }) {
|
|
@@ -1407,7 +1382,7 @@ function PresetManager({ panelId, presets, activePresetId, onAdd }) {
|
|
|
1407
1382
|
strokeWidth: "2.5",
|
|
1408
1383
|
strokeLinecap: "round",
|
|
1409
1384
|
strokeLinejoin: "round",
|
|
1410
|
-
animate: { rotate: isOpen ? 180 : 0 },
|
|
1385
|
+
animate: { rotate: isOpen ? 180 : 0, opacity: hasPresets ? 0.6 : 0.25 },
|
|
1411
1386
|
transition: { type: "spring", visualDuration: 0.2, bounce: 0.15 },
|
|
1412
1387
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M6 9.5L12 15.5L18 9.5" })
|
|
1413
1388
|
}
|
|
@@ -1603,11 +1578,13 @@ Apply these values as the new defaults in the useDialKit call.`;
|
|
|
1603
1578
|
const iconTransition = { type: "spring", visualDuration: 0.4, bounce: 0.1 };
|
|
1604
1579
|
const toolbar = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
1605
1580
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1606
|
-
|
|
1581
|
+
import_react15.motion.button,
|
|
1607
1582
|
{
|
|
1608
1583
|
className: "dialkit-toolbar-add",
|
|
1609
1584
|
onClick: handleAddPreset,
|
|
1610
1585
|
title: "Add preset",
|
|
1586
|
+
whileTap: { scale: 0.9 },
|
|
1587
|
+
transition: { type: "spring", visualDuration: 0.15, bounce: 0.3 },
|
|
1611
1588
|
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1612
1589
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M4 6H20" }),
|
|
1613
1590
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M4 12H10" }),
|
|
@@ -1627,13 +1604,15 @@ Apply these values as the new defaults in the useDialKit call.`;
|
|
|
1627
1604
|
}
|
|
1628
1605
|
),
|
|
1629
1606
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1630
|
-
|
|
1607
|
+
import_react15.motion.button,
|
|
1631
1608
|
{
|
|
1632
1609
|
className: "dialkit-toolbar-copy",
|
|
1633
1610
|
onClick: handleCopy,
|
|
1634
1611
|
title: "Copy parameters",
|
|
1612
|
+
whileTap: { scale: 0.95 },
|
|
1613
|
+
transition: { type: "spring", visualDuration: 0.15, bounce: 0.3 },
|
|
1635
1614
|
children: [
|
|
1636
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "dialkit-toolbar-copy-icon-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react15.AnimatePresence, { mode: "popLayout", children: copied ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1615
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "dialkit-toolbar-copy-icon-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react15.AnimatePresence, { initial: false, mode: "popLayout", children: copied ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1637
1616
|
import_react15.motion.svg,
|
|
1638
1617
|
{
|
|
1639
1618
|
className: "dialkit-toolbar-copy-icon",
|