@bigtablet/design-system 1.16.0 → 1.16.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.d.ts +1 -1
- package/dist/index.js +73 -99
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ interface SelectProps {
|
|
|
109
109
|
className?: string;
|
|
110
110
|
textAlign?: "left" | "center";
|
|
111
111
|
}
|
|
112
|
-
declare const Select: ({ id, label, placeholder, options, value, onChange, defaultValue, disabled, size, variant, fullWidth, className, textAlign }: SelectProps) => react_jsx_runtime.JSX.Element;
|
|
112
|
+
declare const Select: ({ id, label, placeholder, options, value, onChange, defaultValue, disabled, size, variant, fullWidth, className, textAlign, }: SelectProps) => react_jsx_runtime.JSX.Element;
|
|
113
113
|
|
|
114
114
|
interface SwitchProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onChange"> {
|
|
115
115
|
checked?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -383,9 +383,7 @@ var Select = ({
|
|
|
383
383
|
case "Home":
|
|
384
384
|
e.preventDefault();
|
|
385
385
|
setIsOpen(true);
|
|
386
|
-
setActiveIndex(
|
|
387
|
-
options.findIndex((o) => !o.disabled)
|
|
388
|
-
);
|
|
386
|
+
setActiveIndex(options.findIndex((o) => !o.disabled));
|
|
389
387
|
break;
|
|
390
388
|
case "End":
|
|
391
389
|
e.preventDefault();
|
|
@@ -405,15 +403,8 @@ var Select = ({
|
|
|
405
403
|
};
|
|
406
404
|
React3.useEffect(() => {
|
|
407
405
|
if (!isOpen) return;
|
|
408
|
-
const idx = options.findIndex(
|
|
409
|
-
|
|
410
|
-
);
|
|
411
|
-
setActiveIndex(
|
|
412
|
-
idx >= 0 ? idx : Math.max(
|
|
413
|
-
0,
|
|
414
|
-
options.findIndex((o) => !o.disabled)
|
|
415
|
-
)
|
|
416
|
-
);
|
|
406
|
+
const idx = options.findIndex((o) => o.value === currentValue && !o.disabled);
|
|
407
|
+
setActiveIndex(idx >= 0 ? idx : Math.max(0, options.findIndex((o) => !o.disabled)));
|
|
417
408
|
}, [isOpen, options, currentValue]);
|
|
418
409
|
React3.useLayoutEffect(() => {
|
|
419
410
|
if (!isOpen || !controlRef.current) return;
|
|
@@ -431,93 +422,76 @@ var Select = ({
|
|
|
431
422
|
isOpen && "is_open",
|
|
432
423
|
disabled && "is_disabled"
|
|
433
424
|
].filter(Boolean).join(" ");
|
|
434
|
-
|
|
435
|
-
"
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
selected && /* @__PURE__ */ jsx(
|
|
505
|
-
Check,
|
|
506
|
-
{
|
|
507
|
-
size: 16,
|
|
508
|
-
"aria-hidden": "true"
|
|
509
|
-
}
|
|
510
|
-
)
|
|
511
|
-
]
|
|
512
|
-
},
|
|
513
|
-
opt.value
|
|
514
|
-
);
|
|
515
|
-
})
|
|
516
|
-
}
|
|
517
|
-
)
|
|
518
|
-
]
|
|
519
|
-
}
|
|
520
|
-
);
|
|
425
|
+
const listClassName = [
|
|
426
|
+
"select_list",
|
|
427
|
+
dropUp && "select_list_up"
|
|
428
|
+
].filter(Boolean).join(" ");
|
|
429
|
+
return /* @__PURE__ */ jsxs("div", { ref: wrapperRef, className: rootClassName, style: fullWidth ? { width: "100%" } : void 0, children: [
|
|
430
|
+
label && /* @__PURE__ */ jsx("label", { htmlFor: selectId, className: "select_label", children: label }),
|
|
431
|
+
/* @__PURE__ */ jsxs(
|
|
432
|
+
"button",
|
|
433
|
+
{
|
|
434
|
+
ref: controlRef,
|
|
435
|
+
id: selectId,
|
|
436
|
+
type: "button",
|
|
437
|
+
className: controlClassName,
|
|
438
|
+
"aria-haspopup": "listbox",
|
|
439
|
+
"aria-expanded": isOpen,
|
|
440
|
+
"aria-controls": `${selectId}_listbox`,
|
|
441
|
+
onClick: () => !disabled && setIsOpen((o) => !o),
|
|
442
|
+
onKeyDown,
|
|
443
|
+
disabled,
|
|
444
|
+
children: [
|
|
445
|
+
/* @__PURE__ */ jsx(
|
|
446
|
+
"span",
|
|
447
|
+
{
|
|
448
|
+
className: currentOption ? "select_value" : "select_placeholder",
|
|
449
|
+
style: textAlign === "left" ? { textAlign: "start" } : void 0,
|
|
450
|
+
children: currentOption ? currentOption.label : placeholder
|
|
451
|
+
}
|
|
452
|
+
),
|
|
453
|
+
/* @__PURE__ */ jsx("span", { className: "select_icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx(ChevronDown, { size: 16 }) })
|
|
454
|
+
]
|
|
455
|
+
}
|
|
456
|
+
),
|
|
457
|
+
isOpen && /* @__PURE__ */ jsx(
|
|
458
|
+
"ul",
|
|
459
|
+
{
|
|
460
|
+
id: `${selectId}_listbox`,
|
|
461
|
+
role: "listbox",
|
|
462
|
+
className: listClassName,
|
|
463
|
+
children: options.map((opt, i) => {
|
|
464
|
+
const selected = currentValue === opt.value;
|
|
465
|
+
const active = i === activeIndex;
|
|
466
|
+
const optionClassName = [
|
|
467
|
+
"select_option",
|
|
468
|
+
selected && "is_selected",
|
|
469
|
+
active && "is_active",
|
|
470
|
+
opt.disabled && "is_disabled"
|
|
471
|
+
].filter(Boolean).join(" ");
|
|
472
|
+
return /* @__PURE__ */ jsxs(
|
|
473
|
+
"li",
|
|
474
|
+
{
|
|
475
|
+
role: "option",
|
|
476
|
+
"aria-selected": selected,
|
|
477
|
+
className: optionClassName,
|
|
478
|
+
onMouseEnter: () => !opt.disabled && setActiveIndex(i),
|
|
479
|
+
onClick: () => {
|
|
480
|
+
if (opt.disabled) return;
|
|
481
|
+
setValue(opt.value);
|
|
482
|
+
setIsOpen(false);
|
|
483
|
+
},
|
|
484
|
+
children: [
|
|
485
|
+
/* @__PURE__ */ jsx("span", { children: opt.label }),
|
|
486
|
+
selected && /* @__PURE__ */ jsx(Check, { size: 16, "aria-hidden": "true" })
|
|
487
|
+
]
|
|
488
|
+
},
|
|
489
|
+
opt.value
|
|
490
|
+
);
|
|
491
|
+
})
|
|
492
|
+
}
|
|
493
|
+
)
|
|
494
|
+
] });
|
|
521
495
|
};
|
|
522
496
|
var Switch = ({
|
|
523
497
|
checked,
|