@nubitio/ui 1.3.0 → 1.3.1

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
@@ -692,7 +692,7 @@ function FileDropzone({ accept, value = null, image = false, disabled = false, r
692
692
  }
693
693
  //#endregion
694
694
  //#region packages/ui/AppDropdown.tsx
695
- function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onChange, disabled = false, placeholder = "Seleccionar…", variant = "form", className, showFieldLabel = variant === "form", menuMinWidth, error, helpText, menuHeader, menuFooter, onOpenChange }) {
695
+ function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onChange, disabled = false, placeholder = "Seleccionar…", variant = "form", className, showFieldLabel = variant === "form", menuMinWidth, error, helpText, menuHeader, menuFooter, onOpenChange, triggerIcon }) {
696
696
  const generatedId = (0, react.useId)();
697
697
  const id = idProp ?? generatedId;
698
698
  const container = useOverlayContainer();
@@ -700,6 +700,7 @@ function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onCha
700
700
  const selected = options.find((option) => option.value === value);
701
701
  const labelled = !!label && (showFieldLabel || variant === "toolbar");
702
702
  const message = error ?? helpText;
703
+ const triggerIconClass = triggerIcon?.startsWith("ph ") ? triggerIcon : triggerIcon?.startsWith("ph-") ? `ph ${triggerIcon}` : `ph ph-${triggerIcon}`;
703
704
  const iconClass = icon?.startsWith("ph ") ? icon : icon?.startsWith("ph-") ? `ph ${icon}` : `ph ph-${icon}`;
704
705
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.Root, {
705
706
  value,
@@ -751,17 +752,25 @@ function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onCha
751
752
  }
752
753
  },
753
754
  "aria-label": ariaLabel,
755
+ title: triggerIcon ? ariaLabel ?? selected?.label : void 0,
754
756
  "aria-labelledby": ariaLabel ? void 0 : labelled ? `${id}-label ${id}-value` : `${id}-value`,
755
757
  "aria-describedby": message ? `${id}-message` : void 0,
756
758
  "aria-invalid": !!error || void 0,
757
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
758
- className: "nb-dropdown__value",
759
- id: `${id}-value`,
760
- children: selected?.selectedLabel ?? selected?.label ?? placeholder
761
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
762
- className: "ph ph-caret-down nb-dropdown__caret",
763
- "aria-hidden": "true"
764
- })]
759
+ children: [
760
+ triggerIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
761
+ className: `${triggerIconClass} nb-dropdown__trigger-icon`,
762
+ "aria-hidden": "true"
763
+ }),
764
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
765
+ className: `nb-dropdown__value${triggerIcon ? " nb-sr-only" : ""}`,
766
+ id: `${id}-value`,
767
+ children: selected?.selectedLabel ?? selected?.label ?? placeholder
768
+ }),
769
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
770
+ className: "ph ph-caret-down nb-dropdown__caret",
771
+ "aria-hidden": "true"
772
+ })
773
+ ]
765
774
  }),
766
775
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.Portal, {
767
776
  container: container ?? void 0,
package/dist/index.d.cts CHANGED
@@ -200,8 +200,13 @@ interface AppDropdownProps {
200
200
  menuHeader?: ReactNode;
201
201
  menuFooter?: ReactNode;
202
202
  onOpenChange?: (open: boolean) => void;
203
+ /**
204
+ * Renders the trigger as this icon alone. The selected label stays available to assistive
205
+ * technology and as the tooltip, so the current choice is never icon-only.
206
+ */
207
+ triggerIcon?: string;
203
208
  }
204
- declare function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onChange, disabled, placeholder, variant, className, showFieldLabel, menuMinWidth, error, helpText, menuHeader, menuFooter, onOpenChange }: AppDropdownProps): import("react").JSX.Element;
209
+ declare function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onChange, disabled, placeholder, variant, className, showFieldLabel, menuMinWidth, error, helpText, menuHeader, menuFooter, onOpenChange, triggerIcon }: AppDropdownProps): import("react").JSX.Element;
205
210
  //#endregion
206
211
  //#region packages/ui/SearchableAppDropdown.d.ts
207
212
  interface SearchableAppDropdownProps extends Omit<AppDropdownProps, 'options'> {
package/dist/index.d.mts CHANGED
@@ -200,8 +200,13 @@ interface AppDropdownProps {
200
200
  menuHeader?: ReactNode;
201
201
  menuFooter?: ReactNode;
202
202
  onOpenChange?: (open: boolean) => void;
203
+ /**
204
+ * Renders the trigger as this icon alone. The selected label stays available to assistive
205
+ * technology and as the tooltip, so the current choice is never icon-only.
206
+ */
207
+ triggerIcon?: string;
203
208
  }
204
- declare function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onChange, disabled, placeholder, variant, className, showFieldLabel, menuMinWidth, error, helpText, menuHeader, menuFooter, onOpenChange }: AppDropdownProps): import("react").JSX.Element;
209
+ declare function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onChange, disabled, placeholder, variant, className, showFieldLabel, menuMinWidth, error, helpText, menuHeader, menuFooter, onOpenChange, triggerIcon }: AppDropdownProps): import("react").JSX.Element;
205
210
  //#endregion
