gooee 0.50.0 → 0.51.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 (172) hide show
  1. package/README.md +17 -4
  2. package/package.json +5 -3
  3. package/scripts/add.js +28 -6
  4. package/src/components/Accordion/Accordion.vue +62 -0
  5. package/src/components/Accordion/AccordionItem.vue +45 -0
  6. package/src/components/Accordion/accordionContext.ts +6 -0
  7. package/src/components/Alert/Alert.tsx +7 -27
  8. package/src/components/Alert/Alert.vue +59 -0
  9. package/src/components/AlertDialog/AlertDialog.vue +126 -0
  10. package/src/components/AnimatedNumber/AnimatedNumber.vue +36 -0
  11. package/src/components/AspectRatio/AspectRatio.vue +17 -0
  12. package/src/components/Avatar/Avatar.vue +56 -0
  13. package/src/components/AvatarGroup/AvatarGroup.vue +42 -0
  14. package/src/components/Badge/Badge.vue +32 -0
  15. package/src/components/Breadcrumb/Breadcrumb.vue +58 -0
  16. package/src/components/Button/Button.vue +130 -0
  17. package/src/components/ButtonGroup/ButtonGroup.tsx +4 -21
  18. package/src/components/ButtonGroup/ButtonGroup.vue +33 -0
  19. package/src/components/Card/Card.vue +34 -0
  20. package/src/components/Center/Center.vue +32 -0
  21. package/src/components/Checkbox/Checkbox.tsx +8 -25
  22. package/src/components/Checkbox/Checkbox.vue +108 -0
  23. package/src/components/CheckboxGroup/CheckboxGroup.vue +76 -0
  24. package/src/components/Cluster/Cluster.vue +34 -0
  25. package/src/components/CodeBlock/CodeBlock.vue +45 -0
  26. package/src/components/Collapsible/Collapsible.vue +59 -0
  27. package/src/components/Container/Container.vue +22 -0
  28. package/src/components/CopyButton/CopyButton.tsx +3 -49
  29. package/src/components/CopyButton/CopyButton.vue +116 -0
  30. package/src/components/Dial/Dial.tsx +12 -120
  31. package/src/components/Dial/Dial.vue +228 -0
  32. package/src/components/Dialog/Dialog.vue +139 -0
  33. package/src/components/Divider/Divider.vue +27 -0
  34. package/src/components/DropdownMenu/DropdownMenu.tsx +11 -46
  35. package/src/components/DropdownMenu/DropdownMenu.vue +185 -0
  36. package/src/components/EmptyState/EmptyState.vue +33 -0
  37. package/src/components/Fab/Fab.tsx +4 -14
  38. package/src/components/Fab/Fab.vue +115 -0
  39. package/src/components/Fieldset/Fieldset.vue +42 -0
  40. package/src/components/FormField/FormField.tsx +2 -17
  41. package/src/components/FormField/FormField.vue +64 -0
  42. package/src/components/Grid/Grid.vue +43 -0
  43. package/src/components/HoldToConfirm/HoldToConfirm.tsx +13 -143
  44. package/src/components/HoldToConfirm/HoldToConfirm.vue +281 -0
  45. package/src/components/IconButton/IconButton.vue +25 -0
  46. package/src/components/Input/Input.vue +112 -0
  47. package/src/components/InputGroup/InputGroup.vue +102 -0
  48. package/src/components/Kbd/Kbd.tsx +2 -12
  49. package/src/components/Kbd/Kbd.vue +21 -0
  50. package/src/components/Link/Link.vue +38 -0
  51. package/src/components/LivePill/LivePill.tsx +11 -39
  52. package/src/components/LivePill/LivePill.vue +152 -0
  53. package/src/components/Meter/Meter.vue +88 -0
  54. package/src/components/MorphButton/MorphButton.tsx +11 -67
  55. package/src/components/MorphButton/MorphButton.vue +120 -0
  56. package/src/components/NumberInput/NumberInput.tsx +11 -48
  57. package/src/components/NumberInput/NumberInput.vue +184 -0
  58. package/src/components/Pagination/Pagination.tsx +2 -15
  59. package/src/components/Pagination/Pagination.vue +87 -0
  60. package/src/components/Pagination/range.ts +15 -0
  61. package/src/components/PasswordInput/PasswordInput.vue +53 -0
  62. package/src/components/PickerWheel/DateWheel.vue +48 -0
  63. package/src/components/PickerWheel/PickerWheel.tsx +15 -129
  64. package/src/components/PickerWheel/PickerWheel.vue +77 -0
  65. package/src/components/PickerWheel/TimeWheel.vue +50 -0
  66. package/src/components/PickerWheel/WheelColumn.vue +70 -0
  67. package/src/components/Popover/Popover.vue +108 -0
  68. package/src/components/ProgressBar/ProgressBar.vue +48 -0
  69. package/src/components/Prose/Prose.vue +18 -0
  70. package/src/components/Radio/Radio.vue +49 -0
  71. package/src/components/Radio/RadioGroup.vue +69 -0
  72. package/src/components/Retime/Retime.tsx +7 -40
  73. package/src/components/Retime/Retime.vue +64 -0
  74. package/src/components/RulerScrubber/RulerScrubber.tsx +9 -38
  75. package/src/components/RulerScrubber/RulerScrubber.vue +166 -0
  76. package/src/components/ScrollArea/ScrollArea.tsx +17 -129
  77. package/src/components/ScrollArea/ScrollArea.vue +58 -0
  78. package/src/components/SearchInput/SearchInput.tsx +2 -15
  79. package/src/components/SearchInput/SearchInput.vue +70 -0
  80. package/src/components/SegmentedControl/SegmentedControl.tsx +7 -51
  81. package/src/components/SegmentedControl/SegmentedControl.vue +111 -0
  82. package/src/components/Select/Select.tsx +16 -47
  83. package/src/components/Select/Select.vue +236 -0
  84. package/src/components/Sheet/Sheet.tsx +52 -231
  85. package/src/components/Sheet/Sheet.vue +249 -0
  86. package/src/components/Skeleton/Skeleton.vue +38 -0
  87. package/src/components/Slider/Slider.tsx +25 -84
  88. package/src/components/Slider/Slider.vue +113 -0
  89. package/src/components/Spinner/Spinner.vue +30 -0
  90. package/src/components/Split/Split.vue +34 -0
  91. package/src/components/SplitFlap/SplitFlap.tsx +11 -175
  92. package/src/components/SplitFlap/SplitFlap.vue +52 -0
  93. package/src/components/Stack/Stack.vue +22 -0
  94. package/src/components/SwipeDeck/SwipeDeck.tsx +30 -194
  95. package/src/components/SwipeDeck/SwipeDeck.vue +168 -0
  96. package/src/components/Switch/Switch.tsx +6 -75
  97. package/src/components/Switch/Switch.vue +66 -0
  98. package/src/components/Table/Table.module.css +12 -3
  99. package/src/components/Table/Table.tsx +8 -59
  100. package/src/components/Table/Table.vue +274 -0
  101. package/src/components/TableOfContents/TableOfContents.vue +90 -0
  102. package/src/components/Tabs/Tab.vue +37 -0
  103. package/src/components/Tabs/TabList.vue +47 -0
  104. package/src/components/Tabs/TabPanel.vue +26 -0
  105. package/src/components/Tabs/Tabs.module.css +2 -2
  106. package/src/components/Tabs/Tabs.tsx +11 -84
  107. package/src/components/Tabs/Tabs.vue +33 -0
  108. package/src/components/Tabs/tabsContext.ts +15 -0
  109. package/src/components/Tag/Tag.tsx +6 -26
  110. package/src/components/Tag/Tag.vue +63 -0
  111. package/src/components/Textarea/Textarea.tsx +2 -22
  112. package/src/components/Textarea/Textarea.vue +120 -0
  113. package/src/components/ThemeToggle/ThemeToggle.tsx +10 -84
  114. package/src/components/ThemeToggle/ThemeToggle.vue +90 -0
  115. package/src/components/Toast/Toast.tsx +34 -264
  116. package/src/components/Toast/Toast.vue +138 -0
  117. package/src/components/Toast/ToastItem.vue +108 -0
  118. package/src/components/Toggle/Toggle.vue +52 -0
  119. package/src/components/Tooltip/Tooltip.tsx +17 -48
  120. package/src/components/Tooltip/Tooltip.vue +95 -0
  121. package/src/components/VisuallyHidden/VisuallyHidden.vue +17 -0
  122. package/src/internal/FieldMessage.vue +41 -0
  123. package/src/internal/Roll.vue +20 -0
  124. package/src/internal/focus.ts +4 -47
  125. package/src/internal/icons.module.css +39 -27
  126. package/src/internal/layers.ts +7 -61
  127. package/src/internal/motion/alert.ts +17 -0
  128. package/src/internal/motion/buttonGroup.ts +21 -0
  129. package/src/internal/motion/checkbox.ts +39 -0
  130. package/src/internal/motion/collapseOut.ts +26 -0
  131. package/src/internal/motion/copyButton.ts +48 -0
  132. package/src/internal/motion/dial.ts +137 -0
  133. package/src/internal/motion/fab.ts +14 -0
  134. package/src/internal/motion/floating.ts +58 -0
  135. package/src/internal/motion/focus.ts +53 -0
  136. package/src/internal/motion/formField.ts +19 -0
  137. package/src/internal/motion/holdToConfirm.ts +147 -0
  138. package/src/internal/motion/keys.ts +42 -0
  139. package/src/internal/motion/layers.ts +78 -0
  140. package/src/internal/motion/listbox.ts +69 -0
  141. package/src/internal/motion/livePill.ts +71 -0
  142. package/src/internal/motion/menuKeys.ts +58 -0
  143. package/src/internal/motion/morphButton.ts +71 -0
  144. package/src/internal/motion/numberInput.ts +57 -0
  145. package/src/internal/motion/pickerWheel.ts +166 -0
  146. package/src/internal/motion/retime.ts +45 -0
  147. package/src/internal/motion/ruler.ts +57 -0
  148. package/src/internal/motion/scrollArea.ts +133 -0
  149. package/src/internal/motion/scrubLook.ts +15 -0
  150. package/src/internal/motion/segmented.ts +63 -0
  151. package/src/internal/motion/sheetDetents.ts +271 -0
  152. package/src/internal/motion/slider.ts +108 -0
  153. package/src/internal/motion/splitFlap.ts +205 -0
  154. package/src/internal/motion/swipeDeck.ts +236 -0
  155. package/src/internal/motion/switchThumb.ts +83 -0
  156. package/src/internal/motion/table.ts +77 -0
  157. package/src/internal/motion/tabs.ts +105 -0
  158. package/src/internal/motion/textarea.ts +22 -0
  159. package/src/internal/motion/themeIcon.ts +91 -0
  160. package/src/internal/motion/themeReveal.ts +71 -0
  161. package/src/internal/motion/toast.ts +291 -0
  162. package/src/internal/motion/tooltip.ts +58 -0
  163. package/src/internal/themeReveal.ts +3 -61
  164. package/src/internal/useFloating.ts +9 -49
  165. package/src/internal/useScrub.ts +1 -13
  166. package/src/internal/vue/trigger.ts +18 -0
  167. package/src/internal/vue/useFloating.ts +38 -0
  168. package/src/internal/vue/usePresence.ts +21 -0
  169. package/src/internal/vue/useScrub.ts +40 -0
  170. package/src/internal/vueIcons.ts +134 -0
  171. package/src/tokens.css +5 -0
  172. package/src/internal/relativeTime.ts +0 -26
