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.js CHANGED
@@ -361,8 +361,6 @@ function Folder({ title, children, defaultOpen = true, isRoot = false, onOpenCha
361
361
  const [isCollapsed, setIsCollapsed] = useState(!defaultOpen);
362
362
  const contentRef = useRef2(null);
363
363
  const [contentHeight, setContentHeight] = useState(void 0);
364
- const iconTransition = { type: "spring", visualDuration: 0.4, bounce: 0.1 };
365
- const panelTransition = { type: "spring", visualDuration: 0.4, bounce: 0.2 };
366
364
  useEffect2(() => {
367
365
  const el = contentRef.current;
368
366
  if (!el) return;
@@ -375,25 +373,20 @@ function Folder({ title, children, defaultOpen = true, isRoot = false, onOpenCha
375
373
  ro.observe(el);
376
374
  return () => ro.disconnect();
377
375
  }, [isOpen]);
376
+ const handleToggle = () => {
377
+ const next = !isOpen;
378
+ setIsOpen(next);
379
+ if (next) {
380
+ setIsCollapsed(false);
381
+ } else {
382
+ setIsCollapsed(true);
383
+ }
384
+ onOpenChange?.(next);
385
+ };
378
386
  const folderContent = /* @__PURE__ */ jsxs("div", { ref: isRoot ? contentRef : void 0, className: `dialkit-folder ${isRoot ? "dialkit-folder-root" : ""}`, children: [
379
- /* @__PURE__ */ jsxs("div", { className: `dialkit-folder-header ${isRoot ? "dialkit-panel-header" : ""}`, onClick: () => {
380
- const next = !isOpen;
381
- setIsOpen(next);
382
- if (next) setIsCollapsed(false);
383
- onOpenChange?.(next);
384
- }, children: [
387
+ /* @__PURE__ */ jsxs("div", { className: `dialkit-folder-header ${isRoot ? "dialkit-panel-header" : ""}`, onClick: handleToggle, children: [
385
388
  /* @__PURE__ */ jsxs("div", { className: "dialkit-folder-header-top", children: [
386
- isRoot ? /* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "popLayout", children: isOpen && /* @__PURE__ */ jsx(
387
- motion.div,
388
- {
389
- className: "dialkit-folder-title-row",
390
- initial: { opacity: 1 },
391
- animate: { opacity: 1 },
392
- exit: { opacity: 0 },
393
- transition: { duration: 0.15 },
394
- children: /* @__PURE__ */ jsx("span", { className: "dialkit-folder-title dialkit-folder-title-root", children: title })
395
- }
396
- ) }) : /* @__PURE__ */ jsx("div", { className: "dialkit-folder-title-row", children: /* @__PURE__ */ jsx("span", { className: "dialkit-folder-title", children: title }) }),
389
+ isRoot ? isOpen && /* @__PURE__ */ jsx("div", { className: "dialkit-folder-title-row", children: /* @__PURE__ */ jsx("span", { className: "dialkit-folder-title dialkit-folder-title-root", children: title }) }) : /* @__PURE__ */ jsx("div", { className: "dialkit-folder-title-row", children: /* @__PURE__ */ jsx("span", { className: "dialkit-folder-title", children: title }) }),
397
390
  isRoot ? (
398
391
  // Root panel icon — fixed position, container morphs around it
399
392
  /* @__PURE__ */ jsxs(
@@ -430,53 +423,32 @@ function Folder({ title, children, defaultOpen = true, isRoot = false, onOpenCha
430
423
  )
431
424
  )
432
425
  ] }),
433
- isRoot && toolbar && /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: isOpen && /* @__PURE__ */ jsx(
434
- motion.div,
435
- {
436
- initial: { opacity: 1 },
437
- animate: { opacity: 1 },
438
- exit: { opacity: 0 },
439
- transition: { duration: 0.15 },
440
- children: /* @__PURE__ */ jsx("div", { className: "dialkit-panel-toolbar", onClick: (e) => e.stopPropagation(), children: toolbar })
441
- }
442
- ) })
426
+ isRoot && toolbar && isOpen && /* @__PURE__ */ jsx("div", { className: "dialkit-panel-toolbar", onClick: (e) => e.stopPropagation(), children: toolbar })
443
427
  ] }),
444
428
  /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: isOpen && /* @__PURE__ */ jsx(
445
429
  motion.div,
446
430
  {
447
431
  className: "dialkit-folder-content",
448
- initial: isRoot ? { opacity: 1 } : { height: 0, opacity: 0 },
449
- animate: isRoot ? { opacity: 1 } : { height: "auto", opacity: 1 },
450
- exit: isRoot ? { opacity: 0 } : { height: 0, opacity: 0 },
451
- transition: isRoot ? { duration: 0.15 } : { type: "spring", visualDuration: 0.35, bounce: 0.1 },
452
- style: isRoot ? void 0 : { overflow: "hidden" },
432
+ initial: isRoot ? void 0 : { height: 0, opacity: 0 },
433
+ animate: isRoot ? void 0 : { height: "auto", opacity: 1 },
434
+ exit: isRoot ? void 0 : { height: 0, opacity: 0 },
435
+ transition: isRoot ? void 0 : { type: "spring", visualDuration: 0.35, bounce: 0.1 },
436
+ style: isRoot ? void 0 : { clipPath: "inset(0 -20px)" },
453
437
  children: /* @__PURE__ */ jsx("div", { className: "dialkit-folder-inner", children })
454
438
  }
455
439
  ) })
456
440
  ] });
457
441
  if (isRoot) {
442
+ 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" };
458
443
  return /* @__PURE__ */ jsx(
459
444
  motion.div,
460
445
  {
461
446
  className: "dialkit-panel-inner",
462
- initial: false,
463
- animate: {
464
- width: isOpen ? 280 : 42,
465
- height: isOpen ? contentHeight !== void 0 ? contentHeight + 24 : "auto" : 42,
466
- borderRadius: isOpen ? 14 : 21,
467
- boxShadow: isOpen ? "0 8px 32px rgba(0, 0, 0, 0.5)" : "0 4px 16px rgba(0, 0, 0, 0.25)"
468
- },
469
- transition: panelTransition,
470
- style: { overflow: isOpen ? void 0 : "hidden", cursor: isOpen ? void 0 : "pointer" },
471
- onClick: !isOpen ? () => {
472
- setIsOpen(true);
473
- setIsCollapsed(false);
474
- onOpenChange?.(true);
475
- } : void 0,
476
- onAnimationComplete: () => {
477
- if (!isOpen) setIsCollapsed(true);
478
- },
447
+ style: panelStyle,
448
+ onClick: !isOpen ? handleToggle : void 0,
479
449
  "data-collapsed": isCollapsed,
450
+ whileTap: !isOpen ? { scale: 0.9 } : void 0,
451
+ transition: { type: "spring", visualDuration: 0.15, bounce: 0.3 },
480
452
  children: folderContent
481
453
  }
482
454
  );
@@ -1147,9 +1119,12 @@ function TextControl({ label, value, onChange, placeholder }) {
1147
1119
  import { useState as useState4, useRef as useRef5, useEffect as useEffect4 } from "react";
1148
1120
  import { motion as motion4, AnimatePresence as AnimatePresence2 } from "motion/react";
1149
1121
  import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1122
+ function toTitleCase(s) {
1123
+ return s.replace(/\b\w/g, (c) => c.toUpperCase());
1124
+ }
1150
1125
  function normalizeOptions(options) {
1151
1126
  return options.map(
1152
- (opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
1127
+ (opt) => typeof opt === "string" ? { value: opt, label: toTitleCase(opt) } : opt
1153
1128
  );
1154
1129
  }
1155
1130
  function SelectControl({ label, value, options, onChange }) {
@@ -1370,7 +1345,7 @@ function PresetManager({ panelId, presets, activePresetId, onAdd }) {
1370
1345
  strokeWidth: "2.5",
1371
1346
  strokeLinecap: "round",
1372
1347
  strokeLinejoin: "round",
1373
- animate: { rotate: isOpen ? 180 : 0 },
1348
+ animate: { rotate: isOpen ? 180 : 0, opacity: hasPresets ? 0.6 : 0.25 },
1374
1349
  transition: { type: "spring", visualDuration: 0.2, bounce: 0.15 },
1375
1350
  children: /* @__PURE__ */ jsx10("path", { d: "M6 9.5L12 15.5L18 9.5" })
1376
1351
  }
@@ -1566,11 +1541,13 @@ Apply these values as the new defaults in the useDialKit call.`;
1566
1541
  const iconTransition = { type: "spring", visualDuration: 0.4, bounce: 0.1 };
1567
1542
  const toolbar = /* @__PURE__ */ jsxs11(Fragment2, { children: [
1568
1543
  /* @__PURE__ */ jsx11(
1569
- "button",
1544
+ motion6.button,
1570
1545
  {
1571
1546
  className: "dialkit-toolbar-add",
1572
1547
  onClick: handleAddPreset,
1573
1548
  title: "Add preset",
1549
+ whileTap: { scale: 0.9 },
1550
+ transition: { type: "spring", visualDuration: 0.15, bounce: 0.3 },
1574
1551
  children: /* @__PURE__ */ jsxs11("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
1575
1552
  /* @__PURE__ */ jsx11("path", { d: "M4 6H20" }),
1576
1553
  /* @__PURE__ */ jsx11("path", { d: "M4 12H10" }),
@@ -1590,13 +1567,15 @@ Apply these values as the new defaults in the useDialKit call.`;
1590
1567
  }
1591
1568
  ),
1592
1569
  /* @__PURE__ */ jsxs11(
1593
- "button",
1570
+ motion6.button,
1594
1571
  {
1595
1572
  className: "dialkit-toolbar-copy",
1596
1573
  onClick: handleCopy,
1597
1574
  title: "Copy parameters",
1575
+ whileTap: { scale: 0.95 },
1576
+ transition: { type: "spring", visualDuration: 0.15, bounce: 0.3 },
1598
1577
  children: [
1599
- /* @__PURE__ */ jsx11("span", { className: "dialkit-toolbar-copy-icon-wrap", children: /* @__PURE__ */ jsx11(AnimatePresence4, { mode: "popLayout", children: copied ? /* @__PURE__ */ jsx11(
1578
+ /* @__PURE__ */ jsx11("span", { className: "dialkit-toolbar-copy-icon-wrap", children: /* @__PURE__ */ jsx11(AnimatePresence4, { initial: false, mode: "popLayout", children: copied ? /* @__PURE__ */ jsx11(
1600
1579
  motion6.svg,
1601
1580
  {
1602
1581
  className: "dialkit-toolbar-copy-icon",