gooee 0.52.0 → 1.0.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 (269) hide show
  1. package/README.md +10 -3
  2. package/package.json +6 -2
  3. package/scripts/add.js +181 -42
  4. package/src/base.css +3 -1
  5. package/src/components/Accordion/Accordion.module.css +7 -5
  6. package/src/components/Accordion/Accordion.tsx +13 -11
  7. package/src/components/Accordion/Accordion.vue +16 -15
  8. package/src/components/Accordion/AccordionItem.vue +8 -7
  9. package/src/components/Alert/Alert.module.css +9 -7
  10. package/src/components/Alert/Alert.tsx +25 -16
  11. package/src/components/Alert/Alert.vue +31 -27
  12. package/src/components/AlertDialog/AlertDialog.module.css +2 -0
  13. package/src/components/AlertDialog/AlertDialog.tsx +8 -7
  14. package/src/components/AlertDialog/AlertDialog.vue +25 -23
  15. package/src/components/AnimatedNumber/AnimatedNumber.module.css +5 -3
  16. package/src/components/AnimatedNumber/AnimatedNumber.tsx +6 -6
  17. package/src/components/AnimatedNumber/AnimatedNumber.vue +5 -5
  18. package/src/components/AspectRatio/AspectRatio.module.css +2 -0
  19. package/src/components/AspectRatio/AspectRatio.tsx +3 -3
  20. package/src/components/AspectRatio/AspectRatio.vue +5 -8
  21. package/src/components/Avatar/Avatar.module.css +10 -8
  22. package/src/components/Avatar/Avatar.tsx +4 -3
  23. package/src/components/Avatar/Avatar.vue +17 -19
  24. package/src/components/Avatar/index.ts +0 -2
  25. package/src/components/AvatarGroup/AvatarGroup.module.css +11 -9
  26. package/src/components/AvatarGroup/AvatarGroup.tsx +4 -4
  27. package/src/components/AvatarGroup/AvatarGroup.vue +13 -16
  28. package/src/components/Badge/Badge.module.css +6 -4
  29. package/src/components/Badge/Badge.tsx +3 -3
  30. package/src/components/Badge/Badge.vue +15 -14
  31. package/src/components/Breadcrumb/Breadcrumb.module.css +5 -3
  32. package/src/components/Breadcrumb/Breadcrumb.tsx +20 -12
  33. package/src/components/Breadcrumb/Breadcrumb.vue +33 -25
  34. package/src/components/Button/Button.module.css +16 -14
  35. package/src/components/Button/Button.tsx +6 -4
  36. package/src/components/Button/Button.vue +42 -33
  37. package/src/components/ButtonGroup/ButtonGroup.module.css +2 -0
  38. package/src/components/ButtonGroup/ButtonGroup.tsx +1 -1
  39. package/src/components/ButtonGroup/ButtonGroup.vue +9 -12
  40. package/src/components/Card/Card.module.css +6 -4
  41. package/src/components/Card/Card.tsx +6 -6
  42. package/src/components/Card/Card.vue +18 -21
  43. package/src/components/Center/Center.module.css +2 -0
  44. package/src/components/Center/Center.tsx +1 -1
  45. package/src/components/Center/Center.vue +18 -15
  46. package/src/components/Checkbox/Checkbox.module.css +10 -8
  47. package/src/components/Checkbox/Checkbox.tsx +15 -9
  48. package/src/components/Checkbox/Checkbox.vue +29 -31
  49. package/src/components/CheckboxGroup/CheckboxGroup.module.css +3 -1
  50. package/src/components/CheckboxGroup/CheckboxGroup.tsx +4 -4
  51. package/src/components/CheckboxGroup/CheckboxGroup.vue +33 -30
  52. package/src/components/Cluster/Cluster.module.css +2 -0
  53. package/src/components/Cluster/Cluster.tsx +1 -1
  54. package/src/components/Cluster/Cluster.vue +21 -17
  55. package/src/components/CodeBlock/CodeBlock.module.css +12 -10
  56. package/src/components/CodeBlock/CodeBlock.tsx +18 -10
  57. package/src/components/CodeBlock/CodeBlock.vue +30 -27
  58. package/src/components/CodeBlock/highlight.ts +1 -1
  59. package/src/components/Collapsible/Collapsible.module.css +7 -5
  60. package/src/components/Collapsible/Collapsible.tsx +7 -6
  61. package/src/components/Collapsible/Collapsible.vue +30 -26
  62. package/src/components/Container/Container.module.css +2 -0
  63. package/src/components/Container/Container.tsx +1 -1
  64. package/src/components/Container/Container.vue +13 -12
  65. package/src/components/CopyButton/CopyButton.module.css +20 -18
  66. package/src/components/CopyButton/CopyButton.tsx +21 -14
  67. package/src/components/CopyButton/CopyButton.vue +41 -31
  68. package/src/components/Dial/Dial.module.css +26 -11
  69. package/src/components/Dial/Dial.tsx +18 -18
  70. package/src/components/Dial/Dial.vue +57 -60
  71. package/src/components/Dialog/Dialog.module.css +4 -2
  72. package/src/components/Dialog/Dialog.tsx +22 -13
  73. package/src/components/Dialog/Dialog.vue +34 -30
  74. package/src/components/Divider/Divider.module.css +5 -3
  75. package/src/components/Divider/Divider.tsx +6 -4
  76. package/src/components/Divider/Divider.vue +13 -16
  77. package/src/components/DropdownMenu/DropdownMenu.module.css +8 -6
  78. package/src/components/DropdownMenu/DropdownMenu.tsx +12 -9
  79. package/src/components/DropdownMenu/DropdownMenu.vue +25 -28
  80. package/src/components/EmptyState/EmptyState.module.css +6 -4
  81. package/src/components/EmptyState/EmptyState.tsx +6 -6
  82. package/src/components/EmptyState/EmptyState.vue +14 -17
  83. package/src/components/Fab/Fab.module.css +19 -17
  84. package/src/components/Fab/Fab.tsx +11 -9
  85. package/src/components/Fab/Fab.vue +29 -26
  86. package/src/components/Fieldset/Fieldset.module.css +2 -0
  87. package/src/components/Fieldset/Fieldset.tsx +4 -3
  88. package/src/components/Fieldset/Fieldset.vue +4 -4
  89. package/src/components/FormField/FormField.module.css +5 -3
  90. package/src/components/FormField/FormField.tsx +7 -7
  91. package/src/components/FormField/FormField.vue +4 -4
  92. package/src/components/Grid/Grid.module.css +2 -0
  93. package/src/components/Grid/Grid.tsx +1 -1
  94. package/src/components/Grid/Grid.vue +25 -22
  95. package/src/components/HoldToConfirm/HoldToConfirm.module.css +13 -11
  96. package/src/components/HoldToConfirm/HoldToConfirm.tsx +11 -9
  97. package/src/components/HoldToConfirm/HoldToConfirm.vue +37 -32
  98. package/src/components/IconButton/IconButton.module.css +7 -5
  99. package/src/components/IconButton/IconButton.tsx +2 -1
  100. package/src/components/IconButton/IconButton.vue +15 -14
  101. package/src/components/Input/Input.module.css +12 -10
  102. package/src/components/Input/Input.tsx +9 -7
  103. package/src/components/Input/Input.vue +45 -35
  104. package/src/components/InputGroup/InputGroup.module.css +8 -6
  105. package/src/components/InputGroup/InputGroup.tsx +5 -4
  106. package/src/components/InputGroup/InputGroup.vue +41 -36
  107. package/src/components/Kbd/Kbd.module.css +9 -7
  108. package/src/components/Kbd/Kbd.tsx +1 -1
  109. package/src/components/Kbd/Kbd.vue +1 -1
  110. package/src/components/Link/Link.module.css +4 -2
  111. package/src/components/Link/Link.tsx +4 -3
  112. package/src/components/Link/Link.vue +13 -16
  113. package/src/components/LivePill/LivePill.module.css +39 -37
  114. package/src/components/LivePill/LivePill.tsx +11 -10
  115. package/src/components/LivePill/LivePill.vue +38 -40
  116. package/src/components/Meter/Meter.module.css +5 -3
  117. package/src/components/Meter/Meter.tsx +9 -8
  118. package/src/components/Meter/Meter.vue +52 -43
  119. package/src/components/MorphButton/MorphButton.module.css +11 -9
  120. package/src/components/MorphButton/MorphButton.tsx +20 -10
  121. package/src/components/MorphButton/MorphButton.vue +29 -25
  122. package/src/components/NumberInput/NumberInput.module.css +7 -5
  123. package/src/components/NumberInput/NumberInput.tsx +11 -8
  124. package/src/components/NumberInput/NumberInput.vue +69 -57
  125. package/src/components/Pagination/Pagination.module.css +147 -5
  126. package/src/components/Pagination/Pagination.tsx +216 -41
  127. package/src/components/Pagination/Pagination.vue +201 -36
  128. package/src/components/Pagination/labels.ts +38 -0
  129. package/src/components/PasswordInput/PasswordInput.module.css +10 -8
  130. package/src/components/PasswordInput/PasswordInput.tsx +15 -7
  131. package/src/components/PasswordInput/PasswordInput.vue +20 -16
  132. package/src/components/PasswordInput/index.ts +1 -1
  133. package/src/components/PickerWheel/DateWheel.vue +20 -12
  134. package/src/components/PickerWheel/PickerWheel.module.css +15 -6
  135. package/src/components/PickerWheel/PickerWheel.tsx +70 -44
  136. package/src/components/PickerWheel/PickerWheel.vue +39 -38
  137. package/src/components/PickerWheel/TimeWheel.vue +23 -21
  138. package/src/components/PickerWheel/WheelColumn.vue +7 -5
  139. package/src/components/Popover/Popover.module.css +5 -3
  140. package/src/components/Popover/Popover.tsx +17 -8
  141. package/src/components/Popover/Popover.vue +26 -25
  142. package/src/components/ProgressBar/ProgressBar.module.css +4 -2
  143. package/src/components/ProgressBar/ProgressBar.tsx +6 -5
  144. package/src/components/ProgressBar/ProgressBar.vue +28 -25
  145. package/src/components/Prose/Prose.module.css +5 -3
  146. package/src/components/Prose/Prose.tsx +1 -1
  147. package/src/components/Prose/Prose.vue +5 -8
  148. package/src/components/Radio/Radio.module.css +10 -8
  149. package/src/components/Radio/Radio.tsx +10 -8
  150. package/src/components/Radio/Radio.vue +8 -8
  151. package/src/components/Radio/RadioGroup.vue +33 -35
  152. package/src/components/Radio/radioContext.ts +12 -0
  153. package/src/components/Retime/Retime.vue +25 -22
  154. package/src/components/RulerScrubber/RulerScrubber.module.css +11 -2
  155. package/src/components/RulerScrubber/RulerScrubber.tsx +19 -18
  156. package/src/components/RulerScrubber/RulerScrubber.vue +50 -54
  157. package/src/components/ScrollArea/ScrollArea.module.css +17 -15
  158. package/src/components/ScrollArea/ScrollArea.tsx +5 -4
  159. package/src/components/ScrollArea/ScrollArea.vue +15 -17
  160. package/src/components/SearchInput/SearchInput.module.css +6 -4
  161. package/src/components/SearchInput/SearchInput.tsx +22 -10
  162. package/src/components/SearchInput/SearchInput.vue +20 -17
  163. package/src/components/SearchInput/index.ts +1 -1
  164. package/src/components/SegmentedControl/SegmentedControl.module.css +7 -5
  165. package/src/components/SegmentedControl/SegmentedControl.tsx +9 -5
  166. package/src/components/SegmentedControl/SegmentedControl.vue +25 -29
  167. package/src/components/Select/Select.module.css +19 -17
  168. package/src/components/Select/Select.tsx +31 -18
  169. package/src/components/Select/Select.vue +63 -58
  170. package/src/components/Sheet/Sheet.module.css +6 -4
  171. package/src/components/Sheet/Sheet.tsx +39 -29
  172. package/src/components/Sheet/Sheet.vue +46 -40
  173. package/src/components/Skeleton/Skeleton.module.css +4 -2
  174. package/src/components/Skeleton/Skeleton.tsx +3 -2
  175. package/src/components/Skeleton/Skeleton.vue +16 -18
  176. package/src/components/Slider/Slider.module.css +14 -12
  177. package/src/components/Slider/Slider.tsx +27 -11
  178. package/src/components/Slider/Slider.vue +47 -37
  179. package/src/components/Spinner/Spinner.module.css +2 -0
  180. package/src/components/Spinner/Spinner.tsx +3 -3
  181. package/src/components/Spinner/Spinner.vue +9 -12
  182. package/src/components/Split/Split.module.css +2 -0
  183. package/src/components/Split/Split.tsx +3 -3
  184. package/src/components/Split/Split.vue +19 -17
  185. package/src/components/SplitFlap/SplitFlap.module.css +9 -7
  186. package/src/components/SplitFlap/SplitFlap.tsx +2 -2
  187. package/src/components/SplitFlap/SplitFlap.vue +24 -21
  188. package/src/components/Stack/Stack.module.css +2 -0
  189. package/src/components/Stack/Stack.tsx +1 -1
  190. package/src/components/Stack/Stack.vue +13 -12
  191. package/src/components/SwipeDeck/SwipeDeck.module.css +13 -11
  192. package/src/components/SwipeDeck/SwipeDeck.tsx +23 -28
  193. package/src/components/SwipeDeck/SwipeDeck.vue +32 -38
  194. package/src/components/Switch/Switch.module.css +10 -8
  195. package/src/components/Switch/Switch.tsx +6 -5
  196. package/src/components/Switch/Switch.vue +22 -24
  197. package/src/components/Table/Table.module.css +24 -22
  198. package/src/components/Table/Table.tsx +27 -30
  199. package/src/components/Table/Table.vue +93 -79
  200. package/src/components/TableOfContents/TableOfContents.module.css +9 -7
  201. package/src/components/TableOfContents/TableOfContents.tsx +8 -8
  202. package/src/components/TableOfContents/TableOfContents.vue +20 -23
  203. package/src/components/Tabs/Tab.vue +3 -0
  204. package/src/components/Tabs/TabList.vue +2 -2
  205. package/src/components/Tabs/TabPanel.vue +2 -0
  206. package/src/components/Tabs/Tabs.module.css +4 -2
  207. package/src/components/Tabs/Tabs.tsx +10 -5
  208. package/src/components/Tabs/Tabs.vue +1 -1
  209. package/src/components/Tag/Tag.module.css +12 -10
  210. package/src/components/Tag/Tag.tsx +13 -15
  211. package/src/components/Tag/Tag.vue +12 -14
  212. package/src/components/Textarea/Textarea.module.css +8 -6
  213. package/src/components/Textarea/Textarea.tsx +4 -3
  214. package/src/components/Textarea/Textarea.vue +32 -34
  215. package/src/components/ThemeToggle/ThemeToggle.module.css +2 -0
  216. package/src/components/ThemeToggle/ThemeToggle.tsx +7 -7
  217. package/src/components/ThemeToggle/ThemeToggle.vue +24 -22
  218. package/src/components/Toast/Toast.module.css +17 -15
  219. package/src/components/Toast/Toast.tsx +51 -34
  220. package/src/components/Toast/Toast.vue +35 -24
  221. package/src/components/Toast/ToastItem.vue +17 -16
  222. package/src/components/Toggle/Toggle.module.css +11 -9
  223. package/src/components/Toggle/Toggle.tsx +3 -2
  224. package/src/components/Toggle/Toggle.vue +13 -15
  225. package/src/components/Tooltip/Tooltip.module.css +5 -3
  226. package/src/components/Tooltip/Tooltip.tsx +1 -0
  227. package/src/components/Tooltip/Tooltip.vue +13 -18
  228. package/src/components/VisuallyHidden/VisuallyHidden.module.css +2 -0
  229. package/src/components/VisuallyHidden/VisuallyHidden.tsx +1 -1
  230. package/src/components/VisuallyHidden/VisuallyHidden.vue +5 -8
  231. package/src/{internal → icons}/icons.module.css +4 -2
  232. package/src/{internal → icons}/icons.tsx +15 -16
  233. package/src/internal/FieldMessage.module.css +5 -3
  234. package/src/internal/FieldMessage.tsx +2 -2
  235. package/src/internal/FieldMessage.vue +2 -2
  236. package/src/internal/Roll.module.css +5 -3
  237. package/src/internal/feel.ts +12 -10
  238. package/src/internal/fling.ts +3 -3
  239. package/src/internal/liquid.ts +12 -10
  240. package/src/internal/liquidMatter.ts +1 -1
  241. package/src/internal/liquidMore.ts +7 -7
  242. package/src/internal/motion/checkbox.ts +4 -4
  243. package/src/internal/motion/fling.ts +19 -9
  244. package/src/internal/motion/holdToConfirm.ts +3 -3
  245. package/src/internal/motion/index.ts +8 -6
  246. package/src/internal/motion/liquid.ts +16 -4
  247. package/src/internal/motion/liquidMatter.ts +8 -6
  248. package/src/internal/motion/liquidMore.ts +44 -25
  249. package/src/internal/motion/livePill.ts +1 -1
  250. package/src/internal/motion/numberInput.ts +2 -2
  251. package/src/internal/motion/pickerWheel.ts +7 -4
  252. package/src/internal/motion/ruler.ts +1 -1
  253. package/src/internal/motion/scrollArea.ts +3 -3
  254. package/src/internal/motion/scrollFrame.ts +9 -7
  255. package/src/internal/motion/scrubber.ts +39 -20
  256. package/src/internal/motion/slider.ts +38 -4
  257. package/src/internal/motion/softPress.ts +10 -9
  258. package/src/internal/motion/splitFlap.ts +4 -4
  259. package/src/internal/motion/swipeDeck.ts +38 -7
  260. package/src/internal/motion/table.ts +3 -6
  261. package/src/internal/motion/themeIcon.ts +1 -1
  262. package/src/internal/motion/themeReveal.ts +1 -1
  263. package/src/internal/motion/toast.ts +3 -3
  264. package/src/internal/motion.ts +7 -8
  265. package/src/internal/scrollFrame.ts +3 -3
  266. package/src/internal/useScrub.ts +1 -15
  267. package/src/internal/vue/useScrub.ts +2 -6
  268. package/src/tokens.css +81 -421
  269. package/src/{internal/vueIcons.ts → icons/vue.ts} +5 -5
