@adamjanicki/ui 1.5.4 → 1.5.6
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/components/Alert/Alert.d.ts +3 -15
- package/components/Alert/Alert.js +1 -1
- package/components/Animated/Animated.d.ts +19 -27
- package/components/Animated/Animated.js +54 -19
- package/components/Badge/Badge.d.ts +3 -16
- package/components/Badge/Badge.js +1 -1
- package/components/Banner/Banner.d.ts +3 -15
- package/components/Banner/Banner.js +1 -1
- package/components/Button/Button.d.ts +4 -8
- package/components/Button/Button.js +2 -2
- package/components/Carousel/Carousel.d.ts +56 -0
- package/components/Carousel/Carousel.js +87 -0
- package/components/Carousel/index.d.ts +2 -0
- package/components/Carousel/index.js +2 -0
- package/components/ClickOutside/ClickOutside.d.ts +4 -4
- package/components/ClickOutside/ClickOutside.js +14 -13
- package/components/Hamburger/Hamburger.d.ts +6 -5
- package/components/InlineCode/InlineCode.d.ts +13 -0
- package/components/InlineCode/InlineCode.js +50 -0
- package/components/InlineCode/index.d.ts +2 -0
- package/components/InlineCode/index.js +2 -0
- package/components/Input/IconInput.d.ts +2 -2
- package/components/Input/IconInput.js +1 -1
- package/components/Input/Input.d.ts +1 -1
- package/components/Input/Input.js +1 -1
- package/components/Input/TextArea.d.ts +1 -1
- package/components/Input/TextArea.js +1 -1
- package/components/Layer/Layer.d.ts +4 -11
- package/components/Layer/Layer.js +1 -1
- package/components/Link/Link.d.ts +2 -4
- package/components/Link/Link.js +2 -2
- package/components/Select/Select.d.ts +2 -13
- package/components/Select/Select.js +2 -3
- package/components/Spinner/Spinner.d.ts +2 -2
- package/functions/scrollToId.js +1 -1
- package/hooks/useFocusTrap.d.ts +1 -1
- package/index.d.ts +13 -9
- package/index.js +15 -9
- package/package.json +8 -28
- package/style.css +124 -77
- package/types/index.d.ts +9 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { InputProps } from "./Input";
|
|
3
|
-
import { CornerType } from "../../types";
|
|
3
|
+
import type { CornerType, Style } from "../../types";
|
|
4
4
|
type IconInputProps = {
|
|
5
5
|
/**
|
|
6
6
|
* [Optional] Icon to display at the start of the input
|
|
@@ -17,7 +17,7 @@ type IconInputProps = {
|
|
|
17
17
|
/**
|
|
18
18
|
* [Optional] Inline styles to add to the container
|
|
19
19
|
*/
|
|
20
|
-
style?:
|
|
20
|
+
style?: Style;
|
|
21
21
|
/**
|
|
22
22
|
* [Optional] Corner style for the input
|
|
23
23
|
*/
|
|
@@ -14,6 +14,6 @@ import { forwardRef } from "react";
|
|
|
14
14
|
import classNames from "../../functions/classNames";
|
|
15
15
|
var IconInput = forwardRef(function (_a, ref) {
|
|
16
16
|
var startIcon = _a.startIcon, endIcon = _a.endIcon, className = _a.className, style = _a.style, _b = _a.corners, corners = _b === void 0 ? "rounded" : _b, inputProps = _a.inputProps;
|
|
17
|
-
return (_jsxs("div", { className: classNames("ajui-input-default ajui-icon-input corners--".concat(corners), className), style: style, ref: ref, children: [startIcon || null, _jsx("input", __assign({}, inputProps, { className: classNames("ajui-input-base corners--".concat(corners), inputProps === null || inputProps === void 0 ? void 0 : inputProps.className) })), endIcon || null] }));
|
|
17
|
+
return (_jsxs("div", { className: classNames("ajui-input-default ajui-icon-input ajui-corners--".concat(corners), className), style: style, ref: ref, children: [startIcon || null, _jsx("input", __assign({}, inputProps, { className: classNames("ajui-input-base ajui-corners--".concat(corners), inputProps === null || inputProps === void 0 ? void 0 : inputProps.className) })), endIcon || null] }));
|
|
18
18
|
});
|
|
19
19
|
export default IconInput;
|
|
@@ -25,6 +25,6 @@ import { forwardRef } from "react";
|
|
|
25
25
|
import classNames from "../../functions/classNames";
|
|
26
26
|
var Input = forwardRef(function (_a, ref) {
|
|
27
27
|
var className = _a.className, _b = _a.corners, corners = _b === void 0 ? "rounded" : _b, props = __rest(_a, ["className", "corners"]);
|
|
28
|
-
return (_jsx("input", __assign({}, props, { ref: ref, className: classNames("ajui-input-base ajui-input-default corners--".concat(corners), className) })));
|
|
28
|
+
return (_jsx("input", __assign({}, props, { ref: ref, className: classNames("ajui-input-base ajui-input-default ajui-corners--".concat(corners), className) })));
|
|
29
29
|
});
|
|
30
30
|
export default Input;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { CornerType } from "../../types";
|
|
2
|
+
import type { CornerType } from "../../types";
|
|
3
3
|
type TextAreaProps = React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> & {
|
|
4
4
|
/**
|
|
5
5
|
* Type of corners on the text area
|
|
@@ -25,6 +25,6 @@ import { forwardRef } from "react";
|
|
|
25
25
|
import classNames from "../../functions/classNames";
|
|
26
26
|
var TextArea = forwardRef(function (_a, ref) {
|
|
27
27
|
var className = _a.className, _b = _a.rows, rows = _b === void 0 ? 3 : _b, _c = _a.corners, corners = _c === void 0 ? "rounded" : _c, props = __rest(_a, ["className", "rows", "corners"]);
|
|
28
|
-
return (_jsx("textarea", __assign({}, props, { ref: ref, className: classNames("ajui-input-base ajui-input-default corners--".concat(corners), className), rows: rows })));
|
|
28
|
+
return (_jsx("textarea", __assign({}, props, { ref: ref, className: classNames("ajui-input-base ajui-input-default ajui-corners--".concat(corners), className), rows: rows })));
|
|
29
29
|
});
|
|
30
30
|
export default TextArea;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
type
|
|
2
|
+
import type { DivProps } from "../../types";
|
|
3
|
+
type Props<T extends React.ElementType> = Omit<DivProps, "children"> & {
|
|
3
4
|
/**
|
|
4
5
|
* Callback that fires when the user clicks outside the layer
|
|
5
6
|
*/
|
|
@@ -8,15 +9,7 @@ type Props = {
|
|
|
8
9
|
* The child of the layer.
|
|
9
10
|
* IMPORTANT: the child must be able to accept a ref
|
|
10
11
|
*/
|
|
11
|
-
children: React.ReactElement
|
|
12
|
-
/**
|
|
13
|
-
* [Optional] Additional class name
|
|
14
|
-
*/
|
|
15
|
-
className?: string;
|
|
16
|
-
/**
|
|
17
|
-
* [Optional] Additional styles
|
|
18
|
-
*/
|
|
19
|
-
style?: React.CSSProperties;
|
|
12
|
+
children: React.ReactElement<React.ComponentPropsWithRef<T>>;
|
|
20
13
|
/**
|
|
21
14
|
* [Optional] Whether to disable the escape key to close the layer
|
|
22
15
|
* @default false
|
|
@@ -33,5 +26,5 @@ type Props = {
|
|
|
33
26
|
*/
|
|
34
27
|
disableScrollLock?: boolean;
|
|
35
28
|
};
|
|
36
|
-
declare const Layer: ({ returnFocusOnEscape, disableScrollLock, ...props }: Props) => JSX.Element;
|
|
29
|
+
declare const Layer: <T extends React.ElementType>({ returnFocusOnEscape, disableScrollLock, ...props }: Props<T>) => React.JSX.Element;
|
|
37
30
|
export default Layer;
|
|
@@ -45,7 +45,7 @@ var BaseLayer = function (_a) {
|
|
|
45
45
|
onMouseDown: function (e) {
|
|
46
46
|
var _a, _b;
|
|
47
47
|
e.stopPropagation();
|
|
48
|
-
(_b = (_a = children.props).onMouseDown) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
48
|
+
(_b = (_a = children.props) === null || _a === void 0 ? void 0 : _a.onMouseDown) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
49
49
|
},
|
|
50
50
|
}) }));
|
|
51
51
|
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
type BuiltinLinkProps = Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "href">;
|
|
3
|
-
export type CustomLinkElement =
|
|
3
|
+
export type CustomLinkElement = React.ForwardRefExoticComponent<BuiltinLinkProps & {
|
|
4
4
|
to: string;
|
|
5
|
-
} &
|
|
6
|
-
ref?: React.MutableRefObject<HTMLAnchorElement>;
|
|
7
|
-
}) => React.ReactNode;
|
|
5
|
+
} & React.RefAttributes<HTMLAnchorElement>>;
|
|
8
6
|
type DefaultLinkProps = BuiltinLinkProps & {
|
|
9
7
|
/**
|
|
10
8
|
* URL to navigate to
|
package/components/Link/Link.js
CHANGED
|
@@ -28,8 +28,8 @@ var DefaultLinkElement = forwardRef(function (_a, ref) {
|
|
|
28
28
|
return _jsx("a", __assign({}, props, { href: to, ref: ref }));
|
|
29
29
|
});
|
|
30
30
|
export var UnstyledLink = forwardRef(function (_a, ref) {
|
|
31
|
-
var _b = _a.LinkElement, LinkElement = _b === void 0 ? DefaultLinkElement : _b, props = __rest(_a, ["LinkElement"]);
|
|
32
|
-
return (_jsx(LinkElement, __assign({}, props, { ref: ref })));
|
|
31
|
+
var _b = _a.LinkElement, LinkElement = _b === void 0 ? DefaultLinkElement : _b, className = _a.className, props = __rest(_a, ["LinkElement", "className"]);
|
|
32
|
+
return (_jsx(LinkElement, __assign({}, props, { className: classNames("ajui-action", className), ref: ref })));
|
|
33
33
|
});
|
|
34
34
|
var Link = forwardRef(function (_a, ref) {
|
|
35
35
|
var className = _a.className, props = __rest(_a, ["className"]);
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { CornerType } from "../../types";
|
|
3
|
-
type Props =
|
|
2
|
+
import type { CornerType } from "../../types";
|
|
3
|
+
type Props = React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement> & {
|
|
4
4
|
/**
|
|
5
5
|
* Array of options to display in the select
|
|
6
6
|
*/
|
|
7
7
|
options: string[];
|
|
8
|
-
/**
|
|
9
|
-
* Mapper function to get the value of the option
|
|
10
|
-
*
|
|
11
|
-
* @param option the option to get the value of
|
|
12
|
-
* @returns the value of the option
|
|
13
|
-
*/
|
|
14
|
-
getOptionValue?: (option: string) => string;
|
|
15
8
|
/**
|
|
16
9
|
* Mapper function to get the label of the option
|
|
17
10
|
*
|
|
@@ -24,10 +17,6 @@ type Props = Omit<React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectE
|
|
|
24
17
|
* @default "rounded"
|
|
25
18
|
*/
|
|
26
19
|
corners?: CornerType;
|
|
27
|
-
/**
|
|
28
|
-
* Name of the select for accessibility purposes
|
|
29
|
-
*/
|
|
30
|
-
"aria-label": string;
|
|
31
20
|
};
|
|
32
21
|
declare const _default: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLSelectElement>>;
|
|
33
22
|
export default _default;
|
|
@@ -23,9 +23,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
import { forwardRef } from "react";
|
|
25
25
|
import classNames from "../../functions/classNames";
|
|
26
|
-
var identity = function (x) { return x; };
|
|
27
26
|
var Select = function (_a, ref) {
|
|
28
|
-
var className = _a.className, options = _a.options,
|
|
29
|
-
return (_jsxs("div", { className: classNames("ajui-select-container", "corners--".concat(corners), disabled ? "ajui-select-disabled" : undefined, className)
|
|
27
|
+
var className = _a.className, options = _a.options, getOptionLabel = _a.getOptionLabel, _b = _a.corners, corners = _b === void 0 ? "rounded" : _b, style = _a.style, disabled = _a.disabled, props = __rest(_a, ["className", "options", "getOptionLabel", "corners", "style", "disabled"]);
|
|
28
|
+
return (_jsxs("div", { className: classNames("ajui-select-container", "ajui-corners--".concat(corners), disabled ? "ajui-select-disabled" : undefined, className), style: style, children: [_jsx("select", __assign({}, props, { ref: ref, className: "ajui-select-base ajui-corners--".concat(corners), disabled: disabled, children: options.map(function (option, index) { return (_jsx("option", { value: option, children: (getOptionLabel === null || getOptionLabel === void 0 ? void 0 : getOptionLabel(option)) || option }, index)); }) })), _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 64 64", className: "ajui-select-triangle", "aria-hidden": "true", children: _jsx("path", { fill: "currentColor", d: "M 29.175781 50.824219 C 30.738281 52.386719 33.273438 52.386719 34.835938 50.824219 L 58.835938 26.824219 C 60.398438 25.261719 60.398438 22.726562 58.835938 21.164062 C 57.273438 19.601562 54.738281 19.601562 53.175781 21.164062 L 32 42.335938 L 10.824219 21.175781 C 9.261719 19.613281 6.726562 19.613281 5.164062 21.175781 C 3.601562 22.738281 3.601562 25.273438 5.164062 26.835938 L 29.164062 50.835938 Z M 29.175781 50.824219" }) })] }));
|
|
30
29
|
};
|
|
31
30
|
export default forwardRef(Select);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Style } from "../../types";
|
|
2
2
|
type Props = {
|
|
3
3
|
/**
|
|
4
4
|
* [Optional] Additional class names to apply to the spinner.
|
|
@@ -7,7 +7,7 @@ type Props = {
|
|
|
7
7
|
/**
|
|
8
8
|
* [Optional] Additional styles to apply to the spinner.
|
|
9
9
|
*/
|
|
10
|
-
style?:
|
|
10
|
+
style?: Style;
|
|
11
11
|
};
|
|
12
12
|
declare const Spinner: ({ className, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export default Spinner;
|
package/functions/scrollToId.js
CHANGED
package/hooks/useFocusTrap.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* `true` by default
|
|
6
6
|
* @returns ref object that must be passed to the element that should be trapped
|
|
7
7
|
*/
|
|
8
|
-
declare const useFocusTrap: <T extends HTMLElement>(isActive?: boolean) => import("react").
|
|
8
|
+
declare const useFocusTrap: <T extends HTMLElement>(isActive?: boolean) => import("react").RefObject<T | null>;
|
|
9
9
|
export default useFocusTrap;
|
package/index.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
export * from "./components/Button";
|
|
2
|
-
export { default as Button } from "./components/Button";
|
|
3
|
-
export * from "./components/Link";
|
|
4
|
-
export { default as Link } from "./components/Link";
|
|
5
|
-
export * from "./components/Input";
|
|
6
|
-
export { default as Input } from "./components/Input";
|
|
7
1
|
export { default as Alert } from "./components/Alert";
|
|
8
2
|
export { default as Animated } from "./components/Animated";
|
|
9
3
|
export { default as Badge } from "./components/Badge";
|
|
10
4
|
export { default as Banner } from "./components/Banner";
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export { default as
|
|
5
|
+
export { default as Button } from "./components/Button";
|
|
6
|
+
export * from "./components/Button";
|
|
7
|
+
export { default as Carousel } from "./components/Carousel";
|
|
14
8
|
export { default as ClickOutside } from "./components/ClickOutside";
|
|
9
|
+
export { default as Hamburger } from "./components/Hamburger";
|
|
10
|
+
export * from "./components/Hamburger";
|
|
11
|
+
export { default as InlineCode } from "./components/InlineCode";
|
|
12
|
+
export { default as Input } from "./components/Input";
|
|
13
|
+
export * from "./components/Input";
|
|
15
14
|
export { default as Layer } from "./components/Layer";
|
|
15
|
+
export { default as Link } from "./components/Link";
|
|
16
|
+
export * from "./components/Link";
|
|
17
|
+
export { default as Select } from "./components/Select";
|
|
16
18
|
export { default as Spinner } from "./components/Spinner";
|
|
17
19
|
export * from "./hooks";
|
|
20
|
+
export * from "./functions";
|
|
21
|
+
export * from "./types";
|
package/index.js
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
// Components
|
|
2
|
-
export * from "./components/Button";
|
|
3
|
-
export { default as Button } from "./components/Button";
|
|
4
|
-
export * from "./components/Link";
|
|
5
|
-
export { default as Link } from "./components/Link";
|
|
6
|
-
export * from "./components/Input";
|
|
7
|
-
export { default as Input } from "./components/Input";
|
|
8
2
|
export { default as Alert } from "./components/Alert";
|
|
9
3
|
export { default as Animated } from "./components/Animated";
|
|
10
4
|
export { default as Badge } from "./components/Badge";
|
|
11
5
|
export { default as Banner } from "./components/Banner";
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export { default as
|
|
6
|
+
export { default as Button } from "./components/Button";
|
|
7
|
+
export * from "./components/Button";
|
|
8
|
+
export { default as Carousel } from "./components/Carousel";
|
|
15
9
|
export { default as ClickOutside } from "./components/ClickOutside";
|
|
10
|
+
export { default as Hamburger } from "./components/Hamburger";
|
|
11
|
+
export * from "./components/Hamburger";
|
|
12
|
+
export { default as InlineCode } from "./components/InlineCode";
|
|
13
|
+
export { default as Input } from "./components/Input";
|
|
14
|
+
export * from "./components/Input";
|
|
16
15
|
export { default as Layer } from "./components/Layer";
|
|
16
|
+
export { default as Link } from "./components/Link";
|
|
17
|
+
export * from "./components/Link";
|
|
18
|
+
export { default as Select } from "./components/Select";
|
|
17
19
|
export { default as Spinner } from "./components/Spinner";
|
|
18
20
|
// Hooks
|
|
19
21
|
export * from "./hooks";
|
|
22
|
+
// Functions
|
|
23
|
+
export * from "./functions";
|
|
24
|
+
// Types
|
|
25
|
+
export * from "./types";
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamjanicki/ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.6",
|
|
4
4
|
"description": "Basic UI components and hooks for React in TypeScript",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "./index.js",
|
|
6
7
|
"types": "./index.d.ts",
|
|
7
8
|
"author": "Adam Janicki",
|
|
@@ -11,39 +12,18 @@
|
|
|
11
12
|
"url": "git+https://github.com/adamjanicki2/ui.git"
|
|
12
13
|
},
|
|
13
14
|
"scripts": {
|
|
14
|
-
"build": "tsc; cp src/style.css ./style.css",
|
|
15
15
|
"clean": "./clean.sh",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"prepare": "npm run lint; npm test; npm run build"
|
|
16
|
+
"lint": "eslint src --max-warnings=0",
|
|
17
|
+
"build": "npm run clean && npm run lint && tsc; cp src/style.css ./style.css",
|
|
18
|
+
"prepare": "npm run build"
|
|
20
19
|
},
|
|
21
20
|
"peerDependencies": {
|
|
22
21
|
"react": ">=18",
|
|
23
22
|
"react-dom": ">=18"
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"
|
|
29
|
-
"@typescript-eslint/eslint-plugin": "^6.11.0",
|
|
30
|
-
"@typescript-eslint/parser": "^6.11.0",
|
|
31
|
-
"eslint": "^8.53.0",
|
|
32
|
-
"eslint-config-prettier": "^9.0.0",
|
|
33
|
-
"eslint-plugin-react": "^7.33.2",
|
|
34
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
35
|
-
"jest": "^29.7.0",
|
|
36
|
-
"jest-canvas-mock": "^2.5.2",
|
|
37
|
-
"jest-css-modules": "^2.1.0",
|
|
38
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
39
|
-
"nodemon": "^3.1.4",
|
|
40
|
-
"ts-jest": "^29.2.2",
|
|
41
|
-
"typescript": "^5.2.2"
|
|
42
|
-
},
|
|
43
|
-
"eslintConfig": {
|
|
44
|
-
"extends": [
|
|
45
|
-
"react-app",
|
|
46
|
-
"react-app/jest"
|
|
47
|
-
]
|
|
25
|
+
"@types/react": "^19.1.9",
|
|
26
|
+
"@types/react-dom": "^19.1.7",
|
|
27
|
+
"typescript": "^5.9.2"
|
|
48
28
|
}
|
|
49
29
|
}
|