@brosco/ui 0.0.128 → 0.0.130

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.
@@ -0,0 +1,120 @@
1
+ import { ContextMenuPortalProps, Menu as Menu_2 } from "@base-ui/react"
2
+ import {
3
+ ComponentProps,
4
+ ComponentPropsWithoutRef,
5
+ ComponentType,
6
+ ForwardRefExoticComponent,
7
+ JSX,
8
+ PropsWithChildren,
9
+ ReactElement,
10
+ RefAttributes,
11
+ } from "react"
12
+ import { TVReturnType, TVReturnTypeLike, VariantProps } from "tailwind-variants"
13
+
14
+ declare type ContextValue = {
15
+ link: ComponentType<
16
+ Omit<ComponentPropsWithoutRef<"a">, "href"> & {
17
+ href: string
18
+ }
19
+ >
20
+ pathname: string
21
+ }
22
+
23
+ export declare const DropdownMenu: ({ menu, ...props }: Props) => JSX.Element
24
+
25
+ declare const Menu: {
26
+ Positioner: (props: Menu_2.Positioner.Props) => JSX.Element
27
+ Popup: ({ className, ...props }: Menu_2.Popup.Props) => JSX.Element
28
+ Separator: ({ className, ...props }: Menu_2.Separator.Props) => JSX.Element
29
+ Item: ({
30
+ isActive,
31
+ isDanger,
32
+ className,
33
+ disabled,
34
+ render,
35
+ ...props
36
+ }: MenuItemProps) => JSX.Element
37
+ Group: ({ className, ...props }: Menu_2.Group.Props) => JSX.Element
38
+ GroupLabel: ({ className, ...props }: Menu_2.GroupLabel.Props) => JSX.Element
39
+ Root: <Payload>(props: Menu_2.Root.Props<Payload>) => React.JSX.Element
40
+ Trigger: Menu_2.Trigger
41
+ Portal: ForwardRefExoticComponent<
42
+ Omit<ContextMenuPortalProps, "ref"> & RefAttributes<HTMLDivElement>
43
+ >
44
+ }
45
+
46
+ declare type MenuItemProps = Menu_2.Item.Props &
47
+ VariantProps<typeof menuVariants>
48
+
49
+ declare const menuVariants: TVReturnType<
50
+ {
51
+ isActive: {
52
+ true: "menu--item-active"
53
+ }
54
+ isDanger: {
55
+ true: "menu--item-danger"
56
+ }
57
+ },
58
+ undefined,
59
+ undefined,
60
+ {
61
+ isActive: {
62
+ true: "menu--item-active"
63
+ }
64
+ isDanger: {
65
+ true: "menu--item-danger"
66
+ }
67
+ },
68
+ undefined,
69
+ TVReturnTypeLike<
70
+ {
71
+ isActive: {
72
+ true: "menu--item-active"
73
+ }
74
+ isDanger: {
75
+ true: "menu--item-danger"
76
+ }
77
+ },
78
+ undefined
79
+ >
80
+ >
81
+
82
+ declare type NonEmptyArray<T> = [T, ...T[]]
83
+
84
+ declare type PartialBy<T, K extends keyof T = keyof T> = Omit<T, K> &
85
+ Partial<Pick<T, K>>
86
+
87
+ declare type Props = ComponentProps<typeof Menu.Trigger> & {
88
+ menu: NonEmptyArray<{
89
+ groupLabel?: string
90
+ items: NonEmptyArray<
91
+ {
92
+ label: string
93
+ icon: ReactElement
94
+ isDanger?: true
95
+ disabled?: boolean
96
+ } & (
97
+ | {
98
+ href: string
99
+ onClick?: never
100
+ }
101
+ | {
102
+ href?: never
103
+ onClick: () => void
104
+ }
105
+ )
106
+ >
107
+ }>
108
+ }
109
+
110
+ declare type ProviderProps = PropsWithChildren<PartialBy<ContextValue, "link">>
111
+
112
+ export declare const UIProvider: ({
113
+ link,
114
+ pathname,
115
+ children,
116
+ }: ProviderProps) => JSX.Element
117
+
118
+ export declare const useUIContext: () => ContextValue
119
+
120
+ export {}
package/dist/client.js ADDED
@@ -0,0 +1 @@
1
+ "use client";import{t as e}from"./menu-DOI75GlK.js";import{Fragment as t,createContext as n,useContext as r}from"react";import{jsx as i,jsxs as a}from"react/jsx-runtime";var o=n(null),s=({link:e=e=>/* @__PURE__ */ i(`a`,{...e}),pathname:t=`/`,children:n})=>/* @__PURE__ */ i(o,{value:{link:e,pathname:t},children:n}),c=()=>{let e=r(o);if(!e)throw Error(`useUIContext must be used within UIProvider`);return e},l=({menu:n,...r})=>{let{link:o,pathname:s}=c();return/* @__PURE__ */ a(e.Root,{children:[/* @__PURE__ */ i(e.Trigger,{...r}),/* @__PURE__ */ i(e.Portal,{children:/* @__PURE__ */ i(e.Positioner,{children:/* @__PURE__ */ i(e.Popup,{children:n.map(({items:r,groupLabel:c},l)=>/* @__PURE__ */ a(t,{children:[/* @__PURE__ */ a(e.Group,{children:[c&&/* @__PURE__ */ i(e.GroupLabel,{children:c}),r.map(({label:t,isDanger:n,icon:r,href:c,disabled:l,onClick:u})=>/* @__PURE__ */ a(e.Item,{disabled:l,isActive:s===c,isDanger:n,render:c?/* @__PURE__ */ i(o,{href:c}):void 0,onClick:u,children:[r,t]},c||t))]}),n.length-l>1&&/* @__PURE__ */ i(e.Separator,{})]},r[0].label))})})})]})};export{l as DropdownMenu,s as UIProvider,c as useUIContext};
@@ -0,0 +1 @@
1
+ import{Menu as e}from"@base-ui/react";import{isValidElement as t}from"react";import{jsx as n}from"react/jsx-runtime";import{cn as r,tv as i}from"tailwind-variants";var a=e=>t(e)&&typeof e.props==`object`&&e.props&&`href`in e.props,o=i({variants:{isActive:{true:`menu--item-active`},isDanger:{true:`menu--item-danger`}}}),s={Positioner:t=>/* @__PURE__ */ n(e.Positioner,{sideOffset:8,...t}),Popup:({className:t,...i})=>/* @__PURE__ */ n(e.Popup,{className:r(`menu--popup`,t),...i}),Separator:({className:t,...i})=>/* @__PURE__ */ n(e.Separator,{className:r(`menu--separator`,t),...i}),Item:({isActive:t,isDanger:i,className:s,disabled:c,render:l,...u})=>{let d=a(l);return/* @__PURE__ */ n(e.Item,{className:r(`menu--item`,o({isActive:t,isDanger:i}),s,t&&`opacity-100`),disabled:t||c,nativeButton:!d,render:l,...u})},Group:({className:t,...i})=>/* @__PURE__ */ n(e.Group,{className:r(`menu--group`,t),...i}),GroupLabel:({className:t,...i})=>/* @__PURE__ */ n(e.GroupLabel,{className:r(`menu--group-label`,t),...i}),Root:e.Root,Trigger:e.Trigger,Portal:e.Portal};export{a as n,s as t};
@@ -4,13 +4,8 @@ import {
4
4
  Menu as Menu_2,
5
5
  } from "@base-ui/react"
