@lindle/linoardo 1.0.50 → 1.0.51

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.cjs CHANGED
@@ -46,7 +46,7 @@ var iconBaseClasses = {
46
46
  };
47
47
 
48
48
  // src/Containment/Button/states.button.ts
49
- var base = "btn-base focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:focus-visible:ring-offset-gray-900 rounded-lg transition-colors duration-200 font-medium disabled:opacity-50 disabled:cursor-not-allowed";
49
+ var base = "btn-base focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:focus-visible:ring-offset-gray-900 rounded-lg transition-colors duration-200 font-medium disabled:opacity-50 disabled:cursor-not-allowed";
50
50
  var blackAndWhitePaletteClasses = {
51
51
  solid: "bg-black text-white hover:bg-black/90 focus-visible:ring-black/40 focus-visible:ring-offset-white dark:bg-white dark:text-black dark:hover:bg-white/90 dark:focus-visible:ring-white/40 dark:focus-visible:ring-offset-gray-900",
52
52
  outline: "border-2 border-black text-black bg-white hover:bg-black hover:text-white focus-visible:ring-black/40 focus-visible:ring-offset-white dark:border-white dark:text-white dark:bg-transparent dark:hover:bg-white dark:hover:text-black dark:focus-visible:ring-white/40 dark:focus-visible:ring-offset-gray-900",
@@ -143,9 +143,7 @@ var resolveIconClassName = (icon) => {
143
143
  }
144
144
  const [library, providedName] = icon;
145
145
  const normalizedLibrary = library.trim();
146
- const baseClasses = iconBaseClasses[normalizedLibrary] ?? [
147
- normalizedLibrary
148
- ];
146
+ const baseClasses = iconBaseClasses[normalizedLibrary] ?? [normalizedLibrary];
149
147
  const iconName = providedName.trim();
150
148
  if (!iconName) {
151
149
  return baseClasses.join(" ");
@@ -3555,6 +3553,7 @@ var Select = React15__namespace.default.forwardRef(
3555
3553
  onChange,
3556
3554
  onBlur,
3557
3555
  onFocus,
3556
+ addOptionAction,
3558
3557
  ...props
3559
3558
  }, ref) => {
3560
3559
  const selectId = id || name || generateString();
@@ -3583,6 +3582,13 @@ var Select = React15__namespace.default.forwardRef(
3583
3582
  onFocus?.(event);
3584
3583
  }
3585
3584
  };
3585
+ const handleAddOptionActionClick = (event) => {
3586
+ event.preventDefault();
3587
+ if (disabled || !addOptionAction) return;
3588
+ addOptionAction.onClick();
3589
+ const detailsEl = event.currentTarget.closest("details");
3590
+ detailsEl?.removeAttribute("open");
3591
+ };
3586
3592
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tailwindMerge.twMerge("flex flex-col gap-1", wrapperClassName), children: [
3587
3593
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
3588
3594
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -3614,46 +3620,61 @@ var Select = React15__namespace.default.forwardRef(
3614
3620
  ]
3615
3621
  }
3616
3622
  ),
