mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
* fix(date-picker): error state (#5317) * fix(date-range-picker): fixed the error state in preset * Update giant-sloths-shop.md * Removed if statement * chore(date-picker): prettier --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix(theme): clear button in mobile (#5252) * fix(toast): fixed close button hover position * fix(input): fixed the clear button rendering on smaller devices * Delete .changeset/soft-spoons-march.md * Update input.ts * Undo unrelated toast changes * fix(toast): icons (#5246) * feat(shared-icons): add loading icon * fix(toast): icons * chore(toast): revise types for icons * chore(changeset): add changeset * refactor: migrate eslint to v9 (#5267) * refactor: migrate eslint to v9 * chore: lint * chore: update eslint command * chore: fix lint warnings * chore: separate lint and lint:fix * chore: exclude contentlayer generated code * fix(scripts): add missing await * fix(autocomplete): persist last selected item position (#5286) * refactor(select): remove unnecessary code * fix(autocomplete): persist last selected item position * chore(changeset): add changeset * chore(deps): bump framer-motion version (#5287) * chore(deps): bump framer-motion version * fix: typing issues * chore(changeset): add changeset --------- Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> * chore(docs): supplement onAction & selectionBehavior (#5289) * fix(autocomplete): ensure focused item matches selected item after filter, selection (#5290) * fix(autocomplete): ensure focused item matches selected item after filter, selection * chore: apply type and default value * chore: add perpose coment in updated code * test: add focuskey management testcode * docs: add changeset * docs: update changeset * chore: remove comment * fix: broken components in stories (#5291) * chore(switch): remove xl size * chore(docs): remove xl size * chore(system-rsc): remove xl size * chore(circular-progress): remove xl size * chore: undo * chore(deps): bump RA versions (#5310) * chore(deps): ra version bump * chore(changeset): add changeset * fix(scripts): incorrect docs path --------- Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> * chore(docs): update meta data (#5311) * docs(layout.tsx): added text-foreground (#5316) * feat(tabs): add click handling for tab items in tests and implementation (#3917) Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix issues in tabs examples (#2405) Co-authored-by: WK Wong <wingkwong.code@gmail.com> * chore(docs): add missing onValueChange in CheckboxGroup (#5332) * ci(changesets): version packages (#5323) Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> * chore(deps): bump RA versions (#5361) * chore(deps): bump RA versions * chore(deps): bump RA versions * chore(deps): bump RA versions * chore: changeset * refactor(listbox): already extends in AriaListBoxProps * chore(docs): remove herohack announcement (#5363) * chore: remove herohack announcement * Update carbon-ad.tsx * chore(docs): fixed lint errors * chore(docs): requested changes * Update carbon-ad.tsx * Update carbon-ad.tsx * fix(theme): consistent faded styling for isInvalid in InputOtp and DateInput (#5349) * fix(input-otp): remove bg and border styles from faded variant when isInvalid * fix(date-input): remove bg styles from faded variant when isInvalid * chore(changeset): add changeset * chore: bump theme peerDependencies * chore: bump theme peerDependencies * fix: wrong version * chore: extra line --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix(theme): helperWrapper padding (#5350) * fix(number-input): decreased helperWrapper padding to maintain consistency * Update beige-laws-heal.md * chore(theme): change to p-1 * chore(deps): bump peerDependencies for theme pkg * fix(number-input): incorrect versions * chore(changeset): include number input --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix(autocomplete): onClear (#5365) * fix(autocomplete): add onClear * feat(autocomplete): add test case for onClear * chore(changeset): add changeset * fix(number-input): only allow number type (#5368) * refactor(number-input): avoid non number type passing to number input * chore(changeset): add changeset * refactor: optimization (#5362) * chore(deps): bump RA versions * chore(deps): bump RA versions * chore(deps): bump RA versions * chore: changeset * chore(deps): remove unnecessary dependencies * fix(calendar): typing issue * refactor(system): remove unused SupportedCalendars * refactor(system): move I18nProviderProps to type * refactor: use `spectrumCalendarProps<DateValue>["createCalendar"]` * feat: add consistent-type-imports * fix: eslint * chore: add changeset * refactor: remove unused deps * ci(changesets): version packages (#5364) Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> * chore(deps): bump RA versions (#5382) * fix(tabs): onClick (#5378) * fix(tabs): handleClick * chore(changeset): add changeset * refactor: remove `@interationalized/date` from system (#5374) * refactor(calendar): createCalendar typing * refactor(system): ditch `@react-types/calendar` * feat(system): include the required types or interfaces * chore(deps): pnpm-lock.yaml * fix: cast DateValue * fix: minValue & maxValue typing * chore(changeset): add changeset * refactor(system): abstract class * chore(deps): bump system peer dependency * chore(changeset): add changeset * fix(docs): correct display of the "Toast" component in the Safari browser (#5400) * ci(changesets): version packages (#5394) Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> * docs: replace invalid yarn command (#5422) * chore: remove ph banner (#5437) * feat: 2.8.0 beta changes (#5473) * ci(changesets): 📦 version packages (beta) (#5254) * chore(pre-release): enter pre-release mode * feat: support tailwindcss v4 (#4656) * feat: upgrade tailwindcssv4 * feat: upgrade tailwindcssv4 * feat: update config * feat: first init tailwindcss v4 * fix: update shadow xs to sm * fix: update rounded xs to sm * fix: variant issues * fix: variant shadow etc issues * fix: variant shadow issues * fix: redundant shadow issues * fix: redundant blur-sm issues * fix: redundant blur-sm issues * fix: redundant blur-sm shadow issues * fix: remove redundant rename * fix: role button issues * fix: role button issues * fix: font size * fix: alpha color value * fix: support text utilities in plugin * feat: upgrade tailwind-merge * fix: pkg package scope (cherry picked from commit 6e823233fca0e920336ec32dda6d1d1d845ed0d2) * fix: button base ui add cursor pointer * fix: tailwindcss experimental * feat: upgrade tailwindcss version * fix: input step 1 * fix: input transition issue * fix: theme to var function * ci: run QA in beta branch * fix: var to the theme and incorrect var usage MER-3261 * feat: upgrade tailwind-variants --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> * feat: changeset for tailwindcss v4 * fix: changeset * fix: changeset * ci(changesets): version packages (beta) (#5008) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: tw 4 docs * fix: select tests * chore: timeout * ci(changesets): version packages (beta) * ci(changesets): version packages (beta) * fix: deployment * ci(changesets): version packages (beta) (#5009) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: add the cli to upgrade the packages to beta * fix: cli command * fix: revert to use previous version (#5012) * fix: revert to use previous version * fix: revert to use previous version * fix: revert * fix: revert to use previous tailwind-merge version * ci(changesets): version packages (beta) (#5015) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: adapt tailwind merger config (#5016) * Revert "fix: revert to use previous version (#5012)" This reverts commit 1d01df254d6df9bc524d29d767236823b33a96fd. * fix: adapt tailwind merge config * fix: adapt tailwind merge config * fix: adapt tailwind merge config * fix: changeset * ci(changesets): version packages (beta) * fix(tailwind): add missing values config for bg-grid plugin * fix: remove useless tw config * fix: add default styles * docs: changeset * docs: typo * chore: merge origin canary to beta * ci(changesets): version packages (beta) * chore: remove changeset & pre.json * chore: change to minor * chore(pre-release): enter pre-release mode * chore(deps): fix versions * chore(deps): revise changed packages * chore(deps): update tailwindcss version * ci(changesets): 📦 version packages (beta) (#5166) * ci(changesets): version packages (beta) * fix: add missing delimiter --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: winches <329487092@qq.com> * fix(docs): add missing semicolon * fix: animate about skeleton (#5198) * chore: pre release * ci(changesets): version packages (beta) (#5199) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * docs: blurred hover button style * fix: language selector blur (#5208) * fix: skeleton animate translate value (#5207) * fix: open in remote repo (#5214) * chore: upgrade tw version * fix: open in remote repo * fix: update lock * fix: select translate styles (#5219) * chore: pre release * ci(changesets): version packages (beta) (#5222) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore: remove changeset * chore(pre-release): enter pre-release mode * chore(react): continue from 2.8.0-beta.2 * chore(changeset): add changeset * fix(changeset): use patch * ci(changesets): version packages (beta) * fix(docs): beta docs --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: winches <329487092@qq.com> Co-authored-by: WK Wong <wingkwong.code@gmail.com> Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Charlotte21110 <hejianer9@163.com> * fix(workflow): check_if_pre_json_exists order * chore(changeset): redeploy * chore(changeset): changeset (#5263) * ci(changesets): version packages (beta) (#5264) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(docs): mdx in beta (#5261) * chore(docs): add lint:fix * fix(docs): slug requires promise in next 15 * fix(docs): useMDXComponent * fix(docs): typing issue * docs: typography style error (#5274) * chore(pre-release): enter pre-release mode * feat: support tailwindcss v4 (#4656) * feat: upgrade tailwindcssv4 * feat: upgrade tailwindcssv4 * feat: update config * feat: first init tailwindcss v4 * fix: update shadow xs to sm * fix: update rounded xs to sm * fix: variant issues * fix: variant shadow etc issues * fix: variant shadow issues * fix: redundant shadow issues * fix: redundant blur-sm issues * fix: redundant blur-sm issues * fix: redundant blur-sm shadow issues * fix: remove redundant rename * fix: role button issues * fix: role button issues * fix: font size * fix: alpha color value * fix: support text utilities in plugin * feat: upgrade tailwind-merge * fix: pkg package scope (cherry picked from commit 6e823233fca0e920336ec32dda6d1d1d845ed0d2) * fix: button base ui add cursor pointer * fix: tailwindcss experimental * feat: upgrade tailwindcss version * fix: input step 1 * fix: input transition issue * fix: theme to var function * ci: run QA in beta branch * fix: var to the theme and incorrect var usage MER-3261 * feat: upgrade tailwind-variants --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> * feat: changeset for tailwindcss v4 * fix: changeset * fix: changeset * ci(changesets): version packages (beta) (#5008) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: tw 4 docs * fix: select tests * chore: timeout * ci(changesets): version packages (beta) * ci(changesets): version packages (beta) * fix: deployment * ci(changesets): version packages (beta) (#5009) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: add the cli to upgrade the packages to beta * fix: cli command * fix: revert to use previous version (#5012) * fix: revert to use previous version * fix: revert to use previous version * fix: revert * fix: revert to use previous tailwind-merge version * ci(changesets): version packages (beta) (#5015) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: adapt tailwind merger config (#5016) * Revert "fix: revert to use previous version (#5012)" This reverts commit 1d01df254d6df9bc524d29d767236823b33a96fd. * fix: adapt tailwind merge config * fix: adapt tailwind merge config * fix: adapt tailwind merge config * fix: changeset * ci(changesets): version packages (beta) * fix(tailwind): add missing values config for bg-grid plugin * fix: remove useless tw config * fix: add default styles * docs: changeset * docs: typo * chore: merge origin canary to beta * ci(changesets): version packages (beta) * chore: remove changeset & pre.json * chore: change to minor * chore(pre-release): enter pre-release mode * chore(deps): fix versions * chore(deps): revise changed packages * chore(deps): update tailwindcss version * ci(changesets): 📦 version packages (beta) (#5166) * ci(changesets): version packages (beta) * fix: add missing delimiter --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: winches <329487092@qq.com> * fix(docs): add missing semicolon * fix: animate about skeleton (#5198) * chore: pre release * ci(changesets): version packages (beta) (#5199) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * docs: blurred hover button style * fix: language selector blur (#5208) * fix: skeleton animate translate value (#5207) * fix: open in remote repo (#5214) * chore: upgrade tw version * fix: open in remote repo * fix: update lock * fix: select translate styles * Merge branch beta/release-next of github.com:heroui-inc/heroui into beta/release-next-original --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: WK Wong <wingkwong.code@gmail.com> Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Charlotte21110 <hejianer9@163.com> * fix: transition scale (#5284) * feat(toast): enable programatically closing a toast with a specific key (#5125) * feat(toast): add closeToast method * docs(toast): add example for programmatically closing toast * refactor: change button title in doc * refactor: add type for key * test: sync storybook example with the one in docs * chore: add changeset * refactor: fix grammar * chore: update toast package version change to patch * Merge branch 'canary' into pr/5125 * chore(changeset): add ref number * refactor(toast): export hooks * chore(docs): use flat buttons --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * ci(changesets): version packages (beta) (#5285) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(input): prevent accessibility label duplication (#5161) * fix(input): prevent accessibility label duplication * chore(chageset): add changeset * chore(changeset): include issue number --------- Co-authored-by: WK <wingkwong.code@gmail.com> * refactor: overlay & interactOutside (#5100) * fix: remove ariaShouldCloseOnInteractOutside usage * feat: add `@heroui/use-aria-overlay` * chore(popover): remove ariaHideOutside * fix(use-aria-modal-overlay): use useAriaOverlay instead * fix(use-aira-overlay): revise onInteractOutside * chore(deps): pnpm-lock.yaml * feat(modal): add ModalWithAutocompleteTemplate * chore(modal): remove state.close as handled by useInteractOutside * fix(use-aria-multiselect): add menuTriggerProps.onPressStart and change domProps to triggerProps * chore(use-aria-button): support onPressUp * chore(deps): pnpm-lock.yaml * chore(use-aria-multiselect): join by commas * fix(tooltip): use useAriaOverlay instead * fix(autocomplete): jest timeout issue * chore(deps): pnpm-lock.yaml * chore(changset): add changeset * chore(deps): bump versions * refactor(tooltip): move to type * chore(deps): bump RA versions (#5315) * chore(deps): bump RA versions * fix(scripts): incorrect docs path * chore(changeset): add changeset for bumping RA versions * fix(docs): incorrect import path * refactor(modal): use a simple example * ci(changesets): version packages (beta) (#5303) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat(input): adding outside-top prop (#4775) * feat(input): adding outside-top prop * chore(input): add outside-top to use-label-placement hook * refactor(input): use old method for computing labelPlacement in 'use-input' * fix(input): fix focus behaviouir and alignment for 'outside-top' * Merge branch 'canary' into pr/4775 * chore(changeset): include issue number * feat(system): useInputLabelPlacement * refactor(input): use useInputLabelPlacement * chore(changeset): add changeset --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * chore: sync latest changes to beta (#5347) * chore: add herohack announcement * fix(date-picker): error state (#5317) * fix(date-range-picker): fixed the error state in preset * Update giant-sloths-shop.md * Removed if statement * chore(date-picker): prettier --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * chore: banner replacement * fix(theme): clear button in mobile (#5252) * fix(toast): fixed close button hover position * fix(input): fixed the clear button rendering on smaller devices * Delete .changeset/soft-spoons-march.md * Update input.ts * Undo unrelated toast changes * fix(toast): icons (#5246) * feat(shared-icons): add loading icon * fix(toast): icons * chore(toast): revise types for icons * chore(changeset): add changeset * refactor: migrate eslint to v9 (#5267) * refactor: migrate eslint to v9 * chore: lint * chore: update eslint command * chore: fix lint warnings * chore: separate lint and lint:fix * chore: exclude contentlayer generated code * fix(scripts): add missing await * fix(autocomplete): persist last selected item position (#5286) * refactor(select): remove unnecessary code * fix(autocomplete): persist last selected item position * chore(changeset): add changeset * chore(deps): bump framer-motion version (#5287) * chore(deps): bump framer-motion version * fix: typing issues * chore(changeset): add changeset --------- Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> * chore(docs): supplement onAction & selectionBehavior (#5289) * fix(autocomplete): ensure focused item matches selected item after filter, selection (#5290) * fix(autocomplete): ensure focused item matches selected item after filter, selection * chore: apply type and default value * chore: add perpose coment in updated code * test: add focuskey management testcode * docs: add changeset * docs: update changeset * chore: remove comment * fix: broken components in stories (#5291) * chore(switch): remove xl size * chore(docs): remove xl size * chore(system-rsc): remove xl size * chore(circular-progress): remove xl size * chore: undo * chore(deps): bump RA versions (#5310) * chore(deps): ra version bump * chore(changeset): add changeset * fix(scripts): incorrect docs path --------- Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> * chore(docs): update meta data (#5311) * docs(layout.tsx): added text-foreground (#5316) * feat(tabs): add click handling for tab items in tests and implementation (#3917) Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix issues in tabs examples (#2405) Co-authored-by: WK Wong <wingkwong.code@gmail.com> * chore(docs): add missing onValueChange in CheckboxGroup (#5332) * ci(changesets): version packages (#5323) Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> * chore: remove pre.json --------- Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> Co-authored-by: Vishv Salvi <82429084+Vishvsalvi@users.noreply.github.com> Co-authored-by: KumJungMin <37934668+KumJungMin@users.noreply.github.com> Co-authored-by: liaoyinglong <vigossliao@gmail.com> Co-authored-by: zhengjitf <zhengjitf@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore(pre-release): enter pre-release mode * chore: update changesets * chore: remove changesets * chore: add changeset * chore: update `@heroui/react` pre version * fix(deps): add missing `@heroui/use-aria-overlay` import * fix: lock file (#5351) * ci(changesets): 📦 version packages (beta) (#5348) * ci(changesets): version packages (beta) * Merge branch 'beta/release-next' into changeset-release/beta/release-next --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: WK Wong <wingkwong.code@gmail.com> * chore: sync 2.8.0 to beta (#5388) * chore: remove outdated changeset * chore(pre-release): enter pre-release mode * chore(deps): bump RA versions (beta) (#5392) * chore(deps): bump RA versions * chore: add changeset * ci(changesets): version packages (beta) (#5393) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * refactor: remove RA dependencies (overaly & utils) (#5398) * refactor(system): remove `@react-aria/utils` package * refactor(system): remove `@react-aria/overlays` package * ci(changesets): version packages (beta) (#5399) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * refactor: RA optimization (#5401) * refactor(shared-utils): add common functions from `@react-aria/utils` * feat(system): add shouldClientNavigate & useRouter * refactor(deps): remove `@react-aria/utils` * feat(shared-utils): include common functions from RA * refactor: import functions from `@heroui/shared-utils` instead * chore(deps): pnpm-lock.yaml * chore: add changeset * chore(shared-utils): update directory * fix(shared-utils): add use client directive * feat: add `@heroui/use-viewport-size` * feat: add `@heroui/use-form-reset` * feat(use-resize): add hasResizeObserver & RefObject * feat(form): add useObjectRef * chore: update import * chore(deps): update dependencies * refactor(shared-utils): only keep utils * chore(deps): pnpm-lock.yaml * chore(changeset): add changeset * ci(changesets): version packages (beta) (#5406) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: transitions (#5409) * chore(changeset): add changeset * fix: outline style (#5421) * fix: outline style * chore(changeset): add changeset --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix(toast): Renaming the loadingIcon to loadingComponent (#4919) * fix: toast should be above the modal * fix: renaming the loadingIcon to loadingComponent * chore: adding changeset * chore: fixing conflicts * chore: adding the region props * fix: adding Marcus' suggestions * fix: marcus' suggestions * Revert all commits except 4c6bf32 * chore(toast): bump `@heroui/theme` in peerDependencies * chore: nits * chore: applying marcus' suggestions * chore(toast): update story --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * chore: use beta version * chore: delete pre.json * chore(pre-release): enter pre-release mode * chore(changeset): trigger release * chore(changeset): trigger release * chore: keep previous changesets * ci(changesets): version packages (beta) (#5429) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(table): header and isStriped missing radius (#5062) * fix(table): tableheader and isStriped missing radius * chore: add changeset * fix: fix missing radius styles * chore(changeset): update message * fix(theme): reorder radius --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix(slider): prevent NaN error for equal min / max values (#5044) * fix(slider): prevent NaN error for equal min/max values * fix: restore isdisabled code * fix(slider): perf prevent NaN error for equal min max values * refactor: slider code * fix(slider): prevent NaN error for equal min max values & add test * fix(slider): perf prevent NaN error for equal min max values * fix: remove redundant code * chore: add changeset * Revert "chore: add changeset" This reverts commit f31de4ac859e48eb09c8a14a546fed9e5197eccd. * chore(slider): add missing warn * refactor(slider): remove unnecessary line --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix: double fetch img src (#5417) * fix(image): double fetch when using custom image component * fix(avatar): avoid passing disableAnimation to dom & double fetch source * chore(changeset): include avatar * fix(autocomplete): empty button when selectorIcon is null (#5427) * fix(toast): Toast items close in reverse order (#5405) * fix(toast): correct closing order to implement proper FIFO behavior * chore(changeset): add changeset * fix(changeset): update issue number * chore(toast): use `!==` instead * feat(toast): apply exit animation to auto-close timeout --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix(table): remove removeWrapper on virtualized table (#5428) * fix(table): remove `removeWrapper` for virtualized table * chore(docs): update description for removeWrapper * chore(changeset): add changeset * fix(toast): fixed close button hover position (#5245) * fix(toast): fixed close button hover position * Update soft-spoons-march.md * Update toast.ts * chore(theme): prettier * Using "placement" to apply the top and bottom extension * fix(toast): modified hover for expanded region * update dependancy array * lint fix * Merge branch 'canary' into pr/5245 * chore(theme): remove line breaks * chore(changeset): add missing package * static extension size * fix(toast): static extension fix --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * feat(table): support custom sort icon (#5243) * feat(shared-icons): add SortIcon * feat(table): add CustomSortIcon story * feat(table): support custom sort icon * fix(table): handle functional sortIcon * chore(changeset): add changeset * chore(table): update type * feat(docs): add sortIcon to table * fix(docs): broken object * chore(shared-icons): lint * feat(docs): add example for sort icon * chore: bump pnpm & node version (#5442) * refactor: bump pnpm & node version * chore(deps): bump `@types/node` * fix(calendar): improve month and year picker selection for different zoom levels (#5151) * fix(calendar): improve month and year picker selection for different zoom levels * fix(calendar): improve month and year picker selection for different zoom levels * fix(calendar): prevent stale values while scrolling both year and month pickers simultaneously * docs: replace invalid yarn command (#5422) * chore: remove ph banner (#5437) * chore(changeset): update changeset message * chore: add line breaks --------- Co-authored-by: Nicolas Cappabianca <nicolas.cappabianca@gmail.com> Co-authored-by: WK <wingkwong.code@gmail.com> * feat(select): adding isClearable to select (#4785) * feat(select): adding isClearable to select * chore(select): add changeset * test(select): add tests for isClearable * chore(select): add theme package patch, improve the testcase, rename nextui package to heroui * fix(select): fixing alignment for clear button for different cases * Merge branch 'canary' into pr/4785 * Merge branch 'canary' into pr/4785 * fix(select): remove component level styling * fix(select): fix the alignment and focus behaviour * fix(select): shift clear buttojn close to trigger * fix(select): fix alignment for different variants * feat(select): add data-has-end-content * fix(theme): revise select styles with clear button and end content * feat(docs): add end content --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix(select): use span instead as trigger is button * fix(docs): add ToastProvider for blog post * ci(changesets): version packages (beta) (#5430) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(select): clear button test cases * fix(modal): draggable modal, scrollable on mobile (#5444) Co-authored-by: Vishv Salvi <vishvsalvi@Vishvs-MacBook-Air.local> * chore: trigger release * ci(changesets): version packages (beta) (#5445) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(theme): table header sorting icon transition (#5449) * fix: table header sorcting icon transition * chore(changeset): add changeset --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix(table): allow text selection with cursor in table cells (#5454) * fix(table): allow text selection with cursor in table cells * chore(changeset): add changeset --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * ci(changesets): version packages (beta) (#5450) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore: add back RA deps (#5466) * chore(deps): bump testing-library & jest versions (#5468) * refactor: revise test cases * chore(deps): bump testing-library & jest versions * ci(changesets): version packages (beta) (#5467) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * refactor(autocomplete): test cases * fix(use-theme): incorrect target theme * ci(changesets): version packages (beta) (#5470) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(use-theme): remove all theme values and add the new one * ci(changesets): version packages (beta) (#5472) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * docs: 2.8.0 (#5443) * chore(docs): update routes.json * chore(docs): bump versions * chore(docs): initial draft * chore(docs): add examples * chore(Docs): update credits and community * chore(docs): update date & what's next * chore(docs): update meta data * chore(docs): add update tags * chore(docs): add tableSortIcon example * chore(docs): revise sidebar width * chore(docs): remove package size optimization * chore(docs): update meta * ci(changesets): exit pre-release mode * chore: update package versions * chore(changeset): remove unrelated changeset * chore(deps): remove unused autoprefixer * chore(docs): update tailwind v4 content * chore(docs): update template doc content * chore(docs): update formatting * chore(toast): export getToastQueue (#5476) * chore(docs): add hydration issue handling to page router example (#5474) * docs(dark-mode): add hydration handling to page router example * chore(docs): format --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com> * chore(deps): bump tw4 versions * fix: handle files with paths containing empty space (#5478) * chore(docs): revise wordings in 2.8.0 blog * feat(slider): add getTooltipValue prop for custom tooltip value (#5384) * feat(slider): add getTooltipValue prop for custom tooltip value * feat(slider): fix coderabbit highlights * feat(slider): fixed wingkwong highlights * feat(slider): added custom-tooltip.raw.tsx?raw * feat(slider): improved custom-tooltip.raw.tsx * chore: undo README.md * chore(slider): use normal $ sign * chore(changeset): add changeset * chore(docs): formatting --------- Co-authored-by: andartadev1 <andartadev@gmail.com> Co-authored-by: WK Wong <wingkwong.code@gmail.com> * chore(docs): revise custom tooltip example * chore(docs): add custom tooltip example for slider * chore(deps): bump contentlayer2 & next-contentlayer2 * chore(docs): fix formatting * chore(docs): update metadata * chore: add v2.8.0 image --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: winches <329487092@qq.com> Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Charlotte21110 <hejianer9@163.com> Co-authored-by: Feiyu Zheng <67126194+ChaserZ98@users.noreply.github.com> Co-authored-by: Dmytro Klymenko <dmytro@klymenko.xyz> Co-authored-by: Abhinav Agarwal <78839973+abhinav700@users.noreply.github.com> Co-authored-by: Vishv Salvi <82429084+Vishvsalvi@users.noreply.github.com> Co-authored-by: KumJungMin <37934668+KumJungMin@users.noreply.github.com> Co-authored-by: liaoyinglong <vigossliao@gmail.com> Co-authored-by: zhengjitf <zhengjitf@gmail.com> Co-authored-by: Maharshi Alpesh <maharshialpesh@gmail.com> Co-authored-by: Yohan <58714229+kaishuige@users.noreply.github.com> Co-authored-by: Aditya Ray <96347576+adi-ray@users.noreply.github.com> Co-authored-by: Aakash Patel <ap0524@srmist.edu.in> Co-authored-by: Nicolas Cappabianca <nicolas.cappabianca@gmail.com> Co-authored-by: Vishv Salvi <vishvsalvi@Vishvs-MacBook-Air.local> Co-authored-by: Priyadharshini S <priyadharshinis5102@gmail.com> Co-authored-by: arar <77303253+ararTP@users.noreply.github.com> Co-authored-by: andartadev1 <andartadev@gmail.com> * chore: consolidated version part 2 * ci(changesets): version packages (#5482) Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> * fix(theme): use `outline-hidden` which is equivalent to `outline-none` (#5486) * fix: use `outline-hidden` which is equivalent to `outline-none` in v3 * chore: add changeset * ci(changesets): version packages (#5487) Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> * fix(number-input): label class being incorrectly mixed into the description (#5484) * fix(number-input): label class being incorrectly mixed into the description * chore: add issue number --------- Co-authored-by: wulimaomao <tao@trlab.com> Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix(docs): broken link in custom variants page (#5522) * refactor(alert): vertically center alert icon / endContent (#5512) * chore(deps): bump RA dependencies (#5517) * chore(deps): sync with RA release * fix(tabs): duplicate onClick * chore(docs): update tanstack content * chore(docs): set updated flag * chore(docs): update meta * fix(use-aria-overlay): sync with RA's overlay logic (#5529) * fix(use-aria-overlay): sync with RA logic * fix(use-aria-overlay): add onHide on onInteractOutsideStart * chore(changeset): add changeset * fix(popover): arrow glitch in popover content (#5504) * fix(popover): make PopoverContent children prop optional to fix TS error * chore(changeset): created changeset * fix(popover): do not show content when children is null / undefined * fix(popover): add test case * chore(changeset): update changeset message --------- Co-authored-by: i_nicck <i_nicck@i-niccks-MacBook-Air.local> Co-authored-by: WK Wong <wingkwong.code@gmail.com> * fix(avatar): broken fallbacks (#5519) * fix(toast): toastRegion leftover in DOM (#5508) * fix(theme): focus ring styles (#5531) * chore(deps): bump tailwind-variants version (#5538) * chore(deps): bump tailwind-variants version * chore(deps): add tailwind-merge * ci(changesets): version packages (#5516) Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> --------- Co-authored-by: Vishv Salvi <82429084+Vishvsalvi@users.noreply.github.com> Co-authored-by: Junior Garcia <jrgarciadev@gmail.com> Co-authored-by: KumJungMin <37934668+KumJungMin@users.noreply.github.com> Co-authored-by: liaoyinglong <vigossliao@gmail.com> Co-authored-by: zhengjitf <zhengjitf@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Anuj Kuralkar <76731106+anuj-kuralkar@users.noreply.github.com> Co-authored-by: Poli Sour <57824881+novsource@users.noreply.github.com> Co-authored-by: Nicolas Cappabianca <nicolas.cappabianca@gmail.com> Co-authored-by: winches <329487092@qq.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Charlotte21110 <hejianer9@163.com> Co-authored-by: Feiyu Zheng <67126194+ChaserZ98@users.noreply.github.com> Co-authored-by: Dmytro Klymenko <dmytro@klymenko.xyz> Co-authored-by: Abhinav Agarwal <78839973+abhinav700@users.noreply.github.com> Co-authored-by: Maharshi Alpesh <maharshialpesh@gmail.com> Co-authored-by: Yohan <58714229+kaishuige@users.noreply.github.com> Co-authored-by: Aditya Ray <96347576+adi-ray@users.noreply.github.com> Co-authored-by: Aakash Patel <ap0524@srmist.edu.in> Co-authored-by: Vishv Salvi <vishvsalvi@Vishvs-MacBook-Air.local> Co-authored-by: Priyadharshini S <priyadharshinis5102@gmail.com> Co-authored-by: arar <77303253+ararTP@users.noreply.github.com> Co-authored-by: andartadev1 <andartadev@gmail.com> Co-authored-by: wulimao49 <73568161+wulimao49@users.noreply.github.com> Co-authored-by: wulimaomao <tao@trlab.com> Co-authored-by: Shagun Sharma <108183568+nicck1@users.noreply.github.com> Co-authored-by: i_nicck <i_nicck@i-niccks-MacBook-Air.local>
654 lines
17 KiB
TypeScript
654 lines
17 KiB
TypeScript
import type {SVGProps} from "react";
|
|
import type {Selection, ChipProps, SortDescriptor} from "@heroui/react";
|
|
|
|
import React from "react";
|
|
import {
|
|
Table,
|
|
TableHeader,
|
|
TableColumn,
|
|
TableBody,
|
|
TableRow,
|
|
TableCell,
|
|
Input,
|
|
Button,
|
|
DropdownTrigger,
|
|
Dropdown,
|
|
DropdownMenu,
|
|
DropdownItem,
|
|
Chip,
|
|
User,
|
|
Pagination,
|
|
} from "@heroui/react";
|
|
|
|
export type IconSvgProps = SVGProps<SVGSVGElement> & {
|
|
size?: number;
|
|
};
|
|
|
|
export function capitalize(s: string) {
|
|
return s ? s.charAt(0).toUpperCase() + s.slice(1).toLowerCase() : "";
|
|
}
|
|
|
|
export const PlusIcon = ({size = 24, width, height, ...props}: IconSvgProps) => {
|
|
return (
|
|
<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>
|
|
);
|
|
};
|
|
|
|
export const VerticalDotsIcon = ({size = 24, width, height, ...props}: IconSvgProps) => {
|
|
return (
|
|
<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>
|
|
);
|
|
};
|
|
|
|
export const SearchIcon = (props: IconSvgProps) => {
|
|
return (
|
|
<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>
|
|
);
|
|
};
|
|
|
|
export const ChevronDownIcon = ({strokeWidth = 1.5, ...otherProps}: IconSvgProps) => {
|
|
return (
|
|
<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>
|
|
);
|
|
};
|
|
|
|
export 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"},
|
|
];
|
|
|
|
export const statusOptions = [
|
|
{name: "Active", uid: "active"},
|
|
{name: "Paused", uid: "paused"},
|
|
{name: "Vacation", uid: "vacation"},
|
|
];
|
|
|
|
export 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",
|
|
},
|
|
];
|
|
|
|
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 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 pages = Math.ceil(filteredItems.length / rowsPerPage) || 1;
|
|
|
|
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: "lg", src: user.avatar}}
|
|
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-400">{user.team}</p>
|
|
</div>
|
|
);
|
|
case "status":
|
|
return (
|
|
<Chip className="capitalize" color={statusColorMap[user.status]} size="sm" variant="flat">
|
|
{cellValue}
|
|
</Chip>
|
|
);
|
|
case "actions":
|
|
return (
|
|
<div className="relative flex justify-end items-center gap-2">
|
|
<Dropdown>
|
|
<DropdownTrigger>
|
|
<Button isIconOnly size="sm" variant="light">
|
|
<VerticalDotsIcon className="text-default-300" />
|
|
</Button>
|
|
</DropdownTrigger>
|
|
<DropdownMenu>
|
|
<DropdownItem key="view">View</DropdownItem>
|
|
<DropdownItem key="edit">Edit</DropdownItem>
|
|
<DropdownItem key="delete">Delete</DropdownItem>
|
|
</DropdownMenu>
|
|
</Dropdown>
|
|
</div>
|
|
);
|
|
default:
|
|
return cellValue;
|
|
}
|
|
}, []);
|
|
|
|
const onNextPage = React.useCallback(() => {
|
|
if (page < pages) {
|
|
setPage(page + 1);
|
|
}
|
|
}, [page, pages]);
|
|
|
|
const onPreviousPage = React.useCallback(() => {
|
|
if (page > 1) {
|
|
setPage(page - 1);
|
|
}
|
|
}, [page]);
|
|
|
|
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 onClear = React.useCallback(() => {
|
|
setFilterValue("");
|
|
setPage(1);
|
|
}, []);
|
|
|
|
const topContent = React.useMemo(() => {
|
|
return (
|
|
<div className="flex flex-col gap-4">
|
|
<div className="flex justify-between gap-3 items-end">
|
|
<Input
|
|
isClearable
|
|
className="w-full sm:max-w-[44%]"
|
|
placeholder="Search by name..."
|
|
startContent={<SearchIcon />}
|
|
value={filterValue}
|
|
onClear={() => onClear()}
|
|
onValueChange={onSearchChange}
|
|
/>
|
|
<div className="flex gap-3">
|
|
<Dropdown>
|
|
<DropdownTrigger className="hidden sm:flex">
|
|
<Button endContent={<ChevronDownIcon className="text-small" />} 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" />} 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 color="primary" endContent={<PlusIcon />}>
|
|
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-solid outline-transparent 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">
|
|
<span className="w-[30%] text-small text-default-400">
|
|
{selectedKeys === "all"
|
|
? "All items selected"
|
|
: `${selectedKeys.size} of ${filteredItems.length} selected`}
|
|
</span>
|
|
<Pagination
|
|
isCompact
|
|
showControls
|
|
showShadow
|
|
color="primary"
|
|
page={page}
|
|
total={pages}
|
|
onChange={setPage}
|
|
/>
|
|
<div className="hidden sm:flex w-[30%] justify-end gap-2">
|
|
<Button isDisabled={pages === 1} size="sm" variant="flat" onPress={onPreviousPage}>
|
|
Previous
|
|
</Button>
|
|
<Button isDisabled={pages === 1} size="sm" variant="flat" onPress={onNextPage}>
|
|
Next
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}, [selectedKeys, items.length, page, pages, hasSearchFilter]);
|
|
|
|
return (
|
|
<Table
|
|
isHeaderSticky
|
|
aria-label="Example table with custom cells, pagination and sorting"
|
|
bottomContent={bottomContent}
|
|
bottomContentPlacement="outside"
|
|
classNames={{
|
|
wrapper: "max-h-[382px]",
|
|
}}
|
|
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>
|
|
);
|
|
}
|