@uxf/ui 11.122.0 → 11.122.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.
@@ -1,3 +1,3 @@
1
- import React from "react";
2
- import { CheckboxListProps, CheckboxListValueId } from "./types";
3
- export declare const CheckboxList: React.ForwardRefExoticComponent<CheckboxListProps<CheckboxListValueId, import("./types").CheckboxListOption<CheckboxListValueId>> & React.RefAttributes<HTMLDivElement>>;
1
+ import { ReactElement, RefAttributes } from "react";
2
+ import { CheckboxListOption, CheckboxListProps, CheckboxListValueId } from "./types";
3
+ export declare const CheckboxList: <ValueId extends CheckboxListValueId = CheckboxListValueId, Option extends CheckboxListOption<ValueId> = CheckboxListOption<ValueId>>(props: CheckboxListProps<ValueId, Option> & RefAttributes<HTMLDivElement>) => ReactElement | null;
@@ -40,7 +40,7 @@ const cx_1 = require("@uxf/core/utils/cx");
40
40
  const react_1 = __importStar(require("react"));
41
41
  const checkbox_input_1 = require("../checkbox-input");
42
42
  const form_component_1 = require("../form-component");
43
- exports.CheckboxList = (0, react_1.forwardRef)((props, ref) => {
43
+ function CheckboxListInner(props, ref) {
44
44
  const generatedId = (0, react_1.useId)();
45
45
  const id = props.id || generatedId;
46
46
  const errorId = props.isInvalid && props.id ? `${props.id}--errormessage` : undefined;
@@ -58,5 +58,6 @@ exports.CheckboxList = (0, react_1.forwardRef)((props, ref) => {
58
58
  return (react_1.default.createElement("li", { key: option.id },
59
59
  react_1.default.createElement(checkbox_input_1.CheckboxInput, { id: `${id}-${option.id}`, isDisabled: option.isDisabled || props.isDisabled, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, key: option.id, label: option.label, name: props.name, onBlur: props.onBlur, onChange: (value) => onChange(option.id, value || false), onFocus: props.onFocus, value: (_a = props.value) === null || _a === void 0 ? void 0 : _a.includes(option.id) })));
60
60
  }))));
61
- });
61
+ }
62
+ exports.CheckboxList = (0, react_1.forwardRef)(CheckboxListInner);
62
63
  exports.CheckboxList.displayName = "UxfUiCheckboxList";
@@ -1,12 +1,12 @@
1
1
  import { ReactNode } from "react";
2
2
  import { FormControlProps } from "../types";
3
3
  export type CheckboxListValueId = number | string;
