@zag-js/accordion
Advanced tools
Comparing version 0.0.0-v1-beta-20250220125322 to 0.0.0-v1-beta-20250221135618
@@ -36,7 +36,8 @@ import * as _zag_js_anatomy from '@zag-js/anatomy'; | ||
/** | ||
* The `value` of the accordion items that are currently being expanded. | ||
* The controlled value of the expanded accordion items. | ||
*/ | ||
value?: string[] | undefined; | ||
/** | ||
* The default value of the accordion items that are currently being expanded. | ||
* The initial value of the expanded accordion items. | ||
* Use when you don't need to control the value of the accordion. | ||
*/ | ||
@@ -51,7 +52,7 @@ defaultValue?: string[] | undefined; | ||
*/ | ||
onValueChange?(details: ValueChangeDetails): void; | ||
onValueChange?: ((details: ValueChangeDetails) => void) | undefined; | ||
/** | ||
* The callback fired when the focused accordion item changes. | ||
*/ | ||
onFocusChange?(details: FocusChangeDetails): void; | ||
onFocusChange?: ((details: FocusChangeDetails) => void) | undefined; | ||
/** | ||
@@ -132,2 +133,7 @@ * The orientation of the accordion items. | ||
export { type AccordionApi as Api, type ElementIds, type FocusChangeDetails, type ItemProps, type ItemState, type AccordionProps as Props, type AccordionService as Service, type ValueChangeDetails, anatomy, connect, machine }; | ||
declare const props: (keyof AccordionProps)[]; | ||
declare const splitProps: <Props extends Partial<AccordionProps>>(props: Props) => [Partial<AccordionProps>, Omit<Props, keyof AccordionProps>]; | ||
declare const itemProps: (keyof ItemProps)[]; | ||
declare const splitItemProps: <Props extends ItemProps>(props: Props) => [ItemProps, Omit<Props, keyof ItemProps>]; | ||
export { type AccordionApi as Api, type ElementIds, type FocusChangeDetails, type ItemProps, type ItemState, type AccordionProps as Props, type AccordionService as Service, type ValueChangeDetails, anatomy, connect, itemProps, machine, props, splitItemProps, splitProps }; |
@@ -7,2 +7,3 @@ 'use strict'; | ||
var core = require('@zag-js/core'); | ||
var types = require('@zag-js/types'); | ||
@@ -35,3 +36,3 @@ // src/accordion.anatomy.ts | ||
let nextValue = value2; | ||
if (multiple && nextValue.length > 1) { | ||
if (!multiple && nextValue.length > 1) { | ||
nextValue = [nextValue[0]]; | ||
@@ -41,7 +42,7 @@ } | ||
} | ||
function getItemState(props) { | ||
function getItemState(props2) { | ||
return { | ||
expanded: value.includes(props.value), | ||
focused: focusedValue === props.value, | ||
disabled: Boolean(props.disabled ?? prop("disabled")) | ||
expanded: value.includes(props2.value), | ||
focused: focusedValue === props2.value, | ||
disabled: Boolean(props2.disabled ?? prop("disabled")) | ||
}; | ||
@@ -62,8 +63,8 @@ } | ||
}, | ||
getItemProps(props) { | ||
const itemState = getItemState(props); | ||
getItemProps(props2) { | ||
const itemState = getItemState(props2); | ||
return normalize.element({ | ||
...parts.item.attrs, | ||
dir: prop("dir"), | ||
id: getItemId(scope, props.value), | ||
id: getItemId(scope, props2.value), | ||
"data-state": itemState.expanded ? "open" : "closed", | ||
@@ -75,4 +76,4 @@ "data-focus": domQuery.dataAttr(itemState.focused), | ||
}, | ||
getItemContentProps(props) { | ||
const itemState = getItemState(props); | ||
getItemContentProps(props2) { | ||
const itemState = getItemState(props2); | ||
return normalize.element({ | ||
@@ -82,4 +83,4 @@ ...parts.itemContent.attrs, | ||
role: "region", | ||
id: getItemContentId(scope, props.value), | ||
"aria-labelledby": getItemTriggerId(scope, props.value), | ||
id: getItemContentId(scope, props2.value), | ||
"aria-labelledby": getItemTriggerId(scope, props2.value), | ||
hidden: !itemState.expanded, | ||
@@ -92,4 +93,4 @@ "data-state": itemState.expanded ? "open" : "closed", | ||
}, | ||
getItemIndicatorProps(props) { | ||
const itemState = getItemState(props); | ||
getItemIndicatorProps(props2) { | ||
const itemState = getItemState(props2); | ||
return normalize.element({ | ||
@@ -105,5 +106,5 @@ ...parts.itemIndicator.attrs, | ||
}, | ||
getItemTriggerProps(props) { | ||
const { value: value2 } = props; | ||
const itemState = getItemState(props); | ||
getItemTriggerProps(props2) { | ||
const { value: value2 } = props2; | ||
const itemState = getItemState(props2); | ||
return normalize.button({ | ||
@@ -181,3 +182,3 @@ ...parts.itemTrigger.attrs, | ||
var machine = core.createMachine({ | ||
props({ props }) { | ||
props({ props: props2 }) { | ||
return { | ||
@@ -188,3 +189,3 @@ collapsible: false, | ||
defaultValue: [], | ||
...props | ||
...props2 | ||
}; | ||
@@ -315,5 +316,26 @@ }, | ||
}); | ||
var props = types.createProps()([ | ||
"collapsible", | ||
"dir", | ||
"disabled", | ||
"getRootNode", | ||
"id", | ||
"ids", | ||
"multiple", | ||
"onFocusChange", | ||
"onValueChange", | ||
"orientation", | ||
"value", | ||
"defaultValue" | ||
]); | ||
var splitProps = utils.createSplitProps(props); | ||
var itemProps = types.createProps()(["value", "disabled"]); | ||
var splitItemProps = utils.createSplitProps(itemProps); | ||
exports.anatomy = anatomy; | ||
exports.connect = connect; | ||
exports.itemProps = itemProps; | ||
exports.machine = machine; | ||
exports.props = props; | ||
exports.splitItemProps = splitItemProps; | ||
exports.splitProps = splitProps; |
{ | ||
"name": "@zag-js/accordion", | ||
"version": "0.0.0-v1-beta-20250220125322", | ||
"version": "0.0.0-v1-beta-20250221135618", | ||
"description": "Core logic for the accordion widget implemented as a state machine", | ||
@@ -29,7 +29,7 @@ "keywords": [ | ||
"dependencies": { | ||
"@zag-js/types": "0.0.0-v1-beta-20250220125322", | ||
"@zag-js/core": "0.0.0-v1-beta-20250220125322", | ||
"@zag-js/dom-query": "0.0.0-v1-beta-20250220125322", | ||
"@zag-js/anatomy": "0.0.0-v1-beta-20250220125322", | ||
"@zag-js/utils": "0.0.0-v1-beta-20250220125322" | ||
"@zag-js/anatomy": "0.0.0-v1-beta-20250221135618", | ||
"@zag-js/core": "0.0.0-v1-beta-20250221135618", | ||
"@zag-js/dom-query": "0.0.0-v1-beta-20250221135618", | ||
"@zag-js/utils": "0.0.0-v1-beta-20250221135618", | ||
"@zag-js/types": "0.0.0-v1-beta-20250221135618" | ||
}, | ||
@@ -45,5 +45,10 @@ "devDependencies": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
"import": { | ||
"types": "./dist/index.d.mts", | ||
"default": "./dist/index.mjs" | ||
}, | ||
"require": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
} | ||
}, | ||
@@ -50,0 +55,0 @@ "./package.json": "./package.json" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
32919
775
+ Added@zag-js/anatomy@0.0.0-v1-beta-20250221135618(transitive)
+ Added@zag-js/core@0.0.0-v1-beta-20250221135618(transitive)
+ Added@zag-js/dom-query@0.0.0-v1-beta-20250221135618(transitive)
+ Added@zag-js/types@0.0.0-v1-beta-20250221135618(transitive)
+ Added@zag-js/utils@0.0.0-v1-beta-20250221135618(transitive)
- Removed@zag-js/anatomy@0.0.0-v1-beta-20250220125322(transitive)
- Removed@zag-js/core@0.0.0-v1-beta-20250220125322(transitive)
- Removed@zag-js/dom-query@0.0.0-v1-beta-20250220125322(transitive)
- Removed@zag-js/types@0.0.0-v1-beta-20250220125322(transitive)
- Removed@zag-js/utils@0.0.0-v1-beta-20250220125322(transitive)