@timeax/form-palette 0.0.26 → 0.0.27

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
@@ -16302,6 +16302,8 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
16302
16302
  contentClassName,
16303
16303
  renderOption,
16304
16304
  renderValue,
16305
+ // Mode
16306
+ mode = "default",
16305
16307
  // Icons & controls
16306
16308
  leadingIcons,
16307
16309
  trailingIcons,
@@ -16315,11 +16317,15 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
16315
16317
  trailingControlClassName,
16316
16318
  joinControls = true,
16317
16319
  extendBoxToControls = true,
16320
+ // Button mode only
16321
+ button,
16322
+ children,
16318
16323
  // Virtual scroll / incremental render
16319
16324
  virtualScroll = false,
16320
16325
  virtualScrollPageSize = 50,
16321
16326
  virtualScrollThreshold = 48
16322
16327
  } = props;
16328
+ const isButtonMode = mode === "button";
16323
16329
  const [open, setOpen] = React10.useState(false);
16324
16330
  const [query, setQuery] = React10.useState("");
16325
16331
  const items = React10.useMemo(
@@ -16412,18 +16418,19 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
16412
16418
  const padCls = triggerPadding(density);
16413
16419
  const showClear = clearable && value != null;
16414
16420
  const resolvedLeadingIcons = (() => {
16421
+ if (isButtonMode) return [];
16415
16422
  if (leadingIcons && leadingIcons.length) return leadingIcons;
16416
16423
  if (icon) return [icon];
16417
16424
  return [];
16418
16425
  })();
16419
- const resolvedTrailingIcons = trailingIcons != null ? trailingIcons : [];
16426
+ const resolvedTrailingIcons = isButtonMode ? [] : trailingIcons != null ? trailingIcons : [];
16420
16427
  const baseIconGap = iconGap != null ? iconGap : 4;
16421
16428
  const leadingGap = leadingIconSpacing != null ? leadingIconSpacing : baseIconGap;
16422
16429
  const trailingGap = trailingIconSpacing != null ? trailingIconSpacing : baseIconGap;
16423
16430
  const hasLeadingIcons = resolvedLeadingIcons.length > 0;
16424
16431
  const hasTrailingIcons = resolvedTrailingIcons.length > 0;
16425
- const hasLeadingControl = !!leadingControl;
16426
- const hasTrailingControl = !!trailingControl;
16432
+ const hasLeadingControl = !isButtonMode && !!leadingControl;
16433
+ const hasTrailingControl = !isButtonMode && !!trailingControl;
16427
16434
  const hasControls = hasLeadingControl || hasTrailingControl;
16428
16435
  const triggerInner = renderValue ? renderValue({
16429
16436
  selectedItem,
@@ -16438,7 +16445,57 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
16438
16445
  "focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]",
16439
16446
  "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive"
16440
16447
  );
16441
- const TriggerBody = /* @__PURE__ */ jsx(
16448
+ const ButtonModeTrigger = React10.useMemo(() => {
16449
+ if (!isButtonMode) return null;
16450
+ const selectedValue = value;
16451
+ const renderable = button != null ? button : children;
16452
+ const content = (() => {
16453
+ var _a2, _b2, _c, _d;
16454
+ if (typeof renderable === "function") {
16455
+ return renderable({
16456
+ open,
16457
+ selectedItem,
16458
+ selectedValue,
16459
+ placeholder
16460
+ });
16461
+ }
16462
+ if (renderable != null) return renderable;
16463
+ const iconNode = (_c = (_b2 = selectedItem == null ? void 0 : selectedItem.icon) != null ? _b2 : (_a2 = items.find((it) => it.icon)) == null ? void 0 : _a2.icon) != null ? _c : null;
16464
+ if (iconNode) {
16465
+ return /* @__PURE__ */ jsx("span", { className: "inline-flex items-center justify-center", children: iconNode });
16466
+ }
16467
+ return /* @__PURE__ */ jsx("span", { className: "truncate", children: (_d = selectedItem == null ? void 0 : selectedItem.labelNode) != null ? _d : placeholder != null ? placeholder : "Select..." });
16468
+ })();
16469
+ return /* @__PURE__ */ jsx(
16470
+ "button",
16471
+ {
16472
+ ref: _ref,
16473
+ type: "button",
16474
+ disabled: disabled || readOnly,
16475
+ className: cn(
16476
+ "inline-flex items-center justify-center",
16477
+ "focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",
16478
+ triggerClassName
16479
+ ),
16480
+ "aria-label": (selectedItem == null ? void 0 : selectedItem.labelText) ? `Selected: ${selectedItem.labelText}` : "Select",
16481
+ children: content
16482
+ }
16483
+ );
16484
+ }, [
16485
+ isButtonMode,
16486
+ button,
16487
+ children,
16488
+ open,
16489
+ selectedItem,
16490
+ value,
16491
+ placeholder,
16492
+ items,
16493
+ disabled,
16494
+ readOnly,
16495
+ triggerClassName,
16496
+ _ref
16497
+ ]);
16498
+ const TriggerBody = isButtonMode ? /* @__PURE__ */ jsx(SelectTrigger, { asChild: true, children: ButtonModeTrigger }) : /* @__PURE__ */ jsx(
16442
16499
  SelectTrigger,
16443
16500
  {
16444
16501
  onPointerDown: (e) => {
@@ -16531,7 +16588,7 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
16531
16588
  /* @__PURE__ */ jsxs(
16532
16589
  SelectContent,
16533
16590
  {
16534
- className: cn("min-w-[8rem]", contentClassName),
16591
+ className: cn("min-w-32", contentClassName),
16535
16592
  children: [
16536
16593
  searchable && /* @__PURE__ */ jsx("div", { className: "p-1", children: /* @__PURE__ */ jsx(
16537
16594
  Input,
@@ -16600,7 +16657,7 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
16600
16657
  ]
16601
16658
  }
16602
16659
  );
16603
- if (!hasControls) {
16660
+ if (isButtonMode || !hasControls) {
16604
16661
  return /* @__PURE__ */ jsx(
16605
16662
  "div",
16606
16663
  {