Giter Site home page Giter Site logo

rizzui / rizzui Goto Github PK

View Code? Open in Web Editor NEW
90.0 4.0 11.0 8.43 MB

🎉 A Modern and Minimal React UI Library built with TailwindCSS

Home Page: https://www.rizzui.com

JavaScript 1.43% Shell 0.01% TypeScript 49.60% CSS 3.30% HTML 0.01% MDX 45.65%
react-component-library reactjs tailwindcss typescript components

rizzui's Introduction

RizzUI 🎉

A Modern and Minimal React UI Library built with TailwindCSS. Designed to provide you with a simple and intuitive set of UI components that are easy to use, customize and integrate into your React application. We have carefully crafted each component to ensure that they are responsive, accessible and consistent across different devices and browsers.

Getting Started

Visit https://rizzui.com to get started with RizzUI.

Warning

We are using rizzui for Isomorphic. We will make any necessary adjustments to ensure compatibility with Isomorphic requirements.

License

MIT

rizzui's People

Contributors

explitan avatar idris95 avatar md-nahid avatar neamatmim avatar semanticist21 avatar tareqmahmud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rizzui's Issues

How to avoid default filtering on Select searchable true

Hey I just noticed that we are not able to avoid default filtering when searchable is true.
This is my code

'use client';

