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
@@ -1,37 +1,46 @@
1
1
  <script setup lang="ts">
2
- import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
3
- import { ChevronLeftIcon, ChevronRightIcon } from '../../internal/vueIcons'
2
+ import { computed, onBeforeUnmount, onMounted, ref, useId, watch } from 'vue'
3
+ import FieldMessage from '../../internal/FieldMessage.vue'
4
+ import { motionMs } from '../../internal/motion'
5
+ import { createMorph } from '../../internal/motion/liquid'
6
+ import Roll from '../../internal/Roll.vue'
7
+ import { ChevronLeftIcon, ChevronRightIcon } from '../../icons/vue'
8
+ import { defaultPaginationLabels, readPage, splitPageOf, type PaginationLabels } from './labels'
4
9
  import { pageRange } from './range'
5
10
  import styles from './Pagination.module.css'
6
11
 
7
- // The Vue Pagination: the same look (Pagination.module.css) and gliding pill as the React one.
8
-
9
- const props = withDefaults(
10
- defineProps<{
11
- /** Total number of pages. Pages count from 1. */
12
- pageCount: number
13
- /** Starting page when there is no v-model:page. */
14
- defaultPage?: number
15
- /** Pages shown on each side of the current one. */
16
- siblings?: number
17
- /** Screen reader name for the nav landmark. */
18
- label?: string
19
- /** Screen reader name for the previous button. */
20
- previousLabel?: string
21
- /** Screen reader name for the next button. */
22
- nextLabel?: string
23
- /** Builds the screen reader name for each page button. */
24
- pageLabel?: (page: number) => string
25
- }>(),
26
- { defaultPage: 1, siblings: 1, label: 'Pagination', previousLabel: 'Previous page', nextLabel: 'Next page', pageLabel: (p: number) => `Page ${p}` },
27
- )
12
+ // The Vue Pagination: the same look (Pagination.module.css) and motion as the React one.
13
+
14
+ const {
15
+ pageCount,
16
+ defaultPage = 1,
17
+ variant = 'row',
18
+ siblings = 1,
19
+ label = 'Pagination',
20
+ labels,
21
+ } = defineProps<{
22
+ /** Total number of pages. Pages count from 1. */
23
+ pageCount: number
24
+ /** Starting page when there is no v-model:page. */
25
+ defaultPage?: number
26
+ /** "row" shows the page numbers. "compact" shows Page 5 of 12 over a line that fills, and the number opens a Go to page field. */
27
+ variant?: 'row' | 'compact'
28
+ /** Pages shown on each side of the current one, in the row. */
29
+ siblings?: number
30
+ /** Screen reader name for the nav landmark. */
31
+ label?: string
32
+ /** The words it shows and says. Pass only the ones you change. */
33
+ labels?: Partial<PaginationLabels>
34
+ }>()
28
35
 
29
36
  /** Current page, counting from 1. Use v-model:page, or leave it out and the part keeps its own state. */
30
37
  const model = defineModel<number | undefined>('page', { default: undefined })
31
- const local = ref(props.defaultPage)
38
+ const t = computed<PaginationLabels>(() => ({ ...defaultPaginationLabels, ...labels }))
39
+ const local = ref(defaultPage)
40
+ const count = computed(() => Math.max(pageCount, 1))
32
41
  // A stored page can sit past the end after pageCount drops.
33
- const page = computed(() => Math.min(Math.max(model.value ?? local.value, 1), Math.max(props.pageCount, 1)))
34
- const pages = computed(() => pageRange(page.value, props.pageCount, props.siblings))
42
+ const page = computed(() => Math.min(Math.max(model.value ?? local.value, 1), count.value))
43
+ const pages = computed(() => pageRange(page.value, pageCount, siblings))
35
44
 
36
45
  const list = ref<HTMLUListElement | null>(null)
37
46
  const pill = ref<{ x: number; w: number } | null>(null)
@@ -55,32 +64,188 @@ onMounted(() => {
55
64
  ro = new ResizeObserver(measure)
56
65
  if (list.value) ro.observe(list.value)
57
66
  })
58
- watch([page, () => props.pageCount, () => props.siblings], () => (measure(), center()), { flush: 'post' })
59
- onBeforeUnmount(() => ro?.disconnect())
67
+ watch(list, (el, was) => {
68
+ if (was) ro?.unobserve(was)
69
+ if (el) ro?.observe(el)
70
+ })
71
+ watch([page, () => pageCount, () => siblings, () => variant], () => (measure(), center()), { flush: 'post' })
60
72
 
