@blankways/ui 0.0.0-stage → 0.1.0-alpha.1
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/README.md +228 -2
- package/dist/cli/cli.options.d.ts +5 -0
- package/dist/cli/cli.options.js +53 -0
- package/dist/cli/cli.registry.d.ts +6 -0
- package/dist/cli/cli.registry.js +37 -0
- package/dist/cli/cli.types.d.ts +32 -0
- package/dist/cli/cli.types.js +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +47 -0
- package/dist/commands/add.command.d.ts +2 -0
- package/dist/commands/add.command.js +101 -0
- package/dist/commands/doctor.command.d.ts +3 -0
- package/dist/commands/doctor.command.js +92 -0
- package/dist/commands/index.d.ts +6 -0
- package/dist/commands/index.js +6 -0
- package/dist/commands/init.command.d.ts +2 -0
- package/dist/commands/init.command.js +38 -0
- package/dist/commands/list.command.d.ts +2 -0
- package/dist/commands/list.command.js +54 -0
- package/dist/commands/meta.command.d.ts +1 -0
- package/dist/commands/meta.command.js +19 -0
- package/dist/commands/styles.command.d.ts +6 -0
- package/dist/commands/styles.command.js +68 -0
- package/dist/config/config.helpers.d.ts +7 -0
- package/dist/config/config.helpers.js +63 -0
- package/dist/config/framework.helpers.d.ts +3 -0
- package/dist/config/framework.helpers.js +14 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +2 -0
- package/dist/constants/cli.constants.d.ts +9 -0
- package/dist/constants/cli.constants.js +15 -0
- package/dist/constants/framework.constants.d.ts +3 -0
- package/dist/constants/framework.constants.js +2 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.js +2 -0
- package/dist/doctor/checks/entries.check.d.ts +1 -0
- package/dist/doctor/checks/entries.check.js +21 -0
- package/dist/doctor/checks/icons.check.d.ts +1 -0
- package/dist/doctor/checks/icons.check.js +55 -0
- package/dist/doctor/checks/imports.check.d.ts +1 -0
- package/dist/doctor/checks/imports.check.js +45 -0
- package/dist/doctor/checks/index.d.ts +7 -0
- package/dist/doctor/checks/index.js +7 -0
- package/dist/doctor/checks/motion.check.d.ts +1 -0
- package/dist/doctor/checks/motion.check.js +66 -0
- package/dist/doctor/checks/peers.check.d.ts +1 -0
- package/dist/doctor/checks/peers.check.js +55 -0
- package/dist/doctor/checks/styles.check.d.ts +1 -0
- package/dist/doctor/checks/styles.check.js +45 -0
- package/dist/doctor/checks/themes.check.d.ts +1 -0
- package/dist/doctor/checks/themes.check.js +64 -0
- package/dist/doctor/doctor.helpers.d.ts +6 -0
- package/dist/doctor/doctor.helpers.js +39 -0
- package/dist/doctor/doctor.registry.d.ts +10 -0
- package/dist/doctor/doctor.registry.js +24 -0
- package/dist/doctor/doctor.types.d.ts +27 -0
- package/dist/doctor/doctor.types.js +1 -0
- package/dist/doctor/index.d.ts +3 -0
- package/dist/doctor/index.js +3 -0
- package/dist/errors/cli-error.d.ts +3 -0
- package/dist/errors/cli-error.js +6 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/helpers/args.helpers.d.ts +4 -0
- package/dist/helpers/args.helpers.js +75 -0
- package/dist/helpers/help.helpers.d.ts +1 -0
- package/dist/helpers/help.helpers.js +30 -0
- package/dist/helpers/index.d.ts +5 -0
- package/dist/helpers/index.js +5 -0
- package/dist/helpers/package.helpers.d.ts +2 -0
- package/dist/helpers/package.helpers.js +12 -0
- package/dist/helpers/path.helpers.d.ts +3 -0
- package/dist/helpers/path.helpers.js +15 -0
- package/dist/helpers/styles.helpers.d.ts +21 -0
- package/dist/helpers/styles.helpers.js +164 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/registry/index.d.ts +1 -0
- package/dist/registry/index.js +1 -0
- package/dist/registry/registry.helpers.d.ts +22 -0
- package/dist/registry/registry.helpers.js +328 -0
- package/dist/registry-data/README.md +71 -0
- package/dist/registry-data/avatar/Avatar.tsx +64 -0
- package/dist/registry-data/avatar/component.json +30 -0
- package/dist/registry-data/avatar/index.ts +1 -0
- package/dist/registry-data/badge/Badge.tsx +76 -0
- package/dist/registry-data/badge/component.json +30 -0
- package/dist/registry-data/badge/index.ts +1 -0
- package/dist/registry-data/brand-logo/BrandLogo.tsx +24 -0
- package/dist/registry-data/brand-logo/component.json +26 -0
- package/dist/registry-data/brand-logo/index.ts +1 -0
- package/dist/registry-data/button/Button.tsx +76 -0
- package/dist/registry-data/button/component.json +33 -0
- package/dist/registry-data/button/index.ts +1 -0
- package/dist/registry-data/button-link/ButtonLink.tsx +83 -0
- package/dist/registry-data/button-link/component.json +33 -0
- package/dist/registry-data/button-link/index.ts +5 -0
- package/dist/registry-data/button-styles/component.json +19 -0
- package/dist/registry-data/button-styles/index.ts +45 -0
- package/dist/registry-data/cn/cn.ts +6 -0
- package/dist/registry-data/cn/component.json +16 -0
- package/dist/registry-data/confirm-dialog/ConfirmDialog.tsx +134 -0
- package/dist/registry-data/confirm-dialog/component.json +34 -0
- package/dist/registry-data/confirm-dialog/index.ts +1 -0
- package/dist/registry-data/container/Container.tsx +22 -0
- package/dist/registry-data/container/component.json +28 -0
- package/dist/registry-data/container/index.ts +1 -0
- package/dist/registry-data/cursor-glow/CursorGlow.tsx +29 -0
- package/dist/registry-data/cursor-glow/component.json +28 -0
- package/dist/registry-data/cursor-glow/index.ts +1 -0
- package/dist/registry-data/dropdown-menu/DropdownMenu.tsx +157 -0
- package/dist/registry-data/dropdown-menu/component.json +34 -0
- package/dist/registry-data/dropdown-menu/index.ts +5 -0
- package/dist/registry-data/empty-state/EmptyState.tsx +92 -0
- package/dist/registry-data/empty-state/component.json +30 -0
- package/dist/registry-data/empty-state/index.ts +5 -0
- package/dist/registry-data/eyebrow/Eyebrow.tsx +68 -0
- package/dist/registry-data/eyebrow/component.json +30 -0
- package/dist/registry-data/eyebrow/index.ts +1 -0
- package/dist/registry-data/field-styles/component.json +19 -0
- package/dist/registry-data/field-styles/index.ts +42 -0
- package/dist/registry-data/form-dialog/FormDialog.tsx +128 -0
- package/dist/registry-data/form-dialog/component.json +34 -0
- package/dist/registry-data/form-dialog/index.ts +1 -0
- package/dist/registry-data/icons/component.json +22 -0
- package/dist/registry-data/icons/index.ts +21 -0
- package/dist/registry-data/icons-form/component.json +17 -0
- package/dist/registry-data/icons-form/index.ts +1 -0
- package/dist/registry-data/icons-sidebar/component.json +17 -0
- package/dist/registry-data/icons-sidebar/index.ts +1 -0
- package/dist/registry-data/icons-theme/component.json +17 -0
- package/dist/registry-data/icons-theme/index.ts +1 -0
- package/dist/registry-data/icons-toast/component.json +17 -0
- package/dist/registry-data/icons-toast/index.ts +1 -0
- package/dist/registry-data/info-dialog/InfoDialog.tsx +119 -0
- package/dist/registry-data/info-dialog/component.json +36 -0
- package/dist/registry-data/info-dialog/index.ts +1 -0
- package/dist/registry-data/input/Input.tsx +96 -0
- package/dist/registry-data/input/component.json +33 -0
- package/dist/registry-data/input/index.ts +1 -0
- package/dist/registry-data/multi-combobox/MultiCombobox.tsx +205 -0
- package/dist/registry-data/multi-combobox/component.json +35 -0
- package/dist/registry-data/multi-combobox/index.ts +5 -0
- package/dist/registry-data/remote-provider/RemoteProvider.tsx +8 -0
- package/dist/registry-data/remote-provider/component.json +25 -0
- package/dist/registry-data/remote-provider/index.ts +3 -0
- package/dist/registry-data/reveal/Reveal.tsx +22 -0
- package/dist/registry-data/reveal/component.json +30 -0
- package/dist/registry-data/reveal/index.ts +1 -0
- package/dist/registry-data/section/Section.tsx +80 -0
- package/dist/registry-data/section/component.json +30 -0
- package/dist/registry-data/section/index.ts +1 -0
- package/dist/registry-data/section-heading/SectionHeading.tsx +105 -0
- package/dist/registry-data/section-heading/component.json +32 -0
- package/dist/registry-data/section-heading/index.ts +1 -0
- package/dist/registry-data/select/Select.tsx +197 -0
- package/dist/registry-data/select/component.json +34 -0
- package/dist/registry-data/select/index.ts +1 -0
- package/dist/registry-data/sidebar/Sidebar.tsx +432 -0
- package/dist/registry-data/sidebar/SidebarCollapsible.tsx +77 -0
- package/dist/registry-data/sidebar/SidebarParts.tsx +373 -0
- package/dist/registry-data/sidebar/component.json +47 -0
- package/dist/registry-data/sidebar/index.ts +4 -0
- package/dist/registry-data/sidebar/useSidebar.ts +29 -0
- package/dist/registry-data/styles-base/component.json +19 -0
- package/dist/registry-data/styles-base/index.css +67 -0
- package/dist/registry-data/styles-components/component.json +19 -0
- package/dist/registry-data/styles-components/index.css +30 -0
- package/dist/registry-data/styles-motion/component.json +20 -0
- package/dist/registry-data/styles-motion/index.css +381 -0
- package/dist/registry-data/styles-tokens/component.json +17 -0
- package/dist/registry-data/styles-tokens/index.css +77 -0
- package/dist/registry-data/styles-utilities/component.json +19 -0
- package/dist/registry-data/styles-utilities/index.css +29 -0
- package/dist/registry-data/switch/Switch.tsx +91 -0
- package/dist/registry-data/switch/component.json +34 -0
- package/dist/registry-data/switch/index.ts +1 -0
- package/dist/registry-data/tabs/Tabs.tsx +226 -0
- package/dist/registry-data/tabs/component.json +32 -0
- package/dist/registry-data/tabs/index.ts +1 -0
- package/dist/registry-data/textarea/Textarea.tsx +94 -0
- package/dist/registry-data/textarea/component.json +33 -0
- package/dist/registry-data/textarea/index.ts +1 -0
- package/dist/registry-data/theme-core/component.json +17 -0
- package/dist/registry-data/theme-core/theme.ts +84 -0
- package/dist/registry-data/theme-dark/component.json +19 -0
- package/dist/registry-data/theme-dark/index.ts +7 -0
- package/dist/registry-data/theme-light/component.json +19 -0
- package/dist/registry-data/theme-light/index.ts +7 -0
- package/dist/registry-data/theme-provider/ThemeContext.tsx +177 -0
- package/dist/registry-data/theme-provider/component.json +30 -0
- package/dist/registry-data/theme-provider/index.ts +2 -0
- package/dist/registry-data/theme-selector/ThemeSelector.tsx +269 -0
- package/dist/registry-data/theme-selector/component.json +35 -0
- package/dist/registry-data/theme-selector/selector.ts +1 -0
- package/dist/registry-data/theme-system/component.json +19 -0
- package/dist/registry-data/theme-system/index.ts +7 -0
- package/dist/registry-data/theme-toggle/ThemeToggle.tsx +71 -0
- package/dist/registry-data/theme-toggle/component.json +31 -0
- package/dist/registry-data/theme-toggle/toggle.ts +1 -0
- package/dist/registry-data/toast/Toast.tsx +260 -0
- package/dist/registry-data/toast/ToastTypeIcon.tsx +83 -0
- package/dist/registry-data/toast/component.json +43 -0
- package/dist/registry-data/toast/index.ts +3 -0
- package/dist/registry-data/toast/useToast.ts +47 -0
- package/dist/types/cli.types.d.ts +6 -0
- package/dist/types/cli.types.js +1 -0
- package/dist/types/config.types.d.ts +41 -0
- package/dist/types/config.types.js +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +3 -0
- package/dist/types/registry.types.d.ts +37 -0
- package/dist/types/registry.types.js +1 -0
- package/package.json +35 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Check,
|
|
3
|
+
ChevronDown,
|
|
4
|
+
ChevronRight,
|
|
5
|
+
X,
|
|
6
|
+
Moon,
|
|
7
|
+
Sun,
|
|
8
|
+
Monitor,
|
|
9
|
+
PanelLeftClose,
|
|
10
|
+
PanelLeftOpen,
|
|
11
|
+
Menu,
|
|
12
|
+
Search,
|
|
13
|
+
Plus,
|
|
14
|
+
Info,
|
|
15
|
+
CircleCheck,
|
|
16
|
+
TriangleAlert,
|
|
17
|
+
CircleAlert,
|
|
18
|
+
ArrowRight,
|
|
19
|
+
} from 'lucide-react'
|
|
20
|
+
|
|
21
|
+
export type { LucideIcon } from 'lucide-react'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "icons-form",
|
|
3
|
+
"kind": "icon",
|
|
4
|
+
"framework": "react",
|
|
5
|
+
"description": "Lucide icons for form controls, selects and confirmations.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"peers": [
|
|
8
|
+
"lucide-react"
|
|
9
|
+
],
|
|
10
|
+
"suggestions": [],
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"source": "index.ts",
|
|
14
|
+
"target": "icons/form.ts"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Check, ChevronDown, ChevronRight, X, Search, Plus } from 'lucide-react'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "icons-sidebar",
|
|
3
|
+
"kind": "icon",
|
|
4
|
+
"framework": "react",
|
|
5
|
+
"description": "Lucide icons for sidebar toggles and collapsible navigation.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"peers": [
|
|
8
|
+
"lucide-react"
|
|
9
|
+
],
|
|
10
|
+
"suggestions": [],
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"source": "index.ts",
|
|
14
|
+
"target": "icons/sidebar.ts"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PanelLeftClose, PanelLeftOpen, Menu, ChevronRight } from 'lucide-react'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "icons-theme",
|
|
3
|
+
"kind": "icon",
|
|
4
|
+
"framework": "react",
|
|
5
|
+
"description": "Lucide icons for light, dark and system theme controls.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"peers": [
|
|
8
|
+
"lucide-react"
|
|
9
|
+
],
|
|
10
|
+
"suggestions": [],
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"source": "index.ts",
|
|
14
|
+
"target": "icons/theme.ts"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Moon, Sun, Monitor } from 'lucide-react'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "icons-toast",
|
|
3
|
+
"kind": "icon",
|
|
4
|
+
"framework": "react",
|
|
5
|
+
"description": "Lucide icons for informational and status toast messages.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"peers": [
|
|
8
|
+
"lucide-react"
|
|
9
|
+
],
|
|
10
|
+
"suggestions": [],
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"source": "index.ts",
|
|
14
|
+
"target": "icons/toast.ts"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Info, CircleCheck, TriangleAlert, CircleAlert, X } from 'lucide-react'
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef } from 'react'
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
import { createPortal } from 'react-dom'
|
|
4
|
+
import { State, type StateId } from '@blankways/state'
|
|
5
|
+
import {
|
|
6
|
+
Show,
|
|
7
|
+
Text,
|
|
8
|
+
useAttributes,
|
|
9
|
+
useCompute,
|
|
10
|
+
useState,
|
|
11
|
+
type ReactiveAttributes,
|
|
12
|
+
} from '@blankways/state-react'
|
|
13
|
+
import { cn } from '../../internals/cn.js'
|
|
14
|
+
import { X } from '../../icons/form.js'
|
|
15
|
+
|
|
16
|
+
export type InfoDialogProps = {
|
|
17
|
+
open: boolean
|
|
18
|
+
onOpenChange: (open: boolean) => void
|
|
19
|
+
title: string
|
|
20
|
+
description?: string
|
|
21
|
+
children: ReactNode
|
|
22
|
+
/** Names the close button. */
|
|
23
|
+
closeLabel: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function useSyncedState<Type>(value: Type): StateId<Type> {
|
|
27
|
+
const state = useState(value)
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!Object.is(State.get(state), value)) State.set(state, value)
|
|
30
|
+
}, [state, value])
|
|
31
|
+
return state
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Controlled information dialog with a close button, Escape and outside click. */
|
|
35
|
+
export function InfoDialog({
|
|
36
|
+
open,
|
|
37
|
+
onOpenChange,
|
|
38
|
+
title,
|
|
39
|
+
description,
|
|
40
|
+
children,
|
|
41
|
+
closeLabel,
|
|
42
|
+
}: InfoDialogProps) {
|
|
43
|
+
const openState = useState(open)
|
|
44
|
+
const titleState = useSyncedState(title)
|
|
45
|
+
const descriptionState = useSyncedState(description ?? '')
|
|
46
|
+
const hasDescription = useSyncedState(Boolean(description))
|
|
47
|
+
const modalState = useState('true')
|
|
48
|
+
const stateName = useCompute([openState] as const, ([isOpen]) =>
|
|
49
|
+
isOpen ? 'open' : 'closed',
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
State.set(openState, open)
|
|
54
|
+
}, [open, openState])
|
|
55
|
+
|
|
56
|
+
const panelRef = useRef<HTMLDivElement | null>(null)
|
|
57
|
+
const attributes = useMemo<ReactiveAttributes<HTMLDivElement>>(
|
|
58
|
+
() => ({ 'aria-modal': modalState, 'data-state': stateName }),
|
|
59
|
+
[modalState, stateName],
|
|
60
|
+
)
|
|
61
|
+
useAttributes(panelRef, attributes)
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (!open) return
|
|
65
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
66
|
+
if (event.key === 'Escape') onOpenChange(false)
|
|
67
|
+
}
|
|
68
|
+
document.addEventListener('keydown', onKeyDown)
|
|
69
|
+
panelRef.current?.focus()
|
|
70
|
+
return () => document.removeEventListener('keydown', onKeyDown)
|
|
71
|
+
}, [open, onOpenChange])
|
|
72
|
+
|
|
73
|
+
if (typeof document === 'undefined') return null
|
|
74
|
+
|
|
75
|
+
return createPortal(
|
|
76
|
+
<>
|
|
77
|
+
<Show when={openState}>
|
|
78
|
+
<div
|
|
79
|
+
data-state="open"
|
|
80
|
+
className="backdrop-enter fixed inset-0 z-50 bg-black/50 backdrop-blur-[2px]"
|
|
81
|
+
onClick={() => onOpenChange(false)}
|
|
82
|
+
/>
|
|
83
|
+
</Show>
|
|
84
|
+
<Show when={openState}>
|
|
85
|
+
<div
|
|
86
|
+
ref={panelRef}
|
|
87
|
+
role="dialog"
|
|
88
|
+
tabIndex={-1}
|
|
89
|
+
className={cn(
|
|
90
|
+
'surface-enter fixed top-1/2 left-1/2 z-50 flex max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col gap-5 overflow-y-auto rounded-2xl border border-line bg-paper p-[1.125rem] shadow-2xl outline-none',
|
|
91
|
+
)}
|
|
92
|
+
>
|
|
93
|
+
<div className="flex items-start justify-between gap-4">
|
|
94
|
+
<div className="flex flex-col gap-1.5">
|
|
95
|
+
<h2 className="text-lg font-semibold tracking-[-0.01em] text-ink">
|
|
96
|
+
<Text as="span" value={titleState} />
|
|
97
|
+
</h2>
|
|
98
|
+
<Show when={hasDescription}>
|
|
99
|
+
<p className="text-sm leading-relaxed text-ink-soft">
|
|
100
|
+
<Text as="span" value={descriptionState} />
|
|
101
|
+
</p>
|
|
102
|
+
</Show>
|
|
103
|
+
</div>
|
|
104
|
+
<button
|
|
105
|
+
type="button"
|
|
106
|
+
aria-label={closeLabel}
|
|
107
|
+
onClick={() => onOpenChange(false)}
|
|
108
|
+
className="inline-flex size-8 shrink-0 items-center justify-center rounded-2xl text-ink-soft motion-color outline-none hover:bg-surface-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-brand-500"
|
|
109
|
+
>
|
|
110
|
+
<X className="size-4" aria-hidden="true" />
|
|
111
|
+
</button>
|
|
112
|
+
</div>
|
|
113
|
+
{children}
|
|
114
|
+
</div>
|
|
115
|
+
</Show>
|
|
116
|
+
</>,
|
|
117
|
+
document.body,
|
|
118
|
+
)
|
|
119
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "info-dialog",
|
|
3
|
+
"kind": "component",
|
|
4
|
+
"framework": "react",
|
|
5
|
+
"description": "Controlled read-only dialog with a native portal and close button.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"cn",
|
|
8
|
+
"button",
|
|
9
|
+
"icons-form",
|
|
10
|
+
"styles-motion"
|
|
11
|
+
],
|
|
12
|
+
"peers": [
|
|
13
|
+
"@blankways/state",
|
|
14
|
+
"@blankways/state-react@0.1.0-alpha.1",
|
|
15
|
+
"react",
|
|
16
|
+
"react-dom",
|
|
17
|
+
"lucide-react"
|
|
18
|
+
],
|
|
19
|
+
"suggestions": [
|
|
20
|
+
"styles-tokens",
|
|
21
|
+
"styles-base",
|
|
22
|
+
"styles-components",
|
|
23
|
+
"styles-utilities",
|
|
24
|
+
"styles-motion"
|
|
25
|
+
],
|
|
26
|
+
"files": [
|
|
27
|
+
{
|
|
28
|
+
"source": "InfoDialog.tsx",
|
|
29
|
+
"target": "components/info-dialog/InfoDialog.tsx"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"source": "index.ts",
|
|
33
|
+
"target": "components/info-dialog/index.ts"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InfoDialog, type InfoDialogProps } from './InfoDialog.js'
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { forwardRef, useCallback, useEffect, useMemo, useRef } from 'react'
|
|
2
|
+
import type { ChangeEvent, ComponentPropsWithoutRef } from 'react'
|
|
3
|
+
import { State, type StateId } from '@blankways/state'
|
|
4
|
+
import { useAttributes, useState, type ReactiveAttributes } from '@blankways/state-react'
|
|
5
|
+
import { cn } from '../../internals/cn.js'
|
|
6
|
+
import {
|
|
7
|
+
fieldBase,
|
|
8
|
+
fieldErrorClasses,
|
|
9
|
+
fieldShapeClasses,
|
|
10
|
+
fieldToneClasses,
|
|
11
|
+
type FieldShape,
|
|
12
|
+
type FieldTone,
|
|
13
|
+
} from '../../styles/field-styles.js'
|
|
14
|
+
|
|
15
|
+
export type InputProps = Omit<ComponentPropsWithoutRef<'input'>, 'value'> & {
|
|
16
|
+
value?: string | StateId<string>
|
|
17
|
+
invalid?: boolean | StateId<boolean>
|
|
18
|
+
shape?: FieldShape
|
|
19
|
+
tone?: FieldTone
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Text input with the shared field recipes and optional state-bound value. */
|
|
23
|
+
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
|
|
24
|
+
{
|
|
25
|
+
className,
|
|
26
|
+
tone = 'default',
|
|
27
|
+
shape = 'rounded',
|
|
28
|
+
invalid = false,
|
|
29
|
+
value,
|
|
30
|
+
onChange,
|
|
31
|
+
...rest
|
|
32
|
+
},
|
|
33
|
+
forwardedRef,
|
|
34
|
+
) {
|
|
35
|
+
const localValue = useState<string>(typeof value === 'string' ? value : '')
|
|
36
|
+
const localInvalid = useState<boolean>(
|
|
37
|
+
typeof invalid === 'boolean' ? invalid : false,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
const valueState = typeof value === 'number' ? value : localValue
|
|
41
|
+
const invalidState = typeof invalid === 'number' ? invalid : localInvalid
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (typeof value === 'string') State.set(localValue, value)
|
|
45
|
+
}, [value, localValue])
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (typeof invalid === 'boolean') State.set(localInvalid, invalid)
|
|
49
|
+
}, [invalid, localInvalid])
|
|
50
|
+
|
|
51
|
+
const ref = useRef<HTMLInputElement | null>(null)
|
|
52
|
+
const attributes = useMemo<ReactiveAttributes<HTMLInputElement>>(
|
|
53
|
+
() => ({
|
|
54
|
+
...(value !== undefined ? { value: valueState } : {}),
|
|
55
|
+
...(typeof invalid === 'number'
|
|
56
|
+
? { 'aria-invalid': invalidState, 'data-invalid': invalidState }
|
|
57
|
+
: {}),
|
|
58
|
+
}),
|
|
59
|
+
[invalid, invalidState, value, valueState],
|
|
60
|
+
)
|
|
61
|
+
useAttributes(ref, attributes)
|
|
62
|
+
|
|
63
|
+
const setRef = useCallback(
|
|
64
|
+
(element: HTMLInputElement | null) => {
|
|
65
|
+
ref.current = element
|
|
66
|
+
if (typeof forwardedRef === 'function') forwardedRef(element)
|
|
67
|
+
else if (forwardedRef) {
|
|
68
|
+
;(forwardedRef as { current: HTMLInputElement | null }).current = element
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
[forwardedRef],
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
75
|
+
State.set(valueState, event.currentTarget.value)
|
|
76
|
+
onChange?.(event)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<input
|
|
81
|
+
{...rest}
|
|
82
|
+
ref={setRef}
|
|
83
|
+
value={typeof value === 'string' ? value : undefined}
|
|
84
|
+
onChange={handleChange}
|
|
85
|
+
aria-invalid={typeof invalid === 'boolean' ? invalid || undefined : undefined}
|
|
86
|
+
className={cn(
|
|
87
|
+
fieldBase,
|
|
88
|
+
fieldShapeClasses[shape],
|
|
89
|
+
fieldToneClasses[tone],
|
|
90
|
+
typeof invalid === 'boolean' && invalid && fieldErrorClasses,
|
|
91
|
+
'data-[invalid=true]:border-brand-500 aria-[invalid=true]:ring-2 aria-[invalid=true]:ring-brand-500/30',
|
|
92
|
+
className,
|
|
93
|
+
)}
|
|
94
|
+
/>
|
|
95
|
+
)
|
|
96
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "input",
|
|
3
|
+
"kind": "component",
|
|
4
|
+
"framework": "react",
|
|
5
|
+
"description": "Native input with shared field styles and state-bound value and invalid flags.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"cn",
|
|
8
|
+
"field-styles",
|
|
9
|
+
"styles-motion"
|
|
10
|
+
],
|
|
11
|
+
"peers": [
|
|
12
|
+
"@blankways/state",
|
|
13
|
+
"@blankways/state-react@0.1.0-alpha.1",
|
|
14
|
+
"react"
|
|
15
|
+
],
|
|
16
|
+
"suggestions": [
|
|
17
|
+
"styles-tokens",
|
|
18
|
+
"styles-base",
|
|
19
|
+
"styles-components",
|
|
20
|
+
"styles-utilities",
|
|
21
|
+
"styles-motion"
|
|
22
|
+
],
|
|
23
|
+
"files": [
|
|
24
|
+
{
|
|
25
|
+
"source": "Input.tsx",
|
|
26
|
+
"target": "components/input/Input.tsx"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"source": "index.ts",
|
|
30
|
+
"target": "components/input/index.ts"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Input, type InputProps } from './Input.js'
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react'
|
|
2
|
+
import { useState as useReactState } from 'react'
|
|
3
|
+
import type { CSSProperties, KeyboardEvent } from 'react'
|
|
4
|
+
import { State, type StateId } from '@blankways/state'
|
|
5
|
+
import { Show, Text, useCompute, useState } from '@blankways/state-react'
|
|
6
|
+
import { cn } from '../../internals/cn.js'
|
|
7
|
+
import { Check, Search, X } from '../../icons/form.js'
|
|
8
|
+
import type { SelectOption } from '../select/index.js'
|
|
9
|
+
|
|
10
|
+
export type { SelectOption } from '../select/index.js'
|
|
11
|
+
|
|
12
|
+
export type MultiComboboxProps = {
|
|
13
|
+
options: SelectOption[]
|
|
14
|
+
value?: string[]
|
|
15
|
+
onValueChange?: (value: string[]) => void
|
|
16
|
+
placeholder?: string
|
|
17
|
+
invalid?: boolean
|
|
18
|
+
/** Shown when the typed text matches no option. */
|
|
19
|
+
emptyLabel?: string
|
|
20
|
+
/** Names each chip's remove button. */
|
|
21
|
+
removeLabel?: string
|
|
22
|
+
className?: string
|
|
23
|
+
'aria-label'?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function ChipLabel({ labels, index }: { labels: StateId<string[]>; index: number }) {
|
|
27
|
+
const label = useCompute([labels] as const, ([all]) => all[index] ?? '')
|
|
28
|
+
return <Text as="span" value={label} />
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Multi-select with typed filtering and removable chips, built from native elements. */
|
|
32
|
+
export function MultiCombobox({
|
|
33
|
+
options,
|
|
34
|
+
value = [],
|
|
35
|
+
onValueChange,
|
|
36
|
+
placeholder = 'Buscar…',
|
|
37
|
+
invalid = false,
|
|
38
|
+
emptyLabel = 'Sin resultados',
|
|
39
|
+
removeLabel = 'Quitar',
|
|
40
|
+
className,
|
|
41
|
+
'aria-label': ariaLabel,
|
|
42
|
+
}: MultiComboboxProps) {
|
|
43
|
+
const queryState = useState('')
|
|
44
|
+
const openState = useState(false)
|
|
45
|
+
const [query, setQuery] = useReactState('')
|
|
46
|
+
const [open, setOpen] = useReactState(false)
|
|
47
|
+
|
|
48
|
+
const valueState = useState(value)
|
|
49
|
+
const optionsState = useState(options)
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
State.set(valueState, value)
|
|
52
|
+
}, [value, valueState])
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
State.set(optionsState, options)
|
|
55
|
+
}, [options, optionsState])
|
|
56
|
+
|
|
57
|
+
const filteredOptions = useCompute(
|
|
58
|
+
[queryState, optionsState] as const,
|
|
59
|
+
([text, list]) => {
|
|
60
|
+
const needle = text.trim().toLowerCase()
|
|
61
|
+
if (!needle) return list
|
|
62
|
+
return list.filter(
|
|
63
|
+
(option) =>
|
|
64
|
+
option.label.toLowerCase().includes(needle) ||
|
|
65
|
+
option.value.toLowerCase().includes(needle),
|
|
66
|
+
)
|
|
67
|
+
},
|
|
68
|
+
)
|
|
69
|
+
const selectedLabels = useCompute([valueState, optionsState] as const, ([selected, list]) =>
|
|
70
|
+
selected.map((item) => list.find((option) => option.value === item)?.label ?? item),
|
|
71
|
+
)
|
|
72
|
+
const hasChips = useCompute([valueState] as const, ([selected]) => selected.length > 0)
|
|
73
|
+
const hasResults = useCompute([filteredOptions] as const, ([list]) => list.length > 0)
|
|
74
|
+
const isEmpty = useCompute([hasResults] as const, ([has]) => !has)
|
|
75
|
+
|
|
76
|
+
const containerRef = useRef<HTMLDivElement | null>(null)
|
|
77
|
+
const inputRef = useRef<HTMLInputElement | null>(null)
|
|
78
|
+
|
|
79
|
+
const setQueryValue = (next: string) => {
|
|
80
|
+
State.set(queryState, next)
|
|
81
|
+
setQuery(next)
|
|
82
|
+
}
|
|
83
|
+
const setOpenValue = (next: boolean) => {
|
|
84
|
+
State.set(openState, next)
|
|
85
|
+
setOpen(next)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const choose = (option: SelectOption) => {
|
|
89
|
+
if (!State.get(valueState).includes(option.value)) {
|
|
90
|
+
onValueChange?.([...State.get(valueState), option.value])
|
|
91
|
+
}
|
|
92
|
+
setQueryValue('')
|
|
93
|
+
inputRef.current?.focus()
|
|
94
|
+
}
|
|
95
|
+
const remove = (item: string) => {
|
|
96
|
+
onValueChange?.(State.get(valueState).filter((entry) => entry !== item))
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (!open) return
|
|
101
|
+
const onPointerDown = (event: PointerEvent) => {
|
|
102
|
+
if (containerRef.current && !containerRef.current.contains(event.target as Node)) {
|
|
103
|
+
setOpenValue(false)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
document.addEventListener('pointerdown', onPointerDown)
|
|
107
|
+
return () => document.removeEventListener('pointerdown', onPointerDown)
|
|
108
|
+
}, [open])
|
|
109
|
+
|
|
110
|
+
const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
|
|
111
|
+
if (event.key === 'Escape') {
|
|
112
|
+
setOpenValue(false)
|
|
113
|
+
} else if (event.key === 'Enter' && open) {
|
|
114
|
+
const first = State.get(filteredOptions)[0]
|
|
115
|
+
if (first) {
|
|
116
|
+
event.preventDefault()
|
|
117
|
+
choose(first)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<div ref={containerRef} className={cn('relative w-full', className)}>
|
|
124
|
+
<div
|
|
125
|
+
className={cn(
|
|
126
|
+
'flex min-h-12 w-full flex-wrap items-center gap-1.5 rounded-2xl border border-line bg-paper px-[0.469rem] py-1.5 motion-color',
|
|
127
|
+
'focus-within:border-brand-500 hover:border-line-strong',
|
|
128
|
+
invalid && 'border-brand-500',
|
|
129
|
+
)}
|
|
130
|
+
>
|
|
131
|
+
<Show when={hasChips}>
|
|
132
|
+
<div className="flex flex-wrap items-center gap-1.5">
|
|
133
|
+
{value.map((item, index) => (
|
|
134
|
+
<span
|
|
135
|
+
key={item}
|
|
136
|
+
className="motion-icon-swap inline-flex items-center gap-1 rounded-2xl bg-accent-soft py-[0.188rem] pr-[0.188rem] pl-[0.5625rem] text-xs font-medium text-ink"
|
|
137
|
+
>
|
|
138
|
+
<ChipLabel labels={selectedLabels} index={index} />
|
|
139
|
+
<button
|
|
140
|
+
type="button"
|
|
141
|
+
aria-label={`${removeLabel} ${State.get(selectedLabels)[index] ?? item}`}
|
|
142
|
+
onClick={() => remove(item)}
|
|
143
|
+
className="inline-flex size-5 items-center justify-center rounded-full text-ink-soft outline-none motion-color hover:bg-paper hover:text-ink focus-visible:ring-2 focus-visible:ring-brand-500"
|
|
144
|
+
>
|
|
145
|
+
<X className="size-3" aria-hidden="true" />
|
|
146
|
+
</button>
|
|
147
|
+
</span>
|
|
148
|
+
))}
|
|
149
|
+
</div>
|
|
150
|
+
</Show>
|
|
151
|
+
|
|
152
|
+
<div className="flex min-w-24 flex-1 items-center gap-2">
|
|
153
|
+
<Search className="size-4 shrink-0 text-ink-muted" aria-hidden="true" />
|
|
154
|
+
<input
|
|
155
|
+
ref={inputRef}
|
|
156
|
+
value={query}
|
|
157
|
+
placeholder={value.length === 0 ? placeholder : undefined}
|
|
158
|
+
onChange={(event) => {
|
|
159
|
+
setQueryValue(event.currentTarget.value)
|
|
160
|
+
setOpenValue(true)
|
|
161
|
+
}}
|
|
162
|
+
onFocus={() => setOpenValue(true)}
|
|
163
|
+
onKeyDown={handleKeyDown}
|
|
164
|
+
aria-label={ariaLabel}
|
|
165
|
+
aria-invalid={invalid || undefined}
|
|
166
|
+
className="h-8 w-full min-w-24 flex-1 bg-transparent text-sm text-ink outline-none placeholder:text-ink-muted/70"
|
|
167
|
+
/>
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
<Show when={openState}>
|
|
172
|
+
<div
|
|
173
|
+
role="listbox"
|
|
174
|
+
aria-multiselectable="true"
|
|
175
|
+
data-state="open"
|
|
176
|
+
className="popup-enter absolute top-full left-0 z-[70] mt-1 max-h-64 w-full overflow-y-auto rounded-2xl border border-line bg-paper p-[0.281rem] text-ink shadow-xl outline-none"
|
|
177
|
+
>
|
|
178
|
+
<Show when={hasResults}>
|
|
179
|
+
<ul className="stagger-children flex flex-col gap-0.5" role="presentation">
|
|
180
|
+
{State.get(filteredOptions).map((option, index) => (
|
|
181
|
+
<li
|
|
182
|
+
key={option.value}
|
|
183
|
+
role="option"
|
|
184
|
+
aria-selected={value.includes(option.value)}
|
|
185
|
+
style={{ '--index': index } as CSSProperties}
|
|
186
|
+
onMouseDown={(event) => event.preventDefault()}
|
|
187
|
+
onClick={() => choose(option)}
|
|
188
|
+
className="flex cursor-pointer items-center gap-2.5 rounded-2xl px-[0.5625rem] py-1.5 text-sm text-ink outline-none select-none hover:bg-surface-2"
|
|
189
|
+
>
|
|
190
|
+
<span className="flex-1">{option.label}</span>
|
|
191
|
+
{value.includes(option.value) ? (
|
|
192
|
+
<Check className="size-4 text-brand-500" aria-hidden="true" />
|
|
193
|
+
) : null}
|
|
194
|
+
</li>
|
|
195
|
+
))}
|
|
196
|
+
</ul>
|
|
197
|
+
</Show>
|
|
198
|
+
<Show when={isEmpty}>
|
|
199
|
+
<p className="px-[0.5625rem] py-[0.5625rem] text-sm text-ink-soft">{emptyLabel}</p>
|
|
200
|
+
</Show>
|
|
201
|
+
</div>
|
|
202
|
+
</Show>
|
|
203
|
+
</div>
|
|
204
|
+
)
|
|
205
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "multi-combobox",
|
|
3
|
+
"kind": "component",
|
|
4
|
+
"framework": "react",
|
|
5
|
+
"description": "Multi-select with search, chips and a native listbox popup.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"cn",
|
|
8
|
+
"icons-form",
|
|
9
|
+
"select",
|
|
10
|
+
"styles-motion"
|
|
11
|
+
],
|
|
12
|
+
"peers": [
|
|
13
|
+
"@blankways/state",
|
|
14
|
+
"@blankways/state-react@0.1.0-alpha.1",
|
|
15
|
+
"react",
|
|
16
|
+
"lucide-react"
|
|
17
|
+
],
|
|
18
|
+
"suggestions": [
|
|
19
|
+
"styles-tokens",
|
|
20
|
+
"styles-base",
|
|
21
|
+
"styles-components",
|
|
22
|
+
"styles-utilities",
|
|
23
|
+
"styles-motion"
|
|
24
|
+
],
|
|
25
|
+
"files": [
|
|
26
|
+
{
|
|
27
|
+
"source": "MultiCombobox.tsx",
|
|
28
|
+
"target": "components/multi-combobox/MultiCombobox.tsx"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"source": "index.ts",
|
|
32
|
+
"target": "components/multi-combobox/index.ts"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RemoteProvider as BaseRemoteProvider } from '@blankways/remote-react'
|
|
2
|
+
import type { ComponentProps } from 'react'
|
|
3
|
+
|
|
4
|
+
export type RemoteProviderProps = ComponentProps<typeof BaseRemoteProvider>
|
|
5
|
+
|
|
6
|
+
export function RemoteProvider({ children, ...props }: RemoteProviderProps) {
|
|
7
|
+
return <BaseRemoteProvider {...props}>{children}</BaseRemoteProvider>
|
|
8
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "remote-provider",
|
|
3
|
+
"kind": "component",
|
|
4
|
+
"framework": "react",
|
|
5
|
+
"description": "RemoteProvider wrapper and useCall re-export from the published @blankways/remote-react package.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"peers": [
|
|
8
|
+
"@blankways/remote-react@0.1.0-alpha.1",
|
|
9
|
+
"@blankways/remote@0.1.0-alpha.4",
|
|
10
|
+
"@blankways/serial@0.1.0-alpha.fa636be",
|
|
11
|
+
"@blankways/state@0.2.0-alpha.85cba23",
|
|
12
|
+
"react"
|
|
13
|
+
],
|
|
14
|
+
"suggestions": ["styles-tokens", "styles-base"],
|
|
15
|
+
"files": [
|
|
16
|
+
{
|
|
17
|
+
"source": "RemoteProvider.tsx",
|
|
18
|
+
"target": "components/remote-provider/RemoteProvider.tsx"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"source": "index.ts",
|
|
22
|
+
"target": "components/remote-provider/index.ts"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|