nextui/apps/docs/content/components/table/custom-styles.ts
Junior Garcia f283b2c67e
v2.4.5 (#3509)
* chore(root): reat-aria packages updated (#2889)

* chore(storybook): common colors enabled (#2902)

* fix(range-calendar): hide only dates outside the month (#2906)

* fix(range-calendar): hide only dates outside the month #2890

* fix(range-calendar): corrected spelling mistake in changeset description

* fix(range-calendar): corrected capitalization in changeset description

* chore(changeset): patch @nextui-org/theme

---------

Co-authored-by: shrinidhi.upadhyaya <shrinidhi.upadhyaya@stud.uni-bamberg.de>
Co-authored-by: աɨռɢӄաօռɢ <wingkwong.code@gmail.com>

* fix(date-picker): keep date picker style consistent for different variants (#2908)

* fix: add missing TableRowProps export (#2866)

* fix: add missing TableRowProps export

* feat(changeset): add changeset for PR2866

* chore(changeset): revise changeset message

---------

Co-authored-by: աɨռɢӄաօռɢ <wingkwong.code@gmail.com>

* fix(input): correct label margin for RTL required inputs (#2781)

* fix(input): correct label margin for RTL required inputs

* fix(theme): add changeset fr theme

* docs(core): add storybook and canary release info (#2914)

* Cn utility refactor (#2915)

* refactor(core): cn utility adjusted and moved to the theme package

* chore(root): changeset

* fix(storybook): stories that used cn

* docs(date-picker): change to jsx instead (#2919)

* fix(switch): support uncontrolled switch in react-hook-form (#2924)

* feat(switch): add @nextui-org/use-safe-layout-effect

* chore(deps): add @nextui-org/use-safe-layout-effect

* fix(switch): react-hook-form uncontrolled switch component

* fix(switch): react-hook-form uncontrolled switch component

* feat(switch): add rect-hook-form in dev dep

* feat(switch): add WithReactHookFormTemplate

* refactor(root): react aria packages fixed (#2944)

* feat(docs): docs changes (#2868)

* feat(docs): add example how to set locale (#2867)

* docs(guide): add an explanation for the installation guide (#2769)

* docs(guide): add an explanation for the installation guide

* docs(guide): add an explanation for the cli guide

* docs(guide): add support for cli output

* fix: change sort priority - cmdk (#2873)

* docs: remove unsupported props in range calendar and date range picker (#2881)

* chore(calendar): remove showMonthAndYearPickers from range calendar story

* docs(date-range-picker): remove showMonthAndYearPickers info

* docs(range-calendar): remove unsupported props

* docs: refactor typing in form.ts (#2882)

* chore(docs): supplement errorMessage behaviour in input (#2892)

* refactor(docs): revise NextUI Provider structure

* chore(docs): add updated tag

---------

Co-authored-by: Nozomi-Hijikata <116155762+Nozomi-Hijikata@users.noreply.github.com>
Co-authored-by: HaRuki <soccer_haruki15@me.com>
Co-authored-by: Kaben <carnoxen@gmail.com>

* fix(slider): missing marks when hideThumb is true & revise slider styles (#2883)

* chore(slider): include marks in hideThumb

* fix(slider): revise slider styles

* feat(changeset): add changeset

* feat(slider): add tests with marks and hideThumb

* feat(test): react hook form tests & stories (#2931)

* feat(input): add Input with React Hook Form tests

* refactor(input): add missing types

* feat(checkbox): add checkbox with React Hook Form tests

* feat(select): add react-hook-form to dev dep

* feat(select): add react hook form story

* feat(select): react hook form tests

* fix(select): incorrect button reference

* feat(deps): add react-hook-form to dev dep in autocomplete

* feat(autocomplete): react hook form story

* feat(autocomplete): react hook form tests

* fix(autocomplete): rollback wrapper type

* feat(switch): add react hook form tests

* refactor(stories): reorder stories items

* fix: update accordion item heading tag to be customizable (#2265)

* fix: update accordion item heading tag to be customizable

* Update .changeset/heavy-hairs-join.md

Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>

* Update .changeset/heavy-hairs-join.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* chore(accordion): lint

* chore(changeset): add issue number

* feat(docs): add HeadingComponent prop

---------

Co-authored-by: Shawn Dong <shawn.dong@flybuys.com.au>
Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: աɨռɢӄաօռɢ <wingkwong.code@gmail.com>

* fix(theme): add pointer-events-none to skeleton base (#2972)

* feat(tabs): add `destroyInactiveTabPanel` prop for Tabs component (#2973)

* feat(tabs): add destroyInactiveTabPanel and set default to false

* feat(tabs): integrate with destroyInactiveTabPanel

* feat(theme): hidden inert tab panel

* feat(changeset): add changeset

* chore(changeset): add issue number

* feat(docs): add `destroyInactiveTabPanel` prop to tabs page

* chore(docs): set destroyInactiveTabPanel to true by default

* chore(tabs): set destroyInactiveTabPanel to true by default

* chore(tabs): revise destroyInactiveTabPanel logic

* feat(tabs): add tests for destroyInactiveTabPanel

* chore(tabs): change the default value of destroyInactiveTabPanel to true

* refactor: add support for disabling the animation globally (#2929)

* refactor: add support for disabling the animation globally

* chore(docs): disableAnimation removed from global provider

* feat(docs): nextui provider api updated, storybook preview adjusted

* chore(theme): button is scalable when disabled, tooltip animation improved

* fix(theme): remove origin-bottom from button (#2990)

* fix(skeleton): overflow issue in skeleton (#2986)

* fix(theme): set overflow visible after skeleton loaded

* feat(changeset): add changeset

* fix(table): v2 input/textarea don't allow spaces inside a table (#3020)

* fix(table): set onKeyDownCapture to undefined

* feat(changeset): add changeset

* fix(slider): calculate the correct value on mark click (#3017)

* fix(slider): calculate the correct value on mark click

* refactor(slider): remove the tests inside describe block

* feat(slider): add tests for thumb move on mark click

* refactor(slider): use val instead of pos

* fix(theme): revise input isInvalid styles (#3010)

* fix(theme): revise isInvalid input styles

* feat(changeset): add changeset

* feat(date-picker): add missing ref to input wrapper (#3011)

* fix(date-picker): add missing ref to input wrapper

* feat(changeset): add changeset

* fix(core): incorrect tailwind classnames (#3018)

* fix(dropdown): focus behaviour on press / enter keydown (#2970)

* fix(dropdown): set focus on the first item

* feat(dropdown): add keyboard interactions tests

* feat(changeset): add changeset

* fix(dropdown): use fireEvent.keyDown instead

* chore(deps): add @nextui-org/test-utils to dropdown

* refactor(dropdown): pass onKeyDown to menu trigger and don't hardcode autoFocus

* chore(dropdown): remove autoFocus

* fix(menu): pass userMenuProps to useTreeState and useAriaMenu and remove from getListProps

* chore(changeset): add menu package

* fix(component): update type definition to prevent primitive values as items (#2953)

* fix: update type definition to prevent primitive values as items

* fix: typecheck

* fix(select): onSelectionChange can handle number (#2937)

* fix: onSelectionChange type for dynamic items in Select component

* docs: remove unnecessary properties

* docs: update highlightedLines

* chore: add changeset

* fix(calendar): scrolling is hidden when changing the month (#2949)

* fix(calendar): scrolling is hidden when changing the month

* chore(changeset): correct package name

---------

Co-authored-by: Poli Sour <polisour.work@gmail.com>
Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix: make VisuallyHidden's element type as span when it's inside phrasing element (#3013)

* fix(checkbox): make VisuallyHidden's element type as span

* feat(changeset): add changeset

* fix(radio): make the VisuallyHidden element type as span

* fix(switch): make the VisuallyHidden element type as span

* fix(select): make the VisuallyHidden element type as span

* feat(changeset): replace changeset

* chore: fix formatting

* docs: sync nextui-cli  api (#3035)

* docs: sync nextui-cli  api

* docs: update

* chore: update routes.json with new path and set updated flag

---------

Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>

* feat: switch default validationBehavior to aria and allow switching via props (#2987)

* chore: add support validationBehavior aria

* chore: add validationBehavior to Provider

* chore: add autocomplete validation test

* chore: add checkbox validation test

* fix(input): require condition

* docs: add description of validationBehavior props

* chore: add support validationBehavior props for date components

* docs(dates): add description of validationBehavior props

* chore: add changeset

* chore: format

* chore: fix test

* fix: select validationBehavior is not support yet

* fix: select validationBehavior not supported yet

* chore(docs): validation behavior prop added to nextui-provider

---------

Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>

* fix: popover-based focus behaviour (#2854)

* fix(autocomplete): autocomplete focus behaviour

* feat(autocomplete): add test case for catching blur cases

* refactor(autocomplete): use isOpen instead

* feat(autocomplete): add "should focus when clicking autocomplete" test case

* feat(autocomplete): add should set the input after selection

* fix(autocomplete): remove shouldUseVirtualFocus

* fix(autocomplete): uncomment blur logic

* refactor(autocomplete): remove state as it is in getPopoverProps

* refactor(autocomplete): remove unnecessary blur

* refactor(select): remove unncessary props

* fix(popover): use domRef instead

* fix(popover): revise isNonModal and isDismissable

* fix(popover): use dialogRef back

* fix(popover): rollback

* fix(autocomplete): onFocus logic

* feat(popover): set disableFocusManagement to overlay

* feat(modal): set disableFocusManagement to overlay

* fix(autocomplete): set disableFocusManagement for autocomplete

* feat(popover): include disableFocusManagement prop

* refactor(autocomplete): revise type in selectorButton

* fix(autocomplete): revise focus logic

* feat(autocomplete): add internal focus state and add shouldCloseOnInteractOutside

* feat(autocomplete): handle selectedItem change

* feat(autocomplete): add clear button test

* feat(changeset): add changeset

* refactor(components): use the original order

* refactor(autocomplete): add more comments

* fix(autocomplete): revise focus behaviours

* refactor(autocomplete): rename to listbox

* chore(popover): remove disableFocusManagement from popover

* chore(autocomplete): remove disableFocusManagement from autocomplete

* chore(changeset): add issue number

* fix(popover): don't set default value to transformOrigin

* fix(autocomplete): revise shouldCloseOnInteractOutside logic

* feat(autocomplete): should close listbox by clicking another autocomplete

* fix(popover): add disableFocusManagement to overlay

* refactor(autocomplete): revise comments and refactor shouldCloseOnInteractOutside

* feat(changeset): add issue number

* fix(autocomplete): merge with selectorButtonProps.onClick

* refactor(autocomplete): remove extra line

* refactor(autocomplete): revise comment

* feat(select): add shouldCloseOnInteractOutside

* feat(dropdown): add shouldCloseOnInteractOutside

* feat(date-picker): add shouldCloseOnInteractOutside

* feat(changeset): add dropdown and date-picker

* fix(popover): revise shouldCloseOnInteractOutside

* feat(date-picker): integrate with ariaShouldCloseOnInteractOutside

* feat(select): integrate with ariaShouldCloseOnInteractOutside

* feat(dropdown): integrate with ariaShouldCloseOnInteractOutside

* feat(popover): integrate with ariaShouldCloseOnInteractOutside

* feat(aria-utils): ariaShouldCloseOnInteractOutside

* chore(deps): update pnpm-lock.yaml

* feat(autocomplete): integrate with ariaShouldCloseOnInteractOutside

* feat(aria-utils): handle setShouldFocus logic

* feat(changeset): add @nextui-org/aria-utils

* chore(autocomplete): put the test into correct group

* feat(select): should close listbox by clicking another select

* feat(dropdown): should close listbox by clicking another dropdown

* feat(popover): should close listbox by clicking another popover

* feat(date-picker): should close listbox by clicking another datepicker

* chore(changeset): add issue numbers and revise changeset message

* refactor(autocomplete): change to useRef instead

* refactor(autocomplete): change to useRef instead

* refactor(aria-utils): revise comments and format code

* chore(changeset): add issue number

* chore: take popoverProps.shouldCloseOnInteractOutside first

* refactor(autocomplete): remove unnecessary logic

* refactor(autocomplete): focus management logic

* fix(components): Fix 'Tap to click' behavior on macOS with Edge/Chrome for Accordion and Tab (#2725)

* fix(components): fix 'Tap to click' behavior on macOS

* Add change file for accordion, menu, and tabs

* Remove 'fix(components)' from the .changeset file

* fix(components): undo dropdown change now that it's no longer applicable

* fix(components): update changeset file now that we are no longer modifying the dropdown component

* fix(date-picker): corrected inert value for true condition (#3054)

* fix(date-picker): corrected inert value for true condition #3044

* refactor(calendar): add todo comment

* feat(changeset): add changeset

---------

Co-authored-by: shrinidhi.upadhyaya <shrinidhi.upadhyaya@stud.uni-bamberg.de>
Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix(hooks): resolve type error in onKeyDown event handler (#3064)

* fix(hooks): resolve type error in onKeyDown event handler

* chore(changeset): revise changeset

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* Update dependency array on setPage useCallback hook (#3029)

Changes:
Add the onChangeActivePage function to the dependency array of the setPage useCallback hook to ensure it always reflects the latest state.

Impact:
This fix ensures that the pagination component accurately reflects the current state when triggering onChangeActivePage.

* fix: error peerDep in pkg (#3014)

* fix: error peerDep in pkg

* docs: changeset

* Fix DatePicker Time Input (#2845)

* fix(date-picker): set `isCalendarHeaderExpanded` to `false` when DatePicker is closed

* fix(date-picker): calendar header controlled state on DatePicker

* chore(date-picker): update test

* chore(date-picker): remove unnecessary `async` in test

* Update packages/components/date-picker/__tests__/date-picker.test.tsx

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>
Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>

* fix(date-picker): test

* fix(hooks): optimize useScrollPosition with useCallback and useRef (#3049)

* fix(hooks): optimize useScrollPosition with useCallback and useRef

* Update .changeset/lucky-cobras-jog.md

* Update packages/hooks/use-scroll-position/src/index.ts

* Update packages/hooks/use-scroll-position/src/index.ts

---------

Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>

* fix(select): placeholder text display for controlled component (#3081)

* fix: return placeholder when selectedItems is empty

* chore: add test and changeset

* chore(docs): v2.4.0 (#3084)

* chore(docs): v2.4.0

* chore(docs): v2.4.0 blog

* chore(docs): revise typos based on coderabbitai

* chore(docs): adjust navbar

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* chore(changese): update @nextui-org/react dependency to minor version

* docs: update cli docs (#3096)

* ci(changesets): version packages (#2903)

Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>

* fix(radio): remove required attribute for Radio with validationBehavior="aria" (#3110)

* fix(theme): add missing pointer event after data loaded (#3126)

* fix(system): listbox href issue (experimental) (#3119)

* fix(system): @react-aria/utils

* feat(hooks): include routerLinkProps

* feat(changeset): add changeset

* chore(deps): bump @react-aria/utils to 3.24.1

* fix(hooks): missing arguments

* chore(deps): bump @react-types/link

* chore(link): bump @react-aria/link to 3.7.1

* chore(link): use @react-aria/link instead

* chore(changeset): revise changeset

* chore(hooks): undo use-aria-link changes

* chore(deps): undo use-aria-link changes

* chore(deps): bump `@react-aria/utils` to `3.24.1`

* chore(deps): bump `@react-types/shared`

* feat: add missing router.open parameters due to router change

* chore(changeset): add new line

* chore(deps): bump `@react-types/shared` to `3.23.1`

* fix(avatar): avoid passing `disableAnimation` prop to a DOM element (#3111)

* fix(avatar): avoid passing `disableAnimation` prop to a DOM element

* refactor(avatar): use filterDOMProps approach

* chore(avatar): remove to type import

* chore(avatar): change to shouldFilterDOMProps

* fix(docs): removed unused import & corrected prop for disabled DatePicker (#3136)

Co-authored-by: shrinidhi.upadhyaya <shrinidhi.upadhyaya@stud.uni-bamberg.de>

* ci(changesets): version packages (#3115)

* fix(pagination): missing animation (#3144)

* fix tsup domain (#3158)

* chore(docs): remove destroyInactiveTabPanel from Tab due to merge conflict (#3155)

* fix(autocomplete): maximum update depth exceeded in autocomplete (#3175)

* chore(checkbox): avoid passing non-DOM attributes to svg  (#3199)

* chore(docs): avoid passing non-DOM attributes to svg

* chore(utilities): avoid passing non-DOM attributes to svg

* feat(changeset): add changeset

* fix(docs): fix typo in autocomplete documentation page (#3182)

* fix(select): add missing data-invalid in select and add missing data attributes in docs (#3177)

* fix(select): add missing data-invalid attribute

* chore(docs): add missing data attributes for select base

* fix(tabs): destroyInactiveTabPanel unmounts inactive tabs' content (#3164)

* fix(tabs): incorrect content in tab panel

* feat(tabs): revise destroyInactiveTabPanel test cases

* fix(select): unset form value after unselecting an item (#3157)

* fix(select): set empty string instead of undefined for unsetting value

* feat(selet): should unset form value

* fix(tabs): set tab panel id correctly (#3246)

* docs(tooltip): supplement correct style path (#3183)

* docs(tooltip): supplement correct style path

* chore(docs): move the note below import tabs

* fix(use-aria-menu): link logic in useMenuItem (#3229)

* chore(deps): bump @internationalized/date version (#3230)

* fix(input): input display with hidden type (#3174)

* fix(input): input display with hidden type

* chore(input): add isHiddenType to dependency

* refactor(input): move the styles to theme and change hidden to data attr

* feat(theme): add isHiddenType to input

* chore(changeset): include theme package

* chore(input): revise input test

* fix(theme): remove isHiddenType from variants and use data-hidden prop instead

* fix(theme): remove isHiddenType from defaultVariants

* fix(input): remove isHiddenType passing to input

* feat(date-picker): add support for DatePicker to apply styles to DateInput (#3146)

* feat(date-picker): add support for DatePicker to apply styles to DateInput

* chore: update changeset

* docs(date-picker): add dateInputClassNames props

* refactor(date): updated errorMessage story and modified to import props (#3112)

* refactor(date): updated errorMessage story and modified to import props

* docs(date): add errorMessageFunction examples

* chore: add changeset

* fix: remove unnecessary props

* fix: typo

* Update regex-validation.ts (#3123)

* Update regex-validation.ts

Fix email regex

* Update email regex input.stories.tsx

* fix(autocomplete): controlled state logic (#2969)

* fix(autocomplete): autocomplete controlled state (#2955)

* chore(autocomplete): add changeset

* Update packages/components/autocomplete/__tests__/autocomplete.test.tsx

---------

Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>

* fix(utilities): resolve assignRef TypeScript ref assignment issue (#3098)

* fix(utilities): resolve assignRef TypeScript ref assignment issue

* chore(changeset): revise changeset message

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix(table): table-column align prop (#2900)

* fix(navbar): fixed the height of navbar menu (#1805)

* fix(navbar): fixed the height of navbar menu

* fix(navbar): refactored the css of navbar

* fix(navbar): fix redundant expression

* fix(navbar): fixed unnecessary changes

* fix(navbar): adjust viewport

* fix: RA dependencies bump (#3240)

* fix(popover): popover focus issue (#3187)

* fix(popover): move useDialog to popover-content

* fix(popover): move useDialog to free-solo-popover

* refactor(popover): use const instead

* feat(changset): add changeset

* feat(popover): popover focus test

* refactor(popover): getDialogProps

* fix: interactions with popover & focus issues (#3137)

* fix(aria-utils): handle click on listbox

* fix(popover): move useDialog to popover-content

* fix(popover): move useDialog to free-solo-popover

* refactor(popover): use const instead

* feat(changset): add changeset

* feat(popover): popover focus test

* refactor(popover): getDialogProps

* chore(utilities): remove ariaShouldCloseOnInteractOutside

* chore(deps): pnpm-lock.yaml

* fix(popover): remove disableFocusManagement

* fix(modal): remove disableFocusManagement

* fix(autocomplete): remove custom focus logic and remove ariaShouldCloseOnInteractOutside

* fix(popover): rewrite shouldCloseOnInteractOutside logic

* chore(utilities): remove ariaShouldCloseOnInteractOutside

* chore(deps): bump react-aria dependencies

* chore(autocomplete): change back to focus

* feat(changeset): update changeset

* chore(docs): update type in onSelectionChange

* fix(popover): revise popover test case

* chore(deps): add @nextui-org/aria-utils

* fix(autocomplete): add ariaShouldCloseOnInteractOutside

* fix(date-picker): add ariaShouldCloseOnInteractOutside

* fix(select): add ariaShouldCloseOnInteractOutside

* chore(deps): add @nextui-org/aria-utils

* fix(dropdown): add ariaShouldCloseOnInteractOutside

* feat(utilities): rewrite ariaShouldCloseOnInteractOutside

* fix(popover): use ariaShouldCloseOnInteractOutside

* fix(autocomplete): add back shouldFocus

* fix(utilities): include shouldFocus logic

* chore(utilities): remove !

* refactor(aria-utils): add more comments

* chore(changeset): update packages

* refactor(aria-utils): add more comments

* feat(popover): add test

* fix: dropdown onPress issue (#3211)

* fix(popover): move useDialog to popover-content

* fix(popover): move useDialog to free-solo-popover

* refactor(popover): use const instead

* feat(changset): add changeset

* feat(popover): popover focus test

* refactor(popover): getDialogProps

* fix(popover): dropdown onPress blocking issue

* fix(dropdown): incorrect keyCodes

* feat(dropdown): add keyboard onPress test cases

* chore(deps): keep all @react-aria/overlays version consistent

* chore(deps): sync dependencies

* chore(deps): sync dependencies

* refactor(aria-utils): remove shouldFocus logic

* refactor(autocomplete): remove shouldFocus logic and set input focus when open

* chore(deps): bump dependencies

* chore(deps): fix react aria dependencies

* fix(autocomplete): move popover style width inside isOpen true block

* fix(autocomplete): focus back to trigger

* feat(changeset): add changeset

* chore(deps): bump react-aria dependencies

* refactor(autocomplete): revise comment

* refactor(dropdown): revise logSpy and trigger mockRestore

* refactor(popover): remove debug className

* fix(date-input): avoid setting isInvalid in useDateFieldState

* fix(autocomplete): use ComboBoxValidationValue

* feat(use-aria-menu): add deprecate message

* feat(changeset): add missing packages

* refactor(use-aria-menu): remove isLink since it is included in useLinkProps

* Update packages/hooks/use-aria-menu/src/use-menu-item.ts

---------

Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>

* ci(changesets): version packages (#3147)

Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>

* fix(avatar): remove extra `disableAnimation` prop in `getImageProps` (#3260)

* fix(system-rsc): extendVariants with defaultVariants (#3299)

* fix(date-picker): update calendar classNames in useDateRangePicker (#3258)

* fix(date-picker): update calendar classNames in useDateRangePicker

* feat(docs): include custom styles in date-range-picker docs

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix(accordion): variants for nested accordions (#3291)

* feat(accordion): add data-variant

* fix(theme): revise accordion styles for variants

* feat(changeset): add changeset

* chore(theme): rollback content padding

* chore(accordion): abandon data-group approach

* refactor(theme): pass variant to accordionItem

* refactor(accordion): pass variant to accordionItem

* fix(accordion): revise accordion variants

* refactor(accordion): refine transitionVariants

* refactor(.github): nextui version description in bug report template (#3281)

* refactor(.github): revise version description & placeholder

* refactor(.github): revise version description & placeholder

* chore: add accessible name to the icon button (#3300)

* fix(radio): ensure radio input correctly references description (#3301)

* fix(radio): ensure radio input correctly references description

* refactor: tweak test

* refactor(.github): github action warnings (#3317)

* chore(.github): bump action versions

* refactor(autocomplete): linting

* chore(.github): without version

* fix(doc): migrated ScriptProvider component from the root level to each decendant folder (#3269)

Co-authored-by: HaRuki Kuriwada <haruki.kuriwada@hennge.com>

* refactor(docs): fix international calendar bug (#3363)

* refactor(docs): fix international calendar bug

* chore: update @react-aria/i18n version and update lock file

* fix(table): custom with class names storybook styles (#3344)

* fix: #3338

* fix(table): custom with class names storybook styles

* chore(deps): pnpm-lock.yaml (#3372)

* fix(accordion): allow cursor navigation within text (#3419)

* fix(accordion): allow cursor navigation within text

* fix: wrong issue number

* fix(date-range-picker): input field clear error (#3409)

Co-authored-by: shrinidhi.upadhyaya <shrinidhi.upadhyaya@stud.uni-bamberg.de>

* fix: remove autoCapitalize to prevent Firefox warning (#3376)

* fix: remove autoCapitalize to prevent firefox warning

* chore: add changeset

* fix(user): avatar icon not shown in User component (#3387)

* chore(deps): pnpm-lock.yaml

* fix(user): avoid passing user name to avatar component

* feat(changeset): add changeset

* feat(user): add avatar icon test cases

* fix(select): close select by pressing selector button (#3374)

* feat(select): add test

* fix(select): use domRef in ariaShouldCloseOnInteractOutside

* feat(changeset): add changeset

* fix(select): rewrite "should unset form value" test

* fix(select): import HiddenSelect and UseSelectProps (#3368)

* fix(select): import HiddenSelect and UseSelectProps

* chore: merge import

* feat: eslint add rule prefer top level type import (#3354)

* fix(calendar): disable button picker in calendar if `isDisabled` is true (#3358)

* fix(calendar): disable button picker in calendar if `isDisabled` is true

* feat(changeset): add changeset

* feat(calendar): add test to cover showMonthAndYearPickers with isDisabled

* fix: incorrect year in showMonthAndYearPickers with locale (#3331)

* fix(date-input): add gregorian year offset to minValue & maxValue

* feat(shared-utils): add getGregorianYearOffset

* fix(calendar): add gregorian year offset to minValue & maxValue

* feat(changeset): add changeset

* fix(system): remove defaultDates.minDate and defaultDates.maxDate

* fix(calendar): add missing import

* feat(date-picker): add test

* feat(calendar): add test

* fix(popover): dialog focus behaviour  (#3311)

* fix(autocomplete): set skipDialogFocus to true

* feat(popover): add skipDialogFocus to free solo popover

* refactor(popover): rename variable and add comment

* refactor(autocomplete): rename variable and add comment

* feat(changeset): add changeset

* refactor(docs): sort component routes alphabetically (#3328)

* docs(pagination): fix typo of missing "`" in doc (#3324)

* fix(image): override default auto height (#3327)

* fix(image): override default auto height

* feat(changeset): add changeset

* feat(image): add test

* refactor(image): add comment

* fix(table): differentiate selected bg color from striped bg color (#3221)

* fix: override bg color when selecting striped row

* chore(style): differentiate selected bg color from striped row

* chore: changeset

* chore(changeset): add issue number

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix(date-picker): open and close datepicker after pressing selector button (#3283)

* fix(date-picker): use trigger ref instead

* fix(date-input): add innerWrapperProps

* fix(date-picker): include popoverTriggerRef and add onPress to selector

* feat(date-picker): add test

* feat(changeset): add changeset

* refactor(date-input): merge innerWrapperPropsProp & props and add cn

* fix(popover): close popover on scroll (#3414)

* fix(popover): close popover on scroll

* feat(popover): add "should close popover on scroll" test

* feat(changeset): add changeset

* feat(select): add ScrollableContainerTemplate

* fix(navbar): shouldHideOnScroll fixed (#3315)

* fix(navbar): shouldHideOnScroll fixed

* Update packages/hooks/use-scroll-position/src/index.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update index.ts

* fix(navbar): applying suggested changes

---------

Co-authored-by: Pratyush <conenct2pratyush@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix(accordion): pass missing `dividerProps` to Divider (#3392)

* chore(deps): pnpm-lock.yaml

* fix(accordion): pass missing `dividerProps` to Divider

* chore(changeset): add issue number

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix(image): optional height (#3420)

* fix(image): optional height

* fix(image): incorrect props

* feat(changeset): add changeset

* fix(input): input with file type (#3268)

* fix(input): remove value & onChange for input[type="file"]

* refactor(theme): remove unnecessary styles

* fix(theme): input file styles

* fix(theme): revise cursor-pointer on file

* feat(input): add file input logic

* feat(changeset): add changeset

* refactor(input): use warn function from shared-utils instead

* feat(input): add file type story

* refactor(input): include in Input Types

* fix(date-picker): resolve width clipping issue on 90/110% zoom (#3416)

* fix(date-picker): resolve width clipping issue on 90/110% zoom

* fix(date-picker): resolve width clipping issue on 90/110% zoom

* Delete .changeset/metal-bats-reflect.md

* Update weak-dingos-chew.md

* chore: add storybook

---------

Co-authored-by: Ryo Matsukawa <76232929+ryo-manba@users.noreply.github.com>

* fix: onSelectionChange type incorrect (#3336)

* fix: onSelectionChange type incorrect

* feat: export shardSelection

* fix: typo

* fix: review

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix: tsc errors (#3362)

* fix: tsc error

* docs: changeset

* fix: test

* fix: test

* fix: review problem

* fix: review

* feat: add tw config to get the intelliSense (#3385)

* feat: add tw config to get the intelliSense

* chore(deps): pnpm-lock.yaml

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix(datePicker): prevent year, month change in showMonthAndYearPickers mode (#3088)

* fix: prevent year, month change error in showMonthAndYearPickers mode

* docs: add changeset

* docs: edit changeset

* test:  add test code about date clear issue in date picker

* test: update test code

* test: check application aria is same with current date

* chore(changeset): revise package and add issue number

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix: add onClear prop to Ripple component in button custom implementation (#3439)

* fix(input): fixed the background change on autofill in Chrome (#3430)

* fix(input): fixed the background change on autofill in Chrome

* fix(input): fixed the background change on autofill in Chrome

* chore(changeset): add issue number

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix(time-input): minValue and maxValue validation (#3426)

* fix(time-input): minValue and maxValue validation (#3424)

* test(time-input): update

* refactor(time-input): simplify `isInvalid` logic

* fix(docs): incorrect image height (#3427)

* docs: removed show more from code example (#3373)

* docs: removed show more from code example

* Update sandpack.css

* docs: remove-show-more

* chore(docs): remove unused code

* chore(deps): pnpm-lock.yaml

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix(table): resolve double fetch issue in useInfiniteScroll hook (#3332)

* fix(table): resolve double fetch issue in useInfiniteScroll hook (fix #3251)

* fix(table): remove unnecessary else clause

* fix(table): add a changeset file for use-infinite-scroll

* fix(hooks): add clearTimeout function

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* docs(frameworks): update highlighted line numbers in Frameworks examples (#3412)

* Update highlighted line numbers in Remix examples

* Update highlighted line numbers in Next.js examples

* Update highlighted line numbers in Astro examples

* Update highlighted line numbers in Vite examples

* Adjust highlighted line number

* Adjust highlighted line number

* fix(autocomplete): remove unnecessary state.close (#3464)

* fix(autocomplete): remove unnecessary state.close

* feat(autocomplete): add fully controlled template

* feat(autocomplete): should clear value after clicking clear button (controlled)

* ci(changesets): version packages (#3266)

Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>

* fix(system-rsc): defaultVariants null case in extendVariants (#3503)

* fix(system-rsc): defaultVariants null case in extendVariants

* chore(changeset): add issue number

* fix(date-range-picker): calendar-content width as per visible-months (#3505)

* fix: normalize 'status' field values to lowercase across multiple files (#2947)

* fix(status): normalize 'status' value to lowercase in page.tsx

* fix(status): normalize 'status' value to lowercase in use-case.ts

* fix(status): normalize 'status' value to lowercase in custom-render-value.ts

* fix(status): normalize 'status' value to lowercase in top-content.ts

* fix(status): normalize 'status' value to lowercase in multiple-chips.ts

* fix(status): normalize 'status' value to lowercase in custom-items.ts

* fix(status): normalize 'status' value to lowercase in data.ts

* fix(status): normalize 'status' value to lowercase in custom-styles.ts

* fix(status): normalize 'status' value to lowercase in page.tsx

* fix(status): normalize 'status' value to lowercase in custom-styles.ts

* fix(status): normalize 'status' value to lowercase in custom-items.ts

* fix(status): normalize 'status' value to lowercase in page.tsx

* fix(status): normalize 'status' value to lowercase in custom-styles.ts

* fix(modal): double scrollbar in inside scrollbehaviour (#3495)

* fix(modal): double scrollbar in inside scrollbehaviour

* chore(changeset): update changeset message and add issue number

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix(table): sortable header slow color change during theme change (#3491)

* fix(table): sortable header slow color change during theme change

* chore(changeset): add space

---------

Co-authored-by: WK Wong <wingkwong.code@gmail.com>

* fix(theme): button scaling when disableAnimation is true (#3499)

* fix(system-rsc): add @react-types/shared to dependencies (#3501)

* fix(system-rsc): add @react-types/shared to dependencies

* fix: change pnpm lock

* fix: change pnpm lock

* fix: change pnpm lock

---------

Co-authored-by: winches <329487092@qq.com>

* build(script): fixing Clean script (#3500)

running clean lock before clean node modules.

* ci(changesets): version packages (#3507)

Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>

* ci(changesets): version packages (#3508)

Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>

---------

Co-authored-by: Shrinidhi Upadhyaya <shrinidhiupadhyaya1195@gmail.com>
Co-authored-by: shrinidhi.upadhyaya <shrinidhi.upadhyaya@stud.uni-bamberg.de>
Co-authored-by: աɨռɢӄաօռɢ <wingkwong.code@gmail.com>
Co-authored-by: Paul Tiedtke <PaulTiedtke@web.de>
Co-authored-by: Mohammad Reza Badri <85818966+mrbadri@users.noreply.github.com>
Co-authored-by: Nozomi-Hijikata <116155762+Nozomi-Hijikata@users.noreply.github.com>
Co-authored-by: HaRuki <soccer_haruki15@me.com>
Co-authored-by: Kaben <carnoxen@gmail.com>
Co-authored-by: Shawn Dong <dsknight@live.com.au>
Co-authored-by: Shawn Dong <shawn.dong@flybuys.com.au>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Ryo Matsukawa <76232929+ryo-manba@users.noreply.github.com>
Co-authored-by: Poli Sour <57824881+novsource@users.noreply.github.com>
Co-authored-by: Poli Sour <polisour.work@gmail.com>
Co-authored-by: Artem Pitikin <git@kosmotema.dev>
Co-authored-by: winches <329487092@qq.com>
Co-authored-by: Eric Abreu <ericfabreu@gmail.com>
Co-authored-by: Minsu <52266597+Gaic4o@users.noreply.github.com>
Co-authored-by: Jesus Perdomo Lampignano <38929969+jesuzon@users.noreply.github.com>
Co-authored-by: chirokas <157580465+chirokas@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: EGOIST <0x142857@gmail.com>
Co-authored-by: Damien Leroy <10438692+ShiiFu@users.noreply.github.com>
Co-authored-by: Christian Abele <manufaktur@christian-abele.de>
Co-authored-by: Nozomi Hijikata <121233810+nozomemein@users.noreply.github.com>
Co-authored-by: HaRuki Kuriwada <haruki.kuriwada@hennge.com>
Co-authored-by: Deval Minocha <deval.minocha24@gmail.com>
Co-authored-by: Ankit <82326089+ankitts@users.noreply.github.com>
Co-authored-by: wiyco <lumiwslab@gmail.com>
Co-authored-by: Sjoerd van Bommel <sjoerd.van.bommel@Hotmail.com>
Co-authored-by: Pratyush Kongalla <44525862+pratyush3124@users.noreply.github.com>
Co-authored-by: Pratyush <conenct2pratyush@gmail.com>
Co-authored-by: Abhinandan <abhinandanverma551@gmail.com>
Co-authored-by: KumJungMin <37934668+KumJungMin@users.noreply.github.com>
Co-authored-by: dochi <ryoon50@gmail.com>
Co-authored-by: Abhishek Tomar <104965815+abhisektomar1@users.noreply.github.com>
Co-authored-by: RockerFlower <kira@glorylab.xyz>
Co-authored-by: codeesura <120671243+codeesura@users.noreply.github.com>
Co-authored-by: Simon Podlipsky <simon@podlipsky.net>
Co-authored-by: sandeep Butte <sandeep36butte@gmail.com>
2024-07-18 13:45:51 -07:00

1042 lines
29 KiB
TypeScript

const data = `const columns = [
{name: "ID", uid: "id", sortable: true},
{name: "NAME", uid: "name", sortable: true},
{name: "AGE", uid: "age", sortable: true},
{name: "ROLE", uid: "role", sortable: true},
{name: "TEAM", uid: "team"},
{name: "EMAIL", uid: "email"},
{name: "STATUS", uid: "status", sortable: true},
{name: "ACTIONS", uid: "actions"},
];
const statusOptions = [
{name: "Active", uid: "active"},
{name: "Paused", uid: "paused"},
{name: "Vacation", uid: "vacation"},
];
const users = [
{
id: 1,
name: "Tony Reichert",
role: "CEO",
team: "Management",
status: "active",
age: "29",
avatar: "https://i.pravatar.cc/150?u=a042581f4e29026024d",
email: "tony.reichert@example.com",
},
{
id: 2,
name: "Zoey Lang",
role: "Tech Lead",
team: "Development",
status: "paused",
age: "25",
avatar: "https://i.pravatar.cc/150?u=a042581f4e29026704d",
email: "zoey.lang@example.com",
},
{
id: 3,
name: "Jane Fisher",
role: "Sr. Dev",
team: "Development",
status: "active",
age: "22",
avatar: "https://i.pravatar.cc/150?u=a04258114e29026702d",
email: "jane.fisher@example.com",
},
{
id: 4,
name: "William Howard",
role: "C.M.",
team: "Marketing",
status: "vacation",
age: "28",
avatar: "https://i.pravatar.cc/150?u=a048581f4e29026701d",
email: "william.howard@example.com",
},
{
id: 5,
name: "Kristen Copper",
role: "S. Manager",
team: "Sales",
status: "active",
age: "24",
avatar: "https://i.pravatar.cc/150?u=a092581d4ef9026700d",
email: "kristen.cooper@example.com",
},
{
id: 6,
name: "Brian Kim",
role: "P. Manager",
team: "Management",
age: "29",
avatar: "https://i.pravatar.cc/150?u=a042581f4e29026024d",
email: "brian.kim@example.com",
status: "active",
},
{
id: 7,
name: "Michael Hunt",
role: "Designer",
team: "Design",
status: "paused",
age: "27",
avatar: "https://i.pravatar.cc/150?u=a042581f4e29027007d",
email: "michael.hunt@example.com",
},
{
id: 8,
name: "Samantha Brooks",
role: "HR Manager",
team: "HR",
status: "active",
age: "31",
avatar: "https://i.pravatar.cc/150?u=a042581f4e27027008d",
email: "samantha.brooks@example.com",
},
{
id: 9,
name: "Frank Harrison",
role: "F. Manager",
team: "Finance",
status: "vacation",
age: "33",
avatar: "https://i.pravatar.cc/150?img=4",
email: "frank.harrison@example.com",
},
{
id: 10,
name: "Emma Adams",
role: "Ops Manager",
team: "Operations",
status: "active",
age: "35",
avatar: "https://i.pravatar.cc/150?img=5",
email: "emma.adams@example.com",
},
{
id: 11,
name: "Brandon Stevens",
role: "Jr. Dev",
team: "Development",
status: "active",
age: "22",
avatar: "https://i.pravatar.cc/150?img=8",
email: "brandon.stevens@example.com",
},
{
id: 12,
name: "Megan Richards",
role: "P. Manager",
team: "Product",
status: "paused",
age: "28",
avatar: "https://i.pravatar.cc/150?img=10",
email: "megan.richards@example.com",
},
{
id: 13,
name: "Oliver Scott",
role: "S. Manager",
team: "Security",
status: "active",
age: "37",
avatar: "https://i.pravatar.cc/150?img=12",
email: "oliver.scott@example.com",
},
{
id: 14,
name: "Grace Allen",
role: "M. Specialist",
team: "Marketing",
status: "active",
age: "30",
avatar: "https://i.pravatar.cc/150?img=16",
email: "grace.allen@example.com",
},
{
id: 15,
name: "Noah Carter",
role: "IT Specialist",
team: "I. Technology",
status: "paused",
age: "31",
avatar: "https://i.pravatar.cc/150?img=15",
email: "noah.carter@example.com",
},
{
id: 16,
name: "Ava Perez",
role: "Manager",
team: "Sales",
status: "active",
age: "29",
avatar: "https://i.pravatar.cc/150?img=20",
email: "ava.perez@example.com",
},
{
id: 17,
name: "Liam Johnson",
role: "Data Analyst",
team: "Analysis",
status: "active",
age: "28",
avatar: "https://i.pravatar.cc/150?img=33",
email: "liam.johnson@example.com",
},
{
id: 18,
name: "Sophia Taylor",
role: "QA Analyst",
team: "Testing",
status: "active",
age: "27",
avatar: "https://i.pravatar.cc/150?img=29",
email: "sophia.taylor@example.com",
},
{
id: 19,
name: "Lucas Harris",
role: "Administrator",
team: "Information Technology",
status: "paused",
age: "32",
avatar: "https://i.pravatar.cc/150?img=50",
email: "lucas.harris@example.com",
},
{
id: 20,
name: "Mia Robinson",
role: "Coordinator",
team: "Operations",
status: "active",
age: "26",
avatar: "https://i.pravatar.cc/150?img=45",
email: "mia.robinson@example.com",
},
];
export {columns, users, statusOptions};`;
const utils = `export function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}`;
const PlusIcon = `export const PlusIcon = ({size = 24, width, height, ...props}) => (
<svg
aria-hidden="true"
fill="none"
focusable="false"
height={size || height}
role="presentation"
viewBox="0 0 24 24"
width={size || width}
{...props}
>
<g
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={1.5}
>
<path d="M6 12h12" />
<path d="M12 18V6" />
</g>
</svg>
);`;
const VerticalDotsIcon = `export const VerticalDotsIcon = ({size = 24, width, height, ...props}) => (
<svg
aria-hidden="true"
fill="none"
focusable="false"
height={size || height}
role="presentation"
viewBox="0 0 24 24"
width={size || width}
{...props}
>
<path
d="M12 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"
fill="currentColor"
/>
</svg>
);`;
const SearchIcon = `export const SearchIcon = (props) => (
<svg
aria-hidden="true"
fill="none"
focusable="false"
height="1em"
role="presentation"
viewBox="0 0 24 24"
width="1em"
{...props}
>
<path
d="M11.5 21C16.7467 21 21 16.7467 21 11.5C21 6.25329 16.7467 2 11.5 2C6.25329 2 2 6.25329 2 11.5C2 16.7467 6.25329 21 11.5 21Z"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
/>
<path
d="M22 22L20 20"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
/>
</svg>
);`;
const ChevronDownIcon = `export const ChevronDownIcon = ({strokeWidth = 1.5, ...otherProps}) => (
<svg
aria-hidden="true"
fill="none"
focusable="false"
height="1em"
role="presentation"
viewBox="0 0 24 24"
width="1em"
{...otherProps}
>
<path
d="m19.92 8.95-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeMiterlimit={10}
strokeWidth={strokeWidth}
/>
</svg>
);`;
const App = `import {
Table,
TableHeader,
TableColumn,
TableBody,
TableRow,
TableCell,
Input,
Button,
DropdownTrigger,
Dropdown,
DropdownMenu,
DropdownItem,
Chip,
User,
Pagination,
} from "@nextui-org/react";
import {PlusIcon} from "./PlusIcon";
import {VerticalDotsIcon} from "./VerticalDotsIcon";
import {SearchIcon} from "./SearchIcon";
import {ChevronDownIcon} from "./ChevronDownIcon";
import {columns, users, statusOptions} from "./data";
import {capitalize} from "./utils";
const statusColorMap = {
active: "success",
paused: "danger",
vacation: "warning",
};
const INITIAL_VISIBLE_COLUMNS = ["name", "role", "status", "actions"];
export default function App() {
const [filterValue, setFilterValue] = React.useState("");
const [selectedKeys, setSelectedKeys] = React.useState(new Set([]));
const [visibleColumns, setVisibleColumns] = React.useState(new Set(INITIAL_VISIBLE_COLUMNS));
const [statusFilter, setStatusFilter] = React.useState("all");
const [rowsPerPage, setRowsPerPage] = React.useState(5);
const [sortDescriptor, setSortDescriptor] = React.useState({
column: "age",
direction: "ascending",
});
const [page, setPage] = React.useState(1);
const pages = Math.ceil(users.length / rowsPerPage);
const hasSearchFilter = Boolean(filterValue);
const headerColumns = React.useMemo(() => {
if (visibleColumns === "all") return columns;
return columns.filter((column) => Array.from(visibleColumns).includes(column.uid));
}, [visibleColumns]);
const filteredItems = React.useMemo(() => {
let filteredUsers = [...users];
if (hasSearchFilter) {
filteredUsers = filteredUsers.filter((user) =>
user.name.toLowerCase().includes(filterValue.toLowerCase()),
);
}
if (statusFilter !== "all" && Array.from(statusFilter).length !== statusOptions.length) {
filteredUsers = filteredUsers.filter((user) =>
Array.from(statusFilter).includes(user.status),
);
}
return filteredUsers;
}, [users, filterValue, statusFilter]);
const items = React.useMemo(() => {
const start = (page - 1) * rowsPerPage;
const end = start + rowsPerPage;
return filteredItems.slice(start, end);
}, [page, filteredItems, rowsPerPage]);
const sortedItems = React.useMemo(() => {
return [...items].sort((a, b) => {
const first = a[sortDescriptor.column];
const second = b[sortDescriptor.column];
const cmp = first < second ? -1 : first > second ? 1 : 0;
return sortDescriptor.direction === "descending" ? -cmp : cmp;
});
}, [sortDescriptor, items]);
const renderCell = React.useCallback((user, columnKey) => {
const cellValue = user[columnKey];
switch (columnKey) {
case "name":
return (
<User
avatarProps={{radius: "full", size: "sm", src: user.avatar}}
classNames={{
description: "text-default-500",
}}
description={user.email}
name={cellValue}
>
{user.email}
</User>
);
case "role":
return (
<div className="flex flex-col">
<p className="text-bold text-small capitalize">{cellValue}</p>
<p className="text-bold text-tiny capitalize text-default-500">{user.team}</p>
</div>
);
case "status":
return (
<Chip
className="capitalize border-none gap-1 text-default-600"
color={statusColorMap[user.status]}
size="sm"
variant="dot"
>
{cellValue}
</Chip>
);
case "actions":
return (
<div className="relative flex justify-end items-center gap-2">
<Dropdown className="bg-background border-1 border-default-200">
<DropdownTrigger>
<Button isIconOnly radius="full" size="sm" variant="light">
<VerticalDotsIcon className="text-default-400" />
</Button>
</DropdownTrigger>
<DropdownMenu>
<DropdownItem>View</DropdownItem>
<DropdownItem>Edit</DropdownItem>
<DropdownItem>Delete</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
);
default:
return cellValue;
}
}, []);
const onRowsPerPageChange = React.useCallback((e) => {
setRowsPerPage(Number(e.target.value));
setPage(1);
}, []);
const onSearchChange = React.useCallback((value) => {
if (value) {
setFilterValue(value);
setPage(1);
} else {
setFilterValue("");
}
}, []);
const topContent = React.useMemo(() => {
return (
<div className="flex flex-col gap-4">
<div className="flex justify-between gap-3 items-end">
<Input
isClearable
classNames={{
base: "w-full sm:max-w-[44%]",
inputWrapper: "border-1",
}}
placeholder="Search by name..."
size="sm"
startContent={<SearchIcon className="text-default-300" />}
value={filterValue}
variant="bordered"
onClear={() => setFilterValue("")}
onValueChange={onSearchChange}
/>
<div className="flex gap-3">
<Dropdown>
<DropdownTrigger className="hidden sm:flex">
<Button
endContent={<ChevronDownIcon className="text-small" />}
size="sm"
variant="flat"
>
Status
</Button>
</DropdownTrigger>
<DropdownMenu
disallowEmptySelection
aria-label="Table Columns"
closeOnSelect={false}
selectedKeys={statusFilter}
selectionMode="multiple"
onSelectionChange={setStatusFilter}
>
{statusOptions.map((status) => (
<DropdownItem key={status.uid} className="capitalize">
{capitalize(status.name)}
</DropdownItem>
))}
</DropdownMenu>
</Dropdown>
<Dropdown>
<DropdownTrigger className="hidden sm:flex">
<Button
endContent={<ChevronDownIcon className="text-small" />}
size="sm"
variant="flat"
>
Columns
</Button>
</DropdownTrigger>
<DropdownMenu
disallowEmptySelection
aria-label="Table Columns"
closeOnSelect={false}
selectedKeys={visibleColumns}
selectionMode="multiple"
onSelectionChange={setVisibleColumns}
>
{columns.map((column) => (
<DropdownItem key={column.uid} className="capitalize">
{capitalize(column.name)}
</DropdownItem>
))}
</DropdownMenu>
</Dropdown>
<Button
className="bg-foreground text-background"
endContent={<PlusIcon />}
size="sm"
>
Add New
</Button>
</div>
</div>
<div className="flex justify-between items-center">
<span className="text-default-400 text-small">Total {users.length} users</span>
<label className="flex items-center text-default-400 text-small">
Rows per page:
<select
className="bg-transparent outline-none text-default-400 text-small"
onChange={onRowsPerPageChange}
>
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
</select>
</label>
</div>
</div>
);
}, [
filterValue,
statusFilter,
visibleColumns,
onSearchChange,
onRowsPerPageChange,
users.length,
hasSearchFilter,
]);
const bottomContent = React.useMemo(() => {
return (
<div className="py-2 px-2 flex justify-between items-center">
<Pagination
showControls
classNames={{
cursor: "bg-foreground text-background",
}}
color="default"
isDisabled={hasSearchFilter}
page={page}
total={pages}
variant="light"
onChange={setPage}
/>
<span className="text-small text-default-400">
{selectedKeys === "all"
? "All items selected"
: \`\${selectedKeys.size} of \${items.length} selected\`}
</span>
</div>
);
}, [selectedKeys, items.length, page, pages, hasSearchFilter]);
const classNames = React.useMemo(
() => ({
wrapper: ["max-h-[382px]", "max-w-3xl"],
th: ["bg-transparent", "text-default-500", "border-b", "border-divider"],
td: [
// changing the rows border radius
// first
"group-data-[first=true]:first:before:rounded-none",
"group-data-[first=true]:last:before:rounded-none",
// middle
"group-data-[middle=true]:before:rounded-none",
// last
"group-data-[last=true]:first:before:rounded-none",
"group-data-[last=true]:last:before:rounded-none",
],
}),
[],
);
return (
<Table
isCompact
removeWrapper
aria-label="Example table with custom cells, pagination and sorting"
bottomContent={bottomContent}
bottomContentPlacement="outside"
checkboxesProps={{
classNames: {
wrapper: "after:bg-foreground after:text-background text-background",
},
}}
classNames={classNames}
selectedKeys={selectedKeys}
selectionMode="multiple"
sortDescriptor={sortDescriptor}
topContent={topContent}
topContentPlacement="outside"
onSelectionChange={setSelectedKeys}
onSortChange={setSortDescriptor}
>
<TableHeader columns={headerColumns}>
{(column) => (
<TableColumn
key={column.uid}
align={column.uid === "actions" ? "center" : "start"}
allowsSorting={column.sortable}
>
{column.name}
</TableColumn>
)}
</TableHeader>
<TableBody emptyContent={"No users found"} items={sortedItems}>
{(item) => (
<TableRow key={item.id}>
{(columnKey) => <TableCell>{renderCell(item, columnKey)}</TableCell>}
</TableRow>
)}
</TableBody>
</Table>
);
}`;
const AppTs = `import {
Table,
TableHeader,
TableColumn,
TableBody,
TableRow,
TableCell,
Input,
Button,
DropdownTrigger,
Dropdown,
DropdownMenu,
DropdownItem,
Chip,
User,
Pagination,
Selection,
ChipProps,
SortDescriptor
} from "@nextui-org/react";
import {PlusIcon} from "./PlusIcon";
import {VerticalDotsIcon} from "./VerticalDotsIcon";
import {ChevronDownIcon} from "./ChevronDownIcon";
import {SearchIcon} from "./SearchIcon";
import {columns, users, statusOptions} from "./data";
import {capitalize} from "./utils";
const statusColorMap: Record<string, ChipProps["color"]> = {
active: "success",
paused: "danger",
vacation: "warning",
};
const INITIAL_VISIBLE_COLUMNS = ["name", "role", "status", "actions"];
type User = typeof users[0];
export default function App() {
const [filterValue, setFilterValue] = React.useState("");
const [selectedKeys, setSelectedKeys] = React.useState<Selection>(new Set([]));
const [visibleColumns, setVisibleColumns] = React.useState<Selection>(new Set(INITIAL_VISIBLE_COLUMNS));
const [statusFilter, setStatusFilter] = React.useState<Selection>("all");
const [rowsPerPage, setRowsPerPage] = React.useState(5);
const [sortDescriptor, setSortDescriptor] = React.useState<SortDescriptor>({
column: "age",
direction: "ascending",
});
const [page, setPage] = React.useState(1);
const pages = Math.ceil(users.length / rowsPerPage);
const hasSearchFilter = Boolean(filterValue);
const headerColumns = React.useMemo(() => {
if (visibleColumns === "all") return columns;
return columns.filter((column) => Array.from(visibleColumns).includes(column.uid));
}, [visibleColumns]);
const filteredItems = React.useMemo(() => {
let filteredUsers = [...users];
if (hasSearchFilter) {
filteredUsers = filteredUsers.filter((user) =>
user.name.toLowerCase().includes(filterValue.toLowerCase()),
);
}
if (statusFilter !== "all" && Array.from(statusFilter).length !== statusOptions.length) {
filteredUsers = filteredUsers.filter((user) =>
Array.from(statusFilter).includes(user.status),
);
}
return filteredUsers;
}, [users, filterValue, statusFilter]);
const items = React.useMemo(() => {
const start = (page - 1) * rowsPerPage;
const end = start + rowsPerPage;
return filteredItems.slice(start, end);
}, [page, filteredItems, rowsPerPage]);
const sortedItems = React.useMemo(() => {
return [...items].sort((a: User, b: User) => {
const first = a[sortDescriptor.column as keyof User] as number;
const second = b[sortDescriptor.column as keyof User] as number;
const cmp = first < second ? -1 : first > second ? 1 : 0;
return sortDescriptor.direction === "descending" ? -cmp : cmp;
});
}, [sortDescriptor, items]);
const renderCell = React.useCallback((user: User, columnKey: React.Key) => {
const cellValue = user[columnKey as keyof User];
switch (columnKey) {
case "name":
return (
<User
avatarProps={{radius: "full", size: "sm", src: user.avatar}}
classNames={{
description: "text-default-500",
}}
description={user.email}
name={cellValue}
>
{user.email}
</User>
);
case "role":
return (
<div className="flex flex-col">
<p className="text-bold text-small capitalize">{cellValue}</p>
<p className="text-bold text-tiny capitalize text-default-500">{user.team}</p>
</div>
);
case "status":
return (
<Chip
className="capitalize border-none gap-1 text-default-600"
color={statusColorMap[user.status]}
size="sm"
variant="dot"
>
{cellValue}
</Chip>
);
case "actions":
return (
<div className="relative flex justify-end items-center gap-2">
<Dropdown className="bg-background border-1 border-default-200">
<DropdownTrigger>
<Button isIconOnly radius="full" size="sm" variant="light">
<VerticalDotsIcon className="text-default-400" />
</Button>
</DropdownTrigger>
<DropdownMenu>
<DropdownItem>View</DropdownItem>
<DropdownItem>Edit</DropdownItem>
<DropdownItem>Delete</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
);
default:
return cellValue;
}
}, []);
const onRowsPerPageChange = React.useCallback((e: React.ChangeEvent<HTMLSelectElement>) => {
setRowsPerPage(Number(e.target.value));
setPage(1);
}, []);
const onSearchChange = React.useCallback((value?: string) => {
if (value) {
setFilterValue(value);
setPage(1);
} else {
setFilterValue("");
}
}, []);
const topContent = React.useMemo(() => {
return (
<div className="flex flex-col gap-4">
<div className="flex justify-between gap-3 items-end">
<Input
isClearable
classNames={{
base: "w-full sm:max-w-[44%]",
inputWrapper: "border-1",
}}
placeholder="Search by name..."
size="sm"
startContent={<SearchIcon className="text-default-300" />}
value={filterValue}
variant="bordered"
onClear={() => setFilterValue("")}
onValueChange={onSearchChange}
/>
<div className="flex gap-3">
<Dropdown>
<DropdownTrigger className="hidden sm:flex">
<Button
endContent={<ChevronDownIcon className="text-small" />}
size="sm"
variant="flat"
>
Status
</Button>
</DropdownTrigger>
<DropdownMenu
disallowEmptySelection
aria-label="Table Columns"
closeOnSelect={false}
selectedKeys={statusFilter}
selectionMode="multiple"
onSelectionChange={setStatusFilter}
>
{statusOptions.map((status) => (
<DropdownItem key={status.uid} className="capitalize">
{capitalize(status.name)}
</DropdownItem>
))}
</DropdownMenu>
</Dropdown>
<Dropdown>
<DropdownTrigger className="hidden sm:flex">
<Button
endContent={<ChevronDownIcon className="text-small" />}
size="sm"
variant="flat"
>
Columns
</Button>
</DropdownTrigger>
<DropdownMenu
disallowEmptySelection
aria-label="Table Columns"
closeOnSelect={false}
selectedKeys={visibleColumns}
selectionMode="multiple"
onSelectionChange={setVisibleColumns}
>
{columns.map((column) => (
<DropdownItem key={column.uid} className="capitalize">
{capitalize(column.name)}
</DropdownItem>
))}
</DropdownMenu>
</Dropdown>
<Button
className="bg-foreground text-background"
endContent={<PlusIcon />}
size="sm"
>
Add New
</Button>
</div>
</div>
<div className="flex justify-between items-center">
<span className="text-default-400 text-small">Total {users.length} users</span>
<label className="flex items-center text-default-400 text-small">
Rows per page:
<select
className="bg-transparent outline-none text-default-400 text-small"
onChange={onRowsPerPageChange}
>
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
</select>
</label>
</div>
</div>
);
}, [
filterValue,
statusFilter,
visibleColumns,
onSearchChange,
onRowsPerPageChange,
users.length,
hasSearchFilter,
]);
const bottomContent = React.useMemo(() => {
return (
<div className="py-2 px-2 flex justify-between items-center">
<Pagination
showControls
classNames={{
cursor: "bg-foreground text-background",
}}
color="default"
isDisabled={hasSearchFilter}
page={page}
total={pages}
variant="light"
onChange={setPage}
/>
<span className="text-small text-default-400">
{selectedKeys === "all"
? "All items selected"
: \`\${selectedKeys.size} of \${items.length} selected\`}
</span>
</div>
);
}, [selectedKeys, items.length, page, pages, hasSearchFilter]);
const classNames = React.useMemo(
() => ({
wrapper: ["max-h-[382px]", "max-w-3xl"],
th: ["bg-transparent", "text-default-500", "border-b", "border-divider"],
td: [
// changing the rows border radius
// first
"group-data-[first=true]:first:before:rounded-none",
"group-data-[first=true]:last:before:rounded-none",
// middle
"group-data-[middle=true]:before:rounded-none",
// last
"group-data-[last=true]:first:before:rounded-none",
"group-data-[last=true]:last:before:rounded-none",
],
}),
[],
);
return (
<Table
isCompact
removeWrapper
aria-label="Example table with custom cells, pagination and sorting"
bottomContent={bottomContent}
bottomContentPlacement="outside"
checkboxesProps={{
classNames: {
wrapper: "after:bg-foreground after:text-background text-background",
},
}}
classNames={classNames}
selectedKeys={selectedKeys}
selectionMode="multiple"
sortDescriptor={sortDescriptor}
topContent={topContent}
topContentPlacement="outside"
onSelectionChange={setSelectedKeys}
onSortChange={setSortDescriptor}
>
<TableHeader columns={headerColumns}>
{(column) => (
<TableColumn
key={column.uid}
align={column.uid === "actions" ? "center" : "start"}
allowsSorting={column.sortable}
>
{column.name}
</TableColumn>
)}
</TableHeader>
<TableBody emptyContent={"No users found"} items={sortedItems}>
{(item) => (
<TableRow key={item.id}>
{(columnKey) => <TableCell>{renderCell(item, columnKey)}</TableCell>}
</TableRow>
)}
</TableBody>
</Table>
);
}`;
const react = {
"/App.jsx": App,
"/data.js": data,
"/utils.js": utils,
"/PlusIcon.jsx": PlusIcon,
"/VerticalDotsIcon.jsx": VerticalDotsIcon,
"/SearchIcon.jsx": SearchIcon,
"/ChevronDownIcon.jsx": ChevronDownIcon,
};
const reactTs = {
"/App.tsx": AppTs,
};
export default {
...react,
...reactTs,
};