@rolder-kit/ui 0.1.0-alpha.0

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 (97) hide show
  1. package/dist/AnimatedChevron.d.ts +5 -0
  2. package/dist/AnimatedChevron.js +12 -0
  3. package/dist/JsonInput.d.ts +2 -0
  4. package/dist/JsonInput.js +45 -0
  5. package/dist/RouterLink.d.ts +16 -0
  6. package/dist/RouterLink.js +36 -0
  7. package/dist/editor/Content.d.ts +3 -0
  8. package/dist/editor/Content.js +13 -0
  9. package/dist/editor/Root.d.ts +8 -0
  10. package/dist/editor/Root.js +55 -0
  11. package/dist/editor/Toolbar.d.ts +6 -0
  12. package/dist/editor/Toolbar.js +138 -0
  13. package/dist/editor/index.d.ts +8 -0
  14. package/dist/editor/index.js +10 -0
  15. package/dist/editor/store.d.ts +6 -0
  16. package/dist/editor/store.js +10 -0
  17. package/dist/error/DefaultError.d.ts +2 -0
  18. package/dist/error/DefaultError.js +62 -0
  19. package/dist/error/DefaultNotFound.d.ts +1 -0
  20. package/dist/error/DefaultNotFound.js +37 -0
  21. package/dist/error/Forbidden.d.ts +1 -0
  22. package/dist/error/Forbidden.js +32 -0
  23. package/dist/error/defaultErrorNotification.d.ts +1 -0
  24. package/dist/error/defaultErrorNotification.js +8 -0
  25. package/dist/error/index.d.ts +4 -0
  26. package/dist/error/index.js +5 -0
  27. package/dist/form/blurOnError.d.ts +4 -0
  28. package/dist/form/blurOnError.js +11 -0
  29. package/dist/form/buttons/CancelButton.d.ts +5 -0
  30. package/dist/form/buttons/CancelButton.js +22 -0
  31. package/dist/form/buttons/SubmitButton.d.ts +5 -0
  32. package/dist/form/buttons/SubmitButton.js +22 -0
  33. package/dist/form/buttons/SubscribeActionIcon.d.ts +4 -0
  34. package/dist/form/buttons/SubscribeActionIcon.js +15 -0
  35. package/dist/form/buttons/SubscribeButton.d.ts +5 -0
  36. package/dist/form/buttons/SubscribeButton.js +16 -0
  37. package/dist/form/buttons/index.d.ts +4 -0
  38. package/dist/form/buttons/index.js +4 -0
  39. package/dist/form/context.d.ts +83 -0
  40. package/dist/form/context.js +26 -0
  41. package/dist/form/fields/JsonField.d.ts +2 -0
  42. package/dist/form/fields/JsonField.js +13 -0
  43. package/dist/form/fields/MultiSelectField.d.ts +2 -0
  44. package/dist/form/fields/MultiSelectField.js +15 -0
  45. package/dist/form/fields/NumberField.d.ts +2 -0
  46. package/dist/form/fields/NumberField.js +15 -0
  47. package/dist/form/fields/PasswordField.d.ts +2 -0
  48. package/dist/form/fields/PasswordField.js +18 -0
  49. package/dist/form/fields/SelectField.d.ts +2 -0
  50. package/dist/form/fields/SelectField.js +15 -0
  51. package/dist/form/fields/SwitchField.d.ts +2 -0
  52. package/dist/form/fields/SwitchField.js +15 -0
  53. package/dist/form/fields/TextField.d.ts +2 -0
  54. package/dist/form/fields/TextField.js +15 -0
  55. package/dist/form/fields/TextPasswordField.d.ts +2 -0
  56. package/dist/form/fields/TextPasswordField.js +29 -0
  57. package/dist/form/fields/TextareaField.d.ts +2 -0
  58. package/dist/form/fields/TextareaField.js +15 -0
  59. package/dist/form/fields/index.d.ts +9 -0
  60. package/dist/form/fields/index.js +9 -0
  61. package/dist/form/index.d.ts +3 -0
  62. package/dist/form/index.js +4 -0
  63. package/dist/hoverPaper/HoverPaper.d.ts +6 -0
  64. package/dist/hoverPaper/HoverPaper.js +15 -0
  65. package/dist/hoverPaper/index.d.ts +2 -0
  66. package/dist/hoverPaper/index.js +3 -0
  67. package/dist/hoverPaper/usePaperHover.d.ts +4 -0
  68. package/dist/hoverPaper/usePaperHover.js +9 -0
  69. package/dist/index.d.ts +4 -0
  70. package/dist/index.js +4 -0
  71. package/dist/saveInput/JsonInput.d.ts +6 -0
  72. package/dist/saveInput/JsonInput.js +33 -0
  73. package/dist/saveInput/NumberInput.d.ts +6 -0
  74. package/dist/saveInput/NumberInput.js +26 -0
  75. package/dist/saveInput/SaveInput.d.ts +36 -0
  76. package/dist/saveInput/SaveInput.js +15 -0
  77. package/dist/saveInput/Select.d.ts +6 -0
  78. package/dist/saveInput/Select.js +26 -0
  79. package/dist/saveInput/Switch.d.ts +6 -0
  80. package/dist/saveInput/Switch.js +29 -0
  81. package/dist/saveInput/TextInput.d.ts +6 -0
  82. package/dist/saveInput/TextInput.js +25 -0
  83. package/dist/saveInput/Textarea.d.ts +6 -0
  84. package/dist/saveInput/Textarea.js +25 -0
  85. package/dist/saveInput/index.d.ts +1 -0
  86. package/dist/saveInput/index.js +2 -0
  87. package/dist/scrollArea/Root.d.ts +7 -0
  88. package/dist/scrollArea/Root.js +41 -0
  89. package/dist/scrollArea/ScrollButton.d.ts +7 -0
  90. package/dist/scrollArea/ScrollButton.js +30 -0
  91. package/dist/scrollArea/index.d.ts +6 -0
  92. package/dist/scrollArea/index.js +7 -0
  93. package/dist/scrollArea/methods.d.ts +4 -0
  94. package/dist/scrollArea/methods.js +32 -0
  95. package/dist/scrollArea/store.d.ts +12 -0
  96. package/dist/scrollArea/store.js +25 -0
  97. package/package.json +53 -0
