@duro-app/ui 0.34.9 → 0.35.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duro-app/ui",
3
- "version": "0.34.9",
3
+ "version": "0.35.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -54,7 +54,7 @@
54
54
  }
55
55
  },
56
56
  "dependencies": {
57
- "@duro-app/tokens": "^0.34.9"
57
+ "@duro-app/tokens": "^0.35.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@babel/preset-typescript": "^7.28.0",
@@ -13,6 +13,8 @@ interface ButtonProps {
13
13
  disabled?: boolean
14
14
  type?: 'button' | 'submit'
15
15
  onClick?: () => void
16
+ /** Accessible name override — e.g. for buttons whose visible text isn't unique. */
17
+ 'aria-label'?: string
16
18
  children: ReactNode
17
19
  }
18
20
 
@@ -28,6 +30,7 @@ export function Button({
28
30
  disabled = false,
29
31
  type = 'button',
30
32
  onClick,
33
+ 'aria-label': ariaLabel,
31
34
  children,
32
35
  }: ButtonProps) {
33
36
  return (
@@ -35,6 +38,7 @@ export function Button({
35
38
  type={type}
36
39
  disabled={disabled}
37
40
  onClick={onClick}
41
+ aria-label={ariaLabel}
38
42
  style={[
39
43
  styles.base,
40
44
  isNative && styles.nativeFlex,
@@ -24,7 +24,13 @@ export function useComboboxRoot({
24
24
  defaultValue ?? null,
25
25
  onValueChange,
26
26
  )
27
- const [internalInputValue, setInternalInputValue] = useState('')
27
+ // Seed the visible text from the initially-selected value's label, so a
28
+ // defaultValue/value shows its label on mount — and so the reconcile effect
29
+ // below doesn't see "value set but input empty" and wipe the selection.
30
+ const [internalInputValue, setInternalInputValue] = useState<string>(() => {
31
+ const initial = controlledValue ?? defaultValue
32
+ return initial ? (initialLabels?.[initial] ?? '') : ''
33
+ })
28
34
  const inputValue = controlledInputValue !== undefined ? controlledInputValue : internalInputValue
29
35
  const setInputValue = useCallback(
30
36
  (v: string) => {
@@ -201,7 +207,11 @@ export function useComboboxRoot({
201
207
  // - inputValue equals the selected label: nothing to do.
202
208
  useEffect(() => {
203
209
  if (open) return
204
- if (value === null) return
210
+ // Treat an empty value (null OR '') as "no selection" — nothing to
211
+ // reconcile. Without this, a controlled value="" (e.g. a table column
212
+ // filter) fires setValue(null) every render → inline onValueChange →
213
+ // parent state change → re-render → infinite "Maximum update depth" loop.
214
+ if (!value) return
205
215
  if (inputValue === '') {
206
216
  setValue(null)
207
217
  return
@@ -1128,7 +1128,9 @@ export const SlotPropsOnRoot: Story = {
1128
1128
  play: async ({canvas}) => {
1129
1129
  await expect(canvas.getByRole('table')).toBeInTheDocument()
1130
1130
  // Note no Table.HeaderCell label — children are plain strings, so the
1131
- // label fallback uses extractText. Verify the rendered text appears.
1132
- await expect(canvas.getByText('Name')).toBeInTheDocument()
1131
+ // label fallback uses extractText. "Name" appears both in the header and
1132
+ // the SortChip option list, so assert at least one rendered (not getByText,
1133
+ // which throws on multiple matches).
1134
+ await expect(canvas.getAllByText('Name').length).toBeGreaterThan(0)
1133
1135
  },
1134
1136
  }
@@ -3,17 +3,27 @@ import {css, html} from 'react-strict-dom'
3
3
  import {colors} from '@duro-app/tokens/tokens/colors.css'
4
4
  import {lightTheme, lightShadows} from '@duro-app/tokens/themes/light.css'
5
5
  import {highContrastTheme, highContrastShadows} from '@duro-app/tokens/themes/high-contrast.css'
6
+ import {
7
+ landscapeTheme,
8
+ landscapeShadows,
9
+ landscapeTypography,
10
+ } from '@duro-app/tokens/themes/landscape.css'
6
11
 
7
- export type ThemeName = 'dark' | 'light' | 'high-contrast'
12
+ export type ThemeName = 'dark' | 'light' | 'high-contrast' | 'landscape'
8
13
 
9
14
  interface ThemeProviderProps {
10
15
  theme?: ThemeName
11
16
  children: ReactNode
12
17
  }
13
18
 
14
- const themeMap: Partial<Record<ThemeName, readonly [typeof lightTheme, typeof lightShadows]>> = {
19
+ // A theme is a list of createTheme() overrides (colors + shadows, and
20
+ // optionally typography — e.g. landscape carries its editorial font stack).
21
+ // Loosely typed: each entry themes a DIFFERENT VarGroup (colors / shadows /
22
+ // typography), and the array is cast to the style prop's type at the use site.
23
+ const themeMap: Partial<Record<ThemeName, readonly unknown[]>> = {
15
24
  light: [lightTheme, lightShadows],
16
25
  'high-contrast': [highContrastTheme, highContrastShadows],
26
+ landscape: [landscapeTheme, landscapeShadows, landscapeTypography],
17
27
  }
18
28
 
19
29
  const styles = css.create({
@@ -49,7 +59,7 @@ export function usePortalMount(): HTMLElement | null {
49
59
 
50
60
  export function ThemeProvider({theme = 'dark', children}: ThemeProviderProps) {
51
61
  const overrides = themeMap[theme]
52
- const themeStyles = [overrides?.[0], overrides?.[1], styles.root] as DivStyle
62
+ const themeStyles = [...(overrides ?? []), styles.root] as DivStyle
53
63
  const [mount, setMount] = useState<HTMLElement | null>(null)
54
64
 
55
65
  return (