@uxf/ui 10.6.0 → 10.8.0

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.
@@ -6,6 +6,7 @@ export interface FileInputBaseProps extends FormControlProps<FileResponse | null
6
6
  className?: string;
7
7
  form?: string;
8
8
  id?: string;
9
+ maxFileSize?: number;
9
10
  onUploadError?: (err: unknown) => void;
10
11
  onUploadFile: (file: File) => Promise<FileResponse>;
11
12
  }
@@ -25,12 +25,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports._FileInputBase = void 0;
27
27
  const react_1 = __importStar(require("react"));
28
+ const validator_exceptions_1 = require("../utils/validator/validator-exceptions");
28
29
  exports._FileInputBase = (0, react_1.forwardRef)((props, ref) => {
29
30
  const onChange = async (e) => {
30
31
  var _a;
31
32
  if (e.target.files) {
32
33
  try {
33
- const response = await props.onUploadFile(e.target.files[0]);
34
+ const file = e.target.files[0];
35
+ if (props.maxFileSize && file.size > props.maxFileSize) {
36
+ throw validator_exceptions_1.ValidatorExceptions.MaxFileSize;
37
+ }
38
+ const response = await props.onUploadFile(file);
34
39
  await props.onChange(response, e);
35
40
  }
36
41
  catch (err) {
@@ -28,6 +28,7 @@ export interface SelectBaseProps<Value, Option> extends FormControlProps<Value |
28
28
  id?: string;
29
29
  keyExtractor?: (option: Option) => string | number;
30
30
  label: ReactNode;
31
+ onOptionsUnmount?: () => void;
31
32
  options?: Option[];
32
33
  placeholder?: string;
33
34
  renderOption?: (option: Option, isSelected: boolean) => ReactNode;
@@ -27,6 +27,7 @@ exports._SelectBase = void 0;
27
27
  const react_1 = require("@floating-ui/react");
28
28
  const classes_1 = require("@uxf/core/constants/classes");
29
29
  const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
30
+ const useOnUnmount_1 = require("@uxf/core/hooks/useOnUnmount");
30
31
  const composeRefs_1 = require("@uxf/core/utils/composeRefs");
31
32
  const cx_1 = require("@uxf/core/utils/cx");
32
33
  const use_dropdown_1 = require("@uxf/ui/hooks/use-dropdown");
@@ -34,6 +35,13 @@ const icon_1 = require("@uxf/ui/icon");
34
35
  const input_1 = require("@uxf/ui/input");
35
36
  const label_1 = require("@uxf/ui/label");
36
37
  const react_2 = __importStar(require("react"));
38
+ const Option = (props) => {
39
+ var _a, _b, _c, _d;
40
+ const optionKey = (_a = props.keyExtractor) === null || _a === void 0 ? void 0 : _a.call(props, props.option);
41
+ const HUIComponent = props.HUIComponent;
42
+ return (react_2.default.createElement(HUIComponent.Option, { className: (optionState) => (0, cx_1.cx)("uxf-dropdown__item", optionState.active && classes_1.CLASSES.IS_ACTIVE, optionState.disabled && classes_1.CLASSES.IS_DISABLED, optionState.selected && classes_1.CLASSES.IS_SELECTED), key: optionKey !== null && optionKey !== void 0 ? optionKey : props.option.id, value: props.option }, (_d = (_c = (_b = props.renderOption) === null || _b === void 0 ? void 0 : _b.call(props, props.option)) !== null && _c !== void 0 ? _c : optionKey) !== null && _d !== void 0 ? _d : props.option.label));
43
+ };
44
+ Option.displayName = "UxfUiSelectBaseOption";
37
45
  function isHUICombobox(HUIComponent) {
38
46
  return typeof HUIComponent.Input !== "undefined";
39
47
  }
@@ -53,13 +61,16 @@ const InputArrow = (props) => {
53
61
  const Options = (props) => {
54
62
  var _a, _b;
55
63
  const HUIComponent = props.HUIComponent;
64
+ (0, useOnUnmount_1.useOnUnmount)(() => {
65
+ var _a;
66
+ (_a = props.onUnmount) === null || _a === void 0 ? void 0 : _a.call(props);
67
+ });
56
68
  return (react_2.default.createElement(HUIComponent.Options, { className: (0, cx_1.cx)("uxf-dropdown uxf-select-base__options", `uxf-dropdown--size-${(_a = props.size) !== null && _a !== void 0 ? _a : "default"}`, `uxf-dropdown--variant-${(_b = props.variant) !== null && _b !== void 0 ? _b : "default"}`, props.matchWidth
57
69
  ? "uxf-select-base__options--match-width"
58
70
  : "uxf-select-base__options--not-match-width", props.placement === "bottom" && "uxf-dropdown--bottom", props.placement === "top" && "uxf-dropdown--top", props.className), ref: props.forwardRef, static: true, style: props.style }, props.options && props.options.length > 0 ? (props.options.map((option) => {
59
71
  var _a;
60
72
  const optionKey = (_a = props.keyExtractor) === null || _a === void 0 ? void 0 : _a.call(props, option);
61
- const _option = option;
62
- return (react_2.default.createElement(HUIComponent.Option, { disabled: _option.disabled, className: (optionState) => (0, cx_1.cx)("uxf-dropdown__item", optionState.active && classes_1.CLASSES.IS_ACTIVE, optionState.disabled && classes_1.CLASSES.IS_DISABLED, optionState.selected && classes_1.CLASSES.IS_SELECTED), key: optionKey !== null && optionKey !== void 0 ? optionKey : _option.id, value: option }, (optionState) => { var _a, _b; return (_b = (_a = props.renderOption) === null || _a === void 0 ? void 0 : _a.call(props, option, optionState.selected)) !== null && _b !== void 0 ? _b : option.label; }));
73
+ return (react_2.default.createElement(Option, { key: optionKey, keyExtractor: props.keyExtractor, option: option, HUIComponent: HUIComponent }));
63
74
  })) : (react_2.default.createElement("div", { className: "uxf-dropdown__empty-wrapper" }, props.emptyMessage))));
64
75
  };
65
76
  Options.displayName = "UxfUiSelectBaseOptions";
@@ -91,7 +102,7 @@ const _SelectBase = (props) => {
91
102
  react_2.default.createElement(InputArrow, { iconName: props.iconName, open: renderProps.open }))) : (react_2.default.createElement(InputArrow, { iconName: props.iconName, open: renderProps.open }))),
92
103
  props.rightAddon && react_2.default.createElement(input_1.Input.RightAddon, null, props.rightAddon)),
93
104
  renderProps.open && (react_2.default.createElement(react_1.FloatingPortal, null,
94
- react_2.default.createElement(Options, { HUIComponent: HUIComponent, className: props.dropdownClassName, emptyMessage: props.emptyMessage, forwardRef: dropdown.refs.setFloating, keyExtractor: props.keyExtractor, matchWidth: props.dropdownMatchesInputWidth, options: props.options, placement: dropdown.placement, renderOption: props.renderOption, size: props.size, style: dropdown.floatingStyles, variant: props.variant }))),
105
+ react_2.default.createElement(Options, { HUIComponent: HUIComponent, className: props.dropdownClassName, emptyMessage: props.emptyMessage, forwardRef: dropdown.refs.setFloating, keyExtractor: props.keyExtractor, matchWidth: props.dropdownMatchesInputWidth, onUnmount: props.onOptionsUnmount, options: props.options, placement: dropdown.placement, renderOption: props.renderOption, size: props.size, style: dropdown.floatingStyles, variant: props.variant }))),
95
106
  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)))))));
