import{j as o}from"./jsx-runtime-CnH95YSl.js";import{f as K}from"./index-BJMTVygn.js";import{r as s}from"./index-NdkWRN8K.js";import{O as Q}from"./OdysseyStorybookThemeDecorator-BuDiOG2V.js";import{d as U,c as X,f as Z,r as ee}from"./personData-BYPP3apv.js";import{p as oe}from"./constants-CyailK6t.js";import{M as D}from"./DataView-C5rMFmwA.js";import{M as u}from"./MenuItem-CmSG6PNu.js";import{M as te}from"./Box-1mvP3NLW.js";import{M as d}from"./Button-BEA5U6Tg.js";import{M as f}from"./EmptyState-CpBEzmap.js";import{d as ae}from"./constants-CGUp4oSR.js";import{M as ne,a as se}from"./Refresh-DexPEklu.js";/*!
 * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const ie=({additionalActionButton:t,additionalActionMenuItems:e,bulkActionMenuItems:i,columns:n,currentPage:r,emptyPlaceholder:a,errorMessage:l,filters:I,getData:x,hasChangeableDensity:m,hasColumnResizing:h,hasColumnVisibility:g,initialDensity:b,hasFilters:T,hasPagination:j,hasRowReordering:B,hasRowSelection:O,hasSearch:N,hasSearchSubmitButton:k,hasSorting:R,isLoading:L,isEmpty:v,isNoResults:E,isPaginationMoreDisabled:z,isRowReorderingDisabled:Y,maxResultsPerPage:F,maxPages:V,noResultsPlaceholder:H,onChangeRowSelection:_,paginationType:$,renderDetailPanel:p,resultsPerPage:W,rowActionButtons:y,rowActionMenuItems:P,searchDelayTime:q,totalRows:G})=>{const J=s.useMemo(()=>({columns:n,hasChangeableDensity:m,hasColumnResizing:h,hasColumnVisibility:g,hasSorting:R,initialDensity:b,renderDetailPanel:p,rowActionButtons:y,rowActionMenuItems:P}),[n,m,h,g,R,b,p,y,P]);return o.jsx(D,{additionalActionButton:t,additionalActionMenuItems:e,availableLayouts:["table"],bulkActionMenuItems:i,currentPage:r,emptyPlaceholder:a,errorMessage:l,filters:I,getData:x,hasFilters:T,hasPagination:j,hasRowReordering:B,hasRowSelection:O,hasSearch:N,hasSearchSubmitButton:k,isEmpty:v,isLoading:L,isNoResults:E,isPaginationMoreDisabled:z,isRowReorderingDisabled:Y,maxPages:V,maxResultsPerPage:F,noResultsPlaceholder:H,onChangeRowSelection:_,paginationType:$,resultsPerPage:W,searchDelayTime:q,tableLayoutOptions:J,totalRows:G})},C=s.memo(ie);C.displayName="DataTable";const re={component:D,decorators:[Q],argTypes:{getData:{table:{type:{summary:""}}},getRowId:{table:{type:{summary:""}}},hasRowReordering:{control:"boolean",table:{type:{summary:""}}},isRowReorderingDisabled:{control:"boolean"},onReorderRows:{table:{type:{summary:""}}},hasRowSelection:{control:"boolean"},onChangeRowSelection:{},bulkActionMenuItems:{},hasPagination:{control:"boolean"},currentPage:{control:"number"},paginationType:{control:"select",options:oe},resultsPerPage:{control:"number"},totalRows:{control:"number"},hasFilters:{control:"boolean"},hasSearch:{control:"boolean"},hasSearchSubmitButton:{control:"boolean"},filters:{},searchDelayTime:{control:"number"},errorMessage:{control:"text"},emptyPlaceholder:{},noResultsPlaceholder:{},columns:{},initialDensity:{control:"select",options:ae},hasChangeableDensity:{control:"boolean"},hasColumnResizing:{control:"boolean"},hasColumnVisibility:{control:"boolean"},renderDetailPanel:{},rowActionButtons:{},tableRowActionMenuItems:{},hasSorting:{control:"boolean"},isLoading:{control:"boolean"},isEmpty:{control:"boolean"},isNoResults:{control:"boolean"},isPaginationMoreDisabled:{control:"boolean",description:"If true, the pagination next or show more button will be disabled.",table:{type:{summary:"boolean"}}},hasCustomEmptyPlaceholder:{control:"boolean",name:"[STORY ONLY] Has custom empty placeholder?"},hasCustomNoResultsPlaceholder:{control:"boolean",name:"[STORY ONLY] Has custom 'no results' placeholder?"},hasActionMenuItems:{control:"boolean",name:"[STORY ONLY] Has action menu items?"},hasActionButtons:{control:"boolean",name:"[STORY ONLY] Has action buttons in table view?"},hasAdditionalActionButton:{control:"boolean",name:"[STORY ONLY] Has additional action button?"},hasAdditionalActionMenuItems:{control:"boolean",name:"[STORY ONLY] Has additional action menu items?"}},args:{onChangeRowSelection:K()}},le=(t,e)=>{const i=s.useCallback(({...a})=>Z({data:t,...a}),[t]),n=s.useCallback(({...a})=>{const l=ee({data:t,...a});e(l)},[t,e]),r=s.useCallback(a=>{Object.keys(a).length>0&&console.log(`${Object.keys(a).length} selected`)},[]);return{getData:i,onReorderRows:n,onChangeRowSelection:r}},S=t=>o.jsxs(o.Fragment,{children:[o.jsx(u,{onClick:()=>console.log(t),children:"Action 1"}),o.jsx(u,{onClick:()=>console.log(t),children:"Action 2"})]}),ce=()=>o.jsxs(te,{sx:{display:"flex",alignItems:"center",marginInlineEnd:2},children:[o.jsx(d,{ariaLabel:"Pause",endIcon:o.jsx(ne,{}),size:"small",variant:"floating"}),o.jsx(d,{ariaLabel:"Refresh",endIcon:o.jsx(se,{}),size:"small",variant:"floating"})]}),de=o.jsx(d,{label:"Add widget",variant:"primary"}),ue=o.jsxs(o.Fragment,{children:[o.jsx(u,{onClick:()=>console.log("Action 1"),children:"Action 1"}),o.jsx(u,{onClick:()=>console.log("Action 2"),children:"Action 2"})]}),me=o.jsx(f,{description:"All relevant data will be displayed and can be searched and filtered",heading:"Start by adding data assets",PrimaryCallToActionComponent:o.jsx(d,{label:"Primary",variant:"primary"}),SecondaryCallToActionComponent:o.jsx(d,{label:"Secondary",variant:"secondary"})}),he=o.jsx(f,{description:"You should try searching or filtering for something else.",heading:"Whoops, there's nothing here!"}),c={render:function(e){const[i,n]=s.useState(U),{getData:r,onReorderRows:a,onChangeRowSelection:l}=le(i,n);return o.jsx(C,{additionalActionButton:e.hasAdditionalActionButton?de:void 0,additionalActionMenuItems:e.hasAdditionalActionMenuItems?ue:void 0,bulkActionMenuItems:e.hasActionMenuItems?S:void 0,columns:X,currentPage:e.currentPage,emptyPlaceholder:e.hasCustomEmptyPlaceholder?me:void 0,errorMessage:e.errorMessage,getData:r,hasChangeableDensity:e.hasChangeableDensity,hasColumnResizing:e.hasColumnResizing,hasColumnVisibility:e.hasColumnVisibility,hasFilters:e.hasFilters,hasPagination:e.hasPagination,hasRowReordering:e.hasRowReordering,hasRowSelection:e.hasRowSelection,hasSearch:e.hasSearch,hasSearchSubmitButton:e.hasSearchSubmitButton,hasSorting:e.hasSorting,initialDensity:e.initialDensity,isEmpty:e.isEmpty,isLoading:e.isLoading,isNoResults:e.isNoResults,isRowReorderingDisabled:e.isRowReorderingDisabled,noResultsPlaceholder:e.hasCustomNoResultsPlaceholder?he:void 0,onChangeRowSelection:l,onReorderRows:a,paginationType:e.paginationType,resultsPerPage:e.resultsPerPage,rowActionButtons:e.hasActionButtons?ce:void 0,rowActionMenuItems:e.hasActionMenuItems?S:void 0,searchDelayTime:e.searchDelayTime,totalRows:e.totalRows})}};var A,M,w;c.parameters={...c.parameters,docs:{...(A=c.parameters)==null?void 0:A.docs,source:{originalSource:`{
  render: function C(args) {
    const [data, setData] = useState<Person[]>(personData);
    const {
      getData,
      onReorderRows,
      onChangeRowSelection
    } = useDataCallbacks(data, setData);
    return <DataTable additionalActionButton={args.hasAdditionalActionButton ? additionalActionButton : undefined} additionalActionMenuItems={args.hasAdditionalActionMenuItems ? additionalActionMenuItems : undefined} bulkActionMenuItems={args.hasActionMenuItems ? actionMenuItems : undefined} columns={personColumns} currentPage={args.currentPage} emptyPlaceholder={args.hasCustomEmptyPlaceholder ? customEmptyPlaceholder : undefined} errorMessage={args.errorMessage} getData={getData} hasChangeableDensity={args.hasChangeableDensity} hasColumnResizing={args.hasColumnResizing} hasColumnVisibility={args.hasColumnVisibility} hasFilters={args.hasFilters} hasPagination={args.hasPagination} hasRowReordering={args.hasRowReordering} hasRowSelection={args.hasRowSelection} hasSearch={args.hasSearch} hasSearchSubmitButton={args.hasSearchSubmitButton} hasSorting={args.hasSorting} initialDensity={args.initialDensity} isEmpty={args.isEmpty} isLoading={args.isLoading} isNoResults={args.isNoResults} isRowReorderingDisabled={args.isRowReorderingDisabled} noResultsPlaceholder={args.hasCustomNoResultsPlaceholder ? customNoResultsPlaceholder : undefined} onChangeRowSelection={onChangeRowSelection} onReorderRows={onReorderRows} paginationType={args.paginationType} resultsPerPage={args.resultsPerPage} rowActionButtons={args.hasActionButtons ? actionButtons : undefined} rowActionMenuItems={args.hasActionMenuItems ? actionMenuItems : undefined} searchDelayTime={args.searchDelayTime} totalRows={args.totalRows} />;
  }
}`,...(w=(M=c.parameters)==null?void 0:M.docs)==null?void 0:w.source}}};const ge=["Default"],xe=Object.freeze(Object.defineProperty({__proto__:null,Default:c,__namedExportsOrder:ge,default:re},Symbol.toStringTag,{value:"Module"}));export{xe as D};
