@jars-labs/jars-components 1.0.10 → 1.0.11

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.
@@ -160,7 +160,7 @@ var Animation = function (_a) {
160
160
  var refVector = useRef(null);
161
161
  var _b = useState(null), lottie = _b[0], setLottie = _b[1];
162
162
  useEffect(function () {
163
- import('./lottie-CMIUDj7j.js').then(function (n) { return n.l; }).then(function (Lottie) { return setLottie(Lottie.default); });
163
+ import('./lottie-BBj9Bhzx.js').then(function (n) { return n.l; }).then(function (Lottie) { return setLottie(Lottie.default); });
164
164
  }, []);
165
165
  useEffect(function () {
166
166
  if (lottie && refVector.current) {
@@ -1031,8 +1031,8 @@ var Umbrello = function (props) {
1031
1031
  };
1032
1032
 
1033
1033
  var NavBar = function (_a) {
1034
- var children = _a.children;
1035
- return (jsxs(Flex, { p: "24px 120px", bg: "var(--color-white)", align: "center", justify: "space-between", children: [jsx("a", { href: "/dashboard/management-companies", children: jsx(Umbrello, { fill: "var(--color-neutral-600)", width: "200", height: "40", viewBox: "0 0 200 40" }) }), children] }));
1034
+ var children = _a.children, logo = _a.logo, homePath = _a.homePath, rest = __rest(_a, ["children", "logo", "homePath"]);
1035
+ return (jsxs(Flex, __assign({ p: "24px 120px", bg: "var(--color-white)", align: "center", justify: "space-between", component: "nav" }, rest, { children: [jsx("a", { href: homePath || '/', children: logo || (jsx(Umbrello, { fill: "var(--color-neutral-600)", width: "200", height: "40", viewBox: "0 0 200 40" })) }), children] })));
1036
1036
  };
1037
1037
 
1038
1038
  var Pagination = function (_a) {
@@ -1293,7 +1293,7 @@ var Tooltip = function (_a) {
1293
1293
  }, offset: 4, children: children })));
1294
1294
  };
1295
1295
 
1296
- var multiselectStyles = {"input":"Multiselect-module_input__lwmrJ","disabled":"Multiselect-module_disabled__DyqLt","pill":"Multiselect-module_pill__NwXcT"};
1296
+ var multiselectStyles = {"input":"Multiselect-module_input__lwmrJ","inputFocused":"Multiselect-module_inputFocused__rm-OP","disabled":"Multiselect-module_disabled__DyqLt","pill":"Multiselect-module_pill__NwXcT"};
1297
1297
 
1298
1298
  /**
1299
1299
  * MultiSelect component, use it to select multiple options from a list of options
@@ -1305,99 +1305,160 @@ var multiselectStyles = {"input":"Multiselect-module_input__lwmrJ","disabled":"M
1305
1305
  * @param {string} placeholder - The placeholder of the select
1306
1306
  * @param {string} error - The error message to display
1307
1307
  * @param {string} description - The description to display
1308
+ * @param {boolean} disabled - Whether the select is disabled
1309
+ * @param {number} maxPills - The maximum number of pills to display, the rest will be displayed as a single pill with the number of remaining items
1308
1310
  *
1309
1311
  * @returns {React.ReactElement} The MultiSelect component
1310
1312
  *
1311
1313
  */
1312
1314
  var Multiselect = function (_a) {
1313
- var data = _a.data, onApply = _a.onApply, error = _a.error, description = _a.description, label = _a.label, placeholder = _a.placeholder, onBlur = _a.onBlur, _b = _a.disabled, disabled = _b === undefined ? false : _b;
1315
+ var data = _a.data, onApply = _a.onApply, error = _a.error, description = _a.description, label = _a.label, placeholder = _a.placeholder, onBlur = _a.onBlur, _b = _a.disabled, disabled = _b === undefined ? false : _b, _c = _a.maxPills, maxPills = _c === undefined ? 3 : _c;
1314
1316
  var dataKey = useMemo(function () { return data.map(function (o) { return o.value; }).join('_'); }, [data]);
1315
- return (jsx(MultiselectInternal, { data: data, onApply: onApply, error: error, description: description, label: label, placeholder: placeholder, onBlur: onBlur, disabled: disabled }, dataKey));
1317
+ return (jsx(MultiselectInternal, { data: data, onApply: onApply, error: error, description: description, label: label, placeholder: placeholder, onBlur: onBlur, disabled: disabled, maxPills: maxPills }, dataKey));
1316
1318
  };
