mtxuilib 0.1.255 → 0.1.256

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.
@@ -0,0 +1,2 @@
1
+ import type { PropsWithChildren } from "react";
2
+ export declare const MtErrorBoundary: (props: {} & PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ErrorBoundary } from "react-error-boundary";
3
+ import { MtButton } from "../ui/mt/Button";
4
+ export const MtErrorBoundary = (props) => {
5
+ const { children } = props;
6
+ return (_jsxs("div", { className: "bg-red-300 p-2", children: [_jsx("div", { children: "error boundary" }), _jsx(ErrorBoundary, { fallbackRender: ({ error, resetErrorBoundary }) => {
7
+ console.log("💥💥💥", error);
8
+ return (_jsxs("div", { children: [_jsx("h1", { children: "error" }), _jsx(MtButton, { onClick: () => resetErrorBoundary(), children: "Try again" }), _jsx("pre", { style: { whiteSpace: "normal" }, children: error.message })] }));
9
+ }, onReset: () => { }, children: children })] }));
10
+ };
11
+ const CustomErrorRetry = (props) => {
12
+ const { message, onRetry } = props;
13
+ return (_jsxs("div", { className: "flex flex-col space-y-4 bg-red-200 p-2", children: [message && _jsx("h2", { children: message }), _jsx(MtButton, { onClick: () => {
14
+ onRetry();
15
+ }, children: "retry" })] }));
16
+ };
@@ -0,0 +1 @@
1
+ export declare const InlineCode: ({ children, ...props }: any) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const InlineCode = ({ children, ...props }) => {
3
+ return (_jsx("div", { className: "inline relative", children: _jsx("code", { ...props, className: `
4
+ dark:bg-gray-900 bg-gray-200
5
+ rounded
6
+ px-1.5
7
+ py-0.5
8
+ overflow-x-auto
9
+ `, children: children }) }));
10
+ };
@@ -0,0 +1,5 @@
1
+ export declare function MuiChipsInput({ onChange, value, placeholder, }: {
2
+ onChange: any;
3
+ value?: never[] | undefined;
4
+ placeholder?: string | undefined;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ export function MuiChipsInput({ onChange, value = [], placeholder = "Add chip...", }) {
5
+ const [inputValue, setInputValue] = useState("");
6
+ const handleInputChange = (e) => {
7
+ setInputValue(e.target.value);
8
+ };
9
+ const handleInputKeyDown = (e) => {
10
+ if (e.key === "Enter" && inputValue.trim()) {
11
+ onChange([...value, inputValue.trim()]);
12
+ setInputValue("");
13
+ }
14
+ };
15
+ const removeChip = (chipToRemove) => {
16
+ onChange(value.filter((chip) => chip !== chipToRemove));
17
+ };
18
+ return (_jsxs("div", { className: "flex flex-wrap items-center p-2 border border-gray-300 rounded-md focus-within:ring-2 focus-within:ring-blue-500 focus-within:border-transparent", children: ["TODO: \u76EE\u524D\u65F6ai \u8F85\u52A9\u751F\u6210\u7684\u4EE3\u7801\uFF0C\u529F\u80FD\u8FD8\u9700\u8981\u7EE7\u7EED\u5B8C\u5584", value.map((chip, index) => (_jsxs("div", { className: "flex items-center bg-gray-200 rounded-full px-3 py-1 m-1", children: [_jsx("span", { className: "text-sm", children: chip }), _jsx("button", { onClick: () => removeChip(chip), className: "ml-2 text-gray-500 hover:text-gray-700 focus:outline-none", children: "\u00D7" })] }, index))), _jsx("input", { type: "text", value: inputValue, onChange: handleInputChange, onKeyDown: handleInputKeyDown, placeholder: placeholder, className: "flex-grow outline-none px-2 py-1" })] }));
19
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mtxuilib",
3
3
  "private": false,
4
- "version": "0.1.255",
4
+ "version": "0.1.256",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,4 +0,0 @@
1
- export declare const CustomErrorRetry: (props: {
2
- message?: string;
3
- onRetry: () => void;
4
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,9 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { MtButton } from "../ui/mt/Button";
4
- export const CustomErrorRetry = (props) => {
5
- const { message, onRetry } = props;
6
- return (_jsxs("div", { className: "flex flex-col space-y-4 bg-red-200 p-2", children: [message && _jsx("h2", { children: message }), _jsx(MtButton, { onClick: () => {
7
- onRetry();
8
- }, children: "retry" })] }));
9
- };
@@ -1,3 +0,0 @@
1
- export declare const ExampleError2: () => import("react/jsx-runtime").JSX.Element;
2
- export declare const ExampleError1: () => never;
3
- export declare const WiehErrorExample: import("react").ForwardRefExoticComponent<object & import("react").RefAttributes<any>>;
@@ -1,14 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { ErrorBoundary, withErrorBoundary } from "react-error-boundary";
4
- export const ExampleError2 = () => {
5
- return (_jsx(_Fragment, { children: _jsx(ErrorBoundary, { fallback: _jsx("div", { children: "error123" }), children: _jsx(ExampleError1, {}) }) }));
6
- };
7
- export const ExampleError1 = () => {
8
- throw new Error("💥💥💥");
9
- };
10
- export const WiehErrorExample = withErrorBoundary(ExampleError1, {
11
- fallback: _jsx("div", { children: "Something went wrong" }),
12
- onError(error, info) {
13
- },
14
- });
@@ -1,16 +0,0 @@
1
- import { Component, ErrorInfo, ReactNode } from "react";
2
- interface Props {
3
- children: ReactNode;
4
- title?: string;
5
- }
6
- interface State {
7
- hasError: boolean;
8
- errorMessage: string | null;
9
- }
10
- export declare class MtErrorBoundary extends Component<Props, State> {
11
- state: State;
12
- static getDerivedStateFromError(error: Error): State;
13
- componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
14
- render(): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | null | undefined;
15
- }
16
- export default MtErrorBoundary;
@@ -1,23 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Component } from "react";
4
- export class MtErrorBoundary extends Component {
5
- state = {
6
- hasError: false,
7
- errorMessage: null
8
- };
9
- static getDerivedStateFromError(error) {
10
- return { hasError: true, errorMessage: error.message };
11
- }
12
- componentDidCatch(error, errorInfo) {
13
- console.error("Uncaught error:", error, errorInfo);
14
- }
15
- render() {
16
- if (this.state.hasError) {
17
- return (_jsxs("div", { className: "bg-yellow-300 p-2", children: [_jsx("button", { type: "button", onClick: () => this.setState({ hasError: false }), children: "Try again?" }), this.state.errorMessage &&
18
- _jsxs("details", { children: [_jsx("summary", { children: "Error Details" }), _jsx("div", { children: this.state.errorMessage })] })] }));
19
- }
20
- return this.props.children;
21
- }
22
- }
23
- export default MtErrorBoundary;
@@ -1,2 +0,0 @@
1
- import type { PropsWithChildren } from "react";
2
- export declare const MtErrorBoundaryV2: (props: {} & PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ErrorBoundary } from "react-error-boundary";
3
- import { MtButton } from "../ui/mt/Button";
4
- export const MtErrorBoundaryV2 = (props) => {
5
- const { children } = props;
6
- return (_jsx("div", { className: "bg-red-300 p-2", children: _jsx(ErrorBoundary, { fallbackRender: ({ error, resetErrorBoundary }) => (_jsxs("div", { children: ["There was an error!", " ", _jsx(MtButton, { onClick: () => resetErrorBoundary(), children: "Try again" }), _jsx("pre", { style: { whiteSpace: "normal" }, children: error.message })] })), onReset: () => { }, children: children }) }));
7
- };