6
6
  import {
7
- ComponentProps,
8
- ComponentPropsWithoutRef,
9
- ComponentType,
10
7
  ForwardRefExoticComponent,
11
8
  JSX,
12
- PropsWithChildren,
13
- ReactElement,
14
9
  ReactNode,
15
10
  RefAttributes,
16
11
  SVGProps,
@@ -33,17 +28,6 @@ export declare const Button: ({
33
28
  ...props
34
29
  }: Props) => JSX.Element
35
30
 
36
- declare type ContextValue = {
37
- link: ComponentType<
38
- Omit<ComponentPropsWithoutRef<"a">, "href"> & {
39
- href: string
40
- }
41
- >
42
- pathname: string
43
- }
44
-
45
- export declare const DropdownMenu: ({ menu, ...props }: Props_2) => JSX.Element
46
-
47
31
  declare const linkVariants: TVReturnType<
48
32
  {
49
33
  variant: {
@@ -206,58 +190,20 @@ declare const menuVariants: TVReturnType<
206
190
  >
207
191
  >
208
192
 
209
- declare type NonEmptyArray<T> = [T, ...T[]]
210
-
211
- declare type PartialBy<T, K extends keyof T = keyof T> = Omit<T, K> &
212
- Partial<Pick<T, K>>
213
-
214
193
  declare type Props = ButtonProps &
215
194
  VariantProps<typeof linkVariants> & {
216
195
  icon?: ReactNode
217
196
  isPending?: boolean
218
197
  }
219
198
 
220
- declare type Props_2 = ComponentProps<typeof Menu.Trigger> & {
221
- menu: NonEmptyArray<{
222
- groupLabel?: string
223
- items: NonEmptyArray<
224
- {
225
- label: string
226
- icon: ReactElement
227
- isDanger?: true
228
- disabled?: boolean
229
- } & (
230
- | {
231
- href: string
232
- onClick?: never
233
- }
234
- | {
235
- href?: never
236
- onClick: () => void
237
- }
238
- )
239
- >
240
- }>
241
- }
242
-
243
- declare type Props_3 = SVGProps<SVGSVGElement> & {
199
+ declare type Props_2 = SVGProps<SVGSVGElement> & {
244
200
  size?: number
245
201
  }
246
202
 
247
- declare type ProviderProps = PropsWithChildren<PartialBy<ContextValue, "link">>
248
-
249
203
  export declare const Spinner: ({
250
204
  className,
251
205
  size,
252
206
  ...props
253
- }: Props_3) => JSX.Element
254
-
255
- export declare const UIProvider: ({
256
- link,
257
- pathname,
258
- children,
259
- }: ProviderProps) => JSX.Element
260
-
261
- export declare const useUIContext: () => ContextValue
207
+ }: Props_2) => JSX.Element
262
208
 
263
209
  export {}
package/dist/server.js ADDED
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./menu-DOI75GlK.js";import{Button as n}from"@base-ui/react";import{cn as r}from"cn";import{jsx as i,jsxs as a}from"react/jsx-runtime";import{tv as o}from"tailwind-variants";var s=({className:e,size:t=24,...n})=>/* @__PURE__ */ i(`svg`,{className:r(`spinner`,e),fill:`currentColor`,height:t,stroke:`currentColor`,strokeWidth:`0`,version:`1.1`,viewBox:`0 0 16 16`,width:t,xmlns:`http://www.w3.org/2000/svg`,...n,children:/* @__PURE__ */ i(`path`,{d:`M16 8c-0.020-1.045-0.247-2.086-0.665-3.038-0.417-0.953-1.023-1.817-1.766-2.53s-1.624-1.278-2.578-1.651c-0.953-0.374-1.978-0.552-2.991-0.531-1.013 0.020-2.021 0.24-2.943 0.646-0.923 0.405-1.758 0.992-2.449 1.712s-1.237 1.574-1.597 2.497c-0.361 0.923-0.533 1.914-0.512 2.895 0.020 0.981 0.234 1.955 0.627 2.847 0.392 0.892 0.961 1.7 1.658 2.368s1.523 1.195 2.416 1.543c0.892 0.348 1.851 0.514 2.799 0.493 0.949-0.020 1.89-0.227 2.751-0.608 0.862-0.379 1.642-0.929 2.287-1.604s1.154-1.472 1.488-2.335c0.204-0.523 0.342-1.069 0.415-1.622 0.019 0.001 0.039 0.002 0.059 0.002 0.552 0 1-0.448 1-1 0-0.028-0.001-0.056-0.004-0.083h0.004zM14.411 10.655c-0.367 0.831-0.898 1.584-1.55 2.206s-1.422 1.112-2.254 1.434c-0.832 0.323-1.723 0.476-2.608 0.454-0.884-0.020-1.759-0.215-2.56-0.57-0.801-0.354-1.526-0.867-2.125-1.495s-1.071-1.371-1.38-2.173c-0.31-0.801-0.457-1.66-0.435-2.512s0.208-1.694 0.551-2.464c0.342-0.77 0.836-1.468 1.441-2.044s1.321-1.029 2.092-1.326c0.771-0.298 1.596-0.438 2.416-0.416s1.629 0.202 2.368 0.532c0.74 0.329 1.41 0.805 1.963 1.387s0.988 1.27 1.272 2.011c0.285 0.74 0.418 1.532 0.397 2.32h0.004c-0.002 0.027-0.004 0.055-0.004 0.083 0 0.516 0.39 0.94 0.892 0.994-0.097 0.544-0.258 1.075-0.481 1.578z`})}),c=o({base:`button`,variants:{variant:{solid:`button--solid`,bordered:`button--bordered`,light:`button--light`},color:{primary:`button--primary`,secondary:`button--secondary`,success:`button--success`,danger:`button--danger`},rounded:{full:`rounded-full`,lg:`rounded-lg`,md:`rounded-md`,sm:`rounded-sm`,none:`rounded-none`},size:{sm:`button--sm`,md:`button--md`,lg:`button--lg`},isIconOnly:{true:`button--icon-only`,false:`px-4`},fullWidth:{true:`w-full`}},defaultVariants:{variant:`light`,color:`primary`,rounded:`lg`,size:`md`}}),l=o({extend:c,defaultVariants:{variant:`solid`}}),u=({children:t,className:o,render:u,icon:d,isPending:f,disabled:p,variant:m,color:h,rounded:g,size:_,isIconOnly:v,fullWidth:y,...b})=>{let x={variant:m,color:h,rounded:g,size:_,isIconOnly:v,fullWidth:y},S=e(u);return/* @__PURE__ */ a(n,{className:r(S?c(x):l(x),o),disabled:f||p,nativeButton:!S,render:u,...b,children:[f?/* @__PURE__ */ i(s,{}):d,!v&&t]})};export{u as Button,t as Menu,s as Spinner};
package/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "name": "@brosco/ui",
3
- "version": "0.0.128",
3
+ "version": "0.0.130",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
10
+ "types": "./dist/server.d.ts",
11
+ "import": "./dist/server.js"
12
+ },
13
+ "./client": {
14
+ "types": "./dist/client.d.ts",
15
+ "import": "./dist/client.js"
12
16
  },
13
17
  "./styles.css": "./dist/styles.css"
14
18
  },