61
73
  const go = (p: number) => {
62
- const next = Math.min(Math.max(p, 1), props.pageCount)
74
+ const next = Math.min(Math.max(p, 1), count.value)
63
75
  if (next === page.value) return
64
76
  local.value = next
65
77
  model.value = next
66
78
  }
79
+
80
+ // The compact view.
81
+ const id = useId()
82
+ const editing = ref(false)
83
+ // The field stays shown while it folds back into the number.
84
+ const shown = ref(false)
85
+ const text = ref('')
86
+ const error = ref('')
87
+ const said = ref('')
88
+ const num = ref<HTMLButtonElement | null>(null)
89
+ const field = ref<HTMLDivElement | null>(null)
90
+ const input = ref<HTMLInputElement | null>(null)
91
+ const liquid = createMorph(() => field.value, { origin: () => num.value })
92
+ let refocus = false
93
+ let folding = 0
94
+
95
+ // Presses faster than the roll swap the number in place, so a held key never stacks rolls.
96
+ let lastAt = 0
97
+ const still = ref(false)
98
+ watch(
99
+ page,
100
+ (now) => {
101
+ const at = performance.now()
102
+ still.value = at - lastAt < motionMs('fast')
103
+ lastAt = at
104
+ // Read out after a change only, not when the page first shows.
105
+ said.value = t.value.pageOf(now, count.value)
106
+ },
107
+ { flush: 'sync' },
108
+ )
109
+
110
+ const words = computed(() => t.value.pageOf(page.value, count.value))
111
+ const parts = computed(() => splitPageOf(words.value, page.value))
112
+
113
+ // The field grows out of the number and folds back into it. Only its clip moves.
114
+ watch(
115
+ editing,
116
+ (now) => {
117
+ clearTimeout(folding)
118
+ if (now) {
119
+ input.value?.focus({ preventScroll: true })
120
+ liquid.play('open')
121
+ return
122
+ }
123
+ liquid.play('closed')
124
+ if (refocus) num.value?.focus({ preventScroll: true })
125
+ refocus = false
126
+ folding = window.setTimeout(() => (shown.value = false), motionMs('morph-out'))
127
+ },
128
+ { flush: 'post' },
129
+ )
130
+ onBeforeUnmount(() => {
131
+ ro?.disconnect()
132
+ clearTimeout(folding)
133
+ liquid.destroy()
134
+ })
135
+
136
+ // The value is bound as an attribute, as React writes it, so the field itself is set and read here.
137
+ const typed = (e: Event) => {
138
+ text.value = (e.target as HTMLInputElement).value
139
+ error.value = ''
140
+ }
141
+
142
+ const open = () => {
143
+ text.value = ''
144
+ if (input.value) input.value.value = ''
145
+ error.value = ''
146
+ shown.value = true
147
+ editing.value = true
148
+ }
149
+
150
+ const fold = (focus: boolean) => {
151
+ refocus = focus
152
+ editing.value = false
153
+ error.value = ''
154
+ }
155
+
156
+ const submit = () => {
157
+ const n = readPage(text.value, count.value)
158
+ if (n === null) {
159
+ error.value = t.value.outOfRange(count.value)
160
+ const el = field.value
161
+ if (el) {
162
+ // Replays the shake on every wrong try.
163
+ delete el.dataset.shake
164
+ void el.offsetWidth
165
+ el.dataset.shake = ''
166
+ }
167
+ return
168
+ }
169
+ go(n)
170
+ fold(true)
171
+ }
172
+
173
+ const keys = (e: KeyboardEvent) => {
174
+ if (e.key === 'Enter') {
175
+ e.preventDefault()
176
+ submit()
177
+ } else if (e.key === 'Escape') {
178
+ e.preventDefault()
179
+ e.stopPropagation()
180
+ fold(true)
181
+ }
182
+ }
183
+
184
+ // A press on the label or the border would take focus off the input and fold the field.
185
+ const hold = (e: MouseEvent) => {
186
+ if (e.target !== input.value) e.preventDefault()
187
+ }
188
+
189
+ const blur = (e: FocusEvent) => {
190
+ if (editing.value && !(e.currentTarget as HTMLElement).contains(e.relatedTarget as Node | null)) fold(false)
191
+ }
67
192
  </script>