206
211
  //#region packages/ui/SearchableAppDropdown.d.ts
207
212
  interface SearchableAppDropdownProps extends Omit<AppDropdownProps, 'options'> {
package/dist/index.mjs CHANGED
@@ -668,7 +668,7 @@ function FileDropzone({ accept, value = null, image = false, disabled = false, r
668
668
  }
669
669
  //#endregion
670
670
  //#region packages/ui/AppDropdown.tsx
671
- function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onChange, disabled = false, placeholder = "Seleccionar…", variant = "form", className, showFieldLabel = variant === "form", menuMinWidth, error, helpText, menuHeader, menuFooter, onOpenChange }) {
671
+ function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onChange, disabled = false, placeholder = "Seleccionar…", variant = "form", className, showFieldLabel = variant === "form", menuMinWidth, error, helpText, menuHeader, menuFooter, onOpenChange, triggerIcon }) {
672
672
  const generatedId = useId();
673
673
  const id = idProp ?? generatedId;
674
674
  const container = useOverlayContainer();
@@ -676,6 +676,7 @@ function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onCha
676
676
  const selected = options.find((option) => option.value === value);
677
677
  const labelled = !!label && (showFieldLabel || variant === "toolbar");
678
678
  const message = error ?? helpText;
679
+ const triggerIconClass = triggerIcon?.startsWith("ph ") ? triggerIcon : triggerIcon?.startsWith("ph-") ? `ph ${triggerIcon}` : `ph ph-${triggerIcon}`;
679
680
  const iconClass = icon?.startsWith("ph ") ? icon : icon?.startsWith("ph-") ? `ph ${icon}` : `ph ph-${icon}`;
680
681
  return /* @__PURE__ */ jsx(Select.Root, {
681
682
  value,
@@ -727,17 +728,25 @@ function AppDropdown({ id: idProp, ariaLabel, label, icon, value, options, onCha
727
728
  }
728
729
  },
729
730
  "aria-label": ariaLabel,
731
+ title: triggerIcon ? ariaLabel ?? selected?.label : void 0,
730
732
  "aria-labelledby": ariaLabel ? void 0 : labelled ? `${id}-label ${id}-value` : `${id}-value`,
731
733
  "aria-describedby": message ? `${id}-message` : void 0,
732
734
  "aria-invalid": !!error || void 0,
733
- children: [/* @__PURE__ */ jsx("span", {
734
- className: "nb-dropdown__value",
735
- id: `${id}-value`,
736
- children: selected?.selectedLabel ?? selected?.label ?? placeholder
737
- }), /* @__PURE__ */ jsx("i", {
738
- className: "ph ph-caret-down nb-dropdown__caret",
739
- "aria-hidden": "true"
740
- })]
735
+ children: [
736
+ triggerIcon && /* @__PURE__ */ jsx("i", {
737
+ className: `${triggerIconClass} nb-dropdown__trigger-icon`,
738
+ "aria-hidden": "true"
739
+ }),
740
+ /* @__PURE__ */ jsx("span", {
741
+ className: `nb-dropdown__value${triggerIcon ? " nb-sr-only" : ""}`,
742
+ id: `${id}-value`,
743
+ children: selected?.selectedLabel ?? selected?.label ?? placeholder
744
+ }),
745
+ /* @__PURE__ */ jsx("i", {
746
+ className: "ph ph-caret-down nb-dropdown__caret",
747
+ "aria-hidden": "true"
748
+ })
749
+ ]
741
750
  }),
742
751
  /* @__PURE__ */ jsx(Select.Portal, {
743
752
  container: container ?? void 0,
package/dist/style.css CHANGED
@@ -1421,6 +1421,16 @@ html[data-density=compact] .nb-dialog__footer {
1421
1421
  display: inline-flex;
1422
1422
  flex-shrink: 0;
1423
1423
  }
1424
+
1425
+ .nb-dropdown__value.nb-sr-only {
1426
+ border: 0;
1427
+ clip-path: inset(50%);
1428
+ height: 1px;
1429
+ overflow: hidden;
1430
+ position: absolute;
1431
+ white-space: nowrap;
1432
+ width: 1px;
1433
+ }
1424
1434
  .nb-combobox {
1425
1435
  --nb-combobox-action-size: calc(var(--control-height-form) - 8px);
1426
1436
  --nb-combobox-action-count: 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubitio/ui",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "type": "module",
5
5
  "description": "Visual primitives and theme system for the Nubit admin stack (dialogs, cards, toolbar, light/dark theme).",
6
6
  "license": "MIT",