@uxf/ui 1.0.0-beta.22 → 1.0.0-beta.27
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/avatar-file-input/avatar-file-input.d.ts +32 -0
- package/avatar-file-input/avatar-file-input.js +73 -0
- package/avatar-file-input/avatar-file-input.stories.d.ts +7 -0
- package/avatar-file-input/avatar-file-input.stories.js +30 -0
- package/avatar-file-input/index.d.ts +1 -0
- package/avatar-file-input/index.js +8 -0
- package/button/button.d.ts +14 -0
- package/button/button.js +22 -0
- package/button/button.stories.d.ts +7 -0
- package/button/button.stories.js +52 -0
- package/button/index.d.ts +2 -0
- package/button/index.js +23 -0
- package/button/theme.d.ts +18 -0
- package/{avatar → button}/theme.js +0 -0
- package/checkbox/checkbox.d.ts +12 -0
- package/checkbox/checkbox.js +24 -0
- package/{avatar/avatar.stories.d.ts → checkbox/checkbox.stories.d.ts} +2 -2
- package/checkbox/checkbox.stories.js +40 -0
- package/checkbox/index.d.ts +1 -0
- package/checkbox/index.js +8 -0
- package/checkbox-input/checkbox-input.d.ts +3 -0
- package/checkbox-input/checkbox-input.js +10 -0
- package/checkbox-input/checkbox-input.stories.d.ts +8 -0
- package/checkbox-input/checkbox-input.stories.js +17 -0
- package/checkbox-input/index.d.ts +1 -0
- package/checkbox-input/index.js +8 -0
- package/combobox/combobox.d.ts +27 -0
- package/combobox/combobox.js +56 -0
- package/combobox/combobox.stories.d.ts +8 -0
- package/combobox/combobox.stories.js +48 -0
- package/combobox/index.d.ts +1 -0
- package/combobox/index.js +8 -0
- package/dropdown/dropdown.d.ts +10 -0
- package/dropdown/dropdown.js +26 -0
- package/dropdown/index.d.ts +1 -0
- package/dropdown/index.js +5 -0
- package/error-message/error-message.d.ts +7 -0
- package/error-message/error-message.js +10 -0
- package/error-message/error-message.stories.d.ts +8 -0
- package/error-message/error-message.stories.js +17 -0
- package/error-message/index.d.ts +1 -0
- package/error-message/index.js +8 -0
- package/hooks/use-dropdown.d.ts +7 -0
- package/hooks/use-dropdown.js +37 -0
- package/hooks/use-fix-android-on-focus.d.ts +2 -0
- package/hooks/use-fix-android-on-focus.js +31 -0
- package/hooks/use-input-submit.d.ts +4 -0
- package/hooks/use-input-submit.js +44 -0
- package/hooks/use-latest.d.ts +2 -0
- package/hooks/use-latest.js +12 -0
- package/icon/icon.d.ts +16 -0
- package/icon/icon.js +25 -0
- package/icon/icon.stories.d.ts +7 -0
- package/icon/icon.stories.js +72 -0
- package/icon/index.d.ts +1 -0
- package/icon/index.js +8 -0
- package/icon/theme.d.ts +1 -0
- package/icon/theme.js +2 -0
- package/image-gallery/components/close-button.d.ts +6 -0
- package/image-gallery/components/close-button.js +12 -0
- package/image-gallery/components/dot.d.ts +6 -0
- package/image-gallery/components/dot.js +12 -0
- package/image-gallery/components/gallery.d.ts +11 -0
- package/image-gallery/components/gallery.js +68 -0
- package/image-gallery/components/icon-chevron-left.d.ts +3 -0
- package/image-gallery/components/icon-chevron-left.js +11 -0
- package/image-gallery/components/icon-chevron-right.d.ts +3 -0
- package/image-gallery/components/icon-chevron-right.js +11 -0
- package/image-gallery/components/icon-close.d.ts +3 -0
- package/image-gallery/components/icon-close.js +11 -0
- package/image-gallery/components/next-button.d.ts +6 -0
- package/image-gallery/components/next-button.js +12 -0
- package/image-gallery/components/previous-button.d.ts +6 -0
- package/image-gallery/components/previous-button.js +12 -0
- package/image-gallery/context.d.ts +10 -0
- package/image-gallery/context.js +12 -0
- package/image-gallery/image-gallery.d.ts +6 -0
- package/image-gallery/image-gallery.js +55 -0
- package/image-gallery/image-gallery.stories.d.ts +13 -0
- package/image-gallery/image-gallery.stories.js +26 -0
- package/image-gallery/image.d.ts +4 -0
- package/image-gallery/image.js +12 -0
- package/image-gallery/index.d.ts +3 -0
- package/image-gallery/index.js +25 -0
- package/image-gallery/types.d.ts +6 -0
- package/image-gallery/types.js +2 -0
- package/image-gallery/use-image.d.ts +2 -0
- package/image-gallery/use-image.js +16 -0
- package/input/index.d.ts +13 -0
- package/input/index.js +19 -0
- package/input/input-element.d.ts +8 -0
- package/input/input-element.js +11 -0
- package/input/input-left-addon.d.ts +6 -0
- package/input/input-left-addon.js +10 -0
- package/input/input-left-element.d.ts +6 -0
- package/input/input-left-element.js +10 -0
- package/input/input-right-addon.d.ts +6 -0
- package/input/input-right-addon.js +10 -0
- package/input/input-right-element.d.ts +6 -0
- package/input/input-right-element.js +10 -0
- package/input/input.d.ts +8 -0
- package/input/input.js +62 -0
- package/input/input.stories.d.ts +14 -0
- package/input/input.stories.js +71 -0
- package/input/theme.d.ts +6 -0
- package/input/theme.js +2 -0
- package/label/index.d.ts +1 -0
- package/label/index.js +8 -0
- package/label/label.d.ts +10 -0
- package/label/label.js +12 -0
- package/label/label.stories.d.ts +7 -0
- package/label/label.stories.js +17 -0
- package/package.json +11 -6
- package/radio/index.d.ts +1 -0
- package/radio/index.js +8 -0
- package/radio/radio.d.ts +11 -0
- package/radio/radio.js +17 -0
- package/radio/radio.stories.d.ts +7 -0
- package/radio/radio.stories.js +20 -0
- package/radio-group/index.d.ts +1 -0
- package/radio-group/index.js +8 -0
- package/radio-group/radio-group.d.ts +25 -0
- package/radio-group/radio-group.js +44 -0
- package/radio-group/radio-group.stories.d.ts +7 -0
- package/radio-group/radio-group.stories.js +52 -0
- package/raster-image/index.d.ts +1 -0
- package/raster-image/index.js +8 -0
- package/raster-image/raster-image.d.ts +16 -0
- package/raster-image/raster-image.js +18 -0
- package/raster-image/raster-image.stories.d.ts +8 -0
- package/raster-image/raster-image.stories.js +17 -0
- package/select/index.d.ts +1 -0
- package/select/index.js +8 -0
- package/select/select.d.ts +27 -0
- package/select/select.js +65 -0
- package/select/select.stories.d.ts +8 -0
- package/select/select.stories.js +48 -0
- package/text-input/index.d.ts +1 -0
- package/text-input/index.js +17 -0
- package/text-input/text-input.d.ts +22 -0
- package/text-input/text-input.js +53 -0
- package/text-input/text-input.stories.d.ts +9 -0
- package/text-input/text-input.stories.js +52 -0
- package/textarea/index.d.ts +1 -0
- package/textarea/index.js +8 -0
- package/textarea/textarea.d.ts +26 -0
- package/textarea/textarea.js +74 -0
- package/textarea/textarea.stories.d.ts +7 -0
- package/textarea/textarea.stories.js +32 -0
- package/types/form-control-props.d.ts +24 -0
- package/types/form-control-props.js +2 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +17 -0
- package/utils/action.d.ts +2 -0
- package/utils/action.js +11 -0
- package/utils/component-structure-analyzer.d.ts +6 -0
- package/utils/component-structure-analyzer.js +10 -0
- package/utils/cx.d.ts +3 -0
- package/utils/cx.js +54 -0
- package/utils/forwardRef.d.ts +12 -0
- package/utils/forwardRef.js +10 -0
- package/utils/image.d.ts +9 -0
- package/utils/image.js +30 -0
- package/utils/rem.d.ts +1 -0
- package/utils/rem.js +5 -0
- package/utils/storybook-config.d.ts +19 -0
- package/utils/storybook-config.js +47 -0
- package/avatar/avatar.d.ts +0 -14
- package/avatar/avatar.jsx +0 -10
- package/avatar/avatar.stories.jsx +0 -29
- package/avatar/theme.d.ts +0 -5
|
@@ -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 React, { 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: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const react_1 = __importStar(require("react"));
|
|
27
|
+
const forwardRef_1 = require("../utils/forwardRef");
|
|
28
|
+
const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
|
|
29
|
+
const label_1 = require("../label");
|
|
30
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
31
|
+
const error_message_1 = require("../error-message");
|
|
32
|
+
const use_fix_android_on_focus_1 = require("../hooks/use-fix-android-on-focus");
|
|
33
|
+
const use_latest_1 = require("../hooks/use-latest");
|
|
34
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
35
|
+
const composeRefs_1 = require("@uxf/core/utils/composeRefs");
|
|
36
|
+
function autoHeightHandler(element, rows = 4) {
|
|
37
|
+
element.style.height = "auto";
|
|
38
|
+
if (rows > 1) {
|
|
39
|
+
const contentHeight = element.scrollHeight;
|
|
40
|
+
const lineHeight = parseInt(window.getComputedStyle(element).getPropertyValue("line-height"), 10);
|
|
41
|
+
const fontSize = parseInt(window.getComputedStyle(element).getPropertyValue("font-size"), 10);
|
|
42
|
+
const targetHeight = rows * fontSize * (lineHeight / fontSize);
|
|
43
|
+
element.style.height = Math.max(targetHeight, contentHeight) + "px";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const EVENTS = ["input", "cut", "paste", "drop"];
|
|
47
|
+
function Textarea(props, ref) {
|
|
48
|
+
const { autoComplete, className, disabled, disableAutoHeight, error, form, id, invalid, label, maxLength, minLength, name, onBlur, onChange, onFocus, placeholder, readOnly, required, rows, style, value, } = props;
|
|
49
|
+
const innerRef = (0, react_1.useRef)(null);
|
|
50
|
+
const input = (0, useInputFocus_1.useInputFocus)(innerRef, onBlur, onFocus);
|
|
51
|
+
const fixedOnFocus = (0, use_fix_android_on_focus_1.useFixAndroidOnFocus)(input.onFocus);
|
|
52
|
+
const errorId = invalid && id ? `${id}--errormessage` : undefined;
|
|
53
|
+
const latestRows = (0, use_latest_1.useLatest)(rows);
|
|
54
|
+
(0, react_1.useEffect)(() => {
|
|
55
|
+
const node = innerRef.current;
|
|
56
|
+
if (!node || disableAutoHeight) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const handler = () => autoHeightHandler(node, latestRows.current);
|
|
60
|
+
handler();
|
|
61
|
+
EVENTS.map((e) => node.addEventListener(e, handler));
|
|
62
|
+
window.addEventListener("resize", handler);
|
|
63
|
+
return () => {
|
|
64
|
+
EVENTS.map((e) => node.removeEventListener(e, handler));
|
|
65
|
+
window.removeEventListener("resize", handler);
|
|
66
|
+
};
|
|
67
|
+
}, [disableAutoHeight, latestRows]);
|
|
68
|
+
return (react_1.default.createElement("div", { className: `uxf-textarea-wrapper ${className || ""}`, style: style },
|
|
69
|
+
react_1.default.createElement(label_1.Label, { htmlFor: id }, label),
|
|
70
|
+
react_1.default.createElement("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 },
|
|
71
|
+
react_1.default.createElement("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 })),
|
|
72
|
+
invalid && error && react_1.default.createElement(error_message_1.ErrorMessage, { id: errorId }, error)));
|
|
73
|
+
}
|
|
74
|
+
exports.default = (0, forwardRef_1.forwardRef)("Textarea", Textarea);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.ForwardRefExoticComponent<import("./textarea").TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export declare function Default(): JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 index_1 = require("./index");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
exports.default = {
|
|
10
|
+
title: "UI/Textarea",
|
|
11
|
+
component: index_1.Textarea,
|
|
12
|
+
};
|
|
13
|
+
function Default() {
|
|
14
|
+
return (react_1.default.createElement("div", { className: "space-y-2" },
|
|
15
|
+
react_1.default.createElement(index_1.Textarea, { id: "textarea", label: "Textarea", onChange: () => {
|
|
16
|
+
// eslint-disable-next-line no-console
|
|
17
|
+
console.log("textarea onChange");
|
|
18
|
+
}, placeholder: "Placeholder text...." }),
|
|
19
|
+
react_1.default.createElement(index_1.Textarea, { id: "textarea-readonly", label: "Readonly", readOnly: true, onChange: () => {
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.log("textarea OnChange");
|
|
22
|
+
} }),
|
|
23
|
+
react_1.default.createElement(index_1.Textarea, { disabled: true, id: "textarea-disabled", label: "Textarea disabled", onChange: () => {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.log("textarea OnChange");
|
|
26
|
+
} }),
|
|
27
|
+
react_1.default.createElement(index_1.Textarea, { rows: 10, id: "textarea-rows10", label: "Textarea rows = 10", placeholder: "Placeholder text....", onChange: () => {
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
29
|
+
console.log("textarea OnChange");
|
|
30
|
+
} })));
|
|
31
|
+
}
|
|
32
|
+
exports.Default = Default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ChangeEvent, FocusEventHandler } from "react";
|
|
2
|
+
export interface FormControlProps<ValueType, ElementType = HTMLInputElement, RestParams extends unknown[] = []> {
|
|
3
|
+
value?: ValueType;
|
|
4
|
+
onChange?: (value: ValueType, event?: ChangeEvent<ElementType>, ...args: RestParams) => void;
|
|
5
|
+
onBlur?: FocusEventHandler<ElementType>;
|
|
6
|
+
onFocus?: FocusEventHandler<ElementType>;
|
|
7
|
+
name?: string;
|
|
8
|
+
/**
|
|
9
|
+
* @about
|
|
10
|
+
* The input element will be disabled.
|
|
11
|
+
*/
|
|
12
|
+
isDisabled?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @about
|
|
15
|
+
* It prevents the user from changing the value of the field (not from interacting with the field).
|
|
16
|
+
*/
|
|
17
|
+
isReadOnly?: boolean;
|
|
18
|
+
isInvalid?: boolean;
|
|
19
|
+
isRequired?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare type OptionType<ValueType = string, LabelType = string> = {
|
|
22
|
+
value: ValueType;
|
|
23
|
+
label: LabelType;
|
|
24
|
+
};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./form-control-props";
|
package/types/index.js
ADDED
|
@@ -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("./form-control-props"), exports);
|
package/utils/action.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.action = void 0;
|
|
4
|
+
const addon_actions_1 = require("@storybook/addon-actions");
|
|
5
|
+
function action(name, handler) {
|
|
6
|
+
return function (...args) {
|
|
7
|
+
(0, addon_actions_1.action)(name)(...args);
|
|
8
|
+
handler(...args);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
exports.action = action;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
function ComponentStructureAnalyzer(props) {
|
|
8
|
+
return react_1.default.createElement("div", { className: "uxf-component-structure-analyzer" }, props.children);
|
|
9
|
+
}
|
|
10
|
+
exports.default = ComponentStructureAnalyzer;
|
package/utils/cx.d.ts
ADDED
package/utils/cx.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cx = void 0;
|
|
4
|
+
function toVal(mix) {
|
|
5
|
+
let k;
|
|
6
|
+
let y;
|
|
7
|
+
let str = "";
|
|
8
|
+
if (typeof mix === "string" || typeof mix === "number") {
|
|
9
|
+
str += mix;
|
|
10
|
+
}
|
|
11
|
+
else if (typeof mix === "object") {
|
|
12
|
+
if (Array.isArray(mix)) {
|
|
13
|
+
for (k = 0; k < mix.length; k++) {
|
|
14
|
+
if (mix[k]) {
|
|
15
|
+
if ((y = toVal(mix[k]))) {
|
|
16
|
+
if (str) {
|
|
17
|
+
str += " ";
|
|
18
|
+
}
|
|
19
|
+
str += y;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
for (k in mix) {
|
|
26
|
+
if (mix === null || mix === void 0 ? void 0 : mix[k]) {
|
|
27
|
+
if (str) {
|
|
28
|
+
str += " ";
|
|
29
|
+
}
|
|
30
|
+
str += k;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return str;
|
|
36
|
+
}
|
|
37
|
+
function cx(...classes) {
|
|
38
|
+
let i = 0;
|
|
39
|
+
let tmp;
|
|
40
|
+
let x;
|
|
41
|
+
let str = "";
|
|
42
|
+
while (i < classes.length) {
|
|
43
|
+
if ((tmp = classes[i++])) {
|
|
44
|
+
if ((x = toVal(tmp))) {
|
|
45
|
+
if (str) {
|
|
46
|
+
str += " ";
|
|
47
|
+
}
|
|
48
|
+
str += x;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return str;
|
|
53
|
+
}
|
|
54
|
+
exports.cx = cx;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ForwardedRef, ForwardRefExoticComponent, PropsWithoutRef, ReactElement, RefAttributes } from "react";
|
|
2
|
+
export declare type ForwardRefRenderFunction<T, P> = {
|
|
3
|
+
(props: P, ref: ForwardedRef<T>): ReactElement | null;
|
|
4
|
+
displayName?: string;
|
|
5
|
+
/** defaultProps are not supported on render functions */
|
|
6
|
+
defaultProps?: never;
|
|
7
|
+
/** propTypes are not supported on render functions */
|
|
8
|
+
propTypes?: never;
|
|
9
|
+
/** used by Chakra */
|
|
10
|
+
id?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const forwardRef: <T, P>(name: string, render: ForwardRefRenderFunction<T, P>) => ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.forwardRef = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const forwardRef = (name, render) => {
|
|
6
|
+
const Component = (0, react_1.forwardRef)(render);
|
|
7
|
+
Component.displayName = name;
|
|
8
|
+
return Component;
|
|
9
|
+
};
|
|
10
|
+
exports.forwardRef = forwardRef;
|
package/utils/image.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ResizerImageProps } from "@uxf/core/utils/resizer";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
export interface FileResponse {
|
|
4
|
+
extension: string;
|
|
5
|
+
namespace?: string | null;
|
|
6
|
+
uuid: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function getImgSrcSet(file?: FileResponse, width?: number, height?: number, options?: ResizerImageProps): string | null;
|
|
9
|
+
export declare function getImgSources(file?: FileResponse, width?: number, height?: number): ReactElement | null;
|
package/utils/image.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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.getImgSources = exports.getImgSrcSet = void 0;
|
|
7
|
+
const resizer_1 = require("@uxf/core/utils/resizer");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const TYPES = ["avif", "webp"];
|
|
10
|
+
function getImgSrcSet(file, width = 200, height = 300, options = {}) {
|
|
11
|
+
if (!file || !file.uuid || !file.extension || file.extension === "svg") {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const toFormat = TYPES.includes(file.extension) ? "png" : file.extension;
|
|
15
|
+
return [3, 2, 1]
|
|
16
|
+
.map((size) => (0, resizer_1.resizerImageUrl)(file, width * size, height * size, { toFormat, ...options }) +
|
|
17
|
+
(size > 1 ? ` ${size}x` : ""))
|
|
18
|
+
.join(", ");
|
|
19
|
+
}
|
|
20
|
+
exports.getImgSrcSet = getImgSrcSet;
|
|
21
|
+
function getImgSources(file, width = 200, height = 300) {
|
|
22
|
+
if (!file || !file.uuid || !file.extension || file.extension === "svg") {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, TYPES.map((type) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return (react_1.default.createElement("source", { key: type, srcSet: (_a = getImgSrcSet(file, width, height, { toFormat: type })) !== null && _a !== void 0 ? _a : undefined, type: `image/${type}` }));
|
|
28
|
+
})));
|
|
29
|
+
}
|
|
30
|
+
exports.getImgSources = getImgSources;
|
package/utils/rem.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const rem: (size?: number) => string | undefined;
|
package/utils/rem.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { ButtonColor, ButtonSize, ButtonVariant } from "@uxf/ui/button";
|
|
3
|
+
export declare const defaultConfig: StorybookConfig;
|
|
4
|
+
export interface StorybookConfig {
|
|
5
|
+
Button: {
|
|
6
|
+
sizes: ButtonSize[];
|
|
7
|
+
variants: ButtonVariant[];
|
|
8
|
+
colors: ButtonColor[];
|
|
9
|
+
};
|
|
10
|
+
Input: any;
|
|
11
|
+
Select: any;
|
|
12
|
+
}
|
|
13
|
+
export declare function useStorybookConfig<T extends keyof StorybookConfig>(key: T): StorybookConfig[T];
|
|
14
|
+
interface StorybookContextProviderProps {
|
|
15
|
+
config: StorybookConfig;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export declare function StorybookContextProvider(props: StorybookContextProviderProps): JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.StorybookContextProvider = exports.useStorybookConfig = exports.defaultConfig = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
exports.defaultConfig = {
|
|
29
|
+
Button: {
|
|
30
|
+
sizes: ["xs", "sm", "default", "lg", "xl"],
|
|
31
|
+
colors: ["default", "white", "success", "warning", "error"],
|
|
32
|
+
variants: ["outlined", "default"],
|
|
33
|
+
},
|
|
34
|
+
Input: {},
|
|
35
|
+
Select: {},
|
|
36
|
+
};
|
|
37
|
+
// Context
|
|
38
|
+
const Context = (0, react_1.createContext)(exports.defaultConfig);
|
|
39
|
+
// consumer
|
|
40
|
+
function useStorybookConfig(key) {
|
|
41
|
+
return (0, react_1.useContext)(Context)[key];
|
|
42
|
+
}
|
|
43
|
+
exports.useStorybookConfig = useStorybookConfig;
|
|
44
|
+
function StorybookContextProvider(props) {
|
|
45
|
+
return react_1.default.createElement(Context.Provider, { value: props.config }, props.children);
|
|
46
|
+
}
|
|
47
|
+
exports.StorybookContextProvider = StorybookContextProvider;
|
package/avatar/avatar.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { AvatarSizes } from "./theme";
|
|
3
|
-
interface FileResponse {
|
|
4
|
-
uuid: string;
|
|
5
|
-
namespace?: string;
|
|
6
|
-
extension: string;
|
|
7
|
-
}
|
|
8
|
-
export interface AvatarProps {
|
|
9
|
-
src: FileResponse | string | null | undefined;
|
|
10
|
-
size?: keyof AvatarSizes;
|
|
11
|
-
rounded?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function Avatar(props: AvatarProps): JSX.Element;
|
|
14
|
-
export {};
|
package/avatar/avatar.jsx
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Avatar = void 0;
|
|
4
|
-
const cx_1 = require("@uxf/core/utils/cx");
|
|
5
|
-
function Avatar(props) {
|
|
6
|
-
var _a;
|
|
7
|
-
const className = (0, cx_1.cx)("avatar", `avatar--size-${props.size}`, `avatar--variant-${(_a = props.circular) !== null && _a !== void 0 ? _a : "default"}`);
|
|
8
|
-
return <img src={props.src} className={className}/>;
|
|
9
|
-
}
|
|
10
|
-
exports.Avatar = Avatar;
|
|
@@ -1,29 +0,0 @@
|
|
|
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 storybook_config_1 = require("@uxf/ui/utils/storybook-config");
|
|
9
|
-
const avatar_1 = require("./avatar");
|
|
10
|
-
exports.default = {
|
|
11
|
-
title: "UI/Avatar",
|
|
12
|
-
component: avatar_1.Avatar,
|
|
13
|
-
};
|
|
14
|
-
function Default() {
|
|
15
|
-
const config = (0, storybook_config_1.useStorybookConfig)("Button");
|
|
16
|
-
return (<div className="space-y-4">
|
|
17
|
-
<div className="flex flex-row items-center space-x-4">
|
|
18
|
-
<avatar_1.Avatar src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" size="8"/>
|
|
19
|
-
<avatar_1.Avatar src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" size="10"/>
|
|
20
|
-
<avatar_1.Avatar src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" size="12"/>
|
|
21
|
-
</div>
|
|
22
|
-
<div className="flex flex-row items-center space-x-4">
|
|
23
|
-
<avatar_1.Avatar src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" size="8" variant="circular"/>
|
|
24
|
-
<avatar_1.Avatar src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" size="10" variant="circular"/>
|
|
25
|
-
<avatar_1.Avatar src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" size="12" variant="circular"/>
|
|
26
|
-
</div>
|
|
27
|
-
</div>);
|
|
28
|
-
}
|
|
29
|
-
exports.Default = Default;
|