96
107
  };
97
108
  exports._SelectBase = _SelectBase;
@@ -36,7 +36,7 @@ const button_1 = require("../button");
36
36
  const form_component_1 = require("../form-component");
37
37
  const icon_1 = require("../icon");
38
38
  exports.AvatarFileInput = (0, react_1.forwardRef)((props, ref) => {
39
- var _a, _b, _c, _d, _e;
39
+ var _a, _b, _c, _d, _e, _f;
40
40
  const generatedId = (0, react_1.useId)();
41
41
  const id = props.id || generatedId;
42
42
  const innerRef = (0, react_1.useRef)(null);
@@ -49,14 +49,14 @@ exports.AvatarFileInput = (0, react_1.forwardRef)((props, ref) => {
49
49
  return (react_1.default.createElement(form_component_1.FormComponent, { className: rootClassName, errorId: props.id, helperText: props.helperText, hiddenLabel: props.hiddenLabel, inputId: id, label: props.label },
50
50
  react_1.default.createElement("div", { className: "uxf-avatar-file-input__inner-wrapper" },
51
51
  react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-avatar-file-input__input", stateClassName), onClick: onSelectFile },
52
- react_1.default.createElement(_file_input_base_1._FileInputBase, { accept: props.accept, "aria-describedby": errorId, "aria-invalid": props.isInvalid, className: "uxf-avatar-file-input__input-element", form: props.form, id: id, isDisabled: props.isDisabled, isFocused: props.isFocused, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, name: props.name, onBlur: input.onBlur, onFocus: input.onFocus, onChange: props.onChange, onUploadError: props.onUploadError, onUploadFile: props.onUploadFile, ref: (0, composeRefs_1.composeRefs)(innerRef, ref), value: props.value }),
52
+ react_1.default.createElement(_file_input_base_1._FileInputBase, { accept: (_c = props.accept) !== null && _c !== void 0 ? _c : "image/*", "aria-describedby": errorId, "aria-invalid": props.isInvalid, className: "uxf-avatar-file-input__input-element", form: props.form, id: id, isDisabled: props.isDisabled, isFocused: props.isFocused, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, maxFileSize: props.maxFileSize, name: props.name, onBlur: input.onBlur, onFocus: input.onFocus, onChange: props.onChange, onUploadError: props.onUploadError, onUploadFile: props.onUploadFile, ref: (0, composeRefs_1.composeRefs)(innerRef, ref), value: props.value }),
53
53
  props.value ? (react_1.default.createElement(avatar_1.Avatar, { className: "uxf-avatar-file-input__input-avatar", src: (0, file_1.getFileUrl)(props.value) })) : (react_1.default.createElement("div", { className: "uxf-avatar-file-input__input-empty" },
54
- react_1.default.createElement(icon_1.Icon, { className: "uxf-avatar-file-input__input-empty-icon", name: (_c = props.icon) !== null && _c !== void 0 ? _c : "cloud" })))),
54
+ react_1.default.createElement(icon_1.Icon, { className: "uxf-avatar-file-input__input-empty-icon", name: (_d = props.icon) !== null && _d !== void 0 ? _d : "cloud" })))),
55
55
  react_1.default.createElement("div", { className: "uxf-avatar-file-input__controls" }, props.customControls ? (props.customControls({
56
56
  onSelectFile,
57
57
  onRemoveFile,
58
58
  })) : (react_1.default.createElement("div", { className: "uxf-avatar-file-input__controls-buttons" },
59
- react_1.default.createElement(button_1.Button, { className: "uxf-avatar-file-input__controls-button uxf-avatar-file-input__controls-button--select", disabled: props.isDisabled, onClick: onSelectFile, size: "sm", variant: "white" }, (_d = props.selectFileLabel) !== null && _d !== void 0 ? _d : "Upload image"),
60
- !!props.value && !props.isDisabled && (react_1.default.createElement(button_1.Button, { className: "uxf-avatar-file-input__controls-button uxf-avatar-file-input__controls-button--remove", color: "error", disabled: props.isDisabled, onClick: onRemoveFile, size: "sm", variant: "white" }, (_e = props.removeFileLabel) !== null && _e !== void 0 ? _e : "Remove avatar"))))))));
59
+ react_1.default.createElement(button_1.Button, { className: "uxf-avatar-file-input__controls-button uxf-avatar-file-input__controls-button--select", disabled: props.isDisabled, onClick: onSelectFile, size: "sm", variant: "white" }, (_e = props.selectFileLabel) !== null && _e !== void 0 ? _e : "Upload image"),
60
+ !!props.value && !props.isDisabled && (react_1.default.createElement(button_1.Button, { className: "uxf-avatar-file-input__controls-button uxf-avatar-file-input__controls-button--remove", color: "error", disabled: props.isDisabled, onClick: onRemoveFile, size: "sm", variant: "white" }, (_f = props.removeFileLabel) !== null && _f !== void 0 ? _f : "Remove avatar"))))))));
61
61
  });
