@greenharness/greenrack-ui 7.0.1 → 7.0.2
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/dist/{Table-CT2te7FV.js → Table-ojMk5CaF.js} +9 -9
- package/dist/Table-ojMk5CaF.js.map +1 -0
- package/dist/components/ButtonGroup/ButtonGroup.stories.d.ts +9 -0
- package/dist/components/ButtonGroup/ButtonGroup.stories.d.ts.map +1 -1
- package/dist/components/ButtonGroup/attached.css.d.ts.map +1 -1
- package/dist/components/Drawer/touchInput.d.ts +5 -0
- package/dist/components/Drawer/touchInput.d.ts.map +1 -1
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Select/styles.css.d.ts +9 -0
- package/dist/components/Select/styles.css.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +384 -374
- package/dist/index.js.map +1 -1
- package/dist/table.js +1 -1
- package/package.json +2 -2
- package/src/components/ButtonGroup/ButtonGroup.stories.tsx +70 -1
- package/src/components/ButtonGroup/attached.css.ts +4 -3
- package/src/components/Drawer/touchInput.ts +8 -0
- package/src/components/Select/Select.tsx +1 -0
- package/src/components/Select/styles.css.ts +15 -0
- package/src/components/Toggle/styles.css.ts +4 -4
- package/dist/Table-CT2te7FV.js.map +0 -1
package/dist/table.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as F, v as xt, R as it, H as pt, w as kt, x as bt, y as ft, z as mt, e as ht, a as yt, r as St, A as Tt } from "./Table-
|
|
1
|
+
import { M as F, v as xt, R as it, H as pt, w as kt, x as bt, y as ft, z as mt, e as ht, a as yt, r as St, A as Tt } from "./Table-ojMk5CaF.js";
|
|
2
2
|
import { jsx as g, jsxs as P } from "react/jsx-runtime";
|
|
3
3
|
import { c as H, m as k, d as b } from "./compiler-runtime-CV6vsf8h.js";
|
|
4
4
|
import { flexRender as E, useReactTable as rt, getPaginationRowModel as Ct, getFilteredRowModel as vt, getSortedRowModel as at, getCoreRowModel as st } from "@tanstack/react-table";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@greenharness/greenrack-ui",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@tanstack/react-virtual": "^3.14.13",
|
|
94
94
|
"qrcode": "^1.5.4",
|
|
95
|
-
"@greenharness/greenrack-tokens": "^7.0.
|
|
95
|
+
"@greenharness/greenrack-tokens": "^7.0.2"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@babel/preset-typescript": "^7.28.0",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {useState} from 'react'
|
|
1
|
+
import {useEffect, useState} from 'react'
|
|
2
|
+
import {html} from 'react-strict-dom'
|
|
2
3
|
import type {Meta, StoryObj} from '@storybook/react'
|
|
3
4
|
import {expect, userEvent, waitFor, within} from 'storybook/test'
|
|
4
5
|
import {
|
|
@@ -13,6 +14,7 @@ import {withCoarsePointer, withFinePointer} from '../../docs/coarsePointer'
|
|
|
13
14
|
import {ButtonGroup} from './ButtonGroup'
|
|
14
15
|
import type {ControlSize} from '../../shared/types'
|
|
15
16
|
import {Button} from '../Button/Button'
|
|
17
|
+
import {centre, mouseMove} from '../Drawer/touchInput'
|
|
16
18
|
import {Icon} from '../Icon/Icon'
|
|
17
19
|
import {Inline} from '../Inline/Inline'
|
|
18
20
|
import {Menu} from '../Menu/Menu'
|
|
@@ -251,6 +253,33 @@ export const AttachedFocusMiddle: Story = {
|
|
|
251
253
|
const y = r.top + r.height / 2
|
|
252
254
|
await expect(middle.contains(document.elementFromPoint(r.left + 0.5, y))).toBe(true)
|
|
253
255
|
await expect(middle.contains(document.elementFromPoint(r.right - 0.5, y))).toBe(true)
|
|
256
|
+
// The design system's ring, not the browser's default outline.
|
|
257
|
+
await expect(getComputedStyle(middle).outlineStyle).toBe('solid')
|
|
258
|
+
await expect(getComputedStyle(middle).outlineWidth).toBe('2px')
|
|
259
|
+
},
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** A hovered Select in an attached group hovers like the Buttons and Toggles
|
|
263
|
+
* beside it: transparent at rest, a fill on hover, the border unchanged, and
|
|
264
|
+
* it rises above its neighbours so the whole edge is its own. */
|
|
265
|
+
export const AttachedHoverMiddle: Story = {
|
|
266
|
+
render: () => <TextStyleSelects />,
|
|
267
|
+
play: async ({canvas}) => {
|
|
268
|
+
const [first, middle] = canvas.getAllByRole('combobox')
|
|
269
|
+
await expect(getComputedStyle(middle).backgroundColor).toBe('rgba(0, 0, 0, 0)')
|
|
270
|
+
const restBorder = getComputedStyle(middle).borderTopColor
|
|
271
|
+
await mouseMove(centre(middle))
|
|
272
|
+
try {
|
|
273
|
+
await waitFor(() =>
|
|
274
|
+
expect(getComputedStyle(middle).backgroundColor).not.toBe('rgba(0, 0, 0, 0)'),
|
|
275
|
+
)
|
|
276
|
+
await expect(getComputedStyle(middle).borderTopColor).toBe(restBorder)
|
|
277
|
+
await expect(getComputedStyle(middle).zIndex).toBe(String(LAYERS.raised))
|
|
278
|
+
await expect(getComputedStyle(first).zIndex).toBe('auto')
|
|
279
|
+
} finally {
|
|
280
|
+
// The pointer is shared by every story file: park it off the controls.
|
|
281
|
+
await mouseMove({x: 0, y: 0})
|
|
282
|
+
}
|
|
254
283
|
},
|
|
255
284
|
}
|
|
256
285
|
|
|
@@ -529,3 +558,43 @@ export const SmallTriggersRowCoarsePointer: Story = {
|
|
|
529
558
|
})
|
|
530
559
|
},
|
|
531
560
|
}
|
|
561
|
+
|
|
562
|
+
interface HoverBorderArgs {
|
|
563
|
+
hoverBorder: string
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* A playground, not the component: a stylesheet added for the story colours
|
|
568
|
+
* the border of whichever control in the groups below is hovered, so a hover
|
|
569
|
+
* border can be judged against the joined corners (round at the ends, square
|
|
570
|
+
* inside) and the raise above the neighbours. The components themselves keep
|
|
571
|
+
* the border unchanged on hover.
|
|
572
|
+
*/
|
|
573
|
+
function HoverBorderPlayground({hoverBorder}: HoverBorderArgs) {
|
|
574
|
+
useEffect(() => {
|
|
575
|
+
const sheet = document.createElement('style')
|
|
576
|
+
sheet.textContent = `[data-hover-border] [role="group"] button:hover { border-color: ${hoverBorder} !important; }`
|
|
577
|
+
document.head.appendChild(sheet)
|
|
578
|
+
return () => sheet.remove()
|
|
579
|
+
}, [hoverBorder])
|
|
580
|
+
return (
|
|
581
|
+
<html.div data-hover-border="">
|
|
582
|
+
<Stack gap="md">
|
|
583
|
+
<TextStyleSelects />
|
|
584
|
+
<FormatGroup />
|
|
585
|
+
</Stack>
|
|
586
|
+
</html.div>
|
|
587
|
+
)
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/** Pick a hover border colour and hover across both groups. */
|
|
591
|
+
export const AttachedHoverBorderPlayground: StoryObj<HoverBorderArgs> = {
|
|
592
|
+
args: {hoverBorder: '#6aaffc'},
|
|
593
|
+
argTypes: {
|
|
594
|
+
hoverBorder: {
|
|
595
|
+
control: 'color',
|
|
596
|
+
description: 'border-color of the hovered control (story only; the components keep theirs)',
|
|
597
|
+
},
|
|
598
|
+
},
|
|
599
|
+
render: ({hoverBorder}) => <HoverBorderPlayground hoverBorder={hoverBorder} />,
|
|
600
|
+
}
|
|
@@ -8,12 +8,13 @@ import {layers} from '@greenharness/greenrack-tokens/tokens/layers.css'
|
|
|
8
8
|
const overlap = `calc(-1 * ${borders.hairline})`
|
|
9
9
|
|
|
10
10
|
export const attached = css.create({
|
|
11
|
-
// A focused control rises above its neighbours, so their borders
|
|
12
|
-
// cover its
|
|
11
|
+
// A hovered or focused control rises above its neighbours, so their borders
|
|
12
|
+
// never cover its state edge or its focus ring (Primer, Spectrum and Ant
|
|
13
|
+
// raise on hover too). Position makes the z-index apply to a trigger that
|
|
13
14
|
// is not itself the flex item (Select and Menu triggers sit in a Root).
|
|
14
15
|
item: {
|
|
15
16
|
position: 'relative',
|
|
16
|
-
zIndex: {default: null, ':focus-visible': layers.raised},
|
|
17
|
+
zIndex: {default: null, ':hover': layers.raised, ':focus-visible': layers.raised},
|
|
17
18
|
},
|
|
18
19
|
horizontalFirst: {
|
|
19
20
|
borderTopRightRadius: 0,
|
|
@@ -88,6 +88,14 @@ export async function touchTap(at: Point) {
|
|
|
88
88
|
await cdpSend('Input.dispatchTouchEvent', {type: 'touchEnd', touchPoints: []})
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* The mouse pointer moved to a point: a real `:hover`, which testing-library's
|
|
93
|
+
* synthetic `userEvent.hover` never produces.
|
|
94
|
+
*/
|
|
95
|
+
export async function mouseMove(at: Point) {
|
|
96
|
+
await cdpSend('Input.dispatchMouseEvent', {type: 'mouseMoved', ...toPage(at)})
|
|
97
|
+
}
|
|
98
|
+
|
|
91
99
|
/** The centre of an element, in its own document's coordinates. */
|
|
92
100
|
export function centre(el: Element): Point {
|
|
93
101
|
const r = el.getBoundingClientRect()
|
|
@@ -36,6 +36,21 @@ export const styles = css.create({
|
|
|
36
36
|
cursor: 'pointer',
|
|
37
37
|
transitionProperty: 'border-color',
|
|
38
38
|
transitionDuration: duration.fast,
|
|
39
|
+
// The design system's focus ring, as Button's: the browser's own outline
|
|
40
|
+
// was the only thing a focused trigger showed.
|
|
41
|
+
outlineWidth: {default: 0, ':focus-visible': borders.focusRing},
|
|
42
|
+
outlineStyle: {default: 'none', ':focus-visible': 'solid'},
|
|
43
|
+
outlineColor: {default: 'transparent', ':focus-visible': colors.accent},
|
|
44
|
+
outlineOffset: {default: 0, ':focus-visible': borders.focusOffset},
|
|
45
|
+
},
|
|
46
|
+
// In an attached ButtonGroup the trigger is one control of the group, not a
|
|
47
|
+
// form field: transparent like the Buttons and Toggles beside it, and a
|
|
48
|
+
// hover that changes the fill only, so no item of the group outlines on its
|
|
49
|
+
// own (the accent hover border stays for the standalone, Input-like trigger).
|
|
50
|
+
triggerAttached: {
|
|
51
|
+
backgroundColor: {default: 'transparent', ':hover': colors.bgCardHover},
|
|
52
|
+
borderColor: colors.border,
|
|
53
|
+
transitionProperty: 'background-color',
|
|
39
54
|
},
|
|
40
55
|
// The whole control disabled: Button's disabled look, and no hover accent.
|
|
41
56
|
triggerDisabled: {
|
|
@@ -62,10 +62,10 @@ export const styles = css.create({
|
|
|
62
62
|
default: 'transparent',
|
|
63
63
|
':hover': colors.bgCardHover,
|
|
64
64
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
// Hover changes the fill only, as Button's secondary and ghost variants
|
|
66
|
+
// do: in an attached ButtonGroup a Toggle sits beside them, and a border
|
|
67
|
+
// that darkened on hover made it the odd one out.
|
|
68
|
+
borderColor: colors.border,
|
|
69
69
|
color: colors.textMuted,
|
|
70
70
|
},
|
|
71
71
|
pressed: {
|