@wheelhouse/ui 0.2.8 → 0.2.10

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.
@@ -10,11 +10,11 @@ declare const buttonVariantStyles: {
10
10
  readonly link: "text-primary underline-offset-4 hover:underline [&_[data-slot=button-loading-indicator]]:text-primary";
11
11
  };
12
12
  declare const buttonSizeStyles: {
13
- readonly default: "h-8 gap-2 px-[calc(--spacing(3)-1px)] text-base sm:text-sm has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3";
13
+ readonly default: "h-8 gap-2 px-[calc(--spacing(3)-1px)] text-sm has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3";
14
14
  readonly xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3";
15
- readonly sm: "h-7 gap-1.5 rounded-[min(var(--radius-md),12px)] px-[calc(--spacing(2.5)-1px)] text-base sm:text-sm in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3.5";
15
+ readonly sm: "h-7 gap-1.5 rounded-[min(var(--radius-md),12px)] px-[calc(--spacing(2.5)-1px)] text-sm in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3.5";
16
16
  readonly lg: "h-9 gap-1.5 px-[calc(--spacing(3.5)-1px)] text-base has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3 [&_svg:not([class*='size-'])]:size-3.5";
17
- readonly icon: "size-8";
17
+ readonly icon: "size-8 text-sm";
18
18
  readonly 'icon-xs': "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3";
19
19
  readonly 'icon-sm': "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg";
20
20
  readonly 'icon-lg': "size-9";
@@ -13,11 +13,11 @@ const buttonVariantStyles = {
13
13
  link: 'text-primary underline-offset-4 hover:underline [&_[data-slot=button-loading-indicator]]:text-primary',
14
14
  };
15
15
  const buttonSizeStyles = {
16
- default: "h-8 gap-2 px-[calc(--spacing(3)-1px)] text-base sm:text-sm has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3",
16
+ default: "h-8 gap-2 px-[calc(--spacing(3)-1px)] text-sm has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3",
17
17
  xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
18
- sm: "h-7 gap-1.5 rounded-[min(var(--radius-md),12px)] px-[calc(--spacing(2.5)-1px)] text-base sm:text-sm in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3.5",
18
+ sm: "h-7 gap-1.5 rounded-[min(var(--radius-md),12px)] px-[calc(--spacing(2.5)-1px)] text-sm in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3.5",
19
19
  lg: "h-9 gap-1.5 px-[calc(--spacing(3.5)-1px)] text-base has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3 [&_svg:not([class*='size-'])]:size-3.5",
20
- icon: 'size-8',
20
+ icon: 'size-8 text-sm',
21
21
  'icon-xs': "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
22
22
  'icon-sm': 'size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg',
23
23
  'icon-lg': 'size-9',
@@ -7,8 +7,8 @@ import { cn } from '../../lib/utils';
7
7
  const inputVariants = cva('flex w-full min-w-0 rounded-md border border-input bg-background shadow-xs transition-[color,box-shadow] outline-none group-has-disabled/field:opacity-50 file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-invalid:border-destructive data-invalid:ring-3 data-invalid:ring-destructive/20 dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 dark:data-invalid:border-destructive/50 dark:data-invalid:ring-destructive/40', {
8
8
  variants: {
9
9
  size: {
10
- sm: 'h-7 rounded-[min(var(--radius-md),12px)] px-[calc(--spacing(2.5)-1px)] text-base sm:text-sm',
11
- default: 'h-8 px-[calc(--spacing(3)-1px)] text-base sm:text-sm',
10
+ sm: 'h-7 rounded-[min(var(--radius-md),12px)] px-[calc(--spacing(2.5)-1px)] text-sm',
11
+ default: 'h-8 px-[calc(--spacing(3)-1px)] text-sm',
12
12
  lg: 'h-9 px-[calc(--spacing(3.5)-1px)] text-base',
13
13
  },
14
14
  },
@@ -0,0 +1,3 @@
1
+ export { useIsMobile } from './use-mobile';
2
+ export { useMediaQuery, type MediaQueryInput } from './use-media-query';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { useIsMobile } from './use-mobile';
2
+ export { useMediaQuery } from './use-media-query';
@@ -0,0 +1,19 @@
1
+ /** Matches Tailwind v4 default breakpoints (see tailwindcss theme). */
2
+ declare const BREAKPOINTS: {
3
+ readonly sm: 640;
4
+ readonly md: 768;
5
+ readonly lg: 1024;
6
+ readonly xl: 1280;
7
+ readonly '2xl': 1536;
8
+ };
9
+ type Breakpoint = keyof typeof BREAKPOINTS;
10
+ type BreakpointQuery = Breakpoint | `max-${Breakpoint}` | `${Breakpoint}:max-${Breakpoint}`;
11
+ export type MediaQueryInput = {
12
+ min?: Breakpoint | number;
13
+ max?: Breakpoint | number;
14
+ /** Touch-like input (finger). Use `fine` for mouse/trackpad. */
15
+ pointer?: 'coarse' | 'fine';
16
+ };
17
+ export declare function useMediaQuery(query: BreakpointQuery | MediaQueryInput | (string & {})): boolean;
18
+ export {};
19
+ //# sourceMappingURL=use-media-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-media-query.d.ts","sourceRoot":"","sources":["../../src/hooks/use-media-query.ts"],"names":[],"mappings":"AAIA,uEAAuE;AACvE,QAAA,MAAM,WAAW;;;;;;CAMP,CAAC;AAEX,KAAK,UAAU,GAAG,MAAM,OAAO,WAAW,CAAC;AAE3C,KAAK,eAAe,GAAG,UAAU,GAAG,OAAO,UAAU,EAAE,GAAG,GAAG,UAAU,QAAQ,UAAU,EAAE,CAAC;AAE5F,MAAM,MAAM,eAAe,GAAG;IAC1B,GAAG,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAC1B,GAAG,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAC1B,gEAAgE;IAChE,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC/B,CAAC;AAyCF,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,eAAe,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,OAAO,CAmB/F"}
@@ -0,0 +1,67 @@
1
+ 'use client';
2
+ import { useCallback, useSyncExternalStore } from 'react';
3
+ /** Matches Tailwind v4 default breakpoints (see tailwindcss theme). */
4
+ const BREAKPOINTS = {
5
+ sm: 640,
6
+ md: 768,
7
+ lg: 1024,
8
+ xl: 1280,
9
+ '2xl': 1536,
10
+ };
11
+ function resolveMin(value) {
12
+ const px = typeof value === 'number' ? value : BREAKPOINTS[value];
13
+ return `(min-width: ${px}px)`;
14
+ }
15
+ function resolveMax(value) {
16
+ const px = typeof value === 'number' ? value : BREAKPOINTS[value];
17
+ return `(max-width: ${px - 1}px)`;
18
+ }
19
+ function parseQuery(query) {
20
+ if (typeof query !== 'string') {
21
+ const parts = [];
22
+ if (query.min != null)
23
+ parts.push(resolveMin(query.min));
24
+ if (query.max != null)
25
+ parts.push(resolveMax(query.max));
26
+ if (query.pointer === 'coarse')
27
+ parts.push('(pointer: coarse)');
28
+ if (query.pointer === 'fine')
29
+ parts.push('(pointer: fine)');
30
+ if (parts.length === 0)
31
+ return '(min-width: 0px)';
32
+ return parts.join(' and ');
33
+ }
34
+ if (query.startsWith('('))
35
+ return query;
36
+ const parts = [];
37
+ for (const segment of query.split(':')) {
38
+ if (segment.startsWith('max-')) {
39
+ const bp = segment.slice(4);
40
+ if (bp in BREAKPOINTS)
41
+ parts.push(resolveMax(bp));
42
+ }
43
+ else if (segment in BREAKPOINTS) {
44
+ parts.push(resolveMin(segment));
45
+ }
46
+ }
47
+ return parts.length > 0 ? parts.join(' and ') : query;
48
+ }
49
+ function getServerSnapshot() {
50
+ return false;
51
+ }
52
+ export function useMediaQuery(query) {
53
+ const mediaQuery = parseQuery(query);
54
+ const subscribe = useCallback((callback) => {
55
+ if (typeof window === 'undefined')
56
+ return () => { };
57
+ const mql = window.matchMedia(mediaQuery);
58
+ mql.addEventListener('change', callback);
59
+ return () => mql.removeEventListener('change', callback);
60
+ }, [mediaQuery]);
61
+ const getSnapshot = useCallback(() => {
62
+ if (typeof window === 'undefined')
63
+ return false;
64
+ return window.matchMedia(mediaQuery).matches;
65
+ }, [mediaQuery]);
66
+ return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
67
+ }
@@ -1,2 +1,3 @@
1
+ /** True below the Tailwind `md` breakpoint (max-width 767px). */
1
2
  export declare function useIsMobile(): boolean;
2
3
  //# sourceMappingURL=use-mobile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-mobile.d.ts","sourceRoot":"","sources":["../../src/hooks/use-mobile.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,YAc1B"}
1
+ {"version":3,"file":"use-mobile.d.ts","sourceRoot":"","sources":["../../src/hooks/use-mobile.ts"],"names":[],"mappings":"AAIA,iEAAiE;AACjE,wBAAgB,WAAW,IAAI,OAAO,CAErC"}
@@ -1,15 +1,6 @@
1
- import * as React from 'react';
2
- const MOBILE_BREAKPOINT = 768;
1
+ 'use client';
2
+ import { useMediaQuery } from './use-media-query';
3
+ /** True below the Tailwind `md` breakpoint (max-width 767px). */
3
4
  export function useIsMobile() {
4
- const [isMobile, setIsMobile] = React.useState(undefined);
5
- React.useEffect(() => {
6
- const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
7
- const onChange = () => {
8
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
9
- };
10
- mql.addEventListener('change', onChange);
11
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
12
- return () => mql.removeEventListener('change', onChange);
13
- }, []);
14
- return !!isMobile;
5
+ return useMediaQuery('max-md');
15
6
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './components';
2
2
  export * from './blocks';
3
+ export * from './hooks';
3
4
  export { cn } from './lib/utils';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './components';
2
2
  export * from './blocks';
3
+ export * from './hooks';
3
4
  export { cn } from './lib/utils';