@@ -1,63 +1,5 @@
1
1
  import { flushSync } from 'react-dom'
2
- import { easing, motionMs, prefersReducedMotion } from './motion'
2
+ import { themeReveal as reveal } from './motion/themeReveal'
3
3
 
4
- // The new theme grows from the spot you pressed: the page is snapshot as it is, and the new page opens
5
- // over it in a circle from the button's centre to the farthest corner, at an even pace. The old snapshot
6
- // stays still under it, and no element plays its own colour change meanwhile, so nothing flips piece by
7
- // piece. A second press finishes the running one first. Without View Transitions the page fades in once;
8
- // with reduced motion it changes at once.
9
-
10
- let running: ViewTransition | null = null
11
-
12
- // The radius whose circle covers `share` of the screen, by halving, counted on a coarse grid.
13
- function radiusFor(share: number, x: number, y: number, reach: number) {
14
- if (share >= 1) return reach
15
- const cols = 48, rows = 32
16
- const covered = (r: number) => {
17
- let n = 0
18
- for (let j = 0; j < rows; j++) for (let i = 0; i < cols; i++) if (Math.hypot(((i + 0.5) * innerWidth) / cols - x, ((j + 0.5) * innerHeight) / rows - y) <= r) n++
19
- return n / (cols * rows)
20
- }
21
- let lo = 0, hi = reach
22
- for (let k = 0; k < 18; k++) {
23
- const m = (lo + hi) / 2
24
- if (covered(m) < share) lo = m
25
- else hi = m
26
- }
27
- return hi
28
- }
29
-
30
- export function themeReveal(origin: Element | null, apply: () => void) {
31
- const root = document.documentElement
32
- const ms = motionMs('reveal')
33
- if (prefersReducedMotion() || !ms) return flushSync(apply)
34
- running?.skipTransition()
35
- root.dataset.gooeeThemeSwitch = ''
36
- const done = () => delete root.dataset.gooeeThemeSwitch
37
- if (typeof document.startViewTransition !== 'function') {
38
- flushSync(apply)
39
- document.body.animate([{ opacity: 0.4 }, { opacity: 1 }], { duration: ms * 0.6, easing: easing('morph') }).finished.then(done, done)
40
- return
41
- }
42
- const r = origin?.getBoundingClientRect()
43
- const x = r ? r.left + r.width / 2 : innerWidth / 2
44
- const y = r ? r.top + r.height / 2 : 0
45
- const reach = Math.hypot(Math.max(x, innerWidth - x), Math.max(y, innerHeight - y))
46
- const vt = document.startViewTransition(() => flushSync(apply))
47
- running = vt
48
- vt.ready.then(
49
- // The share of the screen covered grows at an even, calm pace (ease out): a circle's area grows with
50
- // the radius squared, so each step's radius is solved for its share; linear in between.
51
- () =>
52
- root.animate(
53
- { clipPath: Array.from({ length: 21 }, (_, i) => `circle(${radiusFor(1 - (1 - i / 20) ** 2, x, y, reach)}px at ${x}px ${y}px)`) },
54
- { duration: ms, easing: 'linear', pseudoElement: '::view-transition-new(root)' },
55
- ),
56
- () => {},
57
- )
58
- vt.finished.finally(() => {
59
- if (running !== vt) return
60
- running = null
61
- done()
62
- })
63
- }
4
+ /** React's hold on themeReveal (motion/themeReveal.ts): the new theme is put in the page at once with flushSync. */
5
+ export const themeReveal = (origin: Element | null, apply: () => void) => reveal(origin, () => flushSync(apply))
@@ -1,9 +1,7 @@
1
1
  import { useCallback, useLayoutEffect, useState, type CSSProperties, type RefObject } from 'react'
