@radix-ui/react-accordion
Advanced tools
Comparing version 0.0.5 to 0.0.6
import { Primitive } from "@radix-ui/react-primitive"; | ||
import { Collapsible, CollapsibleButton, CollapsibleContent } from "@radix-ui/react-collapsible"; | ||
import * as Polymorphic from "@radix-ui/react-polymorphic"; | ||
import { Merge } from "@radix-ui/utils"; | ||
type AccordionItemOwnProps = Merge<Omit<Polymorphic.OwnProps<typeof Collapsible>, 'open' | 'defaultOpen' | 'onOpenChange'>, { | ||
type AccordionOwnProps = Polymorphic.OwnProps<typeof AccordionSingle> | Polymorphic.OwnProps<typeof AccordionMultiple>; | ||
type AccordionPrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof AccordionSingle> | Polymorphic.IntrinsicElement<typeof AccordionMultiple>, AccordionOwnProps>; | ||
export const Accordion: AccordionPrimitive; | ||
type AccordionSingleOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof AccordionImpl>, { | ||
/** | ||
* Allow only one item to be open at a time. | ||
*/ | ||
type: 'single'; | ||
/** | ||
* 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; | ||
/** | ||
* The callback that fires when the state of the accordion changes. | ||
*/ | ||
onValueChange?(value: string): void; | ||
}>; | ||
type AccordionSinglePrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof AccordionImpl>, AccordionSingleOwnProps>; | ||
declare const AccordionSingle: AccordionSinglePrimitive; | ||
type AccordionMultipleOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof AccordionImpl>, { | ||
/** | ||
* Allow mutltiple items to be open at the same time. | ||
*/ | ||
type: 'multiple'; | ||
/** | ||
* The controlled stateful value of the accordion items whose panels are expanded. | ||
*/ | ||
value?: string[]; | ||
/** | ||
* The value of the items whose panels 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 AccordionMultiplePrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof AccordionImpl>, AccordionMultipleOwnProps>; | ||
declare const AccordionMultiple: AccordionMultiplePrimitive; | ||
type AccordionImplOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof Primitive>, { | ||
/** | ||
* Whether or not an accordion is disabled from user interaction. | ||
* | ||
* @defaultValue false | ||
*/ | ||
disabled?: boolean; | ||
}>; | ||
type AccordionImplPrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof Primitive>, AccordionImplOwnProps>; | ||
declare const AccordionImpl: AccordionImplPrimitive; | ||
type AccordionItemOwnProps = Polymorphic.Merge<Omit<Polymorphic.OwnProps<typeof Collapsible>, 'open' | 'defaultOpen' | 'onOpenChange'>, { | ||
/** | ||
* Whether or not an accordion item is disabled from user interaction. | ||
@@ -43,28 +97,2 @@ * | ||
export const AccordionPanel: AccordionPanelPrimitive; | ||
type AccordionOwnProps = Merge<Polymorphic.OwnProps<typeof Primitive>, { | ||
/** | ||
* 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; | ||
}>; | ||
type AccordionPrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof Primitive>, AccordionOwnProps>; | ||
/** | ||
* `Accordion` is the root component. | ||
*/ | ||
export const Accordion: AccordionPrimitive; | ||
export const Root: AccordionPrimitive; | ||
@@ -71,0 +99,0 @@ export const Item: AccordionItemPrimitive; |
@@ -1,2 +0,2 @@ | ||
var e,r=require("@radix-ui/react-collapsible"),t=r.Collapsible,o=r.CollapsibleButton,n=r.CollapsibleContent,a=require("@radix-ui/react-primitive").Primitive,i=require("@radix-ui/react-utils"),l=i.composeEventHandlers,c=i.createContext,u=i.useComposedRefs,d=i.useControlledState,s=i.useId,f=require("@radix-ui/utils").getSelector,v=(e=require("react"))&&e.__esModule?e.default:e;function p(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 o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}function m(e,r){if(null==e)return{};var t,o,n=function(e,r){if(null==e)return{};var t,o,n={},a=Object.keys(e);for(o=0;o<a.length;o++)t=a[o],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)t=a[o],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}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=[],o=!0,n=!1,a=void 0;try{for(var i,l=e[Symbol.iterator]();!(o=(i=l.next()).done)&&(t.push(i.value),!r||t.length!==r);o=!0);}catch(e){n=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(n)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,o=new Array(r);t<r;t++)o[t]=e[t];return o}var w=y(c("AccordionContext","Accordion"),2),x=w[0],g=w[1],I=y(c("AccordionItemContext","AccordionItem"),2),O=I[0],E=I[1],C=v.forwardRef((function(e,r){var o=e.selector,n=void 0===o?f("AccordionItem"):o,a=e.value,i=m(e,["selector","value"]),l=g("AccordionItem"),c="accordion-button-".concat(s()),u=e.id||c,d=a&&a===l.value||!1,p=l.disabled||e.disabled,y=v.useMemo((function(){return{open:d,disabled:p,buttonId:u}}),[d,p,u]);return v.createElement(O.Provider,{value:y},v.createElement(t,b({},i,{selector:n,ref:r,"data-state":d?"open":"closed",disabled:p,open:d,onOpenChange:function(){return l.setValue(a)}})))}));exports.AccordionItem=C,C.displayName="AccordionItem";var S=v.forwardRef((function(e,r){var t,o=e.as,n=void 0===o?"h3":o,i=e.selector,l=void 0===i?f("AccordionHeader"):i,c=m(e,["as","selector"]),u=E(j);return v.createElement(a,b({"data-state":(t=u.open,t?"open":"closed"),"data-disabled":u.disabled?"":void 0},c,{as:n,selector:l,ref:r}))}));exports.AccordionHeader=S,S.displayName="AccordionHeader";var j="AccordionButton",P=v.forwardRef((function(e,r){var t=e.selector,n=void 0===t?f(j):t,a=m(e,["selector"]),i=g(j).buttonNodesRef,l=E(j),c=v.useRef(null),d=u(c,r);return v.useEffect((function(){var e=i.current,r=c.current;if(r)return e.add(r),function(){e.delete(r)}}),[i]),v.createElement(o,b({},a,{selector:n,ref:d,"aria-disabled":l.open||void 0,id:l.buttonId}))}));exports.AccordionButton=P,P.displayName=j;var R=v.forwardRef((function(e,r){var t=e.selector,o=void 0===t?f("AccordionPanel"):t,a=m(e,["selector"]),i=E("AccordionPanel");return v.createElement(n,b({},a,{selector:o,ref:r,role:"region","aria-labelledby":i.buttonId}))}));exports.AccordionPanel=R,R.displayName="AccordionPanel";var H=["Home","End","ArrowDown","ArrowUp"],N=v.forwardRef((function(e,r){var t=e.selector,o=void 0===t?f("Accordion"):t,n=e.value,i=e.defaultValue,c=e.disabled,s=e.onValueChange,A=void 0===s?function(){}:s,h=m(e,["selector","value","defaultValue","disabled","onValueChange"]),w=v.useRef(new Set),g=v.useRef(null),I=u(g,r),O=y(d({prop:n,defaultProp:i,onChange:function(e){return e&&A(e)}}),2),E=O[0],C=O[1],S=l(e.onKeyDown,(function(e){var r,t=e.target;if(H.includes(e.key)&&t instanceof HTMLButtonElement){var o=p(w.current).filter((function(e){return!(e&&e.disabled)})),n=o.length,a=o.indexOf(t);if(-1!==a){e.preventDefault();var i=a;switch(e.key){case"Home":i=0;break;case"End":i=n-1;break;case"ArrowDown":i=a+1;break;case"ArrowUp":(i=a-1)<0&&(i=n-1)}null===(r=o[i%n])||void 0===r||r.focus()}}})),j=v.useMemo((function(){return{disabled:c,buttonNodesRef:w,value:E,setValue:C}}),[c,E,C]);return v.createElement(x.Provider,{value:j},v.createElement(a,b({},h,{selector:o,ref:I,onKeyDown:c?void 0:S})))}));exports.Accordion=N,N.displayName="Accordion";var k=N;exports.Root=k;var V=C;exports.Item=V;var q=S;exports.Header=q;var B=P;exports.Button=B;var D=R;exports.Panel=D; | ||
var e,r=require("@radix-ui/react-id").useId,t=require("@radix-ui/react-collapsible"),n=t.Collapsible,o=t.CollapsibleButton,a=t.CollapsibleContent,i=require("@radix-ui/react-primitive").Primitive,u=require("@radix-ui/react-use-controllable-state").useControllableState,l=require("@radix-ui/primitive").composeEventHandlers,c=require("@radix-ui/react-compose-refs").useComposedRefs,d=require("@radix-ui/react-context").createContext,f=(e=require("react"))&&e.__esModule?e.default:e;function s(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||m(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 p(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 v(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,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return t}(e,r)||m(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 m(e,r){if(e){if("string"==typeof e)return b(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)?b(e,r):void 0}}function b(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}function y(){return(y=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)}var h=["Home","End","ArrowDown","ArrowUp"],A=f.forwardRef((function(e,r){if("single"===e.type)return f.createElement(E,y({},e,{ref:r}));if("multiple"===e.type)return f.createElement(I,y({},e,{ref:r}));throw new Error("Missing prop `type` expected on `".concat("Accordion","`"))}));exports.Accordion=A,A.displayName="Accordion";var w=v(d("Accordion"),2),g=w[0],x=w[1],E=f.forwardRef((function(e,r){var t=e.value,n=e.defaultValue,o=e.onValueChange,a=void 0===o?function(){}:o,i=p(e,["value","defaultValue","onValueChange"]),l=v(u({prop:t,defaultProp:n,onChange:a}),2),c=l[0],d=l[1];return f.createElement(g,{value:c?[c]:[],onItemOpen:d,onItemClose:function(){return d(void 0)}},f.createElement(S,y({},i,{ref:r})))})),I=f.forwardRef((function(e,r){var t=e.value,n=e.defaultValue,o=e.onValueChange,a=void 0===o?function(){}:o,i=p(e,["value","defaultValue","onValueChange"]),l=v(u({prop:t,defaultProp:n,onChange:a}),2),c=l[0],d=void 0===c?[]:c,m=l[1],b=f.useCallback((function(e){return m((function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return[].concat(s(r),[e])}))}),[m]),h=f.useCallback((function(e){return m((function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return r.filter((function(r){return r!==e}))}))}),[m]);return f.createElement(g,{value:d,onItemOpen:b,onItemClose:h},f.createElement(S,y({},i,{ref:r})))})),C=v(d("Accordion"),2),O=C[0],R=C[1],S=f.forwardRef((function(e,r){var t=e.disabled,n=p(e,["disabled"]),o=f.useRef(new Set),a=f.useRef(null),u=c(a,r),d=l(e.onKeyDown,(function(e){var r,t=e.target;if(h.includes(e.key)&&t instanceof HTMLButtonElement){var n=s(o.current).filter((function(e){return!(null!=e&&e.disabled)})),a=n.length,i=n.indexOf(t);if(-1!==i){e.preventDefault();var u=i;switch(e.key){case"Home":u=0;break;case"End":u=a-1;break;case"ArrowDown":u=i+1;break;case"ArrowUp":(u=i-1)<0&&(u=a-1)}null===(r=n[u%a])||void 0===r||r.focus()}}}));return f.createElement(O,{disabled:t,buttonNodesRef:o},f.createElement(i,y({},n,{ref:u,onKeyDown:t?void 0:d})))})),j=v(d("AccordionItem"),2),P=j[0],k=j[1],q=f.forwardRef((function(e,t){var o=e.value,a=p(e,["value"]),i=R("AccordionItem"),u=x("AccordionItem"),l=r(),c=o&&u.value.includes(o)||!1,d=i.disabled||e.disabled;return f.createElement(P,{open:c,disabled:d,buttonId:l},f.createElement(n,y({"data-state":c?"open":"closed",disabled:d},a,{ref:t,open:c,onOpenChange:function(e){e?u.onItemOpen(o):u.onItemClose(o)}})))}));exports.AccordionItem=q,q.displayName="AccordionItem";var V=f.forwardRef((function(e,r){var t,n=e.as,o=void 0===n?"h3":n,a=p(e,["as"]),u=k(H);return f.createElement(i,y({"data-state":(t=u.open,t?"open":"closed"),"data-disabled":u.disabled?"":void 0},a,{as:o,ref:r}))}));exports.AccordionHeader=V,V.displayName="AccordionHeader";var H="AccordionButton",N=f.forwardRef((function(e,r){var t=R(H).buttonNodesRef,n=k(H),a=f.useRef(null),i=c(a,r);return f.useEffect((function(){var e=t.current,r=a.current;if(r)return e.add(r),function(){e.delete(r)}}),[t]),f.createElement(o,y({"aria-disabled":n.open||void 0,id:n.buttonId},e,{ref:i}))}));exports.AccordionButton=N,N.displayName=H;var B=f.forwardRef((function(e,r){var t=k("AccordionPanel");return f.createElement(a,y({role:"region","aria-labelledby":t.buttonId},e,{ref:r}))}));exports.AccordionPanel=B,B.displayName="AccordionPanel";var D=A;exports.Root=D;var M=q;exports.Item=M;var T=V;exports.Header=T;var U=N;exports.Button=U;var K=B;exports.Panel=K; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{Collapsible as e,CollapsibleButton as o,CollapsibleContent as r}from"@radix-ui/react-collapsible";import{Primitive as t}from"@radix-ui/react-primitive";import{composeEventHandlers as n,createContext as c,useComposedRefs as a,useControlledState as l,useId as d}from"@radix-ui/react-utils";import{getSelector as i}from"@radix-ui/utils";import s from"react";function u(){return(u=Object.assign||function(e){for(var o=1;o<arguments.length;o++){var r=arguments[o];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}function f(e,o){if(null==e)return{};var r,t,n=function(e,o){if(null==e)return{};var r,t,n={},c=Object.keys(e);for(t=0;t<c.length;t++)r=c[t],o.indexOf(r)>=0||(n[r]=e[r]);return n}(e,o);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(t=0;t<c.length;t++)r=c[t],o.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const[p,m]=c("AccordionContext","Accordion"),b="AccordionItem",[A,v]=c("AccordionItemContext",b);export const AccordionItem=s.forwardRef(((o,r)=>{const{selector:t=i(b),value:n}=o,c=f(o,["selector","value"]),a=m(b),l="accordion-button-".concat(d()),p=o.id||l,v=n&&n===a.value||!1,y=a.disabled||o.disabled,x=s.useMemo((()=>({open:v,disabled:y,buttonId:p})),[v,y,p]);return s.createElement(A.Provider,{value:x},s.createElement(e,u({},c,{selector:t,ref:r,"data-state":v?"open":"closed",disabled:y,open:v,onOpenChange:()=>a.setValue(n)})))}));AccordionItem.displayName=b;const y="AccordionHeader",x="h3";export const AccordionHeader=s.forwardRef(((e,o)=>{const{as:r=x,selector:n=i(y)}=e,c=f(e,["as","selector"]),a=v(w);return s.createElement(t,u({"data-state":(l=a.open,l?"open":"closed"),"data-disabled":a.disabled?"":void 0},c,{as:r,selector:n,ref:o}));var l}));AccordionHeader.displayName=y;const w="AccordionButton";export const AccordionButton=s.forwardRef(((e,r)=>{const{selector:t=i(w)}=e,n=f(e,["selector"]),{buttonNodesRef:c}=m(w),l=v(w),d=s.useRef(null),p=a(d,r);return s.useEffect((()=>{const e=c.current,o=d.current;if(o)return e.add(o),()=>{e.delete(o)}}),[c]),s.createElement(o,u({},n,{selector:t,ref:p,"aria-disabled":l.open||void 0,id:l.buttonId}))}));AccordionButton.displayName=w;const g="AccordionPanel";export const AccordionPanel=s.forwardRef(((e,o)=>{const{selector:t=i(g)}=e,n=f(e,["selector"]),c=v(g);return s.createElement(r,u({},n,{selector:t,ref:o,role:"region","aria-labelledby":c.buttonId}))}));AccordionPanel.displayName=g;const O="Accordion",h=["Home","End","ArrowDown","ArrowUp"];export const Accordion=s.forwardRef(((e,o)=>{const{selector:r=i(O),value:c,defaultValue:d,disabled:m,onValueChange:b=(()=>{})}=e,A=f(e,["selector","value","defaultValue","disabled","onValueChange"]),v=s.useRef(new Set),y=s.useRef(null),x=a(y,o),[w,g]=l({prop:c,defaultProp:d,onChange:e=>e&&b(e)}),E=n(e.onKeyDown,(e=>{var o;const r=e.target;if(!(h.includes(e.key)&&(t=r,t instanceof HTMLButtonElement)))return;var t;const n=[...v.current].filter((e=>!(e&&e.disabled))),c=n.length,a=n.indexOf(r);if(-1===a)return;e.preventDefault();let l=a;switch(e.key){case"Home":l=0;break;case"End":l=c-1;break;case"ArrowDown":l=a+1;break;case"ArrowUp":l=a-1,l<0&&(l=c-1)}null===(o=n[l%c])||void 0===o||o.focus()})),P=s.useMemo((()=>({disabled:m,buttonNodesRef:v,value:w,setValue:g})),[m,w,g]);return s.createElement(p.Provider,{value:P},s.createElement(t,u({},A,{selector:r,ref:x,onKeyDown:m?void 0:E})))}));Accordion.displayName=O;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"@radix-ui/react-id";import{Collapsible as o,CollapsibleButton as r,CollapsibleContent as t}from"@radix-ui/react-collapsible";import{Primitive as n}from"@radix-ui/react-primitive";import{useControllableState as a}from"@radix-ui/react-use-controllable-state";import{composeEventHandlers as c}from"@radix-ui/primitive";import{useComposedRefs as d}from"@radix-ui/react-compose-refs";import{createContext as i}from"@radix-ui/react-context";import l from"react";function s(){return(s=Object.assign||function(e){for(var o=1;o<arguments.length;o++){var r=arguments[o];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}const u=["Home","End","ArrowDown","ArrowUp"];export const Accordion=l.forwardRef(((e,o)=>{if("single"===e.type)return l.createElement(m,s({},e,{ref:o}));if("multiple"===e.type)return l.createElement(A,s({},e,{ref:o}));throw new Error("Missing prop `type` expected on `".concat("Accordion","`"))}));Accordion.displayName="Accordion";const[f,p]=i("Accordion"),m=l.forwardRef(((e,o)=>{const{value:r,defaultValue:t,onValueChange:n=(()=>{}),...c}=e,[d,i]=a({prop:r,defaultProp:t,onChange:n});return l.createElement(f,{value:d?[d]:[],onItemOpen:i,onItemClose:()=>i(void 0)},l.createElement(v,s({},c,{ref:o})))})),A=l.forwardRef(((e,o)=>{const{value:r,defaultValue:t,onValueChange:n=(()=>{}),...c}=e,[d=[],i]=a({prop:r,defaultProp:t,onChange:n}),u=l.useCallback((e=>i(((o=[])=>[...o,e]))),[i]),p=l.useCallback((e=>i(((o=[])=>o.filter((o=>o!==e))))),[i]);return l.createElement(f,{value:d,onItemOpen:u,onItemClose:p},l.createElement(v,s({},c,{ref:o})))})),[b,w]=i("Accordion"),v=l.forwardRef(((e,o)=>{const{disabled:r,...t}=e,a=l.useRef(new Set),i=l.useRef(null),f=d(i,o),p=c(e.onKeyDown,(e=>{var o;const r=e.target;if(!(u.includes(e.key)&&(t=r,t instanceof HTMLButtonElement)))return;var t;const n=[...a.current].filter((e=>!(null!=e&&e.disabled))),c=n.length,d=n.indexOf(r);if(-1===d)return;e.preventDefault();let i=d;switch(e.key){case"Home":i=0;break;case"End":i=c-1;break;case"ArrowDown":i=d+1;break;case"ArrowUp":i=d-1,i<0&&(i=c-1)}null===(o=n[i%c])||void 0===o||o.focus()}));return l.createElement(b,{disabled:r,buttonNodesRef:a},l.createElement(n,s({},t,{ref:f,onKeyDown:r?void 0:p})))})),[x,E]=i("AccordionItem");export const AccordionItem=l.forwardRef(((r,t)=>{const{value:n,...a}=r,c=w("AccordionItem"),d=p("AccordionItem"),i=e(),u=n&&d.value.includes(n)||!1,f=c.disabled||r.disabled;return l.createElement(x,{open:u,disabled:f,buttonId:i},l.createElement(o,s({"data-state":u?"open":"closed",disabled:f},a,{ref:t,open:u,onOpenChange:e=>{e?d.onItemOpen(n):d.onItemClose(n)}})))}));AccordionItem.displayName="AccordionItem";const I="h3";export const AccordionHeader=l.forwardRef(((e,o)=>{const{as:r=I,...t}=e,a=E(y);return l.createElement(n,s({"data-state":(c=a.open,c?"open":"closed"),"data-disabled":a.disabled?"":void 0},t,{as:r,ref:o}));var c}));AccordionHeader.displayName="AccordionHeader";const y="AccordionButton";export const AccordionButton=l.forwardRef(((e,o)=>{const{buttonNodesRef:t}=w(y),n=E(y),a=l.useRef(null),c=d(a,o);return l.useEffect((()=>{const e=t.current,o=a.current;if(o)return e.add(o),()=>{e.delete(o)}}),[t]),l.createElement(r,s({"aria-disabled":n.open||void 0,id:n.buttonId},e,{ref:c}))}));AccordionButton.displayName=y;export const AccordionPanel=l.forwardRef(((e,o)=>{const r=E("AccordionPanel");return l.createElement(t,s({role:"region","aria-labelledby":r.buttonId},e,{ref:o}))}));AccordionPanel.displayName="AccordionPanel";export const Root=Accordion;export const Item=AccordionItem;export const Header=AccordionHeader;export const Button=AccordionButton;export const Panel=AccordionPanel; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@radix-ui/react-accordion", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"license": "MIT", | ||
@@ -19,7 +19,10 @@ "source": "src/index.ts", | ||
"dependencies": { | ||
"@radix-ui/react-collapsible": "0.0.5", | ||
"@radix-ui/react-polymorphic": "0.0.5", | ||
"@radix-ui/react-primitive": "0.0.4", | ||
"@radix-ui/react-utils": "0.0.5", | ||
"@radix-ui/utils": "0.0.3" | ||
"@radix-ui/primitive": "0.0.1", | ||
"@radix-ui/react-collapsible": "0.0.6", | ||
"@radix-ui/react-compose-refs": "0.0.1", | ||
"@radix-ui/react-context": "0.0.1", | ||
"@radix-ui/react-id": "0.0.1", | ||
"@radix-ui/react-polymorphic": "0.0.6", | ||
"@radix-ui/react-primitive": "0.0.5", | ||
"@radix-ui/react-use-controllable-state": "0.0.1" | ||
}, | ||
@@ -26,0 +29,0 @@ "peerDependencies": { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59968
142
9
+ Added@radix-ui/primitive@0.0.1
+ Added@radix-ui/react-id@0.0.1
+ Added@radix-ui/primitive@0.0.1(transitive)
+ Added@radix-ui/react-collapsible@0.0.6(transitive)
+ Added@radix-ui/react-compose-refs@0.0.1(transitive)
+ Added@radix-ui/react-context@0.0.1(transitive)
+ Added@radix-ui/react-id@0.0.1(transitive)
+ Added@radix-ui/react-polymorphic@0.0.6(transitive)
+ Added@radix-ui/react-presence@0.0.6(transitive)
+ Added@radix-ui/react-primitive@0.0.5(transitive)
+ Added@radix-ui/react-use-callback-ref@0.0.1(transitive)
+ Added@radix-ui/react-use-controllable-state@0.0.1(transitive)
- Removed@radix-ui/react-utils@0.0.5
- Removed@radix-ui/utils@0.0.3
- Removed@radix-ui/react-collapsible@0.0.5(transitive)
- Removed@radix-ui/react-polymorphic@0.0.5(transitive)
- Removed@radix-ui/react-presence@0.0.5(transitive)
- Removed@radix-ui/react-primitive@0.0.4(transitive)
- Removed@radix-ui/react-utils@0.0.5(transitive)
- Removed@radix-ui/utils@0.0.3(transitive)
- Removed@xstate/fsm@1.6.5(transitive)