@collective-intelligence/ui-react 0.1.1 → 0.1.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 +3 -1
- package/dist/components/illustrations/index.d.ts +8 -8
- package/dist/components/illustrations/index.js +1 -1
- package/dist/components/ui-extensions/index.d.ts +12 -0
- package/dist/components/ui-extensions/index.js +5 -5
- package/dist/resources.d.ts +2 -1
- package/dist/resources.js +1 -1
- package/package.json +1 -1
package/dist/resources.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export type ResourcePaginationPrimitiveProps = Readonly<{
|
|
|
50
50
|
hasNextPage: boolean;
|
|
51
51
|
hasPreviousPage?: boolean;
|
|
52
52
|
isPending?: boolean;
|
|
53
|
+
navigationLabel?: string;
|
|
53
54
|
nextLabel?: ReactNode;
|
|
54
55
|
onNext: () => void;
|
|
55
56
|
onPrevious: () => void;
|
|
@@ -133,6 +134,6 @@ export type ResourceFiltersBarProps = Readonly<{
|
|
|
133
134
|
layout?: "stacked" | "inline";
|
|
134
135
|
controls: readonly ResourceFilterControl[];
|
|
135
136
|
}>;
|
|
136
|
-
export declare const ResourceActionPrimitive: ({ children, className, components, disabled, onClick, pending, style }: ResourceActionPrimitiveProps) => import("react").JSX.Element, ResourceDialogPrimitive: ({ children, className, components, open, onOpenChange, description, style, title }: ResourceDialogPrimitiveProps) => import("react").JSX.Element | null, ResourceFilterPrimitive: ({ className, inputProps, label, onChange, style, value }: ResourceFilterPrimitiveProps) => import("react").JSX.Element, ResourceFormPrimitive: ({ label, fields, values, errors, onChange, onSubmit, onCancel, renderControl, pending, disabled, submitLabel, cancelLabel, error, className }: ResourceFormPrimitiveProps) => import("react").JSX.Element, ResourceFiltersBar: ({ label, layout, controls }: ResourceFiltersBarProps) => import("react").JSX.Element | null, ResourceListPrimitive: <Item>({ ariaLabel, className, empty, getItemKey, items, renderItem, renderContainer, style }: ResourceListPrimitiveProps<Item>) => string | number | bigint | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null | undefined, ResourcePaginationPrimitive: ({ className, currentPage, hasNextPage, hasPreviousPage, isPending, nextLabel, onNext, onPrevious, onPageChange, totalPages, ellipsisLabel, previousLabel, style }: ResourcePaginationPrimitiveProps) => import("react").JSX.Element, ResourceTablePrimitive: <Row>({ caption, className, columns, empty, getRowKey, onRowClick, renderActions, actionsLabel, stickyActions, isPending, isRowSelected, isRowExpanded, onExpandedChange, renderDetails, renderContextMenu, renderCell, rows, style }: ResourceTablePrimitiveProps<Row>) => import("react").JSX.Element;
|
|
137
|
+
export declare const ResourceActionPrimitive: ({ children, className, components, disabled, onClick, pending, style }: ResourceActionPrimitiveProps) => import("react").JSX.Element, ResourceDialogPrimitive: ({ children, className, components, open, onOpenChange, description, style, title }: ResourceDialogPrimitiveProps) => import("react").JSX.Element | null, ResourceFilterPrimitive: ({ className, inputProps, label, onChange, style, value }: ResourceFilterPrimitiveProps) => import("react").JSX.Element, ResourceFormPrimitive: ({ label, fields, values, errors, onChange, onSubmit, onCancel, renderControl, pending, disabled, submitLabel, cancelLabel, error, className }: ResourceFormPrimitiveProps) => import("react").JSX.Element, ResourceFiltersBar: ({ label, layout, controls }: ResourceFiltersBarProps) => import("react").JSX.Element | null, ResourceListPrimitive: <Item>({ ariaLabel, className, empty, getItemKey, items, renderItem, renderContainer, style }: ResourceListPrimitiveProps<Item>) => string | number | bigint | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null | undefined, ResourcePaginationPrimitive: ({ className, currentPage, hasNextPage, hasPreviousPage, isPending, navigationLabel, nextLabel, onNext, onPrevious, onPageChange, totalPages, ellipsisLabel, previousLabel, style }: ResourcePaginationPrimitiveProps) => import("react").JSX.Element, ResourceTablePrimitive: <Row>({ caption, className, columns, empty, getRowKey, onRowClick, renderActions, actionsLabel, stickyActions, isPending, isRowSelected, isRowExpanded, onExpandedChange, renderDetails, renderContextMenu, renderCell, rows, style }: ResourceTablePrimitiveProps<Row>) => import("react").JSX.Element;
|
|
137
138
|
|
|
138
139
|
export {};
|
package/dist/resources.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{Ad as
|
|
2
|
+
import{Ad as w,Bd as M,Cd as S,Dd as oe,Ed as B,Hc as K,Ic as V,Pc as G,dd as J,id as Q,md as U,nd as X,od as f,pd as Y,qd as Z,rd as h,vd as q,wd as x,xd as j,yd as ee}from"./index-eevg910d.js";import{ae as y}from"./index-gzgwcnnv.js";import{Hf as O,Jf as $}from"./index-fdh3nr3r.js";import"./index-mtc4857g.js";import{Mh as Ce}from"./index-225zhfvs.js";var L={};Ce(L,{ResourceTablePrimitive:()=>re,ResourcePaginationPrimitive:()=>ne,ResourceListPrimitive:()=>ie,ResourceFormPrimitive:()=>ce,ResourceFiltersBar:()=>pe,ResourceFilterPrimitive:()=>ae,ResourceDialogPrimitive:()=>se,ResourceActionPrimitive:()=>le});import{Fragment as te,useId as z}from"react";import{jsx as r,jsxs as P}from"react/jsx-runtime";var D=(...e)=>e.filter(Boolean).join(" "),Pe={border:"1px solid currentColor",borderRadius:"0.5rem",padding:"0.75rem"},re=({caption:e,className:i,columns:t,empty:n="No resources found",getRowKey:l,onRowClick:o,renderActions:s,actionsLabel:m="Actions",stickyActions:a=!0,isPending:c=!1,isRowSelected:b,isRowExpanded:d,onExpandedChange:N,renderDetails:T,renderContextMenu:u,renderCell:F,rows:I,style:Re})=>{let A=s!==void 0||T!==void 0,E=a?"sticky right-0 z-10 shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]":"";return P(x,{className:D("ci-resource-table",i),style:{borderCollapse:"collapse",width:"100%",...Re},children:[e?r(oe,{children:e}):null,r(j,{children:P(w,{children:[t.map((p)=>r(M,{scope:"col",children:p.label},p.id)),A?r(M,{className:E,children:r("span",{className:"sr-only",children:m})}):null]})}),r(ee,{children:I.length===0?r(w,{children:r(S,{className:"py-10",colSpan:Math.max(t.length+(A?1:0),1),children:n})}):I.map((p)=>{let C=d?.(p)??!1,H=T?.(p,C),_=!!H,W=P(w,{"data-state":b?.(p)?"selected":void 0,tabIndex:o?0:void 0,className:o?"cursor-pointer":void 0,onKeyDown:(R)=>{if(R.target===R.currentTarget&&(R.key==="Enter"||R.key===" "))R.preventDefault(),o?.(p)},onClick:(R)=>{if(R.target instanceof Element&&R.target.closest("[data-slot='row-actions']"))return;o?.(p)},children:[t.map((R)=>r(S,{children:F(p,R)},R.id)),A?P(S,{"data-slot":"row-actions",className:`flex gap-2 justify-end ${E}`,children:[s?.(p),_&&N?r(y,{type:"button",variant:"ghost",size:"icon","aria-label":C?"Collapse":"Expand","aria-expanded":C,disabled:c,onClick:()=>N(p,!C),children:C?r(O,{}):r($,{})}):null]}):null]},l(p));return P(te,{children:[u?P(K,{children:[r(V,{asChild:!0,children:W}),r(G,{children:u(p)})]}):W,_&&C?r(w,{className:"hover:bg-transparent",children:r(S,{colSpan:t.length+(A?1:0),children:H})}):null]},l(p))})})]})},ie=({ariaLabel:e="Resources",className:i,empty:t="No resources found",getItemKey:n,items:l,renderItem:o,renderContainer:s,style:m})=>s?s(l.length===0?t:l.map((a,c)=>r(te,{children:o(a,c)},n(a)))):r("ul",{"aria-label":e,className:D("ci-resource-list",i),style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"none",...m},children:l.length===0?r("li",{children:t}):l.map((a,c)=>r("li",{children:o(a,c)},n(a)))}),ae=({className:e,inputProps:i,label:t,onChange:n,style:l,value:o})=>r(f,{...i,"aria-label":t,className:D("ci-resource-filter",e),onChange:(s)=>{n(s.currentTarget.value)},style:l,type:"search",value:o}),ye=(e,i)=>{if(i<=7)return Array.from({length:i},(l,o)=>o+1);let t=Math.max(2,Math.min(e-1,i-3)),n=Math.min(i-1,Math.max(e+1,4));return[1,...t>2?[null]:[],...Array.from({length:n-t+1},(l,o)=>t+o),...n<i-1?[null]:[],i]},ne=({className:e,currentPage:i,hasNextPage:t,hasPreviousPage:n=!1,isPending:l=!1,navigationLabel:o="Resource pagination",nextLabel:s="Next",onNext:m,onPrevious:a,onPageChange:c,totalPages:b,ellipsisLabel:d="More pages",previousLabel:N="Previous",style:T})=>r(Y,{"aria-label":o,className:D("ci-resource-pagination",e),style:T,children:P(Z,{children:[r(h,{children:r(y,{variant:"ghost",disabled:!n||l,onClick:a,type:"button",children:N})}),i!==void 0&&b!==void 0&&c?ye(i,b).map((u,F)=>r(h,{children:u===null?r(q,{"aria-label":d}):r(y,{type:"button",size:"icon",variant:u===i?"outline":"ghost","aria-current":u===i?"page":void 0,disabled:l,onClick:()=>c(u),children:u})},u??`gap-${F}`)):null,i!==void 0&&(b===void 0||!c)?r(h,{children:P("span",{"aria-live":"polite",children:["Page ",i]})}):null,r(h,{children:r(y,{variant:"ghost",disabled:!t||l,onClick:m,type:"button",children:s})})]})}),le=({children:e,className:i,components:t,disabled:n=!1,onClick:l,pending:o=!1,style:s})=>{let m=t?.Button??y;return r(m,{"aria-busy":o,className:D("ci-resource-action",i),disabled:n||o,onClick:l,style:s,type:"button",children:e})},se=({children:e,className:i,components:t,open:n,onOpenChange:l,description:o,style:s,title:m})=>{let a=z(),c=z();if(!t?.Dialog)return r(J,{open:n,...l?{onOpenChange:l}:{},children:P(Q,{className:i,style:s,"aria-describedby":o?c:void 0,children:[r(U,{children:m}),o?r(X,{id:c,children:o}):null,e]})});if(!n)return null;let b=t.Dialog;return P(b,{open:n,"aria-labelledby":a,"aria-modal":"true",className:D("ci-resource-dialog",i),style:{...Pe,...s},children:[r("h2",{id:a,children:m}),e]})};import{useId as ge}from"react";import{jsx as g,jsxs as v}from"react/jsx-runtime";var be=(e)=>e===null||e===void 0?"":String(e),Ne=({field:e,id:i,value:t,disabled:n,errorId:l,onChange:o})=>{let s={"aria-describedby":l,"aria-invalid":l!==void 0,disabled:n,id:i,name:e.name,required:e.control!=="checkbox"&&e.required===!0&&t!==null};if(e.control==="select"){let m=e.options??[];return v("select",{...s,disabled:n||e.readOnly,className:"border-input bg-background h-9 w-full rounded-md border px-3 text-sm focus-visible:ring-ring focus-visible:ring-2",value:m.findIndex((a)=>a.value===t),onChange:(a)=>{let c=m[Number(a.currentTarget.value)];if(c)o(c.value)},children:[v("option",{value:-1,disabled:!0,children:["Select ",e.label]}),m.map((a,c)=>g("option",{value:c,children:a.label},c))]})}if(e.control==="checkbox")return g(f,{...s,className:"size-4",type:"checkbox",checked:t===!0,disabled:n||e.readOnly,onChange:(m)=>o(m.currentTarget.checked)});if(e.control==="custom")return v("p",{role:"alert",children:["A custom control is required for ",e.label,"."]});return g(f,{...s,readOnly:e.readOnly,type:e.control,value:be(t),onChange:(m)=>{let a=m.currentTarget;o(e.control==="number"&&a.value!==""?a.valueAsNumber:a.value)}})},ve=({field:e,value:i,error:t,disabled:n,onChange:l,renderControl:o})=>{let s=ge(),m=t?`${s}-error`:void 0,a={disabled:n,errorId:m,field:e,id:s,onChange:(c)=>{if(!n&&!e.readOnly)l(c)},value:i};return v("div",{className:"grid gap-2",children:[v(B,{htmlFor:s,children:[e.label,e.required?" *":""]}),e.control==="custom"&&o?o(a):g(Ne,{...a}),e.nullable?g(y,{"aria-label":`Clear ${e.label}`,type:"button",variant:"ghost",size:"sm",className:"justify-self-start",disabled:n||e.readOnly||i===null,onClick:()=>l(null),children:"Clear"}):null,t?g("p",{id:m,role:"alert",className:"text-destructive text-sm",children:t}):null]})},ce=({label:e,fields:i,values:t,errors:n,onChange:l,onSubmit:o,onCancel:s,renderControl:m,pending:a=!1,disabled:c=!1,submitLabel:b="Save",cancelLabel:d="Cancel",error:N,className:T})=>v("form",{"aria-label":e,"aria-busy":a,className:T??"grid gap-4",onSubmit:(u)=>{if(u.preventDefault(),!a&&!c)o()},children:[N?g("div",{role:"alert",className:"text-destructive text-sm",children:N}):null,i.map((u)=>g(ve,{field:u,value:t[u.name],error:n?.[u.name],disabled:c||a,onChange:(F)=>l(u.name,F),renderControl:m},u.name)),v("div",{"data-slot":"form-actions",className:"flex justify-end gap-2",children:[s?g(y,{type:"button",variant:"outline",disabled:a,onClick:s,children:d}):null,g(y,{type:"submit",disabled:c||a,children:b})]})]});import{jsx as k,jsxs as ue,Fragment as Te}from"react/jsx-runtime";var me=(e)=>k("div",{className:"contents",children:e.control},e.key),pe=({label:e="Filter by",layout:i="stacked",controls:t})=>{if(t.length===0)return null;let n=t.filter((o)=>!o.fullWidth),l=t.filter((o)=>o.fullWidth);return k("div",{className:"mb-4",children:i==="inline"?k("form",{className:"flex flex-wrap items-end gap-2",onSubmit:(o)=>o.preventDefault(),children:t.map(me)}):ue(Te,{children:[n.length>0?ue("form",{className:"flex flex-wrap gap-2 mb-2",onSubmit:(o)=>o.preventDefault(),children:[k(B,{className:"mt-3 mr-2",children:e}),n.map(me)]}):null,l.map((o)=>k("form",{className:"mb-2 last:mb-0",onSubmit:(s)=>s.preventDefault(),children:o.control},o.key))]})})};var{ResourceActionPrimitive:Ge,ResourceDialogPrimitive:Je,ResourceFilterPrimitive:Qe,ResourceFormPrimitive:Ue,ResourceFiltersBar:Xe,ResourceListPrimitive:Ye,ResourcePaginationPrimitive:Ze,ResourceTablePrimitive:qe}=L;export{qe as ResourceTablePrimitive,Ze as ResourcePaginationPrimitive,Ye as ResourceListPrimitive,Ue as ResourceFormPrimitive,Xe as ResourceFiltersBar,Qe as ResourceFilterPrimitive,Je as ResourceDialogPrimitive,Ge as ResourceActionPrimitive};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@collective-intelligence/ui-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Public React primitives, design-system components, icons, illustrations, and utilities for Collective Intelligence applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|