@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.mjs CHANGED
@@ -11046,6 +11046,695 @@ function SearchableDropdown(param) {
11046
11046
  ]
11047
11047
  });
11048
11048
  }
11049
+ function MultiSelectDropdown(param) {
11050
+ 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;
11051
+ var _useState16 = _sliced_to_array(useState16(false), 2), open = _useState16[0], setOpen = _useState16[1];
11052
+ var _useState161 = _sliced_to_array(useState16(""), 2), search = _useState161[0], setSearch = _useState161[1];
11053
+ var ref = useRef8(null);
11054
+ var removeValue = function removeValue(val) {
11055
+ onChange(values.filter(function(v) {
11056
+ return v !== val;
11057
+ }));
11058
+ };
11059
+ useEffect12(function() {
11060
+ var handler = function handler(e) {
11061
+ if (ref.current && !ref.current.contains(e.target)) {
11062
+ setOpen(false);
11063
+ }
11064
+ };
11065
+ document.addEventListener("mousedown", handler);
11066
+ return function() {
11067
+ return document.removeEventListener("mousedown", handler);
11068
+ };
11069
+ }, []);
11070
+ var toggleValue = function toggleValue(value) {
11071
+ if (values.includes(value)) {
11072
+ onChange(values.filter(function(v) {
11073
+ return v !== value;
11074
+ }));
11075
+ } else {
11076
+ onChange(_to_consumable_array(values).concat([
11077
+ value
11078
+ ]));
11079
+ }
11080
+ };
11081
+ var filteredOptions = options.filter(function(o) {
11082
+ return o.label.toLowerCase().includes(search.toLowerCase());
11083
+ });
11084
+ return /* @__PURE__ */ jsxs26("div", {
11085
+ ref: ref,
11086
+ "data-testid": testId,
11087
+ className: "relative w-[320px] max-w-full mx-auto",
11088
+ children: [
11089
+ /* @__PURE__ */ jsx31("label", {
11090
+ className: "block mb-2 text-[12px] font-semibold text-[#1761a3]",
11091
+ children: label
11092
+ }),
11093
+ /* @__PURE__ */ jsxs26("button", {
11094
+ onClick: function onClick() {
11095
+ return setOpen(!open);
11096
+ },
11097
+ 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",
11098
+ children: [
11099
+ values.length === 0 ? "Multi Select" : "Multi Select",
11100
+ /* @__PURE__ */ jsx31(ChevronDown4, {
11101
+ size: 16
11102
+ })
11103
+ ]
11104
+ }),
11105
+ values.length > 0 && /* @__PURE__ */ jsx31("div", {
11106
+ className: "flex flex-wrap gap-2 mt-3",
11107
+ children: values.map(function(val) {
11108
+ var _options_find;
11109
+ var lbl = (_options_find = options.find(function(o) {
11110
+ return o.value === val;
11111
+ })) === null || _options_find === void 0 ? void 0 : _options_find.label;
11112
+ return /* @__PURE__ */ jsxs26("div", {
11113
+ className: "flex items-center gap-[6px] px-[10px] py-[6px]\r\n bg-white border border-[#cde3f1] rounded-[10px] text-[13px]",
11114
+ children: [
11115
+ lbl,
11116
+ /* @__PURE__ */ jsx31(X3, {
11117
+ size: 14,
11118
+ className: "cursor-pointer",
11119
+ onClick: function onClick() {
11120
+ return removeValue(val);
11121
+ }
11122
+ })
11123
+ ]
11124
+ }, val);
11125
+ })
11126
+ }),
11127
+ open && /* @__PURE__ */ jsxs26("div", {
11128
+ 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]",
11129
+ children: [
11130
+ /* @__PURE__ */ jsxs26("div", {
11131
+ className: "p-3 border-b border-[#e5e7eb] relative",
11132
+ children: [
11133
+ /* @__PURE__ */ jsx31("input", {
11134
+ value: search,
11135
+ onChange: function onChange(e) {
11136
+ return setSearch(e.target.value);
11137
+ },
11138
+ placeholder: "Search...",
11139
+ className: "w-full h-[36px] px-3 pr-9 border rounded-[6px]\r\n border-[rgba(23,97,163,0.3)] outline-none"
11140
+ }),
11141
+ search && /* @__PURE__ */ jsx31("button", {
11142
+ onClick: function onClick() {
11143
+ return setSearch("");
11144
+ },
11145
+ className: "absolute right-[15px] top-1/2 -translate-y-1/2\r\n w-[22px] h-[22px] rounded-full bg-[#9ca3af] text-white",
11146
+ children: "\u2715"
11147
+ })
11148
+ ]
11149
+ }),
11150
+ /* @__PURE__ */ jsxs26("div", {
11151
+ className: "max-h-[220px] overflow-y-auto",
11152
+ children: [
11153
+ filteredOptions.map(function(opt) {
11154
+ return /* @__PURE__ */ jsxs26("div", {
11155
+ onClick: function onClick() {
11156
+ return toggleValue(opt.value);
11157
+ },
11158
+ 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]" : ""),
11159
+ children: [
11160
+ /* @__PURE__ */ jsx31("input", {
11161
+ type: "checkbox",
11162
+ checked: values.includes(opt.value),
11163
+ readOnly: true
11164
+ }),
11165
+ opt.label
11166
+ ]
11167
+ }, opt.value);
11168
+ }),
11169
+ filteredOptions.length === 0 && /* @__PURE__ */ jsx31("div", {
11170
+ className: "p-3 text-[#9ca3af]",
11171
+ children: "No results"
11172
+ })
11173
+ ]
11174
+ })
11175
+ ]
11176
+ })
11177
+ ]
11178
+ });
11179
+ }
11180
+ function CascadingDropdown(param) {
11181
+ 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;
11182
+ var _data_find, _level2_find;
11183
+ var _useState16 = _sliced_to_array(useState16(false), 2), open = _useState16[0], setOpen = _useState16[1];
11184
+ var ref = useRef8(null);
11185
+ useEffect12(function() {
11186
+ var handler = function handler(e) {
11187
+ if (ref.current && !ref.current.contains(e.target)) {
11188
+ setOpen(false);
11189
+ }
11190
+ };
11191
+ document.addEventListener("mousedown", handler);
11192
+ return function() {
11193
+ return document.removeEventListener("mousedown", handler);
11194
+ };
11195
+ }, []);
11196
+ var level1 = data;
11197
+ var level2 = ((_data_find = data.find(function(d) {
11198
+ return d.value === value.level1;
11199
+ })) === null || _data_find === void 0 ? void 0 : _data_find.children) || [];
11200
+ var level3 = ((_level2_find = level2.find(function(d) {
11201
+ return d.value === value.level2;
11202
+ })) === null || _level2_find === void 0 ? void 0 : _level2_find.children) || [];
11203
+ var displayText = value.level3 || value.level2 || value.level1 || "Select location";
11204
+ return /* @__PURE__ */ jsxs26("div", {
11205
+ ref: ref,
11206
+ "data-testid": testId,
11207
+ className: "relative w-[320px] max-w-full mx-auto",
11208
+ children: [
11209
+ /* @__PURE__ */ jsx31("label", {
11210
+ className: "block mb-2 text-[12px] font-semibold text-[#1761a3]",
11211
+ children: label
11212
+ }),
11213
+ /* @__PURE__ */ jsxs26("button", {
11214
+ onClick: function onClick() {
11215
+ return setOpen(function(o) {
11216
+ return !o;
11217
+ });
11218
+ },
11219
+ 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",
11220
+ children: [
11221
+ displayText,
11222
+ /* @__PURE__ */ jsx31(ChevronDown4, {
11223
+ size: 16
11224
+ })
11225
+ ]
11226
+ }),
11227
+ open && /* @__PURE__ */ jsxs26("div", {
11228
+ 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]",
11229
+ children: [
11230
+ /* @__PURE__ */ jsx31("div", {
11231
+ className: "max-h-[220px] overflow-y-auto",
11232
+ children: level1.map(function(opt) {
11233
+ return /* @__PURE__ */ jsx31("div", {
11234
+ onClick: function onClick() {
11235
+ return onChange({
11236
+ level1: opt.value
11237
+ });
11238
+ },
11239
+ className: "px-4 py-[10px] text-[14px] cursor-pointer\n hover:bg-[#f1f5f9] ".concat(value.level1 === opt.value ? "bg-[#e6f3ef]" : ""),
11240
+ children: opt.label
11241
+ }, opt.value);
11242
+ })
11243
+ }),
11244
+ level2.length > 0 && /* @__PURE__ */ jsx31("div", {
11245
+ className: "max-h-[220px] overflow-y-auto border-t border-[#e5e7eb]",
11246
+ children: level2.map(function(opt) {
11247
+ return /* @__PURE__ */ jsxs26("div", {
11248
+ onClick: function onClick() {
11249
+ return onChange({
11250
+ level1: value.level1,
11251
+ level2: opt.value
11252
+ });
11253
+ },
11254
+ className: "px-4 py-[10px] text-[14px] cursor-pointer\n hover:bg-[#f1f5f9] ".concat(value.level2 === opt.value ? "bg-[#e6f3ef]" : ""),
11255
+ children: [
11256
+ "\u2514 ",
11257
+ opt.label
11258
+ ]
11259
+ }, opt.value);
11260
+ })
11261
+ }),
11262
+ level3.length > 0 && /* @__PURE__ */ jsx31("div", {
11263
+ className: "max-h-[220px] overflow-y-auto border-t border-[#e5e7eb]",
11264
+ children: level3.map(function(opt) {
11265
+ return /* @__PURE__ */ jsxs26("div", {
11266
+ onClick: function onClick() {
11267
+ return onChange({
11268
+ level1: value.level1,
11269
+ level2: value.level2,
11270
+ level3: opt.value
11271
+ });
11272
+ },
11273
+ className: "px-4 py-[10px] text-[14px] cursor-pointer\n hover:bg-[#f1f5f9] ".concat(value.level3 === opt.value ? "bg-[#e6f3ef]" : ""),
11274
+ children: [
11275
+ "\u2514\u2500 ",
11276
+ opt.label
11277
+ ]
11278
+ }, opt.value);
11279
+ })
11280
+ })
11281
+ ]
11282
+ })
11283
+ ]
11284
+ });
11285
+ }
11286
+ function GroupedDropdown(param) {
11287
+ 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;
11288
+ var _useState16 = _sliced_to_array(useState16(false), 2), open = _useState16[0], setOpen = _useState16[1];
11289
+ var ref = useRef8(null);
11290
+ useEffect12(function() {
11291
+ var handler = function handler(e) {
11292
+ if (ref.current && !ref.current.contains(e.target)) {
11293
+ setOpen(false);
11294
+ }
11295
+ };
11296
+ document.addEventListener("mousedown", handler);
11297
+ return function() {
11298
+ return document.removeEventListener("mousedown", handler);
11299
+ };
11300
+ }, []);
11301
+ var isSectionSelected = function isSectionSelected(group) {
11302
+ return (values === null || values === void 0 ? void 0 : values.section) === group.label;
11303
+ };
11304
+ var isChildChecked = function isChildChecked(value) {
11305
+ var _ref;
11306
+ return (_ref = values === null || values === void 0 ? void 0 : values.values.includes(value)) !== null && _ref !== void 0 ? _ref : false;
11307
+ };
11308
+ var toggleSection = function toggleSection(group) {
11309
+ if ((values === null || values === void 0 ? void 0 : values.section) === group.label) {
11310
+ onChange(null);
11311
+ } else {
11312
+ onChange({
11313
+ section: group.label,
11314
+ values: group.options.map(function(o) {
11315
+ return o.value;
11316
+ })
11317
+ });
11318
+ }
11319
+ };
11320
+ var toggleChild = function toggleChild(group, value) {
11321
+ if ((values === null || values === void 0 ? void 0 : values.section) !== group.label) {
11322
+ onChange({
11323
+ section: group.label,
11324
+ values: [
11325
+ value
11326
+ ]
11327
+ });
11328
+ return;
11329
+ }
11330
+ var exists = values.values.includes(value);
11331
+ var newValues = exists ? values.values.filter(function(v) {
11332
+ return v !== value;
11333
+ }) : _to_consumable_array(values.values).concat([
11334
+ value
11335
+ ]);
11336
+ onChange(newValues.length === 0 ? null : {
11337
+ section: group.label,
11338
+ values: newValues
11339
+ });
11340
+ };
11341
+ var displayValue = !values ? "Select options" : "".concat(values.section, " (").concat(values.values.map(function(v) {
11342
+ var _groups_flatMap_find;
11343
+ return (_groups_flatMap_find = groups.flatMap(function(g) {
11344
+ return g.options;
11345
+ }).find(function(o) {
11346
+ return o.value === v;
11347
+ })) === null || _groups_flatMap_find === void 0 ? void 0 : _groups_flatMap_find.label;
11348
+ }).join(", "), ")");
11349
+ return /* @__PURE__ */ jsxs26("div", {
11350
+ ref: ref,
11351
+ "data-testid": testId,
11352
+ className: "relative w-[320px] max-w-full mx-auto",
11353
+ children: [
11354
+ label && /* @__PURE__ */ jsx31("label", {
11355
+ className: "block mb-2 text-[12px] font-semibold text-[#1761a3]",
11356
+ children: label
11357
+ }),
11358
+ /* @__PURE__ */ jsxs26("button", {
11359
+ onClick: function onClick() {
11360
+ return setOpen(function(o) {
11361
+ return !o;
11362
+ });
11363
+ },
11364
+ 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",
11365
+ children: [
11366
+ displayValue,
11367
+ /* @__PURE__ */ jsx31(ChevronDown4, {
11368
+ size: 16
11369
+ })
11370
+ ]
11371
+ }),
11372
+ open && /* @__PURE__ */ jsx31("div", {
11373
+ 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]",
11374
+ children: groups.map(function(group) {
11375
+ return /* @__PURE__ */ jsxs26("div", {
11376
+ className: "p-3",
11377
+ children: [
11378
+ /* @__PURE__ */ jsxs26("div", {
11379
+ className: "flex items-center gap-2 font-semibold",
11380
+ children: [
11381
+ /* @__PURE__ */ jsx31("input", {
11382
+ type: "checkbox",
11383
+ checked: isSectionSelected(group),
11384
+ onChange: function onChange() {
11385
+ return toggleSection(group);
11386
+ }
11387
+ }),
11388
+ group.label
11389
+ ]
11390
+ }),
11391
+ group.options.map(function(opt) {
11392
+ return /* @__PURE__ */ jsxs26("label", {
11393
+ className: "flex items-center gap-2 text-[14px] mt-[6px] ml-[22px]",
11394
+ children: [
11395
+ /* @__PURE__ */ jsx31("input", {
11396
+ type: "checkbox",
11397
+ checked: isChildChecked(opt.value),
11398
+ onChange: function onChange() {
11399
+ return toggleChild(group, opt.value);
11400
+ }
11401
+ }),
11402
+ opt.label
11403
+ ]
11404
+ }, opt.value);
11405
+ })
11406
+ ]
11407
+ }, group.label);
11408
+ })
11409
+ })
11410
+ ]
11411
+ });
11412
+ }
11413
+ function AvatarDropdown(param) {
11414
+ 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;
11415
+ var _useState16 = _sliced_to_array(useState16(false), 2), open = _useState16[0], setOpen = _useState16[1];
11416
+ var ref = useRef8(null);
11417
+ useEffect12(function() {
11418
+ var handler = function handler(e) {
11419
+ if (ref.current && !ref.current.contains(e.target)) {
11420
+ setOpen(false);
11421
+ }
11422
+ };
11423
+ document.addEventListener("mousedown", handler);
11424
+ return function() {
11425
+ return document.removeEventListener("mousedown", handler);
11426
+ };
11427
+ }, []);
11428
+ var selected = options.find(function(o) {
11429
+ return o.value === value;
11430
+ });
11431
+ return /* @__PURE__ */ jsxs26("div", {
11432
+ ref: ref,
11433
+ "data-testid": testId,
11434
+ className: "relative w-[320px] max-w-full mx-auto",
11435
+ children: [
11436
+ label && /* @__PURE__ */ jsx31("label", {
11437
+ className: "block mb-2 text-[12px] font-semibold text-[#1761a3]",
11438
+ children: label
11439
+ }),
11440
+ /* @__PURE__ */ jsxs26("button", {
11441
+ onClick: function onClick() {
11442
+ return setOpen(function(o) {
11443
+ return !o;
11444
+ });
11445
+ },
11446
+ 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",
11447
+ children: [
11448
+ /* @__PURE__ */ jsx31("span", {
11449
+ className: "flex items-center gap-[10px]",
11450
+ children: selected ? /* @__PURE__ */ jsxs26(Fragment11, {
11451
+ children: [
11452
+ /* @__PURE__ */ jsx31("img", {
11453
+ src: selected.image,
11454
+ alt: selected.label,
11455
+ className: "w-[28px] h-[28px] rounded-[6px] object-cover"
11456
+ }),
11457
+ selected.label
11458
+ ]
11459
+ }) : placeholder
11460
+ }),
11461
+ /* @__PURE__ */ jsx31(ChevronDown4, {
11462
+ size: 16
11463
+ })
11464
+ ]
11465
+ }),
11466
+ open && /* @__PURE__ */ jsx31("div", {
11467
+ 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]",
11468
+ children: /* @__PURE__ */ jsx31("div", {
11469
+ className: "max-h-[220px] overflow-y-auto",
11470
+ children: options.map(function(opt) {
11471
+ return /* @__PURE__ */ jsxs26("div", {
11472
+ onClick: function onClick() {
11473
+ onChange(opt.value);
11474
+ setOpen(false);
11475
+ },
11476
+ 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]" : ""),
11477
+ children: [
11478
+ /* @__PURE__ */ jsx31("img", {
11479
+ src: opt.image,
11480
+ alt: opt.label,
11481
+ className: "w-[36px] h-[28px] rounded-[6px] object-cover"
11482
+ }),
11483
+ /* @__PURE__ */ jsxs26("div", {
11484
+ children: [
11485
+ /* @__PURE__ */ jsx31("div", {
11486
+ className: "font-medium",
11487
+ children: opt.label
11488
+ }),
11489
+ opt.subtitle && /* @__PURE__ */ jsx31("div", {
11490
+ className: "text-[12px] text-[#64748b]",
11491
+ children: opt.subtitle
11492
+ })
11493
+ ]
11494
+ })
11495
+ ]
11496
+ }, opt.value);
11497
+ })
11498
+ })
11499
+ })
11500
+ ]
11501
+ });
11502
+ }
11503
+ function AvatarMultiSelectDropdown(param) {
11504
+ 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;
11505
+ var _useState16 = _sliced_to_array(useState16(false), 2), open = _useState16[0], setOpen = _useState16[1];
11506
+ var ref = useRef8(null);
11507
+ useEffect12(function() {
11508
+ var handler = function handler(e) {
11509
+ if (ref.current && !ref.current.contains(e.target)) {
11510
+ setOpen(false);
11511
+ }
11512
+ };
11513
+ document.addEventListener("mousedown", handler);
11514
+ return function() {
11515
+ return document.removeEventListener("mousedown", handler);
11516
+ };
11517
+ }, []);
11518
+ var toggleValue = function toggleValue(value) {
11519
+ if (values.includes(value)) {
11520
+ onChange(values.filter(function(v) {
11521
+ return v !== value;
11522
+ }));
11523
+ } else {
11524
+ onChange(_to_consumable_array(values).concat([
11525
+ value
11526
+ ]));
11527
+ }
11528
+ };
11529
+ var removeValue = function removeValue(value) {
11530
+ onChange(values.filter(function(v) {
11531
+ return v !== value;
11532
+ }));
11533
+ };
11534
+ return /* @__PURE__ */ jsxs26("div", {
11535
+ ref: ref,
11536
+ "data-testid": testId,
11537
+ className: "relative w-[320px] max-w-full mx-auto",
11538
+ children: [
11539
+ label && /* @__PURE__ */ jsx31("label", {
11540
+ className: "block mb-2 text-[12px] font-semibold text-[#1761a3]",
11541
+ children: label
11542
+ }),
11543
+ /* @__PURE__ */ jsxs26("button", {
11544
+ onClick: function onClick() {
11545
+ return setOpen(function(o) {
11546
+ return !o;
11547
+ });
11548
+ },
11549
+ 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",
11550
+ children: [
11551
+ placeholder,
11552
+ /* @__PURE__ */ jsx31(ChevronDown4, {
11553
+ size: 16
11554
+ })
11555
+ ]
11556
+ }),
11557
+ values.length > 0 && /* @__PURE__ */ jsx31("div", {
11558
+ className: "flex flex-wrap gap-2 mt-3",
11559
+ children: values.map(function(val) {
11560
+ var opt = options.find(function(o) {
11561
+ return o.value === val;
11562
+ });
11563
+ if (!opt) return null;
11564
+ return /* @__PURE__ */ jsxs26("div", {
11565
+ className: "flex items-center gap-2 px-[10px] py-[6px]\r\n bg-white border border-[#cde3f1] rounded-[10px] text-[13px]",
11566
+ children: [
11567
+ /* @__PURE__ */ jsx31("img", {
11568
+ src: opt.image,
11569
+ alt: opt.label,
11570
+ className: "w-[24px] h-[24px] rounded-[6px] object-cover"
11571
+ }),
11572
+ opt.label,
11573
+ /* @__PURE__ */ jsx31(X3, {
11574
+ size: 14,
11575
+ className: "cursor-pointer",
11576
+ onClick: function onClick() {
11577
+ return removeValue(val);
11578
+ }
11579
+ })
11580
+ ]
11581
+ }, val);
11582
+ })
11583
+ }),
11584
+ open && /* @__PURE__ */ jsx31("div", {
11585
+ 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]",
11586
+ children: /* @__PURE__ */ jsx31("div", {
11587
+ className: "max-h-[220px] overflow-y-auto",
11588
+ children: options.map(function(opt) {
11589
+ var active = values.includes(opt.value);
11590
+ return /* @__PURE__ */ jsxs26("div", {
11591
+ onClick: function onClick() {
11592
+ return toggleValue(opt.value);
11593
+ },
11594
+ className: "px-4 py-[10px] text-[14px] cursor-pointer\n flex items-center gap-[12px]\n hover:bg-[#f1f5f9]\n ".concat(active ? "bg-[#e6f3ef]" : ""),
11595
+ children: [
11596
+ /* @__PURE__ */ jsx31("input", {
11597
+ type: "checkbox",
11598
+ checked: active,
11599
+ readOnly: true,
11600
+ className: "accent-[#1761a3]"
11601
+ }),
11602
+ /* @__PURE__ */ jsx31("img", {
11603
+ src: opt.image,
11604
+ alt: opt.label,
11605
+ className: "w-[36px] h-[28px] rounded-[6px] object-cover"
11606
+ }),
11607
+ /* @__PURE__ */ jsxs26("div", {
11608
+ children: [
11609
+ /* @__PURE__ */ jsx31("div", {
11610
+ className: "font-medium",
11611
+ children: opt.label
11612
+ }),
11613
+ opt.subtitle && /* @__PURE__ */ jsx31("div", {
11614
+ className: "text-[12px] text-[#64748b]",
11615
+ children: opt.subtitle
11616
+ })
11617
+ ]
11618
+ })
11619
+ ]
11620
+ }, opt.value);
11621
+ })
11622
+ })
11623
+ })
11624
+ ]
11625
+ });
11626
+ }
11627
+ function AsyncDropdown(param) {
11628
+ 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;
11629
+ var _useState16 = _sliced_to_array(useState16(false), 2), open = _useState16[0], setOpen = _useState16[1];
11630
+ var _useState161 = _sliced_to_array(useState16(""), 2), search = _useState161[0], setSearch = _useState161[1];
11631
+ var _useState162 = _sliced_to_array(useState16([]), 2), options = _useState162[0], setOptions = _useState162[1];
11632
+ var _useState163 = _sliced_to_array(useState16(false), 2), loading = _useState163[0], setLoading = _useState163[1];
11633
+ var ref = useRef8(null);
11634
+ useEffect12(function() {
11635
+ var handler = function handler(e) {
11636
+ if (ref.current && !ref.current.contains(e.target)) {
11637
+ setOpen(false);
11638
+ }
11639
+ };
11640
+ document.addEventListener("mousedown", handler);
11641
+ return function() {
11642
+ return document.removeEventListener("mousedown", handler);
11643
+ };
11644
+ }, []);
11645
+ useEffect12(function() {
11646
+ if (!open) return;
11647
+ setLoading(true);
11648
+ loadOptions(search).then(setOptions).finally(function() {
11649
+ return setLoading(false);
11650
+ });
11651
+ }, [
11652
+ open,
11653
+ search,
11654
+ loadOptions
11655
+ ]);
11656
+ return /* @__PURE__ */ jsxs26("div", {
11657
+ ref: ref,
11658
+ "data-testid": testId,
11659
+ className: "relative w-[320px] max-w-full mx-auto",
11660
+ children: [
11661
+ label && /* @__PURE__ */ jsx31("label", {
11662
+ className: "block mb-2 text-[12px] font-semibold text-[#1761a3]",
11663
+ children: label
11664
+ }),
11665
+ /* @__PURE__ */ jsxs26("button", {
11666
+ disabled: disabled,
11667
+ onClick: function onClick() {
11668
+ return !disabled && setOpen(function(o) {
11669
+ return !o;
11670
+ });
11671
+ },
11672
+ 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"),
11673
+ children: [
11674
+ value || placeholder,
11675
+ /* @__PURE__ */ jsx31(ChevronDown4, {
11676
+ size: 16
11677
+ })
11678
+ ]
11679
+ }),
11680
+ open && !disabled && /* @__PURE__ */ jsxs26("div", {
11681
+ 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]",
11682
+ children: [
11683
+ /* @__PURE__ */ jsxs26("div", {
11684
+ className: "p-3 border-b border-[#e5e7eb] relative",
11685
+ children: [
11686
+ /* @__PURE__ */ jsx31("input", {
11687
+ value: search,
11688
+ placeholder: "Search...",
11689
+ onChange: function onChange(e) {
11690
+ return setSearch(e.target.value);
11691
+ },
11692
+ className: "w-full h-[36px] px-3 pr-9 border rounded-[6px]\r\n border-[rgba(23,97,163,0.3)] outline-none"
11693
+ }),
11694
+ search && /* @__PURE__ */ jsx31("button", {
11695
+ onClick: function onClick() {
11696
+ return setSearch("");
11697
+ },
11698
+ className: "absolute right-[15px] top-1/2 -translate-y-1/2\r\n w-[22px] h-[22px] rounded-full bg-[#9ca3af] text-white",
11699
+ children: "\u2715"
11700
+ })
11701
+ ]
11702
+ }),
11703
+ loading && /* @__PURE__ */ jsxs26("div", {
11704
+ className: "px-4 py-[10px] text-[14px] flex items-center gap-2",
11705
+ children: [
11706
+ /* @__PURE__ */ jsx31(Loader2, {
11707
+ size: 14,
11708
+ className: "mr-2 animate-spin"
11709
+ }),
11710
+ "Loading..."
11711
+ ]
11712
+ }),
11713
+ !loading && /* @__PURE__ */ jsxs26("div", {
11714
+ className: "max-h-[220px] overflow-y-auto",
11715
+ children: [
11716
+ options.map(function(opt) {
11717
+ return /* @__PURE__ */ jsx31("div", {
11718
+ onClick: function onClick() {
11719
+ onChange(opt.value);
11720
+ setOpen(false);
11721
+ setSearch("");
11722
+ },
11723
+ className: "px-4 py-[10px] text-[14px] cursor-pointer hover:bg-[#f1f5f9]",
11724
+ children: opt.label
11725
+ }, opt.value);
11726
+ }),
11727
+ options.length === 0 && /* @__PURE__ */ jsx31("div", {
11728
+ className: "p-3 text-[#9ca3af]",
11729
+ children: "No results"
11730
+ })
11731
+ ]
11732
+ })
11733
+ ]
11734
+ })
11735
+ ]
11736
+ });
11737
+ }
11049
11738
  // src/components/TextToAudio.tsx
