@helpwave/hightide 0.10.1 → 0.10.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.mts CHANGED
@@ -1011,7 +1011,7 @@ interface SelectOptionType<T = string> {
1011
1011
  label?: string;
1012
1012
  display?: ReactNode;
1013
1013
  disabled?: boolean;
1014
- ref: RefObject<HTMLElement>;
1014
+ ref: RefObject<HTMLElement | null>;
1015
1015
  }
1016
1016
  interface SelectContextIds {
1017
1017
  trigger: string;
@@ -1042,8 +1042,8 @@ interface SelectContextActions<T> {
1042
1042
  toggleIsOpen(behavior?: UseSelectFirstHighlightBehavior): void;
1043
1043
  }
1044
1044
  interface SelectContextLayout {
1045
- triggerRef: RefObject<HTMLElement>;
1046
- registerTrigger(element: RefObject<HTMLElement>): () => void;
1045
+ triggerRef: RefObject<HTMLElement | null>;
1046
+ registerTrigger(element: RefObject<HTMLElement | null>): () => void;
1047
1047
  }
1048
1048
  interface SelectContextSearch {
1049
1049
  hasSearch: boolean;
@@ -1065,10 +1065,11 @@ declare const SelectContext: react.Context<SelectContextType<unknown>>;
1065
1065
  declare function useSelectContext<T>(): SelectContextType<T>;
1066
1066
 
1067
1067
  interface SelectButtonProps<T = string> extends ComponentPropsWithoutRef<'div'> {
1068
- placeholder?: ReactNode;
1069
- disabled?: boolean;
1070
- selectedDisplay?: (value: SelectOptionType<T> | null) => ReactNode;
1071
- hideExpansionIcon?: boolean;
1068
+ 'placeholder'?: ReactNode;
1069
+ 'disabled'?: boolean;
1070
+ 'selectedDisplay'?: (value: SelectOptionType<T> | null) => ReactNode;
1071
+ 'hideExpansionIcon'?: boolean;
1072
+ 'data-name'?: string;
1072
1073
  }
1073
1074
  declare const SelectButton: react.ForwardRefExoticComponent<SelectButtonProps<unknown> & react.RefAttributes<HTMLDivElement>>;
1074
1075
 
@@ -2242,7 +2243,7 @@ interface MultiSelectOptionType<T = string> {
2242
2243
  label?: string;
2243
2244
  display?: ReactNode;
2244
2245
  disabled?: boolean;
2245
- ref: RefObject<HTMLElement>;
2246
+ ref: RefObject<HTMLElement | null>;
2246
2247
  }
2247
2248
  interface MultiSelectContextIds {
2248
2249
  trigger: string;
@@ -2274,8 +2275,8 @@ interface MultiSelectContextActions<T> {
2274
2275
  toggleIsOpen(behavior?: UseMultiSelectFirstHighlightBehavior): void;
2275
2276
  }
2276
2277
  interface MultiSelectContextLayout {
2277
- triggerRef: RefObject<HTMLElement>;
2278
- registerTrigger(element: RefObject<HTMLElement>): () => void;
2278
+ triggerRef: RefObject<HTMLElement | null>;
2279
+ registerTrigger(element: RefObject<HTMLElement | null>): () => void;
2279
2280
  }
2280
2281
  interface MultiSelectContextSearch {
2281
2282
  hasSearch: boolean;
@@ -2314,10 +2315,11 @@ interface MultiSelectRootProps<T> extends Partial<FormFieldDataHandling<T[]>>, P
2314
2315
  declare function MultiSelectRoot<T>({ children, value, onValueChange, onEditComplete, initialValue, compareFunction, initialIsOpen, onClose, showSearch, iconAppearance, invalid, disabled, readOnly, required, }: MultiSelectRootProps<T>): react_jsx_runtime.JSX.Element;
2315
2316
 
2316
2317
  interface MultiSelectButtonProps<T = string> extends ComponentPropsWithoutRef<'div'> {
2317
- placeholder?: ReactNode;
2318
- disabled?: boolean;
2319
- selectedDisplay?: (values: T[]) => ReactNode;
2320
- hideExpansionIcon?: boolean;
2318
+ 'placeholder'?: ReactNode;
2319
+ 'disabled'?: boolean;
2320
+ 'selectedDisplay'?: (values: T[]) => ReactNode;
2321
+ 'hideExpansionIcon'?: boolean;
2322
+ 'data-name'?: string;
2321
2323
  }
2322
2324
  declare const MultiSelectButton: react.ForwardRefExoticComponent<MultiSelectButtonProps<unknown> & react.RefAttributes<HTMLDivElement>>;
2323
2325
 
@@ -2336,12 +2338,14 @@ declare const MultiSelect: <T = string>(props: MultiSelectProps<T> & {
2336
2338
  }) => React.ReactElement;
2337
2339
 
2338
2340
  type MultiSelectChipDisplayButtonProps = HTMLAttributes<HTMLDivElement> & {
2339
- disabled?: boolean;
2340
- placeholder?: ReactNode;
2341
+ 'disabled'?: boolean;
2342
+ 'placeholder'?: ReactNode;
2343
+ 'data-name'?: string;
2341
2344
  };
2342
2345
  declare const MultiSelectChipDisplayButton: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
2343
2346
  disabled?: boolean;
2344
2347
  placeholder?: ReactNode;
2348
+ 'data-name'?: string;
2345
2349
  } & react.RefAttributes<HTMLDivElement>>;
2346
2350
  type MultiSelectChipDisplayProps<T = string> = MultiSelectRootProps<T> & {
2347
2351
  contentPanelProps?: MultiSelectContentProps;
package/dist/index.d.ts CHANGED
@@ -1011,7 +1011,7 @@ interface SelectOptionType<T = string> {
1011
1011
  label?: string;
1012
1012
  display?: ReactNode;
1013
1013
  disabled?: boolean;
1014
- ref: RefObject<HTMLElement>;
1014
+ ref: RefObject<HTMLElement | null>;
1015
1015
  }
1016
1016
  interface SelectContextIds {
1017
1017
  trigger: string;
@@ -1042,8 +1042,8 @@ interface SelectContextActions<T> {
1042
1042
  toggleIsOpen(behavior?: UseSelectFirstHighlightBehavior): void;
1043
1043
  }
1044
1044
  interface SelectContextLayout {
1045
- triggerRef: RefObject<HTMLElement>;
1046
- registerTrigger(element: RefObject<HTMLElement>): () => void;
1045
+ triggerRef: RefObject<HTMLElement | null>;
1046
+ registerTrigger(element: RefObject<HTMLElement | null>): () => void;
1047
1047
  }
1048
1048
  interface SelectContextSearch {
1049
1049
  hasSearch: boolean;
@@ -1065,10 +1065,11 @@ declare const SelectContext: react.Context<SelectContextType<unknown>>;
1065
1065
  declare function useSelectContext<T>(): SelectContextType<T>;
1066
1066
 
1067
1067
  interface SelectButtonProps<T = string> extends ComponentPropsWithoutRef<'div'> {
1068
- placeholder?: ReactNode;
1069
- disabled?: boolean;
1070
- selectedDisplay?: (value: SelectOptionType<T> | null) => ReactNode;
1071
- hideExpansionIcon?: boolean;
1068
+ 'placeholder'?: ReactNode;
1069
+ 'disabled'?: boolean;
1070
+ 'selectedDisplay'?: (value: SelectOptionType<T> | null) => ReactNode;
1071
+ 'hideExpansionIcon'?: boolean;
1072
+ 'data-name'?: string;
1072
1073
  }
1073
1074
  declare const SelectButton: react.ForwardRefExoticComponent<SelectButtonProps<unknown> & react.RefAttributes<HTMLDivElement>>;
1074
1075
 
@@ -2242,7 +2243,7 @@ interface MultiSelectOptionType<T = string> {
2242
2243
  label?: string;
2243
2244
  display?: ReactNode;
2244
2245
  disabled?: boolean;
2245
- ref: RefObject<HTMLElement>;
2246
+ ref: RefObject<HTMLElement | null>;
2246
2247
  }
2247
2248
  interface MultiSelectContextIds {
2248
2249
  trigger: string;
@@ -2274,8 +2275,8 @@ interface MultiSelectContextActions<T> {
2274
2275
  toggleIsOpen(behavior?: UseMultiSelectFirstHighlightBehavior): void;
2275
2276
  }
2276
2277
  interface MultiSelectContextLayout {
2277
- triggerRef: RefObject<HTMLElement>;
2278
- registerTrigger(element: RefObject<HTMLElement>): () => void;
2278
+ triggerRef: RefObject<HTMLElement | null>;
2279
+ registerTrigger(element: RefObject<HTMLElement | null>): () => void;
2279
2280
  }
2280
2281
  interface MultiSelectContextSearch {
2281
2282
  hasSearch: boolean;
@@ -2314,10 +2315,11 @@ interface MultiSelectRootProps<T> extends Partial<FormFieldDataHandling<T[]>>, P
2314
2315
  declare function MultiSelectRoot<T>({ children, value, onValueChange, onEditComplete, initialValue, compareFunction, initialIsOpen, onClose, showSearch, iconAppearance, invalid, disabled, readOnly, required, }: MultiSelectRootProps<T>): react_jsx_runtime.JSX.Element;
2315
2316
 
2316
2317
  interface MultiSelectButtonProps<T = string> extends ComponentPropsWithoutRef<'div'> {
2317
- placeholder?: ReactNode;
2318
- disabled?: boolean;
2319
- selectedDisplay?: (values: T[]) => ReactNode;
2320
- hideExpansionIcon?: boolean;
2318
+ 'placeholder'?: ReactNode;
2319
+ 'disabled'?: boolean;
2320
+ 'selectedDisplay'?: (values: T[]) => ReactNode;
2321
+ 'hideExpansionIcon'?: boolean;
2322
+ 'data-name'?: string;
2321
2323
  }
2322
2324
  declare const MultiSelectButton: react.ForwardRefExoticComponent<MultiSelectButtonProps<unknown> & react.RefAttributes<HTMLDivElement>>;
2323
2325
 
@@ -2336,12 +2338,14 @@ declare const MultiSelect: <T = string>(props: MultiSelectProps<T> & {
2336
2338
  }) => React.ReactElement;
2337
2339
 
2338
2340
  type MultiSelectChipDisplayButtonProps = HTMLAttributes<HTMLDivElement> & {
2339
- disabled?: boolean;
2340
- placeholder?: ReactNode;
2341
+ 'disabled'?: boolean;
2342
+ 'placeholder'?: ReactNode;
2343
+ 'data-name'?: string;
2341
2344
  };
2342
2345
  declare const MultiSelectChipDisplayButton: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
2343
2346
  disabled?: boolean;
2344
2347
  placeholder?: ReactNode;
2348
+ 'data-name'?: string;
2345
2349
  } & react.RefAttributes<HTMLDivElement>>;
2346
2350
  type MultiSelectChipDisplayProps<T = string> = MultiSelectRootProps<T> & {
2347
2351
  contentPanelProps?: MultiSelectContentProps;
package/dist/index.js CHANGED
@@ -10353,9 +10353,11 @@ var SelectButton = (0, import_react21.forwardRef)(
10353
10353
  return () => unregister();
10354
10354
  }, [registerTrigger]);
10355
10355
  const disabled = !!disabledOverride || !!context.disabled;
10356
+ const readOnly = !!context.readOnly;
10356
10357
  const invalid = context.invalid;
10357
10358
  const hasValue = context.selectedId !== null;
10358
- const selectedOption = context.idToOptionMap[context.selectedId] ?? null;
10359
+ const hasInteractions = !readOnly && !disabled;
10360
+ const selectedOption = context.selectedId ? context.idToOptionMap[context.selectedId] ?? null : null;
10359
10361
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
10360
10362
  "div",
10361
10363
  {
@@ -10363,12 +10365,13 @@ var SelectButton = (0, import_react21.forwardRef)(
10363
10365
  ref: innerRef,
10364
10366
  id: context.config.ids.trigger,
10365
10367
  onClick: (event) => {
10368
+ if (!hasInteractions) return;
10366
10369
  props.onClick?.(event);
10367
10370
  context.toggleIsOpen();
10368
10371
  },
10369
10372
  onKeyDown: (event) => {
10370
10373
  props.onKeyDown?.(event);
10371
- if (disabled) return;
10374
+ if (!hasInteractions) return;
10372
10375
  switch (event.key) {
10373
10376
  case "Enter":
10374
10377
  case " ":
@@ -10391,16 +10394,18 @@ var SelectButton = (0, import_react21.forwardRef)(
10391
10394
  "data-name": props["data-name"] ?? "select-button",
10392
10395
  "data-value": hasValue ? "" : void 0,
10393
10396
  "data-disabled": disabled ? "" : void 0,
10397
+ "data-readonly": readOnly ? "" : void 0,
10394
10398
  "data-invalid": invalid ? "" : void 0,
10395
10399
  tabIndex: disabled ? -1 : 0,
10396
10400
  role: "button",
10397
10401
  "aria-invalid": invalid,
10398
10402
  "aria-disabled": disabled,
10403
+ "aria-readonly": readOnly,
10399
10404
  "aria-haspopup": "dialog",
10400
10405
  "aria-expanded": context.isOpen,
10401
10406
  "aria-controls": context.isOpen ? context.config.ids.content : void 0,
10402
10407
  children: [
10403
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SelectOptionDisplayContext.Provider, { value: "trigger", children: hasValue ? selectedDisplay?.(selectedOption) ?? selectedOption.display : placeholder ?? translation("clickToSelect") }),
10408
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SelectOptionDisplayContext.Provider, { value: "trigger", children: hasValue ? selectedDisplay?.(selectedOption) ?? selectedOption?.display : placeholder ?? translation("clickToSelect") }),
10404
10409
  !hideExpansionIcon && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ExpansionIcon, { isExpanded: context.isOpen })
10405
10410
  ]
10406
10411
  }
@@ -18867,8 +18872,10 @@ var MultiSelectButton = (0, import_react86.forwardRef)(function MultiSelectButto
18867
18872
  return () => unregister();
18868
18873
  }, [registerTrigger]);
18869
18874
  const disabled = !!disabledOverride || !!context.disabled;
18875
+ const readOnly = !!context.readOnly;
18870
18876
  const invalid = context.invalid;
18871
18877
  const hasValue = context.value.length > 0;
18878
+ const hasInteractions = !readOnly && !disabled;
18872
18879
  const selectedOptions = context.selectedIds.map((id2) => context.idToOptionMap[id2]).filter(Boolean);
18873
18880
  return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
18874
18881
  "div",
@@ -18877,12 +18884,13 @@ var MultiSelectButton = (0, import_react86.forwardRef)(function MultiSelectButto
18877
18884
  ref: innerRef,
18878
18885
  id: context.config.ids.trigger,
18879
18886
  onClick: (event) => {
18887
+ if (!hasInteractions) return;
18880
18888
  props.onClick?.(event);
18881
18889
  context.toggleIsOpen();
18882
18890
  },
18883
18891
  onKeyDown: (event) => {
18884
18892
  props.onKeyDown?.(event);
18885
- if (disabled) return;
18893
+ if (!hasInteractions) return;
18886
18894
  switch (event.key) {
18887
18895
  case "Enter":
18888
18896
  case " ":
@@ -18905,11 +18913,13 @@ var MultiSelectButton = (0, import_react86.forwardRef)(function MultiSelectButto
18905
18913
  "data-name": props["data-name"] ?? "multi-select-button",
18906
18914
  "data-value": hasValue ? "" : void 0,
18907
18915
  "data-disabled": disabled ? "" : void 0,
18916
+ "data-readonly": readOnly ? "" : void 0,
18908
18917
  "data-invalid": invalid ? "" : void 0,
18909
18918
  tabIndex: disabled ? -1 : 0,
18910
18919
  role: "button",
18911
18920
  "aria-invalid": invalid,
18912
18921
  "aria-disabled": disabled,
18922
+ "aria-readonly": readOnly,
18913
18923
  "aria-haspopup": "dialog",
18914
18924
  "aria-expanded": context.isOpen,
18915
18925
  "aria-controls": context.isOpen ? context.config.ids.content : void 0,
@@ -21188,7 +21198,9 @@ var MultiSelectChipDisplayButton = (0, import_react105.forwardRef)(function Mult
21188
21198
  return () => unregister();
21189
21199
  }, [registerTrigger]);
21190
21200
  const disabled = !!props?.disabled || !!context.disabled;
21201
+ const readOnly = !!context.readOnly;
21191
21202
  const invalid = context.invalid;
21203
+ const hasInteractions = !readOnly && !disabled;
21192
21204
  const selectedOptions = context.selectedIds.map((oid) => context.idToOptionMap[oid]).filter(Boolean);
21193
21205
  return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(
21194
21206
  "div",
@@ -21198,14 +21210,17 @@ var MultiSelectChipDisplayButton = (0, import_react105.forwardRef)(function Mult
21198
21210
  onClick: (event) => {
21199
21211
  props.onClick?.(event);
21200
21212
  if (event.defaultPrevented) return;
21213
+ if (!hasInteractions) return;
21201
21214
  context.toggleIsOpen();
21202
21215
  },
21203
21216
  "data-name": props["data-name"] ?? "multi-select-chip-display-button",
21204
21217
  "data-value": context.value.length > 0 ? "" : void 0,
21205
21218
  "data-disabled": disabled ? "" : void 0,
21219
+ "data-readonly": readOnly ? "" : void 0,
21206
21220
  "data-invalid": invalid ? "" : void 0,
21207
21221
  "aria-invalid": invalid,
21208
21222
  "aria-disabled": disabled,
21223
+ "aria-readonly": readOnly,
21209
21224
  children: [
21210
21225
  selectedOptions.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("div", { "data-name": "multi-select-chip-display-chip", children: [
21211
21226
  opt.display,
@@ -21213,6 +21228,7 @@ var MultiSelectChipDisplayButton = (0, import_react105.forwardRef)(function Mult
21213
21228
  IconButton,
21214
21229
  {
21215
21230
  tooltip: translation("remove"),
21231
+ disabled: !hasInteractions,
21216
21232
  onClick: (e) => {
21217
21233
  context.toggleSelection(opt.id, false);
21218
21234
  e.preventDefault();
@@ -21229,11 +21245,14 @@ var MultiSelectChipDisplayButton = (0, import_react105.forwardRef)(function Mult
21229
21245
  IconButton,
21230
21246
  {
21231
21247
  id: context.config.ids.trigger,
21248
+ disabled: !hasInteractions,
21232
21249
  onClick: (event) => {
21233
21250
  event.stopPropagation();
21251
+ if (!hasInteractions) return;
21234
21252
  context.toggleIsOpen();
21235
21253
  },
21236
21254
  onKeyDown: (event) => {
21255
+ if (!hasInteractions) return;
21237
21256
  switch (event.key) {
21238
21257
  case "ArrowDown":
21239
21258
  context.setIsOpen(true, "first");