@helpwave/hightide-native 0.1.1 → 0.3.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.
Files changed (65) hide show
  1. package/package.json +2 -2
  2. package/src/components/chat/ChatAttachmentMessageBubble.tsx +3 -0
  3. package/src/components/chat/ChatConversationRow.tsx +127 -27
  4. package/src/components/chat/ChatQuickReplyChip.tsx +7 -1
  5. package/src/components/chat/ChatThreadHeader.tsx +88 -48
  6. package/src/components/list/ListActionItem.tsx +60 -11
  7. package/src/components/list/ListItem.tsx +47 -21
  8. package/src/components/list/ListItemAccessory.tsx +34 -0
  9. package/src/components/list/ListItemTextContent.tsx +53 -0
  10. package/src/components/list/ListNavigationItem.tsx +60 -16
  11. package/src/components/list/index.ts +2 -0
  12. package/src/components/user-interaction/Button.tsx +6 -15
  13. package/src/components/user-interaction/IconButton.tsx +5 -7
  14. package/src/components/user-interaction/MultiSelect.tsx +72 -46
  15. package/src/components/user-interaction/Select.tsx +5 -1
  16. package/src/components/user-interaction/ThemedPressable.tsx +9 -4
  17. package/src/components/visualization-and-display/Chip.tsx +12 -5
  18. package/src/components/visualization-and-display/ThemedIcon.tsx +12 -8
  19. package/src/components/visualization-and-display/ThemedText.tsx +6 -2
  20. package/src/global-contexts/HightideProvider.tsx +9 -17
  21. package/src/global-contexts/content-theme/ContentThemeContext.ts +5 -2
  22. package/src/global-contexts/content-theme/ContentThemeProvider.tsx +64 -10
  23. package/src/global-contexts/theme/ThemeProvider.tsx +9 -4
  24. package/src/theme/adapters/index.ts +1 -4
  25. package/src/theme/adapters/style-adapter-utils.ts +433 -0
  26. package/src/theme/resolvers/avatar.ts +9 -10
  27. package/src/theme/resolvers/button.ts +6 -7
  28. package/src/theme/resolvers/card.ts +3 -2
  29. package/src/theme/resolvers/chat/attachment-message-bubble.ts +25 -37
  30. package/src/theme/resolvers/chat/conversation-list.ts +5 -4
  31. package/src/theme/resolvers/chat/conversation-row.ts +114 -14
  32. package/src/theme/resolvers/chat/date-divider.ts +4 -4
  33. package/src/theme/resolvers/chat/message-bubble.ts +9 -10
  34. package/src/theme/resolvers/chat/message-composer.ts +5 -6
  35. package/src/theme/resolvers/chat/message-list.ts +3 -2
  36. package/src/theme/resolvers/chat/quick-reply-chip.ts +12 -20
  37. package/src/theme/resolvers/chat/system-line.ts +5 -6
  38. package/src/theme/resolvers/chat/thread-header.ts +60 -12
  39. package/src/theme/resolvers/checkbox.ts +6 -6
  40. package/src/theme/resolvers/chip.ts +9 -4
  41. package/src/theme/resolvers/divider.ts +3 -3
  42. package/src/theme/resolvers/iconButton.ts +5 -10
  43. package/src/theme/resolvers/input.ts +12 -7
  44. package/src/theme/resolvers/listItem.ts +19 -16
  45. package/src/theme/resolvers/multiSelect.ts +23 -16
  46. package/src/theme/resolvers/searchBar.ts +14 -7
  47. package/src/theme/resolvers/select.ts +22 -15
  48. package/src/theme/resolvers/switch.ts +5 -4
  49. package/src/theme/resolvers/themedPressable.ts +10 -5
  50. package/src/theme/themes/createHightideTheme.ts +13 -4
  51. package/src/theme/types/components/chat.ts +63 -3
  52. package/src/theme/types/components/chip.ts +4 -0
  53. package/src/theme/types/components/iconButton.ts +1 -7
  54. package/src/theme/types/components/listItem.ts +5 -0
  55. package/src/theme/types/components/multiSelect.ts +1 -0
  56. package/src/theme/types/components/select.ts +1 -0
  57. package/src/theme/types/components/themedPressable.ts +4 -0
  58. package/src/theme/types/layout.ts +13 -7
  59. package/src/theme/types/semantics.ts +2 -1
  60. package/src/theme/types/theme.ts +40 -12
  61. package/src/theme/types/typography.ts +9 -4
  62. package/src/theme/adapters/container-adapter.ts +0 -323
  63. package/src/theme/adapters/defined.ts +0 -11
  64. package/src/theme/adapters/icon-style-adapter.ts +0 -10
  65. package/src/theme/adapters/text-style-adapter.ts +0 -16
