@a-type/ui 0.3.1 → 0.3.3
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/dist/cjs/components/button/Button.js +6 -1
- package/dist/cjs/components/button/Button.js.map +1 -1
- package/dist/cjs/components/camera/Camera.d.ts +1 -0
- package/dist/cjs/components/camera/Camera.js +24 -18
- package/dist/cjs/components/camera/Camera.js.map +1 -1
- package/dist/cjs/components/icon/generated/IconSpritesheet.js +1 -1
- package/dist/cjs/components/icon/generated/IconSpritesheet.js.map +1 -1
- package/dist/cjs/components/icon/generated/iconNames.d.ts +1 -1
- package/dist/cjs/components/icon/generated/iconNames.js +10 -0
- package/dist/cjs/components/icon/generated/iconNames.js.map +1 -1
- package/dist/cjs/components/imageUploader/ImageUploader.js +28 -2
- package/dist/cjs/components/imageUploader/ImageUploader.js.map +1 -1
- package/dist/cjs/components/imageUploader/ImageUploader.stories.d.ts +22 -0
- package/dist/cjs/components/imageUploader/ImageUploader.stories.js +28 -0
- package/dist/cjs/components/imageUploader/ImageUploader.stories.js.map +1 -0
- package/dist/esm/components/button/Button.js +6 -1
- package/dist/esm/components/button/Button.js.map +1 -1
- package/dist/esm/components/camera/Camera.d.ts +1 -0
- package/dist/esm/components/camera/Camera.js +24 -18
- package/dist/esm/components/camera/Camera.js.map +1 -1
- package/dist/esm/components/icon/generated/IconSpritesheet.js +1 -1
- package/dist/esm/components/icon/generated/IconSpritesheet.js.map +1 -1
- package/dist/esm/components/icon/generated/iconNames.d.ts +1 -1
- package/dist/esm/components/icon/generated/iconNames.js +10 -0
- package/dist/esm/components/icon/generated/iconNames.js.map +1 -1
- package/dist/esm/components/imageUploader/ImageUploader.js +29 -3
- package/dist/esm/components/imageUploader/ImageUploader.js.map +1 -1
- package/dist/esm/components/imageUploader/ImageUploader.stories.d.ts +22 -0
- package/dist/esm/components/imageUploader/ImageUploader.stories.js +25 -0
- package/dist/esm/components/imageUploader/ImageUploader.stories.js.map +1 -0
- package/package.json +3 -2
- package/src/components/actions/ActionBar.tsx +38 -0
- package/src/components/actions/ActionButton.tsx +59 -0
- package/src/components/actions/index.ts +2 -0
- package/src/components/actions.ts +1 -0
- package/src/components/avatar/Avatar.tsx +62 -0
- package/src/components/avatar/AvatarList.tsx +71 -0
- package/src/components/avatar/index.ts +2 -0
- package/src/components/avatar.ts +1 -0
- package/src/components/button/Button.stories.tsx +20 -0
- package/src/components/button/Button.tsx +66 -0
- package/src/components/button/ConfirmedButton.tsx +66 -0
- package/src/components/button/classes.tsx +56 -0
- package/src/components/button/index.ts +3 -0
- package/src/components/button.ts +1 -0
- package/src/components/camera/Camera.stories.tsx +40 -0
- package/src/components/camera/Camera.tsx +215 -0
- package/src/components/camera/index.ts +1 -0
- package/src/components/camera.ts +1 -0
- package/src/components/card/Card.stories.tsx +41 -0
- package/src/components/card/Card.tsx +68 -0
- package/src/components/card/index.ts +1 -0
- package/src/components/card.ts +1 -0
- package/src/components/checkbox/Checkbox.tsx +46 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/checkbox.ts +1 -0
- package/src/components/chip/Chip.tsx +29 -0
- package/src/components/chip/index.ts +1 -0
- package/src/components/chip.ts +1 -0
- package/src/components/collapsible/Collapsible.tsx +48 -0
- package/src/components/collapsible/index.ts +1 -0
- package/src/components/collapsible.ts +1 -0
- package/src/components/colorPicker/ColorPicker.tsx +82 -0
- package/src/components/colorPicker/index.ts +1 -0
- package/src/components/colorPicker.ts +1 -0
- package/src/components/contextMenu/contextMenu.tsx +43 -0
- package/src/components/contextMenu.ts +1 -0
- package/src/components/dialog/Dialog.stories.tsx +38 -0
- package/src/components/dialog/Dialog.tsx +267 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/dialog.ts +1 -0
- package/src/components/divider/Divider.tsx +26 -0
- package/src/components/divider/index.ts +1 -0
- package/src/components/divider.ts +1 -0
- package/src/components/dropdownMenu/DropdownMenu.stories.tsx +47 -0
- package/src/components/dropdownMenu/DropdownMenu.tsx +89 -0
- package/src/components/dropdownMenu/index.ts +1 -0
- package/src/components/dropdownMenu.ts +1 -0
- package/src/components/errorBoundary/ErrorBoundary.tsx +23 -0
- package/src/components/errorBoundary/index.ts +1 -0
- package/src/components/errorBoundary.ts +1 -0
- package/src/components/forms/Form.tsx +9 -0
- package/src/components/forms/FormikForm.tsx +41 -0
- package/src/components/forms/SubmitButton.tsx +15 -0
- package/src/components/forms/TextField.tsx +112 -0
- package/src/components/forms/index.tsx +4 -0
- package/src/components/forms.ts +1 -0
- package/src/components/icon/Icon.tsx +28 -0
- package/src/components/icon/generated/IconSpritesheet.tsx +442 -0
- package/src/components/icon/generated/iconNames.ts +44 -0
- package/src/components/icon/index.ts +3 -0
- package/src/components/icon.ts +1 -0
- package/src/components/imageUploader/ImageUploader.stories.tsx +39 -0
- package/src/components/imageUploader/ImageUploader.tsx +203 -0
- package/src/components/imageUploader/UploadIcon.tsx +23 -0
- package/src/components/imageUploader/index.ts +1 -0
- package/src/components/imageUploader.ts +1 -0
- package/src/components/infiniteLoadTrigger/InfiniteLoadTrigger.tsx +38 -0
- package/src/components/infiniteLoadTrigger.ts +1 -0
- package/src/components/input/Input.stories.tsx +17 -0
- package/src/components/input/Input.tsx +32 -0
- package/src/components/input/index.ts +1 -0
- package/src/components/input.ts +1 -0
- package/src/components/layouts/PageContent.tsx +51 -0
- package/src/components/layouts/PageFixedArea.tsx +17 -0
- package/src/components/layouts/PageNav.tsx +23 -0
- package/src/components/layouts/PageNowPlaying.tsx +24 -0
- package/src/components/layouts/PageRoot.tsx +29 -0
- package/src/components/layouts/PageSection.tsx +23 -0
- package/src/components/layouts/index.tsx +6 -0
- package/src/components/layouts.ts +1 -0
- package/src/components/liveUpdateTextField/LiveUpdateTextField.tsx +132 -0
- package/src/components/liveUpdateTextField/index.ts +1 -0
- package/src/components/liveUpdateTextField.ts +1 -0
- package/src/components/navBar/NavBar.tsx +59 -0
- package/src/components/navBar/index.ts +1 -0
- package/src/components/navBar.ts +1 -0
- package/src/components/note/Note.tsx +21 -0
- package/src/components/note/index.ts +1 -0
- package/src/components/note.ts +1 -0
- package/src/components/numberStepper/NumberStepper.stories.tsx +21 -0
- package/src/components/numberStepper/NumberStepper.tsx +74 -0
- package/src/components/numberStepper/index.ts +1 -0
- package/src/components/numberStepper.ts +1 -0
- package/src/components/particles/ParticleContext.tsx +11 -0
- package/src/components/particles/ParticleLayer.stories.tsx +46 -0
- package/src/components/particles/ParticleLayer.tsx +28 -0
- package/src/components/particles/index.ts +7 -0
- package/src/components/particles/particlesState.ts +502 -0
- package/src/components/particles.ts +1 -0
- package/src/components/peek/Peek.tsx +74 -0
- package/src/components/peek/index.ts +1 -0
- package/src/components/peek.ts +1 -0
- package/src/components/popover/Popover.tsx +84 -0
- package/src/components/popover/index.ts +1 -0
- package/src/components/popover.ts +1 -0
- package/src/components/relativeTime/RelativeTime.tsx +43 -0
- package/src/components/relativeTime/index.ts +1 -0
- package/src/components/relativeTime.ts +1 -0
- package/src/components/richEditor/EditorContent.tsx +4 -0
- package/src/components/richEditor/RichEditor.tsx +38 -0
- package/src/components/richEditor/index.ts +1 -0
- package/src/components/richEditor.ts +1 -0
- package/src/components/select/Select.tsx +247 -0
- package/src/components/select/index.ts +1 -0
- package/src/components/select.ts +1 -0
- package/src/components/skeletons/skeletons.tsx +27 -0
- package/src/components/skeletons.ts +1 -0
- package/src/components/spinner/Spinner.tsx +59 -0
- package/src/components/spinner/index.ts +1 -0
- package/src/components/spinner.ts +1 -0
- package/src/components/switch/Switch.tsx +23 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/switch.ts +1 -0
- package/src/components/tabs/tabs.tsx +18 -0
- package/src/components/tabs.ts +1 -0
- package/src/components/textArea/TextArea.stories.tsx +21 -0
- package/src/components/textArea/TextArea.tsx +58 -0
- package/src/components/textArea/index.ts +1 -0
- package/src/components/textArea.ts +1 -0
- package/src/components/toggleGroup/toggleGroup.tsx +11 -0
- package/src/components/toggleGroup.ts +1 -0
- package/src/components/tooltip/Tooltip.tsx +56 -0
- package/src/components/tooltip/index.ts +1 -0
- package/src/components/tooltip.ts +1 -0
- package/src/components/typography/index.ts +1 -0
- package/src/components/typography/typography.tsx +18 -0
- package/src/components/typography.ts +1 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useMergedRef.ts +14 -0
- package/src/hooks/useOnUnmount.ts +20 -0
- package/src/hooks/useSize.ts +164 -0
- package/src/hooks/useStableCallback.ts +11 -0
- package/src/hooks/useToggle.tsx +9 -0
- package/src/hooks/useVisualViewportOffset.ts +35 -0
- package/src/hooks/withClassName.tsx +21 -0
- package/src/hooks.ts +1 -0
- package/src/uno.preset.ts +767 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { Component, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
export class ErrorBoundary extends Component<
|
|
5
|
+
{ children: ReactNode; fallback?: ReactNode },
|
|
6
|
+
{ error: Error | null }
|
|
7
|
+
> {
|
|
8
|
+
state = {
|
|
9
|
+
error: null,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
static getDerivedStateFromError(error: Error) {
|
|
13
|
+
// Update state so the next render will show the fallback UI.
|
|
14
|
+
return { error };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
render() {
|
|
18
|
+
if (this.state.error) {
|
|
19
|
+
return this.props.fallback || null;
|
|
20
|
+
}
|
|
21
|
+
return this.props.children;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ErrorBoundary.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './errorBoundary/index.js';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Formik, FormikConfig, FormikHelpers, FormikValues } from 'formik';
|
|
2
|
+
import { Form } from './Form.js';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
|
|
5
|
+
export interface FormikFormProps<T extends FormikValues = FormikValues>
|
|
6
|
+
extends FormikConfig<T> {
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function FormikForm<Values extends FormikValues>({
|
|
11
|
+
className,
|
|
12
|
+
children,
|
|
13
|
+
onSubmit,
|
|
14
|
+
...props
|
|
15
|
+
}: FormikFormProps<Values>) {
|
|
16
|
+
const wrappedOnSubmit = useCallback(
|
|
17
|
+
async (values: Values, bag: FormikHelpers<Values>) => {
|
|
18
|
+
try {
|
|
19
|
+
bag.setSubmitting(true);
|
|
20
|
+
return await onSubmit(values, bag);
|
|
21
|
+
} finally {
|
|
22
|
+
bag.setSubmitting(false);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
[onSubmit],
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
if (typeof children === 'function') {
|
|
29
|
+
return (
|
|
30
|
+
<Formik<Values> onSubmit={wrappedOnSubmit} {...props}>
|
|
31
|
+
{(formik) => <Form className={className}>{children(formik)}</Form>}
|
|
32
|
+
</Formik>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Formik<Values> onSubmit={wrappedOnSubmit} {...props}>
|
|
38
|
+
<Form className={className}>{children}</Form>
|
|
39
|
+
</Formik>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useFormikContext } from 'formik';
|
|
2
|
+
import { Button, ButtonProps } from '../button/Button.js';
|
|
3
|
+
|
|
4
|
+
export function SubmitButton(props: ButtonProps) {
|
|
5
|
+
const { isSubmitting, isValid } = useFormikContext();
|
|
6
|
+
return (
|
|
7
|
+
<Button
|
|
8
|
+
loading={isSubmitting}
|
|
9
|
+
disabled={!isValid}
|
|
10
|
+
color="primary"
|
|
11
|
+
type="submit"
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useField } from 'formik';
|
|
4
|
+
import {
|
|
5
|
+
ComponentProps,
|
|
6
|
+
InputHTMLAttributes,
|
|
7
|
+
useEffect,
|
|
8
|
+
useRef,
|
|
9
|
+
Ref,
|
|
10
|
+
forwardRef,
|
|
11
|
+
} from 'react';
|
|
12
|
+
import useMergedRef from '../../hooks/useMergedRef.js';
|
|
13
|
+
import classNames from 'classnames';
|
|
14
|
+
import { Input } from '../input/Input.js';
|
|
15
|
+
import { TextArea, TextAreaProps } from '../textArea/TextArea.js';
|
|
16
|
+
import { withClassName } from '../../hooks.js';
|
|
17
|
+
|
|
18
|
+
export type TextFieldProps = {
|
|
19
|
+
name: string;
|
|
20
|
+
label?: string;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
type?: InputHTMLAttributes<HTMLInputElement>['type'];
|
|
23
|
+
className?: string;
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
autoComplete?: InputHTMLAttributes<HTMLInputElement>['autoComplete'];
|
|
26
|
+
autoFocus?: InputHTMLAttributes<HTMLInputElement>['autoFocus'];
|
|
27
|
+
autoFocusDelay?: number;
|
|
28
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
29
|
+
} & ComponentProps<typeof Input>;
|
|
30
|
+
|
|
31
|
+
const emptyRef = (() => {}) as any;
|
|
32
|
+
|
|
33
|
+
export const TextField = forwardRef<HTMLDivElement, TextFieldProps>(
|
|
34
|
+
function TextField(
|
|
35
|
+
{
|
|
36
|
+
name,
|
|
37
|
+
label,
|
|
38
|
+
className,
|
|
39
|
+
autoFocusDelay,
|
|
40
|
+
autoFocus,
|
|
41
|
+
inputRef,
|
|
42
|
+
onChange,
|
|
43
|
+
onFocus,
|
|
44
|
+
onBlur,
|
|
45
|
+
...rest
|
|
46
|
+
},
|
|
47
|
+
ref,
|
|
48
|
+
) {
|
|
49
|
+
const [props] = useField({
|
|
50
|
+
name,
|
|
51
|
+
onChange,
|
|
52
|
+
onFocus,
|
|
53
|
+
onBlur,
|
|
54
|
+
});
|
|
55
|
+
const innerInputRef = useRef<HTMLInputElement>(null);
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (autoFocusDelay) {
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
if (innerInputRef.current) innerInputRef.current.focus();
|
|
61
|
+
}, autoFocusDelay);
|
|
62
|
+
}
|
|
63
|
+
}, [autoFocusDelay]);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<FieldRoot className={className} ref={ref}>
|
|
67
|
+
{label && <FieldLabel>{label}</FieldLabel>}
|
|
68
|
+
<Input
|
|
69
|
+
{...props}
|
|
70
|
+
{...rest}
|
|
71
|
+
autoFocus={autoFocus}
|
|
72
|
+
ref={useMergedRef(innerInputRef, inputRef || emptyRef)}
|
|
73
|
+
/>
|
|
74
|
+
</FieldRoot>
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
export type TextAreaFieldProps = {
|
|
80
|
+
name: string;
|
|
81
|
+
label?: string;
|
|
82
|
+
required?: boolean;
|
|
83
|
+
rows?: number;
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
className?: string;
|
|
86
|
+
inputRef?: Ref<HTMLTextAreaElement>;
|
|
87
|
+
} & TextAreaProps;
|
|
88
|
+
|
|
89
|
+
export function TextAreaField({
|
|
90
|
+
name,
|
|
91
|
+
label,
|
|
92
|
+
className,
|
|
93
|
+
inputRef,
|
|
94
|
+
...rest
|
|
95
|
+
}: TextAreaFieldProps) {
|
|
96
|
+
const [props] = useField(name);
|
|
97
|
+
return (
|
|
98
|
+
<FieldRoot className={className}>
|
|
99
|
+
{label && <FieldLabel>{label}</FieldLabel>}
|
|
100
|
+
<TextArea ref={inputRef} {...props} {...rest} />
|
|
101
|
+
</FieldRoot>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const FieldRoot = withClassName(
|
|
106
|
+
'div',
|
|
107
|
+
'flex flex-col items-stretch gap-1 self-stretch',
|
|
108
|
+
);
|
|
109
|
+
const FieldLabel = withClassName(
|
|
110
|
+
'label',
|
|
111
|
+
'inline-flex flex-col gap-1 text-sm font-bold text-dark-blend mb-1',
|
|
112
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './forms/index.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { forwardRef, HTMLAttributes } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { IconName } from './generated/iconNames.js';
|
|
4
|
+
|
|
5
|
+
export interface IconProps extends HTMLAttributes<SVGSVGElement> {
|
|
6
|
+
name: IconName;
|
|
7
|
+
size?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const Icon = forwardRef<SVGSVGElement, IconProps>(function Icon(
|
|
11
|
+
{ name, size = 15, className, ...rest },
|
|
12
|
+
ref,
|
|
13
|
+
) {
|
|
14
|
+
return (
|
|
15
|
+
<svg
|
|
16
|
+
ref={ref}
|
|
17
|
+
className={classNames(
|
|
18
|
+
'flex-shrink-0 layer-components:fill-none',
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
width={size}
|
|
22
|
+
height={size}
|
|
23
|
+
{...rest}
|
|
24
|
+
>
|
|
25
|
+
<use xlinkHref={`#icon-${name}`} />
|
|
26
|
+
</svg>
|
|
27
|
+
);
|
|
28
|
+
});
|