@@ -23,7 +27,7 @@
23
27
  "tsc": "tsc --noEmit",
24
28
  "prepare": "husky"
25
29
  },
26
- "dependencies": {
30
+ "peerDependencies": {
27
31
  "@base-ui/react": "^1.8.0",
28
32
  "cn": "^0.4.0",
29
33
  "tailwind-variants": "^3.3.1"
@@ -48,6 +52,7 @@
48
52
  "prettier-plugin-merge": "^0.10.1",
49
53
  "prettier-plugin-tailwindcss": "^0.8.1",
50
54
  "rimraf": "^6.1.3",
55
+ "rollup-preserve-directives": "^1.1.3",
51
56
  "tailwindcss": "^4.3.3",
52
57
  "typescript": "^5.9.3",
53
58
  "typescript-eslint": "^8.71.0",
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- import{Button as e,Menu as t}from"@base-ui/react";import{cn as n}from"cn";import{Fragment as r,createContext as i,isValidElement as a,useContext as o}from"react";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{cn as l,tv as u}from"tailwind-variants";var d=e=>a(e)&&typeof e.props==`object`&&e.props&&`href`in e.props,f=({className:e,size:t=24,...r})=>/* @__PURE__ */ s(`svg`,{className:n(`spinner`,e),fill:`currentColor`,height:t,stroke:`currentColor`,strokeWidth:`0`,version:`1.1`,viewBox:`0 0 16 16`,width:t,xmlns:`http://www.w3.org/2000/svg`,...r,children:/* @__PURE__ */ s(`path`,{d:`M16 8c-0.020-1.045-0.247-2.086-0.665-3.038-0.417-0.953-1.023-1.817-1.766-2.53s-1.624-1.278-2.578-1.651c-0.953-0.374-1.978-0.552-2.991-0.531-1.013 0.020-2.021 0.24-2.943 0.646-0.923 0.405-1.758 0.992-2.449 1.712s-1.237 1.574-1.597 2.497c-0.361 0.923-0.533 1.914-0.512 2.895 0.020 0.981 0.234 1.955 0.627 2.847 0.392 0.892 0.961 1.7 1.658 2.368s1.523 1.195 2.416 1.543c0.892 0.348 1.851 0.514 2.799 0.493 0.949-0.020 1.89-0.227 2.751-0.608 0.862-0.379 1.642-0.929 2.287-1.604s1.154-1.472 1.488-2.335c0.204-0.523 0.342-1.069 0.415-1.622 0.019 0.001 0.039 0.002 0.059 0.002 0.552 0 1-0.448 1-1 0-0.028-0.001-0.056-0.004-0.083h0.004zM14.411 10.655c-0.367 0.831-0.898 1.584-1.55 2.206s-1.422 1.112-2.254 1.434c-0.832 0.323-1.723 0.476-2.608 0.454-0.884-0.020-1.759-0.215-2.56-0.57-0.801-0.354-1.526-0.867-2.125-1.495s-1.071-1.371-1.38-2.173c-0.31-0.801-0.457-1.66-0.435-2.512s0.208-1.694 0.551-2.464c0.342-0.77 0.836-1.468 1.441-2.044s1.321-1.029 2.092-1.326c0.771-0.298 1.596-0.438 2.416-0.416s1.629 0.202 2.368 0.532c0.74 0.329 1.41 0.805 1.963 1.387s0.988 1.27 1.272 2.011c0.285 0.74 0.418 1.532 0.397 2.32h0.004c-0.002 0.027-0.004 0.055-0.004 0.083 0 0.516 0.39 0.94 0.892 0.994-0.097 0.544-0.258 1.075-0.481 1.578z`})}),p=u({base:`button`,variants:{variant:{solid:`button--solid`,bordered:`button--bordered`,light:`button--light`},color:{primary:`button--primary`,secondary:`button--secondary`,success:`button--success`,danger:`button--danger`},rounded:{full:`rounded-full`,lg:`rounded-lg`,md:`rounded-md`,sm:`rounded-sm`,none:`rounded-none`},size:{sm:`button--sm`,md:`button--md`,lg:`button--lg`},isIconOnly:{true:`button--icon-only`,false:`px-4`},fullWidth:{true:`w-full`}},defaultVariants:{variant:`light`,color:`primary`,rounded:`lg`,size:`md`}}),m=u({extend:p,defaultVariants:{variant:`solid`}}),h=({children:t,className:r,render:i,icon:a,isPending:o,disabled:l,variant:u,color:h,rounded:g,size:_,isIconOnly:v,fullWidth:y,...b})=>{let x={variant:u,color:h,rounded:g,size:_,isIconOnly:v,fullWidth:y},S=d(i);return/* @__PURE__ */ c(e,{className:n(S?p(x):m(x),r),disabled:o||l,nativeButton:!S,render:i,...b,children:[o?/* @__PURE__ */ s(f,{}):a,!v&&t]})},g=u({variants:{isActive:{true:`menu--item-active`},isDanger:{true:`menu--item-danger`}}}),_={Positioner:e=>/* @__PURE__ */ s(t.Positioner,{sideOffset:8,...e}),Popup:({className:e,...n})=>/* @__PURE__ */ s(t.Popup,{className:l(`menu--popup`,e),...n}),Separator:({className:e,...n})=>/* @__PURE__ */ s(t.Separator,{className:l(`menu--separator`,e),...n}),Item:({isActive:e,isDanger:n,className:r,disabled:i,render:a,...o})=>{let c=d(a);return/* @__PURE__ */ s(t.Item,{className:l(`menu--item`,g({isActive:e,isDanger:n}),r,e&&`opacity-100`),disabled:e||i,nativeButton:!c,render:a,...o})},Group:({className:e,...n})=>/* @__PURE__ */ s(t.Group,{className:l(`menu--group`,e),...n}),GroupLabel:({className:e,...n})=>/* @__PURE__ */ s(t.GroupLabel,{className:l(`menu--group-label`,e),...n}),Root:t.Root,Trigger:t.Trigger,Portal:t.Portal},v=i(null),y=({link:e=e=>/* @__PURE__ */ s(`a`,{...e}),pathname:t=`/`,children:n})=>/* @__PURE__ */ s(v,{value:{link:e,pathname:t},children:n}),b=()=>{let e=o(v);if(!e)throw Error(`useUIContext must be used within UIProvider`);return e},x=({menu:e,...t})=>{let{link:n,pathname:i}=b();return/* @__PURE__ */ c(_.Root,{children:[/* @__PURE__ */ s(_.Trigger,{...t}),/* @__PURE__ */ s(_.Portal,{children:/* @__PURE__ */ s(_.Positioner,{children:/* @__PURE__ */ s(_.Popup,{children:e.map(({items:t,groupLabel:a},o)=>/* @__PURE__ */ c(r,{children:[/* @__PURE__ */ c(_.Group,{children:[a&&/* @__PURE__ */ s(_.GroupLabel,{children:a}),t.map(({label:e,isDanger:t,icon:r,href:a,disabled:o,onClick:l})=>/* @__PURE__ */ c(_.Item,{disabled:o,isActive:i===a,isDanger:t,render:a?/* @__PURE__ */ s(n,{href:a}):void 0,onClick:l,children:[r,e]},a||e))]}),e.length-o>1&&/* @__PURE__ */ s(_.Separator,{})]},t[0].label))})})})]})};export{h as Button,x as DropdownMenu,_ as Menu,f as Spinner,y as UIProvider,b as useUIContext};