@dxos/ui-theme 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/lib/browser/index.mjs +63 -57
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +63 -57
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/plugin/node-cjs/main.css +64 -29
  8. package/dist/plugin/node-cjs/main.css.map +2 -2
  9. package/dist/plugin/node-cjs/meta.json +1 -1
  10. package/dist/plugin/node-esm/main.css +64 -29
  11. package/dist/plugin/node-esm/main.css.map +2 -2
  12. package/dist/plugin/node-esm/meta.json +1 -1
  13. package/dist/plugin/node-esm/plugins/ThemePlugin.mjs.map +2 -2
  14. package/dist/types/src/Theme.stories.d.ts.map +1 -1
  15. package/dist/types/src/defs.d.ts +1 -1
  16. package/dist/types/src/defs.d.ts.map +1 -1
  17. package/dist/types/src/fragments/density.d.ts +1 -4
  18. package/dist/types/src/fragments/density.d.ts.map +1 -1
  19. package/dist/types/src/fragments/text.d.ts +0 -1
  20. package/dist/types/src/fragments/text.d.ts.map +1 -1
  21. package/dist/types/src/plugins/ThemePlugin.d.ts +1 -1
  22. package/dist/types/src/plugins/ThemePlugin.d.ts.map +1 -1
  23. package/dist/types/src/theme/components/card.d.ts.map +1 -1
  24. package/dist/types/src/theme/components/dialog.d.ts.map +1 -1
  25. package/dist/types/src/theme/components/icon-button.d.ts +1 -0
  26. package/dist/types/src/theme/components/icon-button.d.ts.map +1 -1
  27. package/dist/types/src/theme/components/input.d.ts +8 -8
  28. package/dist/types/src/theme/components/input.d.ts.map +1 -1
  29. package/dist/types/src/theme/components/main.d.ts.map +1 -1
  30. package/dist/types/src/theme/components/scroll-area.d.ts.map +1 -1
  31. package/dist/types/src/theme/primitives/column.d.ts +22 -5
  32. package/dist/types/src/theme/primitives/column.d.ts.map +1 -1
  33. package/dist/types/src/theme/primitives/panel.d.ts.map +1 -1
  34. package/dist/types/src/theme/theme.d.ts.map +1 -1
  35. package/dist/types/src/util/hash-styles.d.ts.map +1 -1
  36. package/dist/types/src/util/mx.d.ts +21 -1
  37. package/dist/types/src/util/mx.d.ts.map +1 -1
  38. package/dist/types/src/util/size.d.ts.map +1 -1
  39. package/dist/types/src/util/valence.d.ts +2 -2
  40. package/dist/types/src/util/valence.d.ts.map +1 -1
  41. package/dist/types/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +9 -16
  43. package/src/css/components/panel.css +22 -22
  44. package/src/css/components/selected.css +8 -3
  45. package/src/css/components/selected.md +101 -0
  46. package/src/css/components/tag.css +3 -1
  47. package/src/css/layout/size.css +16 -3
  48. package/src/css/theme/animation.css +31 -0
  49. package/src/css/theme/spacing.css +6 -7
  50. package/src/css/utilities.css +48 -6
  51. package/src/fragments/AUDIT.md +0 -1
  52. package/src/fragments/density.ts +8 -5
  53. package/src/fragments/text.ts +1 -1
  54. package/src/main.css +36 -2
  55. package/src/theme/components/card.ts +4 -0
  56. package/src/theme/components/dialog.ts +5 -3
  57. package/src/theme/components/icon-button.ts +6 -3
  58. package/src/theme/components/input.ts +6 -6
  59. package/src/theme/components/message.ts +5 -5
  60. package/src/theme/components/popover.ts +1 -1
  61. package/src/theme/components/scroll-area.ts +10 -5
  62. package/src/theme/primitives/column.ts +44 -20
  63. package/src/util/mx.ts +3 -3
@@ -7,10 +7,13 @@ import type { ComponentFunction, Theme } from '@dxos/ui-types';
7
7
  import { mx } from '../../util';
8
8
  import { type ButtonStyleProps } from './button';
9
9
 
10
- export type IconButtonStyleProps = ButtonStyleProps & { iconOnly?: boolean };
10
+ export type IconButtonStyleProps = ButtonStyleProps & {
11
+ iconOnly?: boolean;
12
+ square?: boolean;
13
+ };
11
14
 
