gooee 0.52.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/package.json +6 -2
- package/scripts/add.js +181 -42
- package/src/base.css +3 -1
- package/src/components/Accordion/Accordion.module.css +7 -5
- package/src/components/Accordion/Accordion.tsx +13 -11
- package/src/components/Accordion/Accordion.vue +16 -15
- package/src/components/Accordion/AccordionItem.vue +8 -7
- package/src/components/Alert/Alert.module.css +9 -7
- package/src/components/Alert/Alert.tsx +25 -16
- package/src/components/Alert/Alert.vue +31 -27
- package/src/components/AlertDialog/AlertDialog.module.css +2 -0
- package/src/components/AlertDialog/AlertDialog.tsx +8 -7
- package/src/components/AlertDialog/AlertDialog.vue +25 -23
- package/src/components/AnimatedNumber/AnimatedNumber.module.css +5 -3
- package/src/components/AnimatedNumber/AnimatedNumber.tsx +6 -6
- package/src/components/AnimatedNumber/AnimatedNumber.vue +5 -5
- package/src/components/AspectRatio/AspectRatio.module.css +2 -0
- package/src/components/AspectRatio/AspectRatio.tsx +3 -3
- package/src/components/AspectRatio/AspectRatio.vue +5 -8
- package/src/components/Avatar/Avatar.module.css +10 -8
- package/src/components/Avatar/Avatar.tsx +4 -3
- package/src/components/Avatar/Avatar.vue +17 -19
- package/src/components/Avatar/index.ts +0 -2
- package/src/components/AvatarGroup/AvatarGroup.module.css +11 -9
- package/src/components/AvatarGroup/AvatarGroup.tsx +4 -4
- package/src/components/AvatarGroup/AvatarGroup.vue +13 -16
- package/src/components/Badge/Badge.module.css +6 -4
- package/src/components/Badge/Badge.tsx +3 -3
- package/src/components/Badge/Badge.vue +15 -14
- package/src/components/Breadcrumb/Breadcrumb.module.css +5 -3
- package/src/components/Breadcrumb/Breadcrumb.tsx +20 -12
- package/src/components/Breadcrumb/Breadcrumb.vue +33 -25
- package/src/components/Button/Button.module.css +16 -14
- package/src/components/Button/Button.tsx +6 -4
- package/src/components/Button/Button.vue +42 -33
- package/src/components/ButtonGroup/ButtonGroup.module.css +2 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +1 -1
- package/src/components/ButtonGroup/ButtonGroup.vue +9 -12
- package/src/components/Card/Card.module.css +6 -4
- package/src/components/Card/Card.tsx +6 -6
- package/src/components/Card/Card.vue +18 -21
- package/src/components/Center/Center.module.css +2 -0
- package/src/components/Center/Center.tsx +1 -1
- package/src/components/Center/Center.vue +18 -15
- package/src/components/Checkbox/Checkbox.module.css +10 -8
- package/src/components/Checkbox/Checkbox.tsx +7 -5
- package/src/components/Checkbox/Checkbox.vue +29 -31
- package/src/components/CheckboxGroup/CheckboxGroup.module.css +3 -1
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +4 -4
- package/src/components/CheckboxGroup/CheckboxGroup.vue +33 -30
- package/src/components/Cluster/Cluster.module.css +2 -0
- package/src/components/Cluster/Cluster.tsx +1 -1
- package/src/components/Cluster/Cluster.vue +21 -17
- package/src/components/CodeBlock/CodeBlock.module.css +12 -10
- package/src/components/CodeBlock/CodeBlock.tsx +18 -10
- package/src/components/CodeBlock/CodeBlock.vue +30 -27
- package/src/components/CodeBlock/highlight.ts +1 -1
- package/src/components/Collapsible/Collapsible.module.css +7 -5
- package/src/components/Collapsible/Collapsible.tsx +7 -6
- package/src/components/Collapsible/Collapsible.vue +30 -26
- package/src/components/Container/Container.module.css +2 -0
- package/src/components/Container/Container.tsx +1 -1
- package/src/components/Container/Container.vue +13 -12
- package/src/components/CopyButton/CopyButton.module.css +20 -18
- package/src/components/CopyButton/CopyButton.tsx +21 -14
- package/src/components/CopyButton/CopyButton.vue +41 -31
- package/src/components/Dial/Dial.module.css +26 -11
- package/src/components/Dial/Dial.tsx +18 -18
- package/src/components/Dial/Dial.vue +57 -60
- package/src/components/Dialog/Dialog.module.css +4 -2
- package/src/components/Dialog/Dialog.tsx +22 -13
- package/src/components/Dialog/Dialog.vue +34 -30
- package/src/components/Divider/Divider.module.css +5 -3
- package/src/components/Divider/Divider.tsx +6 -4
- package/src/components/Divider/Divider.vue +13 -16
- package/src/components/DropdownMenu/DropdownMenu.module.css +8 -6
- package/src/components/DropdownMenu/DropdownMenu.tsx +11 -8
- package/src/components/DropdownMenu/DropdownMenu.vue +24 -27
- package/src/components/EmptyState/EmptyState.module.css +6 -4
- package/src/components/EmptyState/EmptyState.tsx +6 -6
- package/src/components/EmptyState/EmptyState.vue +14 -17
- package/src/components/Fab/Fab.module.css +19 -17
- package/src/components/Fab/Fab.tsx +11 -9
- package/src/components/Fab/Fab.vue +29 -26
- package/src/components/Fieldset/Fieldset.module.css +2 -0
- package/src/components/Fieldset/Fieldset.tsx +4 -3
- package/src/components/Fieldset/Fieldset.vue +4 -4
- package/src/components/FormField/FormField.module.css +5 -3
- package/src/components/FormField/FormField.tsx +7 -7
- package/src/components/FormField/FormField.vue +4 -4
- package/src/components/Grid/Grid.module.css +2 -0
- package/src/components/Grid/Grid.tsx +1 -1
- package/src/components/Grid/Grid.vue +25 -22
- package/src/components/HoldToConfirm/HoldToConfirm.module.css +13 -11
- package/src/components/HoldToConfirm/HoldToConfirm.tsx +11 -9
- package/src/components/HoldToConfirm/HoldToConfirm.vue +37 -32
- package/src/components/IconButton/IconButton.module.css +7 -5
- package/src/components/IconButton/IconButton.tsx +2 -1
- package/src/components/IconButton/IconButton.vue +15 -14
- package/src/components/Input/Input.module.css +12 -10
- package/src/components/Input/Input.tsx +9 -7
- package/src/components/Input/Input.vue +45 -35
- package/src/components/InputGroup/InputGroup.module.css +8 -6
- package/src/components/InputGroup/InputGroup.tsx +5 -4
- package/src/components/InputGroup/InputGroup.vue +41 -36
- package/src/components/Kbd/Kbd.module.css +9 -7
- package/src/components/Kbd/Kbd.tsx +1 -1
- package/src/components/Kbd/Kbd.vue +1 -1
- package/src/components/Link/Link.module.css +4 -2
- package/src/components/Link/Link.tsx +4 -3
- package/src/components/Link/Link.vue +13 -16
- package/src/components/LivePill/LivePill.module.css +39 -37
- package/src/components/LivePill/LivePill.tsx +11 -10
- package/src/components/LivePill/LivePill.vue +38 -40
- package/src/components/Meter/Meter.module.css +5 -3
- package/src/components/Meter/Meter.tsx +9 -8
- package/src/components/Meter/Meter.vue +52 -43
- package/src/components/MorphButton/MorphButton.module.css +11 -9
- package/src/components/MorphButton/MorphButton.tsx +20 -10
- package/src/components/MorphButton/MorphButton.vue +29 -25
- package/src/components/NumberInput/NumberInput.module.css +7 -5
- package/src/components/NumberInput/NumberInput.tsx +11 -8
- package/src/components/NumberInput/NumberInput.vue +69 -57
- package/src/components/Pagination/Pagination.module.css +147 -5
- package/src/components/Pagination/Pagination.tsx +216 -41
- package/src/components/Pagination/Pagination.vue +201 -36
- package/src/components/Pagination/labels.ts +38 -0
- package/src/components/PasswordInput/PasswordInput.module.css +10 -8
- package/src/components/PasswordInput/PasswordInput.tsx +15 -7
- package/src/components/PasswordInput/PasswordInput.vue +20 -16
- package/src/components/PasswordInput/index.ts +1 -1
- package/src/components/PickerWheel/DateWheel.vue +20 -12
- package/src/components/PickerWheel/PickerWheel.module.css +15 -6
- package/src/components/PickerWheel/PickerWheel.tsx +70 -44
- package/src/components/PickerWheel/PickerWheel.vue +39 -38
- package/src/components/PickerWheel/TimeWheel.vue +23 -21
- package/src/components/PickerWheel/WheelColumn.vue +7 -5
- package/src/components/Popover/Popover.module.css +5 -3
- package/src/components/Popover/Popover.tsx +17 -8
- package/src/components/Popover/Popover.vue +26 -25
- package/src/components/ProgressBar/ProgressBar.module.css +4 -2
- package/src/components/ProgressBar/ProgressBar.tsx +6 -5
- package/src/components/ProgressBar/ProgressBar.vue +28 -25
- package/src/components/Prose/Prose.module.css +5 -3
- package/src/components/Prose/Prose.tsx +1 -1
- package/src/components/Prose/Prose.vue +5 -8
- package/src/components/Radio/Radio.module.css +10 -8
- package/src/components/Radio/Radio.tsx +10 -8
- package/src/components/Radio/Radio.vue +8 -8
- package/src/components/Radio/RadioGroup.vue +33 -35
- package/src/components/Radio/radioContext.ts +12 -0
- package/src/components/Retime/Retime.vue +25 -22
- package/src/components/RulerScrubber/RulerScrubber.module.css +11 -2
- package/src/components/RulerScrubber/RulerScrubber.tsx +19 -18
- package/src/components/RulerScrubber/RulerScrubber.vue +50 -54
- package/src/components/ScrollArea/ScrollArea.module.css +17 -15
- package/src/components/ScrollArea/ScrollArea.tsx +5 -4
- package/src/components/ScrollArea/ScrollArea.vue +15 -17
- package/src/components/SearchInput/SearchInput.module.css +6 -4
- package/src/components/SearchInput/SearchInput.tsx +15 -8
- package/src/components/SearchInput/SearchInput.vue +20 -17
- package/src/components/SearchInput/index.ts +1 -1
- package/src/components/SegmentedControl/SegmentedControl.module.css +7 -5
- package/src/components/SegmentedControl/SegmentedControl.tsx +9 -5
- package/src/components/SegmentedControl/SegmentedControl.vue +25 -29
- package/src/components/Select/Select.module.css +19 -17
- package/src/components/Select/Select.tsx +30 -17
- package/src/components/Select/Select.vue +62 -57
- package/src/components/Sheet/Sheet.module.css +6 -4
- package/src/components/Sheet/Sheet.tsx +39 -29
- package/src/components/Sheet/Sheet.vue +46 -40
- package/src/components/Skeleton/Skeleton.module.css +4 -2
- package/src/components/Skeleton/Skeleton.tsx +3 -2
- package/src/components/Skeleton/Skeleton.vue +16 -18
- package/src/components/Slider/Slider.module.css +14 -12
- package/src/components/Slider/Slider.tsx +20 -9
- package/src/components/Slider/Slider.vue +47 -37
- package/src/components/Spinner/Spinner.module.css +2 -0
- package/src/components/Spinner/Spinner.tsx +3 -3
- package/src/components/Spinner/Spinner.vue +9 -12
- package/src/components/Split/Split.module.css +2 -0
- package/src/components/Split/Split.tsx +3 -3
- package/src/components/Split/Split.vue +19 -17
- package/src/components/SplitFlap/SplitFlap.module.css +9 -7
- package/src/components/SplitFlap/SplitFlap.tsx +2 -2
- package/src/components/SplitFlap/SplitFlap.vue +24 -21
- package/src/components/Stack/Stack.module.css +2 -0
- package/src/components/Stack/Stack.tsx +1 -1
- package/src/components/Stack/Stack.vue +13 -12
- package/src/components/SwipeDeck/SwipeDeck.module.css +13 -11
- package/src/components/SwipeDeck/SwipeDeck.tsx +23 -28
- package/src/components/SwipeDeck/SwipeDeck.vue +32 -38
- package/src/components/Switch/Switch.module.css +10 -8
- package/src/components/Switch/Switch.tsx +6 -5
- package/src/components/Switch/Switch.vue +22 -24
- package/src/components/Table/Table.module.css +24 -22
- package/src/components/Table/Table.tsx +27 -30
- package/src/components/Table/Table.vue +93 -79
- package/src/components/TableOfContents/TableOfContents.module.css +9 -7
- package/src/components/TableOfContents/TableOfContents.tsx +8 -8
- package/src/components/TableOfContents/TableOfContents.vue +20 -23
- package/src/components/Tabs/Tab.vue +3 -0
- package/src/components/Tabs/TabList.vue +2 -2
- package/src/components/Tabs/TabPanel.vue +2 -0
- package/src/components/Tabs/Tabs.module.css +4 -2
- package/src/components/Tabs/Tabs.tsx +10 -5
- package/src/components/Tabs/Tabs.vue +1 -1
- package/src/components/Tag/Tag.module.css +12 -10
- package/src/components/Tag/Tag.tsx +13 -15
- package/src/components/Tag/Tag.vue +12 -14
- package/src/components/Textarea/Textarea.module.css +8 -6
- package/src/components/Textarea/Textarea.tsx +4 -3
- package/src/components/Textarea/Textarea.vue +32 -34
- package/src/components/ThemeToggle/ThemeToggle.module.css +2 -0
- package/src/components/ThemeToggle/ThemeToggle.tsx +7 -7
- package/src/components/ThemeToggle/ThemeToggle.vue +24 -22
- package/src/components/Toast/Toast.module.css +17 -15
- package/src/components/Toast/Toast.tsx +51 -34
- package/src/components/Toast/Toast.vue +35 -24
- package/src/components/Toast/ToastItem.vue +17 -16
- package/src/components/Toggle/Toggle.module.css +11 -9
- package/src/components/Toggle/Toggle.tsx +3 -2
- package/src/components/Toggle/Toggle.vue +13 -15
- package/src/components/Tooltip/Tooltip.module.css +5 -3
- package/src/components/Tooltip/Tooltip.tsx +1 -0
- package/src/components/Tooltip/Tooltip.vue +13 -18
- package/src/components/VisuallyHidden/VisuallyHidden.module.css +2 -0
- package/src/components/VisuallyHidden/VisuallyHidden.tsx +1 -1
- package/src/components/VisuallyHidden/VisuallyHidden.vue +5 -8
- package/src/{internal → icons}/icons.module.css +4 -2
- package/src/{internal → icons}/icons.tsx +15 -16
- package/src/internal/FieldMessage.module.css +5 -3
- package/src/internal/FieldMessage.tsx +2 -2
- package/src/internal/FieldMessage.vue +2 -2
- package/src/internal/Roll.module.css +5 -3
- package/src/internal/feel.ts +12 -10
- package/src/internal/fling.ts +3 -3
- package/src/internal/liquid.ts +12 -10
- package/src/internal/liquidMatter.ts +1 -1
- package/src/internal/liquidMore.ts +7 -7
- package/src/internal/motion/checkbox.ts +4 -4
- package/src/internal/motion/fling.ts +19 -9
- package/src/internal/motion/holdToConfirm.ts +3 -3
- package/src/internal/motion/index.ts +8 -6
- package/src/internal/motion/liquid.ts +16 -4
- package/src/internal/motion/liquidMatter.ts +8 -6
- package/src/internal/motion/liquidMore.ts +44 -25
- package/src/internal/motion/livePill.ts +1 -1
- package/src/internal/motion/numberInput.ts +2 -2
- package/src/internal/motion/pickerWheel.ts +7 -4
- package/src/internal/motion/ruler.ts +1 -1
- package/src/internal/motion/scrollArea.ts +3 -3
- package/src/internal/motion/scrollFrame.ts +9 -7
- package/src/internal/motion/scrubber.ts +39 -20
- package/src/internal/motion/slider.ts +38 -4
- package/src/internal/motion/softPress.ts +10 -9
- package/src/internal/motion/splitFlap.ts +4 -4
- package/src/internal/motion/swipeDeck.ts +38 -7
- package/src/internal/motion/table.ts +3 -6
- package/src/internal/motion/themeIcon.ts +1 -1
- package/src/internal/motion/themeReveal.ts +1 -1
- package/src/internal/motion/toast.ts +3 -3
- package/src/internal/motion.ts +7 -8
- package/src/internal/scrollFrame.ts +3 -3
- package/src/internal/useScrub.ts +1 -15
- package/src/internal/vue/useScrub.ts +2 -6
- package/src/tokens.css +81 -421
- package/src/{internal/vueIcons.ts → icons/vue.ts} +5 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.root {
|
|
2
3
|
display: flex;
|
|
3
4
|
align-items: center;
|
|
@@ -39,8 +40,8 @@
|
|
|
39
40
|
|
|
40
41
|
.pill[data-ready] {
|
|
41
42
|
transition:
|
|
42
|
-
transform var(--gooee-motion-slow) var(--gooee-ease-
|
|
43
|
-
width var(--gooee-motion-slow) var(--gooee-ease-
|
|
43
|
+
transform var(--gooee-motion-slow) var(--gooee-ease-morph),
|
|
44
|
+
width var(--gooee-motion-slow) var(--gooee-ease-morph);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
.btn {
|
|
@@ -61,9 +62,9 @@
|
|
|
61
62
|
font-weight: var(--gooee-weight-medium);
|
|
62
63
|
cursor: pointer;
|
|
63
64
|
transition:
|
|
64
|
-
color var(--gooee-motion-base) var(--gooee-ease-
|
|
65
|
-
background-color var(--gooee-motion-fast) var(--gooee-ease-
|
|
66
|
-
transform var(--gooee-motion-slow) var(--gooee-ease-
|
|
65
|
+
color var(--gooee-motion-base) var(--gooee-ease-morph),
|
|
66
|
+
background-color var(--gooee-motion-fast) var(--gooee-ease-morph),
|
|
67
|
+
transform var(--gooee-motion-slow) var(--gooee-ease-morph);
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
@media (hover: hover) {
|
|
@@ -87,3 +88,144 @@
|
|
|
87
88
|
text-align: center;
|
|
88
89
|
color: var(--gooee-color-fg-muted);
|
|
89
90
|
}
|
|
91
|
+
|
|
92
|
+
/* Compact: Page 5 of 12 over a line, and a Go to page field that grows out of it in the same place. */
|
|
93
|
+
.root[data-variant='compact'] {
|
|
94
|
+
align-items: flex-start;
|
|
95
|
+
gap: var(--gooee-space-3);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.middle {
|
|
99
|
+
display: grid;
|
|
100
|
+
justify-items: center;
|
|
101
|
+
min-width: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.current,
|
|
105
|
+
.jump { grid-area: 1 / 1; }
|
|
106
|
+
|
|
107
|
+
.current {
|
|
108
|
+
display: flex;
|
|
109
|
+
flex-direction: column;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
align-items: stretch;
|
|
112
|
+
gap: var(--gooee-space-2);
|
|
113
|
+
font-weight: var(--gooee-weight-regular);
|
|
114
|
+
color: var(--gooee-color-fg-muted);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.words { white-space: nowrap; }
|
|
118
|
+
|
|
119
|
+
.num {
|
|
120
|
+
display: inline-grid;
|
|
121
|
+
justify-items: center;
|
|
122
|
+
color: var(--gooee-color-fg);
|
|
123
|
+
font-weight: var(--gooee-weight-semibold);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.num > * { grid-area: 1 / 1; }
|
|
127
|
+
|
|
128
|
+
/* Holds the width of the longest page number, so the words never shift as the number changes. */
|
|
129
|
+
.ghost { visibility: hidden; }
|
|
130
|
+
|
|
131
|
+
.line {
|
|
132
|
+
display: block;
|
|
133
|
+
height: var(--gooee-space-1);
|
|
134
|
+
overflow: hidden;
|
|
135
|
+
border-radius: var(--gooee-radius-full);
|
|
136
|
+
background: var(--gooee-color-border);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.fill {
|
|
140
|
+
display: block;
|
|
141
|
+
height: 100%;
|
|
142
|
+
background: var(--gooee-color-accent);
|
|
143
|
+
transform-origin: left;
|
|
144
|
+
transition: transform var(--gooee-motion-morph) var(--gooee-ease-morph);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.fill:dir(rtl) { transform-origin: right; }
|
|
148
|
+
|
|
149
|
+
/* The label and the number box each fill the field's inner height, 44px, so the whole field is the target.
|
|
150
|
+
The border sits outside that, over the arrows' edge line, so the row keeps its height. */
|
|
151
|
+
.jump {
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: stretch;
|
|
154
|
+
height: calc(var(--gooee-hit-min) + var(--gooee-line) * 2);
|
|
155
|
+
margin-block: calc(var(--gooee-line) * -1);
|
|
156
|
+
position: relative;
|
|
157
|
+
border: var(--gooee-line) solid var(--gooee-color-border-strong);
|
|
158
|
+
border-radius: var(--gooee-radius-md);
|
|
159
|
+
background: var(--gooee-color-surface);
|
|
160
|
+
visibility: hidden;
|
|
161
|
+
transition: border-color var(--gooee-motion-fast) var(--gooee-ease-morph), box-shadow var(--gooee-motion-fast) var(--gooee-ease-morph);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.jump[data-state="open"] { visibility: visible; }
|
|
165
|
+
|
|
166
|
+
.jump:focus-within {
|
|
167
|
+
border-color: var(--gooee-color-fg);
|
|
168
|
+
box-shadow: 0 0 0 var(--gooee-halo) var(--gooee-color-surface-active);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* A red border drawn twice as thick (outside, so nothing inside moves) and the shake, so the error does not rely on colour alone. */
|
|
172
|
+
.jump[data-invalid] {
|
|
173
|
+
border-color: var(--gooee-color-danger);
|
|
174
|
+
box-shadow: 0 0 0 var(--gooee-line) var(--gooee-color-danger);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.jump[data-shake] { animation: nudge var(--gooee-motion-slow) var(--gooee-ease-morph); }
|
|
178
|
+
|
|
179
|
+
.jumpLabel {
|
|
180
|
+
display: flex;
|
|
181
|
+
align-items: center;
|
|
182
|
+
padding-inline: var(--gooee-space-4) var(--gooee-space-3);
|
|
183
|
+
font-size: var(--gooee-text-sm);
|
|
184
|
+
color: var(--gooee-color-fg-muted);
|
|
185
|
+
white-space: nowrap;
|
|
186
|
+
cursor: text;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* Sits in the field's end corners with a one-line gap, so its corners are the field's less that line. */
|
|
190
|
+
.input {
|
|
191
|
+
min-width: 0;
|
|
192
|
+
padding: 0 var(--gooee-space-3);
|
|
193
|
+
border: 0;
|
|
194
|
+
border-start-end-radius: calc(var(--gooee-radius-md) - var(--gooee-line));
|
|
195
|
+
border-end-end-radius: calc(var(--gooee-radius-md) - var(--gooee-line));
|
|
196
|
+
background: var(--gooee-color-surface-sunken);
|
|
197
|
+
color: var(--gooee-color-fg);
|
|
198
|
+
font: inherit;
|
|
199
|
+
font-size: var(--gooee-text-input);
|
|
200
|
+
font-variant-numeric: tabular-nums;
|
|
201
|
+
text-align: center;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.input:focus { outline: none; }
|
|
205
|
+
.input::placeholder { color: var(--gooee-color-fg-subtle); }
|
|
206
|
+
|
|
207
|
+
/* Spans the arrows too without widening the field, so the arrows stay put when an error shows. */
|
|
208
|
+
.message {
|
|
209
|
+
width: 0;
|
|
210
|
+
min-width: calc(100% + (var(--gooee-hit-min) + var(--gooee-space-3)) * 2);
|
|
211
|
+
margin-inline: calc((var(--gooee-hit-min) + var(--gooee-space-3)) * -1);
|
|
212
|
+
text-wrap: balance;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.message p { justify-content: center; }
|
|
216
|
+
|
|
217
|
+
.srOnly {
|
|
218
|
+
position: absolute;
|
|
219
|
+
width: 1px;
|
|
220
|
+
height: 1px;
|
|
221
|
+
overflow: hidden;
|
|
222
|
+
clip-path: inset(50%);
|
|
223
|
+
white-space: nowrap;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
@keyframes nudge {
|
|
227
|
+
0%, 100% { transform: translateX(0); }
|
|
228
|
+
25% { transform: translateX(calc(var(--gooee-shift-sm) * -1)); }
|
|
229
|
+
60% { transform: translateX(var(--gooee-shift-sm)); }
|
|
230
|
+
}
|
|
231
|
+
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useLayoutEffect, useRef, useState } from 'react'
|
|
3
|
+
import { useEffect, useId, useLayoutEffect, useRef, useState, type KeyboardEvent } from 'react'
|
|
4
4
|
import { cx } from '../../internal/cx'
|
|
5
|
-
import {
|
|
5
|
+
import { FieldMessage } from '../../internal/FieldMessage'
|
|
6
|
+
import { ChevronLeftIcon, ChevronRightIcon } from '../../icons/icons'
|
|
7
|
+
import { motionMs } from '../../internal/motion'
|
|
8
|
+
import { createMorph } from '../../internal/motion/liquid'
|
|
9
|
+
import { Roll } from '../../internal/Roll'
|
|
6
10
|
import { useControllable } from '../../internal/useControllable'
|
|
11
|
+
import { defaultPaginationLabels, readPage, splitPageOf, type PaginationLabels } from './labels'
|
|
7
12
|
import { pageRange } from './range'
|
|
8
13
|
import styles from './Pagination.module.css'
|
|
9
14
|
|
|
15
|
+
export type { PaginationLabels }
|
|
16
|
+
|
|
10
17
|
export type PaginationProps = {
|
|
11
18
|
/** Total number of pages. Pages count from 1. */
|
|
12
19
|
pageCount: number
|
|
@@ -16,16 +23,14 @@ export type PaginationProps = {
|
|
|
16
23
|
defaultPage?: number
|
|
17
24
|
/** Called when the page changes, with the new page number. */
|
|
18
25
|
onPageChange?: (page: number) => void
|
|
19
|
-
/**
|
|
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. */
|
|
20
29
|
siblings?: number
|
|
21
30
|
/** Screen reader name for the nav landmark. */
|
|
22
31
|
label?: string
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
/** Screen reader name for the next button. */
|
|
26
|
-
nextLabel?: string
|
|
27
|
-
/** Builds the screen reader name for each page button. */
|
|
28
|
-
pageLabel?: (page: number) => string
|
|
32
|
+
/** The words it shows and says. Pass only the ones you change. */
|
|
33
|
+
labels?: Partial<PaginationLabels>
|
|
29
34
|
/** Extra class for the root element. */
|
|
30
35
|
className?: string
|
|
31
36
|
}
|
|
@@ -35,16 +40,17 @@ export function Pagination({
|
|
|
35
40
|
page: pageProp,
|
|
36
41
|
defaultPage = 1,
|
|
37
42
|
onPageChange,
|
|
43
|
+
variant = 'row',
|
|
38
44
|
siblings = 1,
|
|
39
45
|
label = 'Pagination',
|
|
40
|
-
|
|
41
|
-
nextLabel = 'Next page',
|
|
42
|
-
pageLabel = (p) => `Page ${p}`,
|
|
46
|
+
labels: labelsProp,
|
|
43
47
|
className,
|
|
44
48
|
}: PaginationProps) {
|
|
49
|
+
const labels = { ...defaultPaginationLabels, ...labelsProp }
|
|
45
50
|
const [rawPage, setPage] = useControllable(pageProp, defaultPage, onPageChange)
|
|
51
|
+
const count = Math.max(pageCount, 1)
|
|
46
52
|
// A stored page can sit past the end after pageCount drops.
|
|
47
|
-
const page = Math.min(Math.max(rawPage, 1),
|
|
53
|
+
const page = Math.min(Math.max(rawPage, 1), count)
|
|
48
54
|
const listRef = useRef<HTMLUListElement>(null)
|
|
49
55
|
const [pill, setPill] = useState<{ x: number; w: number } | null>(null)
|
|
50
56
|
const [ready, setReady] = useState(false)
|
|
@@ -63,7 +69,7 @@ export function Pagination({
|
|
|
63
69
|
const ro = new ResizeObserver(measure)
|
|
64
70
|
ro.observe(list)
|
|
65
71
|
return () => ro.disconnect()
|
|
66
|
-
}, [page, pageCount, siblings, ready])
|
|
72
|
+
}, [page, pageCount, siblings, ready, variant])
|
|
67
73
|
|
|
68
74
|
// Keeps the current page in view when the list scrolls on a narrow screen.
|
|
69
75
|
useLayoutEffect(() => {
|
|
@@ -71,43 +77,212 @@ export function Pagination({
|
|
|
71
77
|
const el = list?.querySelector<HTMLElement>('[aria-current="page"]')
|
|
72
78
|
if (!list || !el || list.scrollWidth <= list.clientWidth) return
|
|
73
79
|
list.scrollLeft = el.offsetLeft - (list.clientWidth - el.offsetWidth) / 2
|
|
74
|
-
}, [page, pageCount, siblings])
|
|
80
|
+
}, [page, pageCount, siblings, variant])
|
|
75
81
|
|
|
76
82
|
const go = (p: number) => {
|
|
77
|
-
const next = Math.min(Math.max(p, 1),
|
|
83
|
+
const next = Math.min(Math.max(p, 1), count)
|
|
78
84
|
if (next !== page) setPage(next)
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
return (
|
|
82
|
-
<nav aria-label={label} className={cx(styles.root, className)}>
|
|
83
|
-
<button type="button" className={cx(styles.btn, styles.edge)} aria-label={
|
|
88
|
+
<nav aria-label={label} className={cx(styles.root, className)} data-slot="pagination" data-variant={variant}>
|
|
89
|
+
<button type="button" className={cx(styles.btn, styles.edge)} data-slot="pagination-previous" aria-label={labels.previous} disabled={page <= 1} onClick={() => go(page - 1)}>
|
|
84
90
|
<ChevronLeftIcon />
|
|
85
91
|
</button>
|
|
86
|
-
|
|
87
|
-
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
92
|
+
{variant === 'compact' ? (
|
|
93
|
+
<Compact page={page} count={count} go={go} labels={labels} />
|
|
94
|
+
) : (
|
|
95
|
+
<ul ref={listRef} className={styles.list} data-slot="pagination-list">
|
|
96
|
+
{pill && (
|
|
97
|
+
<li aria-hidden="true" className={styles.pill} data-slot="pagination-indicator" data-ready={ready || undefined} style={{ transform: `translateX(${pill.x}px)`, width: pill.w }} />
|
|
98
|
+
)}
|
|
99
|
+
{pages.map((p, i) =>
|
|
100
|
+
p === 'gap' ? (
|
|
101
|
+
<li key={`gap-${i}`} className={styles.gap} data-slot="pagination-ellipsis" aria-hidden="true">…</li>
|
|
102
|
+
) : (
|
|
103
|
+
<li key={p}>
|
|
104
|
+
<button
|
|
105
|
+
type="button"
|
|
106
|
+
className={styles.btn}
|
|
107
|
+
data-slot="pagination-item"
|
|
108
|
+
aria-label={labels.page(p)}
|
|
109
|
+
aria-current={p === page ? 'page' : undefined}
|
|
110
|
+
onClick={() => go(p)}
|
|
111
|
+
>
|
|
112
|
+
{p}
|
|
113
|
+
</button>
|
|
114
|
+
</li>
|
|
115
|
+
),
|
|
116
|
+
)}
|
|
117
|
+
</ul>
|
|
118
|
+
)}
|
|
119
|
+
<button type="button" className={cx(styles.btn, styles.edge)} data-slot="pagination-next" aria-label={labels.next} disabled={page >= pageCount} onClick={() => go(page + 1)}>
|
|
109
120
|
<ChevronRightIcon />
|
|
110
121
|
</button>
|
|
111
122
|
</nav>
|
|
112
123
|
)
|
|
113
124
|
}
|
|
125
|
+
|
|
126
|
+
function Compact({ page, count, go, labels }: { page: number; count: number; go: (page: number) => void; labels: PaginationLabels }) {
|
|
127
|
+
const id = useId()
|
|
128
|
+
const [editing, setEditing] = useState(false)
|
|
129
|
+
// The field stays shown while it folds back into the number.
|
|
130
|
+
const [shown, setShown] = useState(false)
|
|
131
|
+
const [text, setText] = useState('')
|
|
132
|
+
const [error, setError] = useState('')
|
|
133
|
+
const [said, setSaid] = useState('')
|
|
134
|
+
const numRef = useRef<HTMLButtonElement>(null)
|
|
135
|
+
const fieldRef = useRef<HTMLDivElement>(null)
|
|
136
|
+
const inputRef = useRef<HTMLInputElement>(null)
|
|
137
|
+
const refocus = useRef(false)
|
|
138
|
+
const opened = useRef(false)
|
|
139
|
+
const liquid = useRef<ReturnType<typeof createMorph>>(null)
|
|
140
|
+
liquid.current ??= createMorph(() => fieldRef.current, { origin: () => numRef.current })
|
|
141
|
+
useEffect(() => () => liquid.current?.destroy(), [])
|
|
142
|
+
|
|
143
|
+
// Presses faster than the roll swap the number in place, so a held key never stacks rolls.
|
|
144
|
+
const last = useRef({ page, at: 0, still: false })
|
|
145
|
+
if (last.current.page !== page) {
|
|
146
|
+
const now = performance.now()
|
|
147
|
+
last.current = { page, at: now, still: now - last.current.at < motionMs('fast') }
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Read out after a change only, not when the page first shows.
|
|
151
|
+
const spoken = useRef(page)
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
if (spoken.current === page) return
|
|
154
|
+
spoken.current = page
|
|
155
|
+
setSaid(labels.pageOf(page, count))
|
|
156
|
+
// The words follow the page, not each new labels object.
|
|
157
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
158
|
+
}, [page, count])
|
|
159
|
+
|
|
160
|
+
// The field grows out of the number and folds back into it. Only its clip moves.
|
|
161
|
+
useLayoutEffect(() => {
|
|
162
|
+
if (editing) {
|
|
163
|
+
opened.current = true
|
|
164
|
+
inputRef.current?.focus({ preventScroll: true })
|
|
165
|
+
liquid.current!.play('open')
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
if (!opened.current) return
|
|
169
|
+
liquid.current!.play('closed')
|
|
170
|
+
if (refocus.current) numRef.current?.focus({ preventScroll: true })
|
|
171
|
+
refocus.current = false
|
|
172
|
+
const t = setTimeout(() => setShown(false), motionMs('morph-out'))
|
|
173
|
+
return () => clearTimeout(t)
|
|
174
|
+
}, [editing])
|
|
175
|
+
|
|
176
|
+
const open = () => {
|
|
177
|
+
setText('')
|
|
178
|
+
setError('')
|
|
179
|
+
setShown(true)
|
|
180
|
+
setEditing(true)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const fold = (focus: boolean) => {
|
|
184
|
+
refocus.current = focus
|
|
185
|
+
setEditing(false)
|
|
186
|
+
setError('')
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const submit = () => {
|
|
190
|
+
const n = readPage(text, count)
|
|
191
|
+
if (n === null) {
|
|
192
|
+
setError(labels.outOfRange(count))
|
|
193
|
+
const field = fieldRef.current
|
|
194
|
+
if (field) {
|
|
195
|
+
// Replays the shake on every wrong try.
|
|
196
|
+
delete field.dataset.shake
|
|
197
|
+
void field.offsetWidth
|
|
198
|
+
field.dataset.shake = ''
|
|
199
|
+
}
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
go(n)
|
|
203
|
+
fold(true)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const keys = (e: KeyboardEvent<HTMLInputElement>) => {
|
|
207
|
+
if (e.key === 'Enter') {
|
|
208
|
+
e.preventDefault()
|
|
209
|
+
submit()
|
|
210
|
+
} else if (e.key === 'Escape') {
|
|
211
|
+
e.preventDefault()
|
|
212
|
+
e.stopPropagation()
|
|
213
|
+
fold(true)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const words = labels.pageOf(page, count)
|
|
218
|
+
const parts = splitPageOf(words, page)
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<div className={styles.middle}>
|
|
222
|
+
<button ref={numRef} type="button" className={cx(styles.btn, styles.current)} data-slot="pagination-current" aria-label={`${words}, ${labels.goTo}`} inert={editing} onClick={open}>
|
|
223
|
+
<span className={styles.words}>
|
|
224
|
+
{parts ? (
|
|
225
|
+
<>
|
|
226
|
+
{parts[0]}
|
|
227
|
+
<span className={styles.num}>
|
|
228
|
+
<span className={styles.ghost}>{count}</span>
|
|
229
|
+
<Roll text={String(page)} still={last.current.still} />
|
|
230
|
+
</span>
|
|
231
|
+
{parts[1]}
|
|
232
|
+
</>
|
|
233
|
+
) : (
|
|
234
|
+
words
|
|
235
|
+
)}
|
|
236
|
+
</span>
|
|
237
|
+
<span className={styles.line} aria-hidden="true">
|
|
238
|
+
<span className={styles.fill} style={{ transform: `scaleX(${page / count})` }} />
|
|
239
|
+
</span>
|
|
240
|
+
</button>
|
|
241
|
+
<div
|
|
242
|
+
ref={fieldRef}
|
|
243
|
+
className={styles.jump}
|
|
244
|
+
data-slot="pagination-jump"
|
|
245
|
+
data-state={shown ? 'open' : 'closed'}
|
|
246
|
+
data-invalid={error ? '' : undefined}
|
|
247
|
+
inert={!editing}
|
|
248
|
+
// A press on the label or the border would take focus off the input and fold the field.
|
|
249
|
+
onMouseDown={(e) => {
|
|
250
|
+
if (e.target !== inputRef.current) e.preventDefault()
|
|
251
|
+
}}
|
|
252
|
+
onBlur={(e) => {
|
|
253
|
+
if (editing && !e.currentTarget.contains(e.relatedTarget as Node | null)) fold(false)
|
|
254
|
+
}}
|
|
255
|
+
>
|
|
256
|
+
<label htmlFor={`${id}-to`} className={styles.jumpLabel} data-slot="field-label">
|
|
257
|
+
{labels.goTo}
|
|
258
|
+
</label>
|
|
259
|
+
<input
|
|
260
|
+
ref={inputRef}
|
|
261
|
+
id={`${id}-to`}
|
|
262
|
+
className={styles.input}
|
|
263
|
+
data-slot="pagination-jump-input"
|
|
264
|
+
type="text"
|
|
265
|
+
inputMode="numeric"
|
|
266
|
+
enterKeyHint="go"
|
|
267
|
+
autoComplete="off"
|
|
268
|
+
size={String(count).length + 1}
|
|
269
|
+
placeholder={String(page)}
|
|
270
|
+
value={text}
|
|
271
|
+
aria-invalid={error ? true : undefined}
|
|
272
|
+
aria-describedby={error ? `${id}-error` : undefined}
|
|
273
|
+
onChange={(e) => {
|
|
274
|
+
setText(e.target.value)
|
|
275
|
+
setError('')
|
|
276
|
+
}}
|
|
277
|
+
onKeyDown={keys}
|
|
278
|
+
/>
|
|
279
|
+
</div>
|
|
280
|
+
<div className={styles.message}>
|
|
281
|
+
<FieldMessage helpId={`${id}-help`} errorId={`${id}-error`} error={error || undefined} />
|
|
282
|
+
</div>
|
|
283
|
+
<span className={styles.srOnly} aria-live="polite">
|
|
284
|
+
{said}
|
|
285
|
+
</span>
|
|
286
|
+
</div>
|
|
287
|
+
)
|
|
288
|
+
}
|