@ohos-ports/dxos-react-ui-theme 0.6.7-beta.1

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 (196) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +25 -0
  3. package/README.yml +1 -0
  4. package/dist/lib/browser/index.mjs +2300 -0
  5. package/dist/lib/browser/index.mjs.map +7 -0
  6. package/dist/lib/browser/meta.json +1 -0
  7. package/dist/plugin/node/chunk-G3RQ5GOB.cjs +712 -0
  8. package/dist/plugin/node/chunk-G3RQ5GOB.cjs.map +7 -0
  9. package/dist/plugin/node/esbuild-plugin.cjs +89 -0
  10. package/dist/plugin/node/esbuild-plugin.cjs.map +7 -0
  11. package/dist/plugin/node/meta.json +1 -0
  12. package/dist/plugin/node/plugin.cjs +77 -0
  13. package/dist/plugin/node/plugin.cjs.map +7 -0
  14. package/dist/plugin/node/theme.css +418 -0
  15. package/dist/plugin/node/theme.css.map +7 -0
  16. package/dist/types/src/config/colors.d.ts +109 -0
  17. package/dist/types/src/config/colors.d.ts.map +1 -0
  18. package/dist/types/src/config/index.d.ts +3 -0
  19. package/dist/types/src/config/index.d.ts.map +1 -0
  20. package/dist/types/src/config/resolveContent.d.ts +2 -0
  21. package/dist/types/src/config/resolveContent.d.ts.map +1 -0
  22. package/dist/types/src/config/tailwind.d.ts +9 -0
  23. package/dist/types/src/config/tailwind.d.ts.map +1 -0
  24. package/dist/types/src/esbuild-plugin.d.ts +9 -0
  25. package/dist/types/src/esbuild-plugin.d.ts.map +1 -0
  26. package/dist/types/src/index.d.ts +4 -0
  27. package/dist/types/src/index.d.ts.map +1 -0
  28. package/dist/types/src/plugin.d.ts +13 -0
  29. package/dist/types/src/plugin.d.ts.map +1 -0
  30. package/dist/types/src/styles/components/anchored-overflow.d.ts +6 -0
  31. package/dist/types/src/styles/components/anchored-overflow.d.ts.map +1 -0
  32. package/dist/types/src/styles/components/avatar.d.ts +21 -0
  33. package/dist/types/src/styles/components/avatar.d.ts.map +1 -0
  34. package/dist/types/src/styles/components/breadcrumb.d.ts +9 -0
  35. package/dist/types/src/styles/components/breadcrumb.d.ts.map +1 -0
  36. package/dist/types/src/styles/components/button.d.ts +19 -0
  37. package/dist/types/src/styles/components/button.d.ts.map +1 -0
  38. package/dist/types/src/styles/components/dialog.d.ts +12 -0
  39. package/dist/types/src/styles/components/dialog.d.ts.map +1 -0
  40. package/dist/types/src/styles/components/index.d.ts +22 -0
  41. package/dist/types/src/styles/components/index.d.ts.map +1 -0
  42. package/dist/types/src/styles/components/input.d.ts +103 -0
  43. package/dist/types/src/styles/components/input.d.ts.map +1 -0
  44. package/dist/types/src/styles/components/link.d.ts +7 -0
  45. package/dist/types/src/styles/components/link.d.ts.map +1 -0
  46. package/dist/types/src/styles/components/list.d.ts +14 -0
  47. package/dist/types/src/styles/components/list.d.ts.map +1 -0
  48. package/dist/types/src/styles/components/main.d.ts +25 -0
  49. package/dist/types/src/styles/components/main.d.ts.map +1 -0
  50. package/dist/types/src/styles/components/menu.d.ts +12 -0
  51. package/dist/types/src/styles/components/menu.d.ts.map +1 -0
  52. package/dist/types/src/styles/components/message.d.ts +10 -0
  53. package/dist/types/src/styles/components/message.d.ts.map +1 -0
  54. package/dist/types/src/styles/components/popover.d.ts +10 -0
  55. package/dist/types/src/styles/components/popover.d.ts.map +1 -0
  56. package/dist/types/src/styles/components/scroll-area.d.ts +9 -0
  57. package/dist/types/src/styles/components/scroll-area.d.ts.map +1 -0
  58. package/dist/types/src/styles/components/select.d.ts +13 -0
  59. package/dist/types/src/styles/components/select.d.ts.map +1 -0
  60. package/dist/types/src/styles/components/separator.d.ts +7 -0
  61. package/dist/types/src/styles/components/separator.d.ts.map +1 -0
  62. package/dist/types/src/styles/components/status.d.ts +8 -0
  63. package/dist/types/src/styles/components/status.d.ts.map +1 -0
  64. package/dist/types/src/styles/components/tag.d.ts +7 -0
  65. package/dist/types/src/styles/components/tag.d.ts.map +1 -0
  66. package/dist/types/src/styles/components/toast.d.ts +12 -0
  67. package/dist/types/src/styles/components/toast.d.ts.map +1 -0
  68. package/dist/types/src/styles/components/toolbar.d.ts +5 -0
  69. package/dist/types/src/styles/components/toolbar.d.ts.map +1 -0
  70. package/dist/types/src/styles/components/tooltip.d.ts +6 -0
  71. package/dist/types/src/styles/components/tooltip.d.ts.map +1 -0
  72. package/dist/types/src/styles/components/treegrid.d.ts +10 -0
  73. package/dist/types/src/styles/components/treegrid.d.ts.map +1 -0
  74. package/dist/types/src/styles/fragments/arrow.d.ts +6 -0
  75. package/dist/types/src/styles/fragments/arrow.d.ts.map +1 -0
  76. package/dist/types/src/styles/fragments/density.d.ts +13 -0
  77. package/dist/types/src/styles/fragments/density.d.ts.map +1 -0
  78. package/dist/types/src/styles/fragments/dimensions.d.ts +2 -0
  79. package/dist/types/src/styles/fragments/dimensions.d.ts.map +1 -0
  80. package/dist/types/src/styles/fragments/disabled.d.ts +3 -0
  81. package/dist/types/src/styles/fragments/disabled.d.ts.map +1 -0
  82. package/dist/types/src/styles/fragments/elevation.d.ts +11 -0
  83. package/dist/types/src/styles/fragments/elevation.d.ts.map +1 -0
  84. package/dist/types/src/styles/fragments/focus.d.ts +6 -0
  85. package/dist/types/src/styles/fragments/focus.d.ts.map +1 -0
  86. package/dist/types/src/styles/fragments/group.d.ts +5 -0
  87. package/dist/types/src/styles/fragments/group.d.ts.map +1 -0
  88. package/dist/types/src/styles/fragments/hover.d.ts +14 -0
  89. package/dist/types/src/styles/fragments/hover.d.ts.map +1 -0
  90. package/dist/types/src/styles/fragments/hue.d.ts +16 -0
  91. package/dist/types/src/styles/fragments/hue.d.ts.map +1 -0
  92. package/dist/types/src/styles/fragments/index.d.ts +19 -0
  93. package/dist/types/src/styles/fragments/index.d.ts.map +1 -0
  94. package/dist/types/src/styles/fragments/layout.d.ts +3 -0
  95. package/dist/types/src/styles/fragments/layout.d.ts.map +1 -0
  96. package/dist/types/src/styles/fragments/motion.d.ts +3 -0
  97. package/dist/types/src/styles/fragments/motion.d.ts.map +1 -0
  98. package/dist/types/src/styles/fragments/ornament.d.ts +4 -0
  99. package/dist/types/src/styles/fragments/ornament.d.ts.map +1 -0
  100. package/dist/types/src/styles/fragments/selected.d.ts +12 -0
  101. package/dist/types/src/styles/fragments/selected.d.ts.map +1 -0
  102. package/dist/types/src/styles/fragments/shimmer.d.ts +3 -0
  103. package/dist/types/src/styles/fragments/shimmer.d.ts.map +1 -0
  104. package/dist/types/src/styles/fragments/size.d.ts +9 -0
  105. package/dist/types/src/styles/fragments/size.d.ts.map +1 -0
  106. package/dist/types/src/styles/fragments/surface.d.ts +9 -0
  107. package/dist/types/src/styles/fragments/surface.d.ts.map +1 -0
  108. package/dist/types/src/styles/fragments/text.d.ts +6 -0
  109. package/dist/types/src/styles/fragments/text.d.ts.map +1 -0
  110. package/dist/types/src/styles/fragments/valence.d.ts +13 -0
  111. package/dist/types/src/styles/fragments/valence.d.ts.map +1 -0
  112. package/dist/types/src/styles/index.d.ts +4 -0
  113. package/dist/types/src/styles/index.d.ts.map +1 -0
  114. package/dist/types/src/styles/theme.d.ts +5 -0
  115. package/dist/types/src/styles/theme.d.ts.map +1 -0
  116. package/dist/types/src/tailwind.d.ts +1 -0
  117. package/dist/types/src/tailwind.d.ts.map +1 -0
  118. package/dist/types/src/util/index.d.ts +2 -0
  119. package/dist/types/src/util/index.d.ts.map +1 -0
  120. package/dist/types/src/util/mx.d.ts +2 -0
  121. package/dist/types/src/util/mx.d.ts.map +1 -0
  122. package/dist/types/src/util/semanticColors.d.ts +10 -0
  123. package/dist/types/src/util/semanticColors.d.ts.map +1 -0
  124. package/dist/types/src/util/withLogical.d.ts +158 -0
  125. package/dist/types/src/util/withLogical.d.ts.map +1 -0
  126. package/package.json +45 -0
  127. package/plugin.d.ts +7 -0
  128. package/plugin.js +10 -0
  129. package/src/config/colors.ts +293 -0
  130. package/src/config/index.ts +6 -0
  131. package/src/config/resolveContent.ts +50 -0
  132. package/src/config/tailwind.ts +200 -0
  133. package/src/esbuild-plugin.ts +60 -0
  134. package/src/index.ts +7 -0
  135. package/src/plugin.ts +63 -0
  136. package/src/styles/components/anchored-overflow.ts +20 -0
  137. package/src/styles/components/avatar.ts +96 -0
  138. package/src/styles/components/breadcrumb.ts +29 -0
  139. package/src/styles/components/button.ts +47 -0
  140. package/src/styles/components/dialog.ts +46 -0
  141. package/src/styles/components/index.ts +25 -0
  142. package/src/styles/components/input.ts +172 -0
  143. package/src/styles/components/link.ts +27 -0
  144. package/src/styles/components/list.ts +46 -0
  145. package/src/styles/components/main.ts +81 -0
  146. package/src/styles/components/menu.ts +52 -0
  147. package/src/styles/components/message.ts +27 -0
  148. package/src/styles/components/popover.ts +32 -0
  149. package/src/styles/components/scroll-area.ts +42 -0
  150. package/src/styles/components/select.ts +55 -0
  151. package/src/styles/components/separator.ts +19 -0
  152. package/src/styles/components/status.ts +27 -0
  153. package/src/styles/components/tag.ts +49 -0
  154. package/src/styles/components/toast.ts +53 -0
  155. package/src/styles/components/toolbar.ts +17 -0
  156. package/src/styles/components/tooltip.ts +27 -0
  157. package/src/styles/components/treegrid.ts +37 -0
  158. package/src/styles/fragments/arrow.ts +10 -0
  159. package/src/styles/fragments/density.ts +17 -0
  160. package/src/styles/fragments/dimensions.ts +5 -0
  161. package/src/styles/fragments/disabled.ts +6 -0
  162. package/src/styles/fragments/elevation.ts +14 -0
  163. package/src/styles/fragments/focus.ts +18 -0
  164. package/src/styles/fragments/group.ts +12 -0
  165. package/src/styles/fragments/hover.ts +22 -0
  166. package/src/styles/fragments/hue.ts +151 -0
  167. package/src/styles/fragments/index.ts +22 -0
  168. package/src/styles/fragments/layout.ts +7 -0
  169. package/src/styles/fragments/motion.ts +8 -0
  170. package/src/styles/fragments/ornament.ts +7 -0
  171. package/src/styles/fragments/selected.ts +39 -0
  172. package/src/styles/fragments/shimmer.ts +9 -0
  173. package/src/styles/fragments/size.ts +117 -0
  174. package/src/styles/fragments/surface.ts +29 -0
  175. package/src/styles/fragments/text.ts +11 -0
  176. package/src/styles/fragments/valence.ts +50 -0
  177. package/src/styles/index.ts +7 -0
  178. package/src/styles/layers/anchored-overflow.css +9 -0
  179. package/src/styles/layers/attention.css +50 -0
  180. package/src/styles/layers/button.css +73 -0
  181. package/src/styles/layers/can-scroll.css +26 -0
  182. package/src/styles/layers/checkbox.css +25 -0
  183. package/src/styles/layers/focus-ring.css +26 -0
  184. package/src/styles/layers/index.css +10 -0
  185. package/src/styles/layers/positioning.css +20 -0
  186. package/src/styles/layers/surfaces.css +39 -0
  187. package/src/styles/layers/tldraw.css +87 -0
  188. package/src/styles/layers/typography.css +152 -0
  189. package/src/styles/theme.ts +69 -0
  190. package/src/tailwind.ts +5 -0
  191. package/src/theme.css +52 -0
  192. package/src/typings.d.ts +7 -0
  193. package/src/util/index.ts +5 -0
  194. package/src/util/mx.ts +40 -0
  195. package/src/util/semanticColors.ts +57 -0
  196. package/src/util/withLogical.ts +110 -0
