@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.
Files changed (216) hide show
  1. package/README.md +228 -2
  2. package/dist/cli/cli.options.d.ts +5 -0
  3. package/dist/cli/cli.options.js +53 -0
  4. package/dist/cli/cli.registry.d.ts +6 -0
  5. package/dist/cli/cli.registry.js +37 -0
  6. package/dist/cli/cli.types.d.ts +32 -0
  7. package/dist/cli/cli.types.js +1 -0
  8. package/dist/cli/index.d.ts +3 -0
  9. package/dist/cli/index.js +3 -0
  10. package/dist/cli.d.ts +2 -0
  11. package/dist/cli.js +47 -0
  12. package/dist/commands/add.command.d.ts +2 -0
  13. package/dist/commands/add.command.js +101 -0
  14. package/dist/commands/doctor.command.d.ts +3 -0
  15. package/dist/commands/doctor.command.js +92 -0
  16. package/dist/commands/index.d.ts +6 -0
  17. package/dist/commands/index.js +6 -0
  18. package/dist/commands/init.command.d.ts +2 -0
  19. package/dist/commands/init.command.js +38 -0
  20. package/dist/commands/list.command.d.ts +2 -0
  21. package/dist/commands/list.command.js +54 -0
  22. package/dist/commands/meta.command.d.ts +1 -0
  23. package/dist/commands/meta.command.js +19 -0
  24. package/dist/commands/styles.command.d.ts +6 -0
  25. package/dist/commands/styles.command.js +68 -0
  26. package/dist/config/config.helpers.d.ts +7 -0
  27. package/dist/config/config.helpers.js +63 -0
  28. package/dist/config/framework.helpers.d.ts +3 -0
  29. package/dist/config/framework.helpers.js +14 -0
  30. package/dist/config/index.d.ts +2 -0
  31. package/dist/config/index.js +2 -0
  32. package/dist/constants/cli.constants.d.ts +9 -0
  33. package/dist/constants/cli.constants.js +15 -0
  34. package/dist/constants/framework.constants.d.ts +3 -0
  35. package/dist/constants/framework.constants.js +2 -0
  36. package/dist/constants/index.d.ts +2 -0
  37. package/dist/constants/index.js +2 -0
  38. package/dist/doctor/checks/entries.check.d.ts +1 -0
  39. package/dist/doctor/checks/entries.check.js +21 -0
  40. package/dist/doctor/checks/icons.check.d.ts +1 -0
  41. package/dist/doctor/checks/icons.check.js +55 -0
  42. package/dist/doctor/checks/imports.check.d.ts +1 -0
  43. package/dist/doctor/checks/imports.check.js +45 -0
  44. package/dist/doctor/checks/index.d.ts +7 -0
  45. package/dist/doctor/checks/index.js +7 -0
  46. package/dist/doctor/checks/motion.check.d.ts +1 -0
  47. package/dist/doctor/checks/motion.check.js +66 -0
  48. package/dist/doctor/checks/peers.check.d.ts +1 -0
  49. package/dist/doctor/checks/peers.check.js +55 -0
  50. package/dist/doctor/checks/styles.check.d.ts +1 -0
  51. package/dist/doctor/checks/styles.check.js +45 -0
  52. package/dist/doctor/checks/themes.check.d.ts +1 -0
  53. package/dist/doctor/checks/themes.check.js +64 -0
  54. package/dist/doctor/doctor.helpers.d.ts +6 -0
  55. package/dist/doctor/doctor.helpers.js +39 -0
  56. package/dist/doctor/doctor.registry.d.ts +10 -0
  57. package/dist/doctor/doctor.registry.js +24 -0
  58. package/dist/doctor/doctor.types.d.ts +27 -0
  59. package/dist/doctor/doctor.types.js +1 -0
  60. package/dist/doctor/index.d.ts +3 -0
  61. package/dist/doctor/index.js +3 -0
  62. package/dist/errors/cli-error.d.ts +3 -0
  63. package/dist/errors/cli-error.js +6 -0
  64. package/dist/errors/index.d.ts +1 -0
  65. package/dist/errors/index.js +1 -0
  66. package/dist/helpers/args.helpers.d.ts +4 -0
  67. package/dist/helpers/args.helpers.js +75 -0
  68. package/dist/helpers/help.helpers.d.ts +1 -0
  69. package/dist/helpers/help.helpers.js +30 -0
  70. package/dist/helpers/index.d.ts +5 -0
  71. package/dist/helpers/index.js +5 -0
  72. package/dist/helpers/package.helpers.d.ts +2 -0
  73. package/dist/helpers/package.helpers.js +12 -0
  74. package/dist/helpers/path.helpers.d.ts +3 -0
  75. package/dist/helpers/path.helpers.js +15 -0
  76. package/dist/helpers/styles.helpers.d.ts +21 -0
  77. package/dist/helpers/styles.helpers.js +164 -0
  78. package/dist/index.d.ts +9 -0
  79. package/dist/index.js +9 -0
  80. package/dist/registry/index.d.ts +1 -0
  81. package/dist/registry/index.js +1 -0
  82. package/dist/registry/registry.helpers.d.ts +22 -0
  83. package/dist/registry/registry.helpers.js +328 -0
  84. package/dist/registry-data/README.md +71 -0
  85. package/dist/registry-data/avatar/Avatar.tsx +64 -0
  86. package/dist/registry-data/avatar/component.json +30 -0
  87. package/dist/registry-data/avatar/index.ts +1 -0
  88. package/dist/registry-data/badge/Badge.tsx +76 -0
  89. package/dist/registry-data/badge/component.json +30 -0
  90. package/dist/registry-data/badge/index.ts +1 -0
  91. package/dist/registry-data/brand-logo/BrandLogo.tsx +24 -0
  92. package/dist/registry-data/brand-logo/component.json +26 -0
  93. package/dist/registry-data/brand-logo/index.ts +1 -0
  94. package/dist/registry-data/button/Button.tsx +76 -0
  95. package/dist/registry-data/button/component.json +33 -0
  96. package/dist/registry-data/button/index.ts +1 -0
  97. package/dist/registry-data/button-link/ButtonLink.tsx +83 -0
  98. package/dist/registry-data/button-link/component.json +33 -0
  99. package/dist/registry-data/button-link/index.ts +5 -0
  100. package/dist/registry-data/button-styles/component.json +19 -0
  101. package/dist/registry-data/button-styles/index.ts +45 -0
  102. package/dist/registry-data/cn/cn.ts +6 -0
  103. package/dist/registry-data/cn/component.json +16 -0
  104. package/dist/registry-data/confirm-dialog/ConfirmDialog.tsx +134 -0
  105. package/dist/registry-data/confirm-dialog/component.json +34 -0
  106. package/dist/registry-data/confirm-dialog/index.ts +1 -0
  107. package/dist/registry-data/container/Container.tsx +22 -0
  108. package/dist/registry-data/container/component.json +28 -0
  109. package/dist/registry-data/container/index.ts +1 -0
  110. package/dist/registry-data/cursor-glow/CursorGlow.tsx +29 -0
  111. package/dist/registry-data/cursor-glow/component.json +28 -0
  112. package/dist/registry-data/cursor-glow/index.ts +1 -0
  113. package/dist/registry-data/dropdown-menu/DropdownMenu.tsx +157 -0
  114. package/dist/registry-data/dropdown-menu/component.json +34 -0
  115. package/dist/registry-data/dropdown-menu/index.ts +5 -0
  116. package/dist/registry-data/empty-state/EmptyState.tsx +92 -0
  117. package/dist/registry-data/empty-state/component.json +30 -0
  118. package/dist/registry-data/empty-state/index.ts +5 -0
  119. package/dist/registry-data/eyebrow/Eyebrow.tsx +68 -0
  120. package/dist/registry-data/eyebrow/component.json +30 -0
  121. package/dist/registry-data/eyebrow/index.ts +1 -0
  122. package/dist/registry-data/field-styles/component.json +19 -0
  123. package/dist/registry-data/field-styles/index.ts +42 -0
  124. package/dist/registry-data/form-dialog/FormDialog.tsx +128 -0
  125. package/dist/registry-data/form-dialog/component.json +34 -0
  126. package/dist/registry-data/form-dialog/index.ts +1 -0
  127. package/dist/registry-data/icons/component.json +22 -0
  128. package/dist/registry-data/icons/index.ts +21 -0
  129. package/dist/registry-data/icons-form/component.json +17 -0
  130. package/dist/registry-data/icons-form/index.ts +1 -0
  131. package/dist/registry-data/icons-sidebar/component.json +17 -0
  132. package/dist/registry-data/icons-sidebar/index.ts +1 -0
  133. package/dist/registry-data/icons-theme/component.json +17 -0
  134. package/dist/registry-data/icons-theme/index.ts +1 -0
  135. package/dist/registry-data/icons-toast/component.json +17 -0
  136. package/dist/registry-data/icons-toast/index.ts +1 -0
  137. package/dist/registry-data/info-dialog/InfoDialog.tsx +119 -0
  138. package/dist/registry-data/info-dialog/component.json +36 -0
  139. package/dist/registry-data/info-dialog/index.ts +1 -0
  140. package/dist/registry-data/input/Input.tsx +96 -0
  141. package/dist/registry-data/input/component.json +33 -0
  142. package/dist/registry-data/input/index.ts +1 -0
  143. package/dist/registry-data/multi-combobox/MultiCombobox.tsx +205 -0
  144. package/dist/registry-data/multi-combobox/component.json +35 -0
  145. package/dist/registry-data/multi-combobox/index.ts +5 -0
  146. package/dist/registry-data/remote-provider/RemoteProvider.tsx +8 -0
  147. package/dist/registry-data/remote-provider/component.json +25 -0
  148. package/dist/registry-data/remote-provider/index.ts +3 -0
  149. package/dist/registry-data/reveal/Reveal.tsx +22 -0
  150. package/dist/registry-data/reveal/component.json +30 -0
  151. package/dist/registry-data/reveal/index.ts +1 -0
  152. package/dist/registry-data/section/Section.tsx +80 -0
  153. package/dist/registry-data/section/component.json +30 -0
  154. package/dist/registry-data/section/index.ts +1 -0
  155. package/dist/registry-data/section-heading/SectionHeading.tsx +105 -0
  156. package/dist/registry-data/section-heading/component.json +32 -0
  157. package/dist/registry-data/section-heading/index.ts +1 -0
  158. package/dist/registry-data/select/Select.tsx +197 -0
  159. package/dist/registry-data/select/component.json +34 -0
  160. package/dist/registry-data/select/index.ts +1 -0
  161. package/dist/registry-data/sidebar/Sidebar.tsx +432 -0
  162. package/dist/registry-data/sidebar/SidebarCollapsible.tsx +77 -0
  163. package/dist/registry-data/sidebar/SidebarParts.tsx +373 -0
  164. package/dist/registry-data/sidebar/component.json +47 -0
  165. package/dist/registry-data/sidebar/index.ts +4 -0
  166. package/dist/registry-data/sidebar/useSidebar.ts +29 -0
  167. package/dist/registry-data/styles-base/component.json +19 -0
  168. package/dist/registry-data/styles-base/index.css +67 -0
  169. package/dist/registry-data/styles-components/component.json +19 -0
  170. package/dist/registry-data/styles-components/index.css +30 -0
  171. package/dist/registry-data/styles-motion/component.json +20 -0
  172. package/dist/registry-data/styles-motion/index.css +381 -0
  173. package/dist/registry-data/styles-tokens/component.json +17 -0
  174. package/dist/registry-data/styles-tokens/index.css +77 -0
  175. package/dist/registry-data/styles-utilities/component.json +19 -0
  176. package/dist/registry-data/styles-utilities/index.css +29 -0
  177. package/dist/registry-data/switch/Switch.tsx +91 -0
  178. package/dist/registry-data/switch/component.json +34 -0
  179. package/dist/registry-data/switch/index.ts +1 -0
  180. package/dist/registry-data/tabs/Tabs.tsx +226 -0
  181. package/dist/registry-data/tabs/component.json +32 -0
  182. package/dist/registry-data/tabs/index.ts +1 -0
  183. package/dist/registry-data/textarea/Textarea.tsx +94 -0
  184. package/dist/registry-data/textarea/component.json +33 -0
  185. package/dist/registry-data/textarea/index.ts +1 -0
  186. package/dist/registry-data/theme-core/component.json +17 -0
  187. package/dist/registry-data/theme-core/theme.ts +84 -0
  188. package/dist/registry-data/theme-dark/component.json +19 -0
  189. package/dist/registry-data/theme-dark/index.ts +7 -0
  190. package/dist/registry-data/theme-light/component.json +19 -0
  191. package/dist/registry-data/theme-light/index.ts +7 -0
  192. package/dist/registry-data/theme-provider/ThemeContext.tsx +177 -0
  193. package/dist/registry-data/theme-provider/component.json +30 -0
  194. package/dist/registry-data/theme-provider/index.ts +2 -0
  195. package/dist/registry-data/theme-selector/ThemeSelector.tsx +269 -0
  196. package/dist/registry-data/theme-selector/component.json +35 -0
  197. package/dist/registry-data/theme-selector/selector.ts +1 -0
  198. package/dist/registry-data/theme-system/component.json +19 -0
  199. package/dist/registry-data/theme-system/index.ts +7 -0
  200. package/dist/registry-data/theme-toggle/ThemeToggle.tsx +71 -0
  201. package/dist/registry-data/theme-toggle/component.json +31 -0
  202. package/dist/registry-data/theme-toggle/toggle.ts +1 -0
  203. package/dist/registry-data/toast/Toast.tsx +260 -0
  204. package/dist/registry-data/toast/ToastTypeIcon.tsx +83 -0
  205. package/dist/registry-data/toast/component.json +43 -0
  206. package/dist/registry-data/toast/index.ts +3 -0
  207. package/dist/registry-data/toast/useToast.ts +47 -0
  208. package/dist/types/cli.types.d.ts +6 -0
  209. package/dist/types/cli.types.js +1 -0
  210. package/dist/types/config.types.d.ts +41 -0
  211. package/dist/types/config.types.js +1 -0
  212. package/dist/types/index.d.ts +3 -0
  213. package/dist/types/index.js +3 -0
  214. package/dist/types/registry.types.d.ts +37 -0
  215. package/dist/types/registry.types.js +1 -0
  216. package/package.json +35 -3
