@uxf/ui 11.33.2 → 11.34.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.
@@ -39,7 +39,7 @@ const MenuButton = (0, react_3.forwardRef)((props, ref) => {
39
39
  const { variant, color, isIconButton, isFullWidth, size, icon, label, className, ...restProps } = props;
40
40
  const anchorProps = (0, use_anchor_props_1.useAnchorProps)({
41
41
  ...restProps,
42
- className: (0, cx_1.cx)("uxf-button-list__menu-button", `uxf-button-list__menu-button--color-${color}`, `uxf-button-list__menu-button--variant-${variant}`, className),
42
+ className: (0, cx_1.cx)("uxf-button-list__menu-button", `uxf-button-list__menu-button--color-${color !== null && color !== void 0 ? color : "default"}`, `uxf-button-list__menu-button--variant-${variant !== null && variant !== void 0 ? variant : "default"}`, className),
43
43
  });
44
44
  return (react_3.default.createElement("a", { ref: ref, ...anchorProps },
45
45
  icon && react_3.default.createElement(icon_1.Icon, { className: "uxf-button-list__menu-button-icon", name: icon }),
@@ -14,18 +14,18 @@ exports.default = {
14
14
  function Default() {
15
15
  const component = (react_1.default.createElement(react_1.default.Fragment, null,
16
16
  react_1.default.createElement(index_1.ButtonList, { buttons: [
17
- { label: "First item" },
18
- { label: "Second item", color: "negative" },
19
- { label: "Third item" },
20
- { label: "Fourth item", isDisabled: true },
21
- { label: "Fifth item" },
22
- { label: "Sixth item" },
17
+ { label: "Default" },
18
+ { label: "Color Negative", color: "negative" },
19
+ { label: "Color Negative", color: "negative", icon: "camera" },
20
+ { label: "Disabled", isDisabled: true },
21
+ { label: "Color Negative disabled", color: "negative", isDisabled: true, icon: "camera" },
22
+ { label: "Sixth item", icon: "camera" },
23
23
  { label: "Seventh item" },
24
24
  { label: "Eighth item" },
25
25
  { label: "Nineth item" },
26
26
  { label: "Tenth item" },
27
27
  { label: "Eleventh item" },
28
- ], menuMaxHeight: 350, variant: "secondary", visibleButtonsCount: 0 }),
28
+ ], classNameDropdown: "w-64", menuMaxHeight: 350, variant: "secondary", visibleButtonsCount: 0 }),
29
29
  react_1.default.createElement(index_1.ButtonList, { buttons: [
30
30
  { label: "First item" },
31
31
  { label: "Second item" },
@@ -57,28 +57,30 @@ function Options(props) {
57
57
  })) : (react_3.default.createElement("div", { className: "uxf-dropdown__empty-wrapper" }, props.emptyMessage))));
58
58
  }
59
59
  Options.displayName = "UxfUiComboboxOptions";
60
+ // eslint-disable-next-line complexity
60
61
  function Combobox(props) {
61
- var _a, _b, _c, _d, _e, _f, _g, _h;
62
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
62
63
  const isAsync = (0, is_not_nil_1.isNotNil)(props.loadOptions);
63
64
  const [query, setQuery] = (0, react_3.useState)("");
64
- const options = (0, use_async_loading_1.useAsyncLoading)(query, (_a = props.options) !== null && _a !== void 0 ? _a : empty_array_1.EMPTY_ARRAY, props.loadOptions);
65
+ const asyncOptions = (0, use_async_loading_1.useAsyncLoading)(query, (_a = props.options) !== null && _a !== void 0 ? _a : empty_array_1.EMPTY_ARRAY, props.loadOptions);
66
+ const options = isAsync ? asyncOptions : ((_b = props.options) !== null && _b !== void 0 ? _b : empty_array_1.EMPTY_ARRAY);
65
67
  const filteredData = (0, is_empty_1.isEmpty)(query) || isAsync ? options : options.filter((item) => (0, slugify_1.slugify)(item.label).includes((0, slugify_1.slugify)(query)));
66
68
  const emptyMessage = (0, is_empty_1.isEmpty)(query)
67
- ? ((_b = props.noQueryMessage) !== null && _b !== void 0 ? _b : "Pro zobrazení možností začněte psát")
69
+ ? ((_c = props.noQueryMessage) !== null && _c !== void 0 ? _c : "Pro zobrazení možností začněte psát")
68
70
  : (0, is_empty_1.isEmpty)(options)
69
- ? ((_c = props.noOptionsMessage) !== null && _c !== void 0 ? _c : "Nabídka neosahuje žádné položky")
70
- : ((_d = props.notFoundMessage) !== null && _d !== void 0 ? _d : "Nic nenalezeno");
71
+ ? ((_d = props.noOptionsMessage) !== null && _d !== void 0 ? _d : "Nabídka neosahuje žádné položky")
72
+ : ((_e = props.notFoundMessage) !== null && _e !== void 0 ? _e : "Nic nenalezeno");
71
73
  const clearQuery = () => setQuery("");
72
74
  const onChange = (v) => props.onChange(v);
73
75
  const onInputChange = (event) => setQuery(event.target.value);
74
76
  const displayValue = (item) => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.label) !== null && _a !== void 0 ? _a : ""; };
75
- const selectedOption = (_e = props.value) !== null && _e !== void 0 ? _e : null;
77
+ const selectedOption = (_f = props.value) !== null && _f !== void 0 ? _f : null;
76
78
  const generatedId = (0, react_3.useId)();
77
- const id = (_f = props.id) !== null && _f !== void 0 ? _f : generatedId;
79
+ const id = (_g = props.id) !== null && _g !== void 0 ? _g : generatedId;
78
80
  const innerRef = (0, react_3.useRef)(null);
79
81
  const errorId = props.isInvalid ? `${id}--error-message` : undefined;
80
82
  const input = (0, use_input_focus_1.useInputFocus)(innerRef, props.onBlur, props.onFocus);
81
- const dropdown = (0, use_dropdown_1.useDropdown)((_g = props.dropdownPlacement) !== null && _g !== void 0 ? _g : "bottom", (_h = props.dropdownMatchesInputWidth) !== null && _h !== void 0 ? _h : true, props.dropdownMaxHeight, props.dropdownStrategy);
83
+ const dropdown = (0, use_dropdown_1.useDropdown)((_h = props.dropdownPlacement) !== null && _h !== void 0 ? _h : "bottom", (_j = props.dropdownMatchesInputWidth) !== null && _j !== void 0 ? _j : true, props.dropdownMaxHeight, props.dropdownStrategy);
82
84
  const stableRef = (0, react_3.useMemo)(() => (0, compose_refs_1.composeRefs)(innerRef, props.inputGroupRef, dropdown.refs.setReference), [dropdown.refs.setReference, props.inputGroupRef]);
83
85
  const isNotInteractive = props.isDisabled || props.isReadOnly;
84
86
  return (react_3.default.createElement(react_2.Combobox, { as: "div", by: "id", className: (0, cx_1.cx)("uxf-form-component uxf-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-name": props.name, disabled: isNotInteractive, form: props.form, name: props.name, onChange: onChange, style: props.style, value: selectedOption }, (renderProps) => (react_3.default.createElement(react_3.default.Fragment, null,
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
7
  const snap_test_1 = require("../utils/snap-test");
8
8
  const combobox_stories_1 = require("./combobox.stories");
9
- (0, snap_test_1.snapTest)("render default stories", react_1.default.createElement(combobox_stories_1.Default, null));
10
- (0, snap_test_1.snapTest)("render async stories", react_1.default.createElement(combobox_stories_1.Async, null));
9
+ (0, snap_test_1.snapTest)("render default stories", react_1.default.createElement(combobox_stories_1.SynchronousOptions, null));
10
+ (0, snap_test_1.snapTest)("render async stories", react_1.default.createElement(combobox_stories_1.AsynchronousOptions, null));
@@ -1,10 +1,3 @@
1
1
  import React from "react";
2
- import { Combobox } from "./index";
3
- declare const _default: {
4
- title: string;
5
- component: typeof Combobox;
6
- };
7
- export default _default;
8
- export declare function Default(): React.JSX.Element;
9
- export declare function Async(): React.JSX.Element;
10
- export declare function ComponentStructure(): React.JSX.Element;
2
+ export declare function SynchronousOptions(): React.JSX.Element;
3
+ export declare function AsynchronousOptions(): React.JSX.Element;
@@ -22,61 +22,34 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Default = Default;
30
- exports.Async = Async;
31
- exports.ComponentStructure = ComponentStructure;
26
+ exports.SynchronousOptions = SynchronousOptions;
27
+ exports.AsynchronousOptions = AsynchronousOptions;
32
28
  const react_1 = __importStar(require("react"));
33
29
  const action_1 = require("../utils/action");
34
- const component_structure_analyzer_1 = __importDefault(require("../utils/component-structure-analyzer"));
35
30
  const index_1 = require("./index");
36
- exports.default = {
37
- title: "UI/Combobox",
38
- component: index_1.Combobox,
39
- };
40
- const options = [
31
+ const OPTIONS = [
41
32
  { id: "one", label: "Option one" },
42
33
  { id: "two", label: "Option two disabled", disabled: true },
43
34
  { id: "three", label: "Option three" },
44
35
  { id: "four", label: "Option with diacritics (ěščřžýáíé)" },
45
36
  ];
46
- function Default() {
37
+ function SynchronousOptions() {
47
38
  const [value, setValue] = (0, react_1.useState)(null);
48
- const onChange = (0, action_1.action)("onChange", (v) => {
49
- // eslint-disable-next-line no-console
50
- console.log("Select value: ", v);
51
- setValue(v);
52
- });
53
- const storyComboboxes = (react_1.default.createElement("div", { className: "space-y-8" },
54
- react_1.default.createElement(index_1.Combobox, { id: "combobox-1", label: "Combobox", name: "combobox", onChange: onChange, options: options, placeholder: "Vyberte...", value: value }),
55
- react_1.default.createElement(index_1.Combobox, { helperText: "Start typing to see options...", id: "combobox-1", label: "Combobox with helper text", name: "combobox", onChange: onChange, options: options, placeholder: "Vyberte...", value: value }),
56
- react_1.default.createElement(index_1.Combobox, { helperText: "Error message", id: "combobox-1", isInvalid: true, isRequired: true, label: "Combobox invalid", name: "combobox", onChange: onChange, options: options, placeholder: "Vyberte...", value: value }),
57
- react_1.default.createElement(index_1.Combobox, { dropdownPlacement: "top", id: "combobox-1", isClearable: true, label: "Combobox with dropdown top", name: "combobox", onChange: onChange, options: options, placeholder: "Vyberte...", value: value }),
58
- react_1.default.createElement(index_1.Combobox, { id: "combobox-render", isClearable: true, label: "RenderOption", name: "combobox", onChange: onChange, options: options, placeholder: "Vyberte...", renderOption: (option, isSelected) => (react_1.default.createElement(react_1.default.Fragment, null,
39
+ const onChange = (0, action_1.action)("onChange", setValue);
40
+ return (react_1.default.createElement("div", { className: "space-y-4 p-4" },
41
+ react_1.default.createElement(index_1.Combobox, { helperText: "Start typing to see options...", id: "combobox-1", label: "Combobox", name: "combobox", onChange: onChange, options: OPTIONS, placeholder: "Vyberte...", value: value }),
42
+ react_1.default.createElement(index_1.Combobox, { helperText: "Error message", id: "combobox-1", isInvalid: true, isRequired: true, label: "Combobox invalid", name: "combobox", onChange: onChange, options: OPTIONS, placeholder: "Vyberte...", value: value }),
43
+ react_1.default.createElement(index_1.Combobox, { dropdownPlacement: "top", id: "combobox-1", isClearable: true, label: "Combobox with dropdown top", name: "combobox", onChange: onChange, options: OPTIONS, placeholder: "Vyberte...", value: value }),
44
+ react_1.default.createElement(index_1.Combobox, { id: "combobox-render", isClearable: true, label: "RenderOption", name: "combobox", onChange: onChange, options: OPTIONS, placeholder: "Vyberte...", renderOption: (option, isSelected) => (react_1.default.createElement(react_1.default.Fragment, null,
59
45
  "Option: ",
60
46
  option.label,
61
47
  isSelected && " (selected)")), value: value })));
62
- return (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
63
- react_1.default.createElement("div", { className: "space-y-2 p-20 lg:w-1/2" }, storyComboboxes)));
64
48
  }
65
- function Async() {
49
+ function AsynchronousOptions() {
66
50
  const [value, setValue] = (0, react_1.useState)(null);
67
- const onChange = (0, action_1.action)("onChange", (v) => {
68
- // eslint-disable-next-line no-console
69
- console.log("Select value: ", v);
70
- setValue(v);
71
- });
72
- const loadOptions = (query) => Promise.resolve(options.filter((option) => !query || option.label.toLowerCase().includes(query.toLowerCase())));
73
- const storyComboboxes = (react_1.default.createElement("div", { className: "space-y-8" },
51
+ const onChange = (0, action_1.action)("onChange", setValue);
52
+ const loadOptions = (query) => Promise.resolve(OPTIONS.filter((option) => !query || option.label.toLowerCase().includes(query.toLowerCase())));
53
+ return (react_1.default.createElement("div", { className: "p-4" },
74
54
  react_1.default.createElement(index_1.Combobox, { id: "combobox-1", label: "Combobox", loadOptions: loadOptions, name: "combobox", onChange: onChange, placeholder: "Vyberte...", value: value })));
75
- return (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
76
- react_1.default.createElement("div", { className: "space-y-2 p-20 lg:w-1/2" }, storyComboboxes)));
77
- }
78
- function ComponentStructure() {
79
- const [value, onChange] = (0, react_1.useState)(null);
80
- return (react_1.default.createElement(component_structure_analyzer_1.default, null,
81
- react_1.default.createElement(index_1.Combobox, { helperText: "Start typing to see options...", id: "combobox-structure", label: "Combobox with helper text", name: "combobox", onChange: onChange, options: options, value: value })));
82
55
  }
@@ -63,8 +63,16 @@
63
63
  &.is-disabled {
64
64
  color: theme("colors.lightLow");
65
65
 
66
+ .uxf-button-list__menu-button-icon {
67
+ color: theme("colors.lightLow");
68
+ }
69
+
66
70
  :root .dark & {
67
71
  color: theme("colors.darkLow");
72
+
73
+ .uxf-button-list__menu-button-icon {
74
+ color: theme("colors.darkLow");
75
+ }
68
76
  }
69
77
  }
70
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/ui",
3
- "version": "11.33.2",
3
+ "version": "11.34.1",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"