@uxf/ui 1.0.0-beta.115 → 1.0.0-beta.117

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/button/button.js CHANGED
@@ -15,7 +15,5 @@ exports.Button = (0, forwardRef_1.forwardRef)("Button", (props, ref) => {
15
15
  ...restProps,
16
16
  className: (0, cx_1.cx)("uxf-button", `uxf-button--color-${color !== null && color !== void 0 ? color : "default"}`, `uxf-button--size-${size !== null && size !== void 0 ? size : "default"}`, `uxf-button--variant-${variant !== null && variant !== void 0 ? variant : "default"}`, isIconButton && "uxf-button--icon-button", isFullWidth && "uxf-button--full-width", className),
17
17
  });
18
- return (react_1.default.createElement("a", { ref: ref, ...anchorProps },
19
- typeof props.children === "string" ? (react_1.default.createElement("span", { className: "uxf-button__text" }, props.children)) : (props.children),
20
- react_1.default.createElement("div", { className: "loader" })));
18
+ return (react_1.default.createElement("a", { ref: ref, ...anchorProps }, typeof props.children === "string" ? (react_1.default.createElement("span", { className: "uxf-button__text" }, props.children)) : (props.children)));
21
19
  });
@@ -0,0 +1,19 @@
1
+ import { FC, ReactNode } from "react";
2
+ import { ButtonProps } from "../button";
3
+ import { IconName } from "../icon/types";
4
+ import { Placement } from "@floating-ui/react";
5
+ declare type SingleButtonProps = Omit<ButtonProps, "children"> & {
6
+ icon?: IconName | null;
7
+ label?: ReactNode;
8
+ };
9
+ export interface ButtonGroupProps {
10
+ buttons: SingleButtonProps[];
11
+ openButton?: SingleButtonProps;
12
+ visibleButtonsCount: number;
13
+ color?: ButtonProps["color"];
14
+ size?: ButtonProps["size"];
15
+ variant?: ButtonProps["variant"];
16
+ menuPlacement?: Placement;
17
+ }
18
+ export declare const ButtonList: FC<ButtonGroupProps>;
19
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ButtonList = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const react_2 = require("@headlessui/react");
9
+ const button_1 = require("../button");
10
+ const cx_1 = require("@uxf/core/utils/cx");
11
+ const icon_1 = require("../icon");
12
+ const useAnchorProps_1 = require("@uxf/core/hooks/useAnchorProps");
13
+ const use_dropdown_1 = require("../hooks/use-dropdown");
14
+ const MenuButton = (props) => {
15
+ // eslint-disable-next-line react/destructuring-assignment,@typescript-eslint/no-unused-vars
16
+ const { variant, color, isIconButton, isFullWidth, size, icon, label, className, ...restProps } = props;
17
+ const anchorProps = (0, useAnchorProps_1.useAnchorProps)({
18
+ ...restProps,
19
+ className: (0, cx_1.cx)("uxf-button-list__menu-button", className),
20
+ });
21
+ return (react_1.default.createElement("a", { ...anchorProps },
22
+ icon && react_1.default.createElement(icon_1.Icon, { name: icon, className: "uxf-button-list__menu-button-icon" }),
23
+ label && react_1.default.createElement("span", { className: "uxf-button-list__menu-button-label" }, label)));
24
+ };
25
+ const ButtonList = (props) => {
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
27
+ const buttonsToRender = props.buttons.slice(0, props.visibleButtonsCount);
28
+ const restButtons = props.buttons.slice(props.visibleButtonsCount, props.buttons.length);
29
+ const openButtonIcon = ((_a = props.openButton) === null || _a === void 0 ? void 0 : _a.icon) === null ? null : (_c = (_b = props.openButton) === null || _b === void 0 ? void 0 : _b.icon) !== null && _c !== void 0 ? _c : "ellipsis-vertical";
30
+ const openButtonLabel = (_e = (_d = props.openButton) === null || _d === void 0 ? void 0 : _d.label) !== null && _e !== void 0 ? _e : null;
31
+ const dropdown = (0, use_dropdown_1.useDropdown)((_f = props.menuPlacement) !== null && _f !== void 0 ? _f : "bottom-start");
32
+ return (react_1.default.createElement("div", { className: "uxf-button-list" },
33
+ buttonsToRender.map((button, index) => {
34
+ var _a, _b, _c;
35
+ const { icon, label, ...restProps } = button;
36
+ return (react_1.default.createElement(button_1.Button, { key: index, ...restProps, color: (_a = restProps.color) !== null && _a !== void 0 ? _a : props.color, size: (_b = restProps.size) !== null && _b !== void 0 ? _b : props.size, variant: (_c = restProps.variant) !== null && _c !== void 0 ? _c : props.variant, className: (0, cx_1.cx)(restProps.className, "uxf-button-list__button") },
37
+ icon && react_1.default.createElement(icon_1.Icon, { name: icon, className: "uxf-button-list__button-icon" }),
38
+ label && react_1.default.createElement("span", { className: "uxf-button-list__button-label" }, label)));
39
+ }),
40
+ restButtons.length > 0 && (react_1.default.createElement(react_2.Menu, { as: "div", className: "uxf-button-list__menu" },
41
+ react_1.default.createElement(react_2.Menu.Button, { as: button_1.Button, ...props.openButton, color: (_h = (_g = props.openButton) === null || _g === void 0 ? void 0 : _g.color) !== null && _h !== void 0 ? _h : props.color, size: (_k = (_j = props.openButton) === null || _j === void 0 ? void 0 : _j.size) !== null && _k !== void 0 ? _k : props.size, variant: (_m = (_l = props.openButton) === null || _l === void 0 ? void 0 : _l.variant) !== null && _m !== void 0 ? _m : props.variant, className: (0, cx_1.cx)((_o = props.openButton) === null || _o === void 0 ? void 0 : _o.className, "uxf-button-list__open-button"), isIconButton: !!openButtonIcon && !openButtonLabel, ref: dropdown.reference },
42
+ openButtonIcon && react_1.default.createElement(icon_1.Icon, { name: openButtonIcon, className: "uxf-button-list__open-button-icon" }),
43
+ openButtonLabel && (react_1.default.createElement("span", { className: "uxf-button-list__open-button-label" }, openButtonLabel))),
44
+ react_1.default.createElement(react_2.Menu.Items, { className: "uxf-button-list__menu-items", ref: dropdown.floating }, restButtons.map((button, index) => {
45
+ var _a, _b, _c;
46
+ return (react_1.default.createElement(react_2.Menu.Item, { key: index },
47
+ react_1.default.createElement(MenuButton, { ...button, color: (_a = button.color) !== null && _a !== void 0 ? _a : props.color, size: (_b = button.size) !== null && _b !== void 0 ? _b : props.size, variant: (_c = button.variant) !== null && _c !== void 0 ? _c : props.variant })));
48
+ }))))));
49
+ };
50
+ exports.ButtonList = ButtonList;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ declare const _default: {
3
+ title: string;
4
+ component: React.FC<import("./button-list").ButtonGroupProps>;
5
+ };
6
+ export default _default;
7
+ export declare const Default: () => JSX.Element;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Default = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const index_1 = require("./index");
9
+ exports.default = {
10
+ title: "UI/ButtonList",
11
+ component: index_1.ButtonList,
12
+ };
13
+ const Default = () => {
14
+ const component = (react_1.default.createElement(react_1.default.Fragment, null,
15
+ react_1.default.createElement(index_1.ButtonList, { visibleButtonsCount: 0, variant: "outlined", buttons: [
16
+ { label: "First item" },
17
+ { label: "Second item" },
18
+ { label: "Third item" },
19
+ { label: "Fourth item", disabled: true },
20
+ ] }),
21
+ react_1.default.createElement(index_1.ButtonList, { visibleButtonsCount: 4, variant: "white", buttons: [
22
+ { label: "First item" },
23
+ { label: "Second item" },
24
+ { label: "Third item" },
25
+ { label: "Fourth item" },
26
+ ] }),
27
+ react_1.default.createElement(index_1.ButtonList, { visibleButtonsCount: 2, buttons: [
28
+ // eslint-disable-next-line no-console
29
+ { label: "First item", onClick: console.log },
30
+ { label: "Second item", color: "success" },
31
+ { label: "Third item" },
32
+ // eslint-disable-next-line no-console
33
+ { label: "Fourth item", onClick: console.log },
34
+ ] }),
35
+ react_1.default.createElement(index_1.ButtonList, { visibleButtonsCount: 1, size: "xs", color: "error", variant: "outlined", buttons: [
36
+ // eslint-disable-next-line no-console
37
+ { icon: "check", label: "First item", onClick: console.log },
38
+ { icon: "user", label: "Second item", color: "success" },
39
+ { icon: "cloud", label: "Third item" },
40
+ // eslint-disable-next-line no-console
41
+ { icon: "xmarkLarge", label: "Fourth item", onClick: console.log },
42
+ ], openButton: {} }),
43
+ react_1.default.createElement(index_1.ButtonList, { visibleButtonsCount: 3, size: "xs", color: "success", buttons: [
44
+ // eslint-disable-next-line no-console
45
+ { icon: "check", label: "First item", onClick: console.log, color: "error" },
46
+ { icon: "user", label: "Second item", color: "success", size: "default" },
47
+ { icon: "cloud", label: "Third item" },
48
+ // eslint-disable-next-line no-console
49
+ { icon: "xmarkLarge", label: "Fourth item", onClick: console.log },
50
+ ], openButton: { variant: "outlined", color: "default" } })));
51
+ return (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
52
+ react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, component),
53
+ react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, component)));
54
+ };
55
+ exports.Default = Default;
@@ -0,0 +1 @@
1
+ export { ButtonList, ButtonGroupProps } from "./button-list";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ButtonList = void 0;
4
+ var button_list_1 = require("./button-list");
5
+ Object.defineProperty(exports, "ButtonList", { enumerable: true, get: function () { return button_list_1.ButtonList; } });
@@ -9,10 +9,10 @@ const forwardRef_1 = require("@uxf/core/utils/forwardRef");
9
9
  const react_2 = __importDefault(require("react"));