2
+ import { floatingStyle, follow, place, type Align, type Place, type Side } from './motion/floating'
2
3
 
3
- export type Side = 'top' | 'bottom' | 'left' | 'right'
4
- export type Align = 'start' | 'center' | 'end'
5
-
6
- const MARGIN = 8
4
+ export type { Align, Side } from './motion/floating'
7
5
 
8
6
  type Options = {
9
7
  open: boolean
@@ -13,45 +11,20 @@ type Options = {
13
11
  matchWidth?: boolean
14
12
  }
15
13
 
16
- // Before the first measure the layer is see-through, not hidden, so focus can still move into it.
14
+ /** React's hold on place and follow (motion/floating.ts). */
17
15
  export function useFloating(
18
16
  anchorRef: RefObject<HTMLElement | null>,
19
17
  floatingRef: RefObject<HTMLElement | null>,
20
18
  { open, side = 'bottom', align = 'center', offset = 8, matchWidth = false }: Options,
21
19
  ) {
22
- const [pos, setPos] = useState<{ top: number; left: number; side: Side; width?: number } | null>(null)
20
+ const [pos, setPos] = useState<Place | null>(null)
23
21
  // Measured since this open began.
24
22
  const [fresh, setFresh] = useState(false)
25
23
 
26
24
  const update = useCallback(() => {
27
- const a = anchorRef.current
28
- const f = floatingRef.current
29
- if (!a || !f) return
30
- const r = a.getBoundingClientRect()
31
- const width = matchWidth ? r.width : undefined
32
- const fw = width ?? f.offsetWidth
33
- const fh = f.offsetHeight
34
- const vw = window.innerWidth
35
- const vh = window.innerHeight
36
-
37
- let s = side
38
- if (s === 'bottom' && r.bottom + offset + fh > vh - MARGIN && r.top - offset - fh > MARGIN) s = 'top'
39
- else if (s === 'top' && r.top - offset - fh < MARGIN && r.bottom + offset + fh < vh - MARGIN) s = 'bottom'
40
- else if (s === 'right' && r.right + offset + fw > vw - MARGIN && r.left - offset - fw > MARGIN) s = 'left'
41
- else if (s === 'left' && r.left - offset - fw < MARGIN && r.right + offset + fw < vw - MARGIN) s = 'right'
42
-
43
- let top = 0
44
- let left = 0
45
- if (s === 'bottom' || s === 'top') {
46
- top = s === 'bottom' ? r.bottom + offset : r.top - offset - fh
47
- left = align === 'start' ? r.left : align === 'end' ? r.right - fw : r.left + r.width / 2 - fw / 2
48
- } else {
49
- left = s === 'right' ? r.right + offset : r.left - offset - fw
50
- top = align === 'start' ? r.top : align === 'end' ? r.bottom - fh : r.top + r.height / 2 - fh / 2
51
- }
52
- left = Math.min(Math.max(MARGIN, left), Math.max(MARGIN, vw - fw - MARGIN))
53
- top = Math.min(Math.max(MARGIN, top), Math.max(MARGIN, vh - fh - MARGIN))
54
- setPos({ top, left, side: s, width })
25
+ const at = place(anchorRef.current, floatingRef.current, { side, align, offset, matchWidth })
26
+ if (!at) return
27
+ setPos(at)
55
28
  setFresh(true)
56
29
  }, [anchorRef, floatingRef, side, align, offset, matchWidth])
57
30
 
@@ -62,23 +35,10 @@ export function useFloating(
62
35
  setFresh(false)
63
36
  return
64
37
  }
65
- update()
66
- const f = floatingRef.current
67
- const ro = new ResizeObserver(update)
68
- if (f) ro.observe(f)
69
- if (anchorRef.current) ro.observe(anchorRef.current)
70
- window.addEventListener('scroll', update, true)
71
- window.addEventListener('resize', update)
72
- return () => {
73
- ro.disconnect()
74
- window.removeEventListener('scroll', update, true)
75
- window.removeEventListener('resize', update)
76
- }
38
+ return follow(anchorRef.current, floatingRef.current, update)
77
39
  }, [open, update, floatingRef, anchorRef])
78
40
 
79
- const style: CSSProperties = pos
80
- ? { position: 'fixed', top: pos.top, left: pos.left, width: pos.width }
81
- : { position: 'fixed', top: 0, left: 0, opacity: 0, pointerEvents: 'none' }
41
+ const style = floatingStyle(pos) as CSSProperties
82
42
 
83
43
  // ready: the layer is in its place, so a part can measure it there (for its opening animation).
84
44
  return { style, side: pos?.side ?? side, update, ready: pos !== null && fresh }
@@ -39,19 +39,7 @@ export function useScrub(o: UseScrubOptions) {
39
39
  }
40
40
  }
41
41
 
42
- /** A colour between two tokens by the pull, so ink fills in as a mark is drawn in. */
43
- export const ink = (p: number, from = 'var(--gooee-color-fg-muted)', to = 'var(--gooee-color-fg)') => `color-mix(in srgb, ${to} ${Math.round(p * 100)}%, ${from})`
44
-
45
- /** A number token read from `el`, such as a px size or a share. */
46
- export const tokenNumber = (el: Element | null, name: string) => (el ? parseFloat(getComputedStyle(el).getPropertyValue(name)) || 0 : 0)
47
-
48
- /** A wheel turn's sideways part in px: a sideways swipe, or Shift and the wheel. Null when it is mostly up and down, so the page scrolls. */
49
- export function sideways(e: WheelEvent) {
50
- const line = e.deltaMode === 1 ? 40 : 1
51
- const dx = (e.shiftKey && !e.deltaX ? e.deltaY : e.deltaX) * line
52
- const dy = e.shiftKey ? 0 : e.deltaY * line
53
- return Math.abs(dx) > Math.abs(dy) ? dx : null
54
- }
42
+ export { ink, sideways, tokenNumber } from './motion/scrubLook'
55
43
 
56
44
  /** Calls `fn` each time `value` changes (by `key`), but not for the value it starts with. */
