@uxf/ui 1.0.0-beta.2 → 1.0.0-beta.26

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.
Files changed (175) hide show
  1. package/avatar-file-input/avatar-file-input.d.ts +32 -0
  2. package/avatar-file-input/avatar-file-input.jsx +57 -0
  3. package/avatar-file-input/avatar-file-input.stories.d.ts +7 -0
  4. package/avatar-file-input/avatar-file-input.stories.jsx +27 -0
  5. package/avatar-file-input/index.d.ts +1 -0
  6. package/avatar-file-input/index.jsx +8 -0
  7. package/button/button.d.ts +14 -0
  8. package/button/button.jsx +23 -0
  9. package/button/button.stories.d.ts +7 -0
  10. package/button/button.stories.jsx +64 -0
  11. package/button/index.d.ts +2 -0
  12. package/button/index.js +23 -0
  13. package/button/theme.d.ts +18 -0
  14. package/button/theme.js +2 -0
  15. package/checkbox/checkbox.d.ts +12 -0
  16. package/checkbox/checkbox.jsx +23 -0
  17. package/checkbox/checkbox.stories.d.ts +8 -0
  18. package/checkbox/checkbox.stories.jsx +18 -0
  19. package/checkbox/index.d.ts +1 -0
  20. package/checkbox/index.jsx +8 -0
  21. package/checkbox-input/checkbox-input.d.ts +3 -0
  22. package/checkbox-input/checkbox-input.jsx +6 -0
  23. package/checkbox-input/checkbox-input.stories.d.ts +8 -0
  24. package/checkbox-input/checkbox-input.stories.jsx +14 -0
  25. package/checkbox-input/index.d.ts +1 -0
  26. package/checkbox-input/index.jsx +8 -0
  27. package/combobox/combobox.d.ts +27 -0
  28. package/combobox/combobox.jsx +42 -0
  29. package/combobox/combobox.stories.d.ts +8 -0
  30. package/combobox/combobox.stories.jsx +26 -0
  31. package/combobox/index.d.ts +1 -0
  32. package/combobox/index.js +8 -0
  33. package/dropdown/dropdown.d.ts +10 -0
  34. package/dropdown/dropdown.jsx +26 -0
  35. package/dropdown/index.d.ts +1 -0
  36. package/dropdown/index.js +5 -0
  37. package/error-message/error-message.d.ts +7 -0
  38. package/error-message/error-message.jsx +8 -0
  39. package/error-message/error-message.stories.d.ts +8 -0
  40. package/error-message/error-message.stories.jsx +14 -0
  41. package/error-message/index.d.ts +1 -0
  42. package/error-message/index.js +8 -0
  43. package/hooks/use-dropdown.d.ts +7 -0
  44. package/hooks/use-dropdown.js +37 -0
  45. package/hooks/use-fix-android-on-focus.d.ts +2 -0
  46. package/hooks/use-fix-android-on-focus.js +31 -0
  47. package/hooks/use-input-submit.d.ts +4 -0
  48. package/hooks/use-input-submit.js +44 -0
  49. package/hooks/use-latest.d.ts +2 -0
  50. package/hooks/use-latest.js +12 -0
  51. package/icon/icon.d.ts +16 -0
  52. package/icon/icon.jsx +22 -0
  53. package/icon/icon.stories.d.ts +7 -0
  54. package/icon/icon.stories.jsx +50 -0
  55. package/icon/index.d.ts +1 -0
  56. package/icon/index.js +8 -0
  57. package/icon/theme.d.ts +1 -0
  58. package/icon/theme.js +2 -0
  59. package/image-gallery/components/close-button.d.ts +6 -0
  60. package/image-gallery/components/close-button.jsx +13 -0
  61. package/image-gallery/components/dot.d.ts +6 -0
  62. package/image-gallery/components/dot.jsx +12 -0
  63. package/image-gallery/components/gallery.d.ts +11 -0
  64. package/image-gallery/components/gallery.jsx +75 -0
  65. package/image-gallery/components/icon-chevron-left.d.ts +3 -0
  66. package/image-gallery/components/icon-chevron-left.jsx +12 -0
  67. package/image-gallery/components/icon-chevron-right.d.ts +3 -0
  68. package/image-gallery/components/icon-chevron-right.jsx +12 -0
  69. package/image-gallery/components/icon-close.d.ts +3 -0
  70. package/image-gallery/components/icon-close.jsx +12 -0
  71. package/image-gallery/components/next-button.d.ts +6 -0
  72. package/image-gallery/components/next-button.jsx +13 -0
  73. package/image-gallery/components/previous-button.d.ts +6 -0
  74. package/image-gallery/components/previous-button.jsx +13 -0
  75. package/image-gallery/context.d.ts +10 -0
  76. package/image-gallery/context.jsx +12 -0
  77. package/image-gallery/image-gallery.d.ts +6 -0
  78. package/image-gallery/image-gallery.jsx +56 -0
  79. package/image-gallery/image-gallery.stories.d.ts +13 -0
  80. package/image-gallery/image-gallery.stories.jsx +29 -0
  81. package/image-gallery/image.d.ts +4 -0
  82. package/image-gallery/image.jsx +12 -0
  83. package/image-gallery/index.d.ts +3 -0
  84. package/image-gallery/index.js +25 -0
  85. package/image-gallery/types.d.ts +6 -0
  86. package/image-gallery/types.js +2 -0
  87. package/image-gallery/use-image.d.ts +2 -0
  88. package/image-gallery/use-image.js +16 -0
  89. package/input/index.d.ts +13 -0
  90. package/input/index.js +19 -0
  91. package/input/input-element.d.ts +8 -0
  92. package/input/input-element.jsx +11 -0
  93. package/input/input-left-addon.d.ts +6 -0
  94. package/input/input-left-addon.jsx +10 -0
  95. package/input/input-left-element.d.ts +6 -0
  96. package/input/input-left-element.jsx +10 -0
  97. package/input/input-right-addon.d.ts +6 -0
  98. package/input/input-right-addon.jsx +10 -0
  99. package/input/input-right-element.d.ts +6 -0
  100. package/input/input-right-element.jsx +10 -0
  101. package/input/input.d.ts +8 -0
  102. package/input/input.jsx +64 -0
  103. package/input/input.stories.d.ts +14 -0
  104. package/input/input.stories.jsx +78 -0
  105. package/input/theme.d.ts +6 -0
  106. package/input/theme.js +2 -0
  107. package/label/index.d.ts +1 -0
  108. package/label/index.js +8 -0
  109. package/label/label.d.ts +10 -0
  110. package/label/label.jsx +10 -0
  111. package/label/label.stories.d.ts +7 -0
  112. package/label/label.stories.jsx +14 -0
  113. package/package.json +16 -34
  114. package/radio/index.d.ts +1 -0
  115. package/radio/index.jsx +8 -0
  116. package/radio/radio.d.ts +11 -0
  117. package/radio/radio.jsx +19 -0
  118. package/radio/radio.stories.d.ts +7 -0
  119. package/radio/radio.stories.jsx +17 -0
  120. package/radio-group/index.d.ts +1 -0
  121. package/radio-group/index.jsx +8 -0
  122. package/radio-group/radio-group.d.ts +25 -0
  123. package/radio-group/radio-group.jsx +30 -0
  124. package/radio-group/radio-group.stories.d.ts +7 -0
  125. package/radio-group/radio-group.stories.jsx +30 -0
  126. package/raster-image/index.d.ts +1 -0
  127. package/raster-image/index.jsx +8 -0
  128. package/raster-image/raster-image.d.ts +16 -0
  129. package/raster-image/raster-image.jsx +17 -0
  130. package/raster-image/raster-image.stories.d.ts +8 -0
  131. package/raster-image/raster-image.stories.jsx +14 -0
  132. package/select/index.d.ts +1 -0
  133. package/select/index.js +8 -0
  134. package/select/select.d.ts +27 -0
  135. package/select/select.jsx +58 -0
  136. package/select/select.stories.d.ts +8 -0
  137. package/select/select.stories.jsx +26 -0
  138. package/text-input/index.d.ts +1 -0
  139. package/text-input/index.js +17 -0
  140. package/text-input/text-input.d.ts +22 -0
  141. package/text-input/text-input.jsx +32 -0
  142. package/text-input/text-input.stories.d.ts +9 -0
  143. package/text-input/text-input.stories.jsx +54 -0
  144. package/textarea/index.d.ts +1 -0
  145. package/textarea/index.jsx +8 -0
  146. package/textarea/textarea.d.ts +26 -0
  147. package/textarea/textarea.jsx +54 -0
  148. package/textarea/textarea.stories.d.ts +7 -0
  149. package/textarea/textarea.stories.jsx +29 -0
  150. package/types/form-control-props.d.ts +24 -0
  151. package/types/form-control-props.js +2 -0
  152. package/types/index.d.ts +1 -0
  153. package/types/index.js +17 -0
  154. package/utils/action.d.ts +2 -0
  155. package/utils/action.js +11 -0
  156. package/utils/component-structure-analyzer.d.ts +6 -0
  157. package/utils/component-structure-analyzer.jsx +10 -0
  158. package/utils/cx.d.ts +3 -0
  159. package/utils/cx.js +54 -0
  160. package/utils/forwardRef.d.ts +12 -0
  161. package/utils/forwardRef.js +10 -0
  162. package/utils/image.d.ts +9 -0
  163. package/utils/image.jsx +28 -0
  164. package/utils/rem.d.ts +1 -0
  165. package/utils/rem.js +5 -0
  166. package/utils/storybook-config.d.ts +19 -0
  167. package/utils/storybook-config.jsx +24 -0
  168. package/components/button/button.d.ts +0 -14
  169. package/components/button/button.js +0 -19
  170. package/components/button/index.d.ts +0 -1
  171. package/components/button/index.js +0 -9
  172. package/theme/theme-context.d.ts +0 -10
  173. package/theme/theme-context.js +0 -59
  174. package/theme/theme.d.ts +0 -31
  175. package/theme/theme.js +0 -3
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Default = void 0;
4
+ const index_1 = require("./index");
5
+ exports.default = {
6
+ title: "UI/Radio",
7
+ component: index_1.Radio,
8
+ };
9
+ function Default() {
10
+ return (<div className="space-y-2">
11
+ <index_1.Radio label="Radio" checked={true} active={true}/>
12
+ <index_1.Radio label="Radio" checked={true} active={false}/>
13
+ <index_1.Radio label="Radio" checked={false} active={true}/>
14
+ <index_1.Radio label="Radio" checked={false} active={false}/>
15
+ </div>);
16
+ }
17
+ exports.Default = Default;
@@ -0,0 +1 @@
1
+ export { default as RadioGroup } from "./radio-group";
@@ -0,0 +1,8 @@
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.RadioGroup = void 0;
7
+ var radio_group_1 = require("./radio-group");
8
+ Object.defineProperty(exports, "RadioGroup", { enumerable: true, get: function () { return __importDefault(radio_group_1).default; } });
@@ -0,0 +1,25 @@
1
+ import { CSSProperties, FocusEventHandler } from "react";
2
+ export declare type RadioGroupOptionValue = string | number;
3
+ export interface RadioGroupOption {
4
+ disabled?: boolean;
5
+ label: string;
6
+ value: RadioGroupOptionValue;
7
+ }
8
+ export interface RadioGroupProps {
9
+ className?: string;
10
+ disabled?: boolean;
11
+ error?: string;
12
+ forceColumn?: boolean;
13
+ hiddenLabel?: boolean;
14
+ id: string;
15
+ invalid?: boolean;
16
+ label: string;
17
+ onBlur?: FocusEventHandler<HTMLDivElement>;
18
+ onChange: (value: RadioGroupOptionValue) => void;
19
+ onFocus?: FocusEventHandler<HTMLDivElement>;
20
+ options: RadioGroupOption[];
21
+ style?: CSSProperties;
22
+ value?: RadioGroupOptionValue | null;
23
+ }
24
+ declare const _default: import("react").ForwardRefExoticComponent<RadioGroupProps & import("react").RefAttributes<HTMLDivElement>>;
25
+ export default _default;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ const forwardRef_1 = require("../utils/forwardRef");
5
+ const react_2 = require("@headlessui/react");
6
+ const composeRefs_1 = require("@uxf/core/utils/composeRefs");
7
+ const label_1 = require("../label");
8
+ const radio_1 = require("../radio");
9
+ const error_message_1 = require("../error-message");
10
+ const use_input_submit_1 = require("../hooks/use-input-submit");
11
+ function RadioGroup(props, ref) {
12
+ const { className, disabled, error, forceColumn, hiddenLabel, id, invalid, label, onBlur, onChange, onFocus, options, style, value, } = props;
13
+ const innerRef = (0, react_1.useRef)(null);
14
+ (0, use_input_submit_1.useInputSubmit)(innerRef, "radio-group", disabled);
15
+ const errorId = invalid ? `${id}--errormessage` : undefined;
16
+ return (<react_2.RadioGroup className={`_form-field ${className || ""}`} disabled={disabled} id={id} value={value} onChange={onChange} style={style}>
17
+ {!hiddenLabel && (<react_2.RadioGroup.Label as={label_1.Label} className="mb-2">
18
+ {label}
19
+ </react_2.RadioGroup.Label>)}
20
+ {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
21
+ <div className={`flex ${forceColumn ? "flex-col" : "flex-wrap items-center"} focus-visible:ring-gray-dark outline-none focus-visible:ring-2`} onBlur={onBlur} onFocus={onFocus} ref={(0, composeRefs_1.composeRefs)(innerRef, ref)} tabIndex={disabled ? -1 : 0} // eslint-disable-line jsx-a11y/no-noninteractive-tabindex
22
+ >
23
+ {options.map((option) => (<react_2.RadioGroup.Option as={react_1.Fragment} disabled={option.disabled} key={option.value.toString()} value={option.value}>
24
+ {(o) => (<radio_1.Radio active={o.active} checked={o.checked} disabled={disabled || o.disabled} invalid={invalid} label={option.label}/>)}
25
+ </react_2.RadioGroup.Option>))}
26
+ </div>
27
+ {invalid && error && <error_message_1.ErrorMessage id={errorId}>{error}</error_message_1.ErrorMessage>}
28
+ </react_2.RadioGroup>);
29
+ }
30
+ exports.default = (0, forwardRef_1.forwardRef)("RadioGroup", RadioGroup);
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ declare const _default: {
3
+ title: string;
4
+ component: import("react").ForwardRefExoticComponent<import("./radio-group").RadioGroupProps & import("react").RefAttributes<HTMLDivElement>>;
5
+ };
6
+ export default _default;
7
+ export declare function Default(): JSX.Element;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Default = void 0;
4
+ const index_1 = require("./index");
5
+ const react_1 = require("react");
6
+ exports.default = {
7
+ title: "UI/RadioGroup",
8
+ component: index_1.RadioGroup,
9
+ };
10
+ const options = [
11
+ {
12
+ value: "1",
13
+ label: "Radio one",
14
+ },
15
+ {
16
+ value: "2",
17
+ label: "Radio two",
18
+ },
19
+ {
20
+ value: "3",
21
+ label: "Radio three",
22
+ },
23
+ ];
24
+ function Default() {
25
+ const [value, setValue] = (0, react_1.useState)(options[0].value);
26
+ return (<div className="space-y-2">
27
+ <index_1.RadioGroup id="radiogroup" options={options} label="Radio group" value={value} onChange={setValue}/>
28
+ </div>);
29
+ }
30
+ exports.Default = Default;
@@ -0,0 +1 @@
1
+ export { default as RasterImage } from "./raster-image";
@@ -0,0 +1,8 @@
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.RasterImage = void 0;
7
+ var raster_image_1 = require("./raster-image");
8
+ Object.defineProperty(exports, "RasterImage", { enumerable: true, get: function () { return __importDefault(raster_image_1).default; } });
@@ -0,0 +1,16 @@
1
+ import { ImgHTMLAttributes } from "react";
2
+ import { FileResponse } from "../utils/image";
3
+ declare type ImgProps = ImgHTMLAttributes<HTMLImageElement>;
4
+ interface Props {
5
+ alt: string;
6
+ className?: string;
7
+ height: number;
8
+ imgClassName?: string;
9
+ loading?: ImgProps["loading"];
10
+ mode?: "contain" | "cover" | "responsive";
11
+ role?: ImgProps["role"];
12
+ src?: FileResponse | null;
13
+ width: number;
14
+ }
15
+ declare function RasterImage(props: Props): JSX.Element;
16
+ export default RasterImage;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cx_1 = require("@uxf/core/utils/cx");
4
+ const image_1 = require("../utils/image");
5
+ const resizer_1 = require("@uxf/core/utils/resizer");
6
+ function RasterImage(props) {
7
+ var _a, _b;
8
+ const { alt, className, height, imgClassName, loading = "lazy", mode = "responsive", src, width, ...restProps } = props;
9
+ const Element = src ? "picture" : "div";
10
+ return (<Element className={`uxf-raster-image ${className || ""}`}>
11
+ {src ? (<>
12
+ {(0, image_1.getImgSources)(src, width, height)}
13
+ <img alt={alt} className={(0, cx_1.cx)("uxf-raster-image__img", mode === "contain" && "uxf-raster-image__img--contain", mode === "cover" && "uxf-raster-image__img--cover", imgClassName)} loading={loading} src={(_a = (0, resizer_1.resizerImageUrl)(src, width, height, {})) !== null && _a !== void 0 ? _a : undefined} srcSet={(_b = (0, image_1.getImgSrcSet)(src, width, height)) !== null && _b !== void 0 ? _b : undefined} {...restProps}/>
14
+ </>) : null}
15
+ </Element>);
16
+ }
17
+ exports.default = RasterImage;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { RasterImage } from "./index";
3
+ declare const _default: {
4
+ title: string;
5
+ component: typeof RasterImage;
6
+ };
7
+ export default _default;
8
+ export declare function Default(): JSX.Element;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Default = void 0;
4
+ const index_1 = require("./index");
5
+ exports.default = {
6
+ title: "UI/RasterImage",
7
+ component: index_1.RasterImage,
8
+ };
9
+ function Default() {
10
+ return (<div className="space-y-2">
11
+ <index_1.RasterImage alt="Alt text" height={100} width={300} mode="cover"/>
12
+ </div>);
13
+ }
14
+ exports.Default = Default;
@@ -0,0 +1 @@
1
+ export { default as Select, SelectProps } from "./select";
@@ -0,0 +1,8 @@
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.Select = void 0;
7
+ var select_1 = require("./select");
8
+ Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return __importDefault(select_1).default; } });
@@ -0,0 +1,27 @@
1
+ import { FocusEventHandler } from "react";
2
+ export declare type SelectValue = number | string;
3
+ export declare type SelectOption<T = SelectValue> = {
4
+ key?: number | string;
5
+ id: T;
6
+ label: string;
7
+ disabled?: boolean;
8
+ };
9
+ export interface SelectProps<V = SelectValue, O = SelectOption<V>> {
10
+ className?: string;
11
+ disabled?: boolean;
12
+ error?: string;
13
+ invalid?: boolean;
14
+ onChange: (value: O | null) => void;
15
+ onBlur?: FocusEventHandler<HTMLDivElement>;
16
+ onFocus?: FocusEventHandler<HTMLDivElement>;
17
+ name: string;
18
+ id: string;
19
+ label: string;
20
+ placeholder?: string;
21
+ options: O[];
22
+ readOnly?: boolean;
23
+ required?: boolean;
24
+ value?: V;
25
+ }
26
+ declare const _default: import("react").ForwardRefExoticComponent<SelectProps<SelectValue, SelectOption<SelectValue>> & import("react").RefAttributes<HTMLDivElement>>;
27
+ export default _default;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("@headlessui/react");
4
+ const dropdown_1 = require("../dropdown");
5
+ const use_dropdown_1 = require("../hooks/use-dropdown");
6
+ const classes_1 = require("@uxf/core/constants/classes");
7
+ const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
8
+ const composeRefs_1 = require("@uxf/core/utils/composeRefs");
9
+ const cx_1 = require("@uxf/core/utils/cx");
10
+ const react_2 = require("react");
11
+ const error_message_1 = require("../error-message");
12
+ const label_1 = require("../label");
13
+ const forwardRef_1 = require("@uxf/ui/utils/forwardRef");
14
+ function ChevronDown() {
15
+ return (<svg aria-hidden="true" focusable="false" data-prefix="fass" data-icon="chevron-down" className="svg-inline--fa fa-chevron-down " role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style={{ height: "1em" }}>
16
+ <path fill="currentColor" d="M256 429.3l22.6-22.6 192-192L493.3 192 448 146.7l-22.6 22.6L256 338.7 86.6 169.4 64 146.7 18.7 192l22.6 22.6 192 192L256 429.3z"></path>
17
+ </svg>);
18
+ }
19
+ function ChevronUp() {
20
+ return (<svg aria-hidden="true" focusable="false" data-prefix="fass" data-icon="chevron-up" className="svg-inline--fa fa-chevron-up " role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style={{ height: "1em" }}>
21
+ <path fill="currentColor" d="M256 82.7l22.6 22.6 192 192L493.3 320 448 365.3l-22.6-22.6L256 173.3 86.6 342.6 64 365.3 18.7 320l22.6-22.6 192-192L256 82.7z"></path>
22
+ </svg>);
23
+ }
24
+ function Select(props, ref) {
25
+ const { className, disabled, error, id, invalid, label, onBlur, onChange, onFocus, options, placeholder = "Vyberte z možností...", readOnly, value, } = props;
26
+ //const selectedOption = useMemo(() => options.find((option) => option.id === value), [options, value]);
27
+ const selectedOption = options.find((option) => option.id === value);
28
+ const innerRef = (0, react_2.useRef)(null);
29
+ const disabledOrReadOnly = disabled || readOnly;
30
+ const errorId = invalid ? `${id}--errormessage` : undefined;
31
+ const input = (0, useInputFocus_1.useInputFocus)(innerRef, onBlur, onFocus);
32
+ const dropdown = (0, use_dropdown_1.useDropdown)("bottom", true);
33
+ const stableRef = (0, react_2.useMemo)(() => (0, composeRefs_1.composeRefs)(innerRef, ref, dropdown.reference), [ref, dropdown.reference]);
34
+ return (<react_1.Listbox as="div" className={`select-form-field ${className || ""}`} onChange={onChange} value={selectedOption}>
35
+ <react_1.Listbox.Label as={label_1.Label} onClick={!disabledOrReadOnly ? input.focus : undefined}>
36
+ {label}
37
+ </react_1.Listbox.Label>
38
+ <react_1.Listbox.Button as="div" className={""}>
39
+ {(b) => (
40
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
41
+ <div aria-invalid={invalid} aria-describedby={errorId} className={(0, cx_1.cx)("select-text-input select-text-input__control--select", (b.open || input.focused) && classes_1.CLASSES.IS_FOCUSED, b.disabled && classes_1.CLASSES.IS_DISABLED, readOnly && classes_1.CLASSES.IS_READONLY, invalid && classes_1.CLASSES.IS_INVALID)} onBlur={input.onBlur} onFocus={input.onFocus} tabIndex={!disabledOrReadOnly ? 0 : undefined} ref={stableRef}>
42
+ <div className={`w-full ${!value ? "text-gray-muted" : ""}`}>
43
+ {(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || placeholder}
44
+ </div>
45
+ {b.open ? <ChevronUp /> : <ChevronDown />}
46
+ </div>)}
47
+ </react_1.Listbox.Button>
48
+ {invalid && error && <error_message_1.ErrorMessage id={errorId}>{error}</error_message_1.ErrorMessage>}
49
+ <react_1.Listbox.Options as={dropdown_1.Dropdown.Items} className="w-full" ref={dropdown.floating} style={dropdown.style}>
50
+ {options.map((option) => (<react_1.Listbox.Option as={react_2.Fragment} key={option.key || option.id} value={option}>
51
+ {(o) => (<dropdown_1.Dropdown.Item className={(0, cx_1.cx)(o.active && classes_1.CLASSES.IS_ACTIVE, o.disabled && classes_1.CLASSES.IS_DISABLED, o.selected && classes_1.CLASSES.IS_SELECTED)}>
52
+ {option.label}
53
+ </dropdown_1.Dropdown.Item>)}
54
+ </react_1.Listbox.Option>))}
55
+ </react_1.Listbox.Options>
56
+ </react_1.Listbox>);
57
+ }
58
+ exports.default = (0, forwardRef_1.forwardRef)("Select", Select);
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { SelectOption } from "./select";
3
+ declare const _default: {
4
+ title: string;
5
+ component: import("react").ForwardRefExoticComponent<import("./select").SelectProps<import("./select").SelectValue, SelectOption<import("./select").SelectValue>> & import("react").RefAttributes<HTMLDivElement>>;
6
+ };
7
+ export default _default;
8
+ export declare function Default(): JSX.Element;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Default = void 0;
4
+ const index_1 = require("./index");
5
+ const react_1 = require("react");
6
+ exports.default = {
7
+ title: "UI/Select",
8
+ component: index_1.Select,
9
+ };
10
+ const options = [
11
+ { id: "one", label: "Option one" },
12
+ { id: "two", label: "Option two" },
13
+ { id: "three", label: "Option three" },
14
+ ];
15
+ function Default() {
16
+ const [value, setValue] = (0, react_1.useState)();
17
+ const handleChange = (v) => {
18
+ // eslint-disable-next-line no-console
19
+ console.log("Select value: ", v);
20
+ setValue(v === null || v === void 0 ? void 0 : v.id);
21
+ };
22
+ return (<div className="space-y-2">
23
+ <index_1.Select id={"select-1"} name="select" label="Choose option..." options={options} onChange={handleChange} value={value}/>
24
+ </div>);
25
+ }
26
+ exports.Default = Default;
@@ -0,0 +1 @@
1
+ export * from "./text-input";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./text-input"), exports);
@@ -0,0 +1,22 @@
1
+ import { FormControlProps } from "@uxf/ui/types";
2
+ import { ReactNode } from "react";
3
+ import { InputProps } from "@uxf/ui/input/input";
4
+ declare type EnterKeyHint = "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
5
+ declare type InputMode = "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
6
+ export interface TextInputProps extends FormControlProps<string>, Pick<InputProps, "size" | "variant"> {
7
+ autoComplete?: string;
8
+ className?: string;
9
+ enterKeyHint?: EnterKeyHint;
10
+ form?: string;
11
+ id?: string;
12
+ inputMode?: InputMode;
13
+ label?: ReactNode;
14
+ helperText?: ReactNode;
15
+ placeholder?: string;
16
+ leftElement?: ReactNode;
17
+ rightElement?: ReactNode;
18
+ leftAddon?: ReactNode;
19
+ rightAddon?: ReactNode;
20
+ }
21
+ export declare function TextInput(props: TextInputProps): JSX.Element;
22
+ export {};
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextInput = void 0;
4
+ const input_1 = require("@uxf/ui/input");
5
+ const react_1 = require("react");
6
+ const cx_1 = require("@uxf/core/utils/cx");
7
+ function TextInput(props) {
8
+ const [isFocused, setIsFocused] = (0, react_1.useState)(false);
9
+ const rootClassName = (0, cx_1.cx)("uxf-text-input", props.isInvalid && "uxf-text-input--invalid", props.isDisabled && "uxf-text-input--disabled", props.isRequired && "uxf-text-input--required", isFocused && "uxf-text-input--focused");
10
+ const onFocus = (e) => {
11
+ var _a;
12
+ setIsFocused(true);
13
+ (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e);
14
+ };
15
+ const onBlur = (e) => {
16
+ var _a;
17
+ setIsFocused(false);
18
+ (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
19
+ };
20
+ return (<div className={rootClassName}>
21
+ <label className="uxf-text-input__label">{props.label}</label>
22
+ <input_1.Input size={props.size} variant={props.variant}>
23
+ {props.leftAddon && <input_1.Input.LeftAddon>{props.leftAddon}</input_1.Input.LeftAddon>}
24
+ {props.leftElement && <input_1.Input.LeftElement>{props.leftElement}</input_1.Input.LeftElement>}
25
+ <input_1.Input.Element name={props.name} value={props.value} onChange={props.onChange} onFocus={onFocus} onBlur={onBlur} isInvalid={props.isInvalid} isRequired={props.isRequired} isReadOnly={props.isReadOnly} isDisabled={props.isDisabled} placeholder={props.placeholder}/>
26
+ {props.rightElement && <input_1.Input.RightElement>{props.rightElement}</input_1.Input.RightElement>}
27
+ {props.rightAddon && <input_1.Input.RightAddon>{props.rightAddon}</input_1.Input.RightAddon>}
28
+ </input_1.Input>
29
+ <div className="uxf-text-input__helper-text">{props.helperText}</div>
30
+ </div>);
31
+ }
32
+ exports.TextInput = TextInput;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { TextInput } from "@uxf/ui/text-input";
3
+ declare const _default: {
4
+ title: string;
5
+ component: typeof TextInput;
6
+ };
7
+ export default _default;
8
+ export declare function Default(): JSX.Element;
9
+ export declare function ComponentStructure(): JSX.Element;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.ComponentStructure = exports.Default = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const text_input_1 = require("@uxf/ui/text-input");
32
+ const component_structure_analyzer_1 = __importDefault(require("@uxf/ui/utils/component-structure-analyzer"));
33
+ exports.default = {
34
+ title: "UI/TextInput",
35
+ component: text_input_1.TextInput,
36
+ };
37
+ function Default() {
38
+ const [value, onChange] = (0, react_1.useState)("");
39
+ const [isInvalid, setInvalid] = (0, react_1.useState)(false);
40
+ return (<div className="space-y-4">
41
+ <input type="checkbox" checked={isInvalid} onChange={(e) => setInvalid(e.target.checked)}/>
42
+ <text_input_1.TextInput label="Label" value={value} onChange={onChange} isInvalid={isInvalid} helperText="Helper text" isRequired/>
43
+ <text_input_1.TextInput label="Label" value={value} onChange={onChange} isInvalid={isInvalid} helperText="Helper text" leftElement="USD"/>
44
+ <text_input_1.TextInput label="Label" value={value} onChange={onChange} isInvalid={isInvalid} helperText="Helper text" leftAddon="https://" rightAddon=".cz" leftElement="🌷" rightElement="🔔"/>
45
+ </div>);
46
+ }
47
+ exports.Default = Default;
48
+ function ComponentStructure() {
49
+ const [value, onChange] = (0, react_1.useState)("");
50
+ return (<component_structure_analyzer_1.default>
51
+ <text_input_1.TextInput label="Label" placeholder="Placeholder" leftElement="🌷" rightElement="🔔" leftAddon="https://" rightAddon=".cz" value={value} onChange={onChange} isInvalid={false} helperText="Helper text"/>
52
+ </component_structure_analyzer_1.default>);
53
+ }
54
+ exports.ComponentStructure = ComponentStructure;
@@ -0,0 +1 @@
1
+ export { default as Textarea, TextareaProps } from "./textarea";
@@ -0,0 +1,8 @@
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.Textarea = void 0;
7
+ var textarea_1 = require("./textarea");
8
+ Object.defineProperty(exports, "Textarea", { enumerable: true, get: function () { return __importDefault(textarea_1).default; } });
@@ -0,0 +1,26 @@
1
+ import { ChangeEventHandler, CSSProperties, FocusEventHandler } from "react";
2
+ export interface TextareaProps {
3
+ autoComplete?: string;
4
+ className?: string;
5
+ disabled?: boolean;
6
+ disableAutoHeight?: boolean;
7
+ error?: string;
8
+ form?: string;
9
+ id: string;
10
+ invalid?: boolean;
11
+ label: string;
12
+ maxLength?: number | undefined;
13
+ minLength?: number | undefined;
14
+ name?: string;
15
+ onBlur?: FocusEventHandler<HTMLTextAreaElement>;
16
+ onChange: ChangeEventHandler<HTMLTextAreaElement>;
17
+ onFocus?: FocusEventHandler<HTMLTextAreaElement>;
18
+ placeholder?: string;
19
+ readOnly?: boolean;
20
+ required?: boolean;
21
+ rows?: number;
22
+ style?: CSSProperties;
23
+ value?: string | null;
24
+ }
25
+ declare const _default: import("react").ForwardRefExoticComponent<TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
26
+ export default _default;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ const forwardRef_1 = require("../utils/forwardRef");
5
+ const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
6
+ const label_1 = require("../label");
7
+ const cx_1 = require("@uxf/core/utils/cx");
8
+ const error_message_1 = require("../error-message");
9
+ const use_fix_android_on_focus_1 = require("../hooks/use-fix-android-on-focus");
10
+ const use_latest_1 = require("../hooks/use-latest");
11
+ const classes_1 = require("@uxf/core/constants/classes");
12
+ const composeRefs_1 = require("@uxf/core/utils/composeRefs");
13
+ function autoHeightHandler(element, rows = 4) {
14
+ element.style.height = "auto";
15
+ if (rows > 1) {
16
+ const contentHeight = element.scrollHeight;
17
+ const lineHeight = parseInt(window.getComputedStyle(element).getPropertyValue("line-height"), 10);
18
+ const fontSize = parseInt(window.getComputedStyle(element).getPropertyValue("font-size"), 10);
19
+ const targetHeight = rows * fontSize * (lineHeight / fontSize);
20
+ element.style.height = Math.max(targetHeight, contentHeight) + "px";
21
+ }
22
+ }
23
+ const EVENTS = ["input", "cut", "paste", "drop"];
24
+ function Textarea(props, ref) {
25
+ const { autoComplete, className, disabled, disableAutoHeight, error, form, id, invalid, label, maxLength, minLength, name, onBlur, onChange, onFocus, placeholder, readOnly, required, rows, style, value, } = props;
26
+ const innerRef = (0, react_1.useRef)(null);
27
+ const input = (0, useInputFocus_1.useInputFocus)(innerRef, onBlur, onFocus);
28
+ const fixedOnFocus = (0, use_fix_android_on_focus_1.useFixAndroidOnFocus)(input.onFocus);
29
+ const errorId = invalid && id ? `${id}--errormessage` : undefined;
30
+ const latestRows = (0, use_latest_1.useLatest)(rows);
31
+ (0, react_1.useEffect)(() => {
32
+ const node = innerRef.current;
33
+ if (!node || disableAutoHeight) {
34
+ return;
35
+ }
36
+ const handler = () => autoHeightHandler(node, latestRows.current);
37
+ handler();
38
+ EVENTS.map((e) => node.addEventListener(e, handler));
39
+ window.addEventListener("resize", handler);
40
+ return () => {
41
+ EVENTS.map((e) => node.removeEventListener(e, handler));
42
+ window.removeEventListener("resize", handler);
43
+ };
44
+ }, [disableAutoHeight, latestRows]);
45
+ return (<div className={`uxf-textarea-wrapper ${className || ""}`} style={style}>
46
+ <label_1.Label htmlFor={id}>{label}</label_1.Label>
47
+ {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */}
48
+ <div className={(0, cx_1.cx)("uxf-textarea-nextwrapper h-auto", input.focused && classes_1.CLASSES.IS_FOCUSED, disabled && classes_1.CLASSES.IS_DISABLED, readOnly && classes_1.CLASSES.IS_READONLY, invalid && classes_1.CLASSES.IS_INVALID)} onClick={!disabled ? input.focus : undefined}>
49
+ <textarea aria-describedby={errorId} aria-invalid={invalid} autoComplete={autoComplete} className="uxf-textarea-textarea" disabled={disabled} form={form} id={id} maxLength={maxLength} minLength={minLength} name={name} onBlur={input.onBlur} onChange={onChange} onFocus={fixedOnFocus} placeholder={placeholder} readOnly={readOnly} ref={(0, composeRefs_1.composeRefs)(innerRef, ref)} required={required} value={value !== null && value !== void 0 ? value : undefined}/>
50
+ </div>
51
+ {invalid && error && <error_message_1.ErrorMessage id={errorId}>{error}</error_message_1.ErrorMessage>}
52
+ </div>);
53
+ }
54
+ exports.default = (0, forwardRef_1.forwardRef)("Textarea", Textarea);
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ declare const _default: {
3
+ title: string;
4
+ component: import("react").ForwardRefExoticComponent<import("./textarea").TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
5
+ };
6
+ export default _default;
7
+ export declare function Default(): JSX.Element;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Default = void 0;
4
+ const index_1 = require("./index");
5
+ exports.default = {
6
+ title: "UI/Textarea",
7
+ component: index_1.Textarea,
8
+ };
9
+ function Default() {
10
+ return (<div className="space-y-2">
11
+ <index_1.Textarea id={"textarea"} label={"Textarea"} onChange={() => {
12
+ // eslint-disable-next-line no-console
13
+ console.log("textarea onChange");
14
+ }} placeholder="Placeholder text...."/>
15
+ <index_1.Textarea id={"textarea-readonly"} label={"Readonly"} readOnly={true} onChange={() => {
16
+ // eslint-disable-next-line no-console
17
+ console.log("textarea OnChange");
18
+ }}/>
19
+ <index_1.Textarea disabled={true} id={"textarea-disabled"} label={"Textarea disabled"} onChange={() => {
20
+ // eslint-disable-next-line no-console
21
+ console.log("textarea OnChange");
22
+ }}/>
23
+ <index_1.Textarea rows={10} id={"textarea-rows10"} label={"Textarea rows = 10"} placeholder="Placeholder text...." onChange={() => {
24
+ // eslint-disable-next-line no-console
25
+ console.log("textarea OnChange");
26
+ }}/>
27
+ </div>);
28
+ }
29
+ exports.Default = Default;