68
193
 
69
194
  <template>
70
- <nav :aria-label="label" :class="styles.root">
71
- <button type="button" :class="[styles.btn, styles.edge]" :aria-label="previousLabel" :disabled="page <= 1" @click="go(page - 1)">
195
+ <nav :aria-label="label" :class="styles.root" data-slot="pagination" :data-variant="variant">
196
+ <button type="button" :class="[styles.btn, styles.edge]" data-slot="pagination-previous" :aria-label="t.previous" :disabled="page <= 1" @click="go(page - 1)">
72
197
  <ChevronLeftIcon />
73
198
  </button>
74
- <ul ref="list" :class="styles.list">
75
- <li v-if="pill" aria-hidden="true" :class="styles.pill" :data-ready="ready || undefined" :style="{ transform: `translateX(${pill.x}px)`, width: `${pill.w}px` }" />
199
+ <div v-if="variant === 'compact'" :class="styles.middle">
200
+ <button ref="num" type="button" :class="[styles.btn, styles.current]" data-slot="pagination-current" :aria-label="`${words}, ${t.goTo}`" :inert="editing" @click="open">
201
+ <span :class="styles.words"
202
+ ><template v-if="parts"
203
+ >{{ parts[0]
204
+ }}<span :class="styles.num"
205
+ ><span :class="styles.ghost">{{ count }}</span
206
+ ><Roll :text="String(page)" :still="still" /></span
207
+ >{{ parts[1] }}</template
208
+ ><template v-else>{{ words }}</template></span
209
+ >
210
+ <span :class="styles.line" aria-hidden="true">
211
+ <span :class="styles.fill" :style="{ transform: `scaleX(${page / count})` }" />
212
+ </span>
213
+ </button>
214
+ <div ref="field" :class="styles.jump" data-slot="pagination-jump" :data-state="shown ? 'open' : 'closed'" :data-invalid="error ? '' : undefined" :inert="!editing" @mousedown="hold" @focusout="blur">
215
+ <label :for="`${id}-to`" :class="styles.jumpLabel" data-slot="field-label">{{ t.goTo }}</label>
216
+ <input
217
+ :id="`${id}-to`"
218
+ ref="input"
219
+ :value.attr="text"
220
+ :class="styles.input"
221
+ data-slot="pagination-jump-input"
222
+ type="text"
223
+ inputmode="numeric"
224
+ enterkeyhint="go"
225
+ autocomplete="off"
226
+ :size="String(count).length + 1"
227
+ :placeholder="String(page)"
228
+ :aria-invalid="error ? true : undefined"
229
+ :aria-describedby="error ? `${id}-error` : undefined"
230
+ @input="typed"
231
+ @keydown="keys"
232
+ />
233
+ </div>
234
+ <div :class="styles.message">
235
+ <FieldMessage :help-id="`${id}-help`" :error-id="`${id}-error`" :error="error || undefined" />
236
+ </div>
237
+ <span :class="styles.srOnly" aria-live="polite">{{ said }}</span>
238
+ </div>
239
+ <ul v-else ref="list" :class="styles.list" data-slot="pagination-list">
240
+ <li v-if="pill" aria-hidden="true" :class="styles.pill" data-slot="pagination-indicator" :data-ready="ready || undefined" :style="{ transform: `translateX(${pill.x}px)`, width: `${pill.w}px` }" />
76
241
  <template v-for="(p, i) in pages" :key="p === 'gap' ? `gap-${i}` : p">
77
- <li v-if="p === 'gap'" :class="styles.gap" aria-hidden="true">…</li>
242
+ <li v-if="p === 'gap'" :class="styles.gap" data-slot="pagination-ellipsis" aria-hidden="true">…</li>
78
243
  <li v-else>
79
- <button type="button" :class="styles.btn" :aria-label="pageLabel(p)" :aria-current="p === page ? 'page' : undefined" @click="go(p)">{{ p }}</button>
244
+ <button type="button" :class="styles.btn" data-slot="pagination-item" :aria-label="t.page(p)" :aria-current="p === page ? 'page' : undefined" @click="go(p)">{{ p }}</button>
80
245
  </li>
81
246
  </template>