4
- export type CheckboxListOption<T = CheckboxListValueId> = {
4
+ export type CheckboxListOption<T extends CheckboxListValueId> = {
5
5
  isDisabled?: boolean;
6
6
  id: T;
7
7
  label: ReactNode;
8
8
  };
9
- export interface CheckboxListProps<ValueId = CheckboxListValueId, Option = CheckboxListOption<ValueId>> extends FormControlProps<ValueId[] | null> {
9
+ export interface CheckboxListProps<ValueId extends CheckboxListValueId = CheckboxListValueId, Option extends CheckboxListOption<ValueId> = CheckboxListOption<ValueId>> extends FormControlProps<ValueId[] | null> {
10
10
  className?: string;
11
11
  label: ReactNode;
12
12
  hasHiddenLabel?: boolean;
@@ -1,4 +1,4 @@
1
- import React from "react";
2
- import { MultiComboboxOption, MultiComboboxProps, MultiComboboxValueId } from "./types";
1
+ import { ReactElement, RefAttributes } from "react";
2
+ import { MultiComboboxOption, MultiComboboxProps, MultiComboboxRef, MultiComboboxValueId } from "./types";
3
3
  export declare const MULTI_COMBOBOX_COMPONENT_NAME = "multiCombobox";
4
- export declare const MultiCombobox: React.ForwardRefExoticComponent<MultiComboboxProps<MultiComboboxValueId, MultiComboboxOption<MultiComboboxValueId>> & React.RefAttributes<HTMLInputElement>>;
4
+ export declare const MultiCombobox: <ValueId extends MultiComboboxValueId = MultiComboboxValueId, Option extends MultiComboboxOption<ValueId> = MultiComboboxOption<ValueId>>(props: MultiComboboxProps<ValueId, Option> & RefAttributes<MultiComboboxRef>) => ReactElement | null;
@@ -101,7 +101,7 @@ function useMultiComboboxOptions(query, props) {
101
101
  };
102
102
  }
103
103
  exports.MULTI_COMBOBOX_COMPONENT_NAME = "multiCombobox";
104
- exports.MultiCombobox = (0, react_3.forwardRef)((props, ref) => {
104
+ function MultiComboboxInner(props, ref) {
105
105
  var _a, _b, _c, _d, _e, _f, _g;
106
106
  const t = (0, translations_1.useUxfTranslation)();
107
107
  const generatedId = (0, react_3.useId)();
@@ -161,7 +161,7 @@ exports.MultiCombobox = (0, react_3.forwardRef)((props, ref) => {
161
161
  (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
162
162
  };
163
163
  const isNotInteractive = props.isDisabled || props.isReadOnly;
164
- return (react_3.default.createElement(react_2.Combobox, { as: "div", by: "id", className: (0, cx_1.cx)("uxf-form-component uxf-multi-combobox", props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isRequired && classes_1.CLASSES.IS_REQUIRED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.className), "data-component": exports.MULTI_COMBOBOX_COMPONENT_NAME, "data-name": props.name, disabled: isNotInteractive, form: props.form, multiple: true, name: props.name, onChange: changeHandler, style: props.style, value: selectedOptions }, (renderProps) => {
164
+ return (react_3.default.createElement(react_2.Combobox, { as: "div", by: (a, b) => a.id === b.id, className: (0, cx_1.cx)("uxf-form-component uxf-multi-combobox", props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isRequired && classes_1.CLASSES.IS_REQUIRED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.className), "data-component": exports.MULTI_COMBOBOX_COMPONENT_NAME, "data-name": props.name, disabled: isNotInteractive, form: props.form, multiple: true, name: props.name, onChange: changeHandler, style: props.style, value: selectedOptions }, (renderProps) => {
165
165
  var _a, _b;
166
166
  return (react_3.default.createElement(react_3.default.Fragment, null,
167
167
  react_3.default.createElement("div", { className: "uxf-form-component__label" },
@@ -181,5 +181,6 @@ exports.MultiCombobox = (0, react_3.forwardRef)((props, ref) => {
181
181
  react_3.default.createElement(show_1.Show, { when: Boolean(props.helperText) },
182
182
  react_3.default.createElement("div", { className: (0, cx_1.cx)("uxf-helper-text", props.isInvalid && classes_1.CLASSES.IS_INVALID), id: errorId }, props.helperText)))));
183
183
  }));
184
- });
184
+ }
185
+ exports.MultiCombobox = (0, react_3.forwardRef)(MultiComboboxInner);
185
186
  exports.MultiCombobox.displayName = "UxfUiMultiCombobox";
@@ -5,15 +5,15 @@ import { ChipColor } from "../chip";
5
5
  import { IconName } from "../icon/types";
6
6
  import { FormControlProps } from "../types";
7
7
  export type MultiComboboxValueId = number | string;
8
- export type MultiComboboxValue<ValueId = MultiComboboxValueId> = {
8
+ export type MultiComboboxValue<ValueId extends MultiComboboxValueId> = {
9
9
  id: ValueId;
10
10
  label: string;
11
11
  };
12
- export interface MultiComboboxOption<ValueId = MultiComboboxValueId> extends MultiComboboxValue<ValueId> {
12
+ export interface MultiComboboxOption<ValueId extends MultiComboboxValueId> extends MultiComboboxValue<ValueId> {
13
13
  color?: ChipColor;
14
14
  disabled?: boolean;
15
15
  }
16
- export interface MultiComboboxProps<ValueId = MultiComboboxValueId, Option = MultiComboboxOption<ValueId>> extends FormControlProps<Option[] | null> {
16
+ export interface MultiComboboxProps<ValueId extends MultiComboboxValueId = MultiComboboxValueId, Option extends MultiComboboxOption<ValueId> = MultiComboboxOption<ValueId>> extends FormControlProps<Option[] | null> {
17
17
  allOptionsSelectedMessage?: string;
18
18
  className?: string;
19
19
  dropdownClassName?: string;
@@ -1,4 +1,5 @@
1
- import React from "react";
2
- import { MultiSelectOption, MultiSelectProps } from "./types";
1
+ import { SelectableId } from "@uxf/core/types";
2
+ import { ReactElement, RefAttributes } from "react";
3
+ import { MultiSelectOption, MultiSelectProps, MultiSelectTypeRef } from "./types";
3
4
  export declare const MULTI_SELECT_COMPONENT_NAME = "multiSelect";
4
- export declare const MultiSelect: React.ForwardRefExoticComponent<MultiSelectProps<import("@uxf/core/types").SelectableId, MultiSelectOption<import("@uxf/core/types").SelectableId>> & React.RefAttributes<HTMLDivElement>>;
5
+ export declare const MultiSelect: <ValueId extends SelectableId = SelectableId, Option extends MultiSelectOption<ValueId> = MultiSelectOption<ValueId>>(props: MultiSelectProps<ValueId, Option> & RefAttributes<MultiSelectTypeRef>) => ReactElement | null;
@@ -83,7 +83,7 @@ function Options(props) {
83
83
  }
84
84
  Options.displayName = "UxfUiMultiSelectOptions";
85
85
  exports.MULTI_SELECT_COMPONENT_NAME = "multiSelect";
86
- exports.MultiSelect = (0, react_3.forwardRef)((props, ref) => {
86
+ function MultiSelectInner(props, ref) {
87
87
  var _a, _b, _c, _d, _e, _f;
88
88
  const t = (0, translations_1.useUxfTranslation)();
89
89
  const generatedId = (0, react_3.useId)();
@@ -146,5 +146,6 @@ exports.MultiSelect = (0, react_3.forwardRef)((props, ref) => {
146
146
  react_3.default.createElement(show_1.Show, { when: Boolean(props.helperText) },
147
147
  react_3.default.createElement("div", { className: (0, cx_1.cx)("uxf-helper-text", props.isInvalid && classes_1.CLASSES.IS_INVALID), id: errorId }, props.helperText)))));
148
148
  }));
149
- });
149
+ }
150
+ exports.MultiSelect = (0, react_3.forwardRef)(MultiSelectInner);
150
151
  exports.MultiSelect.displayName = "UxfUiMultiSelect";
@@ -80,8 +80,8 @@ function OnlyForE2ETests() {
80
80
  const [value, setValue] = (0, react_1.useState)(null);
81
81
  const [partialValue, setPartialValue] = (0, react_1.useState)(null);
82
82
  return (react_1.default.createElement("div", { className: "space-y-4 p-8" },
83
- react_1.default.createElement(multi_select_1.MultiSelect, { label: "Stav", name: "stav", onChange: (v) => setValue(v), options: e2eOptions, placeholder: "Vyberte...", value: value }),
83
+ react_1.default.createElement(multi_select_1.MultiSelect, { label: "Stav", name: "stav", onChange: setValue, options: e2eOptions, placeholder: "Vyberte...", value: value }),
84
84
  value !== null && react_1.default.createElement("div", { "data-testid": "selected-value" }, value.join(",")),
85
- react_1.default.createElement(multi_select_1.MultiSelect, { label: "Stav (partial)", name: "stav-partial", onChange: (v) => setPartialValue(v), options: e2ePartialOptions, placeholder: "Vyberte...", value: partialValue }),
85
+ react_1.default.createElement(multi_select_1.MultiSelect, { label: "Stav (partial)", name: "stav-partial", onChange: setPartialValue, options: e2ePartialOptions, placeholder: "Vyberte...", value: partialValue }),
86
86
  partialValue !== null && react_1.default.createElement("div", { "data-testid": "selected-partial-value" }, partialValue.join(","))));
87
87
  }
@@ -8,13 +8,13 @@ import { FormControlProps } from "../types";
8
8
  /** @deprecated use import { SelectableId } from "@uxf/core/types" */
9
9
  export type MultiSelectValueId = SelectableId;
10
10
  export type MultiSelectValue<T extends SelectableId> = T[] | null;
11
- export type MultiSelectOption<T = SelectableId> = {
11
+ export type MultiSelectOption<T extends SelectableId> = {
12
12
  color?: ChipColor;
13
13
  disabled?: boolean;
14
14
  id: T;
15
15
  label: ReactNode;
16
16
  };
17
- export interface MultiSelectProps<ValueId extends SelectableId = SelectableId, Option = MultiSelectOption<ValueId>> extends FormControlProps<MultiSelectValue<ValueId>> {
17
+ export interface MultiSelectProps<ValueId extends SelectableId = SelectableId, Option extends MultiSelectOption<ValueId> = MultiSelectOption<ValueId>> extends FormControlProps<MultiSelectValue<ValueId>> {
18
18
  allOptionsSelectedMessage?: string;
19
19
  className?: string;
20
20
  dropdownClassName?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/ui",
3
- "version": "11.122.0",
3
+ "version": "11.122.1",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,24 +1,24 @@
1
1
  import { RadioSize } from "@uxf/ui/radio";
2
2
  import { RadioGroupVariant } from "@uxf/ui/radio-group/theme";
3
- import React, { CSSProperties, ReactNode } from "react";
3
+ import { CSSProperties, ReactElement, ReactNode, RefAttributes } from "react";
4
4
  import { FormControlProps } from "../types";
5
5
  export type RadioGroupOptionValueId = string | number;
6
- export interface RadioGroupOption {
6
+ export interface RadioGroupOption<ValueId extends RadioGroupOptionValueId> {
7
7
  disabled?: boolean;
8
- id: RadioGroupOptionValueId;
8
+ id: ValueId;
9
9
  label: ReactNode;
10
10
  }
11
- export interface RadioGroupProps extends FormControlProps<RadioGroupOptionValueId | null> {
11
+ export interface RadioGroupProps<ValueId extends RadioGroupOptionValueId = RadioGroupOptionValueId, Option extends RadioGroupOption<ValueId> = RadioGroupOption<ValueId>> extends FormControlProps<ValueId | null> {
12
12
  className?: string;
13
13
  helperText?: ReactNode;
14
14
  forceColumn?: boolean;
15
15
  hiddenLabel?: boolean;
16
16
  id?: string;
17
17
  label: ReactNode;
18
- options: RadioGroupOption[];
18
+ options: Option[];
19
19
  radioSize?: RadioSize;
20
20
  style?: CSSProperties;
21
21
  variant?: RadioGroupVariant;
22
22
  }
23
23
  export declare const RADIO_GROUP_COMPONENT_NAME = "radioGroup";
24
- export declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLLabelElement>>;
24
+ export declare const RadioGroup: <ValueId extends RadioGroupOptionValueId = RadioGroupOptionValueId, Option extends RadioGroupOption<ValueId> = RadioGroupOption<ValueId>>(props: RadioGroupProps<ValueId, Option> & RefAttributes<HTMLLabelElement>) => ReactElement | null;
@@ -42,7 +42,7 @@ const react_2 = __importStar(require("react"));
42
42
  const use_input_submit_1 = require("../hooks/use-input-submit");
43
43
  const label_1 = require("../label");
44
44
  exports.RADIO_GROUP_COMPONENT_NAME = "radioGroup";
45
- exports.RadioGroup = (0, react_2.forwardRef)((props, ref) => {
45
+ function RadioGroupInner(props, ref) {
46
46
  var _a, _b;
47
47
  const innerRef = (0, react_2.useRef)(null);
48
48
  (0, use_input_submit_1.useInputSubmit)(innerRef, "radio-group", props.isDisabled);
@@ -58,5 +58,6 @@ exports.RadioGroup = (0, react_2.forwardRef)((props, ref) => {
58
58
  react_2.default.createElement("span", { className: "uxf-radio-group__option-label" }, option.label),
59
59
  react_2.default.createElement(radio_1.Radio, { checked: o.checked, isDisabled: props.isDisabled || o.disabled, isInvalid: props.isInvalid, name: props.name, ref: o.checked ? innerRef : undefined, size: radioSize, value: option.id }))))))),
60
60
  props.helperText && (react_2.default.createElement("div", { className: (0, cx_1.cx)("uxf-helper-text", props.isInvalid && classes_1.CLASSES.IS_INVALID), id: errorId }, props.helperText)))));
61
- });
61
+ }
62
+ exports.RadioGroup = (0, react_2.forwardRef)(RadioGroupInner);
62
63
  exports.RadioGroup.displayName = "UxfUiRadioGroup";