@@ -1,323 +0,0 @@
1
- import type { ViewStyle } from 'react-native'
2
-
3
- import type {
4
- AlignSelfToken,
5
- AxisAligmentToken,
6
- BorderRadiusToken,
7
- BorderToken,
8
- ContainerTokens,
9
- DirectionalToken,
10
- LayoutDirectionToken,
11
- MarginToken,
12
- PaddingToken
13
- } from '@helpwave/hightide-design/component-token-resolvers'
14
- import {
15
- defaultWritingMode,
16
- resolveDirectionalTokens
17
- } from '@helpwave/hightide-design/component-token-resolvers'
18
- import type { ColorToken, HexColorToken } from '@helpwave/hightide-design/primitive-tokens'
19
- import type { ShadowToken } from '@helpwave/hightide-design/theme-tokens'
20
- import { HexColorUtils } from '@helpwave/hightide-design/utils'
21
-
22
- import { defined } from './defined'
23
-
24
- export const toShadowStyle = (shadow: ShadowToken): ViewStyle => defined({
25
- boxShadow: [{
26
- color: shadow.color,
27
- offsetX: shadow.x,
28
- offsetY: shadow.y,
29
- blurRadius: shadow.blur,
30
- spreadDistance: shadow.spread,
31
- }],
32
- })
33
-
34
- const toFlexDirection = (
35
- direction?: LayoutDirectionToken
36
- ): ViewStyle['flexDirection'] => {
37
- if (direction === undefined) {
38
- return undefined
39
- }
40
-
41
- return direction === 'horizontal' ? 'row' : 'column'
42
- }
43
-
44
- const toJustifyContent = (
45
- alignment?: AxisAligmentToken
46
- ): ViewStyle['justifyContent'] => {
47
- if (alignment === undefined) {
48
- return undefined
49
- }
50
-
51
- if (alignment === 'start') {
52
- return 'flex-start'
53
- }
54
-
55
- if (alignment === 'end') {
56
- return 'flex-end'
57
- }
58
-
59
- return 'center'
60
- }
61
-
62
- const toAlignItems = (
63
- alignment?: AxisAligmentToken
64
- ): ViewStyle['alignItems'] => {
65
- if (alignment === undefined) {
66
- return undefined
67
- }
68
-
69
- if (alignment === 'start') {
70
- return 'flex-start'
71
- }
72
-
73
- if (alignment === 'end') {
74
- return 'flex-end'
75
- }
76
-
77
- return 'center'
78
- }
79
-
80
- const toAlignSelf = (
81
- alignment?: AlignSelfToken
82
- ): ViewStyle['alignSelf'] => {
83
- if (alignment === undefined) {
84
- return undefined
85
- }
86
-
87
- if (alignment === 'start') {
88
- return 'flex-start'
89
- }
90
-
91
- if (alignment === 'end') {
92
- return 'flex-end'
93
- }
94
-
95
- return alignment
96
- }
97
-
98
- const toAlignContent = (
99
- alignment?: AlignSelfToken
100
- ): ViewStyle['alignContent'] => {
101
- if (alignment === undefined) {
102
- return undefined
103
- }
104
-
105
- if (alignment === 'start') {
106
- return 'flex-start'
107
- }
108
-
109
- if (alignment === 'end') {
110
- return 'flex-end'
111
- }
112
-
113
- return alignment
114
- }
115
-
116
- const toBorderRadiusStyle = (
117
- borderRadius?: BorderRadiusToken
118
- ): ViewStyle => {
119
- if (borderRadius === undefined) {
120
- return {}
121
- }
122
-
123
- if (borderRadius.type === 'all') {
124
- return defined({ borderRadius: borderRadius.value })
125
- }
126
-
127
- return defined({
128
- borderTopLeftRadius: borderRadius.topLeft,
129
- borderTopRightRadius: borderRadius.topRight,
130
- borderBottomLeftRadius: borderRadius.bottomLeft,
131
- borderBottomRightRadius: borderRadius.bottomRight,
132
- })
133
- }
134
-
135
- const toDirectionalBorderWidths = (
136
- width?: DirectionalToken<number>
137
- ): ViewStyle => {
138
- if (width === undefined) {
139
- return {}
140
- }
141
-
142
- switch (width.type) {
143
- case 'all':
144
- return defined({
145
- borderWidth: width.value,
146
- })
147
- case 'physicalAxis':
148
- return defined({
149
- borderTopWidth: width.vertical,
150
- borderBottomWidth: width.vertical,
151
- borderLeftWidth: width.horizontal,
152
- borderRightWidth: width.horizontal,
153
- })
154
- case 'physicalSide':
155
- return defined({
156
- borderTopWidth: width.top,
157
- borderRightWidth: width.right,
158
- borderBottomWidth: width.bottom,
159
- borderLeftWidth: width.left,
160
- })
161
- case 'logicalAxis':
162
- return defined({
163
- borderTopWidth: width.block,
164
- borderBottomWidth: width.block,
165
- borderStartWidth: width.inline,
166
- borderEndWidth: width.inline,
167
- })
168
- case 'logicalSide':
169
- return defined({
170
- borderStartWidth: width.inlineStart,
171
- borderEndWidth: width.inlineEnd,
172
- borderTopWidth: width.blockStart,
173
- borderBottomWidth: width.blockEnd,
174
- })
175
- }
176
- }
177
-
178
- const toDirectionalBorderColors = (
179
- color?: NonNullable<BorderToken['color']>
180
- ): ViewStyle => {
181
- if (color === undefined) {
182
- return {}
183
- }
184
-
185
- switch (color.type) {
186
- case 'all':
187
- return defined({
188
- borderColor: color.value,
189
- })
190
- case 'physicalAxis':
191
- return defined({
192
- borderTopColor: color.vertical,
193
- borderBottomColor: color.vertical,
194
- borderLeftColor: color.horizontal,
195
- borderRightColor: color.horizontal,
196
- })
197
- case 'physicalSide':
198
- return defined({
199
- borderTopColor: color.top,
200
- borderRightColor: color.right,
201
- borderBottomColor: color.bottom,
202
- borderLeftColor: color.left,
203
- })
204
- case 'logicalAxis':
205
- return defined({
206
- borderTopColor: color.block,
207
- borderBottomColor: color.block,
208
- borderStartColor: color.inline,
209
- borderEndColor: color.inline,
210
- })
211
- case 'logicalSide':
212
- return defined({
213
- borderStartColor: color.inlineStart,
214
- borderEndColor: color.inlineEnd,
215
- borderTopColor: color.blockStart,
216
- borderBottomColor: color.blockEnd,
217
- })
218
- }
219
- }
220
-
221
- const toBorderStyle = (border?: BorderToken): ViewStyle => {
222
- if (border === undefined) {
223
- return {}
224
- }
225
-
226
- return defined({
227
- ...toDirectionalBorderWidths(border.width),
228
- ...toDirectionalBorderColors(border.color),
229
- borderStyle: border.style,
230
- })
231
- }
232
-
233
- const toPaddingStyle = (padding?: PaddingToken): ViewStyle => {
234
- if (padding === undefined) {
235
- return {}
236
- }
237
-
238
- const sides = resolveDirectionalTokens([padding], defaultWritingMode)
239
-
240
- return defined({
241
- paddingTop: sides.top,
242
- paddingRight: sides.right,
243
- paddingBottom: sides.bottom,
244
- paddingLeft: sides.left,
245
- })
246
- }
247
-
248
- const toMarginStyle = (margin?: MarginToken): ViewStyle => {
249
- if (margin === undefined) {
250
- return {}
251
- }
252
-
253
- const sides = resolveDirectionalTokens([margin], defaultWritingMode)
254
-
255
- return defined({
256
- marginTop: sides.top,
257
- marginRight: sides.right,
258
- marginBottom: sides.bottom,
259
- marginLeft: sides.left,
260
- })
261
- }
262
-
263
- export const toContainerStyle = (tokens: ContainerTokens): ViewStyle => defined({
264
- display: 'flex',
265
- overflow: tokens.overflow,
266
- flexWrap: tokens.layout?.flexWrap,
267
- flexDirection: toFlexDirection(tokens.layout?.direction),
268
- justifyContent: toJustifyContent(tokens.layout?.mainAxisAlignment),
269
- alignItems: toAlignItems(tokens.layout?.crossAxisAligment),
270
- alignContent: toAlignContent(tokens.layout?.alignContent),
271
- alignSelf: toAlignSelf(tokens.layout?.alignSelf),
272
- backgroundColor: tokens.backgroundColor,
273
- opacity: tokens.opacity,
274
- ...toBorderStyle(tokens.border),
275
- height: tokens.size?.height,
276
- width: tokens.size?.width,
277
- minHeight: tokens.size?.minHeight,
278
- minWidth: tokens.size?.minWidth,
279
- maxHeight: tokens.size?.maxHeight,
280
- maxWidth: tokens.size?.maxWidth,
281
- ...toBorderRadiusStyle(tokens.shape?.borderRadius),
282
- ...toPaddingStyle(tokens.padding),
283
- ...toMarginStyle(tokens.margin),
284
- gap: tokens.layout?.gap,
285
- outlineColor: tokens.outline?.color,
286
- outlineOffset: tokens.outline?.offset,
287
- outlineWidth: tokens.outline?.width,
288
- outlineStyle: tokens.outline?.style,
289
- ...(tokens.decoration?.shadow ? toShadowStyle(tokens.decoration.shadow) : {}),
290
- })
291
-
292
- const blendWithStateLayer = (
293
- base: ColorToken | undefined,
294
- tint: ColorToken
295
- ): ColorToken | undefined => {
296
- if (base === undefined || tint === 'transparent' || base === 'transparent') {
297
- return base
298
- }
299
-
300
- return HexColorUtils.blend(base as HexColorToken, tint as HexColorToken)
301
- }
302
-
303
- export const toContainerStyleWithStateLayer = (
304
- container: ContainerTokens,
305
- stateLayer?: ContainerTokens
306
- ): ViewStyle => {
307
- const tint = stateLayer?.backgroundColor ?? 'transparent'
308
- const borderColor = container.border?.color
309
-
310
- return toContainerStyle({
311
- ...container,
312
- backgroundColor: blendWithStateLayer(container.backgroundColor, tint),
313
- border: container.border === undefined ? undefined : {
314
- ...container.border,
315
- color: borderColor?.type === 'all'
316
- ? {
317
- type: 'all',
318
- value: blendWithStateLayer(borderColor.value, tint) ?? borderColor.value,
319
- }
320
- : borderColor,
321
- },
322
- })
323
- }
@@ -1,11 +0,0 @@
1
- export const defined = <T extends object>(style: T): T => {
2
- const result = {} as T
3
-
4
- for (const key of Object.keys(style) as (keyof T)[]) {
5
- if (style[key] !== undefined) {
6
- result[key] = style[key]
7
- }
8
- }
9
-
10
- return result
11
- }
@@ -1,10 +0,0 @@
1
- import type { IconTokens } from '@helpwave/hightide-design/component-token-resolvers'
2
-
3
- import type { IconStyle } from '../../icons'
4
- import { defined } from './defined'
5
-
6
- export const toIconStyle = (tokens: IconTokens): IconStyle => defined({
7
- color: tokens.color,
8
- size: tokens.size,
9
- strokeWidth: tokens.strokeWidth,
10
- })
@@ -1,16 +0,0 @@
1
- import type { TextStyle } from 'react-native'
2
-
3
- import type { TextStyleTokens } from '@helpwave/hightide-design/component-token-resolvers'
4
-
5
- import { defined } from './defined'
6
-
7
- export const toTextStyle = (tokens: TextStyleTokens): TextStyle => defined({
8
- color: tokens.color,
9
- fontSize: tokens.fontSize,
10
- fontWeight: tokens.fontWeight,
11
- fontFamily: tokens.fontFamily,
12
- lineHeight: tokens.lineHeight,
13
- textAlign: tokens.textAlign,
14
- flex: tokens.flex,
15
- flexShrink: tokens.flexShrink,
16
- })