@@ -0,0 +1,26 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Loader, Select, useDebouncedCallback } from "@rolder-kit/mantine";
3
+ import { useState } from "react";
4
+ const Select_Select = ({ initialValue, onChange, debounce = 300, ...props })=>{
5
+ const [value, setValue] = useState(initialValue);
6
+ const [loading, setLoading] = useState(false);
7
+ const handleSave = useDebouncedCallback(async (content)=>{
8
+ setLoading(true);
9
+ await onChange(content);
10
+ setLoading(false);
11
+ }, debounce);
12
+ return /*#__PURE__*/ jsx(Select, {
13
+ value: value,
14
+ onChange: (v)=>{
15
+ setValue(v);
16
+ handleSave(v);
17
+ },
18
+ flex: props.w ? void 0 : 1,
19
+ disabled: loading,
20
+ rightSection: loading ? /*#__PURE__*/ jsx(Loader, {
21
+ size: "sm"
22
+ }) : void 0,
23
+ ...props
24
+ });
25
+ };
26
+ export { Select_Select as Select };
@@ -0,0 +1,6 @@
1
+ import { type SwitchProps } from '@rolder-kit/mantine';
2
+ export declare const Switch: React.FC<{
3
+ initialValue: boolean;
4
+ onChange: (value: boolean) => Promise<void>;
5
+ debounce?: number;
6
+ } & Omit<SwitchProps, 'checked' | 'onChange'>>;
@@ -0,0 +1,29 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Box, Loader, Switch, useDebouncedCallback } from "@rolder-kit/mantine";
3
+ import { useState } from "react";
4
+ const Switch_Switch = ({ initialValue, onChange, debounce = 300, w, ...props })=>{
5
+ const [value, setValue] = useState(initialValue);
6
+ const [loading, setLoading] = useState(false);
7
+ const handleSave = useDebouncedCallback(async (content)=>{
8
+ setLoading(true);
9
+ await onChange(content);
10
+ setLoading(false);
11
+ }, debounce);
12
+ return /*#__PURE__*/ jsx(Box, {
13
+ flex: 1,
14
+ w: w,
15
+ children: loading ? /*#__PURE__*/ jsx(Loader, {
16
+ size: "sm",
17
+ mt: 6.5,
18
+ ml: 8
19
+ }) : /*#__PURE__*/ jsx(Switch, {
20
+ checked: value,
21
+ onChange: (e)=>{
22
+ setValue(e.currentTarget.checked);
23
+ handleSave(e.currentTarget.checked);
24
+ },
25
+ ...props
26
+ })
27
+ });
28
+ };
29
+ export { Switch_Switch as Switch };
@@ -0,0 +1,6 @@
1
+ import { type TextInputProps } from '@rolder-kit/mantine';
2
+ export declare const TextInput: React.FC<{
3
+ initialValue?: string;
4
+ onChange: (value: string) => Promise<void>;
5
+ debounce?: number;
6
+ } & Omit<TextInputProps, 'value' | 'onChange'>>;
@@ -0,0 +1,25 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Loader, TextInput, useDebouncedCallback } from "@rolder-kit/mantine";
3
+ import { useState } from "react";
4
+ const TextInput_TextInput = ({ initialValue, onChange, debounce = 300, ...props })=>{
5
+ const [value, setValue] = useState(initialValue || '');
6
+ const [loading, setLoading] = useState(false);
7
+ const handleSave = useDebouncedCallback(async (content)=>{
8
+ setLoading(true);
9
+ await onChange(content);
10
+ setLoading(false);
11
+ }, debounce);
12
+ return /*#__PURE__*/ jsx(TextInput, {
13
+ value: value,
14
+ onChange: (e)=>{
15
+ setValue(e.target.value);
16
+ handleSave(e.target.value);
17
+ },
18
+ flex: props.w ? void 0 : 1,
19
+ rightSection: loading ? /*#__PURE__*/ jsx(Loader, {
20
+ size: "sm"
21
+ }) : void 0,
22
+ ...props
23
+ });
24
+ };
25
+ export { TextInput_TextInput as TextInput };
@@ -0,0 +1,6 @@
1
+ import { type TextareaProps } from '@rolder-kit/mantine';
2
+ export declare const Textarea: React.FC<{
3
+ initialValue: string;
4
+ onChange: (value: string) => Promise<void>;
5
+ debounce?: number;
6
+ } & Omit<TextareaProps, 'value' | 'onChange'>>;
@@ -0,0 +1,25 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Loader, Textarea, useDebouncedCallback } from "@rolder-kit/mantine";
3
+ import { useState } from "react";
4
+ const Textarea_Textarea = ({ initialValue, onChange, debounce = 300, ...props })=>{
5
+ const [value, setValue] = useState(initialValue);
6
+ const [loading, setLoading] = useState(false);
7
+ const handleSave = useDebouncedCallback(async (content)=>{
8
+ setLoading(true);
9
+ await onChange(content);
10
+ setLoading(false);
11
+ }, debounce);
12
+ return /*#__PURE__*/ jsx(Textarea, {
13
+ value: value,
14
+ onChange: (e)=>{
15
+ setValue(e.target.value);
16
+ handleSave(e.target.value);
17
+ },
18
+ flex: props.w ? void 0 : 1,
19
+ rightSection: loading ? /*#__PURE__*/ jsx(Loader, {
20
+ size: "sm"
21
+ }) : void 0,
22
+ ...props
23
+ });
24
+ };
25
+ export { Textarea_Textarea as Textarea };
@@ -0,0 +1 @@
1
+ export { SaveInput } from './SaveInput';
@@ -0,0 +1,2 @@
1
+ import { SaveInput } from "./SaveInput.js";
2
+ export { SaveInput };
@@ -0,0 +1,7 @@
1
+ import { type MantineRadius, type ScrollAreaProps as MantineScrollAreaProps } from '@rolder-kit/mantine';
2
+ export interface ScrollAreaProps extends Omit<MantineScrollAreaProps, 'h'> {
3
+ height: MantineScrollAreaProps['h'];
4
+ radius?: MantineRadius;
5
+ autoScroll?: boolean;
6
+ }
7
+ export declare const Root: React.FC<ScrollAreaProps>;
@@ -0,0 +1,41 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Box, ScrollArea, getRadius, useElementSize } from "@rolder-kit/mantine";
3
+ import { useEffect, useRef } from "react";
4
+ import { isAboveCenter } from "./methods.js";
5
+ import { getHasScrollableContent, getHeight, getIsAboveCenter, getScrollAreaRef, setAutoScroll, setHeight, setIsAboveCenter, setScrollAreaRef } from "./store.js";
6
+ const Root = ({ children, height, radius, autoScroll = false, ...props })=>{
7
+ const scrollAreaRef = useRef(null);
8
+ const { ref: boxRef, height: contentHeight } = useElementSize();
9
+ useEffect(()=>{
10
+ setAutoScroll(autoScroll);
11
+ });
12
+ useEffect(()=>{
13
+ if (getHeight() !== contentHeight) setHeight(contentHeight);
14
+ if (scrollAreaRef.current && !getScrollAreaRef()) setScrollAreaRef(scrollAreaRef.current);
15
+ }, [
16
+ contentHeight
17
+ ]);
18
+ return /*#__PURE__*/ jsx(ScrollArea, {
19
+ viewportRef: scrollAreaRef,
20
+ h: height,
21
+ classNames: {
22
+ viewport: 'rolder-scroll-area-viewport',
23
+ scrollbar: 'rolder-scroll-area-scrollbar'
24
+ },
25
+ style: {
26
+ '--radius': radius ? getRadius(radius) : void 0
27
+ },
28
+ onScrollPositionChange: ()=>{
29
+ if (getHasScrollableContent()) {
30
+ const current = isAboveCenter();
31
+ if (getIsAboveCenter() !== current) setIsAboveCenter(current);
32
+ }
33
+ },
34
+ ...props,
35
+ children: /*#__PURE__*/ jsx(Box, {
36
+ ref: boxRef,
37
+ children: children
38
+ })
39
+ });
40
+ };
41
+ export { Root };
@@ -0,0 +1,7 @@
1
+ import { type ActionIconProps } from '@rolder-kit/mantine';
2
+ import { type ReactNode } from '@tabler/icons-react';
3
+ export interface ScrollButtonProps extends ActionIconProps {
4
+ upIcon?: ReactNode;
5
+ downIcon?: ReactNode;
6
+ }
7
+ export declare const ScrollButton: React.FC<ScrollButtonProps>;
@@ -0,0 +1,30 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { ActionIcon } from "@rolder-kit/mantine";
3
+ import { IconChevronDown, IconChevronUp } from "@tabler/icons-react";
4
+ import { scrollToBottom, scrollToTop } from "./methods.js";
5
+ import { useHasScrollableContent, useIsAboveCenter } from "./store.js";
6
+ const ScrollButton = ({ upIcon, downIcon, ...props })=>{
7
+ const hasScrollableContent = useHasScrollableContent();
8
+ const isScrollingDown = useIsAboveCenter();
9
+ if (!hasScrollableContent) return null;
10
+ const icon = isScrollingDown ? downIcon ?? /*#__PURE__*/ jsx(IconChevronDown, {
11
+ strokeWidth: 1.5
12
+ }) : upIcon ?? /*#__PURE__*/ jsx(IconChevronUp, {
13
+ strokeWidth: 1.5
14
+ });
15
+ const handleClick = ()=>{
16
+ if (isScrollingDown) scrollToBottom();
17
+ else scrollToTop();
18
+ };
19
+ return /*#__PURE__*/ jsx(ActionIcon, {
20
+ pos: "absolute",
21
+ bottom: 16,
22
+ right: 16,
23
+ variant: "light",
24
+ onClick: handleClick,
25
+ "aria-label": isScrollingDown ? 'Scroll to bottom' : 'Scroll to top',
26
+ ...props,
27
+ children: icon
28
+ });
29
+ };
30
+ export { ScrollButton };
@@ -0,0 +1,6 @@
1
+ export declare const ScrollArea: {
2
+ Root: import("react").FC<import("./Root").ScrollAreaProps>;
3
+ ScrollButton: import("react").FC<import("./ScrollButton").ScrollButtonProps>;
4
+ };
5
+ export type * from './Root';
6
+ export type * from './ScrollButton';
@@ -0,0 +1,7 @@
1
+ import { Root } from "./Root.js";
2
+ import { ScrollButton } from "./ScrollButton.js";
3
+ const ScrollArea = {
4
+ Root: Root,
5
+ ScrollButton: ScrollButton
6
+ };
7
+ export { ScrollArea };
@@ -0,0 +1,4 @@
1
+ export declare const scrollToBottom: () => void;
2
+ export declare const scrollToTop: () => void;
3
+ export declare const isAboveCenter: () => boolean;
4
+ export declare const hasScrollableContent: () => boolean;
@@ -0,0 +1,32 @@
1
+ import { getScrollAreaRef } from "./store.js";
2
+ const scrollToBottom = ()=>{
3
+ const ref = getScrollAreaRef();
4
+ if (!ref) return;
5
+ ref.scrollTo({
6
+ top: ref.scrollHeight,
7
+ behavior: 'smooth'
8
+ });
9
+ };
10
+ const scrollToTop = ()=>{
11
+ const ref = getScrollAreaRef();
12
+ if (!ref) return;
13
+ ref.scrollTo({
14
+ top: 0,
15
+ behavior: 'smooth'
16
+ });
17
+ };
18
+ const isAboveCenter = ()=>{
19
+ const ref = getScrollAreaRef();
20
+ if (!ref) return false;
21
+ const { scrollTop, scrollHeight, clientHeight } = ref;
22
+ const viewportCenter = scrollTop + clientHeight / 2;
23
+ const contentCenter = scrollHeight / 2;
24
+ return viewportCenter < contentCenter;
25
+ };
26
+ const hasScrollableContent = ()=>{
27
+ const ref = getScrollAreaRef();
28
+ if (!ref) return false;
29
+ const { scrollHeight, clientHeight } = ref;
30
+ return scrollHeight > clientHeight;
31
+ };
32
+ export { hasScrollableContent, isAboveCenter, scrollToBottom, scrollToTop };
@@ -0,0 +1,12 @@
1
+ export declare const getScrollAreaRef: () => HTMLElement | null;
2
+ export declare const setScrollAreaRef: (scrollAreaRef: HTMLElement | null) => void;
3
+ export declare const getHeight: () => number;
4
+ export declare const setHeight: (height: number) => void;
5
+ export declare const getAutoScroll: () => boolean;
6
+ export declare const setAutoScroll: (autoScroll: boolean) => void;
7
+ export declare const getHasScrollableContent: () => boolean;
8
+ export declare const useHasScrollableContent: () => boolean;
9
+ export declare const setHasScrollableContent: (hasScrollableContent: boolean) => void;
10
+ export declare const getIsAboveCenter: () => boolean;
11
+ export declare const useIsAboveCenter: () => boolean;
12
+ export declare const setIsAboveCenter: (isAboveCenter: boolean) => void;
@@ -0,0 +1,25 @@
1
+ import { useStore } from "@nanostores/react";
2
+ import { atom } from "nanostores";
3
+ import { hasScrollableContent as external_methods_js_hasScrollableContent, scrollToBottom } from "./methods.js";
4
+ const $scrollAreaRef = atom(null);
5
+ const getScrollAreaRef = ()=>$scrollAreaRef.get();
6
+ const setScrollAreaRef = (scrollAreaRef)=>$scrollAreaRef.set(scrollAreaRef);
7
+ const $height = atom(0);
8
+ const getHeight = ()=>$height.get();
9
+ const setHeight = (height)=>$height.set(height);
10
+ const $autoScroll = atom(false);
11
+ const getAutoScroll = ()=>$autoScroll.get();
12
+ const setAutoScroll = (autoScroll)=>$autoScroll.set(autoScroll);
13
+ const $hasScrollableContent = atom(false);
14
+ const getHasScrollableContent = ()=>$hasScrollableContent.get();
15
+ const useHasScrollableContent = ()=>useStore($hasScrollableContent);
16
+ const setHasScrollableContent = (hasScrollableContent)=>$hasScrollableContent.set(hasScrollableContent);
17
+ const $isAboveCenter = atom(false);
18
+ const getIsAboveCenter = ()=>$isAboveCenter.get();
19
+ const useIsAboveCenter = ()=>useStore($isAboveCenter);
20
+ const setIsAboveCenter = (isAboveCenter)=>$isAboveCenter.set(isAboveCenter);
21
+ $height.listen((height)=>{
22
+ if (getAutoScroll() && height) scrollToBottom();
23
+ if (external_methods_js_hasScrollableContent() && !getHasScrollableContent()) setHasScrollableContent(true);
24
+ });
25
+ export { getAutoScroll, getHasScrollableContent, getHeight, getIsAboveCenter, getScrollAreaRef, setAutoScroll, setHasScrollableContent, setHeight, setIsAboveCenter, setScrollAreaRef, useHasScrollableContent, useIsAboveCenter };
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@rolder-kit/ui",
3
+ "version": "0.1.0-alpha.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js"
9
+ },
10
+ "./editor": {
11
+ "types": "./dist/editor/index.d.ts",
12
+ "import": "./dist/editor/index.js"
13
+ },
14
+ "./ui": {
15
+ "types": "./dist/ui/index.d.ts",
16
+ "import": "./dist/ui/index.js"
17
+ },
18
+ "./notifications": {
19
+ "types": "./dist/notifications.d.ts",
20
+ "import": "./dist/notifications.js"
21
+ }
22
+ },
23
+ "sideEffects": false,
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "scripts": {
28
+ "build": "rslib build",
29
+ "dev": "rslib build --watch",
30
+ "prepublishOnly": "bun run build",
31
+ "check": "biome check --write && tsc --noEmit"
32
+ },
33
+ "peerDependencies": {
34
+ "@rolder-kit/tanstack": "*",
35
+ "@rolder-kit/mantine": "*",
36
+ "@mantine/tiptap": "^8.3.14",
37
+ "@tiptap/extension-highlight": "^3.19.0",
38
+ "@tiptap/extension-placeholder": "^3.19.0",
39
+ "@tiptap/extension-table": "^3.19.0",
40
+ "@tiptap/extension-task-item": "^3.19.0",
41
+ "@tiptap/extension-task-list": "^3.19.0",
42
+ "@tiptap/extension-text-align": "^3.19.0",
43
+ "@tiptap/react": "^3.19.0",
44
+ "@tiptap/starter-kit": "^3.19.0",
45
+ "nanostores": "^1.1.0",
46
+ "@nanostores/react": "^1.0.0",
47
+ "@tanstack/react-router": "^1.160.0",
48
+ "@tanstack/react-form": "^1.28.3",
49
+ "@uiw/react-codemirror": "^4.25.4",
50
+ "@codemirror/lang-json": "^6.0.2",
51
+ "@codemirror/lint": "^6.9.4"
52
+ }
53
+ }