57
45
  export function useOnChange<T>(value: T, fn: ((value: T) => void) | undefined, key = String(value)) {
@@ -0,0 +1,18 @@
1
+ import { Comment, Fragment, cloneVNode, type Ref, type VNode } from 'vue'
2
+
3
+ /** The first real node in a slot, looking through fragments and past comments. */
4
+ export function firstNode(nodes?: VNode[]): VNode | undefined {
5
+ for (const n of nodes ?? []) {
6
+ if (n.type === Comment) continue
7
+ const inner = n.type === Fragment ? firstNode(n.children as VNode[]) : n
8
+ if (inner) return inner
9
+ }
10
+ }
11
+
12
+ /** A ref callback that stores the element. A component's ref is its instance, so its element is its $el. */
13
+ export const elementRef = (target: Ref<HTMLElement | null>) => (el: unknown) => (target.value = el instanceof Element ? (el as HTMLElement) : ((el as { $el?: HTMLElement } | null)?.$el ?? null))
14
+
15
+ /** The slot's own element as the trigger, given the part's ref, ARIA and events, like React's cloneElement. */
16
+ export function cloneTrigger(node: VNode | undefined, ref: (el: unknown) => void, props: Record<string, unknown>) {
17
+ return node ? cloneVNode(node, { ref, ...props }, true) : null
18
+ }
@@ -0,0 +1,38 @@
1
+ import { computed, onBeforeUnmount, ref, toValue, watch, type MaybeRefOrGetter, type Ref } from 'vue'
2
+ import { floatingStyle, follow, place, type FloatingOptions, type Place } from '../motion/floating'
3
+
4
+ /** Vue's useFloating: places `floating` by `anchor` while `open` (motion/floating.ts). */
5
+ export function useFloating(anchor: Ref<HTMLElement | null>, floating: Ref<HTMLElement | null>, open: MaybeRefOrGetter<boolean>, options: MaybeRefOrGetter<FloatingOptions> = {}) {
6
+ const pos = ref<Place | null>(null)
7
+ // Measured since this open began.
8
+ const fresh = ref(false)
9
+ const update = () => {
10
+ const at = place(anchor.value, floating.value, toValue(options))
11
+ if (!at) return
12
+ pos.value = at
13
+ fresh.value = true
14
+ }
15
+ let stop = () => {}
16
+ watch(
17
+ [() => toValue(open), anchor, floating],
18
+ ([isOpen]) => {
19
+ stop()
20
+ stop = () => {}
21
+ // Closed: the next open is not ready until it is measured again. The place stays, so nothing flashes.
22
+ if (!isOpen) {
23
+ fresh.value = false
24
+ return
25
+ }
26
+ if (typeof window !== 'undefined') stop = follow(anchor.value, floating.value, update)
27
+ },
28
+ { immediate: true, flush: 'post' },
29
+ )
30
+ onBeforeUnmount(() => stop())
31
+ return {
32
+ // Vue adds no unit to a bare number, so the place goes in as px.
33
+ style: computed(() => Object.fromEntries(Object.entries(floatingStyle(pos.value)).map(([k, v]) => [k, typeof v === 'number' && k !== 'opacity' ? `${v}px` : v]))),
34
+ side: computed(() => pos.value?.side ?? toValue(options).side ?? 'bottom'),
35
+ ready: computed(() => pos.value !== null && fresh.value),
36
+ update,
37
+ }
38
+ }
@@ -0,0 +1,21 @@
1
+ import { computed, onBeforeUnmount, ref, toValue, watch, type MaybeRefOrGetter } from 'vue'
2
+ import { motionMs, type MotionToken } from '../motion'
3
+
4
+ /** Vue's usePresence: stays mounted through the exit motion after `open` turns false. */
5
+ export function usePresence(open: MaybeRefOrGetter<boolean>, exit: MotionToken = 'base') {
6
+ const kept = ref(toValue(open))
7
+ let timer = 0
8
+ watch(
9
+ () => toValue(open),
10
+ (now) => {
11
+ clearTimeout(timer)
12
+ if (now) kept.value = true
13
+ else timer = window.setTimeout(() => (kept.value = false), motionMs(exit))
14
+ },
15
+ )
16
+ onBeforeUnmount(() => clearTimeout(timer))
17
+ return {
18
+ mounted: computed(() => toValue(open) || kept.value),
19
+ state: computed(() => (toValue(open) ? ('open' as const) : ('closed' as const))),
20
+ }
21
+ }
@@ -0,0 +1,40 @@
1
+ import { onBeforeUnmount, onMounted, ref, watch, watchEffect } from 'vue'
2
+ import { createScrubber, type ScrubberOptions } from '../motion/scrubber'
3
+
4
+ // Vue's hold on createScrubber (motion/scrubber.ts) for Dial, RulerScrubber and PickerWheel, like useScrub.ts.
5
+
6
+ export type UseScrubOptions = Omit<ScrubberOptions<PointerEvent>, 'onFrame' | 'onMoving'>
7
+
8
+ /** `options` is read again whenever what it reads changes, as React reads them on each render. */
9
+ export function useScrub(options: () => UseScrubOptions) {
10
+ const at = ref(options().value)
11
+ const moving = ref(false)
12
+ const el = ref<HTMLElement | null>(null)
13
+ const full = () => ({ ...options(), onFrame: (v: number) => (at.value = v), onMoving: (m: boolean) => (moving.value = m) })
14
+ const s = createScrubber<PointerEvent>(full())
15
+ watchEffect(() => s.update(full()))
16
+
17
+ // A value set from outside (a v-model, a reset) glides there. So does one the parent kept or changed
18
+ // when it came to rest.
19
+ watch([() => options().value, moving], () => s.sync(options().value), { flush: 'post' })
20
+
21
+ let stopWheel = () => {}
22
+ onMounted(() => {
23
+ if (el.value && options().wheel) stopWheel = s.wheelOn(el.value)
24
+ })
25
+ onBeforeUnmount(() => {
26
+ stopWheel()
27
+ s.destroy()
28
+ })
29
+
30
+ return {
31
+ el,
32
+ /** Where it is drawn now. */
33
+ at,
34
+ moving,
35
+ go: s.go,
36
+ place: s.place,
37
+ target: s.target,
38
+ handlers: { pointerdown: s.down, pointermove: s.move, pointerup: s.up, pointercancel: s.up, keydown: (e: KeyboardEvent) => s.keyDown(e) },
39
+ }
40
+ }
@@ -0,0 +1,134 @@
1
+ // Generated from icons.tsx by scripts/vue-icons.mjs. Do not edit: change icons.tsx and run the script.
2
+ import { h, type FunctionalComponent } from 'vue'
3
+ import styles from './icons.module.css'
4
+
5
+ export type IconProps = { size?: string; animated?: boolean }
6
+
7
+ // The same svg as the React Svg wrapper: 24 grid, 1.75 line, round ends, hidden from screen readers. With
8
+ // `animated` it plays its motion when its control is pointed at or focused (icons.module.css).
9
+ const icon = (motion: string, body: string): FunctionalComponent<IconProps> => {
10
+ const Icon: FunctionalComponent<IconProps> = ({ size = '1em', animated }) =>
11
+ h('svg', {
12
+ width: size,
13
+ height: size,
14
+ viewBox: '0 0 24 24',
15
+ fill: 'none',
16
+ stroke: 'currentColor',
17
+ 'stroke-width': 1.75,
18
+ 'stroke-linecap': 'round',
19
+ 'stroke-linejoin': 'round',
20
+ 'aria-hidden': 'true',
21
+ focusable: 'false',
22
+ ...(animated ? { class: styles.icon, 'data-motion': motion } : {}),
23
+ innerHTML: animated && motion === 'draw' ? body.replace(/<(\w+)/g, '<$1 pathLength="1"') : body,
24
+ })
25
+ Icon.props = ['size', 'animated']
26
+ return Icon
27
+ }
28
+
29
+ export const CheckIcon = icon('draw', "<path d=\"M5 12.5l4.5 4.5L19 7.5\"/>")
30
+ export const XIcon = icon('pop', "<path d=\"M6 6l12 12M18 6L6 18\"/>")
31
+ export const ChevronDownIcon = icon('nudge-d', "<path d=\"M6 9l6 6 6-6\"/>")
32
+ export const ChevronRightIcon = icon('nudge-r', "<path d=\"M9 6l6 6-6 6\"/>")
33
+ export const ChevronLeftIcon = icon('nudge-l', "<path d=\"M15 6l-6 6 6 6\"/>")
34
+ export const CopyIcon = icon('pop', "<rect x=\"8.5\" y=\"8.5\" width=\"11\" height=\"11\" rx=\"2.5\"/><path d=\"M15.5 8.5V6.5a2 2 0 0 0-2-2h-7a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h2\"/>")
35
+ export const InfoIcon = icon('pop', "<circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M12 11v5M12 7.75v.01\"/>")
36
+ export const CheckCircleIcon = icon('draw', "<circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M8.5 12.25l2.5 2.5 4.5-5\"/>")
37
+ export const WarningIcon = icon('pop', "<path d=\"M12 4L2.75 19.5h18.5L12 4z\"/><path d=\"M12 10v4.5M12 17v.01\"/>")
38
+ export const ErrorIcon = icon('pop', "<path d=\"M8.25 3.5h7.5l5 5v7l-5 5h-7.5l-5-5v-7z\"/><path d=\"M9.5 9.5l5 5M14.5 9.5l-5 5\"/>")
39
+ export const EyeIcon = icon('blink', "<path 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\"/><circle cx=\"12\" cy=\"12\" r=\"2.75\"/>")
40
+ export const CodeIcon = icon('draw', "<path d=\"M8.5 7.5L4 12l4.5 4.5M15.5 7.5L20 12l-4.5 4.5\"/>")
41
+ export const SearchIcon = icon('wiggle', "<circle cx=\"11\" cy=\"11\" r=\"6.5\"/><path d=\"M16 16l4 4\"/>")
42
+ export const SunIcon = icon('turn', "<circle cx=\"12\" cy=\"12\" r=\"4\"/><path d=\"M12 2.5v2M12 19.5v2M4.6 4.6l1.4 1.4M18 18l1.4 1.4M2.5 12h2M19.5 12h2M4.6 19.4L6 18M18 6l1.4-1.4\"/>")
43
+ export const MoonIcon = icon('wiggle', "<path d=\"M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z\"/>")
44
+ export const PlusIcon = icon('pop', "<path d=\"M12 5v14M5 12h14\"/>")
45
+ export const MinusIcon = icon('pop', "<path d=\"M5 12h14\"/>")
46
+ export const MenuIcon = icon('draw', "<path d=\"M4 7h16M4 12h16M4 17h10\"/>")
47
+ export const MoreIcon = icon('wiggle', "<circle cx=\"6\" cy=\"12\" r=\"0.9\" fill=\"currentColor\"/><circle cx=\"12\" cy=\"12\" r=\"0.9\" fill=\"currentColor\"/><circle cx=\"18\" cy=\"12\" r=\"0.9\" fill=\"currentColor\"/>")
48
+ export const InboxIcon = icon('wiggle', "<path d=\"M3.5 13.5l2.5-8h12l2.5 8v5a1.5 1.5 0 0 1-1.5 1.5H5a1.5 1.5 0 0 1-1.5-1.5z\"/><path d=\"M3.5 13.5H8l1.5 2.5h5l1.5-2.5h4.5\"/>")
49
+ export const ArrowUpRightIcon = icon('nudge-ur', "<path d=\"M8 16L16 8M9 8h7v7\"/>")
50
+ export const TrashIcon = icon('wiggle', "<path d=\"M4.5 7h15M10 4h4M6.5 7l1 12.5h9l1-12.5\"/>")
51
+ export const EditIcon = icon('draw', "<path d=\"M4 20h4L19 9l-4-4L4 16v4z\"/>")
52
+ export const UndoIcon = icon('nudge-l', "<path d=\"M9 14L4 9l5-5M4 9h10.5a5.5 5.5 0 0 1 0 11H11\"/>")
53
+ export const ShareIcon = icon('nudge-u', "<path d=\"M12 15V4M8 8l4-4 4 4\"/><path d=\"M6 12v6.5A1.5 1.5 0 0 0 7.5 20h9a1.5 1.5 0 0 0 1.5-1.5V12\"/>")
54
+ export const HeartIcon = icon('pop', "<path d=\"M12 19.5s-7.5-4.4-7.5-10A4.3 4.3 0 0 1 12 7a4.3 4.3 0 0 1 7.5 2.5c0 5.6-7.5 10-7.5 10z\"/>")
55
+ export const SettingsIcon = icon('turn', "<circle cx=\"12\" cy=\"12\" r=\"3\"/><path d=\"M12 3v2.5M12 18.5V21M3 12h2.5M18.5 12H21M5.6 5.6l1.8 1.8M16.6 16.6l1.8 1.8M5.6 18.4l1.8-1.8M16.6 7.4l1.8-1.8\"/>")
56
+ export const PlayIcon = icon('pop', "<path d=\"M7.5 5.5v13l10.5-6.5z\" fill=\"currentColor\"/>")
57
+ export const PauseIcon = icon('pop', "<rect x=\"6.5\" y=\"5.5\" width=\"3.5\" height=\"13\" rx=\"1\" fill=\"currentColor\"/><rect x=\"14\" y=\"5.5\" width=\"3.5\" height=\"13\" rx=\"1\" fill=\"currentColor\"/>")
58
+ export const VolumeIcon = icon('wiggle', "<path d=\"M4 9.5h3.5L12 5.5v13l-4.5-4H4z\"/><path d=\"M15.5 9a4 4 0 0 1 0 6M18 6.5a7.5 7.5 0 0 1 0 11\"/>")
59
+ export const VolumeOffIcon = icon('wiggle', "<path d=\"M4 9.5h3.5L12 5.5v13l-4.5-4H4z\"/><path d=\"M16 9.5l5 5M21 9.5l-5 5\"/>")
60
+ export const CaptionsIcon = icon('wiggle', "<rect x=\"3\" y=\"5.5\" width=\"18\" height=\"13\" rx=\"2.5\"/><path d=\"M10.5 10.25a2 2 0 1 0 0 3.5M17 10.25a2 2 0 1 0 0 3.5\"/>")
61
+ export const FullscreenIcon = icon('pop', "<path d=\"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5\"/>")
62
+ export const ExitFullscreenIcon = icon('pop', "<path d=\"M9 4v5H4M20 9h-5V4M15 20v-5h5M4 15h5v5\"/>")
63
+ export const PipIcon = icon('pop', "<rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\"/><rect x=\"12\" y=\"11.5\" width=\"6\" height=\"4.5\" rx=\"1\" fill=\"currentColor\"/>")
64
+ export const BellIcon = icon('swing', "<path d=\"M6 16.5V11a6 6 0 0 1 12 0v5.5l1.5 1.5h-15z\"/><path d=\"M10 20.5a2.2 2.2 0 0 0 4 0\"/>")
65
+ export const StopIcon = icon('pop', "<rect x=\"6.5\" y=\"6.5\" width=\"11\" height=\"11\" rx=\"2.5\" fill=\"currentColor\"/>")
66
+ export const ArrowUpIcon = icon('nudge-u', "<path d=\"M12 19V5M6 11l6-6 6 6\"/>")
67
+ export const ArrowDownIcon = icon('nudge-d', "<path d=\"M12 5v14M6 13l6 6 6-6\"/>")
68
+ export const DownloadIcon = icon('nudge-d', "<path d=\"M12 4v11M7.5 10.5L12 15l4.5-4.5\"/><path d=\"M5 19.5h14\"/>")
69
+ export const ReplyIcon = icon('nudge-l', "<path d=\"M10 6L4.5 11.5 10 17M5 11.5h8.5a6 6 0 0 1 6 6V19\"/>")
70
+ export const ClockIcon = icon('wiggle', "<circle cx=\"12\" cy=\"12\" r=\"8.5\"/><path d=\"M12 7.5V12l3 2\"/>")
71
+ export const RetryIcon = icon('turn', "<path d=\"M19.5 12a7.5 7.5 0 1 1-2.2-5.3\"/><path d=\"M19.5 4.5v4h-4\"/>")
72
+ export const GripIcon = icon('wiggle', "<path d=\"M5 9h14M5 15h14\"/>")
73
+ export const FilterIcon = icon('draw', "<path d=\"M4.5 6h15l-5.75 7v5.5l-3.5-2V13z\"/>")
74
+ export const BookIcon = icon('bounce', "<path d=\"M12 6.5C10.5 5.3 8.2 4.75 4 4.75v13.5c4.2 0 6.5.55 8 1.75 1.5-1.2 3.8-1.75 8-1.75V4.75c-4.2 0-6.5.55-8 1.75z\"/><path d=\"M12 6.5V20\"/>")
75
+ export const PlugIcon = icon('swing', "<path d=\"M9 3.5v4M15 3.5v4\"/><path d=\"M6.5 7.5h11v3a5.5 5.5 0 0 1-11 0z\"/><path d=\"M12 16v4.5\"/>")
76
+ export const CompassIcon = icon('turn', "<circle cx=\"12\" cy=\"12\" r=\"8.5\"/><path d=\"M15.5 8.5l-2 5-5 2 2-5z\"/>")
77
+ export const PaletteIcon = icon('bounce', "<path d=\"M12 3.5a8.5 8.5 0 0 0 0 17c1.4 0 2-.9 2-1.9 0-1.4-1.1-1.9-1.1-3.1 0-1 .8-1.75 1.8-1.75H17a3.5 3.5 0 0 0 3.5-3.5C20.5 6.9 16.7 3.5 12 3.5z\"/><circle cx=\"7.75\" cy=\"11.5\" r=\"1.1\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"10.25\" cy=\"7.5\" r=\"1.1\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"14.75\" cy=\"7.75\" r=\"1.1\" fill=\"currentColor\" stroke=\"none\"/>")
78
+ export const RulerIcon = icon('draw', "<path d=\"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z\"/><path d=\"m14.5 12.5 2-2M11.5 9.5l2-2M8.5 6.5l2-2M17.5 15.5l2-2\"/>")
79
+ export const SlidersIcon = icon('bounce', "<path d=\"M4 7h9M17 7h3M4 17h3M11 17h9\"/><circle cx=\"15\" cy=\"7\" r=\"2\"/><circle cx=\"9\" cy=\"17\" r=\"2\"/>")
80
+ export const GridIcon = icon('pop', "<rect x=\"4\" y=\"4\" width=\"6.5\" height=\"6.5\" rx=\"1.5\"/><rect x=\"13.5\" y=\"4\" width=\"6.5\" height=\"6.5\" rx=\"1.5\"/><rect x=\"4\" y=\"13.5\" width=\"6.5\" height=\"6.5\" rx=\"1.5\"/><rect x=\"13.5\" y=\"13.5\" width=\"6.5\" height=\"6.5\" rx=\"1.5\"/>")
81
+ export const PackageIcon = icon('bounce', "<path d=\"M12 3.5l8 4.25v8.5L12 20.5l-8-4.25v-8.5z\"/><path d=\"M4 7.75l8 4.25 8-4.25M12 12v8.5\"/>")
82
+ export const SproutIcon = icon('grow', "<path d=\"M12 20.5V11\"/><path d=\"M12 14.5c-.4-3.6-2.8-5.7-6.5-5.7 0 3.6 2.5 5.7 6.5 5.7z\"/><path d=\"M12 11.5c.3-4 2.8-6.3 6.5-6.3 0 4-2.6 6.3-6.5 6.3z\"/><path d=\"M8.5 20.5h7\"/>")
83
+ export const LayersIcon = icon('bounce', "<path d=\"M12 4l8.5 4.5L12 13 3.5 8.5z\"/><path d=\"M3.5 12.75L12 17.25l8.5-4.5\"/><path d=\"M3.5 16.5L12 21l8.5-4.5\"/>")
84
+ export const TerminalIcon = icon('bounce', "<rect x=\"3.5\" y=\"4.5\" width=\"17\" height=\"15\" rx=\"2.5\"/><path d=\"M7.5 9.5l3 2.5-3 2.5M12.5 15h4\"/>")
85
+ export const FileIcon = icon('bounce', "<path d=\"M13.5 3.5H7a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V9z\"/><path d=\"M13.5 3.5V9H19\"/>")
86
+ export const FileTextIcon = icon('bounce', "<path d=\"M13.5 3.5H7a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V9z\"/><path d=\"M13.5 3.5V9H19M8.5 13h7M8.5 16.5h5\"/>")
87
+ export const FolderIcon = icon('bounce', "<path d=\"M3.5 7.5a2 2 0 0 1 2-2h4l2 2.25h7a2 2 0 0 1 2 2v7.75a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2z\"/>")
88
+ export const ImageIcon = icon('pop', "<rect x=\"3.5\" y=\"4.5\" width=\"17\" height=\"15\" rx=\"2.5\"/><circle cx=\"9\" cy=\"9.5\" r=\"1.5\"/><path d=\"M20.5 15.5L16 11l-8.5 8.5\"/>")
89
+ export const LinkIcon = icon('draw', "<path d=\"M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1\"/><path d=\"M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1\"/>")
90
+ export const PaperclipIcon = icon('draw', "<path d=\"M19 11.5l-7.25 7.25a4.6 4.6 0 0 1-6.5-6.5L12.5 5a3 3 0 0 1 4.25 4.25l-7 7a1.5 1.5 0 0 1-2.1-2.1l6.6-6.65\"/>")
91
+ export const UploadIcon = icon('nudge-u', "<path d=\"M12 15V4M7.5 8.5L12 4l4.5 4.5\"/><path d=\"M5 19.5h14\"/>")
92
+ export const CloudIcon = icon('bounce', "<path d=\"M7 18.5a4 4 0 0 1-.6-7.95A5.5 5.5 0 0 1 17 9a4.75 4.75 0 0 1 .5 9.5z\"/>")
93
+ export const DatabaseIcon = icon('bounce', "<ellipse cx=\"12\" cy=\"6\" rx=\"7\" ry=\"2.5\"/><path d=\"M5 6v12c0 1.4 3.1 2.5 7 2.5s7-1.1 7-2.5V6\"/><path d=\"M5 12c0 1.4 3.1 2.5 7 2.5s7-1.1 7-2.5\"/>")
94
+ export const BarChartIcon = icon('draw', "<path d=\"M4 20h16\"/><path d=\"M7 16.5v-4M12 16.5V7M17 16.5v-7\"/>")
95
+ export const LineChartIcon = icon('draw', "<path d=\"M4 4v16h16\"/><path d=\"M7.5 15l3.5-4 3 2.5 5-6\"/>")
96
+ export const TableIcon = icon('bounce', "<rect x=\"3.5\" y=\"4.5\" width=\"17\" height=\"15\" rx=\"2.5\"/><path d=\"M3.5 9.5h17M3.5 14.5h17M10 9.5v10\"/>")
97
+ export const CalendarIcon = icon('wiggle', "<rect x=\"4\" y=\"5.5\" width=\"16\" height=\"14.5\" rx=\"2.5\"/><path d=\"M4 10h16M8.5 3.5v4M15.5 3.5v4\"/>")
98
+ export const ListIcon = icon('draw', "<path d=\"M9 7h11M9 12h11M9 17h11\"/><path d=\"M4.5 7h.01M4.5 12h.01M4.5 17h.01\"/>")
99
+ export const HashIcon = icon('draw', "<path d=\"M5 9h15M4 15h15M10 4L8 20M16 4l-2 16\"/>")
100
+ export const UserIcon = icon('bounce', "<circle cx=\"12\" cy=\"8.5\" r=\"4\"/><path d=\"M4.5 20a7.5 7.5 0 0 1 15 0\"/>")
101
+ export const UsersIcon = icon('bounce', "<circle cx=\"9\" cy=\"9\" r=\"3.5\"/><path d=\"M3 19.5a6 6 0 0 1 12 0\"/><path d=\"M15.5 5.75a3.5 3.5 0 0 1 0 6.5M17.5 14.25A6 6 0 0 1 21 19.5\"/>")
102
+ export const MailIcon = icon('wiggle', "<rect x=\"3.5\" y=\"5.5\" width=\"17\" height=\"13\" rx=\"2.5\"/><path d=\"M4 7.5l8 5.5 8-5.5\"/>")
103
+ export const MessageIcon = icon('wiggle', "<path d=\"M20.5 14.5a2 2 0 0 1-2 2H9.5L5 20v-3.5h.5a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h13a2 2 0 0 1 2 2z\"/>")
104
+ export const PhoneIcon = icon('wiggle', "<rect x=\"6.5\" y=\"3\" width=\"11\" height=\"18\" rx=\"2.5\"/><path d=\"M11 17.5h2\"/>")
105
+ export const AtSignIcon = icon('bounce', "<circle cx=\"12\" cy=\"12\" r=\"3.5\"/><path d=\"M15.5 8.5v4.75a2.25 2.25 0 0 0 4.5 0V12a8 8 0 1 0-3.2 6.4\"/>")
106
+ export const LockIcon = icon('wiggle', "<rect x=\"5\" y=\"10.5\" width=\"14\" height=\"10\" rx=\"2.5\"/><path d=\"M8 10.5V8a4 4 0 0 1 8 0v2.5\"/>")
107
+ export const UnlockIcon = icon('wiggle', "<rect x=\"5\" y=\"10.5\" width=\"14\" height=\"10\" rx=\"2.5\"/><path d=\"M8 10.5V8a4 4 0 0 1 7.75-1.4\"/>")
108
+ export const KeyIcon = icon('swing', "<circle cx=\"8\" cy=\"15.5\" r=\"4\"/><path d=\"M10.9 12.6L19.5 4M16.5 7L19 9.5M14 9.5l2 2\"/>")
109
+ export const ShieldIcon = icon('bounce', "<path d=\"M12 3.5l7 2.75v5.25c0 4.25-2.9 7.6-7 9-4.1-1.4-7-4.75-7-9V6.25z\"/>")
110
+ export const LogInIcon = icon('nudge-r', "<path d=\"M14 4h4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-4\"/><path d=\"M3.5 12h11M10.5 8l4 4-4 4\"/>")
111
+ export const LogOutIcon = icon('nudge-r', "<path d=\"M10 4H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h4\"/><path d=\"M9.5 12h11M16.5 8l4 4-4 4\"/>")
112
+ export const SendIcon = icon('nudge-ur', "<path d=\"M20.5 3.5l-17 7 7 3 3 7z\"/><path d=\"M20.5 3.5l-10 10\"/>")
113
+ export const SmileIcon = icon('blink', "<circle cx=\"12\" cy=\"12\" r=\"8.5\"/><path d=\"M8.5 14.5a4.5 4.5 0 0 0 7 0\"/><path d=\"M9 9.5h.01M15 9.5h.01\"/>")
114
+ export const VideoIcon = icon('wiggle', "<rect x=\"3\" y=\"6.5\" width=\"12.5\" height=\"11\" rx=\"2.5\"/><path d=\"M15.5 10.5l5.5-3v9l-5.5-3\"/>")
115
+ export const MicIcon = icon('wiggle', "<rect x=\"9\" y=\"3.5\" width=\"6\" height=\"11\" rx=\"3\"/><path d=\"M5.5 11.5a6.5 6.5 0 0 0 13 0M12 18v2.5\"/>")
116
+ export const CartIcon = icon('wiggle', "<path d=\"M3 4.5h2.5l2 10.5h10.5l2-7.5H6.5\"/><circle cx=\"9\" cy=\"19\" r=\"1.25\"/><circle cx=\"17\" cy=\"19\" r=\"1.25\"/>")
117
+ export const BagIcon = icon('wiggle', "<path d=\"M5.5 8h13l-1 12h-11z\"/><path d=\"M9 10.5V7a3 3 0 0 1 6 0v3.5\"/>")
118
+ export const CreditCardIcon = icon('bounce', "<rect x=\"3\" y=\"5.5\" width=\"18\" height=\"13\" rx=\"2.5\"/><path d=\"M3 10h18M7 14.5h3\"/>")
119
+ export const ReceiptIcon = icon('bounce', "<path d=\"M6 3.5h12v17l-2-1.5-2 1.5-2-1.5-2 1.5-2-1.5-2 1.5z\"/><path d=\"M9 8.5h6M9 12h6M9 15.5h3\"/>")
120
+ export const TagIcon = icon('swing', "<path d=\"M3.5 12.1V5A1.5 1.5 0 0 1 5 3.5h7.1a1.5 1.5 0 0 1 1.06.44l7.4 7.4a1.5 1.5 0 0 1 0 2.12l-7.1 7.1a1.5 1.5 0 0 1-2.12 0l-7.4-7.4a1.5 1.5 0 0 1-.44-1.06z\"/><circle cx=\"8.25\" cy=\"8.25\" r=\"1.25\"/>")
121
+ export const GiftIcon = icon('pop', "<rect x=\"4\" y=\"8.5\" width=\"16\" height=\"4\" rx=\"1\"/><path d=\"M5.5 12.5V20h13v-7.5M12 8.5V20\"/><path d=\"M12 8.5C10.5 5 7 4.75 7 6.75 7 8 9 8.5 12 8.5zM12 8.5c1.5-3.5 5-3.75 5-1.75 0 1.25-2 1.75-5 1.75z\"/>")
122
+ export const HomeIcon = icon('bounce', "<path d=\"M4 10.5L12 4l8 6.5V19a1.5 1.5 0 0 1-1.5 1.5H15v-6H9v6H5.5A1.5 1.5 0 0 1 4 19z\"/>")
123
+ export const MapPinIcon = icon('bounce', "<path d=\"M12 21s-6.5-5.6-6.5-11a6.5 6.5 0 0 1 13 0c0 5.4-6.5 11-6.5 11z\"/><circle cx=\"12\" cy=\"10\" r=\"2.5\"/>")
124
+ export const GlobeIcon = icon('turn', "<circle cx=\"12\" cy=\"12\" r=\"8.5\"/><path d=\"M3.5 12h17\"/><path d=\"M12 3.5c2.4 2.4 3.5 5.3 3.5 8.5s-1.1 6.1-3.5 8.5c-2.4-2.4-3.5-5.3-3.5-8.5S9.6 5.9 12 3.5z\"/>")
125
+ export const StarIcon = icon('pop', "<path d=\"M12.00 3.85L14.20 9.57L20.32 9.90L15.57 13.76L17.14 19.68L12.00 16.35L6.86 19.68L8.43 13.76L3.68 9.90L9.80 9.57z\"/>")
126
+ export const BookmarkIcon = icon('swing', "<path d=\"M6.5 4.5a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v16L12 16.5l-5.5 4z\"/>")
127
+ export const FlagIcon = icon('swing', "<path d=\"M5 21V4\"/><path d=\"M5 4.5c3-1.5 5.5 1.5 8.5 0s5.5 0 5.5 0v9s-2.5-1.5-5.5 0-5.5-1.5-8.5 0\"/>")
128
+ export const TruckIcon = icon('nudge-r', "<path d=\"M14 16.5v-10H3.5v10h1.75M14 9.5h3.75l3 3.5v3.5h-1.5M8.75 16.5h6.5\"/><circle cx=\"7\" cy=\"17\" r=\"1.75\"/><circle cx=\"17.75\" cy=\"17\" r=\"1.75\"/>")
129
+ export const ChevronUpIcon = icon('nudge-u', "<path d=\"M6 15l6-6 6 6\"/>")
130
+ export const ArrowLeftIcon = icon('nudge-l', "<path d=\"M19 12H5M11 6l-6 6 6 6\"/>")
131
+ export const ArrowRightIcon = icon('nudge-r', "<path d=\"M5 12h14M13 6l6 6-6 6\"/>")
132
+ export const EyeOffIcon = icon('blink', "<path 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\"/><circle cx=\"12\" cy=\"12\" r=\"2.75\"/><path d=\"M4 4l16 16\"/>")
133
+ export const ZapIcon = icon('pop', "<path d=\"M13 3L5 13.5h6L10.5 21 19 10.5h-6z\"/>")
134
+ export const LayoutIcon = icon('bounce', "<rect x=\"3.5\" y=\"4.5\" width=\"17\" height=\"15\" rx=\"2.5\"/><path d=\"M3.5 9.5h17M9.5 9.5v10\"/>")
package/src/tokens.css CHANGED
@@ -634,6 +634,9 @@
634
634
  --gooee-flap-h: 1.36em;
635
635
  --gooee-flap-top: var(--gooee-color-surface-sunken);
636
636
  --gooee-flap-bottom: var(--gooee-color-surface-hover);
637
+ /* Tabs: the panel, and the chosen tab that rises out of it. In light it takes the pressed grey, as the
638
+ sunken one is too close to a white or near-white page to see; the dark one stands out already. */
639
+ --gooee-tabs-panel: var(--gooee-color-surface-active);
637
640
  }