10
10
  const checkbox_visual_1 = require("../checkbox-visual");
11
11
  exports.Checkbox = (0, forwardRef_1.forwardRef)("Checkbox", (props, ref) => {
12
- var _a;
12
+ var _a, _b, _c;
13
13
  return (react_2.default.createElement(react_1.Switch.Group, null,
14
14
  react_2.default.createElement("div", { className: `uxf-checkbox__wrapper ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
15
- react_2.default.createElement(react_1.Switch, { checked: props.value, className: "uxf-checkbox-visual-wrapper", disabled: props.isDisabled, name: props.name, onChange: props.onChange, ref: ref, style: props.style },
16
- react_2.default.createElement(checkbox_visual_1.CheckboxVisual, { indeterminate: props.indeterminate, isDisabled: props.isDisabled, isFocused: props.isFocused, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, size: props.size, value: props.value })),
15
+ react_2.default.createElement(react_1.Switch, { checked: (_b = props.value) !== null && _b !== void 0 ? _b : false, className: "uxf-checkbox-visual-wrapper", disabled: props.isDisabled, name: props.name, onChange: props.onChange, ref: ref, style: props.style },
16
+ react_2.default.createElement(checkbox_visual_1.CheckboxVisual, { indeterminate: props.indeterminate, isDisabled: props.isDisabled, isFocused: props.isFocused, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, size: props.size, value: (_c = props.value) !== null && _c !== void 0 ? _c : false })),
17
17
  react_2.default.createElement(react_1.Switch.Label, { className: "uxf-checkbox__label" }, props.label))));
18
18
  });
@@ -1,7 +1,7 @@
1
1
  import { Placement } from "@floating-ui/react";
2
+ import { IconsSet } from "@uxf/ui/icon/theme";
3
+ import { FormControlProps } from "@uxf/ui/types";
2
4
  import React, { ReactNode } from "react";
3
- import { IconsSet } from "../icon/theme";
4
- import { FormControlProps } from "../types";
5
5
  export declare type ComboboxValueId = number | string;
6
6
  export declare type ComboboxValue<ValueId = ComboboxValueId> = {
7
7
  id: ValueId;
@@ -31,11 +31,12 @@ const composeRefs_1 = require("@uxf/core/utils/composeRefs");
31
31
  const cx_1 = require("@uxf/core/utils/cx");
32
32
  const forwardRef_1 = require("@uxf/core/utils/forwardRef");
33
33
  const slugify_1 = require("@uxf/core/utils/slugify");
34
+ const use_async_loading_1 = require("@uxf/ui/hooks/use-async-loading");
35
+ const use_dropdown_1 = require("@uxf/ui/hooks/use-dropdown");
36
+ const icon_1 = require("@uxf/ui/icon");
37
+ const input_1 = require("@uxf/ui/input");
38
+ const label_1 = require("@uxf/ui/label");
34
39
  const react_2 = __importStar(require("react"));
35
- const use_dropdown_1 = require("../hooks/use-dropdown");
36
- const icon_1 = require("../icon");
37
- const label_1 = require("../label");
38
- const use_async_loading_1 = require("../hooks/use-async-loading");
39
40
  // TODO make the component generic ComboboxProps<T>
40
41
  exports.Combobox = (0, forwardRef_1.forwardRef)("Combobox", (props, ref) => {
41
42
  var _a, _b, _c, _d, _e, _f;
@@ -55,10 +56,11 @@ exports.Combobox = (0, forwardRef_1.forwardRef)("Combobox", (props, ref) => {
55
56
  const emptyMessage = query.length === 0
56
57
  ? (_e = props.noQueryMessage) !== null && _e !== void 0 ? _e : "Pro zobrazení možností začněte psát"
57
58
  : (_f = props.notFoundMessage) !== null && _f !== void 0 ? _f : "Nic nenalezeno";
58
- return (react_2.default.createElement(react_1.Combobox, { as: "div", className: (0, cx_1.cx)("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), onChange: (v) => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v); }, value: selectedOption, disabled: props.isDisabled || props.isReadOnly }, (renderProps) => (react_2.default.createElement(react_2.default.Fragment, null,
59
+ return (react_2.default.createElement(react_1.Combobox, { as: "div", className: (0, cx_1.cx)("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), onChange: (v) => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v); }, value: selectedOption !== null && selectedOption !== void 0 ? selectedOption : null, disabled: props.isDisabled || props.isReadOnly }, (renderProps) => (react_2.default.createElement(react_2.default.Fragment, null,
59
60
  react_2.default.createElement(react_1.Combobox.Label, { as: label_1.Label, isHidden: props.hiddenLabel, onClick: props.isDisabled || props.isReadOnly ? undefined : input.focus }, props.label),
60
61
  react_2.default.createElement(react_1.Combobox.Button, { as: "div", className: (0, cx_1.cx)("uxf-combobox__button", (renderProps.open || input.focused) && classes_1.CLASSES.IS_FOCUSED, renderProps.disabled && classes_1.CLASSES.IS_DISABLED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isInvalid && classes_1.CLASSES.IS_INVALID, dropdown.placement === "bottom" && "is-open--bottom", dropdown.placement === "top" && "is-open--top", renderProps.open && classes_1.CLASSES.IS_OPEN), onBlur: input.onBlur, onFocus: input.onFocus, tabIndex: props.isDisabled || props.isReadOnly ? undefined : 0, ref: stableRef, "aria-invalid": props.isInvalid, "aria-describedby": errorId },
61
62
  react_2.default.createElement(react_1.Combobox.Input, { className: (0, cx_1.cx)("uxf-combobox__input"), displayValue: (item) => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.label) !== null && _a !== void 0 ? _a : ""; }, onBlur: props.onBlur, onChange: (event) => setQuery(event.target.value), placeholder: props.placeholder, ref: stableRef, type: "text" }),
63
+ props.value && !props.isDisabled && !props.isReadOnly && (react_2.default.createElement(input_1.Input.RemoveButton, { onChange: props.onChange })),
62
64
  react_2.default.createElement(icon_1.Icon, { className: (0, cx_1.cx)("uxf-select__button-icon", renderProps.open && "is-open"), name: iconName })),
63
65
  react_2.default.createElement(react_1.Combobox.Options, { className: (0, cx_1.cx)("uxf-dropdown", dropdown.placement === "bottom" && "uxf-dropdown--bottom", dropdown.placement === "top" && "uxf-dropdown--top"), ref: dropdown.floating }, filteredData.length > 0 ? (filteredData.map((option) => {
64
66
  var _a, _b, _c, _d;
@@ -1,2 +1,2 @@
1
- export declare const ICONS_VERSION = "1674566060684";
1
+ export declare const ICONS_VERSION = "1676106442386";
2
2
  export declare const ICON_SPRITE = "/.storybook/static-assets/icons-generated/_icon-sprite.svg";
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ICON_SPRITE = exports.ICONS_VERSION = void 0;
4
- exports.ICONS_VERSION = "1674566060684";
4
+ exports.ICONS_VERSION = "1676106442386";
5
5
  exports.ICON_SPRITE = "/.storybook/static-assets/icons-generated/_icon-sprite.svg";
package/config/icons.d.ts CHANGED
@@ -55,6 +55,10 @@ export declare const ICONS: {
55
55
  readonly w: 512;
56
56
  readonly h: 512;
57
57
  };
58
+ readonly "ellipsis-vertical": {
59
+ readonly w: 128;
60
+ readonly h: 512;
61
+ };
58
62
  readonly file: {
59
63
  readonly w: 384;
60
64
  readonly h: 512;
@@ -93,6 +97,7 @@ declare module "@uxf/ui/icon/theme" {
93
97
  "chevronUp": true;
94
98
  "cloud": true;
95
99
  "copy": true;
100
+ "ellipsis-vertical": true;
96
101
  "file": true;
97
102
  "imageFile": true;
98
103
  "videoFile": true;
package/config/icons.js CHANGED
@@ -17,6 +17,7 @@ exports.ICONS = {
17
17
  "chevronUp": { w: 512, h: 512 },
18
18
  "cloud": { w: 640, h: 512 },
19
19
  "copy": { w: 512, h: 512 },
20
+ "ellipsis-vertical": { w: 128, h: 512 },
20
21
  "file": { w: 384, h: 512 },
21
22
  "imageFile": { w: 384, h: 512 },
22
23
  "videoFile": { w: 384, h: 512 },
@@ -0,0 +1,61 @@
1
+ .uxf-button-list {
2
+ @apply flex items-center space-x-2;
3
+
4
+ &__menu {
5
+ @apply relative;
6
+ }
7
+
8
+ &__menu-items {
9
+ @apply absolute right-0 mt-2 w-40 divide-y rounded-md shadow-lg ring-1 focus:outline-none z-dropdown;
10
+
11
+ :root .light & {
12
+ @apply divide-gray-100 bg-white ring-black/5;
13
+ }
14
+
15
+ :root .dark & {
16
+ @apply divide-gray-700 bg-gray-900 ring-white/10;
17
+ }
18
+ }
19
+
20
+ &__button {
21
+ @apply space-x-2;
22
+ }
23
+
24
+ &__open-button {
25
+ @apply space-x-2;
26
+ }
27
+
28
+ &__menu-button {
29
+ @apply flex px-3 py-2 space-x-3 text-sm is-hoverable:hover:cursor-pointer;
30
+
31
+ :root .light & {
32
+ @apply text-black hover:text-gray-800;
33
+ }
34
+
35
+ :root .dark & {
36
+ @apply text-white hover:text-gray-200;
37
+ }
38
+
39
+ &-icon {
40
+ @apply w-3;
41
+
42
+ :root .light & {
43
+ @apply text-lightMedium;
44
+ }
45
+
46
+ :root .dark & {
47
+ @apply text-darkMedium;
48
+ }
49
+ }
50
+
51
+ &.is-disabled {
52
+ :root .light & {
53
+ @apply text-lightLow;
54
+ }
55
+
56
+ :root .dark & {
57
+ @apply text-darkLow;
58
+ }
59
+ }
60
+ }
61
+ }
@@ -58,7 +58,7 @@
58
58
  }
59
59
 
60
60
  &__wrapper {
61
- @apply flex items-center border px-3 rounded-r-md w-full min-w-0;
61
+ @apply flex items-center justify-between border px-3 rounded-r-md w-full min-w-0;
62
62
 
63
63
  :root .light & {
64
64
  @apply border-gray-200;
package/css/input.css CHANGED
@@ -66,6 +66,30 @@
66
66
  }
67
67
  }
68
68
 
69
+ &__remove-button {
70
+ @apply px-1 py-0.5 mx-2 rounded-full;
71
+
72
+ :root .light & {
73
+ @apply bg-gray-300;
74
+ }
75
+
76
+ :root .dark & {
77
+ @apply bg-gray-600;
78
+ }
79
+
80
+ &__icon {
81
+ @apply w-2 h-3;
82
+
83
+ :root .light & {
84
+ @apply text-white;
85
+ }
86
+
87
+ :root .dark & {
88
+ @apply text-darkMedium;
89
+ }
90
+ }
91
+ }
92
+
69
93
  &--size-small {
70
94
  height: theme("inputSize.sm");
71
95
 
package/css/select.css CHANGED
@@ -49,7 +49,7 @@
49
49
  }
50
50
 
51
51
  &__button-text {
52
- @apply flex-grow;
52
+ @apply flex-grow truncate;
53
53
  }
54
54
 
55
55
  &__button-icon {
@@ -1,6 +1,6 @@
1
+ import { InputProps } from "@uxf/ui/input/input";
2
+ import { FormControlProps } from "@uxf/ui/types";
1
3
  import React, { ReactNode } from "react";
2
- import { InputProps } from "../input/input";
3
- import { FormControlProps } from "../types";
4
4
  export interface DatePickerInputProps extends Omit<FormControlProps<Date | null>, "value">, Pick<InputProps, "size" | "variant"> {
5
5
  className?: string;
6
6
  defaultValue?: string;
@@ -33,9 +33,10 @@ const classes_1 = require("@uxf/core/constants/classes");
33
33
  const composeRefs_1 = require("@uxf/core/utils/composeRefs");
34
34
  const cx_1 = require("@uxf/core/utils/cx");
35
35
  const forwardRef_1 = require("@uxf/core/utils/forwardRef");
36
+ const form_control_1 = require("@uxf/ui/form-control");
37
+ const input_1 = require("@uxf/ui/input");
36
38
  const dayjs_1 = __importDefault(require("dayjs"));
37
39
  const react_3 = __importStar(require("react"));
38
- const form_control_1 = require("../form-control");
39
40
  const date_picker_provider_1 = require("./date-picker-provider");
40
41
  exports.DatePickerInput = (0, forwardRef_1.forwardRef)("DatePickerInput", (props, ref) => {
41
42
  var _a;
@@ -82,6 +83,7 @@ exports.DatePickerInput = (0, forwardRef_1.forwardRef)("DatePickerInput", (props
82
83
  react_3.default.createElement(react_2.Popover.Button, { as: "div", className: "uxf-date-picker-input__wrapper", ref: stableRef },
83
84
  react_3.default.createElement("span", { className: "uxf-date-picker-input__left-element" }, props.leftElement),
84
85
  react_3.default.createElement("input", { "aria-describedby": errorId, "aria-errormessage": props.error && errorId ? `${errorId}__error-message` : undefined, "aria-invalid": !!props.error, "aria-live": "polite", autoComplete: "off", className: "uxf-date-picker-input__element", disabled: props.isDisabled, form: props.form, id: id, inputMode: "none", name: props.name, onBlur: onBlur, onChange: () => props.onChange, onFocus: onFocus, placeholder: "Vyberte datum...", readOnly: props.isReadOnly, ref: ref, required: props.isRequired, tabIndex: props.isReadOnly ? -1 : undefined, value: props.value ? (0, dayjs_1.default)(props.value).format("l") : "" }),
86
+ props.value && !props.isDisabled && !props.isReadOnly && (react_3.default.createElement(input_1.Input.RemoveButton, { onChange: props.onChange })),
85
87
  react_3.default.createElement("span", { className: "uxf-date-picker-input__right-element" }, props.rightElement)),
86
88
  !props.isDisabled && !props.isReadOnly && (react_3.default.createElement(react_2.Transition, { as: react_3.Fragment, enter: "transition duration-200 ease-out", enterFrom: "origin-top scale-50 opacity-0", enterTo: "origin-top scale-100 opacity-100", leave: "transition duration-200 ease-out", leaveFrom: "origin-top scale-50 opacity-100", leaveTo: "origin-top scale-0 opacity-0" },
87
89
  react_3.default.createElement(react_2.Popover.Panel, { className: "uxf-date-picker-input__popover", ref: floatingDatePicker.floating, static: true }, ({ close }) => (react_3.default.createElement(date_picker_provider_1.DatePickerProvider, { closePopoverHandler: close, onChange: props.onChange, selectedDate: props.value }))))))));
@@ -29,9 +29,11 @@ const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
29
29
  const cx_1 = require("@uxf/core/utils/cx");
30
30
  const forwardRef_1 = require("@uxf/core/utils/forwardRef");
31
31
  const form_control_1 = require("@uxf/ui/form-control");
32
+ const input_1 = require("@uxf/ui/input");
32
33
  const loader_1 = require("@uxf/ui/loader/loader");
33
34
  const react_1 = __importStar(require("react"));
34
35
  const file_input_base_1 = require("./file-input-base");
36
+ // eslint-disable-next-line complexity
35
37
  exports.FileInput = (0, forwardRef_1.forwardRef)("FileInput", (props, ref) => {
36
38
  var _a, _b;
37
39
  const [isUploading, setIsUploading] = (0, react_1.useState)(false);
@@ -60,9 +62,10 @@ exports.FileInput = (0, forwardRef_1.forwardRef)("FileInput", (props, ref) => {
60
62
  };
61
63
  return (react_1.default.createElement(form_control_1.FormControl, { className: (0, cx_1.cx)(input.focused && classes_1.CLASSES.IS_FOCUSED, (props.isDisabled || props.isReadOnly) && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID), errorId: errorId, form: props.form, helperText: props.helperText, inputId: id, isRequired: props.isRequired, label: props.label },
62
64
  react_1.default.createElement(react_1.default.Fragment, null,
65
+ react_1.default.createElement(file_input_base_1.BaseFileInput, { accept: props.accept, "aria-describedby": errorId, "aria-invalid": props.isInvalid, className: "uxf-file-input__input", form: props.form, id: id, isDisabled: props.isDisabled || isUploading, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, name: props.name, onBlur: input.onBlur, onChange: onChange, onFocus: input.onFocus, onUploadError: props.onUploadError, onUploadFile: props.onUploadFile, ref: ref }),
63
66
  react_1.default.createElement("label", { className: (0, cx_1.cx)("uxf-input", "uxf-file-input__label", input.focused && classes_1.CLASSES.IS_FOCUSED, (props.isDisabled || props.isReadOnly) && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID, isUploading && classes_1.CLASSES.IS_LOADING, isUploading && "uxf-file-input__label--has-right-addon", `uxf-input--size-${(_a = props.size) !== null && _a !== void 0 ? _a : "default"}`, `uxf-input--variant-${(_b = props.variant) !== null && _b !== void 0 ? _b : "default"}`), htmlFor: id },
64
67
  react_1.default.createElement("div", { className: "uxf-input__left-addon uxf-file-input__label__button" }, !isUploading ? ("Vyberte soubor") : (react_1.default.createElement(loader_1.Loader, { className: "uxf-file-input__label__loader", size: "sm" }))),
65
68
  react_1.default.createElement("div", { className: "uxf-file-input__label__wrapper" },
66
- react_1.default.createElement("span", { className: "uxf-file-input__label__wrapper__file-name" }, props.value ? `${props.value.name}` : props.placeholder || "No file has been selected yet"))),
67
- react_1.default.createElement(file_input_base_1.BaseFileInput, { accept: props.accept, "aria-describedby": errorId, "aria-invalid": props.isInvalid, className: "uxf-file-input__input", form: props.form, id: id, isDisabled: props.isDisabled, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, name: props.name, onBlur: input.onBlur, onChange: onChange, onFocus: input.onFocus, onUploadError: props.onUploadError, onUploadFile: props.onUploadFile, ref: ref }))));
69
+ react_1.default.createElement("span", { className: "uxf-file-input__label__wrapper__file-name" }, props.value ? `${props.value.name}` : props.placeholder || "No file has been selected yet"),
70
+ props.value && !props.isDisabled && !props.isReadOnly && (react_1.default.createElement(input_1.Input.RemoveButton, { onChange: props.onChange })))))));
68
71
  });
package/input/index.d.ts CHANGED
@@ -5,8 +5,9 @@ import { InputRightAddon } from "./input-right-addon";
5
5
  import { InputRightElement } from "./input-right-element";
6
6
  export declare const Input: import("react").ForwardRefExoticComponent<import("./input").InputProps & import("react").RefAttributes<HTMLInputElement>> & {
7
7
  Element: import("react").ForwardRefExoticComponent<import("./input-element").InputElementProps & import("react").RefAttributes<HTMLInputElement>>;
8
- LeftElement: typeof InputLeftElement;
9
- RightElement: typeof InputRightElement;
10
8
  LeftAddon: typeof InputLeftAddon;
9
+ LeftElement: typeof InputLeftElement;
10
+ RemoveButton: import("react").FC<import("./input-remove-button").InputRemoveButtonProps>;
11
11
  RightAddon: typeof InputRightAddon;
12
+ RightElement: typeof InputRightElement;
12
13
  };
package/input/index.js CHANGED
@@ -5,12 +5,14 @@ const input_1 = require("./input");
5
5
  const input_element_1 = require("./input-element");
6
6
  const input_left_addon_1 = require("./input-left-addon");
7
7
  const input_left_element_1 = require("./input-left-element");
8
+ const input_remove_button_1 = require("./input-remove-button");
8
9
  const input_right_addon_1 = require("./input-right-addon");
9
10
  const input_right_element_1 = require("./input-right-element");
10
11
  exports.Input = Object.assign(input_1.Input, {
11
12
  Element: input_element_1.InputElement,
12
- LeftElement: input_left_element_1.InputLeftElement,
13
- RightElement: input_right_element_1.InputRightElement,
14
13
  LeftAddon: input_left_addon_1.InputLeftAddon,
14
+ LeftElement: input_left_element_1.InputLeftElement,
15
+ RemoveButton: input_remove_button_1.InputRemoveButton,
15
16
  RightAddon: input_right_addon_1.InputRightAddon,
17
+ RightElement: input_right_element_1.InputRightElement,
16
18
  });
@@ -0,0 +1,5 @@
1
+ import { FC } from "react";
2
+ export interface InputRemoveButtonProps {
3
+ onChange?: (value: any) => void;
4
+ }
5
+ export declare const InputRemoveButton: FC<InputRemoveButtonProps>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.InputRemoveButton = void 0;
7
+ const icon_1 = require("@uxf/ui/icon");
8
+ const react_1 = __importDefault(require("react"));
9
+ const InputRemoveButton = (props) => {
10
+ const onRemoveClick = (e) => {
11
+ var _a;
12
+ e.stopPropagation();
13
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, null);
14
+ };
15
+ const onRemoveKeyDown = (e) => {
16
+ var _a;
17
+ if (e.key === "Enter" || e.key === " ") {
18
+ e.preventDefault();
19
+ e.stopPropagation();
20
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, null);
21
+ }
22
+ };
23
+ return (react_1.default.createElement("button", { className: "uxf-input__remove-button", onClick: onRemoveClick, onKeyDown: onRemoveKeyDown, type: "button" },
24
+ react_1.default.createElement(icon_1.Icon, { className: "uxf-input__remove-button__icon", name: "xmarkLarge" })));
25
+ };
26
+ exports.InputRemoveButton = InputRemoveButton;
@@ -3,10 +3,11 @@ declare const _default: {
3
3
  title: string;
4
4
  component: React.ForwardRefExoticComponent<import("./input").InputProps & React.RefAttributes<HTMLInputElement>> & {
5
5
  Element: React.ForwardRefExoticComponent<import("./input-element").InputElementProps & React.RefAttributes<HTMLInputElement>>;
6
- LeftElement: typeof import("./input-left-element").InputLeftElement;
7
- RightElement: typeof import("./input-right-element").InputRightElement;
8
6
  LeftAddon: typeof import("./input-left-addon").InputLeftAddon;
7
+ LeftElement: typeof import("./input-left-element").InputLeftElement;
8
+ RemoveButton: React.FC<import("./input-remove-button").InputRemoveButtonProps>;
9
9
  RightAddon: typeof import("./input-right-addon").InputRightAddon;
10
+ RightElement: typeof import("./input-right-element").InputRightElement;
10
11
  };
11
12
  };
12
13
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/ui",
3
- "version": "1.0.0-beta.115",
3
+ "version": "1.0.0-beta.117",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,8 +1,8 @@
1
1
  import type { Placement } from "@floating-ui/react";
2
- import React, { ReactNode } from "react";
3
- import { IconsSet } from "../icon/theme";
4
- import { FormControlProps } from "../types";
2
+ import { IconsSet } from "@uxf/ui/icon/theme";
5
3
  import { SelectSizes } from "@uxf/ui/select/theme";
4
+ import { FormControlProps } from "@uxf/ui/types";
5
+ import React, { ReactNode } from "react";
6
6
  export declare type SelectValue = number | string;
7
7
  export declare type SelectOption<T = SelectValue> = {
8
8
  disabled?: boolean;
package/select/select.js CHANGED
@@ -30,10 +30,11 @@ const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
30
30
  const composeRefs_1 = require("@uxf/core/utils/composeRefs");
31
31
  const cx_1 = require("@uxf/core/utils/cx");
32
32
  const forwardRef_1 = require("@uxf/core/utils/forwardRef");
33
+ const use_dropdown_1 = require("@uxf/ui/hooks/use-dropdown");
34
+ const icon_1 = require("@uxf/ui/icon");
35
+ const input_1 = require("@uxf/ui/input");
36
+ const label_1 = require("@uxf/ui/label");
33
37
  const react_2 = __importStar(require("react"));
34
- const use_dropdown_1 = require("../hooks/use-dropdown");
35
- const icon_1 = require("../icon");
36
- const label_1 = require("../label");
37
38
  exports.Select = (0, forwardRef_1.forwardRef)("Select", (props, ref) => {
38
39
  var _a, _b, _c, _d;
39
40
  const generatedId = (0, react_2.useId)();
@@ -45,10 +46,11 @@ exports.Select = (0, forwardRef_1.forwardRef)("Select", (props, ref) => {
45
46
  const dropdown = (0, use_dropdown_1.useDropdown)((_b = props.dropdownPlacement) !== null && _b !== void 0 ? _b : "bottom", true);
46
47
  const stableRef = (0, react_2.useMemo)(() => (0, composeRefs_1.composeRefs)(innerRef, ref, dropdown.reference), [ref, dropdown.reference]);
47
48
  const iconName = (_c = props.iconName) !== null && _c !== void 0 ? _c : "chevronDown";
48
- return (react_2.default.createElement(react_1.Listbox, { as: "div", className: (0, cx_1.cx)("uxf-select", `uxf-select--size-${(_d = props.size) !== null && _d !== void 0 ? _d : "default"}`, 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), onChange: (v) => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v.id); }, value: selectedOption, disabled: props.isDisabled || props.isReadOnly }, (renderProps) => (react_2.default.createElement(react_2.default.Fragment, null,
49
+ return (react_2.default.createElement(react_1.Listbox, { as: "div", className: (0, cx_1.cx)("uxf-select", `uxf-select--size-${(_d = props.size) !== null && _d !== void 0 ? _d : "default"}`, 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), onChange: (v) => { var _a; return v && ((_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v.id)); }, value: selectedOption !== null && selectedOption !== void 0 ? selectedOption : null, disabled: props.isDisabled || props.isReadOnly }, (renderProps) => (react_2.default.createElement(react_2.default.Fragment, null,
49
50
  react_2.default.createElement(react_1.Listbox.Label, { as: label_1.Label, isHidden: props.hiddenLabel, onClick: props.isDisabled || props.isReadOnly ? undefined : input.focus }, props.label),
50
51
  react_2.default.createElement(react_1.Listbox.Button, { as: "div", className: (0, cx_1.cx)("uxf-select__button", (renderProps.open || input.focused) && classes_1.CLASSES.IS_FOCUSED, renderProps.disabled && classes_1.CLASSES.IS_DISABLED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isInvalid && classes_1.CLASSES.IS_INVALID, dropdown.placement === "bottom" && "is-open--bottom", dropdown.placement === "top" && "is-open--top", renderProps.open && "is-open"), onBlur: input.onBlur, onFocus: input.onFocus, tabIndex: props.isDisabled || props.isReadOnly ? undefined : 0, ref: stableRef, "aria-invalid": props.isInvalid, "aria-describedby": errorId },
51
52
  react_2.default.createElement("div", { className: (0, cx_1.cx)("uxf-select__button-text", !(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) && "is-empty") }, (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || props.placeholder),
53
+ props.value && !props.isDisabled && !props.isReadOnly && (react_2.default.createElement(input_1.Input.RemoveButton, { onChange: props.onChange })),
52
54
  react_2.default.createElement(icon_1.Icon, { className: (0, cx_1.cx)("uxf-select__button-icon", renderProps.open && "is-open"), name: iconName })),
53
55
  react_2.default.createElement(react_1.Listbox.Options, { ref: dropdown.floating, className: (0, cx_1.cx)("uxf-dropdown", dropdown.placement === "bottom" && "uxf-dropdown--bottom", dropdown.placement === "top" && "uxf-dropdown--top") }, props.options.map((option) => {
54
56
  var _a, _b, _c, _d;
@@ -1,5 +1,5 @@
1
- import { SelectValue } from "./select";
2
1
  import React from "react";
2
+ import { SelectValue } from "./select";
3
3
  declare const _default: {
4
4
  title: string;
5
5
  component: React.ForwardRefExoticComponent<import("./select").SelectProps<SelectValue, import("./select").SelectOption<SelectValue>> & React.RefAttributes<HTMLDivElement>>;
@@ -27,9 +27,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.ComponentStructure = exports.Default = void 0;
30
- const index_1 = require("./index");
31
30
  const react_1 = __importStar(require("react"));
32
31
  const component_structure_analyzer_1 = __importDefault(require("../utils/component-structure-analyzer"));
32
+ const index_1 = require("./index");
33
33
  exports.default = {
34
34
  title: "UI/Select",
35
35
  component: index_1.Select,
@@ -38,15 +38,13 @@ const options = [
38
38
  { id: "one", label: "Option one" },
39
39
  { id: "two", label: "Option two" },
40
40
  { id: "three", label: "Option three" },
41
- { id: "three", label: "Option three" },
42
- { id: "three", label: "Option three" },
43
- { id: "three", label: "Option three" },
44
- { id: "three", label: "Option three" },
45
- { id: "three", label: "Option three" },
46
- { id: "three", label: "Option three" },
47
- { id: "three", label: "Option three" },
48
- { id: "three", label: "Option three" },
49
- { id: "three", label: "Option three" },
41
+ { id: "four", label: "Option four" },
42
+ { id: "five", label: "Option five" },
43
+ { id: "six", label: "Option six" },
44
+ { id: "seven", label: "Option seven" },
45
+ { id: "eight", label: "Option eight" },
46
+ { id: "nine", label: "Option nine" },
47
+ { id: "ten", label: "Option ten" },
50
48
  ];
51
49
  function Default() {
52
50
  const [value, setValue] = (0, react_1.useState)();
@@ -1,7 +1,7 @@
1
1
  import { TimeType } from "@uxf/datepicker/hooks/use-time-picker";
2
+ import { InputProps } from "@uxf/ui/input/input";
3
+ import { FormControlProps } from "@uxf/ui/types";
2
4
  import React, { ReactNode } from "react";
3
- import { InputProps } from "../input/input";
4
- import { FormControlProps } from "../types";
5
5
  export interface TimePickerInputProps extends Omit<FormControlProps<TimeType | null>, "value">, Pick<InputProps, "size" | "variant"> {
6
6
  className?: string;
7
7
  defaultValue?: string;
@@ -30,8 +30,9 @@ const classes_1 = require("@uxf/core/constants/classes");
30
30
  const composeRefs_1 = require("@uxf/core/utils/composeRefs");
31
31
  const cx_1 = require("@uxf/core/utils/cx");
32
32
  const forwardRef_1 = require("@uxf/core/utils/forwardRef");
33
+ const form_control_1 = require("@uxf/ui/form-control");
34
+ const input_1 = require("@uxf/ui/input");
33
35
  const react_3 = __importStar(require("react"));
34
- const form_control_1 = require("../form-control");
35
36
  const time_picker_1 = require("./time-picker");
36
37
  exports.TimePickerInput = (0, forwardRef_1.forwardRef)("TimePickerInput", (props, ref) => {
37
38
  var _a;
@@ -80,6 +81,7 @@ exports.TimePickerInput = (0, forwardRef_1.forwardRef)("TimePickerInput", (props
80
81
  react_3.default.createElement("input", { "aria-describedby": errorId, "aria-errormessage": props.error && errorId ? `${errorId}__error-message` : undefined, "aria-invalid": !!props.error, "aria-live": "polite", autoComplete: "off", className: "uxf-time-picker-input__element", disabled: props.isDisabled, form: props.form, id: id, inputMode: "text", name: props.name, onBlur: onBlur, onChange: () => props.onChange, onFocus: onFocus, placeholder: "Vyberte \u010Das...", readOnly: props.isReadOnly, ref: ref, required: props.isRequired, tabIndex: props.isReadOnly ? -1 : undefined, value: props.value
81
82
  ? `${props.value.hour}:${props.value.minute < 10 ? "0" + props.value.minute : props.value.minute}`
82
83
  : "" }),
84
+ props.value && !props.isDisabled && !props.isReadOnly && (react_3.default.createElement(input_1.Input.RemoveButton, { onChange: props.onChange })),
83
85
  react_3.default.createElement("span", { className: "uxf-time-picker-input__right-element" }, props.rightElement)),
84
86
  !props.isDisabled && !props.isReadOnly && (react_3.default.createElement(react_2.Transition, { as: react_3.Fragment, enter: "transition duration-200 ease-out", enterFrom: "origin-top scale-50 opacity-0", enterTo: "origin-top scale-100 opacity-100", leave: "transition duration-200 ease-out", leaveFrom: "origin-top scale-50 opacity-100", leaveTo: "origin-top scale-0 opacity-0" },
85
87
  react_3.default.createElement(react_2.Popover.Panel, { className: "uxf-time-picker-input__popover", ref: floatingTimePicker.floating, static: true }, ({ close }) => {
@@ -70,6 +70,11 @@ module.exports = {
70
70
  height: 512,
71
71
  data: `<path fill="currentColor" d="M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z" />`,
72
72
  },
73
+ "ellipsis-vertical": {
74
+ width: 128,
75
+ height: 512,
76
+ data: `<path fill="currentColor" d="M48 464a48 48 0 1 1 0-96 48 48 0 1 1 0 96zm0-160a48 48 0 1 1 0-96 48 48 0 1 1 0 96zM0 96a48 48 0 1 1 96 0A48 48 0 1 1 0 96z"/>`,
77
+ },
73
78
  file: {
74
79
  width: 384,
75
80
  height: 512,