82
247
  </ul>
83
- <button type="button" :class="[styles.btn, styles.edge]" :aria-label="nextLabel" :disabled="page >= pageCount" @click="go(page + 1)">
248
+ <button type="button" :class="[styles.btn, styles.edge]" data-slot="pagination-next" :aria-label="t.next" :disabled="page >= pageCount" @click="go(page + 1)">
84
249
  <ChevronRightIcon />
85
250
  </button>
86
251
  </nav>
@@ -0,0 +1,38 @@
1
+ // Pagination's text, shared by React and Vue.
2
+
3
+ export type PaginationLabels = {
4
+ /** Screen reader name for the previous button. */
5
+ previous: string
6
+ /** Screen reader name for the next button. */
7
+ next: string
8
+ /** Screen reader name for each page button in the row. */
9
+ page: (page: number) => string
10
+ /** The compact view's words. The page number in them rolls when it changes. */
11
+ pageOf: (page: number, count: number) => string
12
+ /** The visible label of the compact view's Go to page field. */
13
+ goTo: string
14
+ /** Shown under the field when the typed page does not exist. */
15
+ outOfRange: (count: number) => string
16
+ }
17
+
18
+ export const defaultPaginationLabels: PaginationLabels = {
19
+ previous: 'Previous page',
20
+ next: 'Next page',
21
+ page: (page) => `Page ${page}`,
22
+ pageOf: (page, count) => `Page ${page} of ${count}`,
23
+ goTo: 'Go to page',
24
+ outOfRange: (count) => `Pick a page from 1 to ${count}`,
25
+ }
26
+
27
+ /** The compact words cut around the page number, so only the number rolls. With no number in them, they show whole. */
28
+ export function splitPageOf(words: string, page: number): [string, string] | null {
29
+ const at = words.search(new RegExp(`(?<!\\d)${page}(?!\\d)`))
30
+ return at < 0 ? null : [words.slice(0, at), words.slice(at + String(page).length)]
31
+ }
32
+
33
+ /** The typed page, or null when it is not a whole page from 1 to count. */
34
+ export function readPage(text: string, count: number): number | null {
35
+ const t = text.trim()
36
+ const n = Number(t)
37
+ return /^\d+$/.test(t) && n >= 1 && n <= count ? n : null
38
+ }
@@ -1,3 +1,4 @@
1
+ @layer gooee.components {
1
2
  /* Hide the browser's own reveal button */
2
3
  .root input::-ms-reveal { display: none; }
3
4
 
@@ -15,9 +16,9 @@
15
16
  color: var(--gooee-color-fg-muted);
16
17
  cursor: pointer;
17
18
  transition:
18
- background-color var(--gooee-motion-fast) var(--gooee-ease-out),
19
- color var(--gooee-motion-fast) var(--gooee-ease-out),
20
- transform var(--gooee-motion-slow) var(--gooee-ease-spring);
19
+ background-color var(--gooee-motion-fast) var(--gooee-ease-morph),
20
+ color var(--gooee-motion-fast) var(--gooee-ease-morph),
21
+ transform var(--gooee-motion-slow) var(--gooee-ease-morph);
21
22
  }
22
23
 
23
24
  .toggle::after {
@@ -48,17 +49,18 @@
48
49
  .pupil {
49
50
  transform-box: fill-box;
50
51
  transform-origin: center;
51
- transition: transform var(--gooee-motion-slow) var(--gooee-ease-spring);
52
+ transition: transform var(--gooee-motion-slow) var(--gooee-ease-morph);
52
53
  }
53
54
 
54
- .eye[data-open] .lid { transform: scaleY(0.82); }
55
- .eye[data-open] .pupil { transform: scale(0.8); }
55
+ .toggle[data-state="on"] .eye .lid { transform: scaleY(0.82); }
56
+ .toggle[data-state="on"] .eye .pupil { transform: scale(0.8); }
56
57
 
57
58
  .slash {
58
59
  /* Hidden just before the path starts. A zero-length dash would leave its round ends as a dot in Safari. */
59
60
  stroke-dasharray: 1 2;
60
61
  stroke-dashoffset: 1.01;
61
- transition: stroke-dashoffset var(--gooee-motion-base) var(--gooee-ease-out);
62
+ transition: stroke-dashoffset var(--gooee-motion-base) var(--gooee-ease-morph);
62
63
  }
63
64
 
64
- .eye[data-open] .slash { stroke-dashoffset: 0; }
65
+ .toggle[data-state="on"] .eye .slash { stroke-dashoffset: 0; }
66
+ }
@@ -2,25 +2,30 @@
2
2
 