import { Select, type SelectOption, SelectProps } from 'rizzui';
import { useEffect, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import axiosInstance from '@/services/axios-instance.ts';
import { AsyncAutocompleteOption } from '@/types/autocomplete.ts';

interface AsyncSelectProps extends Omit<SelectProps<SelectOption>, 'options' | 'onSearchChange' | 'searchable'> {
  url: string;
  filters?: Record<string, any>;
}

export default function AsyncSelect({ url, filters, ...props }: AsyncSelectProps) {
  const [options, setOptions] = useState<SelectOption[]>([]);
  const [queryParams, setQueryParams] = useState<Record<string, any>>({
    page: 1,
    search: '',
    ...filters,
  });
  
  const fetchOptions = async () => {
    const params = new URLSearchParams({ ...queryParams }).toString();
    const response = await axiosInstance.get(`${url}?${params}`);
    return await response.data;
  };
  
  const { data } = useQuery({
    queryKey: [url, queryParams],
    queryFn: fetchOptions,
  });
  
  useEffect(() => {
    if (data) {
      setOptions((prevOptions) => {
        const existingIds = new Set(prevOptions.map((option: SelectOption) => option.value));
        const newOptions = data.results
        .filter((option: AsyncAutocompleteOption) => !existingIds.has(option.id))
        .map((item: AsyncAutocompleteOption) => ({
          value: item.id,
          label: item.text,
        }));
        return [...prevOptions, ...newOptions];
      });
    }
  }, [data]);

  const handleInputChange = (newValue: string) => {
    setQueryParams({ ...queryParams, search: newValue, page: 1 });
  };
  
  return (
    <Select
      { ...props }
      searchable={ true }
      searchPlaceHolder="Buscar..."
      onSearchChange={ handleInputChange }
      options={ options }
    />
  )
}

I'm creating an async select wrapper which fetch information from the backend using queryParams. So my backend requires a search param and then it filters by two different fields let's say "name" and "identification". So it's working fine for the name because that's my label but if I type an identification it pulls the information from the backend but the Select is making an extra filtering using searchByKey and searchQuery, right here

  const filteredOptions = useMemo(
    () =>
      options.filter((item) =>
        item[searchByKey].toLowerCase().includes(searchQuery.toLowerCase())
      ),
    [searchQuery, options]
  );

This is a possible workaround from MUI Autocomplete:
"Search as you type

If your logic is fetching new options on each keystroke and using the current value of the textbox to filter on the server, you may want to consider throttling requests.

Additionally, you will need to disable the built-in filtering of the Autocomplete component by overriding the filterOptions prop:

<Autocomplete filterOptions={(x) => x} />"
image

Ran an npm update and getting this error

Failed to compile
./node_modules/rizzui/dist/index.mjs
Attempted import error: 'Label' is not exported from 'barrel_optimize?names=Label,Listbox,ListboxButton,ListboxOption,ListboxOptions,Transition!=!@headlessui/react' (imported as 'li').

Multiselect component does not reload options after loading API data

Hello, I have tried to create a Multiselect component loading data from my API. The component works fine with static data, using the example in the documentation, but I have tried loading the options from my API but the problem I have is that the component does not redraw the options once the data has been loaded from the API.
This is my code

'use client';

import { useEffect, useState } from 'react';

import { type Table as ReactTableType } from '@tanstack/react-table';
import TableSearchInput from '@/app/shared/table/table-search-input.tsx';
import { MultiSelect, MultiSelectOption } from "rizzui";
import { useQuery } from '@tanstack/react-query';
import { getProductParentCategories } from '@/services/products-categories.tsx';

interface TableToolbarProps<T extends Record<string, any>> {
  table: ReactTableType<T>;
}

export default function TableToolbar<TData extends Record<string, any>>({
  table,
}: TableToolbarProps<TData>) {
  const [value, setValue] = useState<string[]>([]);
  const [parentCategoriesOptions, setParentCategoriesOptions] = useState<MultiSelectOption[]>([]);
  const { data: parentCategoriesData } = useQuery({
    queryKey: ['product-parent-categories'],
    queryFn: getProductParentCategories,
  });

  useEffect(() => {
    const options = parentCategoriesData?.map((category) => ({
      value: String(category.id),
      label: category.name,
    }));
    setParentCategoriesOptions(options || []);
  }, [parentCategoriesData]);

  const {
    options: { meta },
  } = table;
  
  return (
    <div className="flex w-full flex-col items-center justify-between gap-3 md:flex-row md:w-auto">
      <div className="flex w-full flex-col gap-3 md:flex-row md:w-auto">
          <MultiSelect
            searchable={true}
            className="w-full min-w-[158px] md:w-auto"
            placeholder="Categorías"
            options={parentCategoriesOptions}
            onChange={(selectedValues: string[]) => setValue(selectedValues)}
            value={value}
          />
      </div>
      <div className="w-full md:w-80">
        <TableSearchInput
          value={table.getState().globalFilter ?? ''}
          onClear={() => table.setGlobalFilter('')}
          onChange={(value) => table.setGlobalFilter(value)}
        />
      </div>
    </div>
  );
}

An this is the result for that
image
So then the options are displayed when you type something in the search bar
image
I found an approach adding a if clause like this

      <div className="flex w-full flex-col gap-3 md:flex-row md:w-auto">
        { parentCategoriesOptions.length > 0 && (
          <MultiSelect
            searchable={true}
            className="w-full min-w-[158px] md:w-auto"
            placeholder="Categorías"
            options={parentCategoriesOptions}
            onChange={(selectedValues: string[]) => setValue(selectedValues)}
            value={value}
          />
        )}
      </div>

So this prevents the initial rendering until get my data from the backend but it's a hacky solution.
And btw is there a way to use a different type for the select options?
I use typescript, so I am forced to perform this conversion every time.

    const options = parentCategoriesData?.map((category) => ({
      value: String(category.id),
      label: category.name,
    }));

Next js 14 Modal Import Issue

This error is coming when I am going to import and use the modal component in the next js project. How can it be solved?

`Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of De.`

error

Accordion issue

Using the Accordion seems to cause issues with Typescript
Type error: Type '({ open }: { open: boolean;}) => JSX.Element' is not assignable to type '((string | number | bigint | boolean | ReactElement<any, string | JSXElementConstructor> | Iterable | ReactPortal | Promise<...> | (({ open }: { ...; }) => ReactNode)) & (string | ... 6 more ... | Promise<...>)) | null | undefined'.
Type '({ open }: { open: boolean;}) => JSX.Element' is not assignable to type '(({ open }: { open: boolean; }) => ReactNode) & string'.
Type '({ open }: { open: boolean;}) => JSX.Element' is not assignable to type 'string'.

27 |
28 | <Accordion.Header>

29 | {({ open }: { open: boolean }) => (
| ^
30 |


31 | Order Details
32 | <ChevronDownIcon
Thanks

How can i perform using two modal

i tried showing two modal in on component

  const { openModal: openModalAddItem } = useModal();
  const { openModal: openModalAddTracking } = useModal();

but i've seen this hook using same state , my goals can create callback when user close modal,
here this

'use client';

import { useEffect } from 'react';
import { usePathname } from 'next/navigation';
import { Modal } from 'rizzui';
import { useModal } from '@/app/shared/modal-views/use-modal';

export default function GlobalModal() {
  const { isOpen, view, customSize, size, closeModal, onClose } = useModal();
  const pathname = usePathname();
  useEffect(() => {
    closeModal();
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [pathname]);

  const handleCloseModal = () => {
    onClose && onClose();
  };

  return (
    <Modal
      isOpen={isOpen}
      onClose={handleCloseModal}
      customSize={customSize}
      size={size}
      overlayClassName="dark:bg-opacity-40 dark:backdrop-blur-lg"
      containerClassName="dark:bg-gray-100"
      className="z-[999] [&_.pointer-events-none]:overflow-visible"
    >
      {view}
    </Modal>
  );
}

can you give other hint for this?

Select Dropdown Option is Not Showing In Modal When The Modal is Initiated from Popover

Everything Except the Select Options is working fine when added absolute for the dropdownClassName with an index of [99999] The dropdown still shows the other functionality like the selection is not working..
My Modal Trigger through PopOver Code
<Popover
isOpen={openPopoverId === row.id}
setIsOpen={(isOpen) => setOpenPopoverId(isOpen ? row.id : null)}
>
<Popover.Trigger>
<ActionIcon
onClick={() => setOpenPopoverId(openPopoverId === row.id ? null : row.id)}
className="action-icon-wrapper"
variant="text"
>


</Popover.Trigger>
<Popover.Content>


<EditModal
member={row}
onUpdate={(updatedMember) => {
console.log('Member updated:', updatedMember);
setOpenPopoverId(null); // Close popover after update
}}
/>
{
row.due > 0 &&
}
<Button
// size="sm"
variant="text"
// onClick={() => setIsOpen(true)}
className="flex flex-row gap-2 items-center justify-start font-medium hover:scale-105 duration-300"
>

Renew



</Popover.Content>

const EditModal: React.FC<{ member: Member; onUpdate: (updatedMember: Member) => void }> = ({ member, onUpdate }) => {
// My Declarations
};
return (
<>
<Button
// size="sm"
variant="text"
onClick={() => setIsOpen(true)}
className="flex flex-row gap-2 items-center justify-start font-medium hover:scale-105 duration-300"
>

Edit

<Modal isOpen={isOpen} onClose={() => setIsOpen(false)}>



Edit Member


<ActionIcon
size="sm"
variant="text"
onClick={() => setIsOpen(false)}
>



        <Input
          name="name"
          label="Name *"
          placeholder="Enter Full Name"
          value={data.name}
          onChange={handleInputChange}
        />
        <Input
          name="email"
          label="Email *"
          placeholder="Enter email"
          value={data.email}
          onChange={handleInputChange}
        />
        <PhoneNumber
          label="Phone Number *"
          country="us"
          value={data.phone}
          onChange={handlePhoneChange}
        />
        <Input
          name="date_of_birth"
          type="date"
          label="Date of Birth"
          value={data.date_of_birth}
          onChange={handleInputChange}
        />
        <Input
          name="joining_date"
          type="date"
          label="Joining Date"
          value={data.joining_date}
          onChange={handleInputChange}
        />
        <Select
          name="gender"
          label="Gender"
          options={[
            { label: 'Male', value: 'male' },
            { label: 'Female', value: 'female' },
            { label: 'Other', value: 'other' }
          ]}
          value={data.gender}
          onChange={({value}:{label:string,value:string}) => setData((prev) => ({ ...prev, gender: value }))}
        />
        <Input
          name="address_street"
          label="Street Address"
          placeholder="Street Address"
          className="col-span-full"
          value={data.address_street}
          onChange={handleInputChange}
        />
        <Input
          name="address_state"
          label="State"
          placeholder="State"
          value={data.address_state}
          onChange={handleInputChange}
        />
        <Input
          name="address_city"
          label="City"
          placeholder="City"
          value={data.address_city}
          onChange={handleInputChange}
        />
        <Input
          name="address_country"
          label="Country"
          placeholder="Country"
          value={data.address_country}
          onChange={handleInputChange}
        />
        <Input
          name="address_zip_code"
          label="ZIP / Postcode"
          placeholder="ZIP / postcode"
          value={data.address_zip_code}
          onChange={handleInputChange}
        />
      </div>
      <div className="mt-6 flex justify-end gap-3">
        <Button variant="outline" onClick={() => setIsOpen(false)}>
          Cancel
        </Button>
        <Button variant="solid" color="primary" onClick={handleEdit}>
          Update
        </Button>
      </div>
    </div>
  </Modal>
</>

);
};

Controllable Focus in Select Component

Is it possible to make "controllable" auto focus in <Select /> component?

the code something like this:

     useEffect(() => {
         setFocus('area_origin_id');
         // setFocus --> API react-hook-form
     }, [setFocus]);
     
     
      <Controller 
        control={control}
        name="area_origin_id"
        render={({ field: { value, onChange, ref } }) => (
          <Select
            searchType="search"
            label="Area Pick Up"
            className="col-span-1"
            labelClassName="text-gray-900"
            inPortal={false}
            value={value}
            onChange={(val) => {
              onChange(val);
              setTimeout(() => {
                setFocus("pickup_address");
              }, 200);
            }}
            ref={ref}
            options={orgAreaOpt || []}
            getOptionValue={(option) => option.value}
            displayValue={(selected: number) => {
              return (orgAreaOpt || []).find((item) => item.value === selected)
                ?.label;
            }}
            searchable
            error={errors?.area_origin_id?.message}
            clearable
            disabled={!orgAreaOpt}
            onClear={() => {
              resetField("area_origin_id", { defaultValue: undefined });
            }}
          />
        )}
      />

Its work in <Input /> component but not work in <Select /> component.

How can I change the overflow className of a Modal in tailwind?

hello i need your help thank you!
I want to change the over-flow hidden of the div tag whose className is pointer-events-none relative w-full transform overflow-hidden transition-all opacity-100 scale-100 to visible, but there is no change even if I give !overflow-visible to the overlayClassName and containerClassName. What should I do?

Cannot add `node_modules/rizzui/dist` to Tailwind

Hi,

I'm new to Tailwind. Using Bun monorepo / Turborepo / Next.js with a bunch of apps and packages.

When I install all the deps in the app, they actually live in the node_modules folder of the monorepo, not of each app/package.

I assume it's something by design in Bun.sh or Turborepo.

Which means i can't just do ../../node_modules/rizzui/dist in the content object for Tailwind.

Any other way to add the JS files? A plugin or some other way?

The only workaround I found was to move rizzui as a package under root/packages, but looking to just import it from the native module.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.