Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@interop-ui/react-accordion

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@interop-ui/react-accordion - npm Package Compare versions

Comparing version 0.0.1-17 to 0.2.0-rc.1

119

dist/index.d.ts

@@ -1,3 +0,59 @@

type AccordionItemOwnProps = {
import React from "react";
import * as Radix from "@interop-ui/react-primitive";
import { Primitive } from "@interop-ui/react-primitive";
import * as CollapsiblePrimitive from "@interop-ui/react-collapsible";
export interface AccordionSingleProps extends AccordionImplSingleProps {
type: 'single';
}
export interface AccordionMultipleProps extends AccordionImplMultipleProps {
type: 'multiple';
}
export const Accordion: React.ForwardRefExoticComponent<(AccordionSingleProps & React.RefAttributes<HTMLDivElement>) | (AccordionMultipleProps & React.RefAttributes<HTMLDivElement>)>;
interface AccordionImplSingleProps extends AccordionImplProps {
/**
* The controlled stateful value of the accordion item whose content is expanded.
*/
value?: string;
/**
* The value of the item whose content is expanded when the accordion is initially rendered. Use
* `defaultValue` if you do not need to control the state of an accordion.
*/
defaultValue?: string;
/**
* The callback that fires when the state of the accordion changes.
*/
onValueChange?(value: string): void;
/**
* Whether an accordion item can be collapsed after it has been opened.
* @default false
*/
collapsible?: boolean;
}
interface AccordionImplMultipleProps extends AccordionImplProps {
/**
* The controlled stateful value of the accordion items whose contents are expanded.
*/
value?: string[];
/**
* The value of the items whose contents are expanded when the accordion is initially rendered. Use
* `defaultValue` if you do not need to control the state of an accordion.
*/
defaultValue?: string[];
/**
* The callback that fires when the state of the accordion changes.
*/
onValueChange?(value: string[]): void;
}
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
interface AccordionImplProps extends PrimitiveDivProps {
/**
* Whether or not an accordion is disabled from user interaction.
*
* @defaultValue false
*/
disabled?: boolean;
}
type CollapsibleProps = Radix.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Root>;
export interface AccordionItemProps extends Omit<CollapsibleProps, 'open' | 'defaultOpen' | 'onOpenChange'> {
/**
* Whether or not an accordion item is disabled from user interaction.

@@ -12,10 +68,10 @@ *

value: string;
open: never;
defaultOpen: never;
onOpenChange: never;
};
}
/**
* `AccordionItem` contains all of the parts of a collapsible section inside of an `Accordion`.
*/
export const AccordionItem: import("@interop-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"div", import("@interop-ui/react-polymorphic").MergeProps<import("@interop-ui/react-collapsible").CollapsibleOwnProps, AccordionItemOwnProps>>;
export const AccordionItem: React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
type PrimitiveHeading3Props = Radix.ComponentPropsWithoutRef<typeof Primitive.h3>;
export interface AccordionHeaderProps extends PrimitiveHeading3Props {
}
/**

@@ -25,43 +81,24 @@ * `AccordionHeader` contains the content for the parts of an `AccordionItem` that will be visible

*/
export const AccordionHeader: import("@interop-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"h3", {}>;
export const AccordionHeader: React.ForwardRefExoticComponent<AccordionHeaderProps & React.RefAttributes<HTMLHeadingElement>>;
type CollapsibleTriggerProps = Radix.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Trigger>;
export interface AccordionTriggerProps extends CollapsibleTriggerProps {
}
/**
* `AccordionButton` is the trigger that toggles the collapsed state of an `AccordionItem`. It
* `AccordionTrigger` is the trigger that toggles the collapsed state of an `AccordionItem`. It
* should always be nested inside of an `AccordionHeader`.
*/
export const AccordionButton: import("@interop-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"button", Pick<{}, never>>;
export const AccordionTrigger: React.ForwardRefExoticComponent<AccordionTriggerProps & React.RefAttributes<HTMLButtonElement>>;
type CollapsibleContentProps = Radix.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Content>;
export interface AccordionContentProps extends CollapsibleContentProps {
}
/**
* `AccordionPanel` contains the collapsible content for an `AccordionItem`.
* `AccordionContent` contains the collapsible content for an `AccordionItem`.
*/
export const AccordionPanel: import("@interop-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"div", Pick<import("@interop-ui/react-collapsible").CollapsibleContentOwnProps, "forceMount">>;
type AccordionOwnProps = {
/**
* The controlled stateful value of the accordion item whose panel is expanded.
*/
value?: string;
/**
* The value of the item whose panel is expanded when the accordion is initially rendered. Use
* `defaultValue` if you do not need to control the state of an accordion.
*/
defaultValue?: string;
/**
* Whether or not an accordion is disabled from user interaction.
*
* @defaultValue false
*/
disabled?: boolean;
/**
* The callback that fires when the state of the accordion changes.
*/
onValueChange?(value: string): void;
};
/**
* `Accordion` is the root component.
*/
export const Accordion: import("@interop-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"div", AccordionOwnProps>;
export const Root: import("@interop-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"div", AccordionOwnProps>;
export const Item: import("@interop-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"div", import("@interop-ui/react-polymorphic").MergeProps<import("@interop-ui/react-collapsible").CollapsibleOwnProps, AccordionItemOwnProps>>;
export const Header: import("@interop-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"h3", {}>;
export const Button: import("@interop-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"button", Pick<{}, never>>;
export const Panel: import("@interop-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"div", Pick<import("@interop-ui/react-collapsible").CollapsibleContentOwnProps, "forceMount">>;
export const AccordionContent: React.ForwardRefExoticComponent<AccordionContentProps & React.RefAttributes<HTMLDivElement>>;
export const Root: React.ForwardRefExoticComponent<(AccordionSingleProps & React.RefAttributes<HTMLDivElement>) | (AccordionMultipleProps & React.RefAttributes<HTMLDivElement>)>;
export const Item: React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
export const Header: React.ForwardRefExoticComponent<AccordionHeaderProps & React.RefAttributes<HTMLHeadingElement>>;
export const Trigger: React.ForwardRefExoticComponent<AccordionTriggerProps & React.RefAttributes<HTMLButtonElement>>;
export const Content: React.ForwardRefExoticComponent<AccordionContentProps & React.RefAttributes<HTMLDivElement>>;
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

var e,r=require("@interop-ui/react-collapsible"),t=r.Collapsible,n=r.CollapsibleButton,o=r.CollapsibleContent,a=require("@interop-ui/react-polymorphic").forwardRefWithAs,i=require("@interop-ui/react-utils"),c=i.composeEventHandlers,u=i.createContext,l=i.useComposedRefs,d=i.useControlledState,s=i.useId,f=require("@interop-ui/utils").getPartDataAttrObj,p=(e=require("react"))&&e.__esModule?e.default:e;function v(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||A(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(){return(b=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function m(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function y(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(n=(i=c.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==c.return||c.return()}finally{if(o)throw a}}return t}(e,r)||A(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,r){if(e){if("string"==typeof e)return h(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?h(e,r):void 0}}function h(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var g=y(u("AccordionContext","Accordion"),2),w=g[0],O=g[1],x=y(u("AccordionItemContext","AccordionItem"),2),I=x[0],E=x[1],j=a((function(e,r){var n,o=e.value,a=e.children,i=m(e,["value","children"]),c=O("AccordionItem"),u="accordion-button-".concat(s()),l=e.id||u,d=o&&o===c.value||!1,v=null!==(n=c.disabled)&&void 0!==n?n:e.disabled,y=p.useMemo((function(){return{open:d,buttonId:l}}),[d,l]);return p.createElement(t,b({},i,f("AccordionItem"),{ref:r,"data-state":d?"open":"closed","data-disabled":v||void 0,disabled:v,open:d,onOpenChange:function(){return c.setValue(o)}}),p.createElement(I.Provider,{value:y},a))}));exports.AccordionItem=j,j.displayName="AccordionItem";var C=a((function(e,r){var t=e.as,n=void 0===t?"h3":t,o=m(e,["as"]);return p.createElement(n,b({ref:r},o,f("AccordionHeader")))}));exports.AccordionHeader=C,C.displayName="AccordionHeader";var S=a((function(e,r){var t=Object.assign({},e),o=O("AccordionButton").buttonNodesRef,a=E("AccordionButton"),i=p.useRef(null),c=l(i,r);return p.useEffect((function(){var e=o.current,r=i.current;if(r)return e.add(r),function(){e.delete(r)}}),[o]),p.createElement(n,b({},t,f("AccordionButton"),{ref:c,"aria-disabled":a.open||void 0,id:a.buttonId}))}));exports.AccordionButton=S,S.displayName="AccordionButton";var P=a((function(e,r){var t=E("AccordionPanel");return p.createElement(o,b({},e,f("AccordionPanel"),{ref:r,role:"region","aria-labelledby":t.buttonId}))}));exports.AccordionPanel=P,P.displayName="AccordionPanel";var B=["Home","End","ArrowDown","ArrowUp"],H=a((function(e,r){var t=e.as,n=void 0===t?"div":t,o=e.value,a=e.defaultValue,i=e.children,u=e.disabled,s=e.onValueChange,A=void 0===s?function(){}:s,h=m(e,["as","value","defaultValue","children","disabled","onValueChange"]),g=p.useRef(new Set),O=p.useRef(null),x=l(O,r),I=y(d({prop:o,defaultProp:a,onChange:function(e){return e&&A(e)}}),2),E=I[0],j=I[1],C=c(e.onKeyDown,(function(e){var r,t=e.target;if(B.includes(e.key)&&t instanceof HTMLButtonElement){var n=v(g.current).filter((function(e){return!(e&&e.disabled)})),o=n.length,a=n.indexOf(t);if(-1!==a){e.preventDefault();var i=a;switch(e.key){case"Home":i=0;break;case"End":i=o-1;break;case"ArrowDown":i=a+1;break;case"ArrowUp":(i=a-1)<0&&(i=o-1)}null===(r=n[i%o])||void 0===r||r.focus()}}})),S=p.useMemo((function(){return{disabled:u,buttonNodesRef:g,value:E,setValue:j}}),[u,E,j]);return p.createElement(n,b({},h,f("Accordion"),{ref:x,onKeyDown:u?void 0:C}),p.createElement(w.Provider,{value:S},i))}));exports.Accordion=H,H.displayName="Accordion";var R=H;exports.Root=R;var N=j;exports.Item=N;var k=C;exports.Header=k;var D=S;exports.Button=D;var V=P;exports.Panel=V;
var e,r,t=require("@interop-ui/react-id").useId,o=(e={},r=require("@interop-ui/react-collapsible"),Object.keys(r).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})),e),n=require("@interop-ui/react-primitive").Primitive,a=require("@interop-ui/react-use-controllable-state").useControllableState,c=require("@interop-ui/primitive").composeEventHandlers,i=require("@interop-ui/react-compose-refs").useComposedRefs,l=require("@interop-ui/react-context").createContext,s=u(require("react")),d=u(require("@babel/runtime/helpers/extends"));function u(e){return e&&e.__esModule?e.default:e}const f=["Home","End","ArrowDown","ArrowUp"],p=/*#__PURE__*/s.forwardRef(((e,r)=>{const{type:t,...o}=e;if("single"===t){const e=o;/*#__PURE__*/return s.createElement(v,d({},e,{ref:r}))}if("multiple"===t){const e=o;/*#__PURE__*/return s.createElement(E,d({},e,{ref:r}))}throw new Error("Missing prop `type` expected on `Accordion`")}));exports.Accordion=p;const[m,g]=l("Accordion"),b=/*#__PURE__*/s.createContext(!1),v=/*#__PURE__*/s.forwardRef(((e,r)=>{const{value:t,defaultValue:o,onValueChange:n=(()=>{}),collapsible:c=!1,...i}=e,[l,u]=a({prop:t,defaultProp:o,onChange:n});/*#__PURE__*/return s.createElement(m,{value:l?[l]:[],onItemOpen:u,onItemClose:s.useCallback((()=>c&&u("")),[c,u])},/*#__PURE__*/s.createElement(b.Provider,{value:c},/*#__PURE__*/s.createElement(x,d({},i,{ref:r}))))})),E=/*#__PURE__*/s.forwardRef(((e,r)=>{const{value:t,defaultValue:o,onValueChange:n=(()=>{}),...c}=e,[i=[],l]=a({prop:t,defaultProp:o,onChange:n}),u=s.useCallback((e=>l(((r=[])=>[...r,e]))),[l]),f=s.useCallback((e=>l(((r=[])=>r.filter((r=>r!==e))))),[l]);/*#__PURE__*/return s.createElement(m,{value:i,onItemOpen:u,onItemClose:f},/*#__PURE__*/s.createElement(b.Provider,{value:!0},/*#__PURE__*/s.createElement(x,d({},c,{ref:r}))))})),[w,C]=l("Accordion"),x=/*#__PURE__*/s.forwardRef(((e,r)=>{const{disabled:t,...o}=e,a=s.useRef(new Set),l=s.useRef(null),u=i(l,r),p=c(e.onKeyDown,(e=>{var r;const t=e.target;if(!(f.includes(e.key)&&(o=t,o instanceof HTMLButtonElement)))return;var o;const n=[...a.current].filter((e=>!(null!=e&&e.disabled))),c=n.length,i=n.indexOf(t);if(-1===i)return;e.preventDefault();let l=i;switch(e.key){case"Home":l=0;break;case"End":l=c-1;break;case"ArrowDown":l=i+1;break;case"ArrowUp":l=i-1,l<0&&(l=c-1)}null===(r=n[l%c])||void 0===r||r.focus()}));/*#__PURE__*/return s.createElement(w,{triggerNodesRef:a,disabled:t},/*#__PURE__*/s.createElement(n.div,d({},o,{ref:u,onKeyDown:t?void 0:p})))})),[A,R]=l("AccordionItem"),h=/*#__PURE__*/s.forwardRef(((e,r)=>{const{value:n,...a}=e,c=C("AccordionItem"),i=g("AccordionItem"),l=t(),u=n&&i.value.includes(n)||!1,f=c.disabled||e.disabled;/*#__PURE__*/return s.createElement(A,{open:u,disabled:f,triggerId:l},/*#__PURE__*/s.createElement(o.Root,d({"data-state":u?"open":"closed"},a,{ref:r,disabled:f,open:u,onOpenChange:e=>{e?i.onItemOpen(n):i.onItemClose(n)}})))}));exports.AccordionItem=h;const I=/*#__PURE__*/s.forwardRef(((e,r)=>{const t=R("AccordionHeader");/*#__PURE__*/return s.createElement(n.h3,d({"data-state":(o=t.open,o?"open":"closed"),"data-disabled":t.disabled?"":void 0},e,{ref:r}));var o}));exports.AccordionHeader=I;const y=/*#__PURE__*/s.forwardRef(((e,r)=>{const{triggerNodesRef:t}=C("AccordionTrigger"),n=R("AccordionTrigger"),a=s.useContext(b),c=s.useRef(null),l=i(c,r);return s.useEffect((()=>{const e=t.current,r=c.current;if(r)return e.add(r),()=>{e.delete(r)}}),[t]),/*#__PURE__*/s.createElement(o.Trigger,d({"aria-disabled":n.open&&!a||void 0,id:n.triggerId},e,{ref:l}))}));exports.AccordionTrigger=y;const k=/*#__PURE__*/s.forwardRef(((e,r)=>{const t=R("AccordionContent");/*#__PURE__*/return s.createElement(o.Content,d({role:"region","aria-labelledby":t.triggerId},e,{style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)",...e.style},ref:r}))}));exports.AccordionContent=k;const q=p;exports.Root=q;const H=h;exports.Item=H;const O=I;exports.Header=O;const P=y;exports.Trigger=P;const T=k;exports.Content=T;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{Collapsible as e,CollapsibleButton as o,CollapsibleContent as t}from"@interop-ui/react-collapsible";import{forwardRefWithAs as n}from"@interop-ui/react-polymorphic";import{composeEventHandlers as r,createContext as c,useComposedRefs as a,useControlledState as i,useId as d}from"@interop-ui/react-utils";import{getPartDataAttrObj as l}from"@interop-ui/utils";import u from"react";function s(){return(s=Object.assign||function(e){for(var o=1;o<arguments.length;o++){var t=arguments[o];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function p(e,o){if(null==e)return{};var t,n,r=function(e,o){if(null==e)return{};var t,n,r={},c=Object.keys(e);for(n=0;n<c.length;n++)t=c[n],o.indexOf(t)>=0||(r[t]=e[t]);return r}(e,o);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)t=c[n],o.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}const[f,m]=c("AccordionContext","Accordion"),[A,b]=c("AccordionItemContext","AccordionItem");export const AccordionItem=n(((o,t)=>{var n;const{value:r,children:c}=o,a=p(o,["value","children"]),i=m("AccordionItem"),f="accordion-button-".concat(d()),b=o.id||f,v=r&&r===i.value||!1,y=null!==(n=i.disabled)&&void 0!==n?n:o.disabled,h=u.useMemo((()=>({open:v,buttonId:b})),[v,b]);return u.createElement(e,s({},a,l("AccordionItem"),{ref:t,"data-state":v?"open":"closed","data-disabled":y||void 0,disabled:y,open:v,onOpenChange:()=>i.setValue(r)}),u.createElement(A.Provider,{value:h},c))}));AccordionItem.displayName="AccordionItem";const v="h3";export const AccordionHeader=n(((e,o)=>{const{as:t=v}=e,n=p(e,["as"]);return u.createElement(t,s({ref:o},n,l("AccordionHeader")))}));AccordionHeader.displayName="AccordionHeader";export const AccordionButton=n(((e,t)=>{const n=Object.assign({},e),{buttonNodesRef:r}=m("AccordionButton"),c=b("AccordionButton"),i=u.useRef(null),d=a(i,t);return u.useEffect((()=>{const e=r.current,o=i.current;if(o)return e.add(o),()=>{e.delete(o)}}),[r]),u.createElement(o,s({},n,l("AccordionButton"),{ref:d,"aria-disabled":c.open||void 0,id:c.buttonId}))}));AccordionButton.displayName="AccordionButton";export const AccordionPanel=n(((e,o)=>{const n=b("AccordionPanel");return u.createElement(t,s({},e,l("AccordionPanel"),{ref:o,role:"region","aria-labelledby":n.buttonId}))}));AccordionPanel.displayName="AccordionPanel";const y="div",h=["Home","End","ArrowDown","ArrowUp"];export const Accordion=n(((e,o)=>{const{as:t=y,value:n,defaultValue:c,children:d,disabled:m,onValueChange:A=(()=>{})}=e,b=p(e,["as","value","defaultValue","children","disabled","onValueChange"]),v=u.useRef(new Set),x=u.useRef(null),g=a(x,o),[O,w]=i({prop:n,defaultProp:c,onChange:e=>e&&A(e)}),I=r(e.onKeyDown,(e=>{var o;const t=e.target;if(!(h.includes(e.key)&&(n=t,n instanceof HTMLButtonElement)))return;var n;const r=[...v.current].filter((e=>!(e&&e.disabled))),c=r.length,a=r.indexOf(t);if(-1===a)return;e.preventDefault();let i=a;switch(e.key){case"Home":i=0;break;case"End":i=c-1;break;case"ArrowDown":i=a+1;break;case"ArrowUp":i=a-1,i<0&&(i=c-1)}null===(o=r[i%c])||void 0===o||o.focus()})),P=u.useMemo((()=>({disabled:m,buttonNodesRef:v,value:O,setValue:w})),[m,O,w]);return u.createElement(t,s({},b,l("Accordion"),{ref:g,onKeyDown:m?void 0:I}),u.createElement(f.Provider,{value:P},d))}));Accordion.displayName="Accordion";export const Root=Accordion;export const Item=AccordionItem;export const Header=AccordionHeader;export const Button=AccordionButton;export const Panel=AccordionPanel;
import{useId as e}from"@interop-ui/react-id";import*as r from"@interop-ui/react-collapsible";import{Primitive as o}from"@interop-ui/react-primitive";import{useControllableState as t}from"@interop-ui/react-use-controllable-state";import{composeEventHandlers as n}from"@interop-ui/primitive";import{useComposedRefs as c}from"@interop-ui/react-compose-refs";import{createContext as a}from"@interop-ui/react-context";import i from"react";import l from"@babel/runtime/helpers/esm/extends";const d=["Home","End","ArrowDown","ArrowUp"];export const Accordion=/*#__PURE__*/i.forwardRef(((e,r)=>{const{type:o,...t}=e;if("single"===o){const e=t;/*#__PURE__*/return i.createElement(f,l({},e,{ref:r}))}if("multiple"===o){const e=t;/*#__PURE__*/return i.createElement(m,l({},e,{ref:r}))}throw new Error("Missing prop `type` expected on `Accordion`")}));/*#__PURE__*/const[s,p]=a("Accordion"),u=/*#__PURE__*/i.createContext(!1),f=/*#__PURE__*/i.forwardRef(((e,r)=>{const{value:o,defaultValue:n,onValueChange:c=(()=>{}),collapsible:a=!1,...d}=e,[p,f]=t({prop:o,defaultProp:n,onChange:c});/*#__PURE__*/return i.createElement(s,{value:p?[p]:[],onItemOpen:f,onItemClose:i.useCallback((()=>a&&f("")),[a,f])},/*#__PURE__*/i.createElement(u.Provider,{value:a},/*#__PURE__*/i.createElement(A,l({},d,{ref:r}))))})),m=/*#__PURE__*/i.forwardRef(((e,r)=>{const{value:o,defaultValue:n,onValueChange:c=(()=>{}),...a}=e,[d=[],p]=t({prop:o,defaultProp:n,onChange:c}),f=i.useCallback((e=>p(((r=[])=>[...r,e]))),[p]),m=i.useCallback((e=>p(((r=[])=>r.filter((r=>r!==e))))),[p]);/*#__PURE__*/return i.createElement(s,{value:d,onItemOpen:f,onItemClose:m},/*#__PURE__*/i.createElement(u.Provider,{value:!0},/*#__PURE__*/i.createElement(A,l({},a,{ref:r}))))})),[g,b]=a("Accordion"),A=/*#__PURE__*/i.forwardRef(((e,r)=>{const{disabled:t,...a}=e,s=i.useRef(new Set),p=i.useRef(null),u=c(p,r),f=n(e.onKeyDown,(e=>{var r;const o=e.target;if(!(d.includes(e.key)&&(t=o,t instanceof HTMLButtonElement)))return;var t;const n=[...s.current].filter((e=>!(null!=e&&e.disabled))),c=n.length,a=n.indexOf(o);if(-1===a)return;e.preventDefault();let i=a;switch(e.key){case"Home":i=0;break;case"End":i=c-1;break;case"ArrowDown":i=a+1;break;case"ArrowUp":i=a-1,i<0&&(i=c-1)}null===(r=n[i%c])||void 0===r||r.focus()}));/*#__PURE__*/return i.createElement(g,{triggerNodesRef:s,disabled:t},/*#__PURE__*/i.createElement(o.div,l({},a,{ref:u,onKeyDown:t?void 0:f})))})),[v,w]=a("AccordionItem");export const AccordionItem=/*#__PURE__*/i.forwardRef(((o,t)=>{const{value:n,...c}=o,a=b("AccordionItem"),d=p("AccordionItem"),s=e(),u=n&&d.value.includes(n)||!1,f=a.disabled||o.disabled;/*#__PURE__*/return i.createElement(v,{open:u,disabled:f,triggerId:s},/*#__PURE__*/i.createElement(r.Root,l({"data-state":u?"open":"closed"},c,{ref:t,disabled:f,open:u,onOpenChange:e=>{e?d.onItemOpen(n):d.onItemClose(n)}})))}));/*#__PURE__*/export const AccordionHeader=/*#__PURE__*/i.forwardRef(((e,r)=>{const t=w("AccordionHeader");/*#__PURE__*/return i.createElement(o.h3,l({"data-state":(n=t.open,n?"open":"closed"),"data-disabled":t.disabled?"":void 0},e,{ref:r}));var n}));/*#__PURE__*/export const AccordionTrigger=/*#__PURE__*/i.forwardRef(((e,o)=>{const{triggerNodesRef:t}=b("AccordionTrigger"),n=w("AccordionTrigger"),a=i.useContext(u),d=i.useRef(null),s=c(d,o);return i.useEffect((()=>{const e=t.current,r=d.current;if(r)return e.add(r),()=>{e.delete(r)}}),[t]),/*#__PURE__*/i.createElement(r.Trigger,l({"aria-disabled":n.open&&!a||void 0,id:n.triggerId},e,{ref:s}))}));/*#__PURE__*/export const AccordionContent=/*#__PURE__*/i.forwardRef(((e,o)=>{const t=w("AccordionContent");/*#__PURE__*/return i.createElement(r.Content,l({role:"region","aria-labelledby":t.triggerId},e,{style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)",...e.style},ref:o}))}));/*#__PURE__*/export const Root=Accordion;export const Item=AccordionItem;export const Header=AccordionHeader;export const Trigger=AccordionTrigger;export const Content=AccordionContent;
//# sourceMappingURL=index.module.js.map
{
"name": "@interop-ui/react-accordion",
"version": "0.0.1-17",
"version": "0.2.0-rc.1",
"license": "MIT",

@@ -15,19 +15,27 @@ "source": "src/index.ts",

"scripts": {
"build": "parcel build src/index.ts --no-cache",
"clean": "rm -rf dist",
"version": "yarn version",
"prepublish": "yarn clean && yarn build"
"version": "yarn version"
},
"dependencies": {
"@interop-ui/react-collapsible": "0.0.1-16",
"@interop-ui/react-polymorphic": "0.0.1-3",
"@interop-ui/react-utils": "0.0.1-16",
"@interop-ui/utils": "0.0.1-8"
"@babel/runtime": "^7.13.10",
"@interop-ui/primitive": "0.2.0-rc.1",
"@interop-ui/react-collapsible": "0.2.0-rc.1",
"@interop-ui/react-compose-refs": "0.2.0-rc.1",
"@interop-ui/react-context": "0.2.0-rc.1",
"@interop-ui/react-id": "0.2.0-rc.1",
"@interop-ui/react-primitive": "0.2.0-rc.1",
"@interop-ui/react-use-controllable-state": "0.2.0-rc.1"
},
"devDependencies": {
"parcel": "^2.0.0-beta.1"
},
"peerDependencies": {
"react": "^16.8 || ^17.0"
}
},
"homepage": "https://radix-ui.com/primitives",
"repository": {
"type": "git",
"url": "git+https://github.com/radix-ui/primitives.git"
},
"bugs": {
"url": "https://github.com/radix-ui/primitives/issues"
},
"stableVersion": "0.1.0"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc