@jamsrui/composite 0.0.2
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/README.md +40 -0
- package/dist/composite-context.d.mts +12 -0
- package/dist/composite-context.mjs +1 -0
- package/dist/composite-item.d.mts +11 -0
- package/dist/composite-item.mjs +1 -0
- package/dist/composite.d.mts +3 -0
- package/dist/composite.mjs +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +1 -0
- package/dist/use-composite-_Cst7X9L.d.mts +45 -0
- package/dist/use-composite-item.d.mts +30 -0
- package/dist/use-composite-item.mjs +1 -0
- package/dist/use-composite.d.mts +3 -0
- package/dist/use-composite.mjs +1 -0
- package/dist/utils.d.mts +2 -0
- package/dist/utils.mjs +0 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# π **JamsrUI**
|
|
2
|
+
|
|
3
|
+
**A comprehensive React UI component library designed for developers, with Tailwind CSS integration for seamless styling.**
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## π **Overview**
|
|
7
|
+
|
|
8
|
+
[JamsrUI](https://jamsr-ui.jamsrworld.com) is designed to help developers build modern, fast and visually appealing web applications with ease.
|
|
9
|
+
|
|
10
|
+
## π Getting Started
|
|
11
|
+
|
|
12
|
+
Boost & Build your websites using [JamsrUI](https://jamsr-ui.jamsrworld.com).
|
|
13
|
+
|
|
14
|
+
## β¨ Features
|
|
15
|
+
|
|
16
|
+
- π **Production-Ready**: Optimized for modern React projects.
|
|
17
|
+
- π¨ **Customizable**: Easily override styles and themes.
|
|
18
|
+
- π οΈ **Reusable Components**: Save time with prebuilt, efficient UI elements.
|
|
19
|
+
- β‘ **Developer-Friendly**: Simple API and well-documented usage.
|
|
20
|
+
- π¦ **Lightweight**: Minimal dependencies for fast performance.
|
|
21
|
+
- π₯οΈ **Modern Design**: Clean, responsive, and user-friendly components.
|
|
22
|
+
|
|
23
|
+
## π± Community
|
|
24
|
+
|
|
25
|
+
Weβre thrilled to see the community actively engage with **JamsrUI**! Whether you're sharing feedback, reporting bugs, requesting features, or showcasing projects built with JamsrUI, your involvement helps us grow and improve.
|
|
26
|
+
|
|
27
|
+
### How to Engage
|
|
28
|
+
|
|
29
|
+
- π¬ **Report Bugs**: [GitHub Issues](https://github.com/jamsrworld/jamsr-ui/issues)
|
|
30
|
+
- π **Request Features**: Share ideas for new components.
|
|
31
|
+
- π€ **Showcase Projects**: Let us know how you use JamsrUI.
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
We welcome contributions from developers of all skill levels!
|
|
36
|
+
|
|
37
|
+
## β Support the Project
|
|
38
|
+
|
|
39
|
+
If you find **JamsrUI** helpful, consider giving it a β on [GitHub](https://github.com/jamsrworld/jamsr-ui).
|
|
40
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { u as useComposite } from './use-composite-_Cst7X9L.mjs';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
declare const CompositeContext: react.Context<CompositeContext.Props | null>;
|
|
6
|
+
declare namespace CompositeContext {
|
|
7
|
+
interface Props extends ReturnType<typeof useComposite> {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare const useCompositeContext: () => CompositeContext.Props;
|
|
11
|
+
|
|
12
|
+
export { CompositeContext, useCompositeContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as t,use as o}from"react";const s=t(null),r=()=>{const e=o(s);if(!e)throw new Error("useCompositeContext must be used within a Composite");return e};export{s as CompositeContext,r as useCompositeContext};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { useCompositeItem } from './use-composite-item.mjs';
|
|
3
|
+
|
|
4
|
+
declare const CompositeItem: (props: CompositeItem.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
+
declare namespace CompositeItem {
|
|
6
|
+
interface Props extends useCompositeItem.Props {
|
|
7
|
+
children: React.ReactElement;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { CompositeItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cloneElement as s}from"react";import{useCompositeItem as m}from"./use-composite-item";const c=e=>{const{children:t,...o}=e,r=m(o);return s(t,r.props)};export{c as CompositeItem};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as i}from"react/jsx-runtime";import{CompositeContext as r}from"./composite-context";import{useComposite as p}from"./use-composite";const m=o=>{const{children:t}=o,e=p(o);return i(r,{value:e,children:t})};export{m as Composite};
|
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{Composite as t}from"./composite";import{CompositeItem as p}from"./composite-item";import{useComposite as s}from"./use-composite";import{useCompositeItem as f}from"./use-composite-item";export{t as Composite,p as CompositeItem,s as useComposite,f as useCompositeItem};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
declare const Composite: (props: Composite.Props) => react_jsx_runtime.JSX.Element;
|
|
5
|
+
declare namespace Composite {
|
|
6
|
+
type Orientation = "horizontal" | "vertical" | "both";
|
|
7
|
+
type Dir = "ltr" | "rtl";
|
|
8
|
+
interface Props extends useComposite.Props {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type CompositeItemRef = {
|
|
14
|
+
id: string;
|
|
15
|
+
ref: HTMLElement | null;
|
|
16
|
+
isDisabled: boolean;
|
|
17
|
+
};
|
|
18
|
+
declare const useComposite: (props: useComposite.Props) => {
|
|
19
|
+
registerItem: (entry: CompositeItemRef) => {
|
|
20
|
+
index: number;
|
|
21
|
+
};
|
|
22
|
+
unregisterItem: (id: string) => void;
|
|
23
|
+
getIndex: (id: string) => number;
|
|
24
|
+
items: react.RefObject<CompositeItemRef[]>;
|
|
25
|
+
activeIndex: number;
|
|
26
|
+
setActiveIndex: react.Dispatch<react.SetStateAction<number>>;
|
|
27
|
+
movePrev: (from: number) => number;
|
|
28
|
+
moveNext: (from: number) => number;
|
|
29
|
+
moveFirst: () => number;
|
|
30
|
+
moveLast: () => number;
|
|
31
|
+
orientation: Composite.Orientation;
|
|
32
|
+
dir: Composite.Dir;
|
|
33
|
+
loop: boolean;
|
|
34
|
+
virtual: boolean;
|
|
35
|
+
};
|
|
36
|
+
declare namespace useComposite {
|
|
37
|
+
interface Props {
|
|
38
|
+
orientation?: Composite.Orientation;
|
|
39
|
+
dir?: Composite.Dir;
|
|
40
|
+
loop?: boolean;
|
|
41
|
+
virtual?: boolean;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { Composite as C, useComposite as u };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import react__default from 'react';
|
|
2
|
+
|
|
3
|
+
declare const useCompositeItem: (props: useCompositeItem.Props) => {
|
|
4
|
+
props: {
|
|
5
|
+
id: string;
|
|
6
|
+
"data-index": number;
|
|
7
|
+
ref: (node: HTMLElement | null) => void;
|
|
8
|
+
tabIndex: number;
|
|
9
|
+
"aria-selected": boolean | "true" | "false";
|
|
10
|
+
onKeyDown?: undefined;
|
|
11
|
+
onFocus?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
id: string;
|
|
14
|
+
"data-index": number;
|
|
15
|
+
ref: (node: HTMLElement | null) => void;
|
|
16
|
+
tabIndex: number;
|
|
17
|
+
onKeyDown: (e: react__default.KeyboardEvent) => void;
|
|
18
|
+
onFocus: () => void;
|
|
19
|
+
"aria-selected"?: undefined;
|
|
20
|
+
};
|
|
21
|
+
index: number;
|
|
22
|
+
};
|
|
23
|
+
declare namespace useCompositeItem {
|
|
24
|
+
interface Props {
|
|
25
|
+
id?: string;
|
|
26
|
+
isDisabled?: boolean;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { useCompositeItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as a,useEffect as w,useId as D,useMemo as g,useRef as h,useState as C}from"react";import{dataAttr as P}from"@jamsrui/utils";import{useCompositeContext as R}from"./composite-context";const M=v=>{const{id:x,isDisabled:m=!1}=v,e=R(),I=D(),u=h(null),[y,A]=C(-1),i=x??I;w(()=>{const{index:t}=e.registerItem({id:i,ref:u.current,isDisabled:m});return A(t),()=>e.unregisterItem(i)},[e,m,i]);const r=y,l=r===e.activeIndex,s=a(t=>{const n=e.items.current[t]?.ref;e.virtual||n?.focus()},[e.items,e.virtual]),d=a(t=>{if(e.virtual)return;const n=e.dir==="rtl",c=e.orientation==="horizontal"||e.orientation==="both",p=e.orientation==="vertical"||e.orientation==="both";let o=r;t.key==="ArrowRight"&&c&&!n||t.key==="ArrowDown"&&p||t.key==="ArrowLeft"&&c&&n?(t.preventDefault(),o=e.moveNext(r),console.log(o),e.setActiveIndex(o),s(o)):t.key==="ArrowLeft"&&c&&!n||t.key==="ArrowUp"&&p||t.key==="ArrowRight"&&c&&n?(t.preventDefault(),o=e.movePrev(r),e.setActiveIndex(o),s(o)):t.key==="Home"||t.key==="PageUp"?(t.preventDefault(),o=e.moveFirst(),e.setActiveIndex(o),s(o)):(t.key==="End"||t.key==="PageDown")&&(t.preventDefault(),o=e.moveLast(),e.setActiveIndex(o),s(o))},[e,s,r]),f=a(()=>{e.setActiveIndex(r)},[e,r]),b=g(()=>e.virtual?{tabIndex:-1,"aria-selected":P(l)}:{tabIndex:l?0:-1,onKeyDown:d,onFocus:f},[e.virtual,l,f,d]),k=a(t=>{u.current=t},[]);return{props:{...b,id:i,"data-index":r,ref:k},index:r}};export{M as useCompositeItem};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as l,useMemo as C,useRef as k,useState as w}from"react";import{isDisabledElement as R}from"@jamsrui/utils";const H=y=>{const{dir:p="ltr",loop:m=!0,orientation:a="vertical",virtual:f=!1}=y,o=k([]),[c,u]=w(0),I=k(null);console.log({rootRef:I,items:o,activeIndex:c});const x=l(e=>(o.current.push({...e,isDisabled:e.isDisabled||(e.ref?R(e.ref):!1)}),{index:o.current.length-1}),[]),h=l(e=>{const r=o.current.findIndex(t=>t.id===e);r>=0&&o.current.splice(r,1),u(t=>Math.max(0,Math.min(o.current.length-1,t)))},[]),D=l(e=>o.current.findIndex(r=>r.id===e),[]),s=l((e,r)=>{const t=o.current.length;if(t===0)return-1;let n=e;for(let i=0;i<t;i++){if(n=n+r,m)n=(n+t)%t;else if(n<0||n>=t)return e;if(!o.current[n]?.isDisabled)return n}return e},[m]),d=l(e=>s(e,-1),[s]),v=l(e=>s(e,1),[s]),b=l(()=>s(-1,1),[s]),g=l(()=>s(o.current.length,-1),[s]),A=e=>{if(!f)return;const r=p==="rtl",t=a==="horizontal"||a==="both",n=a==="vertical"||a==="both";let i=c;e.key==="ArrowRight"&&t&&!r||e.key==="ArrowDown"&&n||e.key==="ArrowLeft"&&t&&r?(e.preventDefault(),i=v(c),u(i)):e.key==="ArrowLeft"&&t&&!r||e.key==="ArrowUp"&&n||e.key==="ArrowRight"&&t&&r?(e.preventDefault(),i=d(c),u(i)):e.key==="Home"||e.key==="PageUp"?(e.preventDefault(),i=b(),u(i)):(e.key==="End"||e.key==="PageDown")&&(e.preventDefault(),i=g(),u(i))},E=o.current[c]?.id;return C(()=>({registerItem:x,unregisterItem:h,getIndex:D,items:o,activeIndex:c,setActiveIndex:u,movePrev:d,moveNext:v,moveFirst:b,moveLast:g,orientation:a,dir:p,loop:m,virtual:f}),[x,h,D,c,d,v,b,g,a,p,m,f])};export{H as useComposite};
|
package/dist/utils.d.mts
ADDED
package/dist/utils.mjs
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jamsrui/composite",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"react": ">=19"
|
|
6
|
+
},
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@jamsrui/utils": "^0.0.9"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"description": "A modern and beautiful Next.js UI components library.",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react",
|
|
20
|
+
"ui",
|
|
21
|
+
"UI components",
|
|
22
|
+
"Next.js",
|
|
23
|
+
"React",
|
|
24
|
+
"JamsrUI",
|
|
25
|
+
"jamsr-ui",
|
|
26
|
+
"TypeScript"
|
|
27
|
+
],
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"author": "@jamsrworld",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/jamsrworld/jamsr-ui"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/jamsrworld/jamsr-ui/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://jamsr-ui.jamsrworld.com",
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"README",
|
|
42
|
+
"README.md",
|
|
43
|
+
"package.json",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
]
|
|
46
|
+
}
|