3
3
  import { useState } from 'react'
4
4
  import { cx } from '../../internal/cx'
5
- import { Input, type InputProps } from '../Input'
5
+ import { Input, type InputLabels, type InputProps } from '../Input'
6
6
  import styles from './PasswordInput.module.css'
7
7
 
8
- export type PasswordInputProps = Omit<InputProps, 'type' | 'trailing'> & {
8
+ export type PasswordInputLabels = InputLabels & {
9
+ /** Name of the toggle. It stays the same; aria-pressed says whether it is on. */
10
+ toggle: string
11
+ }
12
+
13
+ export type PasswordInputProps = Omit<InputProps, 'type' | 'trailing' | 'labels'> & {
9
14
  /** Start with the password shown. */
10
15
  defaultVisible?: boolean
11
16
  /** Whether the password shows as plain text, when you control it. */
12
17
  visible?: boolean
13
18
  /** Called when the show button is pressed, with the new visible state. */
14
19
  onVisibleChange?: (visible: boolean) => void
15
- /** Name of the toggle. It stays the same; aria-pressed says whether it is on. */
16
- toggleLabel?: string
20
+ /** Text for the label and the toggle, so you can translate it. Missing keys use the English defaults. */
21
+ labels?: Partial<PasswordInputLabels>
17
22
  }
18
23
 
19
24
  export function PasswordInput({
20
25
  defaultVisible = false,
21
26
  visible: visibleProp,
22
27
  onVisibleChange,
23
- toggleLabel = 'Show password',
28
+ labels,
24
29
  autoComplete = 'current-password',
25
30
  disabled,
26
31
  className,
@@ -36,6 +41,7 @@ export function PasswordInput({
36
41
  return (
37
42
  <Input
38
43
  {...rest}
44
+ labels={labels}
39
45
  className={cx(styles.root, className)}
40
46
  type={visible ? 'text' : 'password'}
41
47
  autoComplete={autoComplete}
@@ -46,12 +52,14 @@ export function PasswordInput({
46
52
  <button
47
53
  type="button"
48
54
  className={styles.toggle}
49
- aria-label={toggleLabel}
55
+ data-slot="password-input-toggle"
56
+ data-state={visible ? 'on' : 'off'}
57
+ aria-label={labels?.toggle ?? 'Show password'}
50
58
  aria-pressed={visible}
51
59
  disabled={disabled}
52
60
  onClick={toggle}
53
61
  >
54
- <svg viewBox="0 0 24 24" className={styles.eye} data-open={visible || undefined} aria-hidden="true" focusable="false">
62
+ <svg viewBox="0 0 24 24" className={styles.eye} aria-hidden="true" focusable="false">
55
63
  <path className={styles.lid} d="M2.5 12s3.5-6.5 9.5-6.5 9.5 6.5 9.5 6.5-3.5 6.5-9.5 6.5S2.5 12 2.5 12z" />
56
64
  <circle className={styles.pupil} cx="12" cy="12" r="2.75" />
57
65
  <path className={styles.slash} d="M4 4l16 16" pathLength={1} />
@@ -1,27 +1,30 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, ref } from 'vue'
3
- import Input from '../Input/Input.vue'
3
+ import Input, { type InputLabels } from '../Input/Input.vue'
4
4
  import styles from './PasswordInput.module.css'
5
5
 
6
6
  // The Vue PasswordInput: an Input with a show and hide toggle, the same look (PasswordInput.module.css) as the React one.
7
7
  // Every Input prop and attribute passes through; autocomplete defaults to current-password.
8
- const props = withDefaults(
9
- defineProps<{
10
- /** Always required. A placeholder is only an example, never the label. */
11
- label: string
12
- /** Start with the password shown, when there is no v-model:visible. */
13
- defaultVisible?: boolean
14
- /** Name of the toggle. It stays the same; aria-pressed says whether it is on. */
15
- toggleLabel?: string
16
- disabled?: boolean
17
- }>(),
18
- { defaultVisible: false, toggleLabel: 'Show password' },
19
- )
8
+
9
+ export type PasswordInputLabels = InputLabels & {
10
+ /** Name of the toggle. It stays the same; aria-pressed says whether it is on. */
11
+ toggle: string
12
+ }
13
+
14
+ const { defaultVisible = false } = defineProps<{
15
+ /** Always required. A placeholder is only an example, never the label. */
16
+ label: string
17
+ /** Start with the password shown, when there is no v-model:visible. */
18
+ defaultVisible?: boolean
19
+ /** Text for the label and the toggle, so you can translate it. Missing keys use the English defaults. */
20
+ labels?: Partial<PasswordInputLabels>
21
+ disabled?: boolean
22
+ }>()
20
23
  /** The text, passed to the Input. */
21
24
  const model = defineModel<string>()
22
25
  /** Whether the password shows as plain text. Use v-model:visible, or leave it out and the field keeps its own state. */
23
26
  const visibleModel = defineModel<boolean | undefined>('visible', { default: undefined })
24
- const inner = ref(props.defaultVisible)
27
+ const inner = ref(defaultVisible)
25
28
  const visible = computed(() => visibleModel.value ?? inner.value)
26
29
  const toggle = () => {
27
30
  inner.value = !visible.value
@@ -33,6 +36,7 @@ const toggle = () => {
33
36
  <Input
34
37
  v-model="model"
35
38
  :label="label"
39
+ :labels="labels"
36
40
  :class="styles.root"
37
41
  :type="visible ? 'text' : 'password'"
38
42
  autocomplete="current-password"
@@ -41,8 +45,8 @@ const toggle = () => {
41
45
  :disabled="disabled"
42
46
  >
43
47
  <template #trailing>
44
- <button type="button" :class="styles.toggle" :aria-label="toggleLabel" :aria-pressed="visible" :disabled="disabled" @click="toggle">
45
- <svg viewBox="0 0 24 24" :class="styles.eye" :data-open="visible || undefined" aria-hidden="true" focusable="false">
48
+ <button type="button" :class="styles.toggle" data-slot="password-input-toggle" :data-state="visible ? 'on' : 'off'" :aria-label="labels?.toggle ?? 'Show password'" :aria-pressed="visible" :disabled="disabled" @click="toggle">
49
+ <svg viewBox="0 0 24 24" :class="styles.eye" aria-hidden="true" focusable="false">
46
50
  <path :class="styles.lid" d="M2.5 12s3.5-6.5 9.5-6.5 9.5 6.5 9.5 6.5-3.5 6.5-9.5 6.5S2.5 12 2.5 12z" />
47
51
  <circle :class="styles.pupil" cx="12" cy="12" r="2.75" />
48
52
  <path :class="styles.slash" d="M4 4l16 16" pathLength="1" />
@@ -1,2 +1,2 @@
1
1
  export { PasswordInput } from './PasswordInput'
2
- export type { PasswordInputProps } from './PasswordInput'
2
+ export type { PasswordInputLabels, PasswordInputProps } from './PasswordInput'
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, ref } from 'vue'
2
+ import { computed, ref, watch } from 'vue'
3
3
  import { dateWheel, today } from '../../internal/motion/pickerWheel'
4
4
  import PickerWheel from './PickerWheel.vue'
5
5
 
@@ -18,10 +18,10 @@ const props = defineProps<{
18
18
  /** Dates, as "YYYY-MM-DD", drawn stronger. Undefined is today. */
19
19
  strong?: string[]
20
20
  }>()
21
- const emit = defineEmits<{ /** The date in the band while the wheel still turns, as "YYYY-MM-DD". */ scrub: [value: string] }>()
21
+ const emit = defineEmits<{ /** The date, as "YYYY-MM-DD", once the wheel comes to rest on a new one. */ valueCommit: [value: string] }>()
22
22
 
23
23
  const now = today()
24
- /** The date as "YYYY-MM-DD", set once the wheel comes to rest. Use v-model, or leave it out and the wheel keeps its own date. */
24
+ /** The date in the band as "YYYY-MM-DD", set each time it changes while the wheel turns. Use v-model, or leave it out and the wheel keeps its own date. */
25
25
  const model = defineModel<string>()
26
26
  const local = ref(props.defaultValue ?? now)
27
27
  const value = computed({
@@ -31,18 +31,26 @@ const value = computed({
31
31
  model.value = next
32
32
  },
33
33
  })
34
- const wheel = computed(() => dateWheel(value.value, now, props.fromYear, props.toYear, props.strong))
34
+ // The days follow the month the wheel rests on, not each month that turns past (31 stays 31 on the way
35
+ // through February). A date from outside, not one this wheel told, is a new rest.
36
+ let told = value.value
37
+ const rested = ref(value.value)
38
+ watch(value, (v) => v !== told && (rested.value = v), { flush: 'sync' })
39
+ const wheel = computed(() => dateWheel(rested.value, now, props.fromYear, props.toYear, props.strong))
40
+ const onChange = (rows: number[] | undefined) => {
41
+ if (!rows) return
42
+ told = wheel.value.toDate(rows)
43
+ value.value = told
44
+ }
45
+ const onCommit = (rows: number[]) => {
46
+ told = wheel.value.toDate(rows)
47
+ rested.value = told
48
+ emit('valueCommit', told)
49
+ }
35
50
  </script>
36
51
 
37
52
  <template>
38
- <PickerWheel
39
- :label="label"
40
- :columns="wheel.columns"
41
- :model-value="wheel.rows"
42
- :format-value="wheel.show"
43
- @update:model-value="(rows) => rows && (value = wheel.toDate(rows))"
44
- @scrub="emit('scrub', wheel.toDate($event))"
45
- >
53
+ <PickerWheel :label="label" :columns="wheel.columns" :model-value="wheel.rows" :format-value="wheel.show" @update:model-value="onChange" @value-commit="onCommit">
46
54
  <template v-for="(_, name) in $slots" #[name]><slot :name="name" /></template>
47
55
  </PickerWheel>
48
56
  </template>
@@ -1,3 +1,11 @@
1
+ /* The script reads this token, so each is registered with its default: set it on :root to change it. */
2
+ @property --gooee-picker-wheel-tilt {
3
+ syntax: '<angle>';
4
+ inherits: true;
5
+ initial-value: 18deg;
6
+ }
7
+
8
+ @layer gooee.components {
1
9
  .root {
2
10
  display: grid;
3
11
  gap: var(--gooee-space-5);
@@ -37,12 +45,12 @@
37
45
  }
38
46
 
39
47
  .column {
40
- /* The drum's radius, so each row of --gooee-hit-min turns by --gooee-wheel-tilt. */
41
- --wheel-r: calc(var(--gooee-hit-min) / 2 / tan(var(--gooee-wheel-tilt) / 2));
48
+ /* The drum's radius, so each row of --gooee-hit-min turns by --gooee-picker-wheel-tilt. */
49
+ --wheel-r: calc(var(--gooee-hit-min) / 2 / tan(var(--gooee-picker-wheel-tilt) / 2));
42
50
  position: relative;
43
51
  flex: none;
44
- width: var(--gooee-wheel-w);
45
- height: calc(var(--gooee-wheel-rows) * var(--gooee-hit-min));
52
+ width: var(--gooee-picker-wheel-w, 64px);
53
+ height: calc(var(--gooee-picker-wheel-rows, 5) * var(--gooee-hit-min));
46
54
  perspective: calc(var(--wheel-r) * 7);
47
55
  touch-action: none;
48
56
  cursor: grab;
@@ -54,7 +62,7 @@
54
62
  }
55
63
 
56
64
  .column[data-wide] {
57
- width: calc(var(--gooee-wheel-w) * 2);
65
+ width: calc(var(--gooee-picker-wheel-w, 64px) * 2);
58
66
  }
59
67
 
60
68
  .column[data-moving] {
@@ -109,7 +117,7 @@
109
117
  font-variant-numeric: tabular-nums;
110
118
  white-space: nowrap;
111
119
  backface-visibility: hidden;
112
- transform: rotateX(calc(var(--d) * -1 * var(--gooee-wheel-tilt))) translateZ(var(--wheel-r));
120
+ transform: rotateX(calc(var(--d) * -1 * var(--gooee-picker-wheel-tilt))) translateZ(var(--wheel-r));
113
121
  }
114
122
 
115
123
  .row[data-strong]::after {
@@ -121,3 +129,4 @@
121
129
  border-radius: var(--gooee-radius-full);
122
130
  background: currentColor;
123
131
  }
132
+ }