3617
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-lg border border-gray-200 bg-white py-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:bg-slate-800 dark:border-slate-700", children: normalizedOptions.map((option, index) => {
3618
- const optionValueStr = String(option.value);
3619
- const isSelected = Array.isArray(value) ? value.map(String).includes(optionValueStr) : String(value) === optionValueStr;
3620
- const isDefaultSelected = Array.isArray(defaultValue) ? defaultValue.map(String).includes(optionValueStr) : String(defaultValue) === optionValueStr;
3621
- const iconClassName = resolveIconClassName4(option.icon);
3622
- const inputId = `${selectId}-${toIdSafe(optionValueStr)}-${index}`;
3623
- return /* @__PURE__ */ jsxRuntime.jsxs(
3624
- "label",
3623
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-lg border border-gray-200 bg-white py-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:bg-slate-800 dark:border-slate-700", children: [
3624
+ normalizedOptions.map((option, index) => {
3625
+ const optionValueStr = String(option.value);
3626
+ const isSelected = Array.isArray(value) ? value.map(String).includes(optionValueStr) : String(value) === optionValueStr;
3627
+ const isDefaultSelected = Array.isArray(defaultValue) ? defaultValue.map(String).includes(optionValueStr) : String(defaultValue) === optionValueStr;
3628
+ const iconClassName = resolveIconClassName4(option.icon);
3629
+ const inputId = `${selectId}-${toIdSafe(optionValueStr)}-${index}`;
3630
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3631
+ "label",
3632
+ {
3633
+ htmlFor: inputId,
3634
+ className: tailwindMerge.twMerge(
3635
+ "relative flex cursor-pointer select-none items-center gap-2 px-4 py-2 text-sm text-gray-900 hover:bg-gray-50 dark:text-gray-100 dark:hover:bg-slate-700",
3636
+ option.disabled && "cursor-not-allowed opacity-50"
3637
+ ),
3638
+ children: [
3639
+ /* @__PURE__ */ jsxRuntime.jsx(
3640
+ "input",
3641
+ {
3642
+ type: multiple ? "checkbox" : "radio",
3643
+ id: inputId,
3644
+ name: inputName,
3645
+ value: option.value,
3646
+ disabled: option.disabled || disabled,
3647
+ checked: value !== void 0 ? isSelected : void 0,
3648
+ defaultChecked: defaultValue !== void 0 ? isDefaultSelected : void 0,
3649
+ onChange: handleOptionChange,
3650
+ onBlur,
3651
+ ref,
3652
+ required: required && !multiple,
3653
+ className: "peer sr-only"
3654
+ }
3655
+ ),
3656
+ iconClassName && /* @__PURE__ */ jsxRuntime.jsx("i", { className: tailwindMerge.twMerge(iconClassName, "text-lg text-gray-500 peer-checked:text-primary dark:text-gray-400") }),
3657
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate peer-checked:font-medium peer-checked:text-primary", children: option.label }),
3658
+ /* @__PURE__ */ jsxRuntime.jsx("i", { className: "mdi mdi-check invisible ml-auto text-primary peer-checked:visible" })
3659
+ ]
3660
+ },
3661
+ `${optionValueStr}-${index}`
3662
+ );
3663
+ }),
3664
+ addOptionAction && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 border-t border-gray-100 pt-1 dark:border-slate-700", children: /* @__PURE__ */ jsxRuntime.jsxs(
3665
+ "button",
3625
3666
  {
3626
- htmlFor: inputId,
3627
- className: tailwindMerge.twMerge(
3628
- "relative flex cursor-pointer select-none items-center gap-2 px-4 py-2 text-sm text-gray-900 hover:bg-gray-50 dark:text-gray-100 dark:hover:bg-slate-700",
3629
- option.disabled && "cursor-not-allowed opacity-50"
3630
- ),
3667
+ type: "button",
3668
+ className: "flex w-full cursor-pointer items-center gap-2 px-4 py-2 text-left text-sm font-medium text-primary hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:bg-slate-700",
3669
+ onClick: handleAddOptionActionClick,
3670
+ disabled,
3631
3671
  children: [
3632
- /* @__PURE__ */ jsxRuntime.jsx(
3633
- "input",
3634
- {
3635
- type: multiple ? "checkbox" : "radio",
3636
- id: inputId,
3637
- name: inputName,
3638
- value: option.value,
3639
- disabled: option.disabled || disabled,
3640
- checked: value !== void 0 ? isSelected : void 0,
3641
- defaultChecked: defaultValue !== void 0 ? isDefaultSelected : void 0,
3642
- onChange: handleOptionChange,
3643
- onBlur,
3644
- ref,
3645
- required: required && !multiple,
3646
- className: "peer sr-only"
3647
- }
3648
- ),
3649
- iconClassName && /* @__PURE__ */ jsxRuntime.jsx("i", { className: tailwindMerge.twMerge(iconClassName, "text-lg text-gray-500 peer-checked:text-primary dark:text-gray-400") }),
3650
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate peer-checked:font-medium peer-checked:text-primary", children: option.label }),
3651
- /* @__PURE__ */ jsxRuntime.jsx("i", { className: "mdi mdi-check invisible ml-auto text-primary peer-checked:visible" })
3672
+ /* @__PURE__ */ jsxRuntime.jsx("i", { className: "mdi mdi-plus", "aria-hidden": true }),
3673
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: addOptionAction.label })
3652
3674
  ]
3653
- },
3654
- `${optionValueStr}-${index}`
3655
- );
3656
- }) })
3675
+ }
3676
+ ) })
3677
+ ] })
3657
3678
  ]
3658
3679
  }
3659
3680
  ),