@@ -0,0 +1,76 @@
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
+ })
@@ -0,0 +1,33 @@
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
+ }
@@ -0,0 +1 @@
1
+ export { Button, type ButtonProps } from './Button.js'
@@ -0,0 +1,83 @@
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
+ }
@@ -0,0 +1,33 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ export {
2
+ ButtonLink,
3
+ type ButtonLinkProps,
4
+ type ButtonRouterLink,
5
+ } from './ButtonLink.js'
@@ -0,0 +1,19 @@
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
+ }
@@ -0,0 +1,45 @@
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
+ }
@@ -0,0 +1,6 @@
1
+ export type ClassValue = string | false | null | undefined
2
+
3
+ /** Joins truthy class values into a single className string. */
4
+ export function cn(...values: ClassValue[]): string {
5
+ return values.filter(Boolean).join(' ')
6
+ }
@@ -0,0 +1,16 @@
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
+ }
@@ -0,0 +1,134 @@
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
+ }
@@ -0,0 +1,34 @@
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
+ }
@@ -0,0 +1 @@
1
+ export { ConfirmDialog, type ConfirmDialogProps } from './ConfirmDialog.js'
@@ -0,0 +1,22 @@
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
+ }
@@ -0,0 +1,28 @@
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
+ }
@@ -0,0 +1 @@
1
+ export { Container, type ContainerProps } from './Container.js'
@@ -0,0 +1,29 @@
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
+ }
@@ -0,0 +1,28 @@
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
+ }
@@ -0,0 +1 @@
1
+ export { CursorGlow, type CursorGlowProps } from './CursorGlow.js'