@refraction-ui/astro 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/astro-audience-feature-card/AudienceFeatureCard.astro +53 -0
- package/dist/astro-audience-feature-card/index.ts +1 -0
- package/dist/astro-audio-room/AudioRoom.astro +81 -0
- package/dist/astro-audio-room/index.ts +1 -0
- package/dist/astro-brand-network-cell/BrandNetworkCell.astro +77 -0
- package/dist/astro-brand-network-cell/index.ts +1 -0
- package/dist/astro-browser-chrome-mock/BrowserChromeMock.astro +62 -0
- package/dist/astro-browser-chrome-mock/index.ts +1 -0
- package/dist/astro-call-controls/CallControls.astro +57 -0
- package/dist/astro-call-controls/index.ts +1 -0
- package/dist/astro-checklist/Checklist.astro +76 -0
- package/dist/astro-checklist/index.ts +1 -0
- package/dist/astro-editor-status-bar/EditorStatusBar.astro +92 -0
- package/dist/astro-editor-status-bar/index.ts +1 -0
- package/dist/astro-editor-tabs/EditorTabs.astro +74 -0
- package/dist/astro-editor-tabs/index.ts +1 -0
- package/dist/astro-floating-reactions/FloatingReactions.astro +56 -0
- package/dist/astro-floating-reactions/index.ts +1 -0
- package/dist/astro-flow-editor/FlowEditor.astro +99 -0
- package/dist/astro-flow-editor/index.ts +3 -0
- package/dist/astro-graph-view/GraphView.astro +109 -0
- package/dist/astro-graph-view/index.ts +1 -0
- package/dist/astro-infinite-canvas/InfiniteCanvas.astro +43 -0
- package/dist/astro-infinite-canvas/index.ts +1 -0
- package/dist/astro-live-captions/LiveCaptions.astro +54 -0
- package/dist/astro-live-captions/index.ts +1 -0
- package/dist/astro-live-cursors/LiveCursors.astro +55 -0
- package/dist/astro-live-cursors/index.ts +1 -0
- package/dist/astro-live-transcript/LiveTranscript.astro +55 -0
- package/dist/astro-live-transcript/index.ts +1 -0
- package/dist/astro-marquee-strip/MarqueeStrip.astro +63 -0
- package/dist/astro-marquee-strip/index.ts +1 -0
- package/dist/astro-mastery-bar/MasteryBar.astro +56 -0
- package/dist/astro-mastery-bar/index.ts +1 -0
- package/dist/astro-mini-map/MiniMap.astro +74 -0
- package/dist/astro-mini-map/index.ts +1 -0
- package/dist/astro-numbered-steps/NumberedSteps.astro +47 -0
- package/dist/astro-numbered-steps/index.ts +1 -0
- package/dist/astro-pre-call-lobby/PreCallLobby.astro +202 -0
- package/dist/astro-pre-call-lobby/index.ts +1 -0
- package/dist/astro-pricing-card/PricingCard.astro +114 -0
- package/dist/astro-pricing-card/index.ts +1 -0
- package/dist/astro-radial-gauge/RadialGauge.astro +144 -0
- package/dist/astro-radial-gauge/index.ts +1 -0
- package/dist/astro-rating-scale/RatingScale.astro +73 -0
- package/dist/astro-rating-scale/index.ts +1 -0
- package/dist/astro-section-head/SectionHead.astro +44 -0
- package/dist/astro-section-head/index.ts +1 -0
- package/dist/astro-stat-grid/StatGrid.astro +46 -0
- package/dist/astro-stat-grid/index.ts +1 -0
- package/dist/astro-sticky-note/StickyNote.astro +55 -0
- package/dist/astro-sticky-note/index.ts +1 -0
- package/dist/astro-terminal/Terminal.astro +67 -0
- package/dist/astro-terminal/index.ts +1 -0
- package/dist/astro-test-results/TestResults.astro +76 -0
- package/dist/astro-test-results/index.ts +1 -0
- package/dist/astro-timeline/Timeline.astro +59 -0
- package/dist/astro-timeline/index.ts +1 -0
- package/dist/astro-video-grid/VideoGrid.astro +182 -0
- package/dist/astro-video-grid/index.ts +1 -0
- package/dist/astro-video-tile/VideoTile.astro +104 -0
- package/dist/astro-video-tile/index.ts +1 -0
- package/dist/astro-wizard/Wizard.astro +137 -0
- package/dist/astro-wizard/index.ts +1 -0
- package/dist/audience-feature-card/audience-feature-card.styles.ts +23 -0
- package/dist/audience-feature-card/audience-feature-card.ts +39 -0
- package/dist/audience-feature-card/index.ts +13 -0
- package/dist/audio-room/audio-room.styles.ts +88 -0
- package/dist/audio-room/audio-room.ts +70 -0
- package/dist/audio-room/index.ts +16 -0
- package/dist/brand-network-cell/brand-network-cell.styles.ts +46 -0
- package/dist/brand-network-cell/brand-network-cell.ts +35 -0
- package/dist/brand-network-cell/index.ts +14 -0
- package/dist/browser-chrome-mock/browser-chrome-mock.styles.ts +43 -0
- package/dist/browser-chrome-mock/browser-chrome-mock.ts +52 -0
- package/dist/browser-chrome-mock/index.ts +17 -0
- package/dist/call-controls/call-controls.styles.ts +63 -0
- package/dist/call-controls/call-controls.ts +79 -0
- package/dist/call-controls/index.ts +15 -0
- package/dist/checklist/checklist.styles.ts +76 -0
- package/dist/checklist/checklist.ts +62 -0
- package/dist/checklist/index.ts +18 -0
- package/dist/editor-status-bar/editor-status-bar.styles.ts +40 -0
- package/dist/editor-status-bar/editor-status-bar.ts +78 -0
- package/dist/editor-status-bar/index.ts +15 -0
- package/dist/editor-tabs/editor-tabs.styles.ts +52 -0
- package/dist/editor-tabs/editor-tabs.ts +82 -0
- package/dist/editor-tabs/index.ts +15 -0
- package/dist/floating-reactions/floating-reactions.styles.ts +54 -0
- package/dist/floating-reactions/floating-reactions.ts +85 -0
- package/dist/floating-reactions/index.ts +14 -0
- package/dist/flow-editor/flow-editor.styles.ts +56 -0
- package/dist/flow-editor/flow-editor.ts +126 -0
- package/dist/flow-editor/index.ts +18 -0
- package/dist/graph-view/graph-view.styles.ts +66 -0
- package/dist/graph-view/graph-view.ts +130 -0
- package/dist/graph-view/index.ts +21 -0
- package/dist/index.ts +32 -0
- package/dist/infinite-canvas/index.ts +17 -0
- package/dist/infinite-canvas/infinite-canvas.styles.ts +49 -0
- package/dist/infinite-canvas/infinite-canvas.ts +97 -0
- package/dist/live-captions/index.ts +13 -0
- package/dist/live-captions/live-captions.styles.ts +45 -0
- package/dist/live-captions/live-captions.ts +57 -0
- package/dist/live-cursors/index.ts +14 -0
- package/dist/live-cursors/live-cursors.styles.ts +41 -0
- package/dist/live-cursors/live-cursors.ts +73 -0
- package/dist/live-transcript/index.ts +16 -0
- package/dist/live-transcript/live-transcript.styles.ts +48 -0
- package/dist/live-transcript/live-transcript.ts +82 -0
- package/dist/marquee-strip/index.ts +14 -0
- package/dist/marquee-strip/marquee-strip.styles.ts +61 -0
- package/dist/marquee-strip/marquee-strip.ts +35 -0
- package/dist/mastery-bar/index.ts +15 -0
- package/dist/mastery-bar/mastery-bar.styles.ts +45 -0
- package/dist/mastery-bar/mastery-bar.ts +55 -0
- package/dist/mini-map/index.ts +16 -0
- package/dist/mini-map/mini-map.styles.ts +32 -0
- package/dist/mini-map/mini-map.ts +122 -0
- package/dist/numbered-steps/index.ts +16 -0
- package/dist/numbered-steps/numbered-steps.styles.ts +36 -0
- package/dist/numbered-steps/numbered-steps.ts +64 -0
- package/dist/pre-call-lobby/index.ts +22 -0
- package/dist/pre-call-lobby/pre-call-lobby.styles.ts +108 -0
- package/dist/pre-call-lobby/pre-call-lobby.ts +61 -0
- package/dist/pricing-card/index.ts +19 -0
- package/dist/pricing-card/pricing-card.styles.ts +71 -0
- package/dist/pricing-card/pricing-card.ts +37 -0
- package/dist/radial-gauge/index.ts +26 -0
- package/dist/radial-gauge/radial-gauge.styles.ts +75 -0
- package/dist/radial-gauge/radial-gauge.ts +183 -0
- package/dist/rating-scale/index.ts +16 -0
- package/dist/rating-scale/rating-scale.styles.ts +48 -0
- package/dist/rating-scale/rating-scale.ts +101 -0
- package/dist/section-head/index.ts +13 -0
- package/dist/section-head/section-head.styles.ts +30 -0
- package/dist/section-head/section-head.ts +28 -0
- package/dist/stat-grid/index.ts +13 -0
- package/dist/stat-grid/stat-grid.styles.ts +25 -0
- package/dist/stat-grid/stat-grid.ts +41 -0
- package/dist/sticky-note/index.ts +14 -0
- package/dist/sticky-note/sticky-note.styles.ts +37 -0
- package/dist/sticky-note/sticky-note.ts +47 -0
- package/dist/terminal/index.ts +13 -0
- package/dist/terminal/terminal.styles.ts +56 -0
- package/dist/terminal/terminal.ts +60 -0
- package/dist/test-results/index.ts +19 -0
- package/dist/test-results/test-results.styles.ts +93 -0
- package/dist/test-results/test-results.ts +83 -0
- package/dist/timeline/index.ts +22 -0
- package/dist/timeline/timeline.styles.ts +98 -0
- package/dist/timeline/timeline.ts +86 -0
- package/dist/video-grid/index.ts +16 -0
- package/dist/video-grid/video-grid.styles.ts +38 -0
- package/dist/video-grid/video-grid.ts +93 -0
- package/dist/video-tile/index.ts +17 -0
- package/dist/video-tile/video-tile.styles.ts +59 -0
- package/dist/video-tile/video-tile.ts +74 -0
- package/dist/wizard/index.ts +28 -0
- package/dist/wizard/wizard.styles.ts +147 -0
- package/dist/wizard/wizard.ts +128 -0
- package/package.json +33 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** Microphone state for a video participant. */
|
|
2
|
+
export type VideoTileMicState = 'on' | 'muted'
|
|
3
|
+
|
|
4
|
+
/** Data describing a video meeting participant tile. */
|
|
5
|
+
export interface VideoTileData {
|
|
6
|
+
/** Unique participant identifier. */
|
|
7
|
+
id: string
|
|
8
|
+
/** Display name shown in the name chip. */
|
|
9
|
+
name: string
|
|
10
|
+
/** Current microphone state. Defaults to 'on'. */
|
|
11
|
+
micState?: VideoTileMicState
|
|
12
|
+
/** Whether the participant is currently speaking (active audio). */
|
|
13
|
+
speaking?: boolean
|
|
14
|
+
/** Whether the tile is pinned in the grid. */
|
|
15
|
+
pinned?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface VideoTileHeadlessProps {
|
|
19
|
+
/** Whether the participant is actively speaking. */
|
|
20
|
+
speaking?: boolean
|
|
21
|
+
/** Whether the tile is pinned in the grid. */
|
|
22
|
+
pinned?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface VideoTileAPI {
|
|
26
|
+
/** Data attributes for styling hooks — spread onto the tile container. */
|
|
27
|
+
dataAttributes: {
|
|
28
|
+
'data-speaking': string
|
|
29
|
+
'data-pinned': string
|
|
30
|
+
}
|
|
31
|
+
/** ARIA props — spread onto the tile container. */
|
|
32
|
+
ariaProps: {
|
|
33
|
+
role: 'group'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Derive framework-agnostic data attributes and ARIA props for a VideoTile.
|
|
39
|
+
*
|
|
40
|
+
* Adapters spread `dataAttributes` and `ariaProps` onto the tile container so
|
|
41
|
+
* CSS selectors and assistive technology can reflect the current participant
|
|
42
|
+
* state without coupling to a specific framework.
|
|
43
|
+
*/
|
|
44
|
+
export function createVideoTile(props: VideoTileHeadlessProps = {}): VideoTileAPI {
|
|
45
|
+
const { speaking = false, pinned = false } = props
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
dataAttributes: {
|
|
49
|
+
'data-speaking': speaking ? 'true' : 'false',
|
|
50
|
+
'data-pinned': pinned ? 'true' : 'false',
|
|
51
|
+
},
|
|
52
|
+
ariaProps: {
|
|
53
|
+
role: 'group',
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Derive up to two uppercase initials from a display name.
|
|
60
|
+
*
|
|
61
|
+
* Splits on whitespace and takes the first character of the first two words.
|
|
62
|
+
* Single-word names produce a single initial.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* getInitials('Maya Goldberg') // 'MG'
|
|
66
|
+
* getInitials('Alice') // 'A'
|
|
67
|
+
*/
|
|
68
|
+
export function getInitials(name: string): string {
|
|
69
|
+
const words = name.trim().split(/\s+/).filter(Boolean)
|
|
70
|
+
return words
|
|
71
|
+
.slice(0, 2)
|
|
72
|
+
.map((w) => w[0].toUpperCase())
|
|
73
|
+
.join('')
|
|
74
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export {
|
|
2
|
+
createWizard,
|
|
3
|
+
getStepState,
|
|
4
|
+
getNextIndex,
|
|
5
|
+
getPrevIndex,
|
|
6
|
+
canAdvance,
|
|
7
|
+
wizardProgress,
|
|
8
|
+
type WizardStep,
|
|
9
|
+
type WizardStepStatus,
|
|
10
|
+
type WizardStepState,
|
|
11
|
+
type WizardOrientation,
|
|
12
|
+
type WizardProps,
|
|
13
|
+
type WizardAPI,
|
|
14
|
+
} from './wizard.js'
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
wizardVariants,
|
|
18
|
+
wizardRailVariants,
|
|
19
|
+
wizardStepItemVariants,
|
|
20
|
+
wizardStepIndicatorVariants,
|
|
21
|
+
wizardStepLabelVariants,
|
|
22
|
+
wizardStepOptionalClass,
|
|
23
|
+
wizardConnectorVariants,
|
|
24
|
+
wizardContentClass,
|
|
25
|
+
wizardFooterClass,
|
|
26
|
+
wizardPrimaryButtonVariants,
|
|
27
|
+
wizardSecondaryButtonVariants,
|
|
28
|
+
} from './wizard.styles.js'
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { cva } from '../shared/index.ts'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Root container that holds the step rail and the content/footer area
|
|
5
|
+
* side-by-side (vertical) or stacked (horizontal).
|
|
6
|
+
*/
|
|
7
|
+
export const wizardVariants = cva({
|
|
8
|
+
base: 'flex gap-8',
|
|
9
|
+
variants: {
|
|
10
|
+
orientation: {
|
|
11
|
+
vertical: 'flex-row',
|
|
12
|
+
horizontal: 'flex-col',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: {
|
|
16
|
+
orientation: 'vertical',
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The step rail — the ordered list of step indicators.
|
|
22
|
+
* Vertical: a narrow column on the left. Horizontal: a row across the top.
|
|
23
|
+
*/
|
|
24
|
+
export const wizardRailVariants = cva({
|
|
25
|
+
base: 'flex shrink-0',
|
|
26
|
+
variants: {
|
|
27
|
+
orientation: {
|
|
28
|
+
vertical: 'flex-col gap-0',
|
|
29
|
+
horizontal: 'flex-row items-center gap-0',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
orientation: 'vertical',
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A single step item in the rail. The `status` variant drives colour so
|
|
39
|
+
* adapters never inline these classes.
|
|
40
|
+
*/
|
|
41
|
+
export const wizardStepItemVariants = cva({
|
|
42
|
+
base: 'flex items-center gap-3 relative',
|
|
43
|
+
variants: {
|
|
44
|
+
orientation: {
|
|
45
|
+
vertical: 'flex-row',
|
|
46
|
+
horizontal: 'flex-col',
|
|
47
|
+
},
|
|
48
|
+
status: {
|
|
49
|
+
complete: '',
|
|
50
|
+
current: '',
|
|
51
|
+
upcoming: '',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
defaultVariants: {
|
|
55
|
+
orientation: 'vertical',
|
|
56
|
+
status: 'upcoming',
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The circular step indicator (the number/check badge on the rail).
|
|
62
|
+
* `status` variant applies the appropriate background and text treatment.
|
|
63
|
+
*/
|
|
64
|
+
export const wizardStepIndicatorVariants = cva({
|
|
65
|
+
base: [
|
|
66
|
+
'relative z-10 flex size-8 shrink-0 items-center justify-center',
|
|
67
|
+
'rounded-full border-2 text-xs font-semibold transition-colors',
|
|
68
|
+
].join(' '),
|
|
69
|
+
variants: {
|
|
70
|
+
status: {
|
|
71
|
+
complete: 'border-primary bg-primary text-primary-foreground',
|
|
72
|
+
current: 'border-primary bg-background text-primary',
|
|
73
|
+
upcoming: 'border-border bg-background text-muted-foreground',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
defaultVariants: {
|
|
77
|
+
status: 'upcoming',
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
/** The label text next to / below the step indicator. */
|
|
82
|
+
export const wizardStepLabelVariants = cva({
|
|
83
|
+
base: 'text-sm font-medium transition-colors',
|
|
84
|
+
variants: {
|
|
85
|
+
status: {
|
|
86
|
+
complete: 'text-foreground',
|
|
87
|
+
current: 'text-foreground',
|
|
88
|
+
upcoming: 'text-muted-foreground',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
defaultVariants: {
|
|
92
|
+
status: 'upcoming',
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
/** "(Optional)" sub-label shown beneath the step label. */
|
|
97
|
+
export const wizardStepOptionalClass = 'text-xs text-muted-foreground'
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The connector line drawn between two adjacent step indicators.
|
|
101
|
+
* Positioned absolutely so the indicator sits on top of it.
|
|
102
|
+
*/
|
|
103
|
+
export const wizardConnectorVariants = cva({
|
|
104
|
+
base: 'shrink-0 transition-colors',
|
|
105
|
+
variants: {
|
|
106
|
+
orientation: {
|
|
107
|
+
vertical: 'mx-4 w-0.5 flex-1 min-h-[1.5rem]',
|
|
108
|
+
horizontal: 'my-4 h-0.5 flex-1 min-w-[1.5rem]',
|
|
109
|
+
},
|
|
110
|
+
complete: {
|
|
111
|
+
true: 'bg-primary',
|
|
112
|
+
false: 'bg-border',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
defaultVariants: {
|
|
116
|
+
orientation: 'vertical',
|
|
117
|
+
complete: 'false',
|
|
118
|
+
},
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
/** The main content area to the right (vertical) or below (horizontal) the rail. */
|
|
122
|
+
export const wizardContentClass = 'flex min-w-0 flex-1 flex-col'
|
|
123
|
+
|
|
124
|
+
/** Footer row that holds the Back / Skip / Next-or-Complete buttons. */
|
|
125
|
+
export const wizardFooterClass = 'mt-6 flex items-center gap-3'
|
|
126
|
+
|
|
127
|
+
/** The primary action button (Next / Complete). */
|
|
128
|
+
export const wizardPrimaryButtonVariants = cva({
|
|
129
|
+
base: [
|
|
130
|
+
'inline-flex items-center justify-center rounded-md px-4 py-2 text-sm font-medium',
|
|
131
|
+
'bg-primary text-primary-foreground transition-colors',
|
|
132
|
+
'hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2',
|
|
133
|
+
'focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
134
|
+
'disabled:pointer-events-none disabled:opacity-50',
|
|
135
|
+
].join(' '),
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
/** The secondary action button (Back / Skip). */
|
|
139
|
+
export const wizardSecondaryButtonVariants = cva({
|
|
140
|
+
base: [
|
|
141
|
+
'inline-flex items-center justify-center rounded-md px-4 py-2 text-sm font-medium',
|
|
142
|
+
'border border-input bg-background text-foreground transition-colors',
|
|
143
|
+
'hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2',
|
|
144
|
+
'focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
145
|
+
'disabled:pointer-events-none disabled:opacity-50',
|
|
146
|
+
].join(' '),
|
|
147
|
+
})
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { AccessibilityProps } from '../shared/index.ts'
|
|
2
|
+
|
|
3
|
+
/** A single step in a wizard flow. */
|
|
4
|
+
export interface WizardStep {
|
|
5
|
+
/** Unique identifier for the step. */
|
|
6
|
+
id: string
|
|
7
|
+
/** Human-readable label shown in the step rail. */
|
|
8
|
+
label: string
|
|
9
|
+
/** When true the user may skip this step. */
|
|
10
|
+
optional?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The resolved status of a step relative to the current position. */
|
|
14
|
+
export type WizardStepStatus = 'complete' | 'current' | 'upcoming'
|
|
15
|
+
|
|
16
|
+
/** A step enriched with its resolved status and position. */
|
|
17
|
+
export interface WizardStepState {
|
|
18
|
+
step: WizardStep
|
|
19
|
+
status: WizardStepStatus
|
|
20
|
+
index: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Orientation of the step rail. */
|
|
24
|
+
export type WizardOrientation = 'vertical' | 'horizontal'
|
|
25
|
+
|
|
26
|
+
export interface WizardProps {
|
|
27
|
+
/** Controlled current step index (0-based). */
|
|
28
|
+
currentIndex?: number
|
|
29
|
+
/** Total number of steps. */
|
|
30
|
+
count?: number
|
|
31
|
+
/** Orientation of the step rail. */
|
|
32
|
+
orientation?: WizardOrientation
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface WizardAPI {
|
|
36
|
+
/** ARIA attributes to spread on the root element. */
|
|
37
|
+
ariaProps: Partial<AccessibilityProps>
|
|
38
|
+
/** Data attributes for styling hooks. */
|
|
39
|
+
dataAttributes: Record<string, string>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Derive the status of every step from the current position.
|
|
44
|
+
*
|
|
45
|
+
* Steps before `currentIndex` are `'complete'`, the step at `currentIndex` is
|
|
46
|
+
* `'current'`, and every step after is `'upcoming'`.
|
|
47
|
+
*/
|
|
48
|
+
export function getStepState(
|
|
49
|
+
steps: WizardStep[],
|
|
50
|
+
currentIndex: number,
|
|
51
|
+
): WizardStepState[] {
|
|
52
|
+
return steps.map((step, index) => {
|
|
53
|
+
let status: WizardStepStatus
|
|
54
|
+
if (index < currentIndex) {
|
|
55
|
+
status = 'complete'
|
|
56
|
+
} else if (index === currentIndex) {
|
|
57
|
+
status = 'current'
|
|
58
|
+
} else {
|
|
59
|
+
status = 'upcoming'
|
|
60
|
+
}
|
|
61
|
+
return { step, status, index }
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Returns the next step index, clamped to the last step so the wizard never
|
|
67
|
+
* advances past the final step.
|
|
68
|
+
*/
|
|
69
|
+
export function getNextIndex(currentIndex: number, count: number): number {
|
|
70
|
+
if (count <= 0) return currentIndex
|
|
71
|
+
return Math.min(currentIndex + 1, count - 1)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Returns the previous step index, clamped to 0 so the wizard never goes
|
|
76
|
+
* behind the first step.
|
|
77
|
+
*/
|
|
78
|
+
export function getPrevIndex(currentIndex: number): number {
|
|
79
|
+
return Math.max(currentIndex - 1, 0)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Whether the wizard can advance from `currentIndex`.
|
|
84
|
+
*
|
|
85
|
+
* Returns `false` when already on the last step.
|
|
86
|
+
*/
|
|
87
|
+
export function canAdvance(currentIndex: number, count: number): boolean {
|
|
88
|
+
if (count <= 0) return false
|
|
89
|
+
return currentIndex < count - 1
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Fractional progress through the wizard (0 when on step 0, 1 when the final
|
|
94
|
+
* step is complete). Returns 0 for empty wizards.
|
|
95
|
+
*
|
|
96
|
+
* `wizardProgress(0, 4)` → 0 (just started)
|
|
97
|
+
* `wizardProgress(3, 4)` → 0.75
|
|
98
|
+
* `wizardProgress(4, 4)` → 1 (done)
|
|
99
|
+
*/
|
|
100
|
+
export function wizardProgress(currentIndex: number, count: number): number {
|
|
101
|
+
if (count <= 0) return 0
|
|
102
|
+
return Math.min(currentIndex / count, 1)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Build the framework-agnostic root props for a wizard component.
|
|
107
|
+
*
|
|
108
|
+
* Returns `role="group"` plus `data-step` / `data-orientation` attributes so
|
|
109
|
+
* adapters can spread them onto their container without duplicating logic.
|
|
110
|
+
*/
|
|
111
|
+
export function createWizard(props: WizardProps = {}): WizardAPI {
|
|
112
|
+
const { currentIndex = 0, count = 0, orientation = 'vertical' } = props
|
|
113
|
+
|
|
114
|
+
const ariaProps: Partial<AccessibilityProps> = {
|
|
115
|
+
role: 'group',
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const dataAttributes: Record<string, string> = {
|
|
119
|
+
'data-step': String(currentIndex),
|
|
120
|
+
'data-orientation': orientation,
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (count > 0) {
|
|
124
|
+
dataAttributes['data-count'] = String(count)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return { ariaProps, dataAttributes }
|
|
128
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refraction-ui/astro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "All Refraction UI Astro components in one package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -25,20 +25,26 @@
|
|
|
25
25
|
"@refraction-ui/astro-analytics": "workspace:*",
|
|
26
26
|
"@refraction-ui/astro-animated-text": "workspace:*",
|
|
27
27
|
"@refraction-ui/astro-app-shell": "workspace:*",
|
|
28
|
+
"@refraction-ui/astro-audience-feature-card": "workspace:*",
|
|
29
|
+
"@refraction-ui/astro-audio-room": "workspace:*",
|
|
28
30
|
"@refraction-ui/astro-auth": "workspace:*",
|
|
29
31
|
"@refraction-ui/astro-avatar": "workspace:*",
|
|
30
32
|
"@refraction-ui/astro-avatar-group": "workspace:*",
|
|
31
33
|
"@refraction-ui/astro-badge": "workspace:*",
|
|
32
34
|
"@refraction-ui/astro-bottom-nav": "workspace:*",
|
|
35
|
+
"@refraction-ui/astro-brand-network-cell": "workspace:*",
|
|
33
36
|
"@refraction-ui/astro-breadcrumbs": "workspace:*",
|
|
37
|
+
"@refraction-ui/astro-browser-chrome-mock": "workspace:*",
|
|
34
38
|
"@refraction-ui/astro-button": "workspace:*",
|
|
35
39
|
"@refraction-ui/astro-calendar": "workspace:*",
|
|
40
|
+
"@refraction-ui/astro-call-controls": "workspace:*",
|
|
36
41
|
"@refraction-ui/astro-callout": "workspace:*",
|
|
37
42
|
"@refraction-ui/astro-card": "workspace:*",
|
|
38
43
|
"@refraction-ui/astro-card-grid": "workspace:*",
|
|
39
44
|
"@refraction-ui/astro-carousel": "workspace:*",
|
|
40
45
|
"@refraction-ui/astro-charts": "workspace:*",
|
|
41
46
|
"@refraction-ui/astro-checkbox": "workspace:*",
|
|
47
|
+
"@refraction-ui/astro-checklist": "workspace:*",
|
|
42
48
|
"@refraction-ui/astro-code-block": "workspace:*",
|
|
43
49
|
"@refraction-ui/astro-code-editor": "workspace:*",
|
|
44
50
|
"@refraction-ui/astro-collapsible": "workspace:*",
|
|
@@ -53,13 +59,19 @@
|
|
|
53
59
|
"@refraction-ui/astro-dialog": "workspace:*",
|
|
54
60
|
"@refraction-ui/astro-diff-viewer": "workspace:*",
|
|
55
61
|
"@refraction-ui/astro-dropdown-menu": "workspace:*",
|
|
62
|
+
"@refraction-ui/astro-editor-status-bar": "workspace:*",
|
|
63
|
+
"@refraction-ui/astro-editor-tabs": "workspace:*",
|
|
56
64
|
"@refraction-ui/astro-emoji-picker": "workspace:*",
|
|
57
65
|
"@refraction-ui/astro-empty-state": "workspace:*",
|
|
58
66
|
"@refraction-ui/astro-feedback-dialog": "workspace:*",
|
|
59
67
|
"@refraction-ui/astro-file-tree": "workspace:*",
|
|
60
68
|
"@refraction-ui/astro-file-upload": "workspace:*",
|
|
69
|
+
"@refraction-ui/astro-floating-reactions": "workspace:*",
|
|
70
|
+
"@refraction-ui/astro-flow-editor": "workspace:*",
|
|
61
71
|
"@refraction-ui/astro-footer": "workspace:*",
|
|
72
|
+
"@refraction-ui/astro-graph-view": "workspace:*",
|
|
62
73
|
"@refraction-ui/astro-icon-system": "workspace:*",
|
|
74
|
+
"@refraction-ui/astro-infinite-canvas": "workspace:*",
|
|
63
75
|
"@refraction-ui/astro-inline-editor": "workspace:*",
|
|
64
76
|
"@refraction-ui/astro-input": "workspace:*",
|
|
65
77
|
"@refraction-ui/astro-input-group": "workspace:*",
|
|
@@ -67,22 +79,34 @@
|
|
|
67
79
|
"@refraction-ui/astro-keyboard-shortcut": "workspace:*",
|
|
68
80
|
"@refraction-ui/astro-language-selector": "workspace:*",
|
|
69
81
|
"@refraction-ui/astro-link-card": "workspace:*",
|
|
82
|
+
"@refraction-ui/astro-live-captions": "workspace:*",
|
|
83
|
+
"@refraction-ui/astro-live-cursors": "workspace:*",
|
|
84
|
+
"@refraction-ui/astro-live-transcript": "workspace:*",
|
|
70
85
|
"@refraction-ui/astro-logger": "workspace:*",
|
|
71
86
|
"@refraction-ui/astro-markdown-renderer": "workspace:*",
|
|
87
|
+
"@refraction-ui/astro-marquee-strip": "workspace:*",
|
|
88
|
+
"@refraction-ui/astro-mastery-bar": "workspace:*",
|
|
89
|
+
"@refraction-ui/astro-mini-map": "workspace:*",
|
|
72
90
|
"@refraction-ui/astro-mobile-nav": "workspace:*",
|
|
73
91
|
"@refraction-ui/astro-navbar": "workspace:*",
|
|
92
|
+
"@refraction-ui/astro-numbered-steps": "workspace:*",
|
|
74
93
|
"@refraction-ui/astro-otp-input": "workspace:*",
|
|
75
94
|
"@refraction-ui/astro-pagination": "workspace:*",
|
|
76
95
|
"@refraction-ui/astro-password-input": "workspace:*",
|
|
77
96
|
"@refraction-ui/astro-payment": "workspace:*",
|
|
78
97
|
"@refraction-ui/astro-popover": "workspace:*",
|
|
98
|
+
"@refraction-ui/astro-pre-call-lobby": "workspace:*",
|
|
79
99
|
"@refraction-ui/astro-presence-indicator": "workspace:*",
|
|
100
|
+
"@refraction-ui/astro-pricing-card": "workspace:*",
|
|
80
101
|
"@refraction-ui/astro-progress-display": "workspace:*",
|
|
102
|
+
"@refraction-ui/astro-radial-gauge": "workspace:*",
|
|
81
103
|
"@refraction-ui/astro-radio": "workspace:*",
|
|
104
|
+
"@refraction-ui/astro-rating-scale": "workspace:*",
|
|
82
105
|
"@refraction-ui/astro-reaction-bar": "workspace:*",
|
|
83
106
|
"@refraction-ui/astro-resizable-layout": "workspace:*",
|
|
84
107
|
"@refraction-ui/astro-rich-editor": "workspace:*",
|
|
85
108
|
"@refraction-ui/astro-search-bar": "workspace:*",
|
|
109
|
+
"@refraction-ui/astro-section-head": "workspace:*",
|
|
86
110
|
"@refraction-ui/astro-segmented-control": "workspace:*",
|
|
87
111
|
"@refraction-ui/astro-select": "workspace:*",
|
|
88
112
|
"@refraction-ui/astro-separator": "workspace:*",
|
|
@@ -92,20 +116,28 @@
|
|
|
92
116
|
"@refraction-ui/astro-slide-viewer": "workspace:*",
|
|
93
117
|
"@refraction-ui/astro-slider": "workspace:*",
|
|
94
118
|
"@refraction-ui/astro-social-auth-button": "workspace:*",
|
|
119
|
+
"@refraction-ui/astro-stat-grid": "workspace:*",
|
|
95
120
|
"@refraction-ui/astro-status-indicator": "workspace:*",
|
|
96
121
|
"@refraction-ui/astro-steps": "workspace:*",
|
|
122
|
+
"@refraction-ui/astro-sticky-note": "workspace:*",
|
|
97
123
|
"@refraction-ui/astro-switch": "workspace:*",
|
|
98
124
|
"@refraction-ui/astro-table-of-contents": "workspace:*",
|
|
99
125
|
"@refraction-ui/astro-tabs": "workspace:*",
|
|
126
|
+
"@refraction-ui/astro-terminal": "workspace:*",
|
|
127
|
+
"@refraction-ui/astro-test-results": "workspace:*",
|
|
100
128
|
"@refraction-ui/astro-textarea": "workspace:*",
|
|
101
129
|
"@refraction-ui/astro-theme": "workspace:*",
|
|
102
130
|
"@refraction-ui/astro-thread-view": "workspace:*",
|
|
131
|
+
"@refraction-ui/astro-timeline": "workspace:*",
|
|
103
132
|
"@refraction-ui/astro-toast": "workspace:*",
|
|
104
133
|
"@refraction-ui/astro-tooltip": "workspace:*",
|
|
105
134
|
"@refraction-ui/astro-version-selector": "workspace:*",
|
|
135
|
+
"@refraction-ui/astro-video-grid": "workspace:*",
|
|
106
136
|
"@refraction-ui/astro-video-player": "workspace:*",
|
|
137
|
+
"@refraction-ui/astro-video-tile": "workspace:*",
|
|
107
138
|
"@refraction-ui/astro-voice-pill": "workspace:*",
|
|
108
139
|
"@refraction-ui/astro-waveform": "workspace:*",
|
|
140
|
+
"@refraction-ui/astro-wizard": "workspace:*",
|
|
109
141
|
"@refraction-ui/shared": "workspace:*"
|
|
110
142
|
},
|
|
111
143
|
"publishConfig": {
|