@radix-ui/react-tabs 0.1.2-rc.1 → 0.1.2-rc.13

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/dist/index.d.ts CHANGED
@@ -23,7 +23,10 @@ export interface TabsProps extends PrimitiveDivProps {
23
23
  * @defaultValue ltr
24
24
  */
25
25
  dir?: RovingFocusGroupProps['dir'];
26
- /** Whether a tab is activated automatically or manually (default: automatic) */
26
+ /**
27
+ * Whether a tab is activated automatically or manually.
28
+ * @defaultValue automatic
29
+ * */
27
30
  activationMode?: 'automatic' | 'manual';
28
31
  }
29
32
  export const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
@@ -31,18 +34,18 @@ export interface TabsListProps extends PrimitiveDivProps {
31
34
  loop?: RovingFocusGroupProps['loop'];
32
35
  }
33
36
  export const TabsList: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
34
- export interface TabsTriggerProps extends PrimitiveDivProps {
37
+ type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
38
+ export interface TabsTriggerProps extends PrimitiveButtonProps {
35
39
  value: string;
36
- disabled?: boolean;
37
40
  }
38
- export const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLDivElement>>;
41
+ export const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
39
42
  export interface TabsContentProps extends PrimitiveDivProps {
40
43
  value: string;
41
44
  }
42
45
  export const TabsContent: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>;
43
46
  export const Root: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
44
47
  export const List: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
45
- export const Trigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLDivElement>>;
48
+ export const Trigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
46
49
  export const Content: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>;
47
50
 
48
51
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"mappings":"A;A;A;A;AAoBA,OAAA,sFAEE,CAAC;AAeH,6BAA6B,MAAM,wBAAwB,CAAC,OAAO,iBAAiB,IAAI,CAAC,CAAC;AAC1F,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,0BAAoB,SAAQ,iBAAiB;IAC3C,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;A;A;A;OAIG;IACH,WAAW,CAAC,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;IACnD;A;A;OAGG;IACH,GAAG,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACnC,gFAAgF;IAChF,cAAc,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;CACzC;AAED,OAAA,MAAM,sFAiCL,CAAC;AAWF,8BAAwB,SAAQ,iBAAiB;IAC/C,IAAI,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC;CACtC;AAED,OAAA,MAAM,8FAuBL,CAAC;AAWF,iCAA2B,SAAQ,iBAAiB;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,OAAA,MAAM,oGAkDL,CAAC;AAWF,iCAA2B,SAAQ,iBAAiB;IAClD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,OAAA,MAAM,oGAuBL,CAAC;AAcF,OAAA,MAAM,sFAAW,CAAC;AAClB,OAAA,MAAM,0FAAe,CAAC;AACtB,OAAA,MAAM,gGAAqB,CAAC;AAC5B,OAAA,MAAM,gGAAqB,CAAC","sources":["./packages/react/tabs/src/packages/react/tabs/src/Tabs.tsx","./packages/react/tabs/src/packages/react/tabs/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"index.d.ts.map"}
1
+ {"mappings":"A;A;A;A;AAoBA,OAAA,sFAEE,CAAC;AAeH,6BAA6B,MAAM,wBAAwB,CAAC,OAAO,iBAAiB,IAAI,CAAC,CAAC;AAC1F,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,0BAAoB,SAAQ,iBAAiB;IAC3C,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;A;A;A;OAIG;IACH,WAAW,CAAC,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;IACnD;A;A;OAGG;IACH,GAAG,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACnC;A;A;SAGK;IACL,cAAc,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;CACzC;AAED,OAAA,MAAM,sFAiCL,CAAC;AAWF,8BAAwB,SAAQ,iBAAiB;IAC/C,IAAI,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC;CACtC;AAED,OAAA,MAAM,8FAuBL,CAAC;AAWF,4BAA4B,MAAM,wBAAwB,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC;AACpF,iCAA2B,SAAQ,oBAAoB;IACrD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,OAAA,MAAM,uGAiDL,CAAC;AAWF,iCAA2B,SAAQ,iBAAiB;IAClD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,OAAA,MAAM,oGAuBL,CAAC;AAcF,OAAA,MAAM,sFAAW,CAAC;AAClB,OAAA,MAAM,0FAAe,CAAC;AACtB,OAAA,MAAM,mGAAqB,CAAC;AAC5B,OAAA,MAAM,gGAAqB,CAAC","sources":["./packages/react/tabs/src/packages/react/tabs/src/Tabs.tsx","./packages/react/tabs/src/packages/react/tabs/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"index.d.ts.map"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var e,t=require("@radix-ui/react-id").useId,a=require("@radix-ui/react-roving-focus"),r=b({},a),o=a.createRovingFocusGroupScope,i=require("@radix-ui/react-primitive").Primitive,n=require("@radix-ui/react-use-controllable-state").useControllableState,s=require("@radix-ui/react-use-callback-ref").useCallbackRef,c=require("@radix-ui/react-context").createContextScope,d=require("@radix-ui/primitive").composeEventHandlers,u=b({},require("react")),l=(e=require("@babel/runtime/helpers/extends"))&&e.__esModule?e.default:e;function b(e,t){return Object.keys(t).forEach((function(a){"default"!==a&&"__esModule"!==a&&Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[a]}})})),e}const[p,f]=c("Tabs",[o]);exports.createTabsScope=f;const v=o(),[x,T]=p("Tabs"),m=/*#__PURE__*/u.forwardRef(((e,a)=>{const{__scopeTabs:r,value:o,onValueChange:s,defaultValue:c,orientation:d="horizontal",dir:b="ltr",activationMode:p="automatic",...f}=e,[v,T]=n({prop:o,onChange:s,defaultProp:c});/*#__PURE__*/return u.createElement(x,{scope:r,baseId:t(),value:v,onValueChange:T,orientation:d,dir:b,activationMode:p},/*#__PURE__*/u.createElement(i.div,l({"data-orientation":d},f,{ref:a})))}));exports.Tabs=m;const g=/*#__PURE__*/u.forwardRef(((e,t)=>{const{__scopeTabs:a,loop:o=!0,...n}=e,s=T("TabsList",a),c=v(a);/*#__PURE__*/return u.createElement(r.Root,l({asChild:!0},c,{orientation:s.orientation,dir:s.dir,loop:o}),/*#__PURE__*/u.createElement(i.div,l({role:"tablist","aria-orientation":s.orientation,dir:s.dir},n,{ref:t})))}));exports.TabsList=g;const C=/*#__PURE__*/u.forwardRef(((e,t)=>{const{__scopeTabs:a,value:o,disabled:n=!1,...c}=e,b=T("TabsTrigger",a),p=v(a),f=h(b.baseId,o),x=E(b.baseId,o),m=o===b.value,g=s((()=>b.onValueChange(o)));/*#__PURE__*/return u.createElement(r.Item,l({asChild:!0},p,{focusable:!n,active:m}),/*#__PURE__*/u.createElement(i.div,l({role:"tab","aria-selected":m,"aria-controls":x,"aria-disabled":n||void 0,"data-state":m?"active":"inactive","data-disabled":n?"":void 0,id:f},c,{ref:t,onKeyDown:d(e.onKeyDown,(e=>{n||" "!==e.key&&"Enter"!==e.key||g()})),onMouseDown:d(e.onMouseDown,(e=>{n||0!==e.button||!1!==e.ctrlKey||g()})),onFocus:d(e.onFocus,(()=>{const e="manual"!==b.activationMode;m||n||!e||g()}))})))}));exports.TabsTrigger=C;const _=/*#__PURE__*/u.forwardRef(((e,t)=>{const{__scopeTabs:a,value:r,children:o,...n}=e,s=T("TabsContent",a),c=h(s.baseId,r),d=E(s.baseId,r),b=r===s.value;/*#__PURE__*/return u.createElement(i.div,l({"data-state":b?"active":"inactive","data-orientation":s.orientation,role:"tabpanel","aria-labelledby":c,hidden:!b,id:d,tabIndex:0},n,{ref:t}),b&&o)}));function h(e,t){return`${e}-trigger-${t}`}function E(e,t){return`${e}-content-${t}`}exports.TabsContent=_;const q=m;exports.Root=q;const w=g;exports.List=w;const y=C;exports.Trigger=y;const I=_;exports.Content=I;
1
+ var e,t=require("@radix-ui/react-id").useId,a=require("@radix-ui/react-roving-focus"),r=b({},a),o=a.createRovingFocusGroupScope,i=require("@radix-ui/react-primitive").Primitive,n=require("@radix-ui/react-use-controllable-state").useControllableState,s=require("@radix-ui/react-use-callback-ref").useCallbackRef,c=require("@radix-ui/react-context").createContextScope,u=require("@radix-ui/primitive").composeEventHandlers,l=b({},require("react")),d=(e=require("@babel/runtime/helpers/extends"))&&e.__esModule?e.default:e;function b(e,t){return Object.keys(t).forEach((function(a){"default"!==a&&"__esModule"!==a&&Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[a]}})})),e}const[p,f]=c("Tabs",[o]);exports.createTabsScope=f;const v=o(),[x,T]=p("Tabs"),m=/*#__PURE__*/l.forwardRef(((e,a)=>{const{__scopeTabs:r,value:o,onValueChange:s,defaultValue:c,orientation:u="horizontal",dir:b="ltr",activationMode:p="automatic",...f}=e,[v,T]=n({prop:o,onChange:s,defaultProp:c});/*#__PURE__*/return l.createElement(x,{scope:r,baseId:t(),value:v,onValueChange:T,orientation:u,dir:b,activationMode:p},/*#__PURE__*/l.createElement(i.div,d({"data-orientation":u},f,{ref:a})))}));exports.Tabs=m;const g=/*#__PURE__*/l.forwardRef(((e,t)=>{const{__scopeTabs:a,loop:o=!0,...n}=e,s=T("TabsList",a),c=v(a);/*#__PURE__*/return l.createElement(r.Root,d({asChild:!0},c,{orientation:s.orientation,dir:s.dir,loop:o}),/*#__PURE__*/l.createElement(i.div,d({role:"tablist","aria-orientation":s.orientation,dir:s.dir},n,{ref:t})))}));exports.TabsList=g;const C=/*#__PURE__*/l.forwardRef(((e,t)=>{const{__scopeTabs:a,value:o,disabled:n=!1,...c}=e,b=T("TabsTrigger",a),p=v(a),f=h(b.baseId,o),x=q(b.baseId,o),m=o===b.value,g=s((()=>b.onValueChange(o)));/*#__PURE__*/return l.createElement(r.Item,d({asChild:!0},p,{focusable:!n,active:m}),/*#__PURE__*/l.createElement(i.button,d({type:"button",role:"tab","aria-selected":m,"aria-controls":x,"data-state":m?"active":"inactive","data-disabled":n?"":void 0,disabled:n,id:f},c,{ref:t,onClick:u(e.onClick,g),onMouseDown:u(e.onMouseDown,(e=>{n||0!==e.button||!1!==e.ctrlKey||g()})),onFocus:u(e.onFocus,(()=>{const e="manual"!==b.activationMode;m||n||!e||g()}))})))}));exports.TabsTrigger=C;const _=/*#__PURE__*/l.forwardRef(((e,t)=>{const{__scopeTabs:a,value:r,children:o,...n}=e,s=T("TabsContent",a),c=h(s.baseId,r),u=q(s.baseId,r),b=r===s.value;/*#__PURE__*/return l.createElement(i.div,d({"data-state":b?"active":"inactive","data-orientation":s.orientation,role:"tabpanel","aria-labelledby":c,hidden:!b,id:u,tabIndex:0},n,{ref:t}),b&&o)}));function h(e,t){return`${e}-trigger-${t}`}function q(e,t){return`${e}-content-${t}`}exports.TabsContent=_;const E=m;exports.Root=E;const I=g;exports.List=I;const R=C;exports.Trigger=R;const M=_;exports.Content=M;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":"IAAgCA,6bAAAA,8CAClBA,EAAEC,WAAaD,EAAEE,QAAUF,EAWzC,SAASG,EAAuBC,EAAMC,GAcpC,OAbAC,OAAOC,KAAKF,GAAQG,SAAQ,SAASC,GACvB,YAARA,GAA6B,eAARA,GAIzBH,OAAOI,eAAeN,EAAMK,EAAK,CAC/BE,YAAY,EACZC,IAAK,WACH,OAAOP,EAAOI,SAKbL,ECTT,MAGOS,EAAmBC,GAAmBC,EAH3B,OAGyD,CACzEC,8BAEF,MAAMC,EAA2BD,KAW1BE,EAAcC,GAAkBN,EAjBrB,QA4CZO,eAAOC,EAAMC,YACjB,CAACC,EAA+BC,KAC9B,MAAMC,YACJA,EACAC,MAAOC,EAFHC,cAGJA,EAHIC,aAIJA,EAJIC,YAKJA,EAAc,aALVC,IAMJA,EAAM,MANFC,eAOJA,EAAiB,eACdC,GACDV,GAEGG,EAAOQ,GAAYC,EAAqB,CAC7CC,KAAMT,EACNU,SAAUT,EACVU,YAAaT,iBAGf,OACEU,EAAAC,cAACC,EAAD,CACEC,MAAOjB,EACPkB,OAAQC,IACRlB,MAAOA,EACPE,cAAeM,EACfJ,YAAaA,EACbC,IAAKA,EACLC,eAAgBA,gBAEhBO,EAAAC,cAACK,EAAUC,IAAXC,EAAA,CAAe,mBAAkBjB,GAAiBG,EAAlD,CAA6De,IAAKxB,wBAY1E,MAOMyB,eAAW5B,EAAMC,YACrB,CAACC,E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EAAMG,SAC3CZ,OAGJa,QAASL,EAAqBnD,EAAMwD,SAAS,KAG3C,MAAMC,EAAmD,WAA3B5B,EAAQpB,eACjCiC,GAAeN,IAAYqB,GAC9Bd,oCAed,MAOMe,eAAc5D,EAAMC,YACxB,CAACC,EAAsCC,KACrC,MAAMC,YAAEA,EAAFC,MAAeA,EAAfwD,SAAsBA,KAAaC,GAAiB5D,EACpD6B,EAAUjC,EAVC,cAU4BM,GACvCoC,EAAYC,EAAcV,EAAQT,OAAQjB,GAC1CqC,EAAYC,EAAcZ,EAAQT,OAAQjB,GAC1CuC,EAAavC,IAAU0B,EAAQ1B,mBACrC,OACEa,EAAAC,cAACK,EAAUC,IAAXC,EAAA,CACE,aAAYkB,EAAa,SAAW,WACpC,mBAAkBb,EAAQtB,YAC1B2B,KAAK,WACL,kBAAiBI,EACjBuB,QAASnB,EACTO,GAAIT,EACJsB,SAAU,GACNF,EARN,CASEnC,IAAKxB,IAEJyC,GAAciB,MAUvB,SAASpB,EAAcnB,EAAgBjB,GACrC,MAAQ,GAAEiB,aAAkBjB,IAG9B,SAASsC,EAAcrB,EAAgBjB,GACrC,MAAQ,GAAEiB,aAAkBjB,0BAG9B,MAAM6B,EAAOnC,iBACb,MAAMkE,EAAOrC,iBACb,MAAMsC,EAAU7B,oBAChB,MAAM8B,EAAUP","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/tabs/src/Tabs.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { useId } from '@radix-ui/react-id';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs';\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope };\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\n\ntype TabsContextValue = {\n baseId: string;\n value?: string;\n onValueChange: (value: string) => void;\n orientation?: TabsProps['orientation'];\n dir?: TabsProps['dir'];\n activationMode?: TabsProps['activationMode'];\n};\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME);\n\ntype TabsElement = React.ElementRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface TabsProps extends PrimitiveDivProps {\n /** The value for the selected tab, if controlled */\n value?: string;\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string;\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void;\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation'];\n /**\n * The direction of navigation between toolbar items.\n * @defaultValue ltr\n */\n dir?: RovingFocusGroupProps['dir'];\n /** Whether a tab is activated automatically or manually (default: automatic) */\n activationMode?: 'automatic' | 'manual';\n}\n\nconst Tabs = React.forwardRef<TabsElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir = 'ltr',\n activationMode = 'automatic',\n ...tabsProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue,\n });\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={useId()}\n value={value}\n onValueChange={setValue}\n orientation={orientation}\n dir={dir}\n activationMode={activationMode}\n >\n <Primitive.div data-orientation={orientation} {...tabsProps} ref={forwardedRef} />\n </TabsProvider>\n );\n }\n);\n\nTabs.displayName = TABS_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList';\n\ntype TabsListElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsListProps extends PrimitiveDivProps {\n loop?: RovingFocusGroupProps['loop'];\n}\n\nconst TabsList = React.forwardRef<TabsListElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, ...listProps } = props;\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);\n return (\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n >\n <Primitive.div\n role=\"tablist\"\n aria-orientation={context.orientation}\n dir={context.dir}\n {...listProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n );\n }\n);\n\nTabsList.displayName = TAB_LIST_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger';\n\ntype TabsTriggerElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsTriggerProps extends PrimitiveDivProps {\n value: string;\n disabled?: boolean;\n}\n\nconst TabsTrigger = React.forwardRef<TabsTriggerElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const { __scopeTabs, value, disabled = false, ...triggerProps } = props;\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);\n const triggerId = makeTriggerId(context.baseId, value);\n const contentId = makeContentId(context.baseId, value);\n const isSelected = value === context.value;\n const handleTabChange = useCallbackRef(() => context.onValueChange(value));\n return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <Primitive.div\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n aria-disabled={disabled || undefined}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n id={triggerId}\n {...triggerProps}\n ref={forwardedRef}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (!disabled && (event.key === ' ' || event.key === 'Enter')) {\n handleTabChange();\n }\n })}\n onMouseDown={composeEventHandlers(props.onMouseDown, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n if (!disabled && event.button === 0 && event.ctrlKey === false) {\n handleTabChange();\n }\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual';\n if (!isSelected && !disabled && isAutomaticActivation) {\n handleTabChange();\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n }\n);\n\nTabsTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent';\n\ntype TabsContentElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsContentProps extends PrimitiveDivProps {\n value: string;\n}\n\nconst TabsContent = React.forwardRef<TabsContentElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, children, ...contentProps } = props;\n const context = useTabsContext(CONTENT_NAME, __scopeTabs);\n const triggerId = makeTriggerId(context.baseId, value);\n const contentId = makeContentId(context.baseId, value);\n const isSelected = value === context.value;\n return (\n <Primitive.div\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n hidden={!isSelected}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {isSelected && children}\n </Primitive.div>\n );\n }\n);\n\nTabsContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`;\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`;\n}\n\nconst Root = Tabs;\nconst List = TabsList;\nconst Trigger = TabsTrigger;\nconst Content = TabsContent;\n\nexport {\n createTabsScope,\n //\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n //\n Root,\n List,\n Trigger,\n Content,\n};\nexport type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps };\n"],"names":["a","__esModule","default","$parcel$exportWildcard","dest","source","Object","keys","forEach","key","defineProperty","enumerable","get","createTabsContext","createTabsScope","createContextScope","createRovingFocusGroupScope","useRovingFocusGroupScope","TabsProvider","useTabsContext","Tabs","React","forwardRef","props","forwardedRef","__scopeTabs","value","valueProp","onValueChange","defaultValue","orientation","dir","activationMode","tabsProps","setValue","useControllableState","prop","onChange","defaultProp","_react","createElement","$cebddb0c75f42c980c43f093526f6ec6$var$TabsProvider","scope","baseId","useId","Primitive","div","_babelRuntimeHelpersExtends","ref","TabsList","loop","listProps","context","rovingFocusGroupScope","_radixUiReactRovingFocus","Root","asChild","role","TabsTrigger","disabled","triggerProps","triggerId","makeTriggerId","contentId","makeContentId","isSelected","handleTabChange","useCallbackRef","Item","focusable","active","undefined","id","onKeyDown","composeEventHandlers","event","onMouseDown","button","ctrlKey","onFocus","isAutomaticActivation","TabsContent","children","contentProps","hidden","tabIndex","List","Trigger","Content"],"version":3,"file":"index.js.map"}
1
+ {"mappings":"IAAgCA,6bAAAA,8CAClBA,EAAEC,WAAaD,EAAEE,QAAUF,EAWzC,SAASG,EAAuBC,EAAMC,GAcpC,OAbAC,OAAOC,KAAKF,GAAQG,SAAQ,SAASC,GACvB,YAARA,GAA6B,eAARA,GAIzBH,OAAOI,eAAeN,EAAMK,EAAK,CAC/BE,YAAY,EACZC,IAAK,WACH,OAAOP,EAAOI,SAKbL,ECTT,MAGOS,EAAmBC,GAAmBC,EAH3B,OAGyD,CACzEC,8BAEF,MAAMC,EAA2BD,KAW1BE,EAAcC,GAAkBN,EAjBrB,QA+CZO,eAAOC,EAAMC,YACjB,CAACC,EAA+BC,KAC9B,MAAMC,YACJA,EACAC,MAAOC,EAFHC,cAGJA,EAHIC,aAIJA,EAJIC,YAKJA,EAAc,aALVC,IAMJA,EAAM,MANFC,eAOJA,EAAiB,eACdC,GACDV,GAEGG,EAAOQ,GAAYC,EAAqB,CAC7CC,KAAMT,EACNU,SAAUT,EACVU,YAAaT,iBAGf,OACEU,EAAAC,cAACC,EAAD,CACEC,MAAOjB,EACPkB,OAAQC,IACRlB,MAAOA,EACPE,cAAeM,EACfJ,YAAaA,EACbC,IAAKA,EACLC,eAAgBA,gBAEhBO,EAAAC,cAACK,EAAUC,IAAXC,EAAA,CAAe,mBAA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,EAAMP,SAAkC,IAAlBO,EAAMC,SAC3Cb,OAGJc,QAASJ,EAAqBrD,EAAMyD,SAAS,KAG3C,MAAMC,EAAmD,WAA3B7B,EAAQpB,eACjCiC,GAAeN,IAAYsB,GAC9Bf,oCAed,MAOMgB,eAAc7D,EAAMC,YACxB,CAACC,EAAsCC,KACrC,MAAMC,YAAEA,EAAFC,MAAeA,EAAfyD,SAAsBA,KAAaC,GAAiB7D,EACpD6B,EAAUjC,EAVC,cAU4BM,GACvCoC,EAAYC,EAAcV,EAAQT,OAAQjB,GAC1CqC,EAAYC,EAAcZ,EAAQT,OAAQjB,GAC1CuC,EAAavC,IAAU0B,EAAQ1B,mBACrC,OACEa,EAAAC,cAACK,EAAUC,IAAXC,EAAA,CACE,aAAYkB,EAAa,SAAW,WACpC,mBAAkBb,EAAQtB,YAC1B2B,KAAK,WACL,kBAAiBI,EACjBwB,QAASpB,EACTS,GAAIX,EACJuB,SAAU,GACNF,EARN,CASEpC,IAAKxB,IAEJyC,GAAckB,MAUvB,SAASrB,EAAcnB,EAAgBjB,GACrC,MAAQ,GAAEiB,aAAkBjB,IAG9B,SAASsC,EAAcrB,EAAgBjB,GACrC,MAAQ,GAAEiB,aAAkBjB,0BAG9B,MAAM6B,EAAOnC,iBACb,MAAMmE,EAAOtC,iBACb,MAAMuC,EAAU9B,oBAChB,MAAM+B,EAAUP","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/tabs/src/Tabs.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { useId } from '@radix-ui/react-id';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs';\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope };\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\n\ntype TabsContextValue = {\n baseId: string;\n value?: string;\n onValueChange: (value: string) => void;\n orientation?: TabsProps['orientation'];\n dir?: TabsProps['dir'];\n activationMode?: TabsProps['activationMode'];\n};\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME);\n\ntype TabsElement = React.ElementRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface TabsProps extends PrimitiveDivProps {\n /** The value for the selected tab, if controlled */\n value?: string;\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string;\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void;\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation'];\n /**\n * The direction of navigation between toolbar items.\n * @defaultValue ltr\n */\n dir?: RovingFocusGroupProps['dir'];\n /** \n * Whether a tab is activated automatically or manually.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual';\n}\n\nconst Tabs = React.forwardRef<TabsElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir = 'ltr',\n activationMode = 'automatic',\n ...tabsProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue,\n });\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={useId()}\n value={value}\n onValueChange={setValue}\n orientation={orientation}\n dir={dir}\n activationMode={activationMode}\n >\n <Primitive.div data-orientation={orientation} {...tabsProps} ref={forwardedRef} />\n </TabsProvider>\n );\n }\n);\n\nTabs.displayName = TABS_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList';\n\ntype TabsListElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsListProps extends PrimitiveDivProps {\n loop?: RovingFocusGroupProps['loop'];\n}\n\nconst TabsList = React.forwardRef<TabsListElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, ...listProps } = props;\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);\n return (\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n >\n <Primitive.div\n role=\"tablist\"\n aria-orientation={context.orientation}\n dir={context.dir}\n {...listProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n );\n }\n);\n\nTabsList.displayName = TAB_LIST_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger';\n\ntype TabsTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface TabsTriggerProps extends PrimitiveButtonProps {\n value: string;\n}\n\nconst TabsTrigger = React.forwardRef<TabsTriggerElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const { __scopeTabs, value, disabled = false, ...triggerProps } = props;\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);\n const triggerId = makeTriggerId(context.baseId, value);\n const contentId = makeContentId(context.baseId, value);\n const isSelected = value === context.value;\n const handleTabChange = useCallbackRef(() => context.onValueChange(value));\n return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <Primitive.button\n type=\"button\"\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n {...triggerProps}\n ref={forwardedRef}\n // Handle anything that the browser considers a click for the element type if\n // not using pointer e.g. Space keyup and Enter keydown\n onClick={composeEventHandlers(props.onClick, handleTabChange)}\n onMouseDown={composeEventHandlers(props.onMouseDown, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n if (!disabled && event.button === 0 && event.ctrlKey === false) {\n handleTabChange();\n }\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual';\n if (!isSelected && !disabled && isAutomaticActivation) {\n handleTabChange();\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n }\n);\n\nTabsTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent';\n\ntype TabsContentElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsContentProps extends PrimitiveDivProps {\n value: string;\n}\n\nconst TabsContent = React.forwardRef<TabsContentElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, children, ...contentProps } = props;\n const context = useTabsContext(CONTENT_NAME, __scopeTabs);\n const triggerId = makeTriggerId(context.baseId, value);\n const contentId = makeContentId(context.baseId, value);\n const isSelected = value === context.value;\n return (\n <Primitive.div\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n hidden={!isSelected}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {isSelected && children}\n </Primitive.div>\n );\n }\n);\n\nTabsContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`;\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`;\n}\n\nconst Root = Tabs;\nconst List = TabsList;\nconst Trigger = TabsTrigger;\nconst Content = TabsContent;\n\nexport {\n createTabsScope,\n //\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n //\n Root,\n List,\n Trigger,\n Content,\n};\nexport type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps };\n"],"names":["a","__esModule","default","$parcel$exportWildcard","dest","source","Object","keys","forEach","key","defineProperty","enumerable","get","createTabsContext","createTabsScope","createContextScope","createRovingFocusGroupScope","useRovingFocusGroupScope","TabsProvider","useTabsContext","Tabs","React","forwardRef","props","forwardedRef","__scopeTabs","value","valueProp","onValueChange","defaultValue","orientation","dir","activationMode","tabsProps","setValue","useControllableState","prop","onChange","defaultProp","_react","createElement","$cebddb0c75f42c980c43f093526f6ec6$var$TabsProvider","scope","baseId","useId","Primitive","div","_babelRuntimeHelpersExtends","ref","TabsList","loop","listProps","context","rovingFocusGroupScope","_radixUiReactRovingFocus","Root","asChild","role","TabsTrigger","disabled","triggerProps","triggerId","makeTriggerId","contentId","makeContentId","isSelected","handleTabChange","useCallbackRef","Item","focusable","active","button","type","undefined","id","onClick","composeEventHandlers","onMouseDown","event","ctrlKey","onFocus","isAutomaticActivation","TabsContent","children","contentProps","hidden","tabIndex","List","Trigger","Content"],"version":3,"file":"index.js.map"}
@@ -1,2 +1,2 @@
1
- import{useId as e}from"@radix-ui/react-id";import*as t from"@radix-ui/react-roving-focus";import{createRovingFocusGroupScope as a}from"@radix-ui/react-roving-focus";import{Primitive as o}from"@radix-ui/react-primitive";import{useControllableState as r}from"@radix-ui/react-use-controllable-state";import{useCallbackRef as i}from"@radix-ui/react-use-callback-ref";import{createContextScope as n}from"@radix-ui/react-context";import{composeEventHandlers as s}from"@radix-ui/primitive";import*as c from"react";import d from"@babel/runtime/helpers/esm/extends";const[l,u]=n("Tabs",[a]);export{u as createTabsScope};const b=a(),[m,p]=l("Tabs");export const Tabs=/*#__PURE__*/c.forwardRef(((t,a)=>{const{__scopeTabs:i,value:n,onValueChange:s,defaultValue:l,orientation:u="horizontal",dir:b="ltr",activationMode:p="automatic",...f}=t,[v,T]=r({prop:n,onChange:s,defaultProp:l});/*#__PURE__*/return c.createElement(m,{scope:i,baseId:e(),value:v,onValueChange:T,orientation:u,dir:b,activationMode:p},/*#__PURE__*/c.createElement(o.div,d({"data-orientation":u},f,{ref:a})))}));/*#__PURE__*/export const TabsList=/*#__PURE__*/c.forwardRef(((e,a)=>{const{__scopeTabs:r,loop:i=!0,...n}=e,s=p("TabsList",r),l=b(r);/*#__PURE__*/return c.createElement(t.Root,d({asChild:!0},l,{orientation:s.orientation,dir:s.dir,loop:i}),/*#__PURE__*/c.createElement(o.div,d({role:"tablist","aria-orientation":s.orientation,dir:s.dir},n,{ref:a})))}));/*#__PURE__*/export const TabsTrigger=/*#__PURE__*/c.forwardRef(((e,a)=>{const{__scopeTabs:r,value:n,disabled:l=!1,...u}=e,m=p("TabsTrigger",r),T=b(r),x=f(m.baseId,n),g=v(m.baseId,n),h=n===m.value,C=i((()=>m.onValueChange(n)));/*#__PURE__*/return c.createElement(t.Item,d({asChild:!0},T,{focusable:!l,active:h}),/*#__PURE__*/c.createElement(o.div,d({role:"tab","aria-selected":h,"aria-controls":g,"aria-disabled":l||void 0,"data-state":h?"active":"inactive","data-disabled":l?"":void 0,id:x},u,{ref:a,onKeyDown:s(e.onKeyDown,(e=>{l||" "!==e.key&&"Enter"!==e.key||C()})),onMouseDown:s(e.onMouseDown,(e=>{l||0!==e.button||!1!==e.ctrlKey||C()})),onFocus:s(e.onFocus,(()=>{const e="manual"!==m.activationMode;h||l||!e||C()}))})))}));/*#__PURE__*/export const TabsContent=/*#__PURE__*/c.forwardRef(((e,t)=>{const{__scopeTabs:a,value:r,children:i,...n}=e,s=p("TabsContent",a),l=f(s.baseId,r),u=v(s.baseId,r),b=r===s.value;/*#__PURE__*/return c.createElement(o.div,d({"data-state":b?"active":"inactive","data-orientation":s.orientation,role:"tabpanel","aria-labelledby":l,hidden:!b,id:u,tabIndex:0},n,{ref:t}),b&&i)}));/*#__PURE__*/function f(e,t){return`${e}-trigger-${t}`}function v(e,t){return`${e}-content-${t}`}export const Root=Tabs;export const List=TabsList;export const Trigger=TabsTrigger;export const Content=TabsContent;
1
+ import{useId as e}from"@radix-ui/react-id";import*as t from"@radix-ui/react-roving-focus";import{createRovingFocusGroupScope as o}from"@radix-ui/react-roving-focus";import{Primitive as a}from"@radix-ui/react-primitive";import{useControllableState as r}from"@radix-ui/react-use-controllable-state";import{useCallbackRef as i}from"@radix-ui/react-use-callback-ref";import{createContextScope as n}from"@radix-ui/react-context";import{composeEventHandlers as s}from"@radix-ui/primitive";import*as c from"react";import d from"@babel/runtime/helpers/esm/extends";const[l,u]=n("Tabs",[o]);export{u as createTabsScope};const b=o(),[m,p]=l("Tabs");export const Tabs=/*#__PURE__*/c.forwardRef(((t,o)=>{const{__scopeTabs:i,value:n,onValueChange:s,defaultValue:l,orientation:u="horizontal",dir:b="ltr",activationMode:p="automatic",...f}=t,[v,T]=r({prop:n,onChange:s,defaultProp:l});/*#__PURE__*/return c.createElement(m,{scope:i,baseId:e(),value:v,onValueChange:T,orientation:u,dir:b,activationMode:p},/*#__PURE__*/c.createElement(a.div,d({"data-orientation":u},f,{ref:o})))}));/*#__PURE__*/export const TabsList=/*#__PURE__*/c.forwardRef(((e,o)=>{const{__scopeTabs:r,loop:i=!0,...n}=e,s=p("TabsList",r),l=b(r);/*#__PURE__*/return c.createElement(t.Root,d({asChild:!0},l,{orientation:s.orientation,dir:s.dir,loop:i}),/*#__PURE__*/c.createElement(a.div,d({role:"tablist","aria-orientation":s.orientation,dir:s.dir},n,{ref:o})))}));/*#__PURE__*/export const TabsTrigger=/*#__PURE__*/c.forwardRef(((e,o)=>{const{__scopeTabs:r,value:n,disabled:l=!1,...u}=e,m=p("TabsTrigger",r),T=b(r),x=f(m.baseId,n),g=v(m.baseId,n),C=n===m.value,h=i((()=>m.onValueChange(n)));/*#__PURE__*/return c.createElement(t.Item,d({asChild:!0},T,{focusable:!l,active:C}),/*#__PURE__*/c.createElement(a.button,d({type:"button",role:"tab","aria-selected":C,"aria-controls":g,"data-state":C?"active":"inactive","data-disabled":l?"":void 0,disabled:l,id:x},u,{ref:o,onClick:s(e.onClick,h),onMouseDown:s(e.onMouseDown,(e=>{l||0!==e.button||!1!==e.ctrlKey||h()})),onFocus:s(e.onFocus,(()=>{const e="manual"!==m.activationMode;C||l||!e||h()}))})))}));/*#__PURE__*/export const TabsContent=/*#__PURE__*/c.forwardRef(((e,t)=>{const{__scopeTabs:o,value:r,children:i,...n}=e,s=p("TabsContent",o),l=f(s.baseId,r),u=v(s.baseId,r),b=r===s.value;/*#__PURE__*/return c.createElement(a.div,d({"data-state":b?"active":"inactive","data-orientation":s.orientation,role:"tabpanel","aria-labelledby":l,hidden:!b,id:u,tabIndex:0},n,{ref:t}),b&&i)}));/*#__PURE__*/function f(e,t){return`${e}-trigger-${t}`}function v(e,t){return`${e}-content-${t}`}export const Root=Tabs;export const List=TabsList;export const Trigger=TabsTrigger;export const Content=TabsContent;
2
2
  //# sourceMappingURL=index.module.js.map