@@ -0,0 +1,96 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Size, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { descriptionText, getSize, getSizeHeight } from '../fragments';
9
+
10
+ export type AvatarStyleProps = Partial<{
11
+ size: Size;
12
+ srOnly: boolean;
13
+ status: 'active' | 'inactive' | 'current' | 'error' | 'warning' | 'internal';
14
+ animation: 'pulse' | 'none';
15
+ variant: 'circle' | 'square';
16
+ inGroup: boolean;
17
+ }>;
18
+
19
+ export const avatarRoot: ComponentFunction<AvatarStyleProps> = ({ size = 10, inGroup }, ...etc) =>
20
+ mx(
21
+ 'relative inline-flex shrink-0',
22
+ getSize(size),
23
+ inGroup && (size === 'px' || size <= 3 ? '-mie-1' : '-mie-2'),
24
+ ...etc,
25
+ );
26
+
27
+ export const avatarLabel: ComponentFunction<AvatarStyleProps> = ({ srOnly }, ...etc) => mx(srOnly && 'sr-only', ...etc);
28
+
29
+ export const avatarDescription: ComponentFunction<AvatarStyleProps> = ({ srOnly }, ...etc) =>
30
+ mx(descriptionText, srOnly && 'sr-only', ...etc);
31
+
32
+ export const avatarFrame: ComponentFunction<AvatarStyleProps> = ({ variant }, ...etc) =>
33
+ mx('is-full bs-full bg-[--surface-bg]', variant === 'circle' ? 'rounded-full' : 'rounded', ...etc);
34
+
35
+ export const avatarStatusIcon: ComponentFunction<AvatarStyleProps> = ({ status, size = 3 }, ...etc) =>
36
+ mx(
37
+ 'absolute block-end-0 inline-end-0',
38
+ getSize(size),
39
+ status === 'inactive'
40
+ ? 'text-warning-350 dark:text-warning-250'
41
+ : status === 'active'
42
+ ? 'text-success-350 dark:text-success-250'
43
+ : 'text-neutral-350 dark:text-neutral-250',
44
+ ...etc,
45
+ );
46
+
47
+ export const avatarRing: ComponentFunction<AvatarStyleProps> = ({ status, variant, animation }, ...etc) =>
48
+ mx(
49
+ 'absolute inset-0 border-2',
50
+ variant === 'circle' ? 'rounded-full' : 'rounded',
51
+ status === 'current'
52
+ ? 'border-primary-400 dark:border-primary-500'
53
+ : status === 'active'
54
+ ? 'border-success-400 dark:border-success-400'
55
+ : status === 'error'
56
+ ? 'border-error-400 dark:border-error-500'
57
+ : status === 'warning'
58
+ ? 'border-warning-400 dark:border-warning-500'
59
+ : status === 'inactive'
60
+ ? 'separator-separator'
61
+ : status === 'internal'
62
+ ? 'border-fuchsia-600'
63
+ : 'border-[color:var(--surface-bg)]',
64
+ animation === 'pulse' ? 'animate-halo-pulse' : '',
65
+ ...etc,
66
+ );
67
+
68
+ export const avatarFallbackText: ComponentFunction<AvatarStyleProps> = (_props, ...etc) => mx('fill-white', ...etc);
69
+
70
+ export const avatarGroup: ComponentFunction<AvatarStyleProps> = (_props, ...etc) =>
71
+ mx('inline-flex items-center', ...etc);
72
+
73
+ export const avatarGroupLabel: ComponentFunction<AvatarStyleProps> = ({ size, srOnly }, ...etc) =>
74
+ mx(
75
+ srOnly
76
+ ? 'sr-only'
77
+ : 'rounded-full truncate text-sm leading-none plb-1 pli-2 relative z-[1] flex items-center justify-center',
78
+ size && getSizeHeight(size),
79
+ ...etc,
80
+ );
81
+
82
+ export const avatarGroupDescription: ComponentFunction<AvatarStyleProps> = ({ srOnly }, ...etc) =>
83
+ mx(srOnly ? 'sr-only' : descriptionText, ...etc);
84
+
85
+ export const avatarTheme: Theme<AvatarStyleProps> = {
86
+ root: avatarRoot,
87
+ label: avatarLabel,
88
+ description: avatarDescription,
89
+ statusIcon: avatarStatusIcon,
90
+ frame: avatarFrame,
91
+ ring: avatarRing,
92
+ fallbackText: avatarFallbackText,
93
+ group: avatarGroup,
94
+ groupLabel: avatarGroupLabel,
95
+ groupDescription: avatarGroupDescription,
96
+ };
@@ -0,0 +1,29 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+
9
+ export type breadcrumbStyleProps = {};
10
+
11
+ export const breadcrumbRoot: ComponentFunction<breadcrumbStyleProps> = (_props, ...etc) =>
12
+ mx('shrink-0 flex items-center', ...etc);
13
+
14
+ export const breadcrumbList: ComponentFunction<breadcrumbStyleProps> = (_props, ...etc) => mx('contents', ...etc);
15
+
16
+ export const breadcrumbListItem: ComponentFunction<breadcrumbStyleProps> = (_props, ...etc) => mx('contents', ...etc);
17
+
18
+ export const breadcrumbCurrent: ComponentFunction<breadcrumbStyleProps> = (_props, ...etc) => mx(...etc);
19
+
20
+ export const breadcrumbSeparator: ComponentFunction<breadcrumbStyleProps> = (_props, ...etc) =>
21
+ mx('opacity-50', ...etc);
22
+
23
+ export const breadcrumbTheme: Theme<breadcrumbStyleProps> = {
24
+ root: breadcrumbRoot,
25
+ list: breadcrumbList,
26
+ listItem: breadcrumbListItem,
27
+ current: breadcrumbCurrent,
28
+ separator: breadcrumbSeparator,
29
+ };
@@ -0,0 +1,47 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import type { Density, Elevation, ComponentFunction, Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { contentElevation, ghostHover } from '../fragments';
9
+
10
+ export const primaryButtonColors =
11
+ 'fg-inverse surface-accent hover:surface-accentHover aria-pressed:bg-primary-500 dark:aria-pressed:bg-primary-500 data-[state=open]:bg-primary-500 dark:data-[state=open]:bg-primary-500 aria-checked:bg-primary-500 dark:aria-checked:bg-primary-500 aria-checked:text-primary-100';
12
+
13
+ export const staticDefaultButtonColors = 'surface-input';
14
+
15
+ export const defaultButtonColors =
16
+ staticDefaultButtonColors +
17
+ ' data-[state=open]:surface-input aria-pressed:fg-accent aria-pressed:surface-base aria-checked:fg-accent aria-checked:surface-base';
18
+
19
+ export const ghostButtonColors =
20
+ ghostHover +
21
+ ' hover:text-inherit data-[state=open]:surface-input aria-pressed:fg-accent aria-pressed:surface-base aria-checked:fg-accent aria-checked:surface-base';
22
+
23
+ export type ButtonStyleProps = Partial<{
24
+ inGroup?: boolean;
25
+ textWrap?: boolean;
26
+ density: Density;
27
+ elevation: Elevation;
28
+ disabled: boolean;
29
+ variant: 'default' | 'primary' | 'ghost' | 'outline';
30
+ }>;
31
+
32
+ export const buttonRoot: ComponentFunction<ButtonStyleProps> = (_props, ...etc) => {
33
+ return mx('ch-button ch-focus-ring group', ...etc);
34
+ };
35
+
36
+ export const buttonGroup: ComponentFunction<{ elevation?: Elevation }> = (props, ...etc) => {
37
+ return mx(
38
+ 'inline-flex rounded-sm [&>:first-child]:rounded-is-sm [&>:last-child]:rounded-ie-sm [&>button]:relative',
39
+ contentElevation({ elevation: props.elevation }),
40
+ ...etc,
41
+ );
42
+ };
43
+
44
+ export const buttonTheme: Theme<ButtonStyleProps> = {
45
+ root: buttonRoot,
46
+ group: buttonGroup,
47
+ };
@@ -0,0 +1,46 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Elevation, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { descriptionText, focusRing, surfaceElevation, dialogMotion, groupBorder } from '../fragments';
9
+
10
+ export type DialogStyleProps = {
11
+ srOnly?: boolean;
12
+ inOverlayLayout?: boolean;
13
+ elevation?: Elevation;
14
+ };
15
+
16
+ const dialogLayoutFragment = 'overflow-auto grid place-items-center p-2 md:p-4 lg:p-8';
17
+
18
+ export const dialogOverlay: ComponentFunction<DialogStyleProps> = (_props, ...etc) =>
19
+ mx('fixed z-[22] inset-inline-0 block-start-0 bs-[100dvh] surface-scrim', dialogLayoutFragment, ...etc);
20
+
21
+ export const dialogContent: ComponentFunction<DialogStyleProps> = ({ inOverlayLayout, elevation = 'chrome' }, ...etc) =>
22
+ mx(
23
+ // TODO(thure): `flex` should not be default.
24
+ 'flex flex-col',
25
+ !inOverlayLayout && 'fixed z-[22] top-[50%] left-[50%] -translate-x-[50%] -translate-y-[50%]',
26
+ 'is-[95vw] max-is-full md:max-is-[24rem] border rounded-lg p-4',
27
+ dialogMotion,
28
+ surfaceElevation({ elevation }),
29
+ 'surface-baseGlass backdrop-blur',
30
+ groupBorder,
31
+ focusRing,
32
+ ...etc,
33
+ );
34
+
35
+ export const dialogTitle: ComponentFunction<DialogStyleProps> = ({ srOnly }, ...etc) =>
36
+ mx('rounded shrink-0 text-xl font-medium', srOnly && 'sr-only', ...etc);
37
+
38
+ export const dialogDescription: ComponentFunction<DialogStyleProps> = ({ srOnly }, ...etc) =>
39
+ mx('mlb-2', descriptionText, srOnly && 'sr-only', ...etc);
40
+
41
+ export const dialogTheme: Theme<DialogStyleProps> = {
42
+ overlay: dialogOverlay,
43
+ content: dialogContent,
44
+ title: dialogTitle,
45
+ description: dialogDescription,
46
+ };
@@ -0,0 +1,25 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export * from './anchored-overflow';
6
+ export * from './avatar';
7
+ export * from './breadcrumb';
8
+ export * from './button';
9
+ export * from './dialog';
10
+ export * from './menu';
11
+ export * from './input';
12
+ export * from './link';
13
+ export * from './list';
14
+ export * from './main';
15
+ export * from './message';
16
+ export * from './popover';
17
+ export * from './scroll-area';
18
+ export * from './select';
19
+ export * from './separator';
20
+ export * from './status';
21
+ export * from './tag';
22
+ export * from './toast';
23
+ export * from './toolbar';
24
+ export * from './tooltip';
25
+ export * from './treegrid';
@@ -0,0 +1,172 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import {
6
+ type ComponentFragment,
7
+ type ComponentFunction,
8
+ type Density,
9
+ type Elevation,
10
+ type MessageValence,
11
+ type Size,
12
+ } from '@dxos/react-ui-types';
13
+
14
+ import { mx } from '../../util';
15
+ import {
16
+ coarseDimensions,
17
+ staticDisabled,
18
+ fineDimensions,
19
+ placeholderText,
20
+ focusRing,
21
+ subduedFocus,
22
+ fineBlockSize,
23
+ coarseBlockSize,
24
+ staticFocusRing,
25
+ descriptionText,
26
+ valenceColorText,
27
+ getSize,
28
+ computeSize,
29
+ sizeValue,
30
+ getSizeHeight,
31
+ getSizeWidth,
32
+ } from '../fragments';
33
+
34
+ export type InputStyleProps = Partial<{
35
+ variant: 'default' | 'subdued' | 'static';
36
+ disabled: boolean;
37
+ focused: boolean;
38
+ density: Density;
39
+ elevation: Elevation;
40
+ validationValence: MessageValence;
41
+ size: Size;
42
+ }>;
43
+
44
+ export type InputMetaStyleProps = Partial<{
45
+ srOnly: boolean;
46
+ validationValence: MessageValence;
47
+ }>;
48
+
49
+ export const neutralInputValence = '';
50
+ export const successInputValence = 'shadow-success-500/50 dark:shadow-success-600/50';
51
+ export const infoInputValence = 'shadow-info-500/50 dark:shadow-info-600/50';
52
+ export const warningInputValence = 'shadow-warning-500/50 dark:shadow-warning-600/50';
53
+ export const errorInputValence = 'shadow-error-500/50 dark:shadow-error-600/50';
54
+
55
+ const textInputSurfaceFocus =
56
+ 'transition-colors surface-input focus:surface-attention border-transparent focus:border-transparent';
57
+
58
+ const textInputSurfaceHover = 'hover:surface-hover focus:hover:surface-attention';
59
+
60
+ const booleanInputSurface =
61
+ 'shadow-inner transition-colors surface-unAccent aria-checked:surface-accent aria-[checked=mixed]:surface-accent';
62
+
63
+ const booleanInputSurfaceHover =
64
+ 'hover:surface-unAccentHover hover:aria-checked:surface-accentHover hover:aria-[checked=mixed]:surface-accentHover';
65
+
66
+ export const inputValence = (valence?: MessageValence) => {
67
+ switch (valence) {
68
+ case 'success':
69
+ return successInputValence;
70
+ case 'info':
71
+ return infoInputValence;
72
+ case 'warning':
73
+ return warningInputValence;
74
+ case 'error':
75
+ return errorInputValence;
76
+ default:
77
+ return null;
78
+ }
79
+ };
80
+
81
+ // TODO(burdon): Factor out color defs?
82
+ const sharedSubduedInputStyles: ComponentFragment<InputStyleProps> = (props) => [
83
+ 'is-full bg-transparent text-current',
84
+ props.density === 'fine' ? fineBlockSize : coarseBlockSize,
85
+ placeholderText,
86
+ subduedFocus,
87
+ props.disabled && staticDisabled,
88
+ ];
89
+
90
+ const sharedDefaultInputStyles: ComponentFragment<InputStyleProps> = (props) => [
91
+ 'is-full text-base rounded text-[color:var(--surface-text)]',
92
+ textInputSurfaceFocus,
93
+ placeholderText,
94
+ props.density === 'fine' ? fineDimensions : coarseDimensions,
95
+ props.disabled ? staticDisabled : textInputSurfaceHover,
96
+ ];
97
+
98
+ const sharedStaticInputStyles: ComponentFragment<InputStyleProps> = (props) => [
99
+ 'is-full text-base rounded text-[color:var(--surface-text)]',
100
+ textInputSurfaceFocus,
101
+ textInputSurfaceHover,
102
+ props.focused && 'surface-attention',
103
+ placeholderText,
104
+ inputValence(props.validationValence),
105
+ props.disabled && staticDisabled,
106
+ props.focused && staticFocusRing,
107
+ ];
108
+
109
+ export const inputInput: ComponentFunction<InputStyleProps> = (props, ...etc) =>
110
+ props.variant === 'subdued'
111
+ ? mx(...sharedSubduedInputStyles(props), ...etc)
112
+ : props.variant === 'static'
113
+ ? mx(...sharedStaticInputStyles(props), ...etc)
114
+ : mx(
115
+ ...sharedDefaultInputStyles(props),
116
+ !props.disabled && focusRing,
117
+ inputValence(props.validationValence) || neutralInputValence,
118
+ ...etc,
119
+ );
120
+
121
+ export const inputCheckbox: ComponentFunction<InputStyleProps> = ({ size = 5 }, ...etc) =>
122
+ mx('ch-checkbox ch-focus-ring', getSize(size), ...etc);
123
+
124
+ export const inputCheckboxIndicator: ComponentFunction<InputStyleProps> = ({ size = 5 }, ...etc) =>
125
+ mx(getSize(computeSize(sizeValue(size) * 0.65, 4)), ...etc);
126
+
127
+ export const inputSwitch: ComponentFunction<InputStyleProps> = ({ size = 5, disabled }, ...etc) =>
128
+ mx(
129
+ getSizeHeight(size),
130
+ getSizeWidth(computeSize(sizeValue(size) * 1.75, 9)),
131
+ booleanInputSurface,
132
+ !disabled && booleanInputSurfaceHover,
133
+ // TODO(burdon): Added m-1 margin to make 40px width to align with 40px icon button.
134
+ 'cursor-pointer shrink-0 rounded-full pli-1 mx-1 relative',
135
+ focusRing,
136
+ ...etc,
137
+ );
138
+
139
+ export const inputSwitchThumb: ComponentFunction<InputStyleProps> = ({ size = 5 }, ...etc) =>
140
+ mx(
141
+ getSize(size === 'px' ? 'px' : ((size - 2) as Size)),
142
+ 'block bg-white rounded-full separator-separator transition-transform duration-100 will-change-transform data-[state=checked]:translate-x-[100%]',
143
+ ...etc,
144
+ );
145
+
146
+ export const inputWithSegmentsInput: ComponentFunction<InputStyleProps> = (props, ...etc) =>
147
+ mx('font-mono selection:bg-transparent mli-auto', props.disabled && 'cursor-not-allowed', ...etc);
148
+
149
+ export const inputLabel: ComponentFunction<InputMetaStyleProps> = (props, ...etc) =>
150
+ mx('block text-sm font-medium', props.srOnly && 'sr-only', ...etc);
151
+
152
+ export const inputDescription: ComponentFunction<InputMetaStyleProps> = (props, ...etc) =>
153
+ mx(descriptionText, props.srOnly && 'sr-only', ...etc);
154
+
155
+ export const inputDescriptionAndValidation: ComponentFunction<InputMetaStyleProps> = (props, ...etc) =>
156
+ mx('leading-none mlb-1', props.srOnly && 'sr-only', ...etc);
157
+
158
+ export const inputValidation: ComponentFunction<InputMetaStyleProps> = (props, ...etc) =>
159
+ mx(descriptionText, props.srOnly ? 'sr-only' : valenceColorText(props.validationValence), ...etc);
160
+
161
+ export const inputTheme = {
162
+ input: inputInput,
163
+ inputWithSegments: inputWithSegmentsInput,
164
+ checkbox: inputCheckbox,
165
+ checkboxIndicator: inputCheckboxIndicator,
166
+ label: inputLabel,
167
+ description: inputDescription,
168
+ validation: inputValidation,
169
+ switch: inputSwitch,
170
+ switchThumb: inputSwitchThumb,
171
+ descriptionAndValidation: inputDescriptionAndValidation,
172
+ };
@@ -0,0 +1,27 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { focusRing } from '../fragments';
9
+
10
+ export type LinkStyleProps = {
11
+ variant?: 'accent' | 'neutral';
12
+ };
13
+
14
+ // TODO(burdon): Export fragment.
15
+ export const linkRoot: ComponentFunction<LinkStyleProps> = ({ variant }, ...etc) =>
16
+ mx(
17
+ 'underline decoration-1 underline-offset-2 transition-color rounded-sm',
18
+ variant === 'neutral'
19
+ ? 'text-inherit hover:opacity-90 visited:text-inherit visited:hover:opacity-90'
20
+ : 'fg-accent hover:fg-accentHover visited:fg-accent visited:hover:fg-accentHover',
21
+ focusRing,
22
+ ...etc,
23
+ );
24
+
25
+ export const linkTheme: Theme<LinkStyleProps> = {
26
+ root: linkRoot,
27
+ };
@@ -0,0 +1,46 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Density, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { focusRing, densityBlockSize, getSize, ghostHover } from '../fragments';
9
+
10
+ export type ListStyleProps = Partial<{
11
+ density: Density;
12
+ collapsible: boolean;
13
+ }>;
14
+
15
+ export const listRoot: ComponentFunction<ListStyleProps> = (_, ...etc) => mx(...etc);
16
+
17
+ export const listItem: ComponentFunction<ListStyleProps> = ({ collapsible }, ...etc) =>
18
+ mx(!collapsible && 'flex', ...etc);
19
+
20
+ export const listItemEndcap: ComponentFunction<ListStyleProps> = ({ density }, ...etc) =>
21
+ mx(density === 'fine' ? getSize(8) : getSize(10), 'shrink-0 flex items-start justify-center', ...etc);
22
+
23
+ export const listItemHeading: ComponentFunction<ListStyleProps> = ({ density }, ...etc) =>
24
+ mx(densityBlockSize(density), ...etc);
25
+
26
+ export const listItemDragHandleIcon: ComponentFunction<ListStyleProps> = (_props, ...etc) =>
27
+ mx(getSize(5), 'mbs-2.5', ...etc);
28
+
29
+ export const listItemOpenTrigger: ComponentFunction<ListStyleProps> = ({ density }, ...etc) =>
30
+ mx('is-5 rounded flex justify-center items-center', densityBlockSize(density), ghostHover, focusRing, ...etc);
31
+
32
+ export const listItemOpenTriggerIcon: ComponentFunction<ListStyleProps> = (_props, ...etc) => {
33
+ return mx(getSize(5), ...etc);
34
+ };
35
+
36
+ export const listTheme: Theme<ListStyleProps> = {
37
+ root: listRoot,
38
+ item: {
39
+ root: listItem,
40
+ endcap: listItemEndcap,
41
+ heading: listItemHeading,
42
+ dragHandleIcon: listItemDragHandleIcon,
43
+ openTrigger: listItemOpenTrigger,
44
+ openTriggerIcon: listItemOpenTriggerIcon,
45
+ },
46
+ };
@@ -0,0 +1,81 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction } from '@dxos/react-ui-types/src';
6
+
7
+ import { mx } from '../../util';
8
+ import { bounceLayout, fixedBorder, fixedSurface } from '../fragments';
9
+
10
+ // Padding to apply to in-flow elements which need to clear the fixed topbar / bottombar.
11
+ export const topbarBlockPaddingStart = 'pbs-[--topbar-size] sticky-top-from-topbar-bottom';
12
+ export const bottombarBlockPaddingEnd = 'pbe-[--statusbar-size] sticky-bottom-from-statusbar-bottom';
13
+
14
+ export type MainStyleProps = Partial<{
15
+ bounce: boolean;
16
+ }>;
17
+
18
+ // Sidebar widths (used by main and complementary sidebar).
19
+ const sidebarSlots = {
20
+ start: {
21
+ width: 'sm:data-[side=is]:is-[270px]',
22
+ sidebar: 'sm:data-[side=is]:-inline-start-[270px]',
23
+ content:
24
+ 'lg:data-[sidebar-inline-start-state=open]:pis-[270px] lg:data-[sidebar-inline-start-state=open]:scroll-ps-[270px]',
25
+ notch: 'max-is-[270px]',
26
+ },
27
+ // TODO(burdon): Maximal size for phone.
28
+ end: {
29
+ width: 'sm:data-[side=ie]:is-[360px]',
30
+ sidebar: 'sm:data-[side=ie]:-inline-end-[360px]',
31
+ content:
32
+ 'lg:data-[sidebar-inline-end-state=open]:pie-[360px] lg:data-[sidebar-inline-end-state=open]:scroll-pe-[360px]',
33
+ },
34
+ };
35
+
36
+ export const mainSidebar: ComponentFunction<MainStyleProps> = (_, ...etc) =>
37
+ mx(
38
+ 'fixed block-start-0 block-end-0 is-[100vw] z-10 data-[side=ie]:z-20 overscroll-contain overflow-x-hidden overflow-y-auto',
39
+ 'transition-[inset-inline-start,inset-inline-end] duration-0 data-[resizing=false]:duration-200 ease-in-out',
40
+ `data-[side=is]:-inline-start-[100vw] ${sidebarSlots.start.width} ${sidebarSlots.start.sidebar}`,
41
+ `data-[side=ie]:-inline-end-[100vw] ${sidebarSlots.end.width} ${sidebarSlots.end.sidebar}`,
42
+ 'data-[side=is]:data-[state=open]:inline-start-0 data-[side=ie]:data-[state=open]:inline-end-0',
43
+ 'data-[side=is]:border-ie data-[side=ie]:border-is',
44
+ fixedBorder,
45
+ fixedSurface,
46
+ ...etc,
47
+ );
48
+
49
+ export const mainContent: ComponentFunction<MainStyleProps> = ({ bounce }, ...etc) =>
50
+ mx(
51
+ 'transition-[padding-inline-start,padding-inline-end,scroll-padding-start,scroll-padding-end] duration-200 ease-in-out',
52
+ `pis-0 scroll-ps-0 ${sidebarSlots.start.content}`,
53
+ `pie-0 scroll-pe-0 ${sidebarSlots.end.content}`,
54
+ bounce && bounceLayout,
55
+ ...etc,
56
+ );
57
+
58
+ export const mainOverlay: ComponentFunction<MainStyleProps> = (_, ...etc) =>
59
+ mx(
60
+ 'fixed inset-0 z-[9] surface-scrim',
61
+ 'transition-opacity duration-200 ease-in-out',
62
+ 'opacity-0 data-[state=open]:opacity-100 lg:data-[state=open]:opacity-100',
63
+ 'hidden data-[state=open]:block lg:data-[state=open]:hidden',
64
+ ...etc,
65
+ );
66
+
67
+ export const mainNotch: ComponentFunction<MainStyleProps> = (_, ...etc) =>
68
+ mx(
69
+ 'fixed z-[11] block-end-0 inline-start-0 pbe-[env(safe-area-inset-bottom)] rounded-se-lg min-bs-[var(--rail-size)] is-fit separator-separator surface-base',
70
+ 'transition-[border-width] box-content border-bs border-ie data-[nav-sidebar-state=open]:border-bs-0 data-[nav-sidebar-state=open]:border-ie-0',
71
+ 'pli-1 grid grid-cols-[repeat(auto-fit,var(--rail-action))]',
72
+ sidebarSlots.start.notch,
73
+ ...etc,
74
+ );
75
+
76
+ export const mainTheme = {
77
+ content: mainContent,
78
+ sidebar: mainSidebar,
79
+ overlay: mainOverlay,
80
+ notch: mainNotch,
81
+ };
@@ -0,0 +1,52 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import {
9
+ arrow,
10
+ modalSurface,
11
+ dataDisabled,
12
+ descriptionText,
13
+ popperMotion,
14
+ subduedFocus,
15
+ surfaceElevation,
16
+ } from '../fragments';
17
+
18
+ export type MenuStyleProps = Partial<{
19
+ constrainBlockSize: boolean;
20
+ }>;
21
+
22
+ export const menuViewport: ComponentFunction<MenuStyleProps> = (_props, ...etc) =>
23
+ mx('rounded-md p-1 max-bs-[--radix-dropdown-menu-content-available-height] overflow-y-auto', ...etc);
24
+
25
+ export const menuContent: ComponentFunction<MenuStyleProps> = (_props, ...etc) =>
26
+ mx('is-48 rounded-md md:is-56 z-[30]', popperMotion, modalSurface, surfaceElevation({ elevation: 'group' }), ...etc);
27
+
28
+ export const menuItem: ComponentFunction<MenuStyleProps> = (_props, ...etc) =>
29
+ mx(
30
+ 'flex cursor-pointer select-none items-center gap-2 rounded-md px-2 py-2 text-sm',
31
+ 'data-[highlighted]:surface-hover',
32
+ subduedFocus,
33
+ dataDisabled,
34
+ ...etc,
35
+ );
36
+
37
+ export const menuSeparator: ComponentFunction<MenuStyleProps> = (_props, ...etc) =>
38
+ mx('mlb-1 mli-2 bs-px bg-neutral-75 dark:bg-neutral-700', ...etc);
39
+
40
+ export const menuGroupLabel: ComponentFunction<MenuStyleProps> = (_props, ...etc) =>
41
+ mx(descriptionText, 'select-none pli-2 plb-2', ...etc);
42
+
43
+ export const menuArrow: ComponentFunction<MenuStyleProps> = (_props, ...etc) => mx(arrow, ...etc);
44
+
45
+ export const menuTheme: Theme<MenuStyleProps> = {
46
+ content: menuContent,
47
+ viewport: menuViewport,
48
+ item: menuItem,
49
+ separator: menuSeparator,
50
+ groupLabel: menuGroupLabel,
51
+ arrow: menuArrow,
52
+ };
@@ -0,0 +1,27 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentFunction, type Elevation, type MessageValence, type Theme } from '@dxos/react-ui-types';
6
+
7
+ import { mx } from '../../util';
8
+ import { messageValence, contentElevation } from '../fragments';
9
+
10
+ export type MessageStyleProps = {
11
+ valence?: MessageValence;
12
+ elevation?: Elevation;
13
+ };
14
+
15
+ export const messageRoot: ComponentFunction<MessageStyleProps> = ({ valence, elevation }, ...etc) =>
16
+ mx('p-3 rounded-md max-is-full overflow-auto', contentElevation({ elevation }), messageValence(valence), ...etc);
17
+
18
+ export const messageTitle: ComponentFunction<MessageStyleProps> = (_props, ...etc) =>
19
+ mx('text-base font-medium mb-2', ...etc);
20
+
21
+ export const messageBody: ComponentFunction<MessageStyleProps> = (_props, ...etc) => mx(...etc);
22
+
23
+ export const messageTheme: Theme<MessageStyleProps> = {
24
+ root: messageRoot,
25
+ title: messageTitle,
26
+ body: messageBody,
27
+ };