@octanejs/base-ui 0.1.19 → 0.1.21

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/src/index.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  // (`@octanejs/base-ui/separator`, `@octanejs/base-ui/use-render`, …). This barrel
4
4
  // re-exports the public surface for convenience as components land.
5
5
  export { Separator } from './separator';
6
+ export { Accordion } from './accordion';
6
7
  export { AlertDialog } from './alert-dialog';
7
8
  export { Avatar } from './avatar';
8
9
  export { Button } from './button';
@@ -11,6 +12,7 @@ export { DirectionProvider, useDirection } from './direction-provider';
11
12
  export type { TextDirection } from './direction-provider';
12
13
  export { useMediaQuery } from './unstable-use-media-query';
13
14
  export { Checkbox } from './checkbox';
15
+ export { Collapsible } from './collapsible';
14
16
  export { ContextMenu } from './context-menu';
15
17
  export { CheckboxGroup } from './checkbox-group';
16
18
  export { Dialog } from './dialog';
@@ -0,0 +1,30 @@
1
+ // Ported from .base-ui/packages/react/src/utils/collapsibleOpenStateMapping.ts (v1.6.0).
2
+ //
3
+ // NAME COLLISION, upstream's not ours: Base UI exports `triggerOpenStateMapping` from BOTH
4
+ // this module and `utils/popupStateMapping.ts`, and they emit DIFFERENT attributes —
5
+ // `data-panel-open` here versus `data-popup-open` there. Each consumer imports the one it
6
+ // means, and the collapsible trigger means this one. This package puts one util per file, so
7
+ // the collapsible variant is renamed rather than shadowing the popup export: importing the
8
+ // wrong one is a silent attribute swap that only a rendered-DOM assertion would catch.
9
+ import type { StateAttributesMapping } from './getStateAttributesProps';
10
+
11
+ // CollapsiblePanelDataAttributes.open / .closed
12
+ const PANEL_OPEN_HOOK = { 'data-open': '' };
13
+ const PANEL_CLOSED_HOOK = { 'data-closed': '' };
14
+
15
+ // CollapsibleTriggerDataAttributes.panelOpen
16
+ const TRIGGER_PANEL_OPEN_HOOK = { 'data-panel-open': '' };
17
+
18
+ /** The panel/root mapping: `data-open` when open, `data-closed` when not. */
19
+ export const collapsibleOpenStateMapping: StateAttributesMapping<{ open: boolean }> = {
20
+ open(value: boolean) {
21
+ return value ? PANEL_OPEN_HOOK : PANEL_CLOSED_HOOK;
22
+ },
23
+ };
24
+
25
+ /** Upstream's `triggerOpenStateMapping` from this module: `data-panel-open`, or nothing. */
26
+ export const collapsibleTriggerOpenStateMapping: StateAttributesMapping<{ open: boolean }> = {
27
+ open(value: boolean) {
28
+ return value ? TRIGGER_PANEL_OPEN_HOOK : null;
29
+ },
30
+ };