@@ -5,29 +5,32 @@ import styles from './SplitFlap.module.css'
5
5
 
6
6
  // The Vue SplitFlap: the same look (SplitFlap.module.css) and flips (motion/splitFlap.ts) as the React one.
7
7
  // Other attributes go to the root.
8
- const props = withDefaults(
9
- defineProps<{
10
- /** The text the board shows. A change flips each cell forward through the drum to its new letter. */
11
- value: string
12
- /** At least this many cells: shorter text is padded with blank ones, so a column keeps its width. */
13
- length?: number
14
- /** Text size of the cells. */
15
- size?: 'sm' | 'md' | 'lg'
16
- /** The drum's letters, in the order a cell passes them. A letter that is not on it flips straight in. */
17
- chars?: string
18
- /** Says the new text to screen readers once, when the board has landed. Turn off when one message covers several boards. */
19
- announce?: boolean
20
- }>(),
21
- { length: 0, size: 'md', chars: SPLIT_FLAP_CHARS, announce: true },
22
- )
8
+ const {
9
+ value: valueProp,
10
+ length = 0,
11
+ size = 'md',
12
+ chars = SPLIT_FLAP_CHARS,
13
+ announce = true,
14
+ } = defineProps<{
15
+ /** The text the board shows. A change flips each cell forward through the drum to its new letter. */
16
+ value: string
17
+ /** At least this many cells: shorter text is padded with blank ones, so a column keeps its width. */
18
+ length?: number
19
+ /** Text size of the cells. */
20
+ size?: 'sm' | 'md' | 'lg'
21
+ /** The drum's letters, in the order a cell passes them. A letter that is not on it flips straight in. */
22
+ chars?: string
23
+ /** Says the new text to screen readers once, when the board has landed. Turn off when one message covers several boards. */
24
+ announce?: boolean
25
+ }>()
23
26
  /** settle: fires once with the text when every cell has landed. */