11050
11739
  import { useEffect as useEffect13, useRef as useRef9, useState as useState17 } from "react";
11051
11740
  import { jsx as jsx32, jsxs as jsxs27 } from "react/jsx-runtime";
@@ -12400,5 +13089,5 @@ var MahatiNotificationCard = function MahatiNotificationCard(param) {
12400
13089
  ]
12401
13090
  });
12402
13091
  };
12403
- export { Accordion, CardOverlayLoader, CardWithLoading, CircularSpinner, DEFAULT_ACTIVITY_OPTIONS, DEFAULT_STATUS_OPTIONS, Filter, LoadingDots, LoadingDotsLinear, MahatiActivity, Button as MahatiButton, Calendar as MahatiCalendar, MahatiCameraAccessModal, Card as MahatiCard, MahatiChartAnalyticsWidget, ConfettiExplosion as MahatiConfettiExplosion, Dropdown as MahatiDropdown, FormContainer as MahatiFormContainer, Input as MahatiInput, MahatiLocationAccessModal, MahatiMicrophoneAccessModal, Modal as MahatiModal, MahatiNotificationCard, MahatiPromotionModal as MahatiPromotionModal_V1, MahatiPromotionModalV2Modal as MahatiPromotionModal_V2, MahatiPromotionModalV3Modal as MahatiPromotionModal_V3, RealisticConfetti as MahatiRealisticConfetti, MahatiSearch, SearchableDropdown as MahatiSearchableDropdown, MahatiStatus, TabbedInterface as MahatiTabbedInterface, Table as MahatiTable, TableWithTab as MahatiTableWithTab, TexttoAudio as MahatiTexttoAudio, ToastMessage as MahatiToastMessage, Tooltip2 as MahatiTooltip, Spinner };
13092
+ export { Accordion, CardOverlayLoader, CardWithLoading, CircularSpinner, DEFAULT_ACTIVITY_OPTIONS, DEFAULT_STATUS_OPTIONS, Filter, LoadingDots, LoadingDotsLinear, MahatiActivity, AsyncDropdown as MahatiAsyncDropdown, AvatarDropdown as MahatiAvatarDropdown, AvatarMultiSelectDropdown as MahatiAvatarMultiSelectDropdown, Button as MahatiButton, Calendar as MahatiCalendar, MahatiCameraAccessModal, Card as MahatiCard, CascadingDropdown as MahatiCascadingDropdown, MahatiChartAnalyticsWidget, ConfettiExplosion as MahatiConfettiExplosion, Dropdown as MahatiDropdown, FormContainer as MahatiFormContainer, GroupedDropdown as MahatiGroupedDropdown, Input as MahatiInput, MahatiLocationAccessModal, MahatiMicrophoneAccessModal, Modal as MahatiModal, MultiSelectDropdown as MahatiMultiSelectDropdown, MahatiNotificationCard, MahatiPromotionModal as MahatiPromotionModal_V1, MahatiPromotionModalV2Modal as MahatiPromotionModal_V2, MahatiPromotionModalV3Modal as MahatiPromotionModal_V3, RealisticConfetti as MahatiRealisticConfetti, MahatiSearch, SearchableDropdown as MahatiSearchableDropdown, MahatiStatus, TabbedInterface as MahatiTabbedInterface, Table as MahatiTable, TableWithTab as MahatiTableWithTab, TexttoAudio as MahatiTexttoAudio, ToastMessage as MahatiToastMessage, Tooltip2 as MahatiTooltip, Spinner };
12404
13093
  //# sourceMappingURL=index.mjs.map