gooee 0.51.1 → 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
|
@@ -38,45 +38,57 @@ export type TableLabels = {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// The Vue Table: the same look (Table.module.css), sort, groups and row glide (motion/table.ts) as the React one.
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
41
|
+
const {
|
|
42
|
+
columns,
|
|
43
|
+
rows,
|
|
44
|
+
getRowId,
|
|
45
|
+
defaultSort = null,
|
|
46
|
+
groupBy,
|
|
47
|
+
selectable,
|
|
48
|
+
defaultSelected = [],
|
|
49
|
+
rowLabel,
|
|
50
|
+
layout = 'scroll',
|
|
51
|
+
maxHeight,
|
|
52
|
+
emptyText = 'Nothing here yet.',
|
|
53
|
+
loading = false,
|
|
54
|
+
loadingRows = 5,
|
|
55
|
+
labels: labelsProp,
|
|
56
|
+
} = defineProps<{
|
|
57
|
+
/** The columns, in order, and how each one reads and shows a row. */
|
|
58
|
+
columns: TableColumn<T>[]
|
|
59
|
+
/** The data, one item per row. */
|
|
60
|
+
rows: T[]
|
|
61
|
+
/** Returns a stable, unique id for a row. Used for keys, selection and sort motion. */
|
|
62
|
+
getRowId: (row: T) => string
|
|
63
|
+
/** Always required. Names the table for screen readers. */
|
|
64
|
+
caption: string
|
|
65
|
+
/** Hides the caption visually but keeps it for screen readers. */
|
|
66
|
+
hideCaption?: boolean
|
|
67
|
+
/** Starting sort when there is no v-model:sort. */
|
|
68
|
+
defaultSort?: TableSort | null
|
|
69
|
+
/** Gathers rows under a header per group, such as each row's status. Groups keep the order they first
|
|
70
|
+
* appear in; the sort applies inside each group. Rows glide to their group when it changes. */
|
|
71
|
+
groupBy?: (row: T) => string
|
|
72
|
+
/** Adds a checkbox column. */
|
|
73
|
+
selectable?: boolean
|
|
74
|
+
/** Starting selection when there is no v-model:selected. */
|
|
75
|
+
defaultSelected?: string[]
|
|
76
|
+
/** Names each row checkbox, such as the person's name. Defaults to the first column's value. */
|
|
77
|
+
rowLabel?: (row: T) => string
|
|
78
|
+
/** On a narrow screen: 'scroll' keeps the table and scrolls it sideways with the first column
|
|
79
|
+
* in place; 'stack' turns each row into a card with its labels. */
|
|
80
|
+
layout?: 'scroll' | 'stack'
|
|
81
|
+
/** Scrolls the body under a sticky header past this height. A number is pixels. */
|
|
82
|
+
maxHeight?: number | string
|
|
83
|
+
/** Shown in place of rows when there are none. The empty slot replaces it. */
|
|
84
|
+
emptyText?: string
|
|
85
|
+
/** Shows skeleton rows in place of the data and holds sorting and selection still. */
|
|
86
|
+
loading?: boolean
|
|
87
|
+
/** How many skeleton rows show while loading. */
|
|
88
|
+
loadingRows?: number
|
|
89
|
+
/** Screen reader text for checkboxes and sort news. Missing keys use the English defaults. */
|
|
90
|
+
labels?: Partial<TableLabels>
|
|
91
|
+
}>()
|
|
80
92
|
/** The sort: ascending, descending, then null as a header is pressed. Leave it out and the table keeps its own. */
|
|
81
93
|
const sortModel = defineModel<TableSort | null | undefined>('sort', { default: undefined })
|
|
82
94
|
/** Ids of the selected rows. Leave it out and the table keeps its own. */
|
|
@@ -90,13 +102,13 @@ const labels = computed<TableLabels>(() => ({
|
|
|
90
102
|
unsorted: (column) => `No longer sorted by ${column}`,
|
|
91
103
|
groupCount: (count) => `${count} ${count === 1 ? 'row' : 'rows'}`,
|
|
92
104
|
loading: 'Loading rows',
|
|
93
|
-
...
|
|
105
|
+
...labelsProp,
|
|
94
106
|
}))
|
|
95
107
|
const id = useId()
|
|
96
108
|
const px = (v: number | string | undefined) => (typeof v === 'number' ? `${v}px` : v)
|
|
97
109
|
|
|
98
|
-
const sort = computed(() => (sortModel.value === undefined ?
|
|
99
|
-
const selected = computed(() => selectedModel.value ??
|
|
110
|
+
const sort = computed(() => (sortModel.value === undefined ? defaultSort : sortModel.value))
|
|
111
|
+
const selected = computed(() => selectedModel.value ?? defaultSelected)
|
|
100
112
|
const announce = ref('')
|
|
101
113
|
|
|
102
114
|
const scrollEl = ref<HTMLDivElement | null>(null)
|
|
@@ -110,19 +122,16 @@ const measure = () => {
|
|
|
110
122
|
const reveal = (e: FocusEvent) => scrollEl.value && revealCell(scrollEl.value, e.target)
|
|
111
123
|
let ro: ResizeObserver | undefined
|
|
112
124
|
|
|
113
|
-
const sorted = computed(() => sortRows(
|
|
125
|
+
const sorted = computed(() => sortRows(rows, columns, sort.value))
|
|
114
126
|
const groupOrder: string[] = []
|
|
115
|
-
const groups = computed(() => (
|
|
116
|
-
const
|
|
117
|
-
const order = computed(() => (groups.value ? groups.value.map((g) => `${g.key}:${g.rows.map(props.getRowId).join(',')}`).join('|') : sorted.value.map(props.getRowId).join('|')))
|
|
127
|
+
const groups = computed(() => (groupBy ? groupRows(rows, sorted.value, groupBy, groupOrder) : null))
|
|
128
|
+
const order = computed(() => (groups.value ? groups.value.map((g) => `${g.key}:${g.rows.map(getRowId).join(',')}`).join('|') : sorted.value.map(getRowId).join('|')))
|
|
118
129
|
|
|
119
|
-
// FLIP: rows glide to their new place after a sort
|
|
130
|
+
// FLIP: rows glide to their new place after a sort or a regroup (motion/table.ts).
|
|
120
131
|
let lastTops = new Map<string, number>()
|
|
121
|
-
let lastShape = ''
|
|
122
132
|
const flip = () => {
|
|
123
133
|
if (!tableEl.value) return
|
|
124
|
-
lastTops = flipRows(tableEl.value, lastTops
|
|
125
|
-
lastShape = shape.value
|
|
134
|
+
lastTops = flipRows(tableEl.value, lastTops)
|
|
126
135
|
}
|
|
127
136
|
watch(order, flip, { flush: 'post' })
|
|
128
137
|
onMounted(() => {
|
|
@@ -140,18 +149,18 @@ const labelOf = (c: TableColumn<T>) => c.label ?? (typeof c.header === 'string'
|
|
|
140
149
|
const toggleSort = (key: string) => {
|
|
141
150
|
const next = nextSort(sort.value, key)
|
|
142
151
|
sortModel.value = next
|
|
143
|
-
const col =
|
|
152
|
+
const col = columns.find((c) => c.key === key)
|
|
144
153
|
const name = col ? labelOf(col) : key
|
|
145
154
|
announce.value = next ? labels.value.sortedBy(name, next.direction) : labels.value.unsorted(name)
|
|
146
155
|
}
|
|
147
156
|
|
|
148
|
-
const ids = computed(() => sorted.value.map(
|
|
157
|
+
const ids = computed(() => sorted.value.map(getRowId))
|
|
149
158
|
const selectedSet = computed(() => new Set(selected.value))
|
|
150
159
|
const allOn = computed(() => ids.value.length > 0 && ids.value.every((r) => selectedSet.value.has(r)))
|
|
151
160
|
const someOn = computed(() => !allOn.value && ids.value.some((r) => selectedSet.value.has(r)))
|
|
152
|
-
const scrollable = computed(() => Boolean(
|
|
153
|
-
const nameOf = (row: T) => (
|
|
154
|
-
const colCount = computed(() =>
|
|
161
|
+
const scrollable = computed(() => Boolean(maxHeight) || more.value.start || more.value.end)
|
|
162
|
+
const nameOf = (row: T) => (rowLabel ? rowLabel(row) : String(read(row, columns[0]?.key ?? '') ?? getRowId(row)))
|
|
163
|
+
const colCount = computed(() => columns.length + (selectable ? 1 : 0))
|
|
155
164
|
const setRow = (rid: string, on: boolean) => (selectedModel.value = on ? [...selected.value, rid] : selected.value.filter((s) => s !== rid))
|
|
156
165
|
const setAll = (on: boolean) => (selectedModel.value = on ? Array.from(new Set([...selected.value, ...ids.value])) : selected.value.filter((s) => !ids.value.includes(s)))
|
|
157
166
|
|
|
@@ -159,17 +168,18 @@ const setAll = (on: boolean) => (selectedModel.value = on ? Array.from(new Set([
|
|
|
159
168
|
const rowGroups = computed(() => {
|
|
160
169
|
let i = 0
|
|
161
170
|
const list = groups.value && groups.value.length > 0 ? groups.value : [{ key: '', rows: sorted.value }]
|
|
162
|
-
return list.map((g) => ({ key: g.key, rows: g.rows.map((row) => ({ row, rid:
|
|
171
|
+
return list.map((g) => ({ key: g.key, rows: g.rows.map((row) => ({ row, rid: getRowId(row), i: Math.min(i++, 12) })) }))
|
|
163
172
|
})
|
|
164
173
|
// Draws what a header or cell function returns.
|
|
165
174
|
const Out: FunctionalComponent<{ v: VNodeChild }> = (p) => p.v
|
|
166
175
|
</script>
|
|
167
176
|
|
|
168
177
|
<template>
|
|
169
|
-
<div :class="styles.root" :data-layout="layout" :data-more-start="more.start || undefined" :data-more-end="more.end || undefined">
|
|
178
|
+
<div :class="styles.root" data-slot="table" :data-layout="layout" :data-more-start="more.start || undefined" :data-more-end="more.end || undefined">
|
|
170
179
|
<div
|
|
171
180
|
ref="scrollEl"
|
|
172
181
|
:class="styles.scroll"
|
|
182
|
+
data-slot="table-container"
|
|
173
183
|
:style="{ maxHeight: px(maxHeight) }"
|
|
174
184
|
:tabindex="scrollable ? 0 : undefined"
|
|
175
185
|
:role="scrollable ? 'region' : undefined"
|
|
@@ -178,13 +188,14 @@ const Out: FunctionalComponent<{ v: VNodeChild }> = (p) => p.v
|
|
|
178
188
|
@focusin="reveal"
|
|
179
189
|
>
|
|
180
190
|
<!-- Explicit roles keep table semantics when rows restyle as cards (layout="stack") -->
|
|
181
|
-
<table ref="tableEl" role="table" :class="styles.table" :aria-labelledby="`${id}-cap`" :aria-busy="loading || undefined">
|
|
182
|
-
<caption :id="`${id}-cap`" :class="[styles.caption, hideCaption && styles.srOnly]">{{ caption }}</caption>
|
|
183
|
-
<thead role="rowgroup" :class="styles.head">
|
|
191
|
+
<table ref="tableEl" role="table" :class="styles.table" data-slot="table-element" :aria-labelledby="`${id}-cap`" :aria-busy="loading || undefined">
|
|
192
|
+
<caption :id="`${id}-cap`" :class="[styles.caption, hideCaption && styles.srOnly]" data-slot="table-caption">{{ caption }}</caption>
|
|
193
|
+
<thead role="rowgroup" :class="styles.head" data-slot="table-header">
|
|
184
194
|
<tr role="row">
|
|
185
|
-
<th v-if="selectable" role="columnheader" scope="col" :class="styles.checkCell">
|
|
186
|
-
<span :class="styles.check">
|
|
195
|
+
<th v-if="selectable" role="columnheader" scope="col" :class="styles.checkCell" data-slot="table-head">
|
|
196
|
+
<span :class="styles.check" data-slot="table-checkbox">
|
|
187
197
|
<input
|
|
198
|
+
data-slot="table-checkbox-input"
|
|
188
199
|
type="checkbox"
|
|
189
200
|
:aria-label="labels.selectAll"
|
|
190
201
|
:checked="allOn"
|
|
@@ -193,7 +204,7 @@ const Out: FunctionalComponent<{ v: VNodeChild }> = (p) => p.v
|
|
|
193
204
|
:class="styles.checkInput"
|
|
194
205
|
@change="setAll(($event.target as HTMLInputElement).checked)"
|
|
195
206
|
/>
|
|
196
|
-
<span :class="styles.checkBox" :data-state="someOn ? '
|
|
207
|
+
<span :class="styles.checkBox" data-slot="table-checkbox-indicator" :data-state="someOn ? 'indeterminate' : allOn ? 'checked' : 'unchecked'" aria-hidden="true">
|
|
197
208
|
<svg viewBox="0 0 16 16"><path :class="styles.tick" d="M3.5 8.5l3 3 6-7" pathLength="1" /><path :class="styles.dash" d="M4 8h8" pathLength="1" /></svg>
|
|
198
209
|
</span>
|
|
199
210
|
</span>
|
|
@@ -205,6 +216,7 @@ const Out: FunctionalComponent<{ v: VNodeChild }> = (p) => p.v
|
|
|
205
216
|
scope="col"
|
|
206
217
|
:aria-sort="c.sortable ? (sort?.key === c.key ? sort.direction : 'none') : undefined"
|
|
207
218
|
:class="styles.th"
|
|
219
|
+
data-slot="table-head"
|
|
208
220
|
:data-align="c.align ?? 'start'"
|
|
209
221
|
:data-sortable="c.sortable || undefined"
|
|
210
222
|
:style="{ width: px(c.width) }"
|
|
@@ -213,12 +225,13 @@ const Out: FunctionalComponent<{ v: VNodeChild }> = (p) => p.v
|
|
|
213
225
|
v-if="c.sortable"
|
|
214
226
|
type="button"
|
|
215
227
|
:class="styles.sortButton"
|
|
228
|
+
data-slot="table-sort"
|
|
216
229
|
:disabled="loading"
|
|
217
|
-
:data-
|
|
230
|
+
:data-state="sort?.key === c.key ? 'active' : 'inactive'"
|
|
218
231
|
@click="toggleSort(c.key)"
|
|
219
232
|
>
|
|
220
233
|
<span><Out :v="typeof c.header === 'string' ? c.header : c.header()" /></span>
|
|
221
|
-
<svg viewBox="0 0 16 16" :class="styles.sortIcon" :data-dir="sort?.key === c.key ? sort.direction : undefined" aria-hidden="true">
|
|
234
|
+
<svg viewBox="0 0 16 16" :class="styles.sortIcon" data-slot="table-sort-icon" :data-dir="sort?.key === c.key ? sort.direction : undefined" aria-hidden="true">
|
|
222
235
|
<path d="M8 12.5v-9M4.5 7L8 3.5 11.5 7" />
|
|
223
236
|
</svg>
|
|
224
237
|
</button>
|
|
@@ -226,43 +239,44 @@ const Out: FunctionalComponent<{ v: VNodeChild }> = (p) => p.v
|
|
|
226
239
|
</th>
|
|
227
240
|
</tr>
|
|
228
241
|
</thead>
|
|
229
|
-
<tbody v-if="loading" role="rowgroup">
|
|
230
|
-
<tr v-for="r in loadingRows" :key="r" aria-hidden="true" :class="[styles.row, styles.loadingRow]">
|
|
231
|
-
<td v-if="selectable" :class="styles.checkCell" />
|
|
232
|
-
<td v-for="(c, i) in columns" :key="c.key" :class="styles.td" :data-align="c.align ?? 'start'" :data-label="labelOf(c)">
|
|
242
|
+
<tbody v-if="loading" role="rowgroup" data-slot="table-body">
|
|
243
|
+
<tr v-for="r in loadingRows" :key="r" aria-hidden="true" :class="[styles.row, styles.loadingRow]" data-slot="table-row">
|
|
244
|
+
<td v-if="selectable" :class="styles.checkCell" data-slot="table-cell" />
|
|
245
|
+
<td v-for="(c, i) in columns" :key="c.key" :class="styles.td" data-slot="table-cell" :data-align="c.align ?? 'start'" :data-label="labelOf(c)">
|
|
233
246
|
<Skeleton shape="text" :width="`${[72, 56, 84][(r - 1 + i) % 3]}%`" />
|
|
234
247
|
</td>
|
|
235
248
|
</tr>
|
|
236
249
|
</tbody>
|
|
237
250
|
<template v-else>
|
|
238
|
-
<tbody v-for="g in rowGroups" :key="g.key" role="rowgroup" v-bind="groups && groups.length > 0 ? { class: styles.group } : {}">
|
|
239
|
-
<tr v-if="groups && groups.length > 0" role="row" :data-row-id="`group:${g.key}`" :class="styles.groupRow">
|
|
240
|
-
<th role="rowheader" scope="rowgroup" :colspan="colCount" :class="styles.groupHead">
|
|
241
|
-
<span>{{ g.key }}</span>{{ ' ' }}<span :class="styles.groupCount">{{ labels.groupCount(g.rows.length) }}</span>
|
|
251
|
+
<tbody v-for="g in rowGroups" :key="g.key" role="rowgroup" data-slot="table-body" v-bind="groups && groups.length > 0 ? { class: styles.group } : {}">
|
|
252
|
+
<tr v-if="groups && groups.length > 0" role="row" :data-row-id="`group:${g.key}`" :class="styles.groupRow" data-slot="table-group-row">
|
|
253
|
+
<th role="rowheader" scope="rowgroup" :colspan="colCount" :class="styles.groupHead" data-slot="table-group-head">
|
|
254
|
+
<span>{{ g.key }}</span>{{ ' ' }}<span :class="styles.groupCount" data-slot="table-group-count">{{ labels.groupCount(g.rows.length) }}</span>
|
|
242
255
|
</th>
|
|
243
256
|
</tr>
|
|
244
|
-
<tr v-for="{ row, rid, i } in g.rows" :key="rid" role="row" :data-row-id="rid" :class="styles.row" :data-selected="selectedSet.has(rid) || undefined" :style="{ '--i': i }">
|
|
245
|
-
<td v-if="selectable" role="cell" :class="styles.checkCell">
|
|
246
|
-
<span :class="styles.check">
|
|
257
|
+
<tr v-for="{ row, rid, i } in g.rows" :key="rid" role="row" :data-row-id="rid" :class="styles.row" data-slot="table-row" :data-selected="selectedSet.has(rid) || undefined" :style="{ '--i': i }">
|
|
258
|
+
<td v-if="selectable" role="cell" :class="styles.checkCell" data-slot="table-cell">
|
|
259
|
+
<span :class="styles.check" data-slot="table-checkbox">
|
|
247
260
|
<input
|
|
261
|
+
data-slot="table-checkbox-input"
|
|
248
262
|
type="checkbox"
|
|
249
263
|
:aria-label="labels.selectRow(nameOf(row))"
|
|
250
264
|
:checked="selectedSet.has(rid)"
|
|
251
265
|
:class="styles.checkInput"
|
|
252
266
|
@change="setRow(rid, ($event.target as HTMLInputElement).checked)"
|
|
253
267
|
/>
|
|
254
|
-
<span :class="styles.checkBox" :data-state="selectedSet.has(rid) ? '
|
|
268
|
+
<span :class="styles.checkBox" data-slot="table-checkbox-indicator" :data-state="selectedSet.has(rid) ? 'checked' : 'unchecked'" aria-hidden="true">
|
|
255
269
|
<svg viewBox="0 0 16 16"><path :class="styles.tick" d="M3.5 8.5l3 3 6-7" pathLength="1" /><path :class="styles.dash" d="M4 8h8" pathLength="1" /></svg>
|
|
256
270
|
</span>
|
|
257
271
|
</span>
|
|
258
272
|
</td>
|
|
259
|
-
<td v-for="c in columns" :key="c.key" role="cell" :class="styles.td" :data-align="c.align ?? 'start'" :data-label="labelOf(c)">
|
|
273
|
+
<td v-for="c in columns" :key="c.key" role="cell" :class="styles.td" data-slot="table-cell" :data-align="c.align ?? 'start'" :data-label="labelOf(c)">
|
|
260
274
|
<!-- One wrapper, so the card layout always gets a label and a value -->
|
|
261
275
|
<span><Out :v="c.cell ? c.cell(row) : String(read(row, c.key) ?? '')" /></span>
|
|
262
276
|
</td>
|
|
263
277
|
</tr>
|
|
264
278
|
<tr v-if="!groups?.length && sorted.length === 0" role="row">
|
|
265
|
-
<td role="cell" :colspan="colCount" :class="styles.empty"><slot name="empty">{{ emptyText }}</slot></td>
|
|
279
|
+
<td role="cell" :colspan="colCount" :class="styles.empty" data-slot="table-empty"><slot name="empty">{{ emptyText }}</slot></td>
|
|
266
280
|
</tr>
|
|
267
281
|
</tbody>
|
|
268
282
|
</template>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.root {
|
|
2
3
|
display: flex;
|
|
3
4
|
flex-direction: column;
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
font-size: var(--gooee-text-sm);
|
|
43
44
|
line-height: var(--gooee-leading-snug);
|
|
44
45
|
text-decoration: none;
|
|
45
|
-
transition: color var(--gooee-motion-fast) var(--gooee-ease-
|
|
46
|
+
transition: color var(--gooee-motion-fast) var(--gooee-ease-morph), background-color var(--gooee-motion-fast) var(--gooee-ease-morph);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
.link::after {
|
|
@@ -70,16 +71,16 @@
|
|
|
70
71
|
border-radius: var(--gooee-radius-full);
|
|
71
72
|
background: var(--gooee-color-bg);
|
|
72
73
|
transition:
|
|
73
|
-
background-color var(--gooee-motion-base) var(--gooee-ease-
|
|
74
|
-
border-color var(--gooee-motion-base) var(--gooee-ease-
|
|
75
|
-
box-shadow var(--gooee-motion-base) var(--gooee-ease-
|
|
74
|
+
background-color var(--gooee-motion-base) var(--gooee-ease-morph),
|
|
75
|
+
border-color var(--gooee-motion-base) var(--gooee-ease-morph),
|
|
76
|
+
box-shadow var(--gooee-motion-base) var(--gooee-ease-morph);
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
[data-
|
|
79
|
+
[data-status="read"] .node { border-color: var(--gooee-color-fg-subtle); background: var(--gooee-color-fg-subtle); }
|
|
79
80
|
|
|
80
|
-
[data-
|
|
81
|
+
[data-status="here"] .link { color: var(--gooee-color-fg); font-weight: var(--gooee-weight-medium); }
|
|
81
82
|
|
|
82
|
-
[data-
|
|
83
|
+
[data-status="here"] .node {
|
|
83
84
|
border-color: var(--gooee-color-fg);
|
|
84
85
|
background: var(--gooee-color-fg);
|
|
85
86
|
box-shadow: 0 0 0 var(--gooee-space-1) var(--gooee-color-bg), 0 0 0 calc(var(--gooee-space-1) + var(--gooee-line-thick)) var(--gooee-color-fg);
|
|
@@ -105,3 +106,4 @@
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
.toTop:focus-visible { outline: none; box-shadow: var(--gooee-focus-ring); }
|
|
109
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useState, type MouseEvent } from 'react'
|
|
4
4
|
import { cx } from '../../internal/cx'
|
|
5
|
-
import { ArrowUpIcon } from '../../
|
|
5
|
+
import { ArrowUpIcon } from '../../icons/icons'
|
|
6
6
|
import { prefersReducedMotion } from '../../internal/motion'
|
|
7
7
|
import styles from './TableOfContents.module.css'
|
|
8
8
|
|
|
@@ -70,20 +70,20 @@ export function TableOfContents({ items, title = 'On this page', backToTop = fal
|
|
|
70
70
|
|
|
71
71
|
const at = Math.max(0, items.findIndex((t) => t.id === active))
|
|
72
72
|
return (
|
|
73
|
-
<nav className={cx(styles.root, className)} aria-label={title}>
|
|
74
|
-
<p className={styles.title}>{title}</p>
|
|
75
|
-
<ol className={styles.list}>
|
|
73
|
+
<nav className={cx(styles.root, className)} data-slot="table-of-contents" aria-label={title}>
|
|
74
|
+
<p className={styles.title} data-slot="table-of-contents-title">{title}</p>
|
|
75
|
+
<ol className={styles.list} data-slot="table-of-contents-list">
|
|
76
76
|
{items.map((t, n) => (
|
|
77
|
-
<li key={t.id} data-
|
|
78
|
-
<a href={`#${t.id}`} className={styles.link} aria-current={active === t.id ? 'location' : undefined} onClick={(e) => go(e, t.id)}>
|
|
79
|
-
<span className={styles.node} aria-hidden="true" />
|
|
77
|
+
<li key={t.id} data-slot="table-of-contents-item" data-status={n < at ? 'read' : n === at ? 'here' : 'ahead'}>
|
|
78
|
+
<a href={`#${t.id}`} className={styles.link} data-slot="table-of-contents-link" aria-current={active === t.id ? 'location' : undefined} onClick={(e) => go(e, t.id)}>
|
|
79
|
+
<span className={styles.node} data-slot="table-of-contents-node" aria-hidden="true" />
|
|
80
80
|
{t.label}
|
|
81
81
|
</a>
|
|
82
82
|
</li>
|
|
83
83
|
))}
|
|
84
84
|
</ol>
|
|
85
85
|
{backToTop && at > 0 && (
|
|
86
|
-
<a href="#" className={styles.toTop} onClick={toTop}>
|
|
86
|
+
<a href="#" className={styles.toTop} data-slot="table-of-contents-to-top" onClick={toTop}>
|
|
87
87
|
<ArrowUpIcon aria-hidden="true" />
|
|
88
88
|
Back to top
|
|
89
89
|
</a>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
3
3
|
import { prefersReducedMotion } from '../../internal/motion'
|
|
4
|
-
import { ArrowUpIcon } from '../../
|
|
4
|
+
import { ArrowUpIcon } from '../../icons/vue'
|
|
5
5
|
import styles from './TableOfContents.module.css'
|
|
6
6
|
|
|
7
7
|
// The Vue TableOfContents: the same look (TableOfContents.module.css) and reading strip as the React one.
|
|
@@ -12,20 +12,17 @@ export type TocItem = {
|
|
|
12
12
|
label: string
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}>(),
|
|
24
|
-
{ title: 'On this page', backToTop: false },
|
|
25
|
-
)
|
|
15
|
+
const { items, title = 'On this page', backToTop = false } = defineProps<{
|
|
16
|
+
/** The sections, in page order: each heading's id and the text to show for it. */
|
|
17
|
+
items: TocItem[]
|
|
18
|
+
/** Heading above the list, also the nav's name. */
|
|
19
|
+
title?: string
|
|
20
|
+
/** Adds a way back to the top once the reader has passed the first section. */
|
|
21
|
+
backToTop?: boolean
|
|
22
|
+
}>()
|
|
26
23
|
|
|
27
|
-
const active = ref(
|
|
28
|
-
const at = computed(() => Math.max(0,
|
|
24
|
+
const active = ref(items[0]?.id)
|
|
25
|
+
const at = computed(() => Math.max(0, items.findIndex((t) => t.id === active.value)))
|
|
29
26
|
|
|
30
27
|
// The section being read is the last heading past the top third of the screen.
|
|
31
28
|
let headings: HTMLElement[] = []
|
|
@@ -38,7 +35,7 @@ const update = () => {
|
|
|
38
35
|
active.value = atBottom ? headings[headings.length - 1]?.id : current
|
|
39
36
|
}
|
|
40
37
|
const find = () => {
|
|
41
|
-
headings =
|
|
38
|
+
headings = items.map((t) => document.getElementById(t.id)).filter((h): h is HTMLElement => !!h)
|
|
42
39
|
update()
|
|
43
40
|
}
|
|
44
41
|
onMounted(() => {
|
|
@@ -46,7 +43,7 @@ onMounted(() => {
|
|
|
46
43
|
window.addEventListener('scroll', update, { passive: true })
|
|
47
44
|
window.addEventListener('resize', update)
|
|
48
45
|
})
|
|
49
|
-
watch(() =>
|
|
46
|
+
watch(() => items, find)
|
|
50
47
|
onBeforeUnmount(() => {
|
|
51
48
|
window.removeEventListener('scroll', update)
|
|
52
49
|
window.removeEventListener('resize', update)
|
|
@@ -74,16 +71,16 @@ const toTop = (e: MouseEvent) => {
|
|
|
74
71
|
</script>
|
|
75
72
|
|
|
76
73
|
<template>
|
|
77
|
-
<nav :class="styles.root" :aria-label="title">
|
|
78
|
-
<p :class="styles.title">{{ title }}</p>
|
|
79
|
-
<ol :class="styles.list">
|
|
80
|
-
<li v-for="(t, n) in items" :key="t.id" :data-
|
|
81
|
-
<a :href="`#${t.id}`" :class="styles.link" :aria-current="active === t.id ? 'location' : undefined" @click="go($event, t.id)">
|
|
82
|
-
<span :class="styles.node" aria-hidden="true" />{{ t.label }}</a
|
|
74
|
+
<nav :class="styles.root" data-slot="table-of-contents" :aria-label="title">
|
|
75
|
+
<p :class="styles.title" data-slot="table-of-contents-title">{{ title }}</p>
|
|
76
|
+
<ol :class="styles.list" data-slot="table-of-contents-list">
|
|
77
|
+
<li v-for="(t, n) in items" :key="t.id" data-slot="table-of-contents-item" :data-status="n < at ? 'read' : n === at ? 'here' : 'ahead'">
|
|
78
|
+
<a :href="`#${t.id}`" :class="styles.link" data-slot="table-of-contents-link" :aria-current="active === t.id ? 'location' : undefined" @click="go($event, t.id)">
|
|
79
|
+
<span :class="styles.node" data-slot="table-of-contents-node" aria-hidden="true" />{{ t.label }}</a
|
|
83
80
|
>
|
|
84
81
|
</li>
|
|
85
82
|
</ol>
|
|
86
|
-
<a v-if="backToTop && at > 0" href="#" :class="styles.toTop" @click="toTop">
|
|
83
|
+
<a v-if="backToTop && at > 0" href="#" :class="styles.toTop" data-slot="table-of-contents-to-top" @click="toTop">
|
|
87
84
|
<ArrowUpIcon aria-hidden="true" />Back to top</a
|
|
88
85
|
>
|
|
89
86
|
</nav>
|
|
@@ -39,9 +39,9 @@ onBeforeUnmount(() => {
|
|
|
39
39
|
|
|
40
40
|
<template>
|
|
41
41
|
<div :class="styles.listScroll">
|
|
42
|
-
<div ref="list" role="tablist" :aria-label="label" :class="styles.list" @keydown="tabKey(list, $event)">
|
|
42
|
+
<div ref="list" role="tablist" :aria-label="label" :class="styles.list" data-slot="tabs-list" data-orientation="horizontal" @keydown="tabKey(list, $event)">
|
|
43
43
|
<slot />
|
|
44
|
-
<span v-if="bar" ref="riseEl" :class="styles.rise" aria-hidden="true" />
|
|
44
|
+
<span v-if="bar" ref="riseEl" :class="styles.rise" data-slot="tabs-indicator" aria-hidden="true" />
|
|
45
45
|
</div>
|
|
46
46
|
</div>
|
|
47
47
|
</template>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.root {
|
|
2
3
|
/* The panel's surface; the chosen tab rises out of it in the same colour (--gooee-tabs-panel, by theme). */
|
|
3
|
-
--tabs-panel: var(--gooee-tabs-panel);
|
|
4
|
+
--tabs-panel: var(--gooee-tabs-panel, light-dark(var(--gooee-color-surface-active), var(--gooee-color-surface-sunken)));
|
|
4
5
|
--tabs-r: var(--gooee-radius-md);
|
|
5
6
|
display: flex;
|
|
6
7
|
flex-direction: column;
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
|
|
57
58
|
.tab:focus-visible {
|
|
58
59
|
outline: none;
|
|
59
|
-
box-shadow: inset 0 0 0 var(--gooee-
|
|
60
|
+
box-shadow: inset 0 0 0 var(--gooee-focus-width) var(--gooee-color-fg);
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
/* The rise: the panel's surface grown up behind the chosen tab, with rounded top corners and soft inside
|
|
@@ -100,3 +101,4 @@
|
|
|
100
101
|
@keyframes panelIn {
|
|
101
102
|
from { opacity: 0; }
|
|
102
103
|
}
|
|
104
|
+
}
|
|
@@ -42,11 +42,11 @@ export function Tabs({ value: valueProp, defaultValue, onValueChange, className,
|
|
|
42
42
|
const baseId = useId()
|
|
43
43
|
const [value, set] = useControllable(valueProp, defaultValue, onValueChange)
|
|
44
44
|
return (
|
|
45
|
-
<TabsCtx
|
|
46
|
-
<div className={cx(styles.root, className)} data-gooee-tabs="">
|
|
45
|
+
<TabsCtx value={{ value, set, baseId }}>
|
|
46
|
+
<div className={cx(styles.root, className)} data-slot="tabs" data-gooee-tabs="">
|
|
47
47
|
{children}
|
|
48
48
|
</div>
|
|
49
|
-
</TabsCtx
|
|
49
|
+
</TabsCtx>
|
|
50
50
|
)
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -90,10 +90,10 @@ export function TabList({ label, className, children }: TabListProps) {
|
|
|
90
90
|
|
|
91
91
|
return (
|
|
92
92
|
<div className={cx(styles.listScroll, className)}>
|
|
93
|
-
<div ref={listRef} role="tablist" aria-label={label} className={styles.list} onKeyDown={onKeyDown}>
|
|
93
|
+
<div ref={listRef} role="tablist" aria-label={label} className={styles.list} data-slot="tabs-list" data-orientation="horizontal" onKeyDown={onKeyDown}>
|
|
94
94
|
{children}
|
|
95
95
|
{bar && (
|
|
96
|
-
<span ref={riseRef} className={styles.rise} aria-hidden="true" />
|
|
96
|
+
<span ref={riseRef} className={styles.rise} data-slot="tabs-indicator" aria-hidden="true" />
|
|
97
97
|
)}
|
|
98
98
|
</div>
|
|
99
99
|
</div>
|
|
@@ -123,6 +123,9 @@ export function Tab({ value, disabled, children }: TabProps) {
|
|
|
123
123
|
tabIndex={on ? 0 : -1}
|
|
124
124
|
disabled={disabled}
|
|
125
125
|
className={styles.tab}
|
|
126
|
+
data-slot="tabs-trigger"
|
|
127
|
+
data-state={on ? 'active' : 'inactive'}
|
|
128
|
+
data-disabled={disabled || undefined}
|
|
126
129
|
onClick={() => {
|
|
127
130
|
ctx.set(value)
|
|
128
131
|
revealTab(id)
|
|
@@ -153,6 +156,8 @@ export function TabPanel({ value, className, children }: TabPanelProps) {
|
|
|
153
156
|
hidden={!on}
|
|
154
157
|
tabIndex={0}
|
|
155
158
|
className={cx(styles.panel, className)}
|
|
159
|
+
data-slot="tabs-panel"
|
|
160
|
+
data-state={on ? 'active' : 'inactive'}
|
|
156
161
|
>
|
|
157
162
|
{on && children}
|
|
158
163
|
</div>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.root {
|
|
2
3
|
display: inline-flex;
|
|
3
4
|
width: fit-content;
|
|
@@ -10,11 +11,11 @@
|
|
|
10
11
|
font-size: var(--gooee-text-sm);
|
|
11
12
|
white-space: nowrap;
|
|
12
13
|
vertical-align: middle;
|
|
13
|
-
animation: tagIn var(--gooee-motion-slow) var(--gooee-ease-
|
|
14
|
+
animation: tagIn var(--gooee-motion-slow) var(--gooee-ease-morph);
|
|
14
15
|
transition:
|
|
15
|
-
background-color var(--gooee-motion-base) var(--gooee-ease-
|
|
16
|
-
color var(--gooee-motion-base) var(--gooee-ease-
|
|
17
|
-
border-color var(--gooee-motion-base) var(--gooee-ease-
|
|
16
|
+
background-color var(--gooee-motion-base) var(--gooee-ease-morph),
|
|
17
|
+
color var(--gooee-motion-base) var(--gooee-ease-morph),
|
|
18
|
+
border-color var(--gooee-motion-base) var(--gooee-ease-morph);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
.selected {
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
font-size: inherit;
|
|
45
46
|
cursor: pointer;
|
|
46
47
|
border-radius: inherit;
|
|
47
|
-
transition: transform var(--gooee-motion-slow) var(--gooee-ease-
|
|
48
|
+
transition: transform var(--gooee-motion-slow) var(--gooee-ease-morph);
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
.toggle::after {
|
|
@@ -73,12 +74,12 @@
|
|
|
73
74
|
font-size: var(--gooee-icon-sm);
|
|
74
75
|
opacity: 0;
|
|
75
76
|
transition:
|
|
76
|
-
width var(--gooee-motion-base) var(--gooee-ease-
|
|
77
|
-
margin var(--gooee-motion-base) var(--gooee-ease-
|
|
78
|
-
opacity var(--gooee-motion-base) var(--gooee-ease-
|
|
77
|
+
width var(--gooee-motion-base) var(--gooee-ease-morph),
|
|
78
|
+
margin var(--gooee-motion-base) var(--gooee-ease-morph),
|
|
79
|
+
opacity var(--gooee-motion-base) var(--gooee-ease-morph);
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
.
|
|
82
|
+
.toggle[data-state="on"] .check {
|
|
82
83
|
width: var(--gooee-icon-sm);
|
|
83
84
|
margin-right: 0;
|
|
84
85
|
opacity: 1;
|
|
@@ -100,7 +101,7 @@
|
|
|
100
101
|
font-size: var(--gooee-icon-sm);
|
|
101
102
|
cursor: pointer;
|
|
102
103
|
opacity: 0.7;
|
|
103
|
-
transition: background-color var(--gooee-motion-fast) var(--gooee-ease-
|
|
104
|
+
transition: background-color var(--gooee-motion-fast) var(--gooee-ease-morph), opacity var(--gooee-motion-fast) var(--gooee-ease-morph);
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
.remove::after {
|
|
@@ -118,3 +119,4 @@
|
|
|
118
119
|
@keyframes tagIn {
|
|
119
120
|
from { opacity: 0; transform: scale(0.85); }
|
|
120
121
|
}
|
|
122
|
+
}
|