@@ -1 +1 @@
1
- {"mappings":"6iBAiBA,MAGOA,EAAmBC,GAAmBC,EAH3B,OAGyD,CACzEC,iCAEF,MAAMC,EAA2BD,KAW1BE,EAAcC,GAAkBN,EAjBrB,eA4ClB,MAAMO,kBAAOC,EAAMC,YACjB,CAACC,EAA+BC,KAC9B,MAAMC,YACJA,EACAC,MAAOC,EAFHC,cAGJA,EAHIC,aAIJA,EAJIC,YAKJA,EAAc,aALVC,IAMJA,EAAM,MANFC,eAOJA,EAAiB,eACdC,GACDV,GAEGG,EAAOQ,GAAYC,EAAqB,CAC7CC,KAAMT,EACNU,SAAUT,EACVU,YAAaT,iBAGf,OACEU,EAAAC,cAACC,EAAD,CACEC,MAAOjB,EACPkB,OAAQC,IACRlB,MAAOA,EACPE,cAAeM,EACfJ,YAAaA,EACbC,IAAKA,EACLC,eAAgBA,gBAEhBO,EAAAC,cAACK,EAAUC,IAAXC,EAAA,CAAe,mBAAkBjB,GAAiBG,EAAlD,CAA6De,IAAKxB,6BAmB1E,MAAMyB,sBAAW5B,EAAMC,YACrB,CAACC,EAAmCC,KAClC,MAAMC,YAAEA,EAAFyB,KAAeA,GAAO,KAASC,GAAc5B,EAC7C6B,EAAUjC,EAVE,WAU4BM,GACxC4B,EAAwBpC,EAAyBQ,gBACvD,OACEc,EAAAC,cAACc,EAAiBC,KAAlBR,EAAA,CACES,SAA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ACrC,MAAMC,YAAEA,EAAFC,MAAeA,EAAfyD,SAAsBA,KAAaC,GAAiB7D,EACpD6B,EAAUjC,EAVC,cAU4BM,GACvCoC,EAAYC,EAAcV,EAAQT,OAAQjB,GAC1CqC,EAAYC,EAAcZ,EAAQT,OAAQjB,GAC1CuC,EAAavC,IAAU0B,EAAQ1B,mBACrC,OACEa,EAAAC,cAACK,EAAUC,IAAXC,EAAA,CACE,aAAYkB,EAAa,SAAW,WACpC,mBAAkBb,EAAQtB,YAC1B2B,KAAK,WACL,kBAAiBI,EACjBwB,QAASpB,EACTO,GAAIT,EACJuB,SAAU,GACNF,EARN,CASEpC,IAAKxB,IAEJyC,GAAckB,mBAUvB,SAASrB,EAAcnB,EAAgBjB,GACrC,MAAQ,GAAEiB,aAAkBjB,IAG9B,SAASsC,EAAcrB,EAAgBjB,GACrC,MAAQ,GAAEiB,aAAkBjB,WAG9B,MAAM6B,KAAOnC,YACb,MAAMmE,KAAOtC,gBACb,MAAMuC,QAAU9B,mBAChB,MAAM+B,QAAUP","sources":["./packages/react/tabs/src/Tabs.tsx"],"sourcesContent":["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { useId } from '@radix-ui/react-id';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs';\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope };\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\n\ntype TabsContextValue = {\n baseId: string;\n value?: string;\n onValueChange: (value: string) => void;\n orientation?: TabsProps['orientation'];\n dir?: TabsProps['dir'];\n activationMode?: TabsProps['activationMode'];\n};\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME);\n\ntype TabsElement = React.ElementRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface TabsProps extends PrimitiveDivProps {\n /** The value for the selected tab, if controlled */\n value?: string;\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string;\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void;\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation'];\n /**\n * The direction of navigation between toolbar items.\n * @defaultValue ltr\n */\n dir?: RovingFocusGroupProps['dir'];\n /** Whether a tab is activated automatically or manually (default: automatic) */\n activationMode?: 'automatic' | 'manual';\n}\n\nconst Tabs = React.forwardRef<TabsElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir = 'ltr',\n activationMode = 'automatic',\n ...tabsProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue,\n });\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={useId()}\n value={value}\n onValueChange={setValue}\n orientation={orientation}\n dir={dir}\n activationMode={activationMode}\n >\n <Primitive.div data-orientation={orientation} {...tabsProps} ref={forwardedRef} />\n </TabsProvider>\n );\n }\n);\n\nTabs.displayName = TABS_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList';\n\ntype TabsListElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsListProps extends PrimitiveDivProps {\n loop?: RovingFocusGroupProps['loop'];\n}\n\nconst TabsList = React.forwardRef<TabsListElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, ...listProps } = props;\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);\n return (\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n >\n <Primitive.div\n role=\"tablist\"\n aria-orientation={context.orientation}\n dir={context.dir}\n {...listProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n );\n }\n);\n\nTabsList.displayName = TAB_LIST_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger';\n\ntype TabsTriggerElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsTriggerProps extends PrimitiveDivProps {\n value: string;\n disabled?: boolean;\n}\n\nconst TabsTrigger = React.forwardRef<TabsTriggerElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const { __scopeTabs, value, disabled = false, ...triggerProps } = props;\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);\n const triggerId = makeTriggerId(context.baseId, value);\n const contentId = makeContentId(context.baseId, value);\n const isSelected = value === context.value;\n const handleTabChange = useCallbackRef(() => context.onValueChange(value));\n return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <Primitive.div\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n aria-disabled={disabled || undefined}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n id={triggerId}\n {...triggerProps}\n ref={forwardedRef}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (!disabled && (event.key === ' ' || event.key === 'Enter')) {\n handleTabChange();\n }\n })}\n onMouseDown={composeEventHandlers(props.onMouseDown, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n if (!disabled && event.button === 0 && event.ctrlKey === false) {\n handleTabChange();\n }\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual';\n if (!isSelected && !disabled && isAutomaticActivation) {\n handleTabChange();\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n }\n);\n\nTabsTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent';\n\ntype TabsContentElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsContentProps extends PrimitiveDivProps {\n value: string;\n}\n\nconst TabsContent = React.forwardRef<TabsContentElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, children, ...contentProps } = props;\n const context = useTabsContext(CONTENT_NAME, __scopeTabs);\n const triggerId = makeTriggerId(context.baseId, value);\n const contentId = makeContentId(context.baseId, value);\n const isSelected = value === context.value;\n return (\n <Primitive.div\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n hidden={!isSelected}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {isSelected && children}\n </Primitive.div>\n );\n }\n);\n\nTabsContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`;\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`;\n}\n\nconst Root = Tabs;\nconst List = TabsList;\nconst Trigger = TabsTrigger;\nconst Content = TabsContent;\n\nexport {\n createTabsScope,\n //\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n //\n Root,\n List,\n Trigger,\n Content,\n};\nexport type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps };\n"],"names":["createTabsContext","createTabsScope","createContextScope","createRovingFocusGroupScope","useRovingFocusGroupScope","TabsProvider","useTabsContext","Tabs","React","forwardRef","props","forwardedRef","__scopeTabs","value","valueProp","onValueChange","defaultValue","orientation","dir","activationMode","tabsProps","setValue","useControllableState","prop","onChange","defaultProp","_react","createElement","$b40a02b2d3d1d21ebd9ba3d555116441$var$TabsProvider","scope","baseId","useId","Primitive","div","_babelRuntimeHelpersEsmExtends","ref","TabsList","loop","listProps","context","rovingFocusGroupScope","_radixUiReactRovingFocus","Root","asChild","role","TabsTrigger","disabled","triggerProps","triggerId","makeTriggerId","contentId","makeContentId","isSelected","handleTabChange","useCallbackRef","Item","focusable","active","undefined","id","onKeyDown","composeEventHandlers","event","key","onMouseDown","button","ctrlKey","onFocus","isAutomaticActivation","TabsContent","children","contentProps","hidden","tabIndex","List","Trigger","Content"],"version":3,"file":"index.module.js.map"}
1
+ {"mappings":"6iBAiBA,MAGOA,EAAmBC,GAAmBC,EAH3B,OAGyD,CACzEC,iCAEF,MAAMC,EAA2BD,KAW1BE,EAAcC,GAAkBN,EAjBrB,eA+ClB,MAAMO,kBAAOC,EAAMC,YACjB,CAACC,EAA+BC,KAC9B,MAAMC,YACJA,EACAC,MAAOC,EAFHC,cAGJA,EAHIC,aAIJA,EAJIC,YAKJA,EAAc,aALVC,IAMJA,EAAM,MANFC,eAOJA,EAAiB,eACdC,GACDV,GAEGG,EAAOQ,GAAYC,EAAqB,CAC7CC,KAAMT,EACNU,SAAUT,EACVU,YAAaT,iBAG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,gBAAeN,EAAW,QAAKc,EAC/Bd,SAAUA,EACVe,GAAIb,GACAD,EATN,CAUEZ,IAAKxB,EAGLmD,QAASC,EAAqBrD,EAAMoD,QAAST,GAC7CW,YAAaD,EAAqBrD,EAAMsD,aAAcC,IAG/CnB,GAA6B,IAAjBmB,EAAMP,SAAkC,IAAlBO,EAAMC,SAC3Cb,OAGJc,QAASJ,EAAqBrD,EAAMyD,SAAS,KAG3C,MAAMC,EAAmD,WAA3B7B,EAAQpB,eACjCiC,GAAeN,IAAYsB,GAC9Bf,kCAsBd,MAAMgB,yBAAc7D,EAAMC,YACxB,CAACC,EAAsCC,KACrC,MAAMC,YAAEA,EAAFC,MAAeA,EAAfyD,SAAsBA,KAAaC,GAAiB7D,EACpD6B,EAAUjC,EAVC,cAU4BM,GACvCoC,EAAYC,EAAcV,EAAQT,OAAQjB,GAC1CqC,EAAYC,EAAcZ,EAAQT,OAAQjB,GAC1CuC,EAAavC,IAAU0B,EAAQ1B,mBACrC,OACEa,EAAAC,cAACK,EAAUC,IAAXC,EAAA,CACE,aAAYkB,EAAa,SAAW,WACpC,mBAAkBb,EAAQtB,YAC1B2B,KAAK,WACL,kBAAiBI,EACjBwB,QAASpB,EACTS,GAAIX,EACJuB,SAAU,GACNF,EARN,CASEpC,IAAKxB,IAEJyC,GAAckB,mBAUvB,SAASrB,EAAcnB,EAAgBjB,GACrC,MAAQ,GAAEiB,aAAkBjB,IAG9B,SAASsC,EAAcrB,EAAgBjB,GACrC,MAAQ,GAAEiB,aAAkBjB,WAG9B,MAAM6B,KAAOnC,YACb,MAAMmE,KAAOtC,gBACb,MAAMuC,QAAU9B,mBAChB,MAAM+B,QAAUP","sources":["./packages/react/tabs/src/Tabs.tsx"],"sourcesContent":["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { useId } from '@radix-ui/react-id';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs';\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope };\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\n\ntype TabsContextValue = {\n baseId: string;\n value?: string;\n onValueChange: (value: string) => void;\n orientation?: TabsProps['orientation'];\n dir?: TabsProps['dir'];\n activationMode?: TabsProps['activationMode'];\n};\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME);\n\ntype TabsElement = React.ElementRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface TabsProps extends PrimitiveDivProps {\n /** The value for the selected tab, if controlled */\n value?: string;\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string;\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void;\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation'];\n /**\n * The direction of navigation between toolbar items.\n * @defaultValue ltr\n */\n dir?: RovingFocusGroupProps['dir'];\n /** \n * Whether a tab is activated automatically or manually.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual';\n}\n\nconst Tabs = React.forwardRef<TabsElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir = 'ltr',\n activationMode = 'automatic',\n ...tabsProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue,\n });\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={useId()}\n value={value}\n onValueChange={setValue}\n orientation={orientation}\n dir={dir}\n activationMode={activationMode}\n >\n <Primitive.div data-orientation={orientation} {...tabsProps} ref={forwardedRef} />\n </TabsProvider>\n );\n }\n);\n\nTabs.displayName = TABS_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList';\n\ntype TabsListElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsListProps extends PrimitiveDivProps {\n loop?: RovingFocusGroupProps['loop'];\n}\n\nconst TabsList = React.forwardRef<TabsListElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, ...listProps } = props;\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);\n return (\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n >\n <Primitive.div\n role=\"tablist\"\n aria-orientation={context.orientation}\n dir={context.dir}\n {...listProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n );\n }\n);\n\nTabsList.displayName = TAB_LIST_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger';\n\ntype TabsTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface TabsTriggerProps extends PrimitiveButtonProps {\n value: string;\n}\n\nconst TabsTrigger = React.forwardRef<TabsTriggerElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const { __scopeTabs, value, disabled = false, ...triggerProps } = props;\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);\n const triggerId = makeTriggerId(context.baseId, value);\n const contentId = makeContentId(context.baseId, value);\n const isSelected = value === context.value;\n const handleTabChange = useCallbackRef(() => context.onValueChange(value));\n return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <Primitive.button\n type=\"button\"\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n {...triggerProps}\n ref={forwardedRef}\n // Handle anything that the browser considers a click for the element type if\n // not using pointer e.g. Space keyup and Enter keydown\n onClick={composeEventHandlers(props.onClick, handleTabChange)}\n onMouseDown={composeEventHandlers(props.onMouseDown, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n if (!disabled && event.button === 0 && event.ctrlKey === false) {\n handleTabChange();\n }\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual';\n if (!isSelected && !disabled && isAutomaticActivation) {\n handleTabChange();\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n }\n);\n\nTabsTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent';\n\ntype TabsContentElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsContentProps extends PrimitiveDivProps {\n value: string;\n}\n\nconst TabsContent = React.forwardRef<TabsContentElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, children, ...contentProps } = props;\n const context = useTabsContext(CONTENT_NAME, __scopeTabs);\n const triggerId = makeTriggerId(context.baseId, value);\n const contentId = makeContentId(context.baseId, value);\n const isSelected = value === context.value;\n return (\n <Primitive.div\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n hidden={!isSelected}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {isSelected && children}\n </Primitive.div>\n );\n }\n);\n\nTabsContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`;\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`;\n}\n\nconst Root = Tabs;\nconst List = TabsList;\nconst Trigger = TabsTrigger;\nconst Content = TabsContent;\n\nexport {\n createTabsScope,\n //\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n //\n Root,\n List,\n Trigger,\n Content,\n};\nexport type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps };\n"],"names":["createTabsContext","createTabsScope","createContextScope","createRovingFocusGroupScope","useRovingFocusGroupScope","TabsProvider","useTabsContext","Tabs","React","forwardRef","props","forwardedRef","__scopeTabs","value","valueProp","onValueChange","defaultValue","orientation","dir","activationMode","tabsProps","setValue","useControllableState","prop","onChange","defaultProp","_react","createElement","$b40a02b2d3d1d21ebd9ba3d555116441$var$TabsProvider","scope","baseId","useId","Primitive","div","_babelRuntimeHelpersEsmExtends","ref","TabsList","loop","listProps","context","rovingFocusGroupScope","_radixUiReactRovingFocus","Root","asChild","role","TabsTrigger","disabled","triggerProps","triggerId","makeTriggerId","contentId","makeContentId","isSelected","handleTabChange","useCallbackRef","Item","focusable","active","button","type","undefined","id","onClick","composeEventHandlers","onMouseDown","event","ctrlKey","onFocus","isAutomaticActivation","TabsContent","children","contentProps","hidden","tabIndex","List","Trigger","Content"],"version":3,"file":"index.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-tabs",
3
- "version": "0.1.2-rc.1",
3
+ "version": "0.1.2-rc.13",
4
4
  "license": "MIT",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -19,9 +19,9 @@
19
19
  "@babel/runtime": "^7.13.10",
20
20
  "@radix-ui/primitive": "0.1.0",
21
21
  "@radix-ui/react-context": "0.1.1",
22
- "@radix-ui/react-id": "0.1.1",
23
- "@radix-ui/react-primitive": "0.1.1",
24
- "@radix-ui/react-roving-focus": "0.1.2-rc.1",
22
+ "@radix-ui/react-id": "0.1.2-rc.4",
23
+ "@radix-ui/react-primitive": "0.1.2-rc.3",
24
+ "@radix-ui/react-roving-focus": "0.1.2-rc.13",
25
25
  "@radix-ui/react-use-callback-ref": "0.1.0",
26
26
  "@radix-ui/react-use-controllable-state": "0.1.0"
27
27
  },