@mahatisystems/mahati-ui-components 5.0.0 → 5.0.2

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
@@ -469,6 +469,15 @@ __export(index_exports, {
469
469
  MahatiActivity: function MahatiActivity1() {
470
470
  return MahatiActivity;
471
471
  },
472
+ MahatiAsyncDropdown: function MahatiAsyncDropdown1() {
473
+ return AsyncDropdown;
474
+ },
475
+ MahatiAvatarDropdown: function MahatiAvatarDropdown1() {
476
+ return AvatarDropdown;
477
+ },
478
+ MahatiAvatarMultiSelectDropdown: function MahatiAvatarMultiSelectDropdown1() {
479
+ return AvatarMultiSelectDropdown;
480
+ },
472
481
  MahatiButton: function MahatiButton1() {
473
482
  return Button;
474
483
  },
@@ -481,6 +490,9 @@ __export(index_exports, {
481
490
  MahatiCard: function MahatiCard1() {
482
491
  return Card;
483
492
  },
493
+ MahatiCascadingDropdown: function MahatiCascadingDropdown1() {
494
+ return CascadingDropdown;
495
+ },
484
496
  MahatiChartAnalyticsWidget: function MahatiChartAnalyticsWidget1() {
485
497
  return MahatiChartAnalyticsWidget;
486
498
  },
@@ -493,6 +505,9 @@ __export(index_exports, {
493
505
  MahatiFormContainer: function MahatiFormContainer1() {
494
506
  return FormContainer;
495
507
  },
508
+ MahatiGroupedDropdown: function MahatiGroupedDropdown1() {
509
+ return GroupedDropdown;
510
+ },
496
511
  MahatiInput: function MahatiInput1() {
497
512
  return Input;
498
513
  },
@@ -505,6 +520,9 @@ __export(index_exports, {
505
520
  MahatiModal: function MahatiModal1() {
506
521
  return Modal;
507
522
  },
523
+ MahatiMultiSelectDropdown: function MahatiMultiSelectDropdown1() {
524
+ return MultiSelectDropdown;
525
+ },
508
526
  MahatiNotificationCard: function MahatiNotificationCard1() {
509
527
  return MahatiNotificationCard;
510
528
  },
@@ -11220,6 +11238,695 @@ function SearchableDropdown(param) {
11220
11238
  ]
11221
11239
  });
11222
11240
  }
11241
+ function MultiSelectDropdown(param) {
11242
+ var _param_label = param.label, label = _param_label === void 0 ? "Multi Select" : _param_label, options = param.options, values = param.values, onChange = param.onChange, testId = param.testId;
11243
+ var _ref = _sliced_to_array((0, import_react22.useState)(false), 2), open = _ref[0], setOpen = _ref[1];
11244
+ var _ref1 = _sliced_to_array((0, import_react22.useState)(""), 2), search = _ref1[0], setSearch = _ref1[1];
11245
+ var ref = (0, import_react22.useRef)(null);
11246
+ var removeValue = function removeValue(val) {
11247
+ onChange(values.filter(function(v) {
11248
+ return v !== val;
11249
+ }));
11250
+ };
11251
+ (0, import_react22.useEffect)(function() {
11252
+ var handler = function handler(e) {
11253
+ if (ref.current && !ref.current.contains(e.target)) {
11254
+ setOpen(false);
11255
+ }
11256
+ };
11257
+ document.addEventListener("mousedown", handler);
11258
+ return function() {
11259
+ return document.removeEventListener("mousedown", handler);
11260
+ };
11261
+ }, []);
11262
+ var toggleValue = function toggleValue(value) {
11263
+ if (values.includes(value)) {
11264
+ onChange(values.filter(function(v) {
11265
+ return v !== value;
11266
+ }));
11267
+ } else {
11268
+ onChange(_to_consumable_array(values).concat([
11269
+ value
11270
+ ]));
11271
+ }
11272
+ };
11273
+ var filteredOptions = options.filter(function(o) {
11274
+ return o.label.toLowerCase().includes(search.toLowerCase());
11275
+ });
11276
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11277
+ ref: ref,
11278
+ "data-testid": testId,
11279
+ className: "relative w-[320px] max-w-full mx-auto",
11280
+ children: [
11281
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("label", {
11282
+ className: "block mb-2 text-[12px] font-semibold text-[#1761a3]",
11283
+ children: label
11284
+ }),
11285
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("button", {
11286
+ onClick: function onClick() {
11287
+ return setOpen(!open);
11288
+ },
11289
+ className: "w-full flex justify-between items-center px-4 py-3 rounded-[8px]\r\n bg-gradient-to-r from-[#1761a3] to-[#4daf83] text-white font-semibold",
11290
+ children: [
11291
+ values.length === 0 ? "Multi Select" : "Multi Select",
11292
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react5.ChevronDown, {
11293
+ size: 16
11294
+ })
11295
+ ]
11296
+ }),
11297
+ values.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11298
+ className: "flex flex-wrap gap-2 mt-3",
11299
+ children: values.map(function(val) {
11300
+ var _options_find;
11301
+ var lbl = (_options_find = options.find(function(o) {
11302
+ return o.value === val;
11303
+ })) === null || _options_find === void 0 ? void 0 : _options_find.label;
11304
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11305
+ className: "flex items-center gap-[6px] px-[10px] py-[6px]\r\n bg-white border border-[#cde3f1] rounded-[10px] text-[13px]",
11306
+ children: [
11307
+ lbl,
11308
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react5.X, {
11309
+ size: 14,
11310
+ className: "cursor-pointer",
11311
+ onClick: function onClick() {
11312
+ return removeValue(val);
11313
+ }
11314
+ })
11315
+ ]
11316
+ }, val);
11317
+ })
11318
+ }),
11319
+ open && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11320
+ className: "absolute top-[calc(100%+8px)] left-0 w-full bg-white\r\n rounded-[12px] border border-[rgba(77,175,131,0.4)] z-[100]",
11321
+ children: [
11322
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11323
+ className: "p-3 border-b border-[#e5e7eb] relative",
11324
+ children: [
11325
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", {
11326
+ value: search,
11327
+ onChange: function onChange(e) {
11328
+ return setSearch(e.target.value);
11329
+ },
11330
+ placeholder: "Search...",
11331
+ className: "w-full h-[36px] px-3 pr-9 border rounded-[6px]\r\n border-[rgba(23,97,163,0.3)] outline-none"
11332
+ }),
11333
+ search && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", {
11334
+ onClick: function onClick() {
11335
+ return setSearch("");
11336
+ },
11337
+ className: "absolute right-[15px] top-1/2 -translate-y-1/2\r\n w-[22px] h-[22px] rounded-full bg-[#9ca3af] text-white",
11338
+ children: "\u2715"
11339
+ })
11340
+ ]
11341
+ }),
11342
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11343
+ className: "max-h-[220px] overflow-y-auto",
11344
+ children: [
11345
+ filteredOptions.map(function(opt) {
11346
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11347
+ onClick: function onClick() {
11348
+ return toggleValue(opt.value);
11349
+ },
11350
+ className: "px-4 py-[10px] text-[14px] flex items-center gap-2 cursor-pointer\n hover:bg-[#f1f5f9] ".concat(values.includes(opt.value) ? "bg-[#e6f3ef]" : ""),
11351
+ children: [
11352
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", {
11353
+ type: "checkbox",
11354
+ checked: values.includes(opt.value),
11355
+ readOnly: true
11356
+ }),
11357
+ opt.label
11358
+ ]
11359
+ }, opt.value);
11360
+ }),
11361
+ filteredOptions.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11362
+ className: "p-3 text-[#9ca3af]",
11363
+ children: "No results"
11364
+ })
11365
+ ]
11366
+ })
11367
+ ]
11368
+ })
11369
+ ]
11370
+ });
11371
+ }
11372
+ function CascadingDropdown(param) {
11373
+ var _param_label = param.label, label = _param_label === void 0 ? "Cascading Dropdown" : _param_label, data = param.data, value = param.value, testId = param.testId, onChange = param.onChange;
11374
+ var _data_find, _level2_find;
11375
+ var _ref = _sliced_to_array((0, import_react22.useState)(false), 2), open = _ref[0], setOpen = _ref[1];
11376
+ var ref = (0, import_react22.useRef)(null);
11377
+ (0, import_react22.useEffect)(function() {
11378
+ var handler = function handler(e) {
11379
+ if (ref.current && !ref.current.contains(e.target)) {
11380
+ setOpen(false);
11381
+ }
11382
+ };
11383
+ document.addEventListener("mousedown", handler);
11384
+ return function() {
11385
+ return document.removeEventListener("mousedown", handler);
11386
+ };
11387
+ }, []);
11388
+ var level1 = data;
11389
+ var level2 = ((_data_find = data.find(function(d) {
11390
+ return d.value === value.level1;
11391
+ })) === null || _data_find === void 0 ? void 0 : _data_find.children) || [];
11392
+ var level3 = ((_level2_find = level2.find(function(d) {
11393
+ return d.value === value.level2;
11394
+ })) === null || _level2_find === void 0 ? void 0 : _level2_find.children) || [];
11395
+ var displayText = value.level3 || value.level2 || value.level1 || "Select location";
11396
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11397
+ ref: ref,
11398
+ "data-testid": testId,
11399
+ className: "relative w-[320px] max-w-full mx-auto",
11400
+ children: [
11401
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("label", {
11402
+ className: "block mb-2 text-[12px] font-semibold text-[#1761a3]",
11403
+ children: label
11404
+ }),
11405
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("button", {
11406
+ onClick: function onClick() {
11407
+ return setOpen(function(o) {
11408
+ return !o;
11409
+ });
11410
+ },
11411
+ className: "w-full flex justify-between items-center px-4 py-3 rounded-[8px]\r\n bg-gradient-to-r from-[#1761a3] to-[#4daf83] text-white font-semibold",
11412
+ children: [
11413
+ displayText,
11414
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react5.ChevronDown, {
11415
+ size: 16
11416
+ })
11417
+ ]
11418
+ }),
11419
+ open && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11420
+ className: "absolute top-[calc(100%+8px)] left-0 w-full bg-white\r\n rounded-[12px] border border-[rgba(77,175,131,0.4)] z-[100]",
11421
+ children: [
11422
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11423
+ className: "max-h-[220px] overflow-y-auto",
11424
+ children: level1.map(function(opt) {
11425
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11426
+ onClick: function onClick() {
11427
+ return onChange({
11428
+ level1: opt.value
11429
+ });
11430
+ },
11431
+ className: "px-4 py-[10px] text-[14px] cursor-pointer\n hover:bg-[#f1f5f9] ".concat(value.level1 === opt.value ? "bg-[#e6f3ef]" : ""),
11432
+ children: opt.label
11433
+ }, opt.value);
11434
+ })
11435
+ }),
11436
+ level2.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11437
+ className: "max-h-[220px] overflow-y-auto border-t border-[#e5e7eb]",
11438
+ children: level2.map(function(opt) {
11439
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11440
+ onClick: function onClick() {
11441
+ return onChange({
11442
+ level1: value.level1,
11443
+ level2: opt.value
11444
+ });
11445
+ },
11446
+ className: "px-4 py-[10px] text-[14px] cursor-pointer\n hover:bg-[#f1f5f9] ".concat(value.level2 === opt.value ? "bg-[#e6f3ef]" : ""),
11447
+ children: [
11448
+ "\u2514 ",
11449
+ opt.label
11450
+ ]
11451
+ }, opt.value);
11452
+ })
11453
+ }),
11454
+ level3.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11455
+ className: "max-h-[220px] overflow-y-auto border-t border-[#e5e7eb]",
11456
+ children: level3.map(function(opt) {
11457
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11458
+ onClick: function onClick() {
11459
+ return onChange({
11460
+ level1: value.level1,
11461
+ level2: value.level2,
11462
+ level3: opt.value
11463
+ });
11464
+ },
11465
+ className: "px-4 py-[10px] text-[14px] cursor-pointer\n hover:bg-[#f1f5f9] ".concat(value.level3 === opt.value ? "bg-[#e6f3ef]" : ""),
11466
+ children: [
11467
+ "\u2514\u2500 ",
11468
+ opt.label
11469
+ ]
11470
+ }, opt.value);
11471
+ })
11472
+ })
11473
+ ]
11474
+ })
11475
+ ]
11476
+ });
11477
+ }
11478
+ function GroupedDropdown(param) {
11479
+ var _param_label = param.label, label = _param_label === void 0 ? "Grouped Dropdown" : _param_label, groups = param.groups, values = param.values, onChange = param.onChange, testId = param.testId;
11480
+ var _ref = _sliced_to_array((0, import_react22.useState)(false), 2), open = _ref[0], setOpen = _ref[1];
11481
+ var ref = (0, import_react22.useRef)(null);
11482
+ (0, import_react22.useEffect)(function() {
11483
+ var handler = function handler(e) {
11484
+ if (ref.current && !ref.current.contains(e.target)) {
11485
+ setOpen(false);
11486
+ }
11487
+ };
11488
+ document.addEventListener("mousedown", handler);
11489
+ return function() {
11490
+ return document.removeEventListener("mousedown", handler);
11491
+ };
11492
+ }, []);
11493
+ var isSectionSelected = function isSectionSelected(group) {
11494
+ return (values === null || values === void 0 ? void 0 : values.section) === group.label;
11495
+ };
11496
+ var isChildChecked = function isChildChecked(value) {
11497
+ var _ref;
11498
+ return (_ref = values === null || values === void 0 ? void 0 : values.values.includes(value)) !== null && _ref !== void 0 ? _ref : false;
11499
+ };
11500
+ var toggleSection = function toggleSection(group) {
11501
+ if ((values === null || values === void 0 ? void 0 : values.section) === group.label) {
11502
+ onChange(null);
11503
+ } else {
11504
+ onChange({
11505
+ section: group.label,
11506
+ values: group.options.map(function(o) {
11507
+ return o.value;
11508
+ })
11509
+ });
11510
+ }
11511
+ };
11512
+ var toggleChild = function toggleChild(group, value) {
11513
+ if ((values === null || values === void 0 ? void 0 : values.section) !== group.label) {
11514
+ onChange({
11515
+ section: group.label,
11516
+ values: [
11517
+ value
11518
+ ]
11519
+ });
11520
+ return;
11521
+ }
11522
+ var exists = values.values.includes(value);
11523
+ var newValues = exists ? values.values.filter(function(v) {
11524
+ return v !== value;
11525
+ }) : _to_consumable_array(values.values).concat([
11526
+ value
11527
+ ]);
11528
+ onChange(newValues.length === 0 ? null : {
11529
+ section: group.label,
11530
+ values: newValues
11531
+ });
11532
+ };
11533
+ var displayValue = !values ? "Select options" : "".concat(values.section, " (").concat(values.values.map(function(v) {
11534
+ var _groups_flatMap_find;
11535
+ return (_groups_flatMap_find = groups.flatMap(function(g) {
11536
+ return g.options;
11537
+ }).find(function(o) {
11538
+ return o.value === v;
11539
+ })) === null || _groups_flatMap_find === void 0 ? void 0 : _groups_flatMap_find.label;
11540
+ }).join(", "), ")");
11541
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11542
+ ref: ref,
11543
+ "data-testid": testId,
11544
+ className: "relative w-[320px] max-w-full mx-auto",
11545
+ children: [
11546
+ label && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("label", {
11547
+ className: "block mb-2 text-[12px] font-semibold text-[#1761a3]",
11548
+ children: label
11549
+ }),
11550
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("button", {
11551
+ onClick: function onClick() {
11552
+ return setOpen(function(o) {
11553
+ return !o;
11554
+ });
11555
+ },
11556
+ className: "w-full px-4 py-3 rounded-[8px] text-white font-semibold\r\n bg-gradient-to-r from-[#1761a3] to-[#4daf83]\r\n flex justify-between items-center",
11557
+ children: [
11558
+ displayValue,
11559
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react5.ChevronDown, {
11560
+ size: 16
11561
+ })
11562
+ ]
11563
+ }),
11564
+ open && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11565
+ className: "absolute top-[calc(100%+8px)] left-0 w-full bg-white\r\n rounded-[12px] border border-[rgba(23,97,163,0.3)] z-[100]",
11566
+ children: groups.map(function(group) {
11567
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11568
+ className: "p-3",
11569
+ children: [
11570
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11571
+ className: "flex items-center gap-2 font-semibold",
11572
+ children: [
11573
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", {
11574
+ type: "checkbox",
11575
+ checked: isSectionSelected(group),
11576
+ onChange: function onChange() {
11577
+ return toggleSection(group);
11578
+ }
11579
+ }),
11580
+ group.label
11581
+ ]
11582
+ }),
11583
+ group.options.map(function(opt) {
11584
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("label", {
11585
+ className: "flex items-center gap-2 text-[14px] mt-[6px] ml-[22px]",
11586
+ children: [
11587
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", {
11588
+ type: "checkbox",
11589
+ checked: isChildChecked(opt.value),
11590
+ onChange: function onChange() {
11591
+ return toggleChild(group, opt.value);
11592
+ }
11593
+ }),
11594
+ opt.label
11595
+ ]
11596
+ }, opt.value);
11597
+ })
11598
+ ]
11599
+ }, group.label);
11600
+ })
11601
+ })
11602
+ ]
11603
+ });
11604
+ }
11605
+ function AvatarDropdown(param) {
11606
+ var _param_label = param.label, label = _param_label === void 0 ? "Select Avatar" : _param_label, _param_placeholder = param.placeholder, placeholder = _param_placeholder === void 0 ? "Choose user" : _param_placeholder, options = param.options, value = param.value, testId = param.testId, onChange = param.onChange;
11607
+ var _ref = _sliced_to_array((0, import_react22.useState)(false), 2), open = _ref[0], setOpen = _ref[1];
11608
+ var ref = (0, import_react22.useRef)(null);
11609
+ (0, import_react22.useEffect)(function() {
11610
+ var handler = function handler(e) {
11611
+ if (ref.current && !ref.current.contains(e.target)) {
11612
+ setOpen(false);
11613
+ }
11614
+ };
11615
+ document.addEventListener("mousedown", handler);
11616
+ return function() {
11617
+ return document.removeEventListener("mousedown", handler);
11618
+ };
11619
+ }, []);
11620
+ var selected = options.find(function(o) {
11621
+ return o.value === value;
11622
+ });
11623
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11624
+ ref: ref,
11625
+ "data-testid": testId,
11626
+ className: "relative w-[320px] max-w-full mx-auto",
11627
+ children: [
11628
+ label && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("label", {
11629
+ className: "block mb-2 text-[12px] font-semibold text-[#1761a3]",
11630
+ children: label
11631
+ }),
11632
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("button", {
11633
+ onClick: function onClick() {
11634
+ return setOpen(function(o) {
11635
+ return !o;
11636
+ });
11637
+ },
11638
+ className: "w-full px-4 py-3 rounded-[8px] text-white font-semibold\r\n bg-gradient-to-r from-[#1761a3] to-[#4daf83]\r\n flex justify-between items-center",
11639
+ children: [
11640
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", {
11641
+ className: "flex items-center gap-[10px]",
11642
+ children: selected ? /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, {
11643
+ children: [
11644
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("img", {
11645
+ src: selected.image,
11646
+ alt: selected.label,
11647
+ className: "w-[28px] h-[28px] rounded-[6px] object-cover"
11648
+ }),
11649
+ selected.label
11650
+ ]
11651
+ }) : placeholder
11652
+ }),
11653
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react5.ChevronDown, {
11654
+ size: 16
11655
+ })
11656
+ ]
11657
+ }),
11658
+ open && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11659
+ className: "absolute top-[calc(100%+8px)] left-0 w-full bg-white\r\n rounded-[12px] border border-[rgba(77,175,131,0.4)] z-[100]",
11660
+ children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11661
+ className: "max-h-[220px] overflow-y-auto",
11662
+ children: options.map(function(opt) {
11663
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11664
+ onClick: function onClick() {
11665
+ onChange(opt.value);
11666
+ setOpen(false);
11667
+ },
11668
+ className: "px-4 py-[10px] text-[14px] cursor-pointer\n flex items-center gap-[12px]\n hover:bg-[#f1f5f9]\n ".concat(opt.value === value ? "bg-[#e6f3ef]" : ""),
11669
+ children: [
11670
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("img", {
11671
+ src: opt.image,
11672
+ alt: opt.label,
11673
+ className: "w-[36px] h-[28px] rounded-[6px] object-cover"
11674
+ }),
11675
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11676
+ children: [
11677
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11678
+ className: "font-medium",
11679
+ children: opt.label
11680
+ }),
11681
+ opt.subtitle && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11682
+ className: "text-[12px] text-[#64748b]",
11683
+ children: opt.subtitle
11684
+ })
11685
+ ]
11686
+ })
11687
+ ]
11688
+ }, opt.value);
11689
+ })
11690
+ })
11691
+ })
11692
+ ]
11693
+ });
11694
+ }
11695
+ function AvatarMultiSelectDropdown(param) {
11696
+ var _param_label = param.label, label = _param_label === void 0 ? "Avatar Multi Select" : _param_label, _param_placeholder = param.placeholder, placeholder = _param_placeholder === void 0 ? "Select users" : _param_placeholder, options = param.options, values = param.values, testId = param.testId, onChange = param.onChange;
11697
+ var _ref = _sliced_to_array((0, import_react22.useState)(false), 2), open = _ref[0], setOpen = _ref[1];
11698
+ var ref = (0, import_react22.useRef)(null);
11699
+ (0, import_react22.useEffect)(function() {
11700
+ var handler = function handler(e) {
11701
+ if (ref.current && !ref.current.contains(e.target)) {
11702
+ setOpen(false);
11703
+ }
11704
+ };
11705
+ document.addEventListener("mousedown", handler);
11706
+ return function() {
11707
+ return document.removeEventListener("mousedown", handler);
11708
+ };
11709
+ }, []);
11710
+ var toggleValue = function toggleValue(value) {
11711
+ if (values.includes(value)) {
11712
+ onChange(values.filter(function(v) {
11713
+ return v !== value;
11714
+ }));
11715
+ } else {
11716
+ onChange(_to_consumable_array(values).concat([
11717
+ value
11718
+ ]));
11719
+ }
11720
+ };
11721
+ var removeValue = function removeValue(value) {
11722
+ onChange(values.filter(function(v) {
11723
+ return v !== value;
11724
+ }));
11725
+ };
11726
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11727
+ ref: ref,
11728
+ "data-testid": testId,
11729
+ className: "relative w-[320px] max-w-full mx-auto",
11730
+ children: [
11731
+ label && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("label", {
11732
+ className: "block mb-2 text-[12px] font-semibold text-[#1761a3]",
11733
+ children: label
11734
+ }),
11735
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("button", {
11736
+ onClick: function onClick() {
11737
+ return setOpen(function(o) {
11738
+ return !o;
11739
+ });
11740
+ },
11741
+ className: "w-full px-4 py-3 rounded-[8px] text-white font-semibold\r\n bg-gradient-to-r from-[#1761a3] to-[#4daf83]\r\n flex justify-between items-center",
11742
+ children: [
11743
+ placeholder,
11744
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react5.ChevronDown, {
11745
+ size: 16
11746
+ })
11747
+ ]
11748
+ }),
11749
+ values.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11750
+ className: "flex flex-wrap gap-2 mt-3",
11751
+ children: values.map(function(val) {
11752
+ var opt = options.find(function(o) {
11753
+ return o.value === val;
11754
+ });
11755
+ if (!opt) return null;
11756
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11757
+ className: "flex items-center gap-2 px-[10px] py-[6px]\r\n bg-white border border-[#cde3f1] rounded-[10px] text-[13px]",
11758
+ children: [
11759
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("img", {
11760
+ src: opt.image,
11761
+ alt: opt.label,
11762
+ className: "w-[24px] h-[24px] rounded-[6px] object-cover"
11763
+ }),
11764
+ opt.label,
11765
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react5.X, {
11766
+ size: 14,
11767
+ className: "cursor-pointer",
11768
+ onClick: function onClick() {
11769
+ return removeValue(val);
11770
+ }
11771
+ })
11772
+ ]
11773
+ }, val);
11774
+ })
11775
+ }),
11776
+ open && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11777
+ className: "absolute top-[calc(100%+8px)] left-0 w-full bg-white\r\n rounded-[12px] border border-[rgba(77,175,131,0.4)] z-[100]",
11778
+ children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11779
+ className: "max-h-[220px] overflow-y-auto",
11780
+ children: options.map(function(opt) {
11781
+ var active = values.includes(opt.value);
11782
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11783
+ onClick: function onClick() {
11784
+ return toggleValue(opt.value);
11785
+ },
11786
+ className: "px-4 py-[10px] text-[14px] cursor-pointer\n flex items-center gap-[12px]\n hover:bg-[#f1f5f9]\n ".concat(active ? "bg-[#e6f3ef]" : ""),
11787
+ children: [
11788
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", {
11789
+ type: "checkbox",
11790
+ checked: active,
11791
+ readOnly: true,
11792
+ className: "accent-[#1761a3]"
11793
+ }),
11794
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("img", {
11795
+ src: opt.image,
11796
+ alt: opt.label,
11797
+ className: "w-[36px] h-[28px] rounded-[6px] object-cover"
11798
+ }),
11799
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11800
+ children: [
11801
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11802
+ className: "font-medium",
11803
+ children: opt.label
11804
+ }),
11805
+ opt.subtitle && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11806
+ className: "text-[12px] text-[#64748b]",
11807
+ children: opt.subtitle
11808
+ })
11809
+ ]
11810
+ })
11811
+ ]
11812
+ }, opt.value);
11813
+ })
11814
+ })
11815
+ })
11816
+ ]
11817
+ });
11818
+ }
11819
+ function AsyncDropdown(param) {
11820
+ var _param_label = param.label, label = _param_label === void 0 ? "Async Dropdown" : _param_label, _param_placeholder = param.placeholder, placeholder = _param_placeholder === void 0 ? "Search..." : _param_placeholder, value = param.value, disabled = param.disabled, testId = param.testId, loadOptions = param.loadOptions, onChange = param.onChange;
11821
+ var _ref = _sliced_to_array((0, import_react22.useState)(false), 2), open = _ref[0], setOpen = _ref[1];
11822
+ var _ref1 = _sliced_to_array((0, import_react22.useState)(""), 2), search = _ref1[0], setSearch = _ref1[1];
11823
+ var _ref2 = _sliced_to_array((0, import_react22.useState)([]), 2), options = _ref2[0], setOptions = _ref2[1];
11824
+ var _ref3 = _sliced_to_array((0, import_react22.useState)(false), 2), loading = _ref3[0], setLoading = _ref3[1];
11825
+ var ref = (0, import_react22.useRef)(null);
11826
+ (0, import_react22.useEffect)(function() {
11827
+ var handler = function handler(e) {
11828
+ if (ref.current && !ref.current.contains(e.target)) {
11829
+ setOpen(false);
11830
+ }
11831
+ };
11832
+ document.addEventListener("mousedown", handler);
11833
+ return function() {
11834
+ return document.removeEventListener("mousedown", handler);
11835
+ };
11836
+ }, []);
11837
+ (0, import_react22.useEffect)(function() {
11838
+ if (!open) return;
11839
+ setLoading(true);
11840
+ loadOptions(search).then(setOptions).finally(function() {
11841
+ return setLoading(false);
11842
+ });
11843
+ }, [
11844
+ open,
11845
+ search,
11846
+ loadOptions
11847
+ ]);
11848
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11849
+ ref: ref,
11850
+ "data-testid": testId,
11851
+ className: "relative w-[320px] max-w-full mx-auto",
11852
+ children: [
11853
+ label && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("label", {
11854
+ className: "block mb-2 text-[12px] font-semibold text-[#1761a3]",
11855
+ children: label
11856
+ }),
11857
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("button", {
11858
+ disabled: disabled,
11859
+ onClick: function onClick() {
11860
+ return !disabled && setOpen(function(o) {
11861
+ return !o;
11862
+ });
11863
+ },
11864
+ className: "w-full px-4 py-3 rounded-[8px] text-white font-semibold\n bg-gradient-to-r from-[#1761a3] to-[#4daf83]\n flex justify-between items-center\n ".concat(disabled ? "opacity-60 cursor-not-allowed" : "cursor-pointer"),
11865
+ children: [
11866
+ value || placeholder,
11867
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react5.ChevronDown, {
11868
+ size: 16
11869
+ })
11870
+ ]
11871
+ }),
11872
+ open && !disabled && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11873
+ className: "absolute top-[calc(100%+8px)] left-0 w-full bg-white\r\n rounded-[12px] border border-[rgba(77,175,131,0.4)] z-[100]",
11874
+ children: [
11875
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11876
+ className: "p-3 border-b border-[#e5e7eb] relative",
11877
+ children: [
11878
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", {
11879
+ value: search,
11880
+ placeholder: "Search...",
11881
+ onChange: function onChange(e) {
11882
+ return setSearch(e.target.value);
11883
+ },
11884
+ className: "w-full h-[36px] px-3 pr-9 border rounded-[6px]\r\n border-[rgba(23,97,163,0.3)] outline-none"
11885
+ }),
11886
+ search && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", {
11887
+ onClick: function onClick() {
11888
+ return setSearch("");
11889
+ },
11890
+ className: "absolute right-[15px] top-1/2 -translate-y-1/2\r\n w-[22px] h-[22px] rounded-full bg-[#9ca3af] text-white",
11891
+ children: "\u2715"
11892
+ })
11893
+ ]
11894
+ }),
11895
+ loading && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11896
+ className: "px-4 py-[10px] text-[14px] flex items-center gap-2",
11897
+ children: [
11898
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react5.Loader2, {
11899
+ size: 14,
11900
+ className: "mr-2 animate-spin"
11901
+ }),
11902
+ "Loading..."
11903
+ ]
11904
+ }),
11905
+ !loading && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
11906
+ className: "max-h-[220px] overflow-y-auto",
11907
+ children: [
11908
+ options.map(function(opt) {
11909
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11910
+ onClick: function onClick() {
11911
+ onChange(opt.value);
11912
+ setOpen(false);
11913
+ setSearch("");
11914
+ },
11915
+ className: "px-4 py-[10px] text-[14px] cursor-pointer hover:bg-[#f1f5f9]",
11916
+ children: opt.label
11917
+ }, opt.value);
11918
+ }),
11919
+ options.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {
11920
+ className: "p-3 text-[#9ca3af]",
11921
+ children: "No results"
11922
+ })
11923
+ ]
11924
+ })
11925
+ ]
11926
+ })
11927
+ ]
11928
+ });
11929
+ }
11223
11930
  // src/components/TextToAudio.tsx