12
- export const iconButtonRoot: ComponentFunction<IconButtonStyleProps> = ({ iconOnly }, ...etc) => {
13
- return mx('px-1.5', !iconOnly && 'gap-2', ...etc);
15
+ export const iconButtonRoot: ComponentFunction<IconButtonStyleProps> = ({ iconOnly, square }, ...etc) => {
16
+ return mx('px-1.5', !iconOnly && 'gap-2', square && 'aspect-square', ...etc);
14
17
  };
15
18
 
16
19
  export const iconButtonTheme: Theme<IconButtonStyleProps> = {
@@ -11,7 +11,7 @@ import {
11
11
  type Size,
12
12
  } from '@dxos/ui-types';
13
13
 
14
- import { coarseBlockSize, coarseDimensions, fineBlockSize, fineDimensions, staticDisabled } from '../../fragments';
14
+ import { densityDimensions, staticDisabled } from '../../fragments';
15
15
  import { getSize, getHeight, getWidth, mx, snapSize, sizeValue, textValence } from '../../util';
16
16
 
17
17
  export type InputStyleProps = Partial<{
@@ -58,24 +58,24 @@ const inputValence = (valence?: MessageValence) => {
58
58
  };
59
59
 
60
60
  const sharedSubduedInputStyles: ComponentFragment<InputStyleProps> = (props) => [
61
- 'py-0 w-full bg-transparent text-current placeholder-placeholder',
62
61
  '[[data-drag-autoscroll="active"]_&]:pointer-events-none',
63
- props.density === 'fine' ? fineBlockSize : coarseBlockSize,
62
+ 'py-0 w-full bg-transparent text-current placeholder-placeholder',
64
63
  'dx-focus-subdued',
64
+ densityDimensions(props.density),
65
65
  props.disabled && staticDisabled,
66
66
  ];
67
67
 
68
68
  const sharedDefaultInputStyles: ComponentFragment<InputStyleProps> = (props) => [
69
- 'py-0 w-full text-base-surface-text rounded-xs placeholder-placeholder',
70
69
  '[[data-drag-autoscroll="active"]_&]:pointer-events-none',
70
+ 'py-0 w-full text-base-surface-text rounded-xs placeholder-placeholder',
71
71
  textInputSurfaceFocus,
72
- props.density === 'fine' ? fineDimensions : coarseDimensions,
72
+ densityDimensions(props.density),
73
73
  props.disabled ? staticDisabled : textInputSurfaceHover,
74
74
  ];
75
75
 
76
76
  const sharedStaticInputStyles: ComponentFragment<InputStyleProps> = (props) => [
77
- 'py-0 w-full text-base-surface-text rounded-xs placeholder-placeholder',
78
77
  '[[data-drag-autoscroll="active"]_&]:pointer-events-none',
78
+ 'py-0 w-full text-base-surface-text rounded-xs placeholder-placeholder',
79
79
  textInputSurfaceFocus,
80
80
  textInputSurfaceHover,
81
81
  props.focused && 'bg-attention-surface',
@@ -12,23 +12,23 @@ export type MessageStyleProps = {
12
12
  };
13
13
 
14
14
  export const messageRoot: ComponentFunction<MessageStyleProps> = ({ valence }, etc) => {
15
- return mx('grid grid-cols-[min-content_1fr] gap-x-2 p-trim-sm rounded-sm', messageValence(valence), etc);
15
+ return mx('grid grid-cols-[2rem_1fr_2rem] p-1 rounded-sm', messageValence(valence), etc);
16
16
  };
17
17
 
18
18
  export const messageHeader: ComponentFunction<MessageStyleProps> = (_, etc) => {
19
- return mx('col-span-2 grid grid-cols-subgrid items-center', etc);
19
+ return mx('col-span-full grid grid-cols-subgrid items-center', etc);
20
20
  };
21
21
 
22
22
  export const messageTitle: ComponentFunction<MessageStyleProps> = (_, etc) => {
23
- return mx('col-start-2 gap-trim-sm [&>svg]:inline-block', etc);
23
+ return mx('col-start-2 truncate', etc);
24
24
  };
25
25
 
26
26
  export const messageIcon: ComponentFunction<MessageStyleProps> = (_, etc) => {
27
- return mx('col-start-1', etc);
27
+ return mx('col-start-1 grid place-items-center', etc);
28
28
  };
29
29
 
30
30
  export const messageContent: ComponentFunction<MessageStyleProps> = (_, etc) => {
31
- return mx('grid grid-cols-subgrid col-start-2 first:font-medium', etc);
31
+ return mx('col-start-2 grid grid-cols-subgrid first:font-medium', etc);
32
32
  };
33
33
 
34
34
  export const messageTheme: Theme<MessageStyleProps> = {
@@ -23,7 +23,7 @@ export const popoverContent: ComponentFunction<PopoverStyleProps> = ({ elevation
23
23
 
24
24
  export const popoverViewport: ComponentFunction<PopoverStyleProps> = ({ constrainBlock, constrainInline }, ...etc) =>
25
25
  mx(
26
- 'flex flex-col min-h-0 min-w-popover-min-width',
26
+ 'grid grid-rows-[1fr] min-h-0 min-w-popover-min-width',
27
27
  (constrainBlock || constrainInline) && 'overflow-hidden',
28
28
  constrainBlock && 'max-h-(--radix-popover-content-available-height)',
29
29
  constrainBlock &&
@@ -5,6 +5,7 @@
5
5
  import { type AllowedAxis, type ComponentFunction, type Theme } from '@dxos/ui-types';
6
6
 
7
7
  import { mx } from '../../util';
8
+ import { withColumn } from '../primitives/column';
8
9
 
9
10
  export const scrollbar = {
10
11
  thin: {
@@ -41,8 +42,8 @@ export const scrollAreaRoot: ComponentFunction<ScrollAreaStyleProps> = ({ orient
41
42
  orientation === 'horizontal' && 'group/scroll-h flex',
42
43
  orientation === 'all' && 'group/scroll-all',
43
44
 
44
- // Apply col-span-full only when inside a Column.Root grid (detected via dx-column marker).
45
- '[.dx-column_&]:col-span-full',
45
+ // Apply col-span-full only when inside a Column.Root grid (detected via dx-column-root marker).
46
+ '[.dx-column-root_&]:col-span-full',
46
47
 
47
48
  ...etc,
48
49
  );
@@ -51,13 +52,17 @@ export const scrollAreaRoot: ComponentFunction<ScrollAreaStyleProps> = ({ orient
51
52
  * NOTE: The browser reserves space for scrollbars.
52
53
  */
53
54
  export const scrollAreaViewport: ComponentFunction<ScrollAreaStyleProps> = (
54
- { orientation, centered, padding, snap, thin, autoHide },
55
+ { orientation, centered, padding, snap, autoHide },
55
56
  ...etc
56
57
  ) => {
57
58
  return mx(
58
- 'h-full w-full',
59
+ 'flex-1 min-h-0 w-full',
59
60
 
60
- orientation === 'vertical' && 'flex flex-col overflow-y-scroll',
61
+ // Reset --dx-col so nested components don't try to grid-position themselves.
62
+ // ScrollArea has already consumed --gutter for padding.
63
+ withColumn.consumed(),
64
+
65
+ orientation === 'vertical' && 'overflow-y-scroll',
61
66
  orientation === 'horizontal' && 'flex overflow-x-scroll overscroll-x-contain',
62
67
  orientation === 'all' && 'overflow-scroll',
63
68
 
@@ -6,42 +6,66 @@ import { type ComponentFunction } from '@dxos/ui-types';
6
6
 
7
7
  import { mx } from '../../util';
8
8
 
9
- export type ColumnStyleProps = {
10
- fullWidth?: boolean;
11
- center?: boolean;
9
+ /**
10
+ * Column-aware theme utilities.
11
+ * Components apply these in their theme functions to participate in the Column grid
12
+ * without importing Column React components.
13
+ *
14
+ * CSS custom property cascade:
15
+ * - Column.Root sets `--dx-col: 2 / span 1` (center column placement).
16
+ * - ScrollArea.Viewport resets `--dx-col: auto` after consuming `--gutter`.
17
+ * - Components apply `grid-column: var(--dx-col, auto)` to auto-center in Column
18
+ * or do nothing outside Column / inside ScrollArea.
19
+ */
20
+ export const withColumn = {
21
+ /** Centers element in the Column grid via --dx-col. No-op outside Column or inside ScrollArea. */
22
+ center: () => '[grid-column:var(--dx-col,auto)]',
23
+
24
+ /** Propagates the Column grid to children via subgrid. No-op outside Column.
25
+ * Direct children default to center column unless they are a dx-container (ScrollArea). */
26
+ propagate: () =>
27
+ '[.dx-column-root_&]:col-span-full [.dx-column-root_&]:grid [.dx-column-root_&]:grid-cols-subgrid [.dx-column-root_&]:[&>*:not(.dx-container)]:[grid-column:var(--dx-col,auto)]',
28
+
29
+ /** Resets --dx-col after consuming --gutter. Applied by ScrollArea.Viewport. */
30
+ consumed: () => '[--dx-col:auto]',
12
31
  };
13
32
 
33
+ export type ColumnStyleProps = {};
34
+
14
35
  const columnRoot: ComponentFunction<ColumnStyleProps> = (_, ...etc) => {
15
- return mx('dx-column grid', ...etc);
36
+ return mx('dx-column-root grid', ...etc);
16
37
  };
17
38
 
18
39
  /**
19
- * Full-width content area that inherits the parent Column.Root's 3-column grid via subgrid.
20
- * Non-scrolling children default to column 2 (center, between gutters).
21
- * ScrollArea children span all 3 columns via the existing `[.dx-column_&]:col-span-full` selector.
22
- * This avoids padding/overflow conflicts gutters come from the grid, not padding.
40
+ * Three-column icon-slot row: spans all 3 columns of the parent Column.Root grid.
41
+ * Uses CSS subgrid to inherit column sizing from the parent Column.
42
+ * Children map to: [col-1: icon/slot] [col-2: content] [col-3: icon/action].
43
+ * NOTE: Must not use overflow-hidden here since it will clip input focus rings.
23
44
  */
24
- const columnContent: ComponentFunction<ColumnStyleProps> = (_, ...etc) => {
25
- return mx('col-span-full grid grid-cols-subgrid min-h-0 [&>:not(.dx-container)]:col-start-2', ...etc);
45
+ const columnRow: ComponentFunction<ColumnStyleProps> = (_, ...etc) => {
46
+ return mx('col-span-3 grid grid-cols-subgrid', ...etc);
26
47
  };
27
48
 
28
- const columnViewport: ComponentFunction<ColumnStyleProps> = (_, ...etc) => {
29
- return mx(...etc);
49
+ /**
50
+ * Bleed placement: spans all 3 columns of the parent Column.Root grid (gutter-to-gutter).
51
+ * Use for `ScrollArea`, full-width dividers, tables, or any content that should ignore gutters.
52
+ */
53
+ const columnBleed: ComponentFunction<ColumnStyleProps> = (_, ...etc) => {
54
+ return mx('col-span-full grid grid-cols-subgrid min-h-0', ...etc);
30
55
  };
31
56
 
32
57
  /**
33
- * Three-column icon-slot row: spans all 3 columns of the parent Column.Root grid.
34
- * Uses CSS subgrid to inherit column sizing from the parent Column.
35
- * Children map to: [col-1: icon/slot] [col-2: content] [col-3: icon/action].
36
- * NOTE: Must not use overflow-hidden here since it will clip input focus rings.
58
+ * Center placement: places the element in column 2 (the central track between gutters) of the
59
+ * parent Column.Root grid. Does NOT use subgrid placement is explicit on this element only.
60
+ * Safe to nest arbitrary compound components (including those that render `display: contents`).
37
61
  */
38
- const columnRow: ComponentFunction<ColumnStyleProps> = ({ fullWidth, center }, ...etc) => {
39
- return mx('col-span-3 grid grid-cols-subgrid', fullWidth ? 'col-span-3' : center && 'col-start-2 col-span-1', ...etc);
62
+ const columnCenter: ComponentFunction<ColumnStyleProps> = (_, ...etc) => {
63
+ return mx(withColumn.center(), 'min-h-0', ...etc);
40
64
  };
41
65
 
42
66
  export const columnTheme = {
43
67
  root: columnRoot,
44
- content: columnContent,
45
- viewport: columnViewport,
46
68
  row: columnRow,
69
+ bleed: columnBleed,
70
+ center: columnCenter,
47
71
  };
package/src/util/mx.ts CHANGED
@@ -89,6 +89,9 @@ export const composableProps = <P extends HTMLElement = HTMLElement>(
89
89
  className: mx(defaultClassNames, className, classNames),
90
90
  });
91
91
 
92
+ /** Symbol used to mark components created by `composable()` or `slottable()`. */
93
+ const COMPOSABLE = Symbol.for('dxos.composable');
94
+
92
95
  /**
93
96
  * Factory for slottable components.
94
97
  * The implementation receives full `HTMLAttributes<E>` so it can destructure `role`, `style`, etc.
@@ -109,9 +112,6 @@ export const composableProps = <P extends HTMLElement = HTMLElement>(
109
112
  * );
110
113
  * ```
111
114
  */
112
- /** Symbol used to mark components created by `composable()` or `slottable()`. */
113
- const COMPOSABLE = Symbol.for('dxos.composable');
114
-
115
115
  export function slottable<E extends HTMLElement, P extends object = {}>(
116
116
  render: (props: SlottableProps<P> & HTMLAttributes<E>, forwardedRef: ForwardedRef<E>) => ReactNode,
117
117
  ): ForwardRefExoticComponent<SlottableProps<P> & RefAttributes<E>> {