@blankways/ui 0.1.0-alpha.1 → 0.2.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 +157 -139
- package/dist/cli/cli.options.js +21 -1
- package/dist/cli/cli.types.d.ts +1 -0
- package/dist/cli.js +2 -1
- package/dist/commands/add.command.d.ts +2 -0
- package/dist/commands/add.command.js +30 -82
- package/dist/commands/dev.command.d.ts +3 -0
- package/dist/commands/dev.command.js +76 -0
- package/dist/commands/doctor.command.js +12 -1
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +3 -0
- package/dist/commands/init.command.js +15 -10
- package/dist/commands/install.command.d.ts +2 -0
- package/dist/commands/install.command.js +36 -0
- package/dist/commands/list.command.js +10 -5
- package/dist/commands/registry.command.d.ts +2 -0
- package/dist/commands/registry.command.js +69 -0
- package/dist/commands/styles.command.d.ts +1 -2
- package/dist/commands/styles.command.js +15 -39
- package/dist/config/config.helpers.d.ts +4 -1
- package/dist/config/config.helpers.js +61 -8
- package/dist/constants/cli.constants.d.ts +14 -3
- package/dist/constants/cli.constants.js +14 -9
- package/dist/doctor/checks/barrels.check.d.ts +1 -0
- package/dist/doctor/checks/barrels.check.js +60 -0
- package/dist/doctor/checks/contracts.check.d.ts +1 -0
- package/dist/doctor/checks/contracts.check.js +45 -0
- package/dist/doctor/checks/icons.check.js +8 -3
- package/dist/doctor/checks/index.d.ts +3 -0
- package/dist/doctor/checks/index.js +3 -0
- package/dist/doctor/checks/motion.check.js +2 -2
- package/dist/doctor/checks/namespaces.check.d.ts +1 -0
- package/dist/doctor/checks/namespaces.check.js +76 -0
- package/dist/doctor/checks/themes.check.js +18 -40
- package/dist/doctor/doctor.helpers.js +5 -1
- package/dist/doctor/doctor.types.d.ts +4 -0
- package/dist/helpers/args.helpers.d.ts +2 -0
- package/dist/helpers/args.helpers.js +9 -0
- package/dist/helpers/barrels.helpers.d.ts +15 -0
- package/dist/helpers/barrels.helpers.js +157 -0
- package/dist/index.d.ts +12 -9
- package/dist/index.js +11 -9
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.js +2 -0
- package/dist/registry/lockfile.d.ts +18 -0
- package/dist/registry/lockfile.js +32 -0
- package/dist/registry/registry.helpers.d.ts +3 -13
- package/dist/registry/registry.helpers.js +30 -116
- package/dist/registry/registry.providers.d.ts +13 -0
- package/dist/registry/registry.providers.js +159 -0
- package/dist/registry/registry.service.d.ts +14 -0
- package/dist/registry/registry.service.js +126 -0
- package/dist/types/config.types.d.ts +29 -0
- package/dist/types/registry.types.d.ts +31 -0
- package/dist/types/registry.types.js +2 -0
- package/dist/ui-api/index.d.ts +16 -0
- package/dist/ui-api/index.js +30 -0
- package/dist/ui-api/ui-api.d.ts +18 -0
- package/dist/ui-api/ui-api.js +194 -0
- package/package.json +7 -5
- package/styles.css +16 -0
- package/dist/registry-data/README.md +0 -71
- package/dist/registry-data/avatar/Avatar.tsx +0 -64
- package/dist/registry-data/avatar/component.json +0 -30
- package/dist/registry-data/avatar/index.ts +0 -1
- package/dist/registry-data/badge/Badge.tsx +0 -76
- package/dist/registry-data/badge/component.json +0 -30
- package/dist/registry-data/badge/index.ts +0 -1
- package/dist/registry-data/brand-logo/BrandLogo.tsx +0 -24
- package/dist/registry-data/brand-logo/component.json +0 -26
- package/dist/registry-data/brand-logo/index.ts +0 -1
- package/dist/registry-data/button/Button.tsx +0 -76
- package/dist/registry-data/button/component.json +0 -33
- package/dist/registry-data/button/index.ts +0 -1
- package/dist/registry-data/button-link/ButtonLink.tsx +0 -83
- package/dist/registry-data/button-link/component.json +0 -33
- package/dist/registry-data/button-link/index.ts +0 -5
- package/dist/registry-data/button-styles/component.json +0 -19
- package/dist/registry-data/button-styles/index.ts +0 -45
- package/dist/registry-data/cn/cn.ts +0 -6
- package/dist/registry-data/cn/component.json +0 -16
- package/dist/registry-data/confirm-dialog/ConfirmDialog.tsx +0 -134
- package/dist/registry-data/confirm-dialog/component.json +0 -34
- package/dist/registry-data/confirm-dialog/index.ts +0 -1
- package/dist/registry-data/container/Container.tsx +0 -22
- package/dist/registry-data/container/component.json +0 -28
- package/dist/registry-data/container/index.ts +0 -1
- package/dist/registry-data/cursor-glow/CursorGlow.tsx +0 -29
- package/dist/registry-data/cursor-glow/component.json +0 -28
- package/dist/registry-data/cursor-glow/index.ts +0 -1
- package/dist/registry-data/dropdown-menu/DropdownMenu.tsx +0 -157
- package/dist/registry-data/dropdown-menu/component.json +0 -34
- package/dist/registry-data/dropdown-menu/index.ts +0 -5
- package/dist/registry-data/empty-state/EmptyState.tsx +0 -92
- package/dist/registry-data/empty-state/component.json +0 -30
- package/dist/registry-data/empty-state/index.ts +0 -5
- package/dist/registry-data/eyebrow/Eyebrow.tsx +0 -68
- package/dist/registry-data/eyebrow/component.json +0 -30
- package/dist/registry-data/eyebrow/index.ts +0 -1
- package/dist/registry-data/field-styles/component.json +0 -19
- package/dist/registry-data/field-styles/index.ts +0 -42
- package/dist/registry-data/form-dialog/FormDialog.tsx +0 -128
- package/dist/registry-data/form-dialog/component.json +0 -34
- package/dist/registry-data/form-dialog/index.ts +0 -1
- package/dist/registry-data/icons/component.json +0 -22
- package/dist/registry-data/icons/index.ts +0 -21
- package/dist/registry-data/icons-form/component.json +0 -17
- package/dist/registry-data/icons-form/index.ts +0 -1
- package/dist/registry-data/icons-sidebar/component.json +0 -17
- package/dist/registry-data/icons-sidebar/index.ts +0 -1
- package/dist/registry-data/icons-theme/component.json +0 -17
- package/dist/registry-data/icons-theme/index.ts +0 -1
- package/dist/registry-data/icons-toast/component.json +0 -17
- package/dist/registry-data/icons-toast/index.ts +0 -1
- package/dist/registry-data/info-dialog/InfoDialog.tsx +0 -119
- package/dist/registry-data/info-dialog/component.json +0 -36
- package/dist/registry-data/info-dialog/index.ts +0 -1
- package/dist/registry-data/input/Input.tsx +0 -96
- package/dist/registry-data/input/component.json +0 -33
- package/dist/registry-data/input/index.ts +0 -1
- package/dist/registry-data/multi-combobox/MultiCombobox.tsx +0 -205
- package/dist/registry-data/multi-combobox/component.json +0 -35
- package/dist/registry-data/multi-combobox/index.ts +0 -5
- package/dist/registry-data/remote-provider/RemoteProvider.tsx +0 -8
- package/dist/registry-data/remote-provider/component.json +0 -25
- package/dist/registry-data/remote-provider/index.ts +0 -3
- package/dist/registry-data/reveal/Reveal.tsx +0 -22
- package/dist/registry-data/reveal/component.json +0 -30
- package/dist/registry-data/reveal/index.ts +0 -1
- package/dist/registry-data/section/Section.tsx +0 -80
- package/dist/registry-data/section/component.json +0 -30
- package/dist/registry-data/section/index.ts +0 -1
- package/dist/registry-data/section-heading/SectionHeading.tsx +0 -105
- package/dist/registry-data/section-heading/component.json +0 -32
- package/dist/registry-data/section-heading/index.ts +0 -1
- package/dist/registry-data/select/Select.tsx +0 -197
- package/dist/registry-data/select/component.json +0 -34
- package/dist/registry-data/select/index.ts +0 -1
- package/dist/registry-data/sidebar/Sidebar.tsx +0 -432
- package/dist/registry-data/sidebar/SidebarCollapsible.tsx +0 -77
- package/dist/registry-data/sidebar/SidebarParts.tsx +0 -373
- package/dist/registry-data/sidebar/component.json +0 -47
- package/dist/registry-data/sidebar/index.ts +0 -4
- package/dist/registry-data/sidebar/useSidebar.ts +0 -29
- package/dist/registry-data/styles-base/component.json +0 -19
- package/dist/registry-data/styles-base/index.css +0 -67
- package/dist/registry-data/styles-components/component.json +0 -19
- package/dist/registry-data/styles-components/index.css +0 -30
- package/dist/registry-data/styles-motion/component.json +0 -20
- package/dist/registry-data/styles-motion/index.css +0 -381
- package/dist/registry-data/styles-tokens/component.json +0 -17
- package/dist/registry-data/styles-tokens/index.css +0 -77
- package/dist/registry-data/styles-utilities/component.json +0 -19
- package/dist/registry-data/styles-utilities/index.css +0 -29
- package/dist/registry-data/switch/Switch.tsx +0 -91
- package/dist/registry-data/switch/component.json +0 -34
- package/dist/registry-data/switch/index.ts +0 -1
- package/dist/registry-data/tabs/Tabs.tsx +0 -226
- package/dist/registry-data/tabs/component.json +0 -32
- package/dist/registry-data/tabs/index.ts +0 -1
- package/dist/registry-data/textarea/Textarea.tsx +0 -94
- package/dist/registry-data/textarea/component.json +0 -33
- package/dist/registry-data/textarea/index.ts +0 -1
- package/dist/registry-data/theme-core/component.json +0 -17
- package/dist/registry-data/theme-core/theme.ts +0 -84
- package/dist/registry-data/theme-dark/component.json +0 -19
- package/dist/registry-data/theme-dark/index.ts +0 -7
- package/dist/registry-data/theme-light/component.json +0 -19
- package/dist/registry-data/theme-light/index.ts +0 -7
- package/dist/registry-data/theme-provider/ThemeContext.tsx +0 -177
- package/dist/registry-data/theme-provider/component.json +0 -30
- package/dist/registry-data/theme-provider/index.ts +0 -2
- package/dist/registry-data/theme-selector/ThemeSelector.tsx +0 -269
- package/dist/registry-data/theme-selector/component.json +0 -35
- package/dist/registry-data/theme-selector/selector.ts +0 -1
- package/dist/registry-data/theme-system/component.json +0 -19
- package/dist/registry-data/theme-system/index.ts +0 -7
- package/dist/registry-data/theme-toggle/ThemeToggle.tsx +0 -71
- package/dist/registry-data/theme-toggle/component.json +0 -31
- package/dist/registry-data/theme-toggle/toggle.ts +0 -1
- package/dist/registry-data/toast/Toast.tsx +0 -260
- package/dist/registry-data/toast/ToastTypeIcon.tsx +0 -83
- package/dist/registry-data/toast/component.json +0 -43
- package/dist/registry-data/toast/index.ts +0 -3
- package/dist/registry-data/toast/useToast.ts +0 -47
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type BrandLogoProps = {
|
|
2
|
-
className?: string
|
|
3
|
-
/** Accessible name; omit it for a decorative, hidden logo. */
|
|
4
|
-
title?: string
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/** Official Bisnes symbol: SVG only, no wordmark. Inherits the current text color. */
|
|
8
|
-
export function BrandLogo({ className, title }: BrandLogoProps) {
|
|
9
|
-
return (
|
|
10
|
-
<svg
|
|
11
|
-
viewBox="0 0 240 244"
|
|
12
|
-
focusable="false"
|
|
13
|
-
role={title ? 'img' : undefined}
|
|
14
|
-
aria-hidden={title ? undefined : true}
|
|
15
|
-
className={['h-8 w-auto fill-current text-brand-500', className]
|
|
16
|
-
.filter(Boolean)
|
|
17
|
-
.join(' ')}
|
|
18
|
-
>
|
|
19
|
-
{title ? <title>{title}</title> : null}
|
|
20
|
-
<path d="M33 40H52C75 40 93 59 93 83V214C59 205 33 179 33 150Z" />
|
|
21
|
-
<path d="M104 96H148C178 96 201 123 201 155C201 188 178 215 145 215H100V181C100 168 108 160 121 160H157C163 160 168 157 168 154C165 151 160 149 154 149H104Z" />
|
|
22
|
-
</svg>
|
|
23
|
-
)
|
|
24
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "brand-logo",
|
|
3
|
-
"kind": "component",
|
|
4
|
-
"framework": "react",
|
|
5
|
-
"description": "Native SVG brand symbol with an optional accessible title.",
|
|
6
|
-
"dependencies": [],
|
|
7
|
-
"peers": [
|
|
8
|
-
"react"
|
|
9
|
-
],
|
|
10
|
-
"suggestions": [
|
|
11
|
-
"styles-tokens",
|
|
12
|
-
"styles-base",
|
|
13
|
-
"styles-components",
|
|
14
|
-
"styles-utilities"
|
|
15
|
-
],
|
|
16
|
-
"files": [
|
|
17
|
-
{
|
|
18
|
-
"source": "BrandLogo.tsx",
|
|
19
|
-
"target": "components/brand-logo/BrandLogo.tsx"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"source": "index.ts",
|
|
23
|
-
"target": "components/brand-logo/index.ts"
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { BrandLogo, type BrandLogoProps } from './BrandLogo.js'
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { forwardRef, useCallback, useEffect, useMemo, useRef } from 'react'
|
|
2
|
-
import type { 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 { buttonStyles, type ButtonSize, type ButtonVariant } from '../../styles/button-styles.js'
|
|
7
|
-
|
|
8
|
-
export type ButtonProps = ComponentPropsWithoutRef<'button'> & {
|
|
9
|
-
variant?: ButtonVariant
|
|
10
|
-
size?: ButtonSize
|
|
11
|
-
/** Marks the button busy and prevents interaction. */
|
|
12
|
-
loading?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function useSyncedState<Type>(value: Type): StateId<Type> {
|
|
16
|
-
const state = useState(value)
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (!Object.is(State.get(state), value)) State.set(state, value)
|
|
19
|
-
}, [state, value])
|
|
20
|
-
return state
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Native button with the shared button recipes and reactive data attributes. */
|
|
24
|
-
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
|
|
25
|
-
{
|
|
26
|
-
variant = 'primary',
|
|
27
|
-
size = 'md',
|
|
28
|
-
loading = false,
|
|
29
|
-
disabled = false,
|
|
30
|
-
className,
|
|
31
|
-
children,
|
|
32
|
-
type = 'button',
|
|
33
|
-
...rest
|
|
34
|
-
},
|
|
35
|
-
forwardedRef,
|
|
36
|
-
) {
|
|
37
|
-
const variantState = useSyncedState(variant)
|
|
38
|
-
const sizeState = useSyncedState(size)
|
|
39
|
-
const busyState = useSyncedState(loading)
|
|
40
|
-
const disabledState = useSyncedState(disabled || loading)
|
|
41
|
-
const ref = useRef<HTMLButtonElement | null>(null)
|
|
42
|
-
const attributes = useMemo<ReactiveAttributes<HTMLButtonElement>>(
|
|
43
|
-
() => ({
|
|
44
|
-
'data-variant': variantState,
|
|
45
|
-
'data-size': sizeState,
|
|
46
|
-
'aria-busy': busyState,
|
|
47
|
-
disabled: disabledState,
|
|
48
|
-
}),
|
|
49
|
-
[variantState, sizeState, busyState, disabledState],
|
|
50
|
-
)
|
|
51
|
-
useAttributes(ref, attributes)
|
|
52
|
-
|
|
53
|
-
const setRef = useCallback(
|
|
54
|
-
(element: HTMLButtonElement | null) => {
|
|
55
|
-
ref.current = element
|
|
56
|
-
if (typeof forwardedRef === 'function') forwardedRef(element)
|
|
57
|
-
else if (forwardedRef) {
|
|
58
|
-
;(forwardedRef as { current: HTMLButtonElement | null }).current = element
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
[forwardedRef],
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<button
|
|
66
|
-
{...rest}
|
|
67
|
-
ref={setRef}
|
|
68
|
-
type={type}
|
|
69
|
-
disabled={disabled || loading}
|
|
70
|
-
aria-busy={loading || undefined}
|
|
71
|
-
className={cn(buttonStyles({ variant, size }), className)}
|
|
72
|
-
>
|
|
73
|
-
{children}
|
|
74
|
-
</button>
|
|
75
|
-
)
|
|
76
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "button",
|
|
3
|
-
"kind": "component",
|
|
4
|
-
"framework": "react",
|
|
5
|
-
"description": "Native button with shared variants, sizes and reactive attributes.",
|
|
6
|
-
"dependencies": [
|
|
7
|
-
"cn",
|
|
8
|
-
"button-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": "Button.tsx",
|
|
26
|
-
"target": "components/button/Button.tsx"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"source": "index.ts",
|
|
30
|
-
"target": "components/button/index.ts"
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Button, type ButtonProps } from './Button.js'
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo } from 'react'
|
|
2
|
-
import type { ComponentPropsWithoutRef, ElementType } 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 { buttonStyles, type ButtonSize, type ButtonVariant } from '../../styles/button-styles.js'
|
|
7
|
-
|
|
8
|
-
/** An in-app link component supplied by the consumer's router. */
|
|
9
|
-
export type ButtonRouterLink = ElementType<any>
|
|
10
|
-
|
|
11
|
-
export type ButtonLinkProps = Omit<ComponentPropsWithoutRef<'a'>, 'ref'> & {
|
|
12
|
-
variant?: ButtonVariant
|
|
13
|
-
size?: ButtonSize
|
|
14
|
-
loading?: boolean
|
|
15
|
-
/** Router destination; requires `linkComponent`. */
|
|
16
|
-
to?: string
|
|
17
|
-
/** Router link used for `to`, so this entry never depends on a router. */
|
|
18
|
-
linkComponent?: ButtonRouterLink
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function useSyncedState<Type>(value: Type): StateId<Type> {
|
|
22
|
-
const state = useState(value)
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (!Object.is(State.get(state), value)) State.set(state, value)
|
|
25
|
-
}, [state, value])
|
|
26
|
-
return state
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** A navigation element styled like `Button`, with an optional router link. */
|
|
30
|
-
export function ButtonLink({
|
|
31
|
-
variant = 'primary',
|
|
32
|
-
size = 'md',
|
|
33
|
-
loading = false,
|
|
34
|
-
to,
|
|
35
|
-
href,
|
|
36
|
-
linkComponent: LinkComponent,
|
|
37
|
-
className,
|
|
38
|
-
children,
|
|
39
|
-
...rest
|
|
40
|
-
}: ButtonLinkProps) {
|
|
41
|
-
const variantState = useSyncedState(variant)
|
|
42
|
-
const sizeState = useSyncedState(size)
|
|
43
|
-
const busyState = useSyncedState(loading)
|
|
44
|
-
const bind = useAttributes<HTMLAnchorElement>(
|
|
45
|
-
useMemo<ReactiveAttributes<HTMLAnchorElement>>(
|
|
46
|
-
() => ({
|
|
47
|
-
'data-variant': variantState,
|
|
48
|
-
'data-size': sizeState,
|
|
49
|
-
'aria-busy': busyState,
|
|
50
|
-
}),
|
|
51
|
-
[variantState, sizeState, busyState],
|
|
52
|
-
),
|
|
53
|
-
)
|
|
54
|
-
const classes = cn(buttonStyles({ variant, size }), className)
|
|
55
|
-
const external = typeof href === 'string' && /^https?:\/\//.test(href)
|
|
56
|
-
|
|
57
|
-
if (LinkComponent && to !== undefined) {
|
|
58
|
-
return (
|
|
59
|
-
<LinkComponent
|
|
60
|
-
{...rest}
|
|
61
|
-
ref={bind}
|
|
62
|
-
to={to}
|
|
63
|
-
className={classes}
|
|
64
|
-
aria-busy={loading || undefined}
|
|
65
|
-
>
|
|
66
|
-
{children}
|
|
67
|
-
</LinkComponent>
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<a
|
|
73
|
-
{...rest}
|
|
74
|
-
ref={bind}
|
|
75
|
-
href={href}
|
|
76
|
-
className={classes}
|
|
77
|
-
aria-busy={loading || undefined}
|
|
78
|
-
{...(external ? { target: '_blank', rel: 'noreferrer noopener' } : {})}
|
|
79
|
-
>
|
|
80
|
-
{children}
|
|
81
|
-
</a>
|
|
82
|
-
)
|
|
83
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "button-link",
|
|
3
|
-
"kind": "component",
|
|
4
|
-
"framework": "react",
|
|
5
|
-
"description": "Link styled like Button, with optional router link component.",
|
|
6
|
-
"dependencies": [
|
|
7
|
-
"cn",
|
|
8
|
-
"button-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": "ButtonLink.tsx",
|
|
26
|
-
"target": "components/button-link/ButtonLink.tsx"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"source": "index.ts",
|
|
30
|
-
"target": "components/button-link/index.ts"
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "button-styles",
|
|
3
|
-
"kind": "utility",
|
|
4
|
-
"framework": "react",
|
|
5
|
-
"description": "Tailwind class recipes for button variants and sizes.",
|
|
6
|
-
"dependencies": [
|
|
7
|
-
"cn"
|
|
8
|
-
],
|
|
9
|
-
"peers": [
|
|
10
|
-
"react"
|
|
11
|
-
],
|
|
12
|
-
"suggestions": [],
|
|
13
|
-
"files": [
|
|
14
|
-
{
|
|
15
|
-
"source": "index.ts",
|
|
16
|
-
"target": "styles/button-styles.ts"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { cn } from '../internals/cn.js'
|
|
2
|
-
|
|
3
|
-
export type ButtonVariant =
|
|
4
|
-
| 'primary'
|
|
5
|
-
| 'secondary'
|
|
6
|
-
| 'ghost'
|
|
7
|
-
| 'outline'
|
|
8
|
-
| 'danger'
|
|
9
|
-
|
|
10
|
-
export type ButtonSize = 'sm' | 'md' | 'lg'
|
|
11
|
-
|
|
12
|
-
const variantClasses: Record<ButtonVariant, string> = {
|
|
13
|
-
primary:
|
|
14
|
-
'bg-brand-500 text-on-contrast shadow-[0_10px_30px_-14px_color-mix(in_srgb,var(--color-brand-500)_80%,transparent)] hover:bg-brand-400',
|
|
15
|
-
secondary:
|
|
16
|
-
'border border-line bg-paper text-ink hover:border-line-strong hover:bg-surface',
|
|
17
|
-
ghost: 'text-ink hover:bg-surface-2',
|
|
18
|
-
outline:
|
|
19
|
-
'border border-line-strong bg-transparent text-ink hover:border-ink/40 hover:bg-surface',
|
|
20
|
-
danger: 'bg-accent text-on-contrast hover:bg-accent/90',
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const sizeClasses: Record<ButtonSize, string> = {
|
|
24
|
-
sm: 'h-10 px-3 text-sm',
|
|
25
|
-
md: 'h-12 px-[1.125rem] text-sm',
|
|
26
|
-
lg: 'h-14 px-[1.3125rem] text-base',
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Builds a complete button className from a variant, size and extras. */
|
|
30
|
-
export function buttonStyles({
|
|
31
|
-
variant = 'primary',
|
|
32
|
-
size = 'md',
|
|
33
|
-
className,
|
|
34
|
-
}: {
|
|
35
|
-
variant?: ButtonVariant
|
|
36
|
-
size?: ButtonSize
|
|
37
|
-
className?: string
|
|
38
|
-
} = {}): string {
|
|
39
|
-
return cn(
|
|
40
|
-
'motion-press motion-ripple inline-flex items-center justify-center gap-2 rounded-2xl font-semibold whitespace-nowrap disabled:pointer-events-none disabled:opacity-60',
|
|
41
|
-
variantClasses[variant],
|
|
42
|
-
sizeClasses[size],
|
|
43
|
-
className,
|
|
44
|
-
)
|
|
45
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cn",
|
|
3
|
-
"kind": "utility",
|
|
4
|
-
"framework": "react",
|
|
5
|
-
"hidden": true,
|
|
6
|
-
"description": "Internal className helper installed automatically with components.",
|
|
7
|
-
"dependencies": [],
|
|
8
|
-
"peers": [],
|
|
9
|
-
"suggestions": [],
|
|
10
|
-
"files": [
|
|
11
|
-
{
|
|
12
|
-
"source": "cn.ts",
|
|
13
|
-
"target": "internals/cn.ts"
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { cloneElement, useEffect, useMemo, useRef } from 'react'
|
|
2
|
-
import { useState as useReactState } from 'react'
|
|
3
|
-
import type { MouseEvent, ReactElement } from 'react'
|
|
4
|
-
import { createPortal } from 'react-dom'
|
|
5
|
-
import { State, type StateId } from '@blankways/state'
|
|
6
|
-
import {
|
|
7
|
-
Show,
|
|
8
|
-
Text,
|
|
9
|
-
useAttributes,
|
|
10
|
-
useCompute,
|
|
11
|
-
useState,
|
|
12
|
-
type ReactiveAttributes,
|
|
13
|
-
} from '@blankways/state-react'
|
|
14
|
-
import { cn } from '../../internals/cn.js'
|
|
15
|
-
import { Button } from '../button/index.js'
|
|
16
|
-
|
|
17
|
-
export type ConfirmDialogProps = {
|
|
18
|
-
/** The element that opens the dialog. */
|
|
19
|
-
trigger: ReactElement<{ onClick?: (event: MouseEvent<HTMLElement>) => void }>
|
|
20
|
-
title: string
|
|
21
|
-
description: string
|
|
22
|
-
confirmLabel: string
|
|
23
|
-
cancelLabel: string
|
|
24
|
-
onConfirm: () => void
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function useSyncedState<Type>(value: Type): StateId<Type> {
|
|
28
|
-
const state = useState(value)
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (!Object.is(State.get(state), value)) State.set(state, value)
|
|
31
|
-
}, [state, value])
|
|
32
|
-
return state
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Asks before a consequential action, using a native portal and alertdialog role. */
|
|
36
|
-
export function ConfirmDialog({
|
|
37
|
-
trigger,
|
|
38
|
-
title,
|
|
39
|
-
description,
|
|
40
|
-
confirmLabel,
|
|
41
|
-
cancelLabel,
|
|
42
|
-
onConfirm,
|
|
43
|
-
}: ConfirmDialogProps) {
|
|
44
|
-
const titleState = useSyncedState(title)
|
|
45
|
-
const descriptionState = useSyncedState(description)
|
|
46
|
-
const openState = useState(false)
|
|
47
|
-
const [open, setOpen] = useReactState(false)
|
|
48
|
-
const modalState = useState('true')
|
|
49
|
-
const stateName = useCompute([openState] as const, ([isOpen]) =>
|
|
50
|
-
isOpen ? 'open' : 'closed',
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
const panelRef = useRef<HTMLDivElement | null>(null)
|
|
54
|
-
const attributes = useMemo<ReactiveAttributes<HTMLDivElement>>(
|
|
55
|
-
() => ({ 'aria-modal': modalState, 'data-state': stateName }),
|
|
56
|
-
[modalState, stateName],
|
|
57
|
-
)
|
|
58
|
-
useAttributes(panelRef, attributes)
|
|
59
|
-
|
|
60
|
-
const setOpenValue = (next: boolean) => {
|
|
61
|
-
State.set(openState, next)
|
|
62
|
-
setOpen(next)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
if (!open) return
|
|
67
|
-
const onKeyDown = (event: KeyboardEvent) => {
|
|
68
|
-
if (event.key === 'Escape') setOpenValue(false)
|
|
69
|
-
}
|
|
70
|
-
document.addEventListener('keydown', onKeyDown)
|
|
71
|
-
panelRef.current?.focus()
|
|
72
|
-
return () => document.removeEventListener('keydown', onKeyDown)
|
|
73
|
-
}, [open])
|
|
74
|
-
|
|
75
|
-
const triggerNode = cloneElement(trigger, {
|
|
76
|
-
onClick: (event: MouseEvent<HTMLElement>) => {
|
|
77
|
-
trigger.props.onClick?.(event)
|
|
78
|
-
setOpenValue(true)
|
|
79
|
-
},
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
if (typeof document === 'undefined') return triggerNode
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<>
|
|
86
|
-
{triggerNode}
|
|
87
|
-
{createPortal(
|
|
88
|
-
<>
|
|
89
|
-
<Show when={openState}>
|
|
90
|
-
<div
|
|
91
|
-
data-state="open"
|
|
92
|
-
className="backdrop-enter fixed inset-0 z-50 bg-black/50 backdrop-blur-[2px]"
|
|
93
|
-
onClick={() => setOpenValue(false)}
|
|
94
|
-
/>
|
|
95
|
-
</Show>
|
|
96
|
-
<Show when={openState}>
|
|
97
|
-
<div
|
|
98
|
-
ref={panelRef}
|
|
99
|
-
role="alertdialog"
|
|
100
|
-
tabIndex={-1}
|
|
101
|
-
className={cn(
|
|
102
|
-
'surface-enter fixed top-1/2 left-1/2 z-50 flex w-[calc(100%-2rem)] max-w-md -translate-x-1/2 -translate-y-1/2 flex-col gap-6 rounded-2xl border border-line bg-paper p-[1.125rem] shadow-2xl outline-none',
|
|
103
|
-
)}
|
|
104
|
-
>
|
|
105
|
-
<div className="flex flex-col gap-2">
|
|
106
|
-
<h2 className="text-lg font-semibold tracking-[-0.01em] text-ink">
|
|
107
|
-
<Text as="span" value={titleState} />
|
|
108
|
-
</h2>
|
|
109
|
-
<p className="text-sm leading-relaxed text-ink-soft">
|
|
110
|
-
<Text as="span" value={descriptionState} />
|
|
111
|
-
</p>
|
|
112
|
-
</div>
|
|
113
|
-
<div className="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
|
|
114
|
-
<Button variant="secondary" type="button" onClick={() => setOpenValue(false)}>
|
|
115
|
-
{cancelLabel}
|
|
116
|
-
</Button>
|
|
117
|
-
<Button
|
|
118
|
-
type="button"
|
|
119
|
-
onClick={() => {
|
|
120
|
-
onConfirm()
|
|
121
|
-
setOpenValue(false)
|
|
122
|
-
}}
|
|
123
|
-
>
|
|
124
|
-
{confirmLabel}
|
|
125
|
-
</Button>
|
|
126
|
-
</div>
|
|
127
|
-
</div>
|
|
128
|
-
</Show>
|
|
129
|
-
</>,
|
|
130
|
-
document.body,
|
|
131
|
-
)}
|
|
132
|
-
</>
|
|
133
|
-
)
|
|
134
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "confirm-dialog",
|
|
3
|
-
"kind": "component",
|
|
4
|
-
"framework": "react",
|
|
5
|
-
"description": "Native portal alertdialog that asks before a consequential action.",
|
|
6
|
-
"dependencies": [
|
|
7
|
-
"cn",
|
|
8
|
-
"button",
|
|
9
|
-
"styles-motion"
|
|
10
|
-
],
|
|
11
|
-
"peers": [
|
|
12
|
-
"@blankways/state",
|
|
13
|
-
"@blankways/state-react@0.1.0-alpha.1",
|
|
14
|
-
"react",
|
|
15
|
-
"react-dom"
|
|
16
|
-
],
|
|
17
|
-
"suggestions": [
|
|
18
|
-
"styles-tokens",
|
|
19
|
-
"styles-base",
|
|
20
|
-
"styles-components",
|
|
21
|
-
"styles-utilities",
|
|
22
|
-
"styles-motion"
|
|
23
|
-
],
|
|
24
|
-
"files": [
|
|
25
|
-
{
|
|
26
|
-
"source": "ConfirmDialog.tsx",
|
|
27
|
-
"target": "components/confirm-dialog/ConfirmDialog.tsx"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"source": "index.ts",
|
|
31
|
-
"target": "components/confirm-dialog/index.ts"
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ConfirmDialog, type ConfirmDialogProps } from './ConfirmDialog.js'
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ElementType, HTMLAttributes, ReactNode } from 'react'
|
|
2
|
-
import { cn } from '../../internals/cn.js'
|
|
3
|
-
|
|
4
|
-
export type ContainerProps = Omit<HTMLAttributes<HTMLElement>, 'children' | 'className'> & {
|
|
5
|
-
as?: ElementType
|
|
6
|
-
children?: ReactNode
|
|
7
|
-
className?: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/** Page-width wrapper; `as` swaps the rendered element without changing styles. */
|
|
11
|
-
export function Container({
|
|
12
|
-
as: Component = 'div',
|
|
13
|
-
className,
|
|
14
|
-
children,
|
|
15
|
-
...props
|
|
16
|
-
}: ContainerProps) {
|
|
17
|
-
return (
|
|
18
|
-
<Component className={cn('container-page', className)} {...props}>
|
|
19
|
-
{children}
|
|
20
|
-
</Component>
|
|
21
|
-
)
|
|
22
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "container",
|
|
3
|
-
"kind": "component",
|
|
4
|
-
"framework": "react",
|
|
5
|
-
"description": "Centered page container with an optional element override.",
|
|
6
|
-
"dependencies": [
|
|
7
|
-
"cn"
|
|
8
|
-
],
|
|
9
|
-
"peers": [
|
|
10
|
-
"react"
|
|
11
|
-
],
|
|
12
|
-
"suggestions": [
|
|
13
|
-
"styles-tokens",
|
|
14
|
-
"styles-base",
|
|
15
|
-
"styles-components",
|
|
16
|
-
"styles-utilities"
|
|
17
|
-
],
|
|
18
|
-
"files": [
|
|
19
|
-
{
|
|
20
|
-
"source": "Container.tsx",
|
|
21
|
-
"target": "components/container/Container.tsx"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"source": "index.ts",
|
|
25
|
-
"target": "components/container/index.ts"
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Container, type ContainerProps } from './Container.js'
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { cn } from '../../internals/cn.js'
|
|
2
|
-
|
|
3
|
-
const SIZE = 544
|
|
4
|
-
/** Resting position as a share of the host, from the original component. */
|
|
5
|
-
const REST_X = 0.78
|
|
6
|
-
const REST_Y = 0.22
|
|
7
|
-
|
|
8
|
-
export type CursorGlowProps = {
|
|
9
|
-
className?: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/** Decorative glow pinned at its resting spot; the host should be relative and clipped. */
|
|
13
|
-
export function CursorGlow({ className }: CursorGlowProps) {
|
|
14
|
-
return (
|
|
15
|
-
<div
|
|
16
|
-
aria-hidden="true"
|
|
17
|
-
className={cn(
|
|
18
|
-
'pointer-events-none absolute -translate-x-1/2 -translate-y-1/2 rounded-full bg-[radial-gradient(circle_at_center,rgb(115_115_115/0.22),transparent_65%)] opacity-100 blur-2xl motion-fade-slow',
|
|
19
|
-
className,
|
|
20
|
-
)}
|
|
21
|
-
style={{
|
|
22
|
-
width: SIZE,
|
|
23
|
-
height: SIZE,
|
|
24
|
-
left: `${REST_X * 100}%`,
|
|
25
|
-
top: `${REST_Y * 100}%`,
|
|
26
|
-
}}
|
|
27
|
-
/>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cursor-glow",
|
|
3
|
-
"kind": "component",
|
|
4
|
-
"framework": "react",
|
|
5
|
-
"description": "Static decorative glow resting at the original pointer-start position.",
|
|
6
|
-
"dependencies": [
|
|
7
|
-
"cn"
|
|
8
|
-
],
|
|
9
|
-
"peers": [
|
|
10
|
-
"react"
|
|
11
|
-
],
|
|
12
|
-
"suggestions": [
|
|
13
|
-
"styles-tokens",
|
|
14
|
-
"styles-base",
|
|
15
|
-
"styles-components",
|
|
16
|
-
"styles-utilities"
|
|
17
|
-
],
|
|
18
|
-
"files": [
|
|
19
|
-
{
|
|
20
|
-
"source": "CursorGlow.tsx",
|
|
21
|
-
"target": "components/cursor-glow/CursorGlow.tsx"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"source": "index.ts",
|
|
25
|
-
"target": "components/cursor-glow/index.ts"
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CursorGlow, type CursorGlowProps } from './CursorGlow.js'
|