@raxrai/stylelab-ui 0.3.0 → 0.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/README.md CHANGED
@@ -191,6 +191,7 @@ Implements focus trap and scroll lock when open.
191
191
  | `items` | `{ value, label, disabled? }[]` | — | Options |
192
192
  | `value` / `defaultValue` | `string` | — | Controlled / initial |
193
193
  | `onValueChange`| `(value: string) => void` | — | Selection callback |
194
+ | `disabled` | `boolean` | `false` | When true, does not open; trigger is non-interactive |
194
195
 
195
196
  Keyboard: Enter/Space to open, Arrows to move, Enter to select, Escape to close.
196
197
 
@@ -212,6 +213,10 @@ import { cn, useFocusTrap, useClickOutside, useKeyboardNavigation, getNextListIn
212
213
 
213
214
  ## Changelog
214
215
 
216
+ ### [0.3.1]
217
+
218
+ - **Dropdown** — `disabled` prop: when true, the dropdown does not open and the trigger is non-interactive (opacity, cursor, no popover). Use for empty or loading state.
219
+
215
220
  ### [0.2.0]
216
221
 
217
222
  - **Navbar** — Optional responsive API: pass `logo`, `items` (`{ href, label }[]`), and `right` (e.g. theme switcher). On small screens nav links become a hamburger menu that opens as an overlay (no layout shift), with the theme’s navbar background; glass and clay use an opaque panel so content doesn’t show through. Desktop shows full nav row. Menu closes on link click or outside click. You can still pass `children` for a custom layout. Exported types: `NavbarItem`, `NavbarProps`.
package/dist/index.cjs CHANGED
@@ -4993,6 +4993,7 @@ function Dropdown({
4993
4993
  value: controlledValue,
4994
4994
  defaultValue,
4995
4995
  onValueChange,
4996
+ disabled = false,
4996
4997
  className,
4997
4998
  style,
4998
4999
  theme: themeProp,
@@ -5028,10 +5029,13 @@ function Dropdown({
5028
5029
  });
5029
5030
  }, []);
5030
5031
  (0, import_react15.useLayoutEffect)(() => {
5031
- if (open) {
5032
+ if (open && !disabled) {
5032
5033
  updatePosition();
5033
5034
  }
5034
- }, [open, updatePosition, items.length]);
5035
+ }, [open, disabled, updatePosition, items.length]);
5036
+ (0, import_react15.useEffect)(() => {
5037
+ if (disabled && open) setOpen(false);
5038
+ }, [disabled, open]);
5035
5039
  (0, import_react15.useEffect)(() => {
5036
5040
  if (!open) return;
5037
5041
  const onScrollOrResize = () => updatePosition();
@@ -5074,6 +5078,7 @@ function Dropdown({
5074
5078
  }, [open, displayValue, items]);
5075
5079
  const handleKeyDown = (0, import_react15.useCallback)(
5076
5080
  (e) => {
5081
+ if (disabled) return;
5077
5082
  if (!open) {
5078
5083
  if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") {
5079
5084
  e.preventDefault();
@@ -5106,15 +5111,17 @@ function Dropdown({
5106
5111
  selectIndex(highlightedIndex);
5107
5112
  }
5108
5113
  },
5109
- [open, highlightedIndex, items.length, selectIndex]
5114
+ [disabled, open, highlightedIndex, items.length, selectIndex]
5110
5115
  );
5111
5116
  const selectedLabel = displayValue ? items.find((i) => i.value === displayValue)?.label ?? displayValue : placeholder;
5112
5117
  const defaultTrigger = /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
5113
5118
  "span",
5114
5119
  {
5115
5120
  className: cn(
5116
- "inline-flex min-w-[8rem] cursor-pointer items-center justify-between rounded-lg border border-transparent px-3 py-2 text-sm font-medium transition-colors",
5117
- itemHighlightClass,
5121
+ "inline-flex min-w-[8rem] items-center justify-between rounded-lg border border-transparent px-3 py-2 text-sm font-medium transition-colors",
5122
+ !disabled && "cursor-pointer",
5123
+ !disabled && itemHighlightClass,
5124
+ disabled && "cursor-not-allowed opacity-60",
5118
5125
  classNames.trigger
5119
5126
  ),
5120
5127
  children: [
@@ -5124,7 +5131,7 @@ function Dropdown({
5124
5131
  }
5125
5132
  );
5126
5133
  const trigger = triggerProp ?? defaultTrigger;
5127
- const popover = open ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
5134
+ const popover = open && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
5128
5135
  "ul",
5129
5136
  {
5130
5137
  ref: listRef,
@@ -5170,11 +5177,13 @@ function Dropdown({
5170
5177
  {
5171
5178
  ref: triggerRef,
5172
5179
  role: "button",
5173
- tabIndex: 0,
5180
+ tabIndex: disabled ? -1 : 0,
5174
5181
  "aria-haspopup": "listbox",
5175
5182
  "aria-expanded": open,
5183
+ "aria-disabled": disabled,
5176
5184
  "aria-activedescendant": open && items[highlightedIndex] ? `dropdown-option-${items[highlightedIndex].value}` : void 0,
5177
- onClick: () => setOpen((o) => !o),
5185
+ onClick: () => !disabled && setOpen((o) => !o),
5186
+ className: disabled ? "cursor-not-allowed" : void 0,
5178
5187
  children: trigger
5179
5188
  }
5180
5189
  ),