@refraction-ui/astro 0.11.1 → 0.13.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-audio-room/AudioRoom.astro +81 -0
- package/dist/astro-audio-room/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-empty-state/EmptyState.astro +57 -0
- package/dist/astro-empty-state/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-input/Input.astro +5 -1
- 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-mini-map/MiniMap.astro +74 -0
- package/dist/astro-mini-map/index.ts +1 -0
- package/dist/astro-password-input/PasswordInput.astro +102 -0
- package/dist/astro-password-input/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-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-segmented-control/SegmentedControl.astro +106 -0
- package/dist/astro-segmented-control/SegmentedControlItem.astro +32 -0
- package/dist/astro-segmented-control/index.ts +1 -0
- package/dist/astro-separator/Separator.astro +49 -0
- package/dist/astro-separator/index.ts +1 -0
- package/dist/astro-social-auth-button/SocialAuthButton.astro +110 -0
- package/dist/astro-social-auth-button/SocialAuthRow.astro +13 -0
- package/dist/astro-social-auth-button/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/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/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/empty-state/empty-state.styles.ts +42 -0
- package/dist/empty-state/empty-state.ts +27 -0
- package/dist/empty-state/index.ts +14 -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 +45 -17
- 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/input/index.ts +2 -0
- package/dist/input/input.styles.ts +4 -0
- package/dist/input/input.ts +39 -3
- 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/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/password-input/index.ts +9 -0
- package/dist/password-input/password-input.styles.ts +10 -0
- package/dist/password-input/password-input.ts +45 -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/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/segmented-control/index.ts +13 -0
- package/dist/segmented-control/segmented-control.styles.ts +42 -0
- package/dist/segmented-control/segmented-control.ts +80 -0
- package/dist/separator/index.ts +12 -0
- package/dist/separator/separator.styles.ts +34 -0
- package/dist/separator/separator.ts +53 -0
- package/dist/social-auth-button/index.ts +14 -0
- package/dist/social-auth-button/social-auth-button.styles.ts +16 -0
- package/dist/social-auth-button/social-auth-button.ts +51 -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 +47 -19
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
---
|
|
2
|
+
import {
|
|
3
|
+
createPreCallLobby,
|
|
4
|
+
micLevelToBars,
|
|
5
|
+
preCallLobbyVariants,
|
|
6
|
+
preCallCameraVariants,
|
|
7
|
+
preCallCameraPlaceholderClass,
|
|
8
|
+
preCallDeviceRowClass,
|
|
9
|
+
preCallDeviceLabelClass,
|
|
10
|
+
preCallDeviceSelectClass,
|
|
11
|
+
preCallMicMeterClass,
|
|
12
|
+
preCallMicBarVariants,
|
|
13
|
+
preCallControlsRowClass,
|
|
14
|
+
preCallToggleVariants,
|
|
15
|
+
preCallJoinButtonClass,
|
|
16
|
+
type MediaDeviceOption,
|
|
17
|
+
} from '../pre-call-lobby/index.ts'
|
|
18
|
+
import { cn } from '../shared/index.ts'
|
|
19
|
+
|
|
20
|
+
const MIC_BAR_COUNT = 8
|
|
21
|
+
|
|
22
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {
|
|
23
|
+
/** Whether the camera is on. */
|
|
24
|
+
cameraOn?: boolean
|
|
25
|
+
/** Whether the microphone is on. */
|
|
26
|
+
micOn?: boolean
|
|
27
|
+
/** Current microphone level (0..1). */
|
|
28
|
+
micLevel?: number
|
|
29
|
+
/** Available cameras. */
|
|
30
|
+
cameras?: MediaDeviceOption[]
|
|
31
|
+
/** Available microphones. */
|
|
32
|
+
microphones?: MediaDeviceOption[]
|
|
33
|
+
/** Available speakers. */
|
|
34
|
+
speakers?: MediaDeviceOption[]
|
|
35
|
+
/** Currently selected camera id. */
|
|
36
|
+
selectedCamera?: string
|
|
37
|
+
/** Currently selected microphone id. */
|
|
38
|
+
selectedMicrophone?: string
|
|
39
|
+
/** Currently selected speaker id. */
|
|
40
|
+
selectedSpeaker?: string
|
|
41
|
+
/** Label for the join button. */
|
|
42
|
+
joinLabel?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
cameraOn = true,
|
|
47
|
+
micOn = true,
|
|
48
|
+
micLevel = 0,
|
|
49
|
+
cameras = [],
|
|
50
|
+
microphones = [],
|
|
51
|
+
speakers = [],
|
|
52
|
+
selectedCamera,
|
|
53
|
+
selectedMicrophone,
|
|
54
|
+
selectedSpeaker,
|
|
55
|
+
joinLabel = 'Join',
|
|
56
|
+
class: className,
|
|
57
|
+
...rest
|
|
58
|
+
} = Astro.props
|
|
59
|
+
|
|
60
|
+
const { ariaProps, dataAttributes } = createPreCallLobby({ cameraOn, micOn })
|
|
61
|
+
const litBars = micLevelToBars(micLevel, MIC_BAR_COUNT)
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
<div class={cn(preCallLobbyVariants(), className)} {...ariaProps} {...dataAttributes} {...rest}>
|
|
65
|
+
<!-- Camera preview -->
|
|
66
|
+
<div class={preCallCameraVariants({ camera: cameraOn ? 'on' : 'off' })}>
|
|
67
|
+
{cameraOn ? (
|
|
68
|
+
<slot name="preview">
|
|
69
|
+
<div class={preCallCameraPlaceholderClass}>
|
|
70
|
+
<span class="text-xs">No preview</span>
|
|
71
|
+
</div>
|
|
72
|
+
</slot>
|
|
73
|
+
) : (
|
|
74
|
+
<div class={preCallCameraPlaceholderClass}>
|
|
75
|
+
<svg
|
|
76
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
77
|
+
width="40"
|
|
78
|
+
height="40"
|
|
79
|
+
viewBox="0 0 24 24"
|
|
80
|
+
fill="none"
|
|
81
|
+
stroke="currentColor"
|
|
82
|
+
stroke-width="1.5"
|
|
83
|
+
stroke-linecap="round"
|
|
84
|
+
stroke-linejoin="round"
|
|
85
|
+
aria-hidden="true"
|
|
86
|
+
>
|
|
87
|
+
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" />
|
|
88
|
+
<circle cx="9" cy="7" r="4" />
|
|
89
|
+
<line x1="2" y1="2" x2="22" y2="22" />
|
|
90
|
+
</svg>
|
|
91
|
+
<span class="text-xs">Camera is off</span>
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<!-- Mic level meter -->
|
|
97
|
+
<div class="flex items-center gap-2">
|
|
98
|
+
<span class="text-xs text-muted-foreground">Mic</span>
|
|
99
|
+
<div class={preCallMicMeterClass} aria-label={`Mic level: ${litBars} of ${MIC_BAR_COUNT}`}>
|
|
100
|
+
{Array.from({ length: MIC_BAR_COUNT }, (_, i) => {
|
|
101
|
+
const isLit = i < litBars
|
|
102
|
+
const heightClass = i < 2 ? 'h-2' : i < 4 ? 'h-3' : i < 6 ? 'h-4' : 'h-5'
|
|
103
|
+
return (
|
|
104
|
+
<div
|
|
105
|
+
class={`${preCallMicBarVariants({ lit: isLit ? 'true' : 'false' })} ${heightClass}`}
|
|
106
|
+
data-lit={isLit ? 'true' : 'false'}
|
|
107
|
+
/>
|
|
108
|
+
)
|
|
109
|
+
})}
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<!-- Device selectors -->
|
|
114
|
+
{cameras.length > 0 && (
|
|
115
|
+
<div class={preCallDeviceRowClass}>
|
|
116
|
+
<label for="pcl-camera-select" class={preCallDeviceLabelClass}>Camera</label>
|
|
117
|
+
<select id="pcl-camera-select" class={preCallDeviceSelectClass} value={selectedCamera}>
|
|
118
|
+
{cameras.map((d) => (
|
|
119
|
+
<option value={d.id}>{d.label}</option>
|
|
120
|
+
))}
|
|
121
|
+
</select>
|
|
122
|
+
</div>
|
|
123
|
+
)}
|
|
124
|
+
|
|
125
|
+
{microphones.length > 0 && (
|
|
126
|
+
<div class={preCallDeviceRowClass}>
|
|
127
|
+
<label for="pcl-mic-select" class={preCallDeviceLabelClass}>Microphone</label>
|
|
128
|
+
<select id="pcl-mic-select" class={preCallDeviceSelectClass} value={selectedMicrophone}>
|
|
129
|
+
{microphones.map((d) => (
|
|
130
|
+
<option value={d.id}>{d.label}</option>
|
|
131
|
+
))}
|
|
132
|
+
</select>
|
|
133
|
+
</div>
|
|
134
|
+
)}
|
|
135
|
+
|
|
136
|
+
{speakers.length > 0 && (
|
|
137
|
+
<div class={preCallDeviceRowClass}>
|
|
138
|
+
<label for="pcl-speaker-select" class={preCallDeviceLabelClass}>Speaker</label>
|
|
139
|
+
<select id="pcl-speaker-select" class={preCallDeviceSelectClass} value={selectedSpeaker}>
|
|
140
|
+
{speakers.map((d) => (
|
|
141
|
+
<option value={d.id}>{d.label}</option>
|
|
142
|
+
))}
|
|
143
|
+
</select>
|
|
144
|
+
</div>
|
|
145
|
+
)}
|
|
146
|
+
|
|
147
|
+
<!-- Controls row -->
|
|
148
|
+
<div class={preCallControlsRowClass}>
|
|
149
|
+
<button
|
|
150
|
+
type="button"
|
|
151
|
+
aria-label={cameraOn ? 'Turn camera off' : 'Turn camera on'}
|
|
152
|
+
aria-pressed={cameraOn}
|
|
153
|
+
class={preCallToggleVariants({ active: cameraOn ? 'true' : 'false' })}
|
|
154
|
+
>
|
|
155
|
+
<svg
|
|
156
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
157
|
+
width="18"
|
|
158
|
+
height="18"
|
|
159
|
+
viewBox="0 0 24 24"
|
|
160
|
+
fill="none"
|
|
161
|
+
stroke="currentColor"
|
|
162
|
+
stroke-width="2"
|
|
163
|
+
stroke-linecap="round"
|
|
164
|
+
stroke-linejoin="round"
|
|
165
|
+
aria-hidden="true"
|
|
166
|
+
>
|
|
167
|
+
<path d="M23 7l-7 5 7 5V7z" />
|
|
168
|
+
<rect x="1" y="5" width="15" height="14" rx="2" ry="2" />
|
|
169
|
+
</svg>
|
|
170
|
+
</button>
|
|
171
|
+
|
|
172
|
+
<button
|
|
173
|
+
type="button"
|
|
174
|
+
aria-label={micOn ? 'Mute microphone' : 'Unmute microphone'}
|
|
175
|
+
aria-pressed={micOn}
|
|
176
|
+
class={preCallToggleVariants({ active: micOn ? 'true' : 'false' })}
|
|
177
|
+
>
|
|
178
|
+
<svg
|
|
179
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
180
|
+
width="18"
|
|
181
|
+
height="18"
|
|
182
|
+
viewBox="0 0 24 24"
|
|
183
|
+
fill="none"
|
|
184
|
+
stroke="currentColor"
|
|
185
|
+
stroke-width="2"
|
|
186
|
+
stroke-linecap="round"
|
|
187
|
+
stroke-linejoin="round"
|
|
188
|
+
aria-hidden="true"
|
|
189
|
+
>
|
|
190
|
+
<path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" />
|
|
191
|
+
<path d="M19 10v2a7 7 0 0 1-14 0v-2" />
|
|
192
|
+
<line x1="12" y1="19" x2="12" y2="23" />
|
|
193
|
+
<line x1="8" y1="23" x2="16" y2="23" />
|
|
194
|
+
</svg>
|
|
195
|
+
</button>
|
|
196
|
+
</div>
|
|
197
|
+
|
|
198
|
+
<!-- Join button -->
|
|
199
|
+
<button type="button" class={preCallJoinButtonClass}>
|
|
200
|
+
{joinLabel}
|
|
201
|
+
</button>
|
|
202
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
---
|
|
2
|
+
import {
|
|
3
|
+
clampValue,
|
|
4
|
+
valueToFraction,
|
|
5
|
+
gaugeStrokeDashoffset,
|
|
6
|
+
resolveZoneTone,
|
|
7
|
+
createRadialGauge,
|
|
8
|
+
radialGaugeRootVariants,
|
|
9
|
+
gaugeTrackClass,
|
|
10
|
+
gaugeArcClass,
|
|
11
|
+
gaugeArcToneVariants,
|
|
12
|
+
gaugeLabelClass,
|
|
13
|
+
gaugeSublabelClass,
|
|
14
|
+
GAUGE_SIZE_PX,
|
|
15
|
+
GAUGE_LABEL_FONT_SIZE,
|
|
16
|
+
GAUGE_SUBLABEL_FONT_SIZE,
|
|
17
|
+
type GaugeSize,
|
|
18
|
+
type GaugeZone,
|
|
19
|
+
} from '../radial-gauge/index.ts'
|
|
20
|
+
import { cn } from '../shared/index.ts'
|
|
21
|
+
|
|
22
|
+
interface Props extends astroHTML.JSX.SVGAttributes {
|
|
23
|
+
/** Current value. */
|
|
24
|
+
value: number
|
|
25
|
+
/** Minimum value. Defaults to 0. */
|
|
26
|
+
min?: number
|
|
27
|
+
/** Maximum value. Defaults to 100. */
|
|
28
|
+
max?: number
|
|
29
|
+
/** Visual size of the gauge. Defaults to 'md'. */
|
|
30
|
+
size?: GaugeSize
|
|
31
|
+
/** Stroke thickness in px. Defaults to 8. */
|
|
32
|
+
thickness?: number
|
|
33
|
+
/** Primary center label. When omitted and `showValue` is true, the numeric value is shown. */
|
|
34
|
+
label?: string
|
|
35
|
+
/** Secondary label shown below the primary label. */
|
|
36
|
+
sublabel?: string
|
|
37
|
+
/**
|
|
38
|
+
* Threshold zones that colour the arc based on the current value.
|
|
39
|
+
* List in ascending `upTo` order for clarity (internally sorted).
|
|
40
|
+
*/
|
|
41
|
+
zones?: GaugeZone[]
|
|
42
|
+
/** Show the numeric value in the center when no explicit label is given. Defaults to true. */
|
|
43
|
+
showValue?: boolean
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const {
|
|
47
|
+
value,
|
|
48
|
+
min = 0,
|
|
49
|
+
max = 100,
|
|
50
|
+
size = 'md',
|
|
51
|
+
thickness = 8,
|
|
52
|
+
label,
|
|
53
|
+
sublabel,
|
|
54
|
+
zones,
|
|
55
|
+
showValue = true,
|
|
56
|
+
class: className,
|
|
57
|
+
...rest
|
|
58
|
+
} = Astro.props
|
|
59
|
+
|
|
60
|
+
const diameter = GAUGE_SIZE_PX[size]
|
|
61
|
+
const cx = diameter / 2
|
|
62
|
+
const cy = diameter / 2
|
|
63
|
+
const r = cx - thickness / 2
|
|
64
|
+
|
|
65
|
+
const clamped = clampValue(value, min, max)
|
|
66
|
+
const fraction = valueToFraction(clamped, min, max)
|
|
67
|
+
|
|
68
|
+
const circumference = 2 * Math.PI * r
|
|
69
|
+
const dashoffset = gaugeStrokeDashoffset(fraction, circumference)
|
|
70
|
+
|
|
71
|
+
const tone = zones && zones.length > 0 ? resolveZoneTone(clamped, zones, max) : 'default'
|
|
72
|
+
|
|
73
|
+
const { ariaProps, dataAttributes } = createRadialGauge({ value, min, max, size })
|
|
74
|
+
|
|
75
|
+
const centerLabel = label ?? (showValue ? String(clamped) : null)
|
|
76
|
+
const labelFontSize = GAUGE_LABEL_FONT_SIZE[size]
|
|
77
|
+
const sublabelFontSize = GAUGE_SUBLABEL_FONT_SIZE[size]
|
|
78
|
+
const labelDy = sublabel ? -sublabelFontSize * 0.8 : 0
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
<svg
|
|
82
|
+
width={diameter}
|
|
83
|
+
height={diameter}
|
|
84
|
+
viewBox={`0 0 ${diameter} ${diameter}`}
|
|
85
|
+
role="meter"
|
|
86
|
+
aria-valuenow={ariaProps['aria-valuenow']}
|
|
87
|
+
aria-valuemin={ariaProps['aria-valuemin']}
|
|
88
|
+
aria-valuemax={ariaProps['aria-valuemax']}
|
|
89
|
+
class={cn(radialGaugeRootVariants({ size }), className)}
|
|
90
|
+
{...dataAttributes}
|
|
91
|
+
{...rest}
|
|
92
|
+
>
|
|
93
|
+
{/* Background track */}
|
|
94
|
+
<circle
|
|
95
|
+
cx={cx}
|
|
96
|
+
cy={cy}
|
|
97
|
+
r={r}
|
|
98
|
+
stroke-width={thickness}
|
|
99
|
+
class={gaugeTrackClass}
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
|
+
{/* Value arc */}
|
|
103
|
+
<circle
|
|
104
|
+
cx={cx}
|
|
105
|
+
cy={cy}
|
|
106
|
+
r={r}
|
|
107
|
+
stroke-width={thickness}
|
|
108
|
+
stroke-dasharray={`${circumference} ${circumference}`}
|
|
109
|
+
stroke-dashoffset={dashoffset}
|
|
110
|
+
stroke-linecap="round"
|
|
111
|
+
transform={`rotate(-90 ${cx} ${cy})`}
|
|
112
|
+
class={cn(gaugeArcClass, gaugeArcToneVariants({ tone }))}
|
|
113
|
+
/>
|
|
114
|
+
|
|
115
|
+
{/* Center label */}
|
|
116
|
+
{centerLabel != null && (
|
|
117
|
+
<text
|
|
118
|
+
x={cx}
|
|
119
|
+
y={cy}
|
|
120
|
+
text-anchor="middle"
|
|
121
|
+
dominant-baseline="central"
|
|
122
|
+
font-size={labelFontSize}
|
|
123
|
+
dy={labelDy}
|
|
124
|
+
class={gaugeLabelClass}
|
|
125
|
+
>
|
|
126
|
+
{centerLabel}
|
|
127
|
+
</text>
|
|
128
|
+
)}
|
|
129
|
+
|
|
130
|
+
{/* Sub-label */}
|
|
131
|
+
{sublabel != null && (
|
|
132
|
+
<text
|
|
133
|
+
x={cx}
|
|
134
|
+
y={cy}
|
|
135
|
+
text-anchor="middle"
|
|
136
|
+
dominant-baseline="central"
|
|
137
|
+
font-size={sublabelFontSize}
|
|
138
|
+
dy={labelDy + labelFontSize * 1.1}
|
|
139
|
+
class={gaugeSublabelClass}
|
|
140
|
+
>
|
|
141
|
+
{sublabel}
|
|
142
|
+
</text>
|
|
143
|
+
)}
|
|
144
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
import {
|
|
3
|
+
createRatingScale,
|
|
4
|
+
resolveRatingPoints,
|
|
5
|
+
ratingScaleVariants,
|
|
6
|
+
ratingScaleTrackClass,
|
|
7
|
+
ratingScaleItemVariants,
|
|
8
|
+
ratingScaleLabelClass,
|
|
9
|
+
type RatingScaleSize,
|
|
10
|
+
type RatingScalePoint,
|
|
11
|
+
} from '../rating-scale/index.ts'
|
|
12
|
+
import { cn } from '../shared/index.ts'
|
|
13
|
+
|
|
14
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {
|
|
15
|
+
/** Selected value. */
|
|
16
|
+
value?: number
|
|
17
|
+
/** Number of points (1..count). Ignored when `points` is provided. */
|
|
18
|
+
count?: number
|
|
19
|
+
/** Explicit points with accessible labels. */
|
|
20
|
+
points?: RatingScalePoint[]
|
|
21
|
+
/** Label shown before the scale (low end). */
|
|
22
|
+
minLabel?: string
|
|
23
|
+
/** Label shown after the scale (high end). */
|
|
24
|
+
maxLabel?: string
|
|
25
|
+
/** Visual size. */
|
|
26
|
+
size?: RatingScaleSize
|
|
27
|
+
/** Disables the whole scale. */
|
|
28
|
+
disabled?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
value,
|
|
33
|
+
count = 5,
|
|
34
|
+
points,
|
|
35
|
+
minLabel,
|
|
36
|
+
maxLabel,
|
|
37
|
+
size = 'md',
|
|
38
|
+
disabled = false,
|
|
39
|
+
class: className,
|
|
40
|
+
...rest
|
|
41
|
+
} = Astro.props
|
|
42
|
+
|
|
43
|
+
const resolved = resolveRatingPoints(points, count)
|
|
44
|
+
const selectedIndex = resolved.findIndex((p) => p.value === value)
|
|
45
|
+
const tabbableIndex = selectedIndex === -1 ? 0 : selectedIndex
|
|
46
|
+
const { ariaProps, dataAttributes } = createRatingScale({ value, size })
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
<div class={cn(ratingScaleVariants({ size }), className)} {...ariaProps} {...dataAttributes} {...rest}>
|
|
50
|
+
{minLabel && <span class={ratingScaleLabelClass}>{minLabel}</span>}
|
|
51
|
+
<div class={ratingScaleTrackClass}>
|
|
52
|
+
{
|
|
53
|
+
resolved.map((point, index) => {
|
|
54
|
+
const checked = point.value === value
|
|
55
|
+
return (
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
role="radio"
|
|
59
|
+
aria-checked={checked}
|
|
60
|
+
aria-label={point.label ?? String(point.value)}
|
|
61
|
+
tabindex={index === tabbableIndex ? 0 : -1}
|
|
62
|
+
disabled={disabled}
|
|
63
|
+
data-state={checked ? 'checked' : 'unchecked'}
|
|
64
|
+
class={ratingScaleItemVariants({ size, state: checked ? 'checked' : 'unchecked' })}
|
|
65
|
+
>
|
|
66
|
+
{point.label ?? point.value}
|
|
67
|
+
</button>
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
</div>
|
|
72
|
+
{maxLabel && <span class={ratingScaleLabelClass}>{maxLabel}</span>}
|
|
73
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { segmentedControlVariants, createSegmentedControl } from '../segmented-control/index.ts'
|
|
3
|
+
import { cn } from '../shared/index.ts'
|
|
4
|
+
|
|
5
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {
|
|
6
|
+
value?: string
|
|
7
|
+
size?: 'sm' | 'md'
|
|
8
|
+
name?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { value, size = 'md', name, class: className, ...props } = Astro.props
|
|
12
|
+
|
|
13
|
+
const api = createSegmentedControl({ value, size })
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
class={cn(segmentedControlVariants({ size }), className)}
|
|
18
|
+
data-rfr-segmented-group
|
|
19
|
+
data-rfr-segmented-size={size}
|
|
20
|
+
data-rfr-segmented-value={value || ''}
|
|
21
|
+
{...api.ariaProps}
|
|
22
|
+
{...props}
|
|
23
|
+
>
|
|
24
|
+
<slot />
|
|
25
|
+
{name && <input type="hidden" name={name} value={value || ''} data-rfr-segmented-input />}
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
function getNextSegmentIndex(current: number, key: string, count: number): number {
|
|
30
|
+
if (count <= 0) return current
|
|
31
|
+
switch (key) {
|
|
32
|
+
case 'ArrowRight':
|
|
33
|
+
case 'ArrowDown':
|
|
34
|
+
return (current + 1) % count
|
|
35
|
+
case 'ArrowLeft':
|
|
36
|
+
case 'ArrowUp':
|
|
37
|
+
return (current - 1 + count) % count
|
|
38
|
+
case 'Home':
|
|
39
|
+
return 0
|
|
40
|
+
case 'End':
|
|
41
|
+
return count - 1
|
|
42
|
+
default:
|
|
43
|
+
return current
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
document.querySelectorAll<HTMLElement>('[data-rfr-segmented-group]').forEach((group) => {
|
|
48
|
+
const items = () => group.querySelectorAll<HTMLButtonElement>('[data-rfr-segmented-item]')
|
|
49
|
+
|
|
50
|
+
function selectItem(item: HTMLButtonElement) {
|
|
51
|
+
if (item.disabled) return
|
|
52
|
+
const value = item.getAttribute('data-rfr-segmented-item-value') || ''
|
|
53
|
+
|
|
54
|
+
items().forEach((btn) => {
|
|
55
|
+
const btnValue = btn.getAttribute('data-rfr-segmented-item-value') || ''
|
|
56
|
+
const isSelected = btnValue === value
|
|
57
|
+
btn.setAttribute('aria-checked', String(isSelected))
|
|
58
|
+
btn.setAttribute('tabindex', isSelected ? '0' : '-1')
|
|
59
|
+
btn.setAttribute('data-state', isSelected ? 'checked' : 'unchecked')
|
|
60
|
+
|
|
61
|
+
if (isSelected) {
|
|
62
|
+
btn.classList.add('bg-background', 'text-foreground', 'shadow-sm')
|
|
63
|
+
btn.classList.remove('text-muted-foreground', 'hover:text-foreground')
|
|
64
|
+
} else {
|
|
65
|
+
btn.classList.remove('bg-background', 'text-foreground', 'shadow-sm')
|
|
66
|
+
btn.classList.add('text-muted-foreground', 'hover:text-foreground')
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
group.setAttribute('data-rfr-segmented-value', value)
|
|
71
|
+
|
|
72
|
+
const input = group.querySelector('[data-rfr-segmented-input]') as HTMLInputElement | null
|
|
73
|
+
if (input) input.value = value
|
|
74
|
+
|
|
75
|
+
group.dispatchEvent(new CustomEvent('change', { detail: { value } }))
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
group.addEventListener('click', (e) => {
|
|
79
|
+
const item = (e.target as HTMLElement).closest<HTMLButtonElement>('[data-rfr-segmented-item]')
|
|
80
|
+
if (item) selectItem(item)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
group.addEventListener('keydown', (e) => {
|
|
84
|
+
const target = e.target as HTMLElement
|
|
85
|
+
if (!target.hasAttribute('data-rfr-segmented-item')) return
|
|
86
|
+
|
|
87
|
+
const allItems = Array.from(items()).filter((i) => !i.disabled)
|
|
88
|
+
const currentIndex = allItems.indexOf(target as HTMLButtonElement)
|
|
89
|
+
if (currentIndex === -1) return
|
|
90
|
+
|
|
91
|
+
if (e.key === ' ' || e.key === 'Enter') {
|
|
92
|
+
e.preventDefault()
|
|
93
|
+
selectItem(target as HTMLButtonElement)
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const nextIndex = getNextSegmentIndex(currentIndex, e.key, allItems.length)
|
|
98
|
+
if (nextIndex !== currentIndex) {
|
|
99
|
+
e.preventDefault()
|
|
100
|
+
const nextItem = allItems[nextIndex]
|
|
101
|
+
nextItem.focus()
|
|
102
|
+
selectItem(nextItem)
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
</script>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { segmentedControlItemVariants } from '../segmented-control/index.ts'
|
|
3
|
+
import { cn } from '../shared/index.ts'
|
|
4
|
+
|
|
5
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {
|
|
6
|
+
value: string
|
|
7
|
+
size?: 'sm' | 'md'
|
|
8
|
+
checked?: boolean
|
|
9
|
+
disabled?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { value, size = 'md', checked = false, disabled = false, class: className, ...props } = Astro.props
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<button
|
|
16
|
+
type="button"
|
|
17
|
+
role="radio"
|
|
18
|
+
aria-checked={checked}
|
|
19
|
+
aria-disabled={disabled || undefined}
|
|
20
|
+
tabindex={checked ? 0 : -1}
|
|
21
|
+
disabled={disabled || undefined}
|
|
22
|
+
data-state={checked ? 'checked' : 'unchecked'}
|
|
23
|
+
data-rfr-segmented-item
|
|
24
|
+
data-rfr-segmented-item-value={value}
|
|
25
|
+
class={cn(
|
|
26
|
+
segmentedControlItemVariants({ size, state: checked ? 'checked' : 'unchecked' }),
|
|
27
|
+
className,
|
|
28
|
+
)}
|
|
29
|
+
{...props}
|
|
30
|
+
>
|
|
31
|
+
<slot />
|
|
32
|
+
</button>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
import {
|
|
3
|
+
createSeparator,
|
|
4
|
+
separatorVariants,
|
|
5
|
+
separatorLineClass,
|
|
6
|
+
separatorLabelClass,
|
|
7
|
+
type SeparatorOrientation,
|
|
8
|
+
} from '../separator/index.ts'
|
|
9
|
+
import { cn } from '../shared/index.ts'
|
|
10
|
+
|
|
11
|
+
interface Props extends astroHTML.JSX.HTMLAttributes {
|
|
12
|
+
orientation?: SeparatorOrientation
|
|
13
|
+
/**
|
|
14
|
+
* Optional centered label (horizontal only). Renders a flanking line on
|
|
15
|
+
* each side — the "labeled divider" variant. May also be supplied via the
|
|
16
|
+
* default slot.
|
|
17
|
+
*/
|
|
18
|
+
label?: string
|
|
19
|
+
decorative?: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
orientation = 'horizontal',
|
|
24
|
+
label,
|
|
25
|
+
decorative = true,
|
|
26
|
+
class: className,
|
|
27
|
+
...props
|
|
28
|
+
} = Astro.props
|
|
29
|
+
|
|
30
|
+
const hasLabel = orientation === 'horizontal' && (label != null || Astro.slots.has('default'))
|
|
31
|
+
const { ariaProps, dataAttributes } = createSeparator({ orientation, decorative })
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
{
|
|
35
|
+
hasLabel ? (
|
|
36
|
+
<div role="none" class={cn(separatorVariants({ labeled: 'true' }), className)} {...props}>
|
|
37
|
+
<span class={separatorLineClass} />
|
|
38
|
+
<span class={separatorLabelClass}>{label}<slot /></span>
|
|
39
|
+
<span class={separatorLineClass} />
|
|
40
|
+
</div>
|
|
41
|
+
) : (
|
|
42
|
+
<div
|
|
43
|
+
class={cn(separatorVariants({ orientation }), className)}
|
|
44
|
+
{...ariaProps}
|
|
45
|
+
{...dataAttributes}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|