@leitware/composables 0.1.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/LICENSE +21 -0
- package/README.md +387 -0
- package/dist/presets/brutalist.css +298 -0
- package/dist/presets/default.css +298 -0
- package/dist/presets/signal-pop.css +369 -0
- package/dist/styles.css +2 -0
- package/package.json +216 -0
- package/rules/composables.md +244 -0
- package/src/_internal/accordion.tsx +93 -0
- package/src/_internal/ai-elements/attachments.tsx +385 -0
- package/src/_internal/ai-elements/chain-of-thought.tsx +197 -0
- package/src/_internal/ai-elements/code-block.tsx +516 -0
- package/src/_internal/ai-elements/confirmation.tsx +150 -0
- package/src/_internal/ai-elements/conversation.tsx +148 -0
- package/src/_internal/ai-elements/inline-citation.tsx +248 -0
- package/src/_internal/ai-elements/message.tsx +292 -0
- package/src/_internal/ai-elements/plan.tsx +126 -0
- package/src/_internal/ai-elements/prompt-input.tsx +1285 -0
- package/src/_internal/ai-elements/reasoning.tsx +208 -0
- package/src/_internal/ai-elements/shimmer.tsx +72 -0
- package/src/_internal/ai-elements/sources.tsx +53 -0
- package/src/_internal/ai-elements/suggestion.tsx +48 -0
- package/src/_internal/ai-elements/task.tsx +64 -0
- package/src/_internal/ai-elements/tool.tsx +156 -0
- package/src/_internal/alert-dialog.tsx +159 -0
- package/src/_internal/alert.tsx +88 -0
- package/src/_internal/aspect-ratio.tsx +23 -0
- package/src/_internal/avatar.tsx +58 -0
- package/src/_internal/badge.tsx +60 -0
- package/src/_internal/breadcrumb.tsx +104 -0
- package/src/_internal/bubble.tsx +125 -0
- package/src/_internal/button-group.tsx +78 -0
- package/src/_internal/button.tsx +62 -0
- package/src/_internal/calendar.tsx +179 -0
- package/src/_internal/card.tsx +83 -0
- package/src/_internal/carousel.tsx +215 -0
- package/src/_internal/checkbox.tsx +26 -0
- package/src/_internal/code-block.tsx +53 -0
- package/src/_internal/collapsible.tsx +15 -0
- package/src/_internal/combobox.tsx +264 -0
- package/src/_internal/command.tsx +155 -0
- package/src/_internal/container.tsx +35 -0
- package/src/_internal/dialog.tsx +132 -0
- package/src/_internal/direction.tsx +12 -0
- package/src/_internal/divider.tsx +162 -0
- package/src/_internal/dropdown-menu.tsx +247 -0
- package/src/_internal/dropzone.tsx +481 -0
- package/src/_internal/empty.tsx +94 -0
- package/src/_internal/field.tsx +221 -0
- package/src/_internal/grid-overlay.tsx +48 -0
- package/src/_internal/grid.tsx +109 -0
- package/src/_internal/hover-card.tsx +47 -0
- package/src/_internal/icon.tsx +45 -0
- package/src/_internal/input-group.tsx +146 -0
- package/src/_internal/input.tsx +24 -0
- package/src/_internal/item.tsx +187 -0
- package/src/_internal/kbd.tsx +28 -0
- package/src/_internal/label.tsx +18 -0
- package/src/_internal/layout-bento.tsx +386 -0
- package/src/_internal/layout.tsx +174 -0
- package/src/_internal/marker.tsx +66 -0
- package/src/_internal/message.tsx +85 -0
- package/src/_internal/native-select.tsx +50 -0
- package/src/_internal/pagination.tsx +108 -0
- package/src/_internal/popover.tsx +83 -0
- package/src/_internal/progress.tsx +59 -0
- package/src/_internal/radio-group.tsx +36 -0
- package/src/_internal/resizable.tsx +44 -0
- package/src/_internal/scroll-area.tsx +48 -0
- package/src/_internal/select.tsx +187 -0
- package/src/_internal/separator.tsx +19 -0
- package/src/_internal/sheet.tsx +122 -0
- package/src/_internal/sidebar.tsx +687 -0
- package/src/_internal/skeleton.tsx +13 -0
- package/src/_internal/slider.tsx +60 -0
- package/src/_internal/sonner.tsx +51 -0
- package/src/_internal/spacer.tsx +42 -0
- package/src/_internal/spinner.tsx +16 -0
- package/src/_internal/stack.tsx +78 -0
- package/src/_internal/switch.tsx +31 -0
- package/src/_internal/table.tsx +84 -0
- package/src/_internal/tabs.tsx +74 -0
- package/src/_internal/textarea.tsx +19 -0
- package/src/_internal/toggle-group.tsx +99 -0
- package/src/_internal/toggle.tsx +42 -0
- package/src/_internal/tooltip.tsx +55 -0
- package/src/_internal/typography.tsx +129 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/hooks/use-numeric-input.ts +119 -0
- package/src/index.ts +443 -0
- package/src/lib/numeric-input.ts +88 -0
- package/src/lib/utils.ts +39 -0
- package/src/opinionated/accordion.tsx +92 -0
- package/src/opinionated/ai/attachments.tsx +27 -0
- package/src/opinionated/ai/chain-of-thought.tsx +16 -0
- package/src/opinionated/ai/code-block.tsx +22 -0
- package/src/opinionated/ai/confirmation.tsx +16 -0
- package/src/opinionated/ai/conversation.tsx +13 -0
- package/src/opinionated/ai/index.ts +15 -0
- package/src/opinionated/ai/inline-citation.tsx +30 -0
- package/src/opinionated/ai/message.tsx +26 -0
- package/src/opinionated/ai/plan.tsx +18 -0
- package/src/opinionated/ai/prompt-input.tsx +29 -0
- package/src/opinionated/ai/reasoning.tsx +9 -0
- package/src/opinionated/ai/shimmer.tsx +4 -0
- package/src/opinionated/ai/sources.tsx +10 -0
- package/src/opinionated/ai/suggestion.tsx +6 -0
- package/src/opinionated/ai/task.tsx +12 -0
- package/src/opinionated/ai/tool.tsx +14 -0
- package/src/opinionated/alert-dialog.tsx +143 -0
- package/src/opinionated/alert.tsx +99 -0
- package/src/opinionated/aspect-ratio.tsx +12 -0
- package/src/opinionated/avatar.tsx +59 -0
- package/src/opinionated/badge.tsx +33 -0
- package/src/opinionated/breadcrumb.tsx +99 -0
- package/src/opinionated/bubble.tsx +9 -0
- package/src/opinionated/button.tsx +59 -0
- package/src/opinionated/calendar.tsx +20 -0
- package/src/opinionated/card.tsx +83 -0
- package/src/opinionated/carousel.tsx +99 -0
- package/src/opinionated/checkbox.tsx +11 -0
- package/src/opinionated/code-block.tsx +12 -0
- package/src/opinionated/collapsible.tsx +123 -0
- package/src/opinionated/combobox.tsx +123 -0
- package/src/opinionated/container.tsx +12 -0
- package/src/opinionated/dialog.tsx +124 -0
- package/src/opinionated/direction.tsx +6 -0
- package/src/opinionated/divider.tsx +13 -0
- package/src/opinionated/dropdown-menu.tsx +131 -0
- package/src/opinionated/dropzone.tsx +39 -0
- package/src/opinionated/empty.tsx +191 -0
- package/src/opinionated/field.tsx +26 -0
- package/src/opinionated/form-calendar-popover.tsx +138 -0
- package/src/opinionated/form-checkbox.tsx +107 -0
- package/src/opinionated/form-combobox.tsx +181 -0
- package/src/opinionated/form-date-of-birth.tsx +193 -0
- package/src/opinionated/form-dropzone.tsx +126 -0
- package/src/opinionated/form-input-group.tsx +184 -0
- package/src/opinionated/form-input.tsx +118 -0
- package/src/opinionated/form-multi-combobox.tsx +213 -0
- package/src/opinionated/form-multi-dropzone.tsx +141 -0
- package/src/opinionated/form-radiogroup.tsx +116 -0
- package/src/opinionated/form-select.tsx +176 -0
- package/src/opinionated/form-slider.tsx +100 -0
- package/src/opinionated/form-switch.tsx +117 -0
- package/src/opinionated/form-textarea.tsx +79 -0
- package/src/opinionated/grid-overlay.tsx +11 -0
- package/src/opinionated/grid.tsx +14 -0
- package/src/opinionated/hover-card.tsx +59 -0
- package/src/opinionated/icon.tsx +14 -0
- package/src/opinionated/input-group.tsx +20 -0
- package/src/opinionated/input.tsx +11 -0
- package/src/opinionated/item.tsx +182 -0
- package/src/opinionated/kbd.tsx +16 -0
- package/src/opinionated/label.tsx +11 -0
- package/src/opinionated/layout-bento.tsx +29 -0
- package/src/opinionated/layout.tsx +26 -0
- package/src/opinionated/list.tsx +94 -0
- package/src/opinionated/marker.tsx +7 -0
- package/src/opinionated/message.tsx +8 -0
- package/src/opinionated/native-select.tsx +51 -0
- package/src/opinionated/pagination.tsx +204 -0
- package/src/opinionated/popover.tsx +68 -0
- package/src/opinionated/progress.tsx +48 -0
- package/src/opinionated/radio-group.tsx +13 -0
- package/src/opinionated/resizable.tsx +2 -0
- package/src/opinionated/scroll-area.tsx +82 -0
- package/src/opinionated/select.tsx +101 -0
- package/src/opinionated/separator.tsx +11 -0
- package/src/opinionated/sheet.tsx +120 -0
- package/src/opinionated/sidebar.tsx +68 -0
- package/src/opinionated/skeleton.tsx +246 -0
- package/src/opinionated/slider.tsx +11 -0
- package/src/opinionated/sonner.tsx +15 -0
- package/src/opinionated/spacer.tsx +11 -0
- package/src/opinionated/stack.tsx +18 -0
- package/src/opinionated/switch.tsx +11 -0
- package/src/opinionated/table.tsx +11 -0
- package/src/opinionated/tabs.tsx +68 -0
- package/src/opinionated/textarea.tsx +11 -0
- package/src/opinionated/theme-injector.tsx +31 -0
- package/src/opinionated/toggle-group.tsx +63 -0
- package/src/opinionated/toggle.tsx +75 -0
- package/src/opinionated/token-config-panel/color-editor.tsx +85 -0
- package/src/opinionated/token-config-panel/helpers.ts +31 -0
- package/src/opinionated/token-config-panel/index.tsx +398 -0
- package/src/opinionated/token-config-panel/json-import-export.tsx +89 -0
- package/src/opinionated/token-config-panel/preset-manager.ts +31 -0
- package/src/opinionated/token-config-panel/presets-data.ts +23 -0
- package/src/opinionated/token-config-panel/spacing-editor.tsx +325 -0
- package/src/opinionated/token-config-panel/types.ts +39 -0
- package/src/opinionated/token-config-panel/typography-editor.tsx +145 -0
- package/src/opinionated/tooltip.tsx +62 -0
- package/src/opinionated/typography.tsx +7 -0
- package/src/scripts/lint-no-arbitrary.ts +155 -0
- package/src/styles/composable.css +68 -0
- package/src/styles/presets/brutalist.css +298 -0
- package/src/styles/presets/default.css +298 -0
- package/src/styles/presets/signal-pop.css +369 -0
- package/src/styles/presets-data/brutalist.ts +325 -0
- package/src/styles/presets-data/default.ts +315 -0
- package/src/styles/presets-data/index.ts +45 -0
- package/src/styles/presets-data/signal-pop.ts +393 -0
- package/src/styles/tokens/base.css +71 -0
- package/src/styles/tokens/components.css +150 -0
- package/src/styles/tokens/palette.css +795 -0
- package/src/styles/tokens/registry.ts +324 -0
- package/src/styles/tokens/semantic.css +266 -0
- package/src/styles/tokens/tailwind-theme.css +247 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { cn } from '../lib/utils'
|
|
5
|
+
|
|
6
|
+
const typographyVariants = cva('', {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
// Hero variants - brand font, 700, letter-spacing -0.02em, line-height 1
|
|
10
|
+
'hero-100': 'font-brand font-bold text-4xl leading-none tracking-[-0.02em]',
|
|
11
|
+
'hero-200': 'font-brand font-bold text-5xl leading-none tracking-[-0.02em]',
|
|
12
|
+
'hero-300': 'font-brand font-bold text-6xl leading-none tracking-[-0.02em]',
|
|
13
|
+
'hero-400': 'font-brand font-bold text-7xl leading-none tracking-[-0.02em]',
|
|
14
|
+
|
|
15
|
+
// Heading variants - heading font, 500, letter-spacing 0
|
|
16
|
+
'heading-100': 'font-heading font-medium text-sm tracking-normal',
|
|
17
|
+
'heading-200': 'font-heading font-medium text-base tracking-normal',
|
|
18
|
+
'heading-300': 'font-heading font-medium text-xl tracking-normal',
|
|
19
|
+
'heading-400': 'font-heading font-medium text-2xl tracking-normal',
|
|
20
|
+
'heading-500': 'font-heading font-medium text-3xl tracking-normal',
|
|
21
|
+
'heading-600': 'font-heading font-medium text-4xl tracking-normal',
|
|
22
|
+
|
|
23
|
+
// Brand heading variants - brand font, 700, letter-spacing -0.01em
|
|
24
|
+
'brand-heading-100': 'font-brand font-bold text-sm tracking-[-0.01em]',
|
|
25
|
+
'brand-heading-200': 'font-brand font-bold text-base tracking-[-0.01em]',
|
|
26
|
+
'brand-heading-300': 'font-brand font-bold text-xl tracking-[-0.01em]',
|
|
27
|
+
'brand-heading-400': 'font-brand font-bold text-2xl tracking-[-0.01em]',
|
|
28
|
+
'brand-heading-500': 'font-brand font-bold text-3xl tracking-[-0.01em]',
|
|
29
|
+
'brand-heading-600': 'font-brand font-bold text-4xl tracking-[-0.01em]',
|
|
30
|
+
|
|
31
|
+
// Body variants - sans font, 400, letter-spacing 0
|
|
32
|
+
'body-100': 'font-sans font-normal text-sm tracking-normal',
|
|
33
|
+
'body-200': 'font-sans font-normal text-base tracking-normal',
|
|
34
|
+
'body-300': 'font-sans font-normal text-lg tracking-normal',
|
|
35
|
+
|
|
36
|
+
// Brand body variants - brand font, 700
|
|
37
|
+
'brand-body-100': 'font-brand font-bold text-sm tracking-normal',
|
|
38
|
+
'brand-body-200': 'font-brand font-bold text-base tracking-normal',
|
|
39
|
+
'brand-body-300': 'font-brand font-bold text-lg tracking-normal',
|
|
40
|
+
|
|
41
|
+
// Label variants - sans font, 500
|
|
42
|
+
'label-100': 'font-sans font-medium text-2xs leading-none tracking-normal uppercase',
|
|
43
|
+
'label-200': 'font-sans font-medium text-base leading-none tracking-normal uppercase',
|
|
44
|
+
|
|
45
|
+
// Brand label variants - brand font, 700
|
|
46
|
+
'brand-label-100': 'font-brand font-bold text-2xs leading-none tracking-normal uppercase',
|
|
47
|
+
'brand-label-200': 'font-brand font-bold text-base leading-none tracking-normal uppercase',
|
|
48
|
+
|
|
49
|
+
// Caption variant - sans font, 400
|
|
50
|
+
'caption-100': 'font-sans font-normal text-xs tracking-normal text-muted-foreground',
|
|
51
|
+
|
|
52
|
+
// Link variants - sans font, 500, underline
|
|
53
|
+
'link-100': 'font-sans font-medium text-sm tracking-normal underline',
|
|
54
|
+
'link-200': 'font-sans font-medium text-base tracking-normal underline',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
defaultVariants: {
|
|
58
|
+
variant: 'body-200',
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
type TypographyVariant = NonNullable<VariantProps<typeof typographyVariants>['variant']>
|
|
63
|
+
|
|
64
|
+
type PolymorphicElement =
|
|
65
|
+
| 'h1'
|
|
66
|
+
| 'h2'
|
|
67
|
+
| 'h3'
|
|
68
|
+
| 'h4'
|
|
69
|
+
| 'h5'
|
|
70
|
+
| 'h6'
|
|
71
|
+
| 'p'
|
|
72
|
+
| 'span'
|
|
73
|
+
| 'div'
|
|
74
|
+
| 'label'
|
|
75
|
+
| 'a'
|
|
76
|
+
|
|
77
|
+
const defaultElementMap: Record<string, PolymorphicElement> = {
|
|
78
|
+
hero: 'h1',
|
|
79
|
+
heading: 'p',
|
|
80
|
+
'brand-heading': 'p',
|
|
81
|
+
body: 'p',
|
|
82
|
+
'brand-body': 'p',
|
|
83
|
+
label: 'span',
|
|
84
|
+
'brand-label': 'span',
|
|
85
|
+
caption: 'span',
|
|
86
|
+
link: 'span',
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function getDefaultElement(variant: TypographyVariant): PolymorphicElement {
|
|
90
|
+
// Match the longest prefix: e.g. "brand-heading" before "brand"
|
|
91
|
+
const parts = variant.split('-')
|
|
92
|
+
for (let i = parts.length - 1; i >= 1; i--) {
|
|
93
|
+
const prefix = parts.slice(0, i).join('-')
|
|
94
|
+
if (prefix in defaultElementMap) {
|
|
95
|
+
return defaultElementMap[prefix]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return defaultElementMap[parts[0]] || 'p'
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
type TypographyProps<T extends PolymorphicElement = 'p'> = {
|
|
102
|
+
variant: TypographyVariant
|
|
103
|
+
as?: T
|
|
104
|
+
className?: string
|
|
105
|
+
children?: React.ReactNode
|
|
106
|
+
} & Omit<React.ComponentPropsWithoutRef<T>, 'as' | 'className' | 'children'>
|
|
107
|
+
|
|
108
|
+
function Typography<T extends PolymorphicElement = 'p'>({
|
|
109
|
+
variant,
|
|
110
|
+
as,
|
|
111
|
+
className,
|
|
112
|
+
children,
|
|
113
|
+
...props
|
|
114
|
+
}: TypographyProps<T>) {
|
|
115
|
+
const Component = as || getDefaultElement(variant)
|
|
116
|
+
|
|
117
|
+
return React.createElement(
|
|
118
|
+
Component,
|
|
119
|
+
{
|
|
120
|
+
'data-slot': 'typography',
|
|
121
|
+
className: cn(typographyVariants({ variant }), className),
|
|
122
|
+
...props,
|
|
123
|
+
},
|
|
124
|
+
children,
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export { Typography, typographyVariants }
|
|
129
|
+
export type { TypographyVariant, TypographyProps }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
const MOBILE_BREAKPOINT = 768
|
|
4
|
+
|
|
5
|
+
export function useIsMobile() {
|
|
6
|
+
const [isMobile, setIsMobile] = useState(false)
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
|
|
10
|
+
const onChange = () => {
|
|
11
|
+
setIsMobile(mql.matches)
|
|
12
|
+
}
|
|
13
|
+
mql.addEventListener('change', onChange)
|
|
14
|
+
setIsMobile(mql.matches)
|
|
15
|
+
return () => mql.removeEventListener('change', onChange)
|
|
16
|
+
}, [])
|
|
17
|
+
|
|
18
|
+
return isMobile
|
|
19
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
formatNumericValue,
|
|
5
|
+
type NumericMode,
|
|
6
|
+
parseNumericValue,
|
|
7
|
+
sanitizeNumericInput,
|
|
8
|
+
} from '../lib/numeric-input'
|
|
9
|
+
|
|
10
|
+
export interface NumericInputOptions {
|
|
11
|
+
/** Enable numeric mode - handles string-to-number conversion on blur */
|
|
12
|
+
numericMode?: NumericMode
|
|
13
|
+
/** Current numeric value (use with numericMode) */
|
|
14
|
+
numericValue?: number | null
|
|
15
|
+
/** Callback when numeric value changes on blur (use with numericMode) */
|
|
16
|
+
onNumericChange?: (value: number | null) => void
|
|
17
|
+
/** Maximum decimal places allowed (default: 2, only applies to decimal mode) */
|
|
18
|
+
maxDecimalPlaces?: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface UseNumericInputOptions extends NumericInputOptions {
|
|
22
|
+
/** Original value prop (used when not in numeric mode) */
|
|
23
|
+
value?: string | number | readonly string[]
|
|
24
|
+
/** Original onChange handler */
|
|
25
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>
|
|
26
|
+
/** Original onBlur handler */
|
|
27
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>
|
|
28
|
+
/** Original onFocus handler */
|
|
29
|
+
onFocus?: React.FocusEventHandler<HTMLInputElement>
|
|
30
|
+
/** Original type prop */
|
|
31
|
+
type?: React.HTMLInputTypeAttribute
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface UseNumericInputReturn {
|
|
35
|
+
/** Whether numeric mode is active */
|
|
36
|
+
isNumericMode: boolean
|
|
37
|
+
/** Props to spread on the input element */
|
|
38
|
+
inputProps: {
|
|
39
|
+
type: React.HTMLInputTypeAttribute | undefined
|
|
40
|
+
inputMode: 'decimal' | 'numeric' | undefined
|
|
41
|
+
value: string | number | readonly string[] | undefined
|
|
42
|
+
onChange: React.ChangeEventHandler<HTMLInputElement>
|
|
43
|
+
onBlur: React.FocusEventHandler<HTMLInputElement>
|
|
44
|
+
onFocus: React.FocusEventHandler<HTMLInputElement>
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Hook that handles numeric input logic including sanitization and parsing.
|
|
50
|
+
* Used by FormInput and FormInputGroup for consistent numeric handling.
|
|
51
|
+
*/
|
|
52
|
+
export function useNumericInput({
|
|
53
|
+
numericMode,
|
|
54
|
+
numericValue,
|
|
55
|
+
onNumericChange,
|
|
56
|
+
maxDecimalPlaces = 2,
|
|
57
|
+
value,
|
|
58
|
+
onChange,
|
|
59
|
+
onBlur,
|
|
60
|
+
onFocus,
|
|
61
|
+
type,
|
|
62
|
+
}: UseNumericInputOptions): UseNumericInputReturn {
|
|
63
|
+
// Local state for numeric mode - keeps raw string while typing
|
|
64
|
+
const [localValue, setLocalValue] = React.useState(() => formatNumericValue(numericValue))
|
|
65
|
+
const [isFocused, setIsFocused] = React.useState(false)
|
|
66
|
+
|
|
67
|
+
// Sync local value when external numericValue changes (only when not focused)
|
|
68
|
+
React.useEffect(() => {
|
|
69
|
+
if (numericMode && !isFocused) {
|
|
70
|
+
setLocalValue(formatNumericValue(numericValue))
|
|
71
|
+
}
|
|
72
|
+
}, [numericMode, numericValue, isFocused])
|
|
73
|
+
|
|
74
|
+
const handleChange = React.useCallback(
|
|
75
|
+
(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
76
|
+
if (numericMode) {
|
|
77
|
+
const sanitized = sanitizeNumericInput(e.target.value, numericMode, maxDecimalPlaces)
|
|
78
|
+
setLocalValue(sanitized)
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
onChange?.(e)
|
|
82
|
+
},
|
|
83
|
+
[numericMode, maxDecimalPlaces, onChange],
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
const handleBlur = React.useCallback(
|
|
87
|
+
(e: React.FocusEvent<HTMLInputElement>) => {
|
|
88
|
+
setIsFocused(false)
|
|
89
|
+
if (numericMode && onNumericChange) {
|
|
90
|
+
onNumericChange(parseNumericValue(e.target.value, numericMode))
|
|
91
|
+
}
|
|
92
|
+
onBlur?.(e)
|
|
93
|
+
},
|
|
94
|
+
[numericMode, onNumericChange, onBlur],
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
const handleFocus = React.useCallback(
|
|
98
|
+
(e: React.FocusEvent<HTMLInputElement>) => {
|
|
99
|
+
setIsFocused(true)
|
|
100
|
+
onFocus?.(e)
|
|
101
|
+
},
|
|
102
|
+
[onFocus],
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
const isNumericMode = Boolean(numericMode)
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
isNumericMode,
|
|
109
|
+
inputProps: {
|
|
110
|
+
type: numericMode ? 'text' : type,
|
|
111
|
+
inputMode:
|
|
112
|
+
numericMode === 'decimal' ? 'decimal' : numericMode === 'integer' ? 'numeric' : undefined,
|
|
113
|
+
value: numericMode ? localValue : value,
|
|
114
|
+
onChange: handleChange,
|
|
115
|
+
onBlur: handleBlur,
|
|
116
|
+
onFocus: handleFocus,
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// @leitware/composables — barrel exports
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
// ── Utilities ───────────────────────────────────────────────────────────────
|
|
6
|
+
export { cn, FOCUS_RING, FOCUS_RING_DESTRUCTIVE, DISABLED_OPACITY, leftPad } from './lib/utils'
|
|
7
|
+
export {
|
|
8
|
+
formatNumericValue,
|
|
9
|
+
parseNumericValue,
|
|
10
|
+
sanitizeNumericInput,
|
|
11
|
+
type NumericMode,
|
|
12
|
+
} from './lib/numeric-input'
|
|
13
|
+
|
|
14
|
+
// ── Hooks ───────────────────────────────────────────────────────────────────
|
|
15
|
+
export { useIsMobile } from './hooks/use-mobile'
|
|
16
|
+
export {
|
|
17
|
+
useNumericInput,
|
|
18
|
+
type NumericInputOptions,
|
|
19
|
+
type UseNumericInputOptions,
|
|
20
|
+
type UseNumericInputReturn,
|
|
21
|
+
} from './hooks/use-numeric-input'
|
|
22
|
+
|
|
23
|
+
// ── Opinionated components ──────────────────────────────────────────────────
|
|
24
|
+
// These are the recommended, higher-level wrappers that most users should use.
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
Accordion,
|
|
28
|
+
AccordionContent,
|
|
29
|
+
AccordionItem,
|
|
30
|
+
AccordionTrigger,
|
|
31
|
+
type AccordionItemData,
|
|
32
|
+
type AccordionProps,
|
|
33
|
+
} from './opinionated/accordion'
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
AlertDialog,
|
|
37
|
+
AlertDialogAction,
|
|
38
|
+
AlertDialogCancel,
|
|
39
|
+
AlertDialogContent,
|
|
40
|
+
AlertDialogDescription,
|
|
41
|
+
AlertDialogTitle,
|
|
42
|
+
AlertDialogTrigger,
|
|
43
|
+
type AlertDialogProps,
|
|
44
|
+
} from './opinionated/alert-dialog'
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
Alert,
|
|
48
|
+
AlertAction,
|
|
49
|
+
AlertDescription,
|
|
50
|
+
AlertTitle,
|
|
51
|
+
type AlertType,
|
|
52
|
+
type AlertProps,
|
|
53
|
+
} from './opinionated/alert'
|
|
54
|
+
|
|
55
|
+
export { AspectRatio } from './opinionated/aspect-ratio'
|
|
56
|
+
|
|
57
|
+
export { Avatar, AvatarFallback, AvatarImage, type AvatarProps } from './opinionated/avatar'
|
|
58
|
+
|
|
59
|
+
export { Badge, type BadgeProps } from './opinionated/badge'
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
Breadcrumb,
|
|
63
|
+
BreadcrumbEllipsis,
|
|
64
|
+
BreadcrumbItem,
|
|
65
|
+
BreadcrumbLink,
|
|
66
|
+
BreadcrumbList,
|
|
67
|
+
BreadcrumbPage,
|
|
68
|
+
BreadcrumbSeparator,
|
|
69
|
+
type BreadcrumbItemData,
|
|
70
|
+
type BreadcrumbProps,
|
|
71
|
+
} from './opinionated/breadcrumb'
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
Bubble,
|
|
75
|
+
BubbleContent,
|
|
76
|
+
BubbleGroup,
|
|
77
|
+
BubbleReactions,
|
|
78
|
+
type BubbleProps,
|
|
79
|
+
} from './opinionated/bubble'
|
|
80
|
+
|
|
81
|
+
export { Button, type ButtonProps } from './opinionated/button'
|
|
82
|
+
export { Calendar, CalendarDayButton } from './opinionated/calendar'
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
Card,
|
|
86
|
+
CardAction,
|
|
87
|
+
CardContent,
|
|
88
|
+
CardDescription,
|
|
89
|
+
CardFooter,
|
|
90
|
+
CardHeader,
|
|
91
|
+
CardTitle,
|
|
92
|
+
type CardProps,
|
|
93
|
+
} from './opinionated/card'
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
Carousel,
|
|
97
|
+
CarouselContent,
|
|
98
|
+
CarouselItem,
|
|
99
|
+
CarouselNext,
|
|
100
|
+
CarouselPrevious,
|
|
101
|
+
type CarouselProps,
|
|
102
|
+
} from './opinionated/carousel'
|
|
103
|
+
|
|
104
|
+
export { Checkbox } from './opinionated/checkbox'
|
|
105
|
+
export { CodeBlock } from './opinionated/code-block'
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
Collapsible,
|
|
109
|
+
CollapsibleContent,
|
|
110
|
+
CollapsibleTrigger,
|
|
111
|
+
type CollapsibleProps,
|
|
112
|
+
} from './opinionated/collapsible'
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
Combobox,
|
|
116
|
+
ComboboxChip,
|
|
117
|
+
ComboboxChips,
|
|
118
|
+
ComboboxChipsInput,
|
|
119
|
+
ComboboxCollection,
|
|
120
|
+
ComboboxContent,
|
|
121
|
+
ComboboxEmpty,
|
|
122
|
+
ComboboxGroup,
|
|
123
|
+
ComboboxInput,
|
|
124
|
+
ComboboxItem,
|
|
125
|
+
ComboboxLabel,
|
|
126
|
+
ComboboxList,
|
|
127
|
+
ComboboxSeparator,
|
|
128
|
+
ComboboxTrigger,
|
|
129
|
+
ComboboxValue,
|
|
130
|
+
type ComboboxOption,
|
|
131
|
+
type ComboboxProps,
|
|
132
|
+
} from './opinionated/combobox'
|
|
133
|
+
|
|
134
|
+
export { Container } from './opinionated/container'
|
|
135
|
+
|
|
136
|
+
export {
|
|
137
|
+
Dialog,
|
|
138
|
+
DialogClose,
|
|
139
|
+
DialogContent,
|
|
140
|
+
DialogDescription,
|
|
141
|
+
DialogFooter,
|
|
142
|
+
DialogHeader,
|
|
143
|
+
DialogTitle,
|
|
144
|
+
DialogTrigger,
|
|
145
|
+
type DialogProps,
|
|
146
|
+
} from './opinionated/dialog'
|
|
147
|
+
|
|
148
|
+
export { Divider } from './opinionated/divider'
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
DirectionProvider,
|
|
152
|
+
useDirection,
|
|
153
|
+
type DirectionProviderProps,
|
|
154
|
+
type TextDirection,
|
|
155
|
+
} from './opinionated/direction'
|
|
156
|
+
|
|
157
|
+
export {
|
|
158
|
+
DropdownMenu,
|
|
159
|
+
DropdownMenuCheckboxItem,
|
|
160
|
+
DropdownMenuContent,
|
|
161
|
+
DropdownMenuGroup,
|
|
162
|
+
DropdownMenuItem,
|
|
163
|
+
DropdownMenuLabel,
|
|
164
|
+
DropdownMenuRadioGroup,
|
|
165
|
+
DropdownMenuRadioItem,
|
|
166
|
+
DropdownMenuSeparator,
|
|
167
|
+
DropdownMenuSub,
|
|
168
|
+
DropdownMenuSubContent,
|
|
169
|
+
DropdownMenuSubTrigger,
|
|
170
|
+
DropdownMenuTrigger,
|
|
171
|
+
type DropdownMenuItemData,
|
|
172
|
+
type DropdownMenuProps,
|
|
173
|
+
} from './opinionated/dropdown-menu'
|
|
174
|
+
|
|
175
|
+
export { DropZone, DropZoneFile } from './opinionated/dropzone'
|
|
176
|
+
|
|
177
|
+
export {
|
|
178
|
+
Empty,
|
|
179
|
+
EmptyContent,
|
|
180
|
+
EmptyDescription,
|
|
181
|
+
EmptyHeader,
|
|
182
|
+
EmptyMedia,
|
|
183
|
+
EmptyTableState,
|
|
184
|
+
EmptyTitle,
|
|
185
|
+
type EmptyProps,
|
|
186
|
+
type EmptyTableStateProps,
|
|
187
|
+
} from './opinionated/empty'
|
|
188
|
+
|
|
189
|
+
export {
|
|
190
|
+
Field,
|
|
191
|
+
FieldDescription,
|
|
192
|
+
FieldError,
|
|
193
|
+
FieldLabel,
|
|
194
|
+
FieldGroup,
|
|
195
|
+
FieldLegend,
|
|
196
|
+
FieldSeparator,
|
|
197
|
+
FieldSet,
|
|
198
|
+
FieldContent,
|
|
199
|
+
FieldTitle,
|
|
200
|
+
} from './opinionated/field'
|
|
201
|
+
|
|
202
|
+
export {
|
|
203
|
+
FormCalendarPopover,
|
|
204
|
+
type FormCalendarPopoverProps,
|
|
205
|
+
} from './opinionated/form-calendar-popover'
|
|
206
|
+
export { FormCheckbox, type FormCheckboxProps } from './opinionated/form-checkbox'
|
|
207
|
+
export {
|
|
208
|
+
FormCombobox,
|
|
209
|
+
type FormComboboxOption,
|
|
210
|
+
type FormComboboxProps,
|
|
211
|
+
} from './opinionated/form-combobox'
|
|
212
|
+
export {
|
|
213
|
+
FormDateOfBirth,
|
|
214
|
+
type DateOfBirthValue,
|
|
215
|
+
type FormDateOfBirthProps,
|
|
216
|
+
} from './opinionated/form-date-of-birth'
|
|
217
|
+
export { FormDropZone, ACCEPT_PRESETS, type FormDropZoneProps } from './opinionated/form-dropzone'
|
|
218
|
+
export { FormInput, type FormInputProps } from './opinionated/form-input'
|
|
219
|
+
export {
|
|
220
|
+
FormInputGroup,
|
|
221
|
+
type FormInputGroupProps,
|
|
222
|
+
type FormInputGroupInputProps,
|
|
223
|
+
} from './opinionated/form-input-group'
|
|
224
|
+
export {
|
|
225
|
+
FormMultiCombobox,
|
|
226
|
+
type FormMultiComboboxOption,
|
|
227
|
+
type FormMultiComboboxProps,
|
|
228
|
+
} from './opinionated/form-multi-combobox'
|
|
229
|
+
export { FormMultiDropZone, type FormMultiDropZoneProps } from './opinionated/form-multi-dropzone'
|
|
230
|
+
export {
|
|
231
|
+
FormRadioGroup,
|
|
232
|
+
type FormRadioGroupOption,
|
|
233
|
+
type FormRadioGroupProps,
|
|
234
|
+
} from './opinionated/form-radiogroup'
|
|
235
|
+
export { FormSelect, type FormSelectOption, type FormSelectProps } from './opinionated/form-select'
|
|
236
|
+
export { FormSlider, type FormSliderProps } from './opinionated/form-slider'
|
|
237
|
+
export { FormSwitch, type FormSwitchProps } from './opinionated/form-switch'
|
|
238
|
+
export { FormTextarea, type FormTextareaProps } from './opinionated/form-textarea'
|
|
239
|
+
|
|
240
|
+
export { Grid } from './opinionated/grid'
|
|
241
|
+
export { GridOverlay, type GridOverlayProps } from './opinionated/grid-overlay'
|
|
242
|
+
|
|
243
|
+
export {
|
|
244
|
+
HoverCard,
|
|
245
|
+
HoverCardContent,
|
|
246
|
+
HoverCardTrigger,
|
|
247
|
+
type HoverCardProps,
|
|
248
|
+
} from './opinionated/hover-card'
|
|
249
|
+
|
|
250
|
+
export { Icon } from './opinionated/icon'
|
|
251
|
+
export { Input } from './opinionated/input'
|
|
252
|
+
|
|
253
|
+
export { Kbd, KbdGroup, type KbdGroupProps, type KbdProps } from './opinionated/kbd'
|
|
254
|
+
|
|
255
|
+
export {
|
|
256
|
+
InputGroup,
|
|
257
|
+
InputGroupAddon,
|
|
258
|
+
InputGroupButton,
|
|
259
|
+
InputGroupInput,
|
|
260
|
+
InputGroupTextarea,
|
|
261
|
+
} from './opinionated/input-group'
|
|
262
|
+
|
|
263
|
+
export {
|
|
264
|
+
Item,
|
|
265
|
+
ItemActions,
|
|
266
|
+
ItemContent,
|
|
267
|
+
ItemDescription,
|
|
268
|
+
ItemFooter,
|
|
269
|
+
ItemGroup,
|
|
270
|
+
ItemHeader,
|
|
271
|
+
ItemMedia,
|
|
272
|
+
ItemSeparator,
|
|
273
|
+
ItemTitle,
|
|
274
|
+
type ItemProps,
|
|
275
|
+
} from './opinionated/item'
|
|
276
|
+
|
|
277
|
+
export { Label } from './opinionated/label'
|
|
278
|
+
|
|
279
|
+
export { Section, NewspaperGrid, NewspaperCell } from './opinionated/layout'
|
|
280
|
+
|
|
281
|
+
export { BentoGrid, BentoCell } from './opinionated/layout-bento'
|
|
282
|
+
|
|
283
|
+
export {
|
|
284
|
+
List,
|
|
285
|
+
ListArrowItem,
|
|
286
|
+
ListBulletItem,
|
|
287
|
+
type ListItemData,
|
|
288
|
+
type ListVariant,
|
|
289
|
+
type ListProps,
|
|
290
|
+
} from './opinionated/list'
|
|
291
|
+
|
|
292
|
+
export { Marker, MarkerContent, MarkerIcon, type MarkerProps } from './opinionated/marker'
|
|
293
|
+
|
|
294
|
+
export {
|
|
295
|
+
Message,
|
|
296
|
+
MessageAvatar,
|
|
297
|
+
MessageContent,
|
|
298
|
+
MessageFooter,
|
|
299
|
+
MessageGroup,
|
|
300
|
+
MessageHeader,
|
|
301
|
+
} from './opinionated/message'
|
|
302
|
+
|
|
303
|
+
export {
|
|
304
|
+
NativeSelect,
|
|
305
|
+
NativeSelectOptGroup,
|
|
306
|
+
NativeSelectOption,
|
|
307
|
+
type NativeSelectOptionData,
|
|
308
|
+
type NativeSelectProps,
|
|
309
|
+
} from './opinionated/native-select'
|
|
310
|
+
|
|
311
|
+
export {
|
|
312
|
+
Pagination,
|
|
313
|
+
PaginationContent,
|
|
314
|
+
PaginationEllipsis,
|
|
315
|
+
PaginationItem,
|
|
316
|
+
PaginationLink,
|
|
317
|
+
PaginationNext,
|
|
318
|
+
PaginationPrevious,
|
|
319
|
+
type PaginationProps,
|
|
320
|
+
} from './opinionated/pagination'
|
|
321
|
+
|
|
322
|
+
export {
|
|
323
|
+
Popover,
|
|
324
|
+
PopoverContent,
|
|
325
|
+
PopoverDescription,
|
|
326
|
+
PopoverHeader,
|
|
327
|
+
PopoverTitle,
|
|
328
|
+
PopoverTrigger,
|
|
329
|
+
type PopoverProps,
|
|
330
|
+
} from './opinionated/popover'
|
|
331
|
+
|
|
332
|
+
export {
|
|
333
|
+
Progress,
|
|
334
|
+
ProgressIndicator,
|
|
335
|
+
ProgressLabel,
|
|
336
|
+
ProgressTrack,
|
|
337
|
+
ProgressValue,
|
|
338
|
+
type ProgressProps,
|
|
339
|
+
} from './opinionated/progress'
|
|
340
|
+
|
|
341
|
+
export { RadioGroup, RadioGroupItem } from './opinionated/radio-group'
|
|
342
|
+
|
|
343
|
+
export { ResizablePanelGroup, ResizablePanel, ResizableHandle } from './opinionated/resizable'
|
|
344
|
+
|
|
345
|
+
export { ScrollArea, ScrollBar, type ScrollAreaProps } from './opinionated/scroll-area'
|
|
346
|
+
|
|
347
|
+
export {
|
|
348
|
+
Select,
|
|
349
|
+
SelectContent,
|
|
350
|
+
SelectGroup,
|
|
351
|
+
SelectItem,
|
|
352
|
+
SelectLabel,
|
|
353
|
+
SelectTrigger,
|
|
354
|
+
SelectValue,
|
|
355
|
+
type SelectOption,
|
|
356
|
+
type SelectProps,
|
|
357
|
+
} from './opinionated/select'
|
|
358
|
+
|
|
359
|
+
export { Separator } from './opinionated/separator'
|
|
360
|
+
|
|
361
|
+
export {
|
|
362
|
+
Sheet,
|
|
363
|
+
SheetClose,
|
|
364
|
+
SheetContent,
|
|
365
|
+
SheetDescription,
|
|
366
|
+
SheetFooter,
|
|
367
|
+
SheetHeader,
|
|
368
|
+
SheetTitle,
|
|
369
|
+
SheetTrigger,
|
|
370
|
+
type SheetProps,
|
|
371
|
+
} from './opinionated/sheet'
|
|
372
|
+
|
|
373
|
+
export {
|
|
374
|
+
Sidebar,
|
|
375
|
+
SidebarContent,
|
|
376
|
+
SidebarFooter,
|
|
377
|
+
SidebarGroup,
|
|
378
|
+
SidebarGroupAction,
|
|
379
|
+
SidebarGroupContent,
|
|
380
|
+
SidebarGroupLabel,
|
|
381
|
+
SidebarHeader,
|
|
382
|
+
SidebarInput,
|
|
383
|
+
SidebarInset,
|
|
384
|
+
SidebarMenu,
|
|
385
|
+
SidebarMenuAction,
|
|
386
|
+
SidebarMenuBadge,
|
|
387
|
+
SidebarMenuButton,
|
|
388
|
+
SidebarMenuItem,
|
|
389
|
+
SidebarMenuSkeleton,
|
|
390
|
+
SidebarMenuSub,
|
|
391
|
+
SidebarMenuSubButton,
|
|
392
|
+
SidebarMenuSubItem,
|
|
393
|
+
SidebarProvider,
|
|
394
|
+
SidebarRail,
|
|
395
|
+
SidebarSeparator,
|
|
396
|
+
SidebarTrigger,
|
|
397
|
+
useSidebar,
|
|
398
|
+
} from './opinionated/sidebar'
|
|
399
|
+
|
|
400
|
+
export {
|
|
401
|
+
Skeleton,
|
|
402
|
+
SkeletonText,
|
|
403
|
+
SkeletonAvatar,
|
|
404
|
+
SkeletonButton,
|
|
405
|
+
SkeletonInput,
|
|
406
|
+
type SkeletonProps,
|
|
407
|
+
} from './opinionated/skeleton'
|
|
408
|
+
|
|
409
|
+
export { Slider } from './opinionated/slider'
|
|
410
|
+
export { Toaster } from './opinionated/sonner'
|
|
411
|
+
export { Spacer } from './opinionated/spacer'
|
|
412
|
+
export { Stack } from './opinionated/stack'
|
|
413
|
+
export { Switch } from './opinionated/switch'
|
|
414
|
+
|
|
415
|
+
export {
|
|
416
|
+
Table,
|
|
417
|
+
TableBody,
|
|
418
|
+
TableCaption,
|
|
419
|
+
TableCell,
|
|
420
|
+
TableFooter,
|
|
421
|
+
TableHead,
|
|
422
|
+
TableHeader,
|
|
423
|
+
TableRow,
|
|
424
|
+
} from './opinionated/table'
|
|
425
|
+
|
|
426
|
+
export { Tabs, TabsContent, type TabItem } from './opinionated/tabs'
|
|
427
|
+
|
|
428
|
+
export { Textarea } from './opinionated/textarea'
|
|
429
|
+
export { ThemeInjector } from './opinionated/theme-injector'
|
|
430
|
+
export { Toggle, type ToggleProps } from './opinionated/toggle'
|
|
431
|
+
export {
|
|
432
|
+
ToggleGroup,
|
|
433
|
+
ToggleGroupItem,
|
|
434
|
+
type ToggleGroupOption,
|
|
435
|
+
type ToggleGroupProps,
|
|
436
|
+
} from './opinionated/toggle-group'
|
|
437
|
+
|
|
438
|
+
export { Tooltip, TooltipContent, TooltipTrigger, type TooltipProps } from './opinionated/tooltip'
|
|
439
|
+
|
|
440
|
+
export { Typography } from './opinionated/typography'
|
|
441
|
+
|
|
442
|
+
// Token config panel (advanced)
|
|
443
|
+
export { TokenConfigPanel } from './opinionated/token-config-panel'
|