@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 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
- (o) => o.value === currentValue && !o.disabled
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
- return /* @__PURE__ */ jsxs(
435
- "div",
436
- {
437
- ref: wrapperRef,
438
- className: rootClassName,
439
- style: fullWidth ? { width: "100%" } : void 0,
440
- children: [
441
- label && /* @__PURE__ */ jsx(
442
- "label",
443
- {
444
- htmlFor: selectId,
445
- className: "select_label",
446
- children: label
447
- }
448
- ),
449
- /* @__PURE__ */ jsxs(
450
- "button",
451
- {
452
- ref: controlRef,
453
- id: selectId,
454
- type: "button",
455
- className: controlClassName,
456
- "aria-haspopup": "listbox",
457
- "aria-expanded": isOpen,
458
- "aria-controls": `${selectId}_listbox`,
459
- onClick: () => !disabled && setIsOpen((o) => !o),
460
- onKeyDown,
461
- disabled,
462
- children: [
463
- /* @__PURE__ */ jsx(
464
- "span",
465
- {
466
- className: currentOption ? "select_value" : "select_placeholder",
467
- style: textAlign === "left" ? { textAlign: "start" } : void 0,
468
- children: currentOption ? currentOption.label : placeholder
469
- }
470
- ),
471
- /* @__PURE__ */ jsx("span", { className: "select_icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx(ChevronDown, { size: 16 }) })
472
- ]
473
- }
474
- ),
475
- isOpen && /* @__PURE__ */ jsx(
476
- "ul",
477
- {
478
- id: `${selectId}_listbox`,
479
- role: "listbox",
480
- className: `select_list${dropUp ? " select_list_up" : ""}`,
481
- children: options.map((opt, i) => {
482
- const selected = currentValue === opt.value;
483
- const active = i === activeIndex;
484
- const optionClassName = [
485
- "select_option",
486
- selected && "is_selected",
487
- active && "is_active",
488
- opt.disabled && "is_disabled"
489
- ].filter(Boolean).join(" ");
490
- return /* @__PURE__ */ jsxs(
491
- "li",
492
- {
493
- role: "option",
494
- "aria-selected": selected,
495
- className: optionClassName,
496
- onMouseEnter: () => !opt.disabled && setActiveIndex(i),
497
- onClick: () => {
498
- if (opt.disabled) return;
499
- setValue(opt.value);
500
- setIsOpen(false);
501
- },
502
- children: [
503
- /* @__PURE__ */ jsx("span", { children: opt.label }),
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigtablet/design-system",
3
- "version": "1.16.0",
3
+ "version": "1.16.2",
4
4
  "description": "Bigtablet Design System UI Components",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",