11224
11931
  var import_react23 = require("react");
11225
11932
  var import_jsx_runtime32 = require("react/jsx-runtime");
@@ -12586,18 +13293,24 @@ var MahatiNotificationCard = function MahatiNotificationCard(param) {
12586
13293
  LoadingDots: LoadingDots,
12587
13294
  LoadingDotsLinear: LoadingDotsLinear,
12588
13295
  MahatiActivity: MahatiActivity,
13296
+ MahatiAsyncDropdown: MahatiAsyncDropdown,
13297
+ MahatiAvatarDropdown: MahatiAvatarDropdown,
13298
+ MahatiAvatarMultiSelectDropdown: MahatiAvatarMultiSelectDropdown,
12589
13299
  MahatiButton: MahatiButton,
12590
13300
  MahatiCalendar: MahatiCalendar,
12591
13301
  MahatiCameraAccessModal: MahatiCameraAccessModal,
12592
13302
  MahatiCard: MahatiCard,
13303
+ MahatiCascadingDropdown: MahatiCascadingDropdown,
12593
13304
  MahatiChartAnalyticsWidget: MahatiChartAnalyticsWidget,
12594
13305
  MahatiConfettiExplosion: MahatiConfettiExplosion,
12595
13306
  MahatiDropdown: MahatiDropdown,
12596
13307
  MahatiFormContainer: MahatiFormContainer,
13308
+ MahatiGroupedDropdown: MahatiGroupedDropdown,
12597
13309
  MahatiInput: MahatiInput,
12598
13310
  MahatiLocationAccessModal: MahatiLocationAccessModal,
12599
13311
  MahatiMicrophoneAccessModal: MahatiMicrophoneAccessModal,
12600
13312
  MahatiModal: MahatiModal,
13313
+ MahatiMultiSelectDropdown: MahatiMultiSelectDropdown,
12601
13314
  MahatiNotificationCard: MahatiNotificationCard,
12602
13315
  MahatiPromotionModal_V1: MahatiPromotionModal_V1,
12603
13316
  MahatiPromotionModal_V2: MahatiPromotionModal_V2,