nitro-web 0.0.131 → 0.0.133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/index.ts CHANGED
@@ -25,7 +25,7 @@ export { Accordion } from '../components/partials/element/accordion'
25
25
  export { Avatar } from '../components/partials/element/avatar'
26
26
  export { Button } from '../components/partials/element/button'
27
27
  export { Calendar, type CalendarProps } from '../components/partials/element/calendar'
28
- export { Dropdown, type DropdownProps } from '../components/partials/element/dropdown'
28
+ export { Dropdown, type DropdownProps, type DropdownOption } from '../components/partials/element/dropdown'
29
29
  export { Filters, type FiltersHandleType, type FilterType } from '../components/partials/element/filters'
30
30
  export { GithubLink } from '../components/partials/element/github-link'
31
31
  export { Initials } from '../components/partials/element/initials'
@@ -47,7 +47,7 @@ export { FieldCurrency, type FieldCurrencyProps } from '../components/partials/f
47
47
  export { FieldDate, type FieldDateProps } from '../components/partials/form/field-date'
48
48
  export { FieldTime, type FieldTimeProps } from '../components/partials/form/field-time'
49
49
  export { Location } from '../components/partials/form/location'
50
- export { Select, getSelectStyle, type SelectProps } from '../components/partials/form/select'
50
+ export { Select, getSelectStyle, type SelectProps, type SelectOption } from '../components/partials/form/select'
51
51
 
52
52
  // Component Other Components
53
53
  export { IsFirstRender } from '../components/partials/is-first-render'
@@ -3,6 +3,16 @@ import { forwardRef, cloneElement } from 'react'
3
3
  import { getSelectStyle, twMerge } from 'nitro-web'
4
4
  import { CheckCircleIcon } from '@heroicons/react/24/solid'
5
5
 
6
+ export type DropdownOption = {
7
+ label: string|React.ReactNode,
8
+ onClick?: Function,
9
+ isSelected?: boolean,
10
+ icon?: React.ReactNode,
11
+ iconLeft?: React.ReactNode,
12
+ /** Prevent the dropdown from closing when the option is clicked */
13
+ preventCloseOnClick?: boolean,
14
+ className?: string
15
+ }
6
16
  export type DropdownProps = {
7
17
  allowOverflow?: boolean
8
18
  animate?: boolean
@@ -11,16 +21,7 @@ export type DropdownProps = {
11
21
  css?: string
12
22
  /** The direction of the menu **/
13
23
  dir?: 'bottom-left'|'bottom-right'|'top-left'|'top-right'
14
- options?: {
15
- label: string|React.ReactNode,
16
- onClick?: Function,
17
- isSelected?: boolean,
18
- icon?: React.ReactNode,
19
- iconLeft?: React.ReactNode,
20
- /** Prevent the dropdown from closing when the option is clicked */
21
- preventCloseOnClick?: boolean,
22
- className?: string
23
- }[]
24
+ options?: DropdownOption[]
24
25
  /** Whether the dropdown is hoverable **/
25
26
  isHoverable?: boolean
26
27
  /** The content to render inside the top of the dropdown **/
@@ -20,7 +20,12 @@ type GetSelectStyle = {
20
20
  hasError?: boolean
21
21
  usePrefixes?: boolean
22
22
  }
23
-
23
+ export type SelectOption = {
24
+ value: unknown,
25
+ label: string | React.ReactNode,
26
+ fixed?: boolean,
27
+ data?: { [key: string]: unknown }
28
+ }
24
29
  /** Select (all other props are passed to react-select) **/
25
30
  export type SelectProps = {
26
31
  /** field name or path on state (used to match errors), e.g. 'date', 'company.email' **/
@@ -35,8 +40,8 @@ export type SelectProps = {
35
40
  prefix?: string
36
41
  /** The onChange handler **/
37
42
  onChange?: (event: { target: { name: string, value: unknown } }) => void
38
- /** The options to display in the dropdown **/
39
- options: { value: unknown, label: string | React.ReactNode, fixed?: boolean, [key: string]: unknown }[]
43
+ /** The options to display in the dropdown, data is used to pass additional data to the option **/
44
+ options: SelectOption[]
40
45
  /** The state object to get the value and check errors from **/
41
46
  state?: { errors?: Errors, [key: string]: any } // was unknown|unknown[]
42
47
  /** Select variations **/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-web",
3
- "version": "0.0.131",
3
+ "version": "0.0.133",
4
4
  "repository": "github:boycce/nitro-web",
5
5
  "homepage": "https://boycce.github.io/nitro-web/",
6
6
  "description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",