62
62
  exports.AvatarFileInput.displayName = "UxfUiAvatarFileInput";
@@ -33,7 +33,7 @@ const react_1 = __importStar(require("react"));
33
33
  exports.CalendarDayCell = (0, react_1.memo)((props) => {
34
34
  const dayCellRef = (0, react_1.useRef)(null);
35
35
  const innerRef = (0, react_1.useRef)(null);
36
- const { disabledDate, isHovered, isSelected, isInsideRange, isToday, isWithinHoverRange, onClick, onKeyDown, onMouseEnter, tabIndex, } = (0, use_day_1.useDay)({
36
+ const { disabledDate, isHovered, isSelected, isInsideRange, isToday, isWithinHoverRange, onClick, onKeyDown, onMouseEnter, tabIndex, isFirstDisabled, isLastDisabled, } = (0, use_day_1.useDay)({
37
37
  date: props.day.date,
38
38
  focusedDate: props.datePickerProps.focusedDate,
39
39
  isDateBlocked: props.datePickerProps.isDateBlocked,
@@ -46,6 +46,7 @@ exports.CalendarDayCell = (0, react_1.memo)((props) => {
46
46
  onDateSelect: props.datePickerProps.onDateSelect,
47
47
  dayRef: dayCellRef,
48
48
  preventScroll: props.datePickerProps.preventScroll,
49
+ unavailableDates: props.datePickerProps.unavailableDates,
49
50
  });
50
51
  (0, useOnMount_1.useOnMount)(() => {
51
52
  const node = innerRef.current;
@@ -56,7 +57,7 @@ exports.CalendarDayCell = (0, react_1.memo)((props) => {
56
57
  if (!props.day.dayLabel) {
57
58
  return react_1.default.createElement("div", null);
58
59
  }
59
- return (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-calendar__cell uxf-calendar__cell-day", disabledDate && classes_1.CLASSES.IS_DISABLED, isToday && "uxf-calendar__cell--today", isSelected && "uxf-calendar__cell--selected", isInsideRange && "uxf-calendar__cell--inside-range", isWithinHoverRange && "uxf-calendar__cell--is-within-hover-range", isHovered && "uxf-calendar__cell--is-hovered", !props.day.currentMonth && "uxf-calendar__cell--not-current-month"), ref: disabledDate ? undefined : (0, composeRefs_1.composeRefs)(dayCellRef, innerRef), onClick: onClick, onKeyDown: onKeyDown, onMouseEnter: onMouseEnter, tabIndex: tabIndex, type: "button" },
60
+ return (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-calendar__cell uxf-calendar__cell-day", isFirstDisabled && props.day.currentMonth && "is-disabled-start", isLastDisabled && props.day.currentMonth && "is-disabled-end", disabledDate && classes_1.CLASSES.IS_DISABLED, isToday && "uxf-calendar__cell--today", isSelected && "uxf-calendar__cell--selected", isInsideRange && "uxf-calendar__cell--inside-range", isWithinHoverRange && "uxf-calendar__cell--is-within-hover-range", isHovered && "uxf-calendar__cell--is-hovered", !props.day.currentMonth && "uxf-calendar__cell--not-current-month"), ref: disabledDate ? undefined : (0, composeRefs_1.composeRefs)(dayCellRef, innerRef), onClick: onClick, onKeyDown: onKeyDown, onMouseEnter: onMouseEnter, tabIndex: tabIndex, type: "button" },
60
61
  react_1.default.createElement("span", { className: "uxf-calendar__cell__inner" }, props.day.dayLabel)));
61
62
  });
62
63
  exports.CalendarDayCell.displayName = "UxfUiCalendarDayCell";
@@ -8,5 +8,6 @@ export interface CheckboxInputProps extends FormControlProps<boolean | undefined
8
8
  label: ReactNode;
9
9
  size?: CheckboxSize;
10
10
  style?: CSSProperties;
11
+ helperText?: ReactNode;
11
12
  }
12
13
  export declare const CheckboxInput: React.ForwardRefExoticComponent<CheckboxInputProps & React.RefAttributes<HTMLDivElement>>;
@@ -28,10 +28,15 @@ const react_1 = require("@headlessui/react");
28
28
  const react_2 = __importStar(require("react"));
29
29
  const checkbox_1 = require("../checkbox");
30
30
  exports.CheckboxInput = (0, react_2.forwardRef)((props, ref) => {
31
- var _a;
31
+ var _a, _b;
32
+ const generatedId = (0, react_2.useId)();
33
+ const id = (_a = props.id) !== null && _a !== void 0 ? _a : generatedId;
34
+ const errorId = props.isInvalid ? `${id}--error-message` : undefined;
32
35
  return (react_2.default.createElement(react_1.Switch.Group, null,
33
- react_2.default.createElement("div", { className: `uxf-checkbox-input__wrapper ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
36
+ react_2.default.createElement("div", { className: `uxf-checkbox-input__wrapper ${(_b = props.className) !== null && _b !== void 0 ? _b : ""}` },
34
37
  react_2.default.createElement(react_1.Switch, { as: react_2.Fragment, checked: props.value, name: props.name, onChange: props.onChange }, ({ checked }) => (react_2.default.createElement(checkbox_1.Checkbox, { className: "uxf-checkbox-input", id: props.id, indeterminate: props.indeterminate, isDisabled: props.isDisabled, isFocused: props.isFocused, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, onChange: props.onChange, ref: ref, size: props.size, style: props.style, value: checked }))),
35
- react_2.default.createElement(react_1.Switch.Label, { className: "uxf-checkbox-input__label" }, props.label))));
38
+ react_2.default.createElement(react_1.Switch.Label, { className: "uxf-checkbox-input__label" },
39
+ react_2.default.createElement("span", { className: "uxf-checkbox-input__label--text" }, props.label),
40
+ react_2.default.createElement("span", { id: errorId, className: "uxf-checkbox-input__label--subtitle" }, props.helperText)))));
36
41
  });
37
42
  exports.CheckboxInput.displayName = "UxfUiCheckboxInput";
@@ -38,11 +38,12 @@ const Combobox = (props) => {
38
38
  const emptyMessage = query.length === 0
39
39
  ? (_b = props.noQueryMessage) !== null && _b !== void 0 ? _b : "Pro zobrazení možností začněte psát"
40
40
  : (_c = props.notFoundMessage) !== null && _c !== void 0 ? _c : "Nic nenalezeno";
41
+ const clearQuery = () => setQuery("");
41
42
  const onChange = (v) => props.onChange(v);
42
43
  const onInputChange = (event) => setQuery(event.target.value);
43
44
  const displayValue = (item) => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.label) !== null && _a !== void 0 ? _a : ""; };
44
45
  const selectedOption = (_d = props.value) !== null && _d !== void 0 ? _d : null;
45
- return (react_2.default.createElement(_select_base_1._SelectBase, { HUIComponent: react_1.Combobox, className: props.className, customInputElementDisplayName: react_1.Combobox.Input.displayName, dropdownClassName: props.dropdownClassName, dropdownMatchesInputWidth: props.dropdownMatchesInputWidth, dropdownPlacement: props.dropdownPlacement, dropdownStrategy: props.dropdownStrategy, emptyMessage: emptyMessage, forwardRef: props.forwardRef, helperText: props.helperText, hiddenLabel: props.hiddenLabel, iconName: props.iconName, id: props.id, isClearable: props.isClearable, isDisabled: props.isDisabled, isFocused: props.isFocused, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, keyExtractor: props.keyExtractor, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, name: props.name, onBlur: props.onBlur, onChange: onChange, onFocus: props.onFocus, options: filteredData, placeholder: props.placeholder, renderOption: props.renderOption, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, value: selectedOption, variant: props.variant },
46
+ return (react_2.default.createElement(_select_base_1._SelectBase, { HUIComponent: react_1.Combobox, className: props.className, customInputElementDisplayName: react_1.Combobox.Input.displayName, dropdownClassName: props.dropdownClassName, dropdownMatchesInputWidth: props.dropdownMatchesInputWidth, dropdownPlacement: props.dropdownPlacement, dropdownStrategy: props.dropdownStrategy, emptyMessage: emptyMessage, forwardRef: props.forwardRef, helperText: props.helperText, hiddenLabel: props.hiddenLabel, iconName: props.iconName, id: props.id, isClearable: props.isClearable, isDisabled: props.isDisabled, isFocused: props.isFocused, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, keyExtractor: props.keyExtractor, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, name: props.name, onBlur: props.onBlur, onChange: onChange, onFocus: props.onFocus, onOptionsUnmount: clearQuery, options: filteredData, placeholder: props.placeholder, renderOption: props.renderOption, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, value: selectedOption, variant: props.variant },
46
47
  react_2.default.createElement(react_1.Combobox.Input, { autoComplete: "off", className: "uxf-input__element", displayValue: displayValue, onBlur: props.onBlur, onChange: onInputChange, placeholder: props.placeholder, type: "text" })));
47
48
  };
48
49
  exports.Combobox = Combobox;
@@ -1,6 +1,8 @@
1
1
  .uxf-checkbox-input {
2
+ margin-top: 4px;
3
+
2
4
  &__wrapper {
3
- @apply flex items-center justify-between space-x-3;
5
+ @apply flex justify-between space-x-3;
4
6
  }
5
7
 
6
8
  &__label {
@@ -15,6 +17,12 @@
15
17
  }
16
18
  }
17
19
 
20
+ &__label--subtitle {
21
+ color: theme("colors.error.DEFAULT");
22
+ display: block;
23
+ font-size: theme("fontSize.caption");
24
+ }
25
+
18
26
  &.is-disabled,
19
27
  &.is-readonly {
20
28
  & + .uxf-checkbox-input__label {
@@ -22,8 +22,12 @@ 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
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
29
  exports.Default = void 0;
30
+ const dayjs_1 = __importDefault(require("dayjs"));
27
31
  const react_1 = __importStar(require("react"));
28
32
  const action_1 = require("../utils/action");
29
33
  const date_picker_1 = require("./date-picker");
@@ -31,12 +35,24 @@ exports.default = {
31
35
  title: "UI/DatePicker",
32
36
  component: date_picker_1.DatePicker,
33
37
  };
38
+ const today = (0, dayjs_1.default)();
39
+ const unavailableDates = [
40
+ today.toDate(),
41
+ today.add(5, "days").toDate(),
42
+ today.add(6, "days").toDate(),
43
+ today.add(7, "days").toDate(),
44
+ today.add(11, "days").toDate(),
45
+ today.add(12, "days").toDate(),
46
+ ];
34
47
  function Default() {
35
48
  const [value, setValue] = (0, react_1.useState)(null);
36
49
  const onChange = (0, action_1.action)("onChange", setValue);
37
50
  const onClose = () => null;
38
51
  const testDatePickers = (react_1.default.createElement(react_1.default.Fragment, null,
39
- react_1.default.createElement(date_picker_1.DatePicker, { closePopoverHandler: onClose, onChange: onChange, selectedDate: value })));
52
+ react_1.default.createElement("p", { className: "text-lg" }, "Date picker"),
53
+ react_1.default.createElement(date_picker_1.DatePicker, { closePopoverHandler: onClose, onChange: onChange, selectedDate: value }),
54
+ react_1.default.createElement("p", { className: "text-lg" }, "Date picker with unavailable dates"),
55
+ react_1.default.createElement(date_picker_1.DatePicker, { onChange: onChange, selectedDate: value, unavailableDates: unavailableDates })));
40
56
  return (react_1.default.createElement(react_1.default.Fragment, null,
41
57
  react_1.default.createElement("div", { className: "light max-w-[640px] space-y-4 rounded bg-white p-8" }, testDatePickers),
42
58
  react_1.default.createElement("div", { className: "dark max-w-[640px] space-y-4 rounded bg-gray-900 p-8 text-white" }, testDatePickers)));
@@ -4,6 +4,7 @@ import { IconName } from "../icon/types";
4
4
  import { Accept, DropzoneFile } from "./types";
5
5
  export interface DropzoneInputProps extends FormControlProps<DropzoneFile[] | undefined> {
6
6
  accept?: Accept;
7
+ className?: string;
7
8
  helperText?: ReactNode;
8
9
  icon?: IconName;
9
10
  id?: string;
@@ -63,9 +63,10 @@ function fileRejectedHandler(err, dropzoneFile, onValuesChange, values, onUpload
63
63
  }
64
64
  }
65
65
  exports.DropzoneInput = (0, react_1.forwardRef)((props, ref) => {
66
- var _a;
66
+ var _a, _b;
67
67
  const refValue = (0, react_1.useRef)();
68
68
  refValue.current = props.value;
69
+ const inputRef = (0, react_1.useRef)(null);
69
70
  const handleFileDrop = async (acceptedFiles) => {
70
71
  const files = acceptedFiles.map((file) => ({
71
72
  ...fileToFileResponse(file),
@@ -77,6 +78,11 @@ exports.DropzoneInput = (0, react_1.forwardRef)((props, ref) => {
77
78
  const onChange = (values) => {
78
79
  props.onChange(values);
79
80
  refValue.current = values;
81
+ // this ensures that the input is cleared after the upload, so there is no problem with uploading the same file again
82
+ const inputNode = inputRef.current;
83
+ if (inputNode) {
84
+ inputNode.value = "";
85
+ }
80
86
  };
81
87
  for (const file of files) {
82
88
  if (!file.originalFile) {
@@ -107,19 +113,19 @@ exports.DropzoneInput = (0, react_1.forwardRef)((props, ref) => {
107
113
  const labelOnCLick = (e) => {
108
114
  e.stopPropagation();
109
115
  };
110
- return (react_1.default.createElement("div", { className: "uxf-dropzone" },
116
+ return (react_1.default.createElement("div", { className: `uxf-dropzone ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
111
117
  react_1.default.createElement("label", { ...getRootProps({
112
118
  className: (0, cx_1.cx)("uxf-dropzone__label", props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.noClick && "cursor-auto"),
113
119
  onClick: labelOnCLick,
114
120
  }), ref: (0, composeRefs_1.composeRefs)(ref, rootRef) },
115
- react_1.default.createElement(icon_1.Icon, { className: "uxf-dropzone__label__icon", name: (_a = props.icon) !== null && _a !== void 0 ? _a : "cloud" }),
121
+ react_1.default.createElement(icon_1.Icon, { className: "uxf-dropzone__label__icon", name: (_b = props.icon) !== null && _b !== void 0 ? _b : "cloud" }),
116
122
  typeof props.label === "string" ? react_1.default.createElement("span", null, props.label) : props.label,
117
123
  react_1.default.createElement("input", { ...getInputProps({
118
124
  className: "uxf-dropzone__input",
119
125
  id: props.id,
120
126
  name: props.name,
121
127
  type: "file",
122
- }) })),
128
+ }), ref: inputRef })),
123
129
  props.helperText && (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-helper-text", props.isInvalid && classes_1.CLASSES.IS_INVALID) }, props.helperText))));
124
130
  });
125
131
  exports.DropzoneInput.displayName = "UxfUiDropzoneInput";
@@ -2,6 +2,7 @@ import { FormControlProps } from "@uxf/ui/types";
2
2
  import { FC, ReactNode } from "react";
3
3
  import { DropzoneFile } from "./types";
4
4
  export interface DropzoneListProps extends FormControlProps<DropzoneFile[] | undefined> {
5
+ className?: string;
5
6
  errorText?: string;
6
7
  onAbortWarning?: string;
7
8
  onRemoveWarning?: string;
@@ -40,7 +40,7 @@ function formatBytes(bytes, decimals = 2) {
40
40
  return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
41
41
  }
42
42
  const DropzoneList = (props) => {
43
- var _a, _b;
43
+ var _a, _b, _c;
44
44
  const context = (0, react_1.useContext)(context_1.UiContext);
45
45
  const onRemove = (file, isUploading) => () => {
46
46
  var _a;
@@ -58,7 +58,7 @@ const DropzoneList = (props) => {
58
58
  if (((_a = props.value) === null || _a === void 0 ? void 0 : _a.length) === 0) {
59
59
  return null;
60
60
  }
61
- return (react_1.default.createElement("ul", { className: "uxf-dropzone-list" }, (_b = props.value) === null || _b === void 0 ? void 0 : _b.map((file) => {
61
+ return (react_1.default.createElement("ul", { className: `uxf-dropzone-list ${(_b = props.className) !== null && _b !== void 0 ? _b : ""}` }, (_c = props.value) === null || _c === void 0 ? void 0 : _c.map((file) => {
62
62
  var _a, _b, _c;
63
63
  const isUploading = file.id < 0 && !file.error;
64
64
  return ((_b = (_a = props.renderItem) === null || _a === void 0 ? void 0 : _a.call(props, file)) !== null && _b !== void 0 ? _b : (react_1.default.createElement("li", { className: "uxf-dropzone-list__item-wrapper", key: file.id },
@@ -5,11 +5,11 @@ import { FileInputBaseProps } from "../_file-input-base";
5
5
  export interface FileInputProps extends FileInputBaseProps, Clearable {
6
6
  className?: string;
7
7
  helperText?: ReactNode;
8
- label?: ReactNode;
9
8
  hiddenLabel?: boolean;
9
+ label?: ReactNode;
10
10
  placeholder?: string;
11
- uploadButtonLabel?: string;
12
11
  size?: keyof InputGroupSizes;
12
+ uploadButtonLabel?: string;
13
13
  variant?: keyof InputGroupVariants;
14
14
  }
15
15
  export declare const FileInput: React.ForwardRefExoticComponent<FileInputProps & React.RefAttributes<HTMLInputElement>>;
@@ -53,7 +53,7 @@ exports.FileInput = (0, react_1.forwardRef)((props, ref) => {
53
53
  };
54
54
  return (react_1.default.createElement(form_component_1.FormComponent, { className: (0, cx_1.cx)(input.focused && classes_1.CLASSES.IS_FOCUSED, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isReadOnly && classes_1.CLASSES.IS_READONLY), errorId: errorId, form: props.form, helperText: props.helperText, inputId: id, isRequired: props.isRequired, label: props.label, hiddenLabel: props.hiddenLabel },
55
55
  react_1.default.createElement(react_1.default.Fragment, null,
56
- react_1.default.createElement(_file_input_base_1._FileInputBase, { accept: props.accept, "aria-describedby": errorId, "aria-invalid": props.isInvalid, className: `uxf-file-input__input ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, 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: props.onChange, onFocus: input.onFocus, onUploadError: props.onUploadError, onUploadFile: onUploadFile, ref: ref, value: props.value }),
56
+ react_1.default.createElement(_file_input_base_1._FileInputBase, { accept: props.accept, "aria-describedby": errorId, "aria-invalid": props.isInvalid, className: `uxf-file-input__input ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, form: props.form, id: id, isDisabled: props.isDisabled || isUploading, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, maxFileSize: props.maxFileSize, name: props.name, onBlur: input.onBlur, onChange: props.onChange, onFocus: input.onFocus, onUploadError: props.onUploadError, onUploadFile: onUploadFile, ref: ref, value: props.value }),
57
57
  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-${(_b = props.size) !== null && _b !== void 0 ? _b : "default"}`, `uxf-input--variant-${(_c = props.variant) !== null && _c !== void 0 ? _c : "default"}`), htmlFor: id },
58
58
  react_1.default.createElement("div", { className: "uxf-input__left-addon uxf-file-input__label__button" }, !isUploading ? ((_d = props.uploadButtonLabel) !== null && _d !== void 0 ? _d : "Vyberte soubor") : (react_1.default.createElement(loader_1.Loader, { className: "uxf-file-input__label__loader", size: "sm" }))),
59
59
  react_1.default.createElement("div", { className: "uxf-file-input__label__wrapper" },
@@ -52,6 +52,10 @@ function handleInputKeyDownRecursion(selectedOptions, onRemove) {
52
52
  onRemove(lastSelectedOption.id);
53
53
  }
54
54
  }
55
+ const OptionElement = (props) => {
56
+ return (react_3.default.createElement(react_2.Combobox.Option, { className: (optionState) => (0, cx_1.cx)("uxf-dropdown__item", optionState.active && props.withoutPopover && classes_1.CLASSES.IS_ACTIVE, optionState.disabled && classes_1.CLASSES.IS_DISABLED, optionState.selected && classes_1.CLASSES.IS_SELECTED), value: props.option }, (optionState) => (react_3.default.createElement(react_3.default.Fragment, null, props.withCheckboxes ? (react_3.default.createElement(checkbox_input_1.CheckboxInput, { isDisabled: optionState.disabled, isFocused: optionState.active, label: props.label, onChange: props.handleCheckboxChange, value: optionState.selected })) : (props.label)))));
57
+ };
58
+ OptionElement.displayName = "UxfUiMultiComboboxOption";
55
59
  exports._MultiComboboxBase = (0, react_3.forwardRef)((props, ref) => {
56
60
  var _a, _b, _c, _d, _e, _f, _g;
57
61
  const isAsync = !!props.loadOptions;
@@ -120,7 +124,7 @@ exports._MultiComboboxBase = (0, react_3.forwardRef)((props, ref) => {
120
124
  react_3.default.createElement(react_2.Combobox.Options, { className: (0, cx_1.cx)("uxf-dropdown", `uxf-dropdown--size-${(_a = props.size) !== null && _a !== void 0 ? _a : "default"}`, `uxf-dropdown--variant-${(_b = props.variant) !== null && _b !== void 0 ? _b : "default"}`, dropdown.placement === "bottom" && "uxf-dropdown--bottom", dropdown.placement === "top" && "uxf-dropdown--top"), ref: dropdown.refs.setFloating, static: true, style: dropdown.floatingStyles }, filteredData.length > 0 ? (filteredData.map((option) => {
121
125
  var _a, _b, _c, _d;
122
126
  const label = (_b = (_a = props.renderOption) === null || _a === void 0 ? void 0 : _a.call(props, option)) !== null && _b !== void 0 ? _b : option.label;
123
- return (react_3.default.createElement(react_2.Combobox.Option, { className: (optionState) => (0, cx_1.cx)("uxf-dropdown__item", optionState.active && withoutPopover && classes_1.CLASSES.IS_ACTIVE, optionState.disabled && classes_1.CLASSES.IS_DISABLED, optionState.selected && classes_1.CLASSES.IS_SELECTED), disabled: option.disabled, key: (_d = (_c = props.keyExtractor) === null || _c === void 0 ? void 0 : _c.call(props, option)) !== null && _d !== void 0 ? _d : option.id, value: option }, (optionState) => (react_3.default.createElement(react_3.default.Fragment, null, props.withCheckboxes ? (react_3.default.createElement(checkbox_input_1.CheckboxInput, { isDisabled: optionState.disabled, isFocused: optionState.active, label: label, onChange: handleCheckboxChange(option.id), value: optionState.selected })) : (label)))));
127
+ return (react_3.default.createElement(OptionElement, { option: option, key: (_d = (_c = props.keyExtractor) === null || _c === void 0 ? void 0 : _c.call(props, option)) !== null && _d !== void 0 ? _d : option.id, label: label, handleCheckboxChange: handleCheckboxChange(option.id), withCheckboxes: props.withCheckboxes, withoutPopover: withoutPopover }));
124
128
  })) : (react_3.default.createElement("div", { className: "uxf-dropdown__empty-wrapper" }, emptyMessage))))),
125
129
  props.helperText && withoutPopover && (react_3.default.createElement("div", { className: (0, cx_1.cx)("uxf-helper-text", props.isInvalid && classes_1.CLASSES.IS_INVALID), id: props.errorId }, props.helperText))));
126
130
  return (react_3.default.createElement(react_3.default.Fragment, null, withoutPopover ? (react_3.default.createElement(react_3.default.Fragment, null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/ui",
3
- "version": "10.6.0",
3
+ "version": "10.8.0",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -18,7 +18,7 @@
18
18
  "@floating-ui/react": "0.26.0",
19
19
  "@headlessui/react": "1.7.14",
20
20
  "@uxf/core": "10.4.0",
21
- "@uxf/datepicker": "10.0.0",
21
+ "@uxf/datepicker": "10.8.0",
22
22
  "@uxf/styles": "10.4.0",
23
23
  "color2k": "2.0.2",
24
24
  "dayjs": "1.11.10",
@@ -0,0 +1,3 @@
1
+ export declare enum ValidatorExceptions {
2
+ MaxFileSize = "MaxFileSizeException"
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidatorExceptions = void 0;
4
+ var ValidatorExceptions;
5
+ (function (ValidatorExceptions) {
6
+ ValidatorExceptions["MaxFileSize"] = "MaxFileSizeException";
7
+ })(ValidatorExceptions || (exports.ValidatorExceptions = ValidatorExceptions = {}));