24
27
  const emit = defineEmits<{ settle: [value: string] }>()
25
28
 
26
29
  const LOOK: FlapLook = { cell: styles.cell, top: styles.top, bottom: styles.bottom, glyph: styles.glyph, flap: styles.flap, front: styles.front, back: styles.back }
27
- const target = computed(() => props.value.padEnd(props.length, ' '))
30
+ const target = computed(() => valueProp.padEnd(length, ' '))
28
31
  // The first cells come with the markup, so a server page shows the board before any script runs.
29
32
  const first = flapCellsHtml(LOOK, target.value)
30
- const said = ref(props.value)
33
+ const said = ref(valueProp)
31
34
  const board = ref<HTMLSpanElement | null>(null)
32
35
  let flap: ReturnType<typeof createSplitFlap> | null = null
33
36
 
@@ -35,8 +38,8 @@ onMounted(() => {
35
38
  if (board.value) flap = createSplitFlap(board.value, LOOK, target.value)
36
39
  })
37
40
  watch(target, (t) => {
38
- const value = props.value
39
- flap?.show(t, props.chars, () => {
41
+ const value = valueProp
42
+ flap?.show(t, chars, () => {
40
43
  said.value = value
41
44
  emit('settle', value)
42
45
  })
@@ -45,8 +48,8 @@ onBeforeUnmount(() => flap?.destroy())
45
48
  </script>
46
49
 
47
50
  <template>
48
- <span :class="styles.root" :data-size="size">
51
+ <span :class="styles.root" data-slot="split-flap" :data-size="size">
49
52
  <span :class="styles.sr" :aria-live="announce ? 'polite' : undefined" aria-atomic="true">{{ said }}</span>
50
- <span ref="board" :class="styles.board" aria-hidden="true" v-html="first" />
53
+ <span ref="board" :class="styles.board" data-slot="split-flap-board" aria-hidden="true" v-html="first" />
51
54
  </span>
52
55
  </template>
@@ -1,3 +1,4 @@
1
+ @layer gooee.components {
1
2
  .root {
2
3
  display: flex;
3
4
  flex-direction: column;
@@ -15,3 +16,4 @@
15
16
  .start { align-items: flex-start; }
16
17
  .center { align-items: center; }
17
18
  .end { align-items: flex-end; }
19
+ }
@@ -15,5 +15,5 @@ export type StackProps = ComponentPropsWithRef<'div'> & {
15
15
  export function Stack({ gap = 5, align = 'stretch', as = 'div', className, style, ...rest }: StackProps) {
16
16
  // One cast keeps the ref and attribute types simple; every option is a block element.
17
17
  const Tag = as as 'div'
18
- return <Tag className={cx(styles.root, styles[align], className)} style={{ '--stack-gap': space(gap), ...style } as CSSProperties} {...rest} />
18
+ return <Tag className={cx(styles.root, styles[align], className)} data-slot="stack" style={{ '--stack-gap': space(gap), ...style } as CSSProperties} {...rest} />
19
19
  }
@@ -3,20 +3,21 @@ import { space, type Space } from '../../internal/space'
3
3
  import styles from './Stack.module.css'
4
4
 
5
5
  // The Vue Stack: the same look (Stack.module.css) as the React one. Other attributes go to the element.
6
- withDefaults(
7
- defineProps<{
8
- /** Space between items, as a step of the space scale (0 to 12, read as --gooee-space-N). */
9
- gap?: Space
10
- /** Lines items up across the stack. "stretch" makes each item full width. */
11
- align?: 'stretch' | 'start' | 'center' | 'end'
12
- /** Element to render, so the stack can be a list, a section or a form. */
13
- as?: 'div' | 'section' | 'article' | 'aside' | 'nav' | 'header' | 'footer' | 'main' | 'form' | 'fieldset' | 'ul' | 'ol'
14
- }>(),
15
- { gap: 5, align: 'stretch', as: 'div' },
16
- )
6
+ const {
7
+ gap = 5,
8
+ align = 'stretch',
9
+ as = 'div',
10
+ } = defineProps<{
11
+ /** Space between items, as a step of the space scale (0 to 12, read as --gooee-space-N). */
12
+ gap?: Space
13
+ /** Lines items up across the stack. "stretch" makes each item full width. */
14
+ align?: 'stretch' | 'start' | 'center' | 'end'
15
+ /** Element to render, so the stack can be a list, a section or a form. */
16
+ as?: 'div' | 'section' | 'article' | 'aside' | 'nav' | 'header' | 'footer' | 'main' | 'form' | 'fieldset' | 'ul' | 'ol'
17
+ }>()
17
18
  defineSlots<{ default?: () => unknown }>()
18
19
  </script>
19
20
 
20
21
  <template>
21
- <component :is="as" :class="[styles.root, styles[align]]" :style="{ '--stack-gap': space(gap) }"><slot /></component>
22
+ <component :is="as" :class="[styles.root, styles[align]]" data-slot="stack" :style="{ '--stack-gap': space(gap) }"><slot /></component>
22
23
  </template>
@@ -1,3 +1,4 @@
1
+ @layer gooee.components {
1
2
  .root {
2
3
  display: grid;
3
4
  gap: var(--gooee-space-5);
@@ -16,7 +17,7 @@
16
17
  --rise: 0;
17
18
  position: relative;
18
19
  display: grid;
19
- max-inline-size: var(--gooee-deck-w);
20
+ max-inline-size: var(--gooee-swipe-deck-w, 332px);
20
21
  margin-inline: auto;
21
22
  border-radius: var(--gooee-radius-panel);
22
23
  outline: none;
@@ -31,7 +32,7 @@
31
32
  z-index: 3;
32
33
  grid-area: 1 / 1;
33
34
  display: grid;
34
- min-block-size: var(--gooee-deck-card-h);
35
+ min-block-size: var(--gooee-swipe-deck-card-h, 404px);
35
36
  border: var(--gooee-line) solid var(--gooee-color-border);
36
37
  border-radius: var(--gooee-radius-panel);
37
38
  background: var(--gooee-color-surface-raised);
@@ -66,14 +67,14 @@
66
67
 
67
68
  .deck:not([data-dragging]) .card[data-depth='1'],
68
69
  .deck:not([data-dragging]) .card[data-depth='2'] {
69
- transition: transform var(--gooee-motion-base) var(--gooee-ease-out);
70
+ transition: transform var(--gooee-motion-base) var(--gooee-ease-morph);
70
71
  }
71
72
 
72
73
  .empty {
73
74
  grid-area: 1 / 1;
74
75
  display: grid;
75
76
  place-content: center;
76
- min-block-size: var(--gooee-deck-card-h);
77
+ min-block-size: var(--gooee-swipe-deck-card-h, 404px);
77
78
  padding: calc(var(--gooee-space-6) - var(--gooee-line));
78
79
  border: var(--gooee-line) dashed var(--gooee-color-border-strong);
79
80
  border-radius: var(--gooee-radius-panel);
@@ -85,7 +86,7 @@
85
86
  .ruler {
86
87
  position: relative;
87
88
  inline-size: 100%;
88
- max-inline-size: var(--gooee-deck-w);
89
+ max-inline-size: var(--gooee-swipe-deck-w, 332px);
89
90
  block-size: var(--gooee-space-6);
90
91
  margin-inline: auto;
91
92
  background: linear-gradient(var(--gooee-color-border), var(--gooee-color-border)) center / 100% var(--gooee-line) no-repeat;
@@ -100,8 +101,8 @@
100
101
  background: var(--gooee-color-border-strong);
101
102
  translate: -50% -50%;
102
103
  transition:
103
- background-color var(--gooee-motion-fast) var(--gooee-ease-out),
104
- inline-size var(--gooee-motion-fast) var(--gooee-ease-out);
104
+ background-color var(--gooee-motion-fast) var(--gooee-ease-morph),
105
+ inline-size var(--gooee-motion-fast) var(--gooee-ease-morph);
105
106
  }
106
107
 
107
108
  .centre {
@@ -110,11 +111,11 @@
110
111
  }
111
112
 
112
113
  .mark[data-side='left'] {
113
- left: calc(50% - var(--gooee-deck-throw) * 100%);
114
+ left: calc(50% - var(--gooee-swipe-deck-throw, 0.35) * 100%);
114
115
  }
115
116
 
116
117
  .mark[data-side='right'] {
117
- left: calc(50% + var(--gooee-deck-throw) * 100%);
118
+ left: calc(50% + var(--gooee-swipe-deck-throw, 0.35) * 100%);
118
119
  }
119
120
 
120
121
  .mark[data-armed] {
@@ -142,7 +143,7 @@
142
143
  grid-template-columns: 1fr auto 1fr;
143
144
  gap: var(--gooee-space-4);
144
145
  align-items: center;
145
- max-inline-size: var(--gooee-deck-w);
146
+ max-inline-size: var(--gooee-swipe-deck-w, 332px);
146
147
  inline-size: 100%;
147
148
  margin-inline: auto;
148
149
  }
@@ -156,7 +157,7 @@
156
157
 
157
158
  .choice {
158
159
  --fill: 0;
159
- transition: --fill var(--gooee-motion-base) var(--gooee-ease-out);
160
+ transition: --fill var(--gooee-motion-base) var(--gooee-ease-morph);
160
161
  position: relative;
161
162
  display: grid;
162
163
  min-block-size: var(--gooee-control-h-lg);
@@ -248,3 +249,4 @@
248
249
  clip-path: inset(50%);
249
250
  white-space: nowrap;
250
251
  }
252
+ }
@@ -3,11 +3,12 @@
3
3
  import { useEffect, useLayoutEffect, useRef, useState, type ComponentPropsWithRef, type KeyboardEvent, type ReactNode } from 'react'
4
4
  import { flushSync } from 'react-dom'
5
5
  import { cx } from '../../internal/cx'
6
- import { UndoIcon } from '../../internal/icons'
7
- import { createSwipeDeck, type DeckSide } from '../../internal/motion/swipeDeck'
6
+ import { UndoIcon } from '../../icons/icons'
7
+ import { createSwipeDeck, defaultSwipeDeckLabels, type DeckSide, type SwipeDeckLabels } from '../../internal/motion/swipeDeck'
8
8
  import styles from './SwipeDeck.module.css'
9
9
 
10
10
  export type SwipeDeckSide = 'start' | 'end'
11
+ export type { SwipeDeckLabels }
11
12
 
12
13
  export type SwipeDeckProps<T> = Omit<ComponentPropsWithRef<'div'>, 'children' | 'onChange'> & {
13
14
  /** The cards, top card first. The top card is the first whose key is not decided yet, so you may remove decided ones. */
@@ -20,18 +21,12 @@ export type SwipeDeckProps<T> = Omit<ComponentPropsWithRef<'div'>, 'children' |
20
21
  renderCard: (item: T) => ReactNode
21
22
  /** Screen reader name of the deck, such as "Flats to rent". */
22
23
  label: string
23
- /** The two button words, for the start side then the end side. */
24
- actions?: [string, string]
25
- /** What screen readers say was done, start then end, such as "Passed" and "Saved". */
26
- decided?: [string, string]
27
24
  /** Called once for each card, when it has been thrown or a button or key decided it. */
28
25
  onDecide?: (item: T, side: SwipeDeckSide) => void
29
26
  /** Called when Undo brings a card back. If you removed it from items, put it back here. */
30
27
  onUndo?: (item: T) => void
31
- /** Screen reader name of the undo button. */
32
- undoLabel?: string
33
- /** Shown when every card has been decided. */
34
- empty?: ReactNode
28
+ /** The button words and what screen readers hear, so you can change or translate them. Missing keys use the English defaults. */
29
+ labels?: Partial<SwipeDeckLabels>
35
30
  }
36
31
 
37
32
  type Side = DeckSide
@@ -43,15 +38,13 @@ export function SwipeDeck<T>({
43
38
  getName,
44
39
  renderCard,
45
40
  label,
46
- actions = ['Pass', 'Save'],
47
- decided = ['Passed', 'Saved'],
48
41
  onDecide,
49
42
  onUndo,
50
- undoLabel = 'Undo the last decision',
51
- empty = 'That was the last card.',
43
+ labels: labelsProp,
52
44
  className,
53
45
  ...rest
54
46
  }: SwipeDeckProps<T>) {
47
+ const labels = { ...defaultSwipeDeckLabels, ...labelsProp }
55
48
  const [done, setDone] = useState<Done<T>[]>([])
56
49
  const [news, setNews] = useState('')
57
50
  const [armed, setArmed] = useState<Side | 0>(0)
@@ -63,8 +56,8 @@ export function SwipeDeck<T>({
63
56
  // The top card is the first one not yet decided, found by key, so the app may trim or replace items.
64
57
  const gone = new Set(done.map((d) => getKey(d.item)))
65
58
  const left = items.filter((item) => !gone.has(getKey(item)))
66
- const latest = useRef({ left, count: done.length, onDecide, getName, decided })
67
- latest.current = { left, count: done.length, onDecide, getName, decided }
59
+ const latest = useRef({ left, count: done.length, onDecide, getName, labels })
60
+ latest.current = { left, count: done.length, onDecide, getName, labels }
68
61
 
69
62
  // The drag, the throw and undo's way back (motion/swipeDeck.ts).
70
63
  const core = useRef<ReturnType<typeof createSwipeDeck>>(null)
@@ -84,14 +77,14 @@ export function SwipeDeck<T>({
84
77
  const { named, physical, fly } = swipe
85
78
 
86
79
  const commit = (side: Side) => {
87
- const { left, count, onDecide, getName, decided } = latest.current
80
+ const { left, count, onDecide, getName, labels } = latest.current
88
81
  const [item, next] = left
89
82
  if (!item) return
90
83
  const dir = named(side)
91
84
  setDone((d) => [...d, { item, side, dir }])
92
85
  latest.current = { ...latest.current, left: left.slice(1), count: count + 1 }
93
- const said = `${decided[dir === 'start' ? 0 : 1]}: ${getName(item)}.`
94
- setNews(next ? `${said} Card ${count + 2} of ${count + left.length}: ${getName(next)}.` : `${said} No more cards.`)
86
+ const said = `${labels.decided[dir === 'start' ? 0 : 1]}: ${getName(item)}.`
87
+ setNews(`${said} ${next ? labels.next(count + 2, count + left.length, getName(next)) : labels.last}`)
95
88
  onDecide?.(item, dir)
96
89
  }
97
90
 
@@ -101,7 +94,7 @@ export function SwipeDeck<T>({
101
94
  if (!swipe.undo(last.side)) return
102
95
  setDone((d) => d.slice(0, -1))
103
96
  const count = done.length - 1
104
- setNews(`Brought back: ${getName(last.item)}. Card ${count + 1} of ${count + left.length + 1}.`)
97
+ setNews(labels.undone(getName(last.item), count + 1, count + left.length + 1))
105
98
  onUndo?.(last.item)
106
99
  }
107
100
 
@@ -127,28 +120,30 @@ export function SwipeDeck<T>({
127
120
  ref={(b) => void (buttons.current[dir === 'start' ? -1 : 1] = b)}
128
121
  type="button"
129
122
  className={styles.choice}
123
+ data-slot="swipe-deck-choice"
130
124
  data-side={dir}
131
125
  aria-disabled={over || undefined}
132
126
  onClick={() => !over && fly(physical(dir), 0)}
133
127
  >
134
- <span className={styles.word}>{actions[dir === 'start' ? 0 : 1]}</span>
128
+ <span className={styles.word}>{labels.actions[dir === 'start' ? 0 : 1]}</span>
135
129
  <span className={styles.fill} aria-hidden="true">
136
- <span className={styles.word}>{actions[dir === 'start' ? 0 : 1]}</span>
130
+ <span className={styles.word}>{labels.actions[dir === 'start' ? 0 : 1]}</span>
137
131
  </span>
138
132
  </button>
139
133
  )
140
134
 
141
135
  return (
142
- <div ref={root} className={cx(styles.root, className)} data-armed={armedDir} {...rest}>
136
+ <div ref={root} className={cx(styles.root, className)} data-slot="swipe-deck" data-armed={armedDir} {...rest}>
143
137
  <div className={styles.stage}>
144
- <div ref={deck} className={styles.deck} role="group" aria-roledescription="card deck" aria-label={label} aria-keyshortcuts="ArrowLeft ArrowRight Backspace" tabIndex={0} onKeyDown={onKeyDown}>
145
- {over && <div className={styles.empty}>{empty}</div>}
138
+ <div ref={deck} className={styles.deck} data-slot="swipe-deck-stack" role="group" aria-roledescription={labels.deck} aria-label={label} aria-keyshortcuts="ArrowLeft ArrowRight Backspace" tabIndex={0} onKeyDown={onKeyDown}>
139
+ {over && <div className={styles.empty} data-slot="swipe-deck-empty">{labels.empty}</div>}
146
140
  {shown
147
141
  .map((item, depth) => (
148
142
  <div
149
143
  key={getKey(item)}
150
144
  ref={depth === 0 ? top : undefined}
151
145
  className={styles.card}
146
+ data-slot="swipe-deck-card"
152
147
  data-depth={depth}
153
148
  inert={depth > 0}
154
149
  aria-hidden={depth > 0 || undefined}
@@ -165,15 +160,15 @@ export function SwipeDeck<T>({
165
160
  .reverse()}
166
161
  </div>
167
162
  </div>
168
- <div className={styles.ruler} aria-hidden="true">
163
+ <div className={styles.ruler} data-slot="swipe-deck-ruler" aria-hidden="true">
169
164
  <span className={styles.mark} data-side="left" data-armed={armed === -1 || undefined} />
170
165
  <span className={styles.centre} />
171
166
  <span className={styles.mark} data-side="right" data-armed={armed === 1 || undefined} />
172
167
  <span ref={knob} className={styles.knob} data-armed={armed !== 0 || undefined} />
173
168
  </div>
174
- <div className={styles.bar}>
169
+ <div className={styles.bar} data-slot="swipe-deck-actions">
175
170
  {choice('start')}
176
- <button type="button" className={styles.undo} aria-label={undoLabel} aria-disabled={!done.length || undefined} onClick={undo}>
171
+ <button type="button" className={styles.undo} data-slot="swipe-deck-undo" aria-label={labels.undo} aria-disabled={!done.length || undefined} onClick={undo}>
177
172
  <UndoIcon />
178
173
  </button>
179
174
  {choice('end')}
@@ -1,34 +1,27 @@
1
1
  <script setup lang="ts" generic="T">
2
2
  import { computed, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue'
3
- import { createSwipeDeck, type DeckDir, type DeckSide } from '../../internal/motion/swipeDeck'
4
- import { UndoIcon } from '../../internal/vueIcons'
3
+ import { createSwipeDeck, defaultSwipeDeckLabels, type DeckDir, type DeckSide, type SwipeDeckLabels } from '../../internal/motion/swipeDeck'
4
+ import { UndoIcon } from '../../icons/vue'
5
5
  import styles from './SwipeDeck.module.css'
6
6
 
7
7
  export type SwipeDeckSide = DeckDir
8
+ export type { SwipeDeckLabels }
8
9
 
9
10
  // The Vue SwipeDeck: the same look (SwipeDeck.module.css), drag, throw and undo as the React one. Each
10
11
  // card is drawn by the card slot, which gets the item. Other attributes go to the outer box.
11
- const props = withDefaults(
12
- defineProps<{
13
- /** The cards, top card first. The top card is the first whose key is not decided yet, so you may remove decided ones. */
14
- items: T[]
15
- /** A key that stays the same for each item. */
16
- getKey: (item: T) => string
17
- /** A short name for an item, said by screen readers after each decision. */
18
- getName: (item: T) => string
19
- /** Screen reader name of the deck, such as "Flats to rent". */
20
- label: string
21
- /** The two button words, for the start side then the end side. */
22
- actions?: [string, string]
23
- /** What screen readers say was done, start then end, such as "Passed" and "Saved". */
24
- decided?: [string, string]
25
- /** Screen reader name of the undo button. */
26
- undoLabel?: string
27
- /** Shown when every card has been decided. The empty slot replaces it. */
28
- empty?: string
29
- }>(),
30
- { actions: () => ['Pass', 'Save'], decided: () => ['Passed', 'Saved'], undoLabel: 'Undo the last decision', empty: 'That was the last card.' },
31
- )
12
+ const props = defineProps<{
13
+ /** The cards, top card first. The top card is the first whose key is not decided yet, so you may remove decided ones. */
14
+ items: T[]
15
+ /** A key that stays the same for each item. */
16
+ getKey: (item: T) => string
17
+ /** A short name for an item, said by screen readers after each decision. */
18
+ getName: (item: T) => string
19
+ /** Screen reader name of the deck, such as "Flats to rent". */
20
+ label: string
21
+ /** The button words and what screen readers hear, so you can change or translate them. Missing keys use the English defaults. The empty slot replaces labels.empty. */
22
+ labels?: Partial<SwipeDeckLabels>
23
+ }>()
24
+ const labels = computed<SwipeDeckLabels>(() => ({ ...defaultSwipeDeckLabels, ...props.labels }))
32
25
  /** decide: once for each card, when it has been thrown or a button or key decided it. undo: Undo brought a card back; if you removed it from items, put it back here. */
33
26
  const emit = defineEmits<{ decide: [item: T, side: SwipeDeckSide]; undo: [item: T] }>()
34
27
  defineSlots<{ card(props: { item: T }): unknown; empty?: () => unknown }>()
@@ -56,8 +49,8 @@ const commit = (side: DeckSide) => {
56
49
  const n = left.value.length
57
50
  const dir = swipe.named(side)
58
51
  done.value = [...done.value, { item, side, dir }]
59
- const said = `${props.decided[dir === 'start' ? 0 : 1]}: ${props.getName(item)}.`
60
- news.value = next ? `${said} Card ${count + 2} of ${count + n}: ${props.getName(next)}.` : `${said} No more cards.`
52
+ const said = `${labels.value.decided[dir === 'start' ? 0 : 1]}: ${props.getName(item)}.`
53
+ news.value = `${said} ${next ? labels.value.next(count + 2, count + n, props.getName(next)) : labels.value.last}`
61
54
  emit('decide', item, dir)
62
55
  }
63
56
 
@@ -85,7 +78,7 @@ const undo = () => {
85
78
  const count = done.value.length - 1
86
79
  const n = left.value.length
87
80
  done.value = done.value.slice(0, -1)
88
- news.value = `Brought back: ${props.getName(last.item)}. Card ${count + 1} of ${count + n + 1}.`
81
+ news.value = labels.value.undone(props.getName(last.item), count + 1, count + n + 1)
89
82
  emit('undo', last.item)
90
83
  }
91
84
 
@@ -117,15 +110,16 @@ const choose = (dir: SwipeDeckSide) => !over.value && swipe.fly(swipe.physical(d
117
110
  </script>
118
111
 
119
112
  <template>
120
- <div ref="root" :class="styles.root" :data-armed="armedDir">
113
+ <div ref="root" :class="styles.root" data-slot="swipe-deck" :data-armed="armedDir">
121
114
  <div :class="styles.stage">
122
- <div ref="deck" :class="styles.deck" role="group" aria-roledescription="card deck" :aria-label="label" aria-keyshortcuts="ArrowLeft ArrowRight Backspace" tabindex="0" @keydown="onKeyDown">
123
- <div v-if="over" :class="styles.empty"><slot name="empty">{{ empty }}</slot></div>
115
+ <div ref="deck" :class="styles.deck" data-slot="swipe-deck-stack" role="group" :aria-roledescription="labels.deck" :aria-label="label" aria-keyshortcuts="ArrowLeft ArrowRight Backspace" tabindex="0" @keydown="onKeyDown">
116
+ <div v-if="over" :class="styles.empty" data-slot="swipe-deck-empty"><slot name="empty">{{ labels.empty }}</slot></div>
124
117
  <div
125
118
  v-for="{ item, depth } in shown"
126
119
  :key="getKey(item)"
127
120
  :ref="depth === 0 ? setTop : undefined"
128
121
  :class="styles.card"
122
+ data-slot="swipe-deck-card"
129
123
  :data-depth="depth"
130
124
  :inert="depth > 0"
131
125
  :aria-hidden="depth > 0 || undefined"
@@ -140,26 +134,26 @@ const choose = (dir: SwipeDeckSide) => !over.value && swipe.fly(swipe.physical(d
140
134
  </div>
141
135
  </div>
142
136
  </div>
143
- <div :class="styles.ruler" aria-hidden="true">
137
+ <div :class="styles.ruler" data-slot="swipe-deck-ruler" aria-hidden="true">
144
138
  <span :class="styles.mark" data-side="left" :data-armed="armed === -1 || undefined" />
145
139
  <span :class="styles.centre" />
146
140
  <span :class="styles.mark" data-side="right" :data-armed="armed === 1 || undefined" />
147
141
  <span ref="knob" :class="styles.knob" :data-armed="armed !== 0 || undefined" />
148
142
  </div>
149
- <div :class="styles.bar">
150
- <button :ref="buttonRef('start')" type="button" :class="styles.choice" data-side="start" :aria-disabled="over || undefined" @click="choose('start')">
151
- <span :class="styles.word">{{ actions[0] }}</span>
143
+ <div :class="styles.bar" data-slot="swipe-deck-actions">
144
+ <button :ref="buttonRef('start')" type="button" :class="styles.choice" data-slot="swipe-deck-choice" data-side="start" :aria-disabled="over || undefined" @click="choose('start')">
145
+ <span :class="styles.word">{{ labels.actions[0] }}</span>
152
146
  <span :class="styles.fill" aria-hidden="true">
153
- <span :class="styles.word">{{ actions[0] }}</span>
147
+ <span :class="styles.word">{{ labels.actions[0] }}</span>
154
148
  </span>
155
149
  </button>
156
- <button type="button" :class="styles.undo" :aria-label="undoLabel" :aria-disabled="!done.length || undefined" @click="undo">
150
+ <button type="button" :class="styles.undo" data-slot="swipe-deck-undo" :aria-label="labels.undo" :aria-disabled="!done.length || undefined" @click="undo">
157
151
  <UndoIcon />
158
152
  </button>
159
- <button :ref="buttonRef('end')" type="button" :class="styles.choice" data-side="end" :aria-disabled="over || undefined" @click="choose('end')">
160
- <span :class="styles.word">{{ actions[1] }}</span>
153
+ <button :ref="buttonRef('end')" type="button" :class="styles.choice" data-slot="swipe-deck-choice" data-side="end" :aria-disabled="over || undefined" @click="choose('end')">
154
+ <span :class="styles.word">{{ labels.actions[1] }}</span>
161
155
  <span :class="styles.fill" aria-hidden="true">
162
- <span :class="styles.word">{{ actions[1] }}</span>
156
+ <span :class="styles.word">{{ labels.actions[1] }}</span>
163
157
  </span>
164
158
  </button>
165
159
  </div>
@@ -1,3 +1,4 @@
1
+ @layer gooee.components {
1
2
  .root {
2
3
  display: flex;
3
4
  align-items: center;
@@ -13,9 +14,9 @@
13
14
  .root[data-disabled] { opacity: var(--gooee-disabled-opacity); }
14
15
 
15
16
  .track {
16
- --w: var(--gooee-switch-w);
17
- --h: var(--gooee-switch-h);
18
- --pad: var(--gooee-switch-pad);
17
+ --w: var(--gooee-switch-w, 44px);
18
+ --h: var(--gooee-switch-h, 28px);
19
+ --pad: var(--gooee-switch-pad, 3px);
19
20
  /* The thumb sits inside the line as well as the pad, so the gap round it is even: 1 + 3 = 4. */
20
21
  --thumb: calc(var(--h) - (var(--pad) + var(--gooee-line)) * 2);
21
22
  position: relative;
@@ -28,7 +29,7 @@
28
29
  background: var(--gooee-color-surface);
29
30
  cursor: pointer;
30
31
  -webkit-tap-highlight-color: transparent;
31
- transition: box-shadow var(--gooee-motion-fast) var(--gooee-ease-out);
32
+ transition: box-shadow var(--gooee-motion-fast) var(--gooee-ease-morph);
32
33
  }
33
34
 
34
35
  /* The on fill. Off, it is a dot hidden under the thumb; on, its edges move out to cover the track
@@ -44,7 +45,7 @@
44
45
  transition: clip-path var(--gooee-motion-base) var(--gooee-ease-morph);
45
46
  }
46
47
 
47
- .track[data-on]::before { clip-path: inset(0 round var(--gooee-radius-full)); }
48
+ .track[data-state="checked"]::before { clip-path: inset(0 round var(--gooee-radius-full)); }
48
49
 
49
50
  /* While the thumb stretches across (Switch.tsx), the fill's edge rides on it. */
50
51
  .track[data-moving]::before { clip-path: var(--fill); transition: none; }
@@ -72,16 +73,16 @@
72
73
  border-radius: var(--gooee-radius-full);
73
74
  background: var(--gooee-color-border-strong);
74
75
  /* Its move is played by Switch.tsx; CSS holds the end state. */
75
- transition: background-color var(--gooee-motion-base) var(--gooee-ease-out);
76
+ transition: background-color var(--gooee-motion-base) var(--gooee-ease-morph);
76
77
  }
77
78
 
78
79
  /* Both on and off pass 3:1 contrast */
79
- .track[data-on] .thumb {
80
+ .track[data-state="checked"] .thumb {
80
81
  background: var(--gooee-color-accent-fg);
81
82
  box-shadow: var(--gooee-shadow-thumb);
82
83
  }
83
84
 
84
- .track[data-on] .thumb {
85
+ .track[data-state="checked"] .thumb {
85
86
  transform: translateX(calc(var(--w) - var(--thumb) - (var(--pad) + var(--gooee-line)) * 2));
86
87
  }
87
88
 
@@ -97,3 +98,4 @@
97
98
  font-size: var(--gooee-text-sm);
98
99
  color: var(--gooee-color-fg-muted);
99
100
  }
101
+ }
@@ -49,7 +49,7 @@ export function Switch({
49
49
  useLayoutEffect(() => thumb.current!.set(checked), [checked])
50
50
  useLayoutEffect(() => () => thumb.current!.destroy(), [])
51
51
  return (
52
- <div className={cx(styles.root, labelPosition === 'start' && styles.start, className)} data-disabled={disabled || undefined}>
52
+ <div className={cx(styles.root, labelPosition === 'start' && styles.start, className)} data-slot="switch" data-state={checked ? 'checked' : 'unchecked'} data-disabled={disabled || undefined}>
53
53
  <button
54
54
  id={switchId}
55
55
  type="button"
@@ -57,7 +57,8 @@ export function Switch({
57
57
  aria-checked={checked}
58
58
  aria-describedby={describedBy || undefined}
59
59
  className={styles.track}
60
- data-on={checked || undefined}
60
+ data-slot="switch-track"
61
+ data-state={checked ? 'checked' : 'unchecked'}
61
62
  disabled={disabled}
62
63
  onClick={(e) => {
63
64
  setChecked(!checked)
@@ -65,11 +66,11 @@ export function Switch({
65
66
  }}
66
67
  {...rest}
67
68
  >
68
- <span ref={thumbRef} className={styles.thumb} aria-hidden="true" />
69
+ <span ref={thumbRef} className={styles.thumb} data-slot="switch-thumb" aria-hidden="true" />
69
70
  </button>
70
71
  <span className={styles.text}>
71
- <label htmlFor={switchId} className={styles.label}>{label}</label>
72
- {description && <span id={`${switchId}-desc`} className={styles.description}>{description}</span>}
72
+ <label htmlFor={switchId} className={styles.label} data-slot="field-label">{label}</label>
73
+ {description && <span id={`${switchId}-desc`} className={styles.description} data-slot="switch-description">{description}</span>}
73
74
  </span>
74
75
  {/* Submits like a checkbox: "on" when on, nothing when off */}
75
76
  {name && checked && <input type="hidden" name={name} value="on" />}