1317
1319
  /**
1318
- * Private component that holds the local state (`temporaryOptions`)
1320
+ * The internal component that maintains:
1321
+ * - committedOptions (pills shown when dropdown is closed)
1322
+ * - temporaryOptions (draft selection while dropdown is open)
1323
+ * - searchTerm (to filter the dropdown’s list)
1319
1324
  */
1320
1325
  var MultiselectInternal = function (_a) {
1321
- var data = _a.data, onApply = _a.onApply, error = _a.error, description = _a.description, label = _a.label, placeholder = _a.placeholder, onBlur = _a.onBlur, disabled = _a.disabled;
1322
- var _b = useState(data), temporaryOptions = _b[0], setTemporaryOptions = _b[1];
1323
- var _c = useState(false), isFocused = _c[0], setIsFocused = _c[1];
1324
- var _d = useState(false), isHovered = _d[0], setIsHovered = _d[1];
1325
- var hasSelectedOptions = temporaryOptions.some(function (option) { return option.selected; });
1326
- // Handlers
1327
- var handleOptionClick = function (option) {
1328
- var newOptions = temporaryOptions.map(function (selectedOption) {
1329
- if (selectedOption.value === option.value) {
1330
- return __assign(__assign({}, selectedOption), { selected: !selectedOption.selected });
1331
- }
1332
- return selectedOption;
1326
+ var data = _a.data, onApply = _a.onApply, error = _a.error, description = _a.description, label = _a.label, placeholder = _a.placeholder, onBlur = _a.onBlur, disabled = _a.disabled, maxPills = _a.maxPills;
1327
+ // Final selection that shows up as pills when closed / after Apply
1328
+ var _b = useState(data), committedOptions = _b[0], setCommittedOptions = _b[1];
1329
+ // Draft selection while dropdown is open
1330
+ var _c = useState(data), temporaryOptions = _c[0], setTemporaryOptions = _c[1];
1331
+ var _d = useState(''), searchTerm = _d[0], setSearchTerm = _d[1];
1332
+ var _e = useState(false), isFocused = _e[0], setIsFocused = _e[1];
1333
+ var _f = useState(false), isHovered = _f[0], setIsHovered = _f[1];
1334
+ var hasSelectedOptions = committedOptions.some(function (opt) { return opt.selected; });
1335
+ /* -----------------------------------
1336
+ * Handlers
1337
+ * ----------------------------------- */
1338
+ var handleBlur = function () {
1339
+ setIsFocused(false);
1340
+ onBlur === null || onBlur === undefined ? undefined : onBlur();
1341
+ };
1342
+ /** Toggle a checkbox in the *draft* list */
1343
+ var handleDraftToggle = function (option) {
1344
+ setTemporaryOptions(function (prev) {
1345
+ return prev.map(function (o) {
1346
+ return o.value === option.value ? __assign(__assign({}, o), { selected: !o.selected }) : o;
1347
+ });
1333
1348
  });
1334
- setTemporaryOptions(newOptions);
1335
1349
  };
1350
+ /** Click "Apply" => copy draft to pills (committed) and call onApply */
1336
1351
  var handleApply = function (closeDropdown) {
1352
+ setCommittedOptions(temporaryOptions);
1337
1353
  onApply(temporaryOptions);
1338
1354
  closeDropdown();
1339
1355
  };
1356
+ /** Click "Clear" => reset the *draft* selection (not pills yet) */
1340
1357
  var handleClear = function () {
1341
- var newOptions = data.map(function (option) { return (__assign(__assign({}, option), { selected: false })); });
1342
- setTemporaryOptions(newOptions);
1358
+ var reset = data.map(function (o) { return (__assign(__assign({}, o), { selected: false })); });
1359
+ setTemporaryOptions(reset);
1343
1360
  };
1344
- var handleBlur = function () {
1345
- setIsFocused(false);
1346
- if (onBlur) {
1347
- onBlur();
1348
- }
1349
- };
1350
- var handleDeselect = function (optionId) {
1351
- var newOptions = temporaryOptions.map(function (option) {
1352
- if (option.value === optionId) {
1353
- return __assign(__assign({}, option), { selected: false });
1354
- }
1355
- return option;
1361
+ /** Clicking the "X" on a pill => remove from *committed* immediately */
1362
+ var handleDeselectPill = function (optionId) {
1363
+ var newCommitted = committedOptions.map(function (o) {
1364
+ return o.value === optionId ? __assign(__assign({}, o), { selected: false }) : o;
1356
1365
  });
1357
- setTemporaryOptions(newOptions);
1358
- onApply(newOptions);
1366
+ setCommittedOptions(newCommitted);
1367
+ setTemporaryOptions(newCommitted);
1368
+ onApply(newCommitted);
1359
1369
  };
1360
- // Sections
1361
- var PillListSection = function (_a) {
1362
- var store = _a.store;
1363
- var selected = temporaryOptions.filter(function (option) { return option.selected; });
1364
- return (jsx("div", { style: {
1365
- display: 'flex',
1366
- flexGrow: 1,
1367
- gap: 8,
1368
- alignItems: 'center',
1369
- }, children: selected.length === 0 ? (jsx(Text, { variant: "s", children: store.dropdownOpened ? placeholder : label })) : (jsxs(Flex, { gap: 8, align: "center", wrap: "wrap", children: [selected.slice(0, 3).map(function (option) { return (jsxs("span", { className: multiselectStyles.pill, onClick: function (e) {
1370
- handleOptionClick(option);
1371
- e.stopPropagation();
1372
- }, children: [jsx(Text, { variant: "xs", children: option.label }), jsx(ActionIcon$1, { variant: "transparent", onClick: function (e) {
1373
- handleDeselect(option.value);
1374
- e.stopPropagation();
1375
- }, children: jsx(Close, { height: "20px", width: "20px" }) })] }, option.value)); }), selected.length > 3 && (jsx(Tooltip, { label: selected
1376
- .slice(3)
1377
- .map(function (option) { return option.label; })
1378
- .join(', '), children: jsx("span", { className: multiselectStyles.pill, children: jsxs(Text, { variant: "xs", children: ["+ ", selected.length - 3] }) }, selected.length) }))] })) }));
1370
+ /* -----------------------------------
1371
+ * Search / Filtering
1372
+ * ----------------------------------- */
1373
+ var filteredTempOptions = useMemo(function () {
1374
+ if (!searchTerm.trim())
1375
+ return temporaryOptions;
1376
+ return temporaryOptions.filter(function (o) {
1377
+ return o.label.toLowerCase().includes(searchTerm.toLowerCase());
1378
+ });
1379
+ }, [searchTerm, temporaryOptions]);
1380
+ // Build the actual dropdown checkboxes from the filtered list
1381
+ var dropdownOptions = useMemo(function () {
1382
+ var allSelected = filteredTempOptions.length > 0 &&
1383
+ filteredTempOptions.every(function (o) { return o.selected; });
1384
+ var selectAllOption = (jsx(Dropdown.Option, { value: "select_all", py: 12, onClick: function (e) { return e.stopPropagation(); }, children: jsx(Checkbox, { label: "Select All", checked: allSelected, onChange: function (e) {
1385
+ e.stopPropagation();
1386
+ setTemporaryOptions(function (prev) {
1387
+ return prev.map(function (item) { return (__assign(__assign({}, item), { selected: !allSelected })); });
1388
+ });
1389
+ }, w: "100%" }) }, "select_all"));
1390
+ // Now build the rest of the normal checkboxes
1391
+ var normalOptions = filteredTempOptions.map(function (option) { return (jsx(Dropdown.Option, { value: option.value, py: 12, disabled: option.disabled,
1392
+ // Don’t close on click
1393
+ onClick: function (e) { return e.stopPropagation(); }, children: jsx(Checkbox, { label: option.label, checked: option.selected, disabled: option.disabled, onChange: function (e) {
1394
+ e.stopPropagation();
1395
+ handleDraftToggle(option);
1396
+ }, w: "100%" }, option.value) }, option.value)); });
1397
+ var emptyOptions = (jsx(Dropdown.Option, { value: "No options found", style: { cursor: 'not-allowed', pointerEvents: 'none' }, children: "No matches found, try something else." }));
1398
+ return normalOptions.length > 0
1399
+ ? __spreadArray([selectAllOption], normalOptions, true) : [emptyOptions];
1400
+ }, [filteredTempOptions]);
1401
+ /* -----------------------------------
1402
+ * Sections
1403
+ * ----------------------------------- */
1404
+ /**
1405
+ * The main "input" area, showing:
1406
+ * - Pills (from committedOptions) if the dropdown is closed (or open),
1407
+ * but we specifically adjust layout if open.
1408
+ * - If the dropdown is open, also show a search input alongside the pills.
1409
+ */
1410
+ var PillAndSearchSection = function (_a) {
1411
+ var store = _a.store, _b = _a.maxPills, maxPills = _b === undefined ? 3 : _b;
1412
+ var selected = committedOptions.filter(function (opt) { return opt.selected; });
1413
+ var dropdownOpened = store.dropdownOpened;
1414
+ var allSelected = selected.length === data.length;
1415
+ var searchInputRef = useRef(null);
1416
+ useEffect(function () {
1417
+ var _a;
1418
+ if (dropdownOpened) {
1419
+ (_a = searchInputRef.current) === null || _a === undefined ? undefined : _a.focus();
1420
+ }
1421
+ }, [dropdownOpened]);
1422
+ // If the dropdown is closed and everything is selected => single "All {placeholder}" pill
1423
+ if (!dropdownOpened && allSelected) {
1424
+ return (jsx(Flex, { gap: 8, align: "center", wrap: "wrap", style: { flexGrow: 1, minHeight: 32 }, children: jsxs("span", { className: multiselectStyles.pill, children: [jsxs(Text, { variant: "xs", children: ["All ", placeholder] }), jsx(ActionIcon$1, { variant: "transparent", onClick: function (e) {
1425
+ e.stopPropagation();
1426
+ var newCommitted = committedOptions.map(function (o) { return (__assign(__assign({}, o), { selected: false })); });
1427
+ setCommittedOptions(newCommitted);
1428
+ setTemporaryOptions(newCommitted);
1429
+ onApply(newCommitted);
1430
+ }, children: jsx(Close, { height: "20px", width: "20px", stroke: "var(--color-neutral-600)" }) })] }) }));
1431
+ }
1432
+ // Otherwise, render original logic:
1433
+ return (jsxs(Flex, { gap: 8, align: "center", wrap: "wrap", style: { flexGrow: 1, minHeight: 32 }, children: [selected.length === 0 && !dropdownOpened && (jsx(Text, { variant: "s", children: label })), selected.slice(0, maxPills).map(function (option) { return (jsxs("span", { className: multiselectStyles.pill, children: [jsx(Text, { variant: "xs", children: option.label }), jsx(ActionIcon$1, { variant: "transparent", onClick: function (e) {
1434
+ e.stopPropagation();
1435
+ handleDeselectPill(option.value);
1436
+ }, children: jsx(Close, { height: "20px", width: "20px", stroke: "var(--color-neutral-600)" }) })] }, option.value)); }), selected.length > maxPills && (jsx(Tooltip, { label: selected
1437
+ .slice(maxPills, selected.length)
1438
+ .map(function (o) { return o.label; })
1439
+ .join(', '), position: "bottom", children: jsx("span", { className: multiselectStyles.pill, children: jsxs(Text, { variant: "xs", children: ["+", selected.length - maxPills] }) }, "more") })), dropdownOpened && (jsx("input", { ref: searchInputRef, type: "text", placeholder: "Search ".concat(placeholder, "..."), value: searchTerm, onChange: function (e) { return setSearchTerm(e.target.value); }, style: {
1440
+ flexGrow: 1,
1441
+ minWidth: 80,
1442
+ border: '1px solid var(--color-gray-200)',
1443
+ borderRadius: 4,
1444
+ padding: '4px 8px',
1445
+ outline: 'none',
1446
+ }, onClick: function (e) { return e.stopPropagation(); } }))] }));
1379
1447
  };
1380
1448
  var ErrorSection = (jsxs(Flex, { className: styles$k.error, gap: 4, ml: 16, mt: 8, style: { visibility: error ? 'visible' : 'hidden' }, children: [jsx(Info, { width: "18px", height: "18px", viewBox: "0 0 24 24", stroke: "var(--color-red-300)" }), jsx(Text, { variant: "xs", className: classNames(styles$k.errorText), children: error })] }));
1381
1449
  var DescriptionSection = (jsx(Flex, { className: styles$k.description, gap: 4, ml: 16, mt: 8, style: { visibility: description ? 'visible' : 'hidden' }, children: jsx(Text, { variant: "xs", children: description }) }));
1382
- var options = useMemo(function () {
1383
- return temporaryOptions.map(function (option) {
1384
- return (jsx(Dropdown.Option, { value: option.value, py: 12, disabled: option.disabled, onClick: function (e) {
1385
- e.stopPropagation();
1386
- }, children: jsx(Checkbox, { label: option.label, checked: option.selected, disabled: option.disabled, onChange: function (e) {
1387
- handleOptionClick(option);
1388
- e.stopPropagation();
1389
- }, w: "100%" }, option.value) }, option.value));
1390
- });
1391
- }, [temporaryOptions]);
1392
- return (jsx(Dropdown, { options: options, maxHeight: 300, footer: function (store) { return (jsxs(Flex, { justify: "flex-end", py: 8, gap: 8, children: [jsx(Button, { variant: "outlined", label: "Clear", size: "small", onClick: handleClear }), jsx(Button, { variant: "filled", label: "Apply", size: "small", onClick: function () { return handleApply(store.closeDropdown); } })] })); }, children: function (store) {
1450
+ var dropdownFooter = function (store) { return (jsxs(Flex, { justify: "flex-end", py: 8, gap: 8, children: [jsx(Button, { variant: "outlined", label: "Clear", size: "small", onClick: handleClear }), jsx(Button, { variant: "filled", label: "Apply", size: "small", onClick: function () { return handleApply(store.closeDropdown); } })] })); };
1451
+ return (jsx(Dropdown, { options: dropdownOptions, maxHeight: 300, footer: dropdownFooter, children: function (store) {
1393
1452
  var _a, _b;
1394
- return (jsxs("div", { className: styles$k.container, children: [(store.dropdownOpened || hasSelectedOptions) && (jsx("label", { className: classNames(styles$k.label, (_a = {},
1453
+ var floatLabel = store.dropdownOpened || hasSelectedOptions;
1454
+ return (jsxs("div", { className: styles$k.container, children: [floatLabel && (jsx("label", { className: classNames(styles$k.label, (_a = {},
1395
1455
  _a[styles$k.labelError] = error && !isFocused,
1396
1456
  _a[styles$k.labelFocused] = isFocused || isHovered,
1397
1457
  _a)), children: label })), jsxs(Box, { className: classNames(styles$k.input, multiselectStyles.input, (_b = {},
1398
1458
  _b[styles$k.inputError] = error && !isFocused,
1459
+ _b[multiselectStyles.inputFocused] = isFocused || store.dropdownOpened,
1399
1460
  _b[multiselectStyles.disabled] = disabled,
1400
- _b)), onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onClick: function () { return store.toggleDropdown(); }, onFocus: function () { return setIsFocused(true); }, onBlur: handleBlur, tabIndex: 0, children: [jsx(PillListSection, { store: store }), jsx(Chevron, { rotate: store.dropdownOpened ? 90 : 270 })] }), error ? ErrorSection : DescriptionSection] }));
1461
+ _b)), onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onClick: function () { return store.toggleDropdown(); }, onFocus: function () { return setIsFocused(true); }, onBlur: handleBlur, tabIndex: 0, children: [jsx(PillAndSearchSection, { store: store, maxPills: maxPills }), jsx(Chevron, { rotate: store.dropdownOpened ? 90 : 270 })] }), error ? ErrorSection : DescriptionSection] }));
1401
1462
  } }));
1402
1463
  };
1403
1464
 
@@ -1537,4 +1598,4 @@ var World = function (_a) {
1537
1598
  };
1538
1599
 
1539
1600
  export { Document as $, Accordion as A, Badge as B, Card as C, DateInput as D, EnterCodeInput as E, FileInput as F, Multiselect as G, Alert as H, IncrementNumber as I, Arrow as J, Attachment as K, Link as L, Message as M, NavBar as N, AvatarPlaceholder as O, PasswordInput as P, Bell as Q, RadioButton as R, SegmentedControl as S, Table as T, Calendar as U, Cat as V, Chevron as W, Clock as X, Close as Y, Cloud as Z, Delete as _, AccordionItem as a, Dog as a0, EyeHide as a1, EyeShow as a2, Fingerprint as a3, Google as a4, Grid as a5, HappyFace as a6, House as a7, HouseTime as a8, Identification as a9, Info as aa, Location as ab, Mail as ac, Menu as ad, MenuTouched as ae, Notification as af, Open as ag, Pets as ah, Phone as ai, Plaid as aj, Plus as ak, Remove as al, Search as am, ThreeDots as an, ThumbsDown as ao, Tick as ap, Umbrello as aq, Upload as ar, Visa as as, Warning as at, World as au, capitalizeFirstSentenceLetter as av, AccordionControl as b, AccordionPanel as c, ActionIcon as d, Animation as e, Autocomplete as f, getDefaultExportFromCjs as g, badgeVariantMap as h, Button as i, cardStatusVariantMap as j, CardStatus as k, Checkbox as l, Dropdown as m, FileUpload as n, Input as o, LinkModal as p, Loader as q, Modal as r, Pagination as s, Select as t, StatusBadge as u, Tabs as v, Text as w, Textarea as x, ToastContainer as y, Tooltip as z };
1540
- //# sourceMappingURL=index-SJDXCSJk.js.map
1601
+ //# sourceMappingURL=index-COG80HZJ.js.map