@leitware/composables 0.1.0 → 0.2.0
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/dist/presets/signal-pop.css +128 -127
- package/dist/styles.css +1 -1
- package/package.json +7 -7
- package/src/_internal/checkbox.tsx +3 -2
- package/src/_internal/combobox.tsx +4 -2
- package/src/_internal/input-group.tsx +7 -5
- package/src/_internal/input.tsx +3 -2
- package/src/_internal/native-select.tsx +4 -2
- package/src/_internal/radio-group.tsx +3 -2
- package/src/_internal/select.tsx +3 -2
- package/src/_internal/switch.tsx +3 -2
- package/src/_internal/textarea.tsx +2 -1
- package/src/lib/utils.ts +10 -3
- package/src/opinionated/combobox.tsx +0 -2
- package/src/opinionated/theme-injector.tsx +0 -1
- package/src/opinionated/token-config-panel/color-editor.tsx +9 -1
- package/src/styles/presets/signal-pop.css +128 -127
- package/src/styles/presets-data/signal-pop.ts +128 -126
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leitware/composables",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/rowanhen/composables"
|
|
8
|
+
},
|
|
5
9
|
"publishConfig": {
|
|
6
10
|
"access": "public"
|
|
7
11
|
},
|
|
@@ -40,6 +44,7 @@
|
|
|
40
44
|
"class-variance-authority": "^0.7.1",
|
|
41
45
|
"clsx": "^2.1.1",
|
|
42
46
|
"lucide-react": "^1.23.0",
|
|
47
|
+
"radix-ui": "^1.0.0",
|
|
43
48
|
"tailwind-merge": "^3.6.0"
|
|
44
49
|
},
|
|
45
50
|
"peerDependencies": {
|
|
@@ -72,8 +77,7 @@
|
|
|
72
77
|
"sonner": "^2.0.0",
|
|
73
78
|
"cmdk": "^1.0.0",
|
|
74
79
|
"react-colorful": "^5.0.0",
|
|
75
|
-
"motion": "^12.0.0"
|
|
76
|
-
"radix-ui": "^1.0.0"
|
|
80
|
+
"motion": "^12.0.0"
|
|
77
81
|
},
|
|
78
82
|
"peerDependenciesMeta": {
|
|
79
83
|
"@fontsource-variable/inter": {
|
|
@@ -159,9 +163,6 @@
|
|
|
159
163
|
},
|
|
160
164
|
"motion": {
|
|
161
165
|
"optional": true
|
|
162
|
-
},
|
|
163
|
-
"radix-ui": {
|
|
164
|
-
"optional": true
|
|
165
166
|
}
|
|
166
167
|
},
|
|
167
168
|
"devDependencies": {
|
|
@@ -195,7 +196,6 @@
|
|
|
195
196
|
"nanoid": "^5.1.16",
|
|
196
197
|
"oxfmt": "^0.57.0",
|
|
197
198
|
"oxlint": "^1.72.0",
|
|
198
|
-
"radix-ui": "^1.6.1",
|
|
199
199
|
"react": "^19.2.7",
|
|
200
200
|
"react-colorful": "^5.7.0",
|
|
201
201
|
"react-day-picker": "^10.0.1",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox'
|
|
2
2
|
import { CheckIcon } from 'lucide-react'
|
|
3
|
-
import { cn, FOCUS_RING } from '../lib/utils'
|
|
3
|
+
import { cn, FOCUS_RING, HOVER_RING } from '../lib/utils'
|
|
4
4
|
|
|
5
5
|
function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
|
|
6
6
|
return (
|
|
@@ -8,7 +8,8 @@ function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
|
|
|
8
8
|
data-slot="checkbox"
|
|
9
9
|
className={cn(
|
|
10
10
|
FOCUS_RING,
|
|
11
|
-
|
|
11
|
+
HOVER_RING,
|
|
12
|
+
'border-field dark:bg-field/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary flex size-4 items-center justify-center rounded-sm border transition-shadow group-has-disabled/field:opacity-disabled peer relative shrink-0 outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-disabled',
|
|
12
13
|
className,
|
|
13
14
|
)}
|
|
14
15
|
{...props}
|
|
@@ -3,7 +3,7 @@ import { CheckIcon, ChevronDownIcon, XIcon } from 'lucide-react'
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { Button } from './button'
|
|
5
5
|
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from './input-group'
|
|
6
|
-
import { cn, FOCUS_RING } from '../lib/utils'
|
|
6
|
+
import { cn, FOCUS_RING, GROUP_FOCUS_RING, HOVER_RING } from '../lib/utils'
|
|
7
7
|
|
|
8
8
|
const Combobox = ComboboxPrimitive.Root
|
|
9
9
|
|
|
@@ -191,7 +191,9 @@ function ComboboxChips({
|
|
|
191
191
|
<ComboboxPrimitive.Chips
|
|
192
192
|
data-slot="combobox-chips"
|
|
193
193
|
className={cn(
|
|
194
|
-
|
|
194
|
+
GROUP_FOCUS_RING,
|
|
195
|
+
HOVER_RING,
|
|
196
|
+
'bg-field/20 dark:bg-field/30 border-field flex min-h-7 flex-wrap items-center gap-1 rounded-md border bg-clip-padding px-2 py-0.5 text-xs/relaxed has-data-[slot=combobox-chip]:px-1',
|
|
195
197
|
className,
|
|
196
198
|
)}
|
|
197
199
|
{...props}
|
|
@@ -3,7 +3,7 @@ import type * as React from 'react'
|
|
|
3
3
|
import { Button } from './button'
|
|
4
4
|
import { Input } from './input'
|
|
5
5
|
import { Textarea } from './textarea'
|
|
6
|
-
import { cn } from '../lib/utils'
|
|
6
|
+
import { cn, GROUP_FOCUS_RING, HOVER_RING } from '../lib/utils'
|
|
7
7
|
|
|
8
8
|
function InputGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
9
9
|
return (
|
|
@@ -11,7 +11,9 @@ function InputGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
|
11
11
|
data-slot="input-group"
|
|
12
12
|
role="group"
|
|
13
13
|
className={cn(
|
|
14
|
-
|
|
14
|
+
GROUP_FOCUS_RING,
|
|
15
|
+
HOVER_RING,
|
|
16
|
+
'border-field bg-field/20 dark:bg-field/30 h-7 rounded-md border overflow-hidden bg-clip-padding has-data-[align=block-end]:rounded-md has-data-[align=block-start]:rounded-md has-[textarea]:rounded-md has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5 [[data-slot=combobox-content]_&]:focus-within:border-inherit [[data-slot=combobox-content]_&]:focus-within:ring-0 group/input-group relative flex w-full min-w-0 items-center outline-none has-[>textarea]:h-auto',
|
|
15
17
|
className,
|
|
16
18
|
)}
|
|
17
19
|
{...props}
|
|
@@ -61,7 +63,7 @@ function InputGroupAddon({
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
const inputGroupButtonVariants = cva(
|
|
64
|
-
'gap-2 rounded-md text-xs/relaxed shadow-none flex items-center',
|
|
66
|
+
'gap-2 rounded-md text-xs/relaxed shadow-none hover:border-transparent hover:ring-0 focus-visible:border-transparent focus-visible:ring-0 flex items-center',
|
|
65
67
|
{
|
|
66
68
|
variants: {
|
|
67
69
|
size: {
|
|
@@ -115,7 +117,7 @@ function InputGroupInput({ className, ...props }: React.ComponentProps<'input'>)
|
|
|
115
117
|
<Input
|
|
116
118
|
data-slot="input-group-control"
|
|
117
119
|
className={cn(
|
|
118
|
-
'rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent flex-1',
|
|
120
|
+
'rounded-none border-0 bg-transparent shadow-none ring-0 hover:border-transparent hover:ring-0 focus-visible:border-transparent focus-visible:ring-0 aria-invalid:border-transparent aria-invalid:ring-0 dark:bg-transparent flex-1',
|
|
119
121
|
className,
|
|
120
122
|
)}
|
|
121
123
|
{...props}
|
|
@@ -128,7 +130,7 @@ function InputGroupTextarea({ className, ...props }: React.ComponentProps<'texta
|
|
|
128
130
|
<Textarea
|
|
129
131
|
data-slot="input-group-control"
|
|
130
132
|
className={cn(
|
|
131
|
-
'rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent flex-1 resize-none',
|
|
133
|
+
'rounded-none border-0 bg-transparent py-2 shadow-none ring-0 hover:border-transparent hover:ring-0 focus-visible:border-transparent focus-visible:ring-0 aria-invalid:border-transparent aria-invalid:ring-0 dark:bg-transparent flex-1 resize-none',
|
|
132
134
|
className,
|
|
133
135
|
)}
|
|
134
136
|
{...props}
|
package/src/_internal/input.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Input as InputPrimitive } from '@base-ui/react/input'
|
|
2
2
|
import type * as React from 'react'
|
|
3
3
|
|
|
4
|
-
import { cn, FOCUS_RING } from '../lib/utils'
|
|
4
|
+
import { cn, FOCUS_RING, HOVER_RING } from '../lib/utils'
|
|
5
5
|
|
|
6
6
|
function Input({ className, type, ...props }: React.ComponentProps<'input'>) {
|
|
7
7
|
return (
|
|
@@ -10,7 +10,8 @@ function Input({ className, type, ...props }: React.ComponentProps<'input'>) {
|
|
|
10
10
|
data-slot="input"
|
|
11
11
|
className={cn(
|
|
12
12
|
FOCUS_RING,
|
|
13
|
-
|
|
13
|
+
HOVER_RING,
|
|
14
|
+
'bg-field/20 dark:bg-field/30 border-field h-7 rounded-md border px-2 py-0.5 text-sm file:h-6 file:text-xs/relaxed file:font-medium md:text-xs/relaxed file:text-foreground placeholder:text-muted-foreground w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-disabled',
|
|
14
15
|
className,
|
|
15
16
|
)}
|
|
16
17
|
{...props}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as React from 'react'
|
|
2
2
|
import { ChevronDownIcon } from 'lucide-react'
|
|
3
3
|
|
|
4
|
-
import { cn, FOCUS_RING } from '../lib/utils'
|
|
4
|
+
import { cn, FOCUS_RING, HOVER_RING } from '../lib/utils'
|
|
5
5
|
|
|
6
6
|
export type NativeSelectSize = 'sm' | 'default'
|
|
7
7
|
|
|
@@ -25,7 +25,9 @@ function NativeSelect({
|
|
|
25
25
|
data-slot="native-select"
|
|
26
26
|
data-size={size}
|
|
27
27
|
className={cn(
|
|
28
|
-
|
|
28
|
+
FOCUS_RING,
|
|
29
|
+
HOVER_RING,
|
|
30
|
+
'border-field bg-page h-(--input-height) w-full appearance-none rounded-(--input-radius) border px-3 py-2 pr-9 text-xs/relaxed shadow-xs outline-none motion-colors disabled:pointer-events-none disabled:cursor-not-allowed data-[size=sm]:h-8 data-[size=sm]:py-1',
|
|
29
31
|
className,
|
|
30
32
|
)}
|
|
31
33
|
{...props}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Radio as RadioPrimitive } from '@base-ui/react/radio'
|
|
2
2
|
import { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group'
|
|
3
|
-
import { cn, FOCUS_RING } from '../lib/utils'
|
|
3
|
+
import { cn, FOCUS_RING, HOVER_RING } from '../lib/utils'
|
|
4
4
|
|
|
5
5
|
function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) {
|
|
6
6
|
return (
|
|
@@ -18,7 +18,8 @@ function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) {
|
|
|
18
18
|
data-slot="radio-group-item"
|
|
19
19
|
className={cn(
|
|
20
20
|
FOCUS_RING,
|
|
21
|
-
|
|
21
|
+
HOVER_RING,
|
|
22
|
+
'border-field dark:bg-field/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary flex size-4 rounded-[var(--radius)] transition-shadow group/radio-group-item peer relative aspect-square shrink-0 border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-disabled',
|
|
22
23
|
className,
|
|
23
24
|
)}
|
|
24
25
|
{...props}
|
package/src/_internal/select.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Select as SelectPrimitive } from '@base-ui/react/select'
|
|
2
2
|
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react'
|
|
3
3
|
import type * as React from 'react'
|
|
4
|
-
import { cn, FOCUS_RING } from '../lib/utils'
|
|
4
|
+
import { cn, FOCUS_RING, HOVER_RING } from '../lib/utils'
|
|
5
5
|
|
|
6
6
|
const Select = SelectPrimitive.Root
|
|
7
7
|
|
|
@@ -39,7 +39,8 @@ function SelectTrigger({
|
|
|
39
39
|
data-size={size}
|
|
40
40
|
className={cn(
|
|
41
41
|
FOCUS_RING,
|
|
42
|
-
|
|
42
|
+
HOVER_RING,
|
|
43
|
+
"border-field data-[placeholder]:text-muted-foreground bg-field/20 dark:bg-field/30 dark:hover:bg-field/50 gap-1.5 rounded-md border px-2 py-1.5 text-xs/relaxed data-[size=default]:h-7 data-[size=sm]:h-6 *:data-[slot=select-value]:flex *:data-[slot=select-value]:gap-1.5 [&_svg:not([class*='size-'])]:size-3.5 flex w-fit items-center justify-between whitespace-nowrap outline-none disabled:cursor-not-allowed disabled:opacity-disabled *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
43
44
|
className,
|
|
44
45
|
)}
|
|
45
46
|
{...props}
|
package/src/_internal/switch.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Switch as SwitchPrimitive } from '@base-ui/react/switch'
|
|
2
2
|
|
|
3
|
-
import { cn, FOCUS_RING } from '../lib/utils'
|
|
3
|
+
import { cn, FOCUS_RING, HOVER_RING } from '../lib/utils'
|
|
4
4
|
|
|
5
5
|
function Switch({
|
|
6
6
|
className,
|
|
@@ -15,7 +15,8 @@ function Switch({
|
|
|
15
15
|
data-size={size}
|
|
16
16
|
className={cn(
|
|
17
17
|
FOCUS_RING,
|
|
18
|
-
|
|
18
|
+
HOVER_RING,
|
|
19
|
+
'data-checked:bg-primary data-unchecked:bg-field dark:data-unchecked:bg-field/80 shrink-0 rounded-[var(--radius)] p-0.5 data-[size=default]:h-4 data-[size=default]:w-7 data-[size=sm]:h-3.5 data-[size=sm]:w-6 peer group/switch relative inline-flex items-center transition-[opacity,box-shadow] outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-disabled',
|
|
19
20
|
className,
|
|
20
21
|
)}
|
|
21
22
|
{...props}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as React from 'react'
|
|
2
2
|
|
|
3
|
-
import { cn, FOCUS_RING } from '../lib/utils'
|
|
3
|
+
import { cn, FOCUS_RING, HOVER_RING } from '../lib/utils'
|
|
4
4
|
|
|
5
5
|
function Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {
|
|
6
6
|
return (
|
|
@@ -8,6 +8,7 @@ function Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {
|
|
|
8
8
|
data-slot="textarea"
|
|
9
9
|
className={cn(
|
|
10
10
|
FOCUS_RING,
|
|
11
|
+
HOVER_RING,
|
|
11
12
|
'border-field bg-field/20 dark:bg-field/30 resize-none rounded-md border px-2 py-2 text-sm md:text-xs/relaxed placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full outline-none disabled:cursor-not-allowed disabled:opacity-disabled',
|
|
12
13
|
className,
|
|
13
14
|
)}
|
package/src/lib/utils.ts
CHANGED
|
@@ -14,11 +14,18 @@ export const FOCUS_RING =
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Centralised hover ring style for all interactive elements.
|
|
17
|
-
* Uses
|
|
18
|
-
*
|
|
17
|
+
* Uses a thinner accent treatment than focus, with a border color and ring
|
|
18
|
+
* so presets with zero base border width still have a visible hover affordance.
|
|
19
19
|
*/
|
|
20
20
|
export const HOVER_RING =
|
|
21
|
-
'hover:ring-[length:var(--hover-ring-width)] hover:ring-[color:var(--hover-ring-color)]/30'
|
|
21
|
+
'hover:border-[var(--hover-ring-color)] hover:ring-[length:var(--hover-ring-width)] hover:ring-[color:var(--hover-ring-color)]/30'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Focus treatment for grouped controls whose focusable element is nested
|
|
25
|
+
* inside a wrapper, such as InputGroup and chip inputs.
|
|
26
|
+
*/
|
|
27
|
+
export const GROUP_FOCUS_RING =
|
|
28
|
+
'has-[:focus-visible]:border-[var(--focus-ring-color)] has-[:focus-visible]:ring-[color:var(--focus-ring-color)]/30 has-[:focus-visible]:ring-[length:var(--focus-ring-width)] has-aria-invalid:ring-stroke-critical/20 dark:has-aria-invalid:ring-stroke-critical/40 has-aria-invalid:border-stroke-critical dark:has-aria-invalid:border-stroke-critical/50 has-aria-invalid:ring-[length:var(--focus-ring-width)]'
|
|
22
29
|
|
|
23
30
|
/** Destructive-variant focus override – layer on top of FOCUS_RING. */
|
|
24
31
|
export const FOCUS_RING_DESTRUCTIVE =
|
|
@@ -11,7 +11,15 @@ import { getResolvedColor } from './helpers'
|
|
|
11
11
|
export const colorTokens: FlatToken[] = semanticColorTokens
|
|
12
12
|
|
|
13
13
|
export const colorCategories = [...new Set(colorTokens.map((t) => t.category))]
|
|
14
|
-
export const colorTokensByCategory =
|
|
14
|
+
export const colorTokensByCategory = colorTokens.reduce<Record<string, FlatToken[]>>(
|
|
15
|
+
(groups, token) => {
|
|
16
|
+
const group = groups[token.category] ?? []
|
|
17
|
+
group.push(token)
|
|
18
|
+
groups[token.category] = group
|
|
19
|
+
return groups
|
|
20
|
+
},
|
|
21
|
+
{},
|
|
22
|
+
)
|
|
15
23
|
|
|
16
24
|
/* ------------------------------------------------------------------ */
|
|
17
25
|
/* ColorTokenRow */
|