638
641
 
639
642
  /* In the dark the top half is the lighter one, as on a lit board. Both are set again here, so a dark
@@ -642,12 +645,14 @@
642
645
  :root:not([data-theme="light"]) {
643
646
  --gooee-flap-top: var(--gooee-color-surface-active);
644
647
  --gooee-flap-bottom: var(--gooee-color-surface-hover);
648
+ --gooee-tabs-panel: var(--gooee-color-surface-sunken);
645
649
  }
646
650
  }
647
651
 
648
652
  [data-theme="dark"] {
649
653
  --gooee-flap-top: var(--gooee-color-surface-active);
650
654
  --gooee-flap-bottom: var(--gooee-color-surface-hover);
655
+ --gooee-tabs-panel: var(--gooee-color-surface-sunken);
651
656
  }
652
657
 
653
658
  :root,
@@ -1,26 +0,0 @@
1
- const STEPS: Array<[Intl.RelativeTimeFormatUnit, number]> = [
2
- ['second', 60],
3
- ['minute', 60],
4
- ['hour', 24],
5
- ['day', 7],
6
- ['week', 4.35],
7
- ['month', 12],
8
- ['year', Infinity],
9
- ]
10
-
11
- /** "5 minutes ago", "yesterday", "in 2 hours", in the given language. */
12
- export function relativeTime(time: Date, now: Date, locale?: string): string {
13
- if (!isValidDate(time)) return ''
14
- const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' })
15
- let value = (time.getTime() - now.getTime()) / 1000
16
- if (Math.abs(value) < 45) return rtf.format(0, 'second')
17
- for (const [unit, size] of STEPS) {
18
- if (Math.abs(value) < size) return rtf.format(Math.round(value), unit)
19
- value /= size
20
- }
21
- return rtf.format(Math.round(value), 'year')
22
- }
23
-
24
- export const isValidDate = (d: Date) => !Number.isNaN(d.getTime())
25
-
26
- export const toDate = (t: Date | string | number) => (t instanceof Date ? t : new Date(t))