@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.
Files changed (41) hide show
  1. package/components/Alert/Alert.d.ts +3 -15
  2. package/components/Alert/Alert.js +1 -1
  3. package/components/Animated/Animated.d.ts +19 -27
  4. package/components/Animated/Animated.js +54 -19
  5. package/components/Badge/Badge.d.ts +3 -16
  6. package/components/Badge/Badge.js +1 -1
  7. package/components/Banner/Banner.d.ts +3 -15
  8. package/components/Banner/Banner.js +1 -1
  9. package/components/Button/Button.d.ts +4 -8
  10. package/components/Button/Button.js +2 -2
  11. package/components/Carousel/Carousel.d.ts +56 -0
  12. package/components/Carousel/Carousel.js +87 -0
  13. package/components/Carousel/index.d.ts +2 -0
  14. package/components/Carousel/index.js +2 -0
  15. package/components/ClickOutside/ClickOutside.d.ts +4 -4
  16. package/components/ClickOutside/ClickOutside.js +14 -13
  17. package/components/Hamburger/Hamburger.d.ts +6 -5
  18. package/components/InlineCode/InlineCode.d.ts +13 -0
  19. package/components/InlineCode/InlineCode.js +50 -0
  20. package/components/InlineCode/index.d.ts +2 -0
  21. package/components/InlineCode/index.js +2 -0
  22. package/components/Input/IconInput.d.ts +2 -2
  23. package/components/Input/IconInput.js +1 -1
  24. package/components/Input/Input.d.ts +1 -1
  25. package/components/Input/Input.js +1 -1
  26. package/components/Input/TextArea.d.ts +1 -1
  27. package/components/Input/TextArea.js +1 -1
  28. package/components/Layer/Layer.d.ts +4 -11
  29. package/components/Layer/Layer.js +1 -1
  30. package/components/Link/Link.d.ts +2 -4
  31. package/components/Link/Link.js +2 -2
  32. package/components/Select/Select.d.ts +2 -13
  33. package/components/Select/Select.js +2 -3
  34. package/components/Spinner/Spinner.d.ts +2 -2
  35. package/functions/scrollToId.js +1 -1
  36. package/hooks/useFocusTrap.d.ts +1 -1
  37. package/index.d.ts +13 -9
  38. package/index.js +15 -9
  39. package/package.json +8 -28
  40. package/style.css +124 -77
  41. package/types/index.d.ts +9 -0
@@ -0,0 +1,2 @@
1
+ import InlineCode from "./InlineCode";
2
+ export default InlineCode;
@@ -0,0 +1,2 @@
1
+ import InlineCode from "./InlineCode";
2
+ export default InlineCode;
@@ -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?: React.CSSProperties;
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;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { CornerType } from "../../types";
2
+ import type { CornerType } from "../../types";
3
3
  type Props = React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> & {
4
4
  /**
5
5
  * Type of corners on the input
@@ -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 Props = {
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 = (props: Partial<BuiltinLinkProps> & {
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
@@ -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 = Omit<React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>, "aria-label"> & {
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, _b = _a.getOptionValue, getOptionValue = _b === void 0 ? identity : _b, _c = _a.getOptionLabel, getOptionLabel = _c === void 0 ? identity : _c, _d = _a.corners, corners = _d === void 0 ? "rounded" : _d, style = _a.style, disabled = _a.disabled, props = __rest(_a, ["className", "options", "getOptionValue", "getOptionLabel", "corners", "style", "disabled"]);
29
- return (_jsxs("div", { className: classNames("ajui-select-container", "corners--".concat(corners), disabled ? "ajui-select-disabled" : undefined, className) || undefined, style: style, children: [_jsx("select", __assign({}, props, { ref: ref, className: "ajui-select-base corners--".concat(corners), disabled: disabled, children: options.map(function (option, index) { return (_jsx("option", { value: getOptionValue(option), children: getOptionLabel(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" }) })] }));
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 React from "react";
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?: React.CSSProperties;
10
+ style?: Style;
11
11
  };
12
12
  declare const Spinner: ({ className, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
13
13
  export default Spinner;
@@ -12,6 +12,6 @@ export default function scrollToId(id, behavior) {
12
12
  }
13
13
  }
14
14
  catch (_a) {
15
- // do nothing
15
+ return;
16
16
  }
17
17
  }
@@ -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").MutableRefObject<T | null>;
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 * from "./components/Hamburger";
12
- export { default as Hamburger } from "./components/Hamburger";
13
- export { default as Select } from "./components/Select";
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 * from "./components/Hamburger";
13
- export { default as Hamburger } from "./components/Hamburger";
14
- export { default as Select } from "./components/Select";
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.4",
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
- "dev": "nodemon --watch src --ext ts,tsx,css --exec \"npm run build\"",
17
- "test": "jest --config jest.config.js",
18
- "lint": "eslint --ext .ts,.tsx src",
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
- "@testing-library/jest-dom": "^6.4.6",
27
- "@testing-library/react": "^14.1.0",
28
- "